Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2015-08-10 19:46:31

BenMcLean
New member
Registered: 2015-08-10
Posts: 1

Using GBDK and assembly both together?

Can I write part of my game in C using GBDK and then just only write the bits that really need heavy optimization in assembly?

That seems like it would be the ideal process for Gameboy development, because assembly is a pain in the backside to work with on any large project, but necessary for really fast code. However, not all of your code has to be really fast.

How would I call an assembly ... "function"? "module"? from my C code?

How would the GBDK and the assembly portions know to not screw up the memory each other are using?

Offline

 

#2 2015-08-11 19:00:51

Xephyr
Member
From: France
Registered: 2015-02-26
Posts: 59

Re: Using GBDK and assembly both together?

According to the GBDK wiki, you can compile .asm and .c files in different object files and then link them directly :
http://gbdk.sourceforge.net/tools.html

I don't know if you can write assembly directly in your .c file however.
The compiler should theoretically take care of the memory usage.

As I haven't really try assembly yet, I don't know how to call a function from a C code. Maybe you could simply write at a specific location and if there's a value, the function runs? Not the efficient way but that should work.

Offline

 

#3 2015-08-14 01:42:39

l0k1
Member
Registered: 2014-10-23
Posts: 44

Re: Using GBDK and assembly both together?

I'd assume that what you'd want to do is split out the .c and the .asm files, and write assembly functions you'd call from C. My C is terribly rusty, so forgive some syntax errors, but probably something like this.

In your .asm file:

Code:

load_some_stuff::
ld A,[$FF40]
ld [$C000],A
;etc, etc, whatever
ret

In your .c file:

Code:

//...
load_some_stuff()
//...

Worst case scenario, you can always go the trial and error route. =]

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson