#136327 - alwbsok - Tue Jul 31, 2007 1:49 pm
I'm developing two programs in very early stages of development. Both I've put in very similar temporary code to count screen refreshes, and to perform an action when a certain number of screen refreshes have taken place. The basic system between them is to load VCOUNT and check whether it's greater or equal to 160. The program then increments a counter in the IWRAM and checks to see if it equals the desired number. After the program either increments the counter or resets it and performs the action, it then goes into a loop checking VCOUNT again with a simple ldrh-cmp-bge loop until vblank ends (so as not to detect the same vblank twice).
However, this approach doesn't seem to work very well. I've tried the program on VBA (SDL version), the NO$GBA debugger, and the hardware itself. On VBA, the event happens very slowly, several times slower than designed. On the hardware, the events don't happen at all. On NO$GBA, the events don't happen immediately, but as soon as I enter debug mode (pausing the emulation), and immediately resume emulation without making changes, the event occurs once and seems to await another manual interrupt to continue functioning.
Debugging is rather difficult, since VBA seems to work (sort of), and entering debugging mode in NO$GBA seems to temporarily correct the problem. However, from what I've gathered from using breakpoints in NO$GBA, the program gets trapped in the final loop (the simple ldrh-cmp-bge loop that checks for vdraw).
Has anyone else found similar problems when synchronising with the screen without interrupts? Why does the manual interrupting of the NO$GBA emulator make a difference to program flow?
I'd rather not post my code if possible, because it contains a lot of manually entered background and sprite data, and thus require a bit of editing. It's also not particularly readable. However, I'd be happy to post an edited version of the program if it's required to diagnose the problem.
However, this approach doesn't seem to work very well. I've tried the program on VBA (SDL version), the NO$GBA debugger, and the hardware itself. On VBA, the event happens very slowly, several times slower than designed. On the hardware, the events don't happen at all. On NO$GBA, the events don't happen immediately, but as soon as I enter debug mode (pausing the emulation), and immediately resume emulation without making changes, the event occurs once and seems to await another manual interrupt to continue functioning.
Debugging is rather difficult, since VBA seems to work (sort of), and entering debugging mode in NO$GBA seems to temporarily correct the problem. However, from what I've gathered from using breakpoints in NO$GBA, the program gets trapped in the final loop (the simple ldrh-cmp-bge loop that checks for vdraw).
Has anyone else found similar problems when synchronising with the screen without interrupts? Why does the manual interrupting of the NO$GBA emulator make a difference to program flow?
I'd rather not post my code if possible, because it contains a lot of manually entered background and sprite data, and thus require a bit of editing. It's also not particularly readable. However, I'd be happy to post an edited version of the program if it's required to diagnose the problem.