#13422 - poslundc - Sat Dec 13, 2003 2:14 am
I'm looking at combining my graphics engine with my music engine, and it has me a little bit nervous. Basically because both rely heavily on interrupts, and I'm concerned about collisions occuring between the two. Here's the skinny on it:
- Graphics engine has a HBlank ISR that pretty much has to run and cannot afford to be pre-empted with the short length of time that HBlank lasts.
- Music engine relies on a timer that interrupts at a frequency of 4096 Hz.
My ideal situation would be to have both interrupts enabled, and if the music interrupt is activated during the HBlank ISR then it would be blocked until the HBlank ISR completed (and if the HBlank ISR was activated during the music ISR, then it would interrupt it).
I suppose I can at least change my HBlank ISR so that the first thing it does is set REG_IME to zero, and then just before returning sets REG_IME to 1. The problem with this, though, is that if I understand correctly then it won't simply block my music interrupt, it'll ignore it entirely, and some samples will go missing as a result. I'm guessing that over the VDraw period this could accumulate to become quite a nuisance.
Are there any suggestions as to how I should be dealing with this?
Thanks,
Dan.
- Graphics engine has a HBlank ISR that pretty much has to run and cannot afford to be pre-empted with the short length of time that HBlank lasts.
- Music engine relies on a timer that interrupts at a frequency of 4096 Hz.
My ideal situation would be to have both interrupts enabled, and if the music interrupt is activated during the HBlank ISR then it would be blocked until the HBlank ISR completed (and if the HBlank ISR was activated during the music ISR, then it would interrupt it).
I suppose I can at least change my HBlank ISR so that the first thing it does is set REG_IME to zero, and then just before returning sets REG_IME to 1. The problem with this, though, is that if I understand correctly then it won't simply block my music interrupt, it'll ignore it entirely, and some samples will go missing as a result. I'm guessing that over the VDraw period this could accumulate to become quite a nuisance.
Are there any suggestions as to how I should be dealing with this?
Thanks,
Dan.