Prev: E3DE Up: Map Next: E51D
E46C: Handler: Interrupts
IM 02 lands here from AliasInterruptRedirect. Plays the next tune note every five ticks and services any pending sound.
Handler_Interrupts E46C PUSH AF Stash AF, BC, DE, HL and IX.
E46D PUSH BC
E46E PUSH DE
E46F PUSH HL
E470 PUSH IX
E472 LD A,R Return unless bit 7 of the refresh register is set.
E474 BIT 7,A
E476 RET Z
E477 LD A,($646E) Increase *InterruptTick and return unless it reached 05.
E47A INC A
E47B LD ($646E),A
E47E CP $05
E480 JR NZ,Handler_Interrupts_Done
E482 XOR A Write 00 to *InterruptTick.
E483 LD ($646E),A
E486 LD A,($6472) Call Sound_Score if bit 4 of *SoundFlags is set.
E489 BIT 4,A
E48B CALL NZ,Sound_Score
E48E LD A,($6473) Jump to Handler_Interrupts_Beep if *SoundDuration is set.
E491 OR A
E492 JP NZ,Handler_Interrupts_Beep
E495 LD BC,$1106 Call Play_Tune with note length 1106.
E498 CALL Play_Tune
Handler_Interrupts_Done E49B POP IX Restore the stashed registers from the stack.
E49D POP HL
E49E POP DE
E49F POP BC
E4A0 POP AF
E4A1 EI Enable interrupts.
E4A2 RET Return.
Handler_Interrupts_Beep E4A3 DEC A Decrease *SoundDuration and play a short beep.
E4A4 LD ($6473),A
E4A7 LD B,$7F
E4A9 LD D,$0C
E4AB CALL Play_Click
E4AE JP Handler_Interrupts_Done Jump to Handler_Interrupts_Done.
This entry point is used by the routine at Handler_RoomSixteen.
Click the speaker D times using a random delay.
Play_Click E4B1 CALL Play_Click_Delay Toggle bit 4 of the speaker for D iterations.
E4B4 OUT ($FE),A
E4B6 CALL Play_Click_Delay
E4B9 OR $10
E4BB OUT ($FE),A
E4BD DEC D
E4BE JR NZ,Play_Click
E4C0 RET
Play_Click_Delay E4C1 PUSH BC Delay by a random count masked with B.
E4C2 CALL JumpTable_GetRandomNumber
E4C5 AND B
E4C6 LD B,A
E4C7 OR A
E4C8 JR Z,Play_Click_Done
Play_Click_Wait E4CA NOP
E4CB NOP
E4CC DJNZ Play_Click_Wait
Play_Click_Done E4CE POP BC A=*Active_BorderColour.
E4CF LD A,($641D)
E4D2 RET Return.
Falling-pitch score sound.
Sound_Score E4D3 AND %11101111 Clear bit 4.
E4D5 LD ($6472),A Write A to *SoundFlags.
E4D8 LD DE,$0032 DE=0032.
E4DB LD BC,$0064 BC=0064.
E4DE JP Sound_Square Jump to Sound_Square.
This entry point is used by the routine at Handler_Combination.
Square-wave sound while DE and BC count down.
Sound_Square E4E1 CALL JumpTable_Delay Toggle the speaker until both counters are zero.
E4E4 LD A,($641D)
E4E7 OUT ($FE),A
E4E9 CALL JumpTable_Delay
E4EC LD A,($641D)
E4EF OR $10
E4F1 OUT ($FE),A
E4F3 DEC BC
E4F4 LD A,C
E4F5 OR B
E4F6 JR Z,Sound_Square_Done
E4F8 DEC DE
E4F9 LD A,D
E4FA OR E
E4FB JR NZ,Sound_Square
Sound_Square_Done E4FD LD A,($6472) A=*SoundFlags.
E500 RET Return.
This entry point is used by the routines at Handler_InventoryItems and Handler_Combination.
Rising-pitch pickup sound.
Sound_Pickup E501 CALL JumpTable_Delay Toggle the speaker while increasing BC.
E504 LD A,($641D)
E507 OUT ($FE),A
E509 CALL JumpTable_Delay
E50C LD A,($641D)
E50F OR $10
E511 OUT ($FE),A
E513 INC BC
E514 DEC DE
E515 LD A,E
E516 OR D
E517 JR NZ,Sound_Pickup
E519 LD A,($6472)
E51C RET
View the equivalent code in Booty.
Prev: E3DE Up: Map Next: E51D