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.
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
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
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:
load_some_stuff:: ld A,[$FF40] ld [$C000],A ;etc, etc, whatever ret
In your .c file:
//... load_some_stuff() //...
Worst case scenario, you can always go the trial and error route. =]
Offline