Prev: 25640 Up: Map Next: 25734
25687: Run Main Loop
Used by the routine at CreateActor.
The main loop of the game. Each pass through the loop runs the handler for one actor. The handler is chosen by the actor ID, using the table at ActorHandlers. The address of NextActor is put on the stack first, so that when the handler returns, the game moves on to the next actor.
A pass is started at MainLoop_NewPass with the first of the six actors which start at ActorSpawnSlots. Whenever the frame counter has changed, FrameUpdate runs an extra pass over the first four actors (which are Charlie and the sound effect actor).
Input
IX Actor
MainLoop_NewPass 25687 LD SP,24320 Set the stack pointer to SecurityCheck.
25690 EI Enable interrupts.
25691 LD IX,24405 Start with the first of the six spawn slots (ActorSpawnSlots).
25695 XOR A Write 0 to ActorsInPlay to reset the current nasties.
25696 LD (24347),A
This entry point is used by the routines at FrameUpdate and NextActor.
Run the frame update if the frame counter has changed.
MainLoop 25699 LD A,(23672) Compare FRAMES and LastFrame.
25702 LD C,A
25703 LD A,(24354)
If interrupts are enabled, then FrameUpdate will be called and DI executed.
25706 CP C If they are not equal call FrameUpdate.
25707 CALL NZ,FrameUpdate
Make the handler return to NextActor, then find the handler.
25710 LD HL,29091 Point HL at NextActor (the routine for the next actor).
25713 PUSH HL Stash it on the stack, so that the handler returns to it.
25714 LD HL,25734 Point HL at ActorHandlers.
25717 LD A,(IX+0) Fetch the actor ID.
This entry point is used by the routine at HandleMonster.
MainLoop_Dispatch 25720 RLCA Double the ID, as there are two bytes for each handler.
25721 AND %01111110 Keep only bits 1-6 (bits 0-5 of the ID, doubled).
25723 LD C,A Use the result as an offset into the table of handlers.
25724 LD B,0
25726 ADD HL,BC Find the entry for the handler of this actor.
25727 LD A,(HL) Fetch the low byte of the handler address.
25728 INC HL Move onto the high byte.
25729 LD H,(HL) Fetch the high byte of the handler address.
25730 LD L,A Put the low byte in L, so that HL is the address of the handler.
25731 JP 23728 Jump to NMIADD which should just jump to the address in HL.
Prev: 25640 Up: Map Next: 25734