Xenon (NGPC homebrew): stuck on optimisation, could use a second pair of eyes
I've been working on getting my Neo Geo Pocket Color project to run at a stable 30 fps for over a week now, and I've run out of ideas.
I went through it systematically with Claude, measuring block by block, and it can't find anything else either. So either this is as good as it gets, or someone with real experience on this hardware will spot something I don't.
The project is a vertical shoot 'em up in the style of Xenon 2, written in C89 for the TLCS-900H and built with cc900. Source and ROM are here:
https://github.com/Napsterix/xenon-ngpc
About the numbers at the bottom of the screen, that's a measurement display I built in.
The one on the right is VBlanks per 30 game frames in the current window. The one on the left is the average over the last 30 windows, so roughly 30 seconds. Scale: 60 means 30 fps, 90 means 20 fps, lower is better.
The problem: I'm averaging somewhere between 90 and 115. Compute time per frame sits just barely above 2 VBlanks, so the frame keeps flipping between 2 and 3. Since every movement value in the game is per frame, that also makes the game speed visibly wobble. Enemies speed up and slow down as you watch.
Here's what I measured, disabling one block at a time with the frame cap off, then confirming the ranking on real hardware:
Of that 26 percent for drawing, I can only account for about 5 percent through the individual sub parts I can switch off. The rest is spread across code I haven't managed to break down properly yet.
Things I already tried that made no measurable difference at all: moving animations to the end of the frame, skipping animation cells that are off screen, reading animation data from RAM instead of ROM, changing the OAM allocation order (two different approaches), shadow OAM, and flicker multiplexing for player shots. All of them got built, measured, and ripped back out. Every single one came out at plus minus zero.
To get under the 2 VBlank threshold I need roughly 17 percent off the frame. I'd really rather not cut the game down to 20 fps, so I'm asking here: does anyone see something I'm missing? Any pointer would be appreciated.
I've been working on getting my Neo Geo Pocket Color project to run at a stable 30 fps for over a week now, and I've run out of ideas.
I went through it systematically with Claude, measuring block by block, and it can't find anything else either. So either this is as good as it gets, or someone with real experience on this hardware will spot something I don't.
The project is a vertical shoot 'em up in the style of Xenon 2, written in C89 for the TLCS-900H and built with cc900. Source and ROM are here:
https://github.com/Napsterix/xenon-ngpc
About the numbers at the bottom of the screen, that's a measurement display I built in.
The one on the right is VBlanks per 30 game frames in the current window. The one on the left is the average over the last 30 windows, so roughly 30 seconds. Scale: 60 means 30 fps, 90 means 20 fps, lower is better.
The problem: I'm averaging somewhere between 90 and 115. Compute time per frame sits just barely above 2 VBlanks, so the frame keeps flipping between 2 and 3. Since every movement value in the game is per frame, that also makes the game speed visibly wobble. Enemies speed up and slow down as you watch.
Here's what I measured, disabling one block at a time with the frame cap off, then confirming the ranking on real hardware:
- sprite drawing: about 26 percent of frame time
- enemy update: about 18 percent
- everything else (terrain animation, collisions, HUD, worms, shot systems): roughly 1 percent each or less
Of that 26 percent for drawing, I can only account for about 5 percent through the individual sub parts I can switch off. The rest is spread across code I haven't managed to break down properly yet.
Things I already tried that made no measurable difference at all: moving animations to the end of the frame, skipping animation cells that are off screen, reading animation data from RAM instead of ROM, changing the OAM allocation order (two different approaches), shadow OAM, and flicker multiplexing for player shots. All of them got built, measured, and ripped back out. Every single one came out at plus minus zero.
To get under the 2 VBlank threshold I need roughly 17 percent off the frame. I'd really rather not cut the game down to 20 fps, so I'm asking here: does anyone see something I'm missing? Any pointer would be appreciated.

