Prev: CB95 Up: Map Next: CD6F
CD14: Game Entry Point
Manually write "JP Handler_Interrupts" at AliasInterruptRedirect.
GameEntryPoint CD14 LD HL,$FEFE HL=AliasInterruptRedirect.
CD17 LD A,$C3 Write C3 which is the opcode for the "JP" instruction to *HL.
CD19 LD (HL),A
CD1A INC HL Increment HL by one.
CD1B LD A,$69 Write 69 to *HL.
CD1D LD (HL),A
CD1E INC HL Increment HL by one.
CD1F LD A,$FE Write FE to *HL.
CD21 LD (HL),A
All will become clear soon...
CD22 LD HL,$F400 Write FE to 0104 bytes, starting from InterruptLowOrderByteJumpTable.
CD25 LD BC,$0104
WriteInterruptJumpAddress CD28 LD A,$FE
CD2A LD (HL),A
CD2B INC HL
CD2C DEC BC
CD2D LD A,B
CD2E OR C
CD2F JR NZ,WriteInterruptJumpAddress
CD31 LD BC,$0000 Write 0000 to:
CD34 LD ($FFFE),BC
CD38 LD ($FFFC),BC
CD3C LD ($FFFB),BC
CD40 DI Disable interrupts.
CD41 LD HL,$FA00 Write MelodyData_ThemeTune to *MusicPointerThemeMusic.
CD44 LD ($FFF9),HL
This sets interrupt mode 02; when the system generates an interrupt, it'll use the high-order byte set here, together with a low-order byte generated from the system to form a 16-bit address to jump to.
As we've just set FE to every address, this means that every generated interrupt will jump to AliasInterruptRedirect, which in turn will jump to Handler_Interrupts.
CD47 LD A,$F4 Set F4 as the high-order byte in I.
CD49 LD I,A
CD4B IM 2 Set interrupt mode 02.
CD4D LD A,$03 Write 03 to:
CD4F LD ($FFF7),A
CD52 LD ($FFF8),A
CD55 EI Enable interrupts.
CD56 LD HL,$A06C HL=Graphics_MaskSprite.
CD59 LD B,$80 B=80.
CD5B XOR A Write 00 to *HL.
GameEntryPoint_0 CD5C LD (HL),A
CD5D INC HL Increment HL by one.
CD5E DJNZ GameEntryPoint_0 Decrease counter by one and loop back to GameEntryPoint_0 until counter is zero.
CD60 EXX Switch to the shadow registers.
CD61 PUSH HL Stash HL' on the stack.
CD62 EXX Switch back to the normal registers.
CD63 XOR A Write 00 to *DF_SZ.
CD64 LD ($5C6B),A
CD67 LD A,$02 A=02.
CD69 CALL $1601 Call CHAN_OPEN.
CD6C JP DisplayIntroductionScreen Jump to DisplayIntroductionScreen.
Prev: CB95 Up: Map Next: CD6F