Prev: 5C79 Up: Map Next: 5D06
5CD2: Game initialization and interrupt setup
This is the main entry point invoked by the BASIC loader. It performs one-time initialization of the game engine, including setting up the custom interrupt handler (IM 2 mode) and initializing global pointers.
init 5CD2 LD HL,$6BB0 Initialize ptr_state_controls to point to state_controls.
5CD5 LD ($9283),HL
5CD8 LD HL,$6136 Initialize collision_dispatcher_ptr to point to collision_dispatcher
5CDB LD ($8B08),HL
5CDE LD A,$C3 Write the JP opcode to the address that all vector table entries will point to.
5CE0 LD ($FEFE),A
5CE3 LD HL,$6BDB Write the interrupt handler address, completing the JP int_handler instruction.
5CE6 LD ($FEFF),HL
5CE9 LD HL,$FC00 Point HL to the start of interrupt vector table.
5CEC LD B,$00 Prepare to iterate 256 times.
int_vector_table_write_loop 5CEE LD (HL),$FE Write INT_VECTOR_ENTRY to the current vector table entry.
5CF0 INC HL
5CF1 DJNZ int_vector_table_write_loop
5CF3 LD (HL),$FE Write INT_VECTOR_ENTRY to the final vector table entry.
5CF5 LD A,$FC Set the I register to the high byte of the interrupt vector table address.
5CF7 LD I,A
5CF9 LD ($5F83),SP
5CFD IM 2 Set interrupt mode 2 (vectored interrupts).
5CFF EI
5D00 LD HL,$8182 Store the address of msg_credits in ptr_scroller.
5D03 LD ($5F7E),HL
Prev: 5C79 Up: Map Next: 5D06