02-11-2022, 03:55 AM
What are some good general guidelines for optimizing C code for NGPC?
Given that there isn't a big NGPC development scene, that also means there's not a whole lot of documentation/tutorials/guidelines available.
Gameboy, on the other hand, has some, and I found this page that has some advice for optimizing C code for GB:
https://gbdev.io/to_c_or_not_to_c.html#asm-help
Per the Gameboy optimization recommendations:
1. Use global variables instead of local if possible, because GB is slow at using the stack.
2. Inline instead of using functions if best performance is desired.
I have refactored much of my NGPC code to use a lot more global variables and at least avoid nested function calls, but I don't think it is making a perceivable difference.
In fact, I am getting what I see as very good performance, even with likely inefficient C code.
The main issue I am running into is with hblank effects bogging performance down noticeably when used on real hardware. I can cut those out and get what feels like really good performance.
Do recommendations from GB coding carry over into NGPC and/or are there other recommendations for optimizing C code for NGPC?
Given that there isn't a big NGPC development scene, that also means there's not a whole lot of documentation/tutorials/guidelines available.
Gameboy, on the other hand, has some, and I found this page that has some advice for optimizing C code for GB:
https://gbdev.io/to_c_or_not_to_c.html#asm-help
Per the Gameboy optimization recommendations:
1. Use global variables instead of local if possible, because GB is slow at using the stack.
2. Inline instead of using functions if best performance is desired.
I have refactored much of my NGPC code to use a lot more global variables and at least avoid nested function calls, but I don't think it is making a perceivable difference.
In fact, I am getting what I see as very good performance, even with likely inefficient C code.
The main issue I am running into is with hblank effects bogging performance down noticeably when used on real hardware. I can cut those out and get what feels like really good performance.
Do recommendations from GB coding carry over into NGPC and/or are there other recommendations for optimizing C code for NGPC?

