![]() |
Routines |
| Prev: 52117 | Up: Map | Next: 52591 |
|
Manually write "
JP Handler_Interrupts" at AliasInterruptRedirect.
|
||||
| GameEntryPoint | 52500 | LD HL,65278 | HL=AliasInterruptRedirect. | |
| 52503 | LD A,195 | Write 195 which is the opcode for the "JP" instruction to *HL. |
||
| 52505 | LD (HL),A | |||
| 52506 | INC HL | Increment HL by one. | ||
| 52507 | LD A,105 | Write 105 to *HL. | ||
| 52509 | LD (HL),A | |||
| 52510 | INC HL | Increment HL by one. | ||
| 52511 | LD A,254 | Write 254 to *HL. | ||
| 52513 | LD (HL),A | |||
|
All will become clear soon...
|
||||
| 52514 | LD HL,62464 | Write 254 to 0260 bytes, starting from InterruptLowOrderByteJumpTable. | ||
| 52517 | LD BC,260 | |||
| WriteInterruptJumpAddress | 52520 | LD A,254 | ||
| 52522 | LD (HL),A | |||
| 52523 | INC HL | |||
| 52524 | DEC BC | |||
| 52525 | LD A,B | |||
| 52526 | OR C | |||
| 52527 | JR NZ,WriteInterruptJumpAddress | |||
| 52529 | LD BC,0 | Write 0000 to: | ||
| 52532 | LD (65534),BC | |||
| 52536 | LD (65532),BC | |||
| 52540 | LD (65531),BC | |||
| 52544 | DI | Disable interrupts. | ||
| 52545 | LD HL,64000 | Write MelodyData_ThemeTune to *MusicPointerThemeMusic. | ||
| 52548 | LD (65529),HL | |||
|
This sets interrupt mode 2; 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 254 to every address, this means that every generated interrupt will jump to AliasInterruptRedirect, which in turn will jump to Handler_Interrupts.
|
||||
| 52551 | LD A,244 | Set 244 as the high-order byte in I. | ||
| 52553 | LD I,A | |||
| 52555 | IM 2 | Set interrupt mode 2. | ||
| 52557 | LD A,3 | Write 3 to: | ||
| 52559 | LD (65527),A | |||
| 52562 | LD (65528),A | |||
| 52565 | EI | Enable interrupts. | ||
| 52566 | LD HL,41068 | HL=Graphics_MaskSprite. | ||
| 52569 | LD B,128 | B=128. | ||
| 52571 | XOR A | Write 0 to *HL. | ||
| GameEntryPoint_0 | 52572 | LD (HL),A | ||
| 52573 | INC HL | Increment HL by one. | ||
| 52574 | DJNZ GameEntryPoint_0 | Decrease counter by one and loop back to GameEntryPoint_0 until counter is zero. | ||
| 52576 | EXX | Switch to the shadow registers. | ||
| 52577 | PUSH HL | Stash HL' on the stack. | ||
| 52578 | EXX | Switch back to the normal registers. | ||
| 52579 | XOR A | Write 0 to *DF_SZ. | ||
| 52580 | LD (23659),A | |||
| 52583 | LD A,2 | A=2. | ||
| 52585 | CALL 5633 | Call CHAN_OPEN. | ||
| 52588 | JP DisplayIntroductionScreen | Jump to DisplayIntroductionScreen. | ||
| Prev: 52117 | Up: Map | Next: 52591 |