Prev: 24559 Up: Map Next: 24616
24585: Run Main Loop
Used by the routines at HandlerCup and Pause_Loop.
The game loop. Each pass runs the handler for each of the three entities held from Entity_Player (the player's car and the two opponent cars), in turn. The handler is chosen by the entity state held in the first byte of the entity, using the table at JumpTable_Main. Once every entity has been handled NextEntity plays the engine sound, checks for a pause and starts the loop again.
State Meaning
0 Inactive
1 Player car driving
2 Opponent car driving
3 Player car exploding
MainLoop_NewPass 24585 LD IX,24192 Point IX at the first entity, the player's car (Entity_Player).
24589 LD SP,24064 Set the stack pointer to 24064.
This entry point is used by the routine at NextEntity.
Dispatch the handler for this entity.
MainLoop 24592 LD HL,27251 Stash NextEntity on the stack as the return address for the handler.
24595 PUSH HL
24596 LD HL,24616 Point HL at the table of handlers (JumpTable_Main).
24599 LD A,(IX+0) Fetch the entity state from *IX+0.
24602 RLCA Rotate the state left, ready to use it as an index into the table of words.
24603 AND %01111110 Keep only bits 1-6.
24605 LD C,A Make the offset into the table of handlers in BC.
24606 LD B,0
24608 ADD HL,BC Add the offset to the address of the table.
24609 LD A,(HL) Fetch the address of the handler from the table into HL.
24610 INC HL
24611 LD H,(HL)
24612 LD L,A
24613 JP IndirectJump Jump to the handler via IndirectJump.
Prev: 24559 Up: Map Next: 24616