PQ does a lot of stuff like this:
; render a frame..
set1 ie,7 ; master interrupt enable
set1 pcon,0 ; enable halt mode
The issue is that when you turn on ie,7, you might be tempted to handle a base timer interrupt straight away. But that will cause you to run at half speed. The reason is that when ie,7 is turned on, PQ is already late, the source flag for the interrupt is already set.
That means when you reach halt mode, the timer interrupt was already handled, and won't serve to exit halt mode, until another frame or whatever goes by.
The solution that worked for me, was to just have a hacky flag which was like: we just enabled interrupts, wait for another instruction to go by before we actually service any.
Someday we will understand the VMU's interrupts well enough that we can all get rid of our hacky flags, or we can just start calling them normal flags and say the hardware is what's hacky.
PQ does a lot of stuff like this:
The issue is that when you turn on
ie,7, you might be tempted to handle a base timer interrupt straight away. But that will cause you to run at half speed. The reason is that whenie,7is turned on, PQ is already late, the source flag for the interrupt is already set.That means when you reach halt mode, the timer interrupt was already handled, and won't serve to exit halt mode, until another frame or whatever goes by.
The solution that worked for me, was to just have a hacky flag which was like: we just enabled interrupts, wait for another instruction to go by before we actually service any.
Someday we will understand the VMU's interrupts well enough that we can all get rid of our hacky flags, or we can just start calling them normal flags and say the hardware is what's hacky.