#89445 - Lazy1 - Sat Jun 24, 2006 11:08 pm
I got around to adding sound to wolf3d which aside from clicking and one rare bug seems to work great.
The rare bug I had caused the game to stall for about a second and part of the machinegun sprite had turned corrupt.
I figured that it was caused by the timer interrupt calling the function that was interrupted ( loading pages from a swap file ). But I'm not sure if this is the case and it has only happened once since I added support for sounds that use more than 1 page ( 4kb ).
Would setting REG_IME to 0 in all pagefile functions solve this problem?
As for the clicking, it was majorly reduced by moving all sound updates to a 0.98ms timer running on both the arm7 and arm9 but it's still there and very noticable even if reduced.
The basic cycle of sound is this:
Arm9:
1. Request from engine to play sound
2. Send sound data to arm7
Arm9 Timer2 Interrupt:
1. If the arm7 is requesting another page
1a. Load another page from the swapfile
Arm7 Timer2 Interrupt:
1. Is a sound supposed to be playing but the sound hw is finished
1a. Request another sound page from the arm9
2. Is there a sound request from the arm9
2a. Play sound
The rare bug I had caused the game to stall for about a second and part of the machinegun sprite had turned corrupt.
I figured that it was caused by the timer interrupt calling the function that was interrupted ( loading pages from a swap file ). But I'm not sure if this is the case and it has only happened once since I added support for sounds that use more than 1 page ( 4kb ).
Would setting REG_IME to 0 in all pagefile functions solve this problem?
As for the clicking, it was majorly reduced by moving all sound updates to a 0.98ms timer running on both the arm7 and arm9 but it's still there and very noticable even if reduced.
The basic cycle of sound is this:
Arm9:
1. Request from engine to play sound
2. Send sound data to arm7
Arm9 Timer2 Interrupt:
1. If the arm7 is requesting another page
1a. Load another page from the swapfile
Arm7 Timer2 Interrupt:
1. Is a sound supposed to be playing but the sound hw is finished
1a. Request another sound page from the arm9
2. Is there a sound request from the arm9
2a. Play sound