#74051 - edwdig - Thu Mar 02, 2006 12:27 am
I've got a glitch in my game that's happening randomly and very infrequently. Sometimes you can play for 10 minutes and not see it happen, other times it'll happen once a minute or so.
As far as I can tell, what's happening is my HDMA doesn't run for one frame. It's also possible that I'm somehow completely skipping an entire frame. The screen turns to garbage for what I'm assuming is 1 frame, then everything continues as if nothing happens. If you're only half paying attention to the game then you won't even notice anything happened.
I'm using HDMA to reprogram the BGxCNT registers. My backgrounds tend to use all the available tile memory. I change BGxCNT partway through the screen drawing to change the characer base block. I originally used interrupts to change it, but switched to HDMA in hopes that it would solve the bug. Didn't make a significant difference.
Using the change the background color trick, my CPU usage tends to peak at about 1/2 the CPU power, so my processing isn't spilling over into the next frame.
I'm using Krawall (non-commercial edition) for my music & sfx. As far as I can tell the sound isn't glitching when the graphics do.
I also did another test to see if I'm somehow losing VBlank interrupts. I created a VBlank handler that simply sets a variable to one. My main loop resets that variable to zero when the CPU wakes up after VBlank. Before I start the VBlank wait, I check if the variable is one and print a debugging message if so. This should tell me if a VBlank occured while my game code was running. The only time I seem to be missing VBlanks is while loading a level, which isn't an issue.
Any thoughts on how I can track this down? As far as I can tell, either a VBlank is getting eaten and never detected by anything, or HDMA just fails once every thousand times or so.
As far as I can tell, what's happening is my HDMA doesn't run for one frame. It's also possible that I'm somehow completely skipping an entire frame. The screen turns to garbage for what I'm assuming is 1 frame, then everything continues as if nothing happens. If you're only half paying attention to the game then you won't even notice anything happened.
I'm using HDMA to reprogram the BGxCNT registers. My backgrounds tend to use all the available tile memory. I change BGxCNT partway through the screen drawing to change the characer base block. I originally used interrupts to change it, but switched to HDMA in hopes that it would solve the bug. Didn't make a significant difference.
Using the change the background color trick, my CPU usage tends to peak at about 1/2 the CPU power, so my processing isn't spilling over into the next frame.
I'm using Krawall (non-commercial edition) for my music & sfx. As far as I can tell the sound isn't glitching when the graphics do.
I also did another test to see if I'm somehow losing VBlank interrupts. I created a VBlank handler that simply sets a variable to one. My main loop resets that variable to zero when the CPU wakes up after VBlank. Before I start the VBlank wait, I check if the variable is one and print a debugging message if so. This should tell me if a VBlank occured while my game code was running. The only time I seem to be missing VBlanks is while loading a level, which isn't an issue.
Any thoughts on how I can track this down? As far as I can tell, either a VBlank is getting eaten and never detected by anything, or HDMA just fails once every thousand times or so.