Prev: 25389 Up: Map Next: 25470
25423: Run Main Loop
Used by the routines at SpawnBonusItem and UpdateBonusItem.
The main game loop. The objects from State_Robbie_Active onwards are 8 bytes each, and the loop calls the update routine for the type of each object in turn (see JumpTable_Main). Every update routine returns to NewActor, which moves on to the next object.
A pass starts here with the flower object at State_Flower and carries on up to the last object (the explosion at State_Explosion), then the next pass is started here again. Whenever the frame counter has changed, FrameUpdate is called to update the first four objects (Robbie, the spray can and the two weapons) once. This means that these are updated on every frame no matter how long a pass through the other objects takes.
Start a new pass through the objects.
MainLoop_NewPass 25423 LD SP,23808 SP=23808.
25426 EI Enable interrupts.
25427 LD IX,24204 IX=State_Flower (the flower object).
25431 XOR A Write 0 to CurrentBug_ID to reset the enemy counter.
25432 LD (24086),A
This entry point is used by the routines at FrameUpdate and NewActor.
Check whether the frame counter has changed.
MainLoop 25435 LD A,(23672) Compare FRAMES and LastFrame.
25438 LD C,A
25439 LD A,(24095)
25442 CP C If they are not equal call FrameUpdate to update the fast objects.
25443 CALL NZ,FrameUpdate
Every update routine returns to NewActor.
25446 LD HL,28976 HL=NewActor (the routine which moves onto the next object).
25449 PUSH HL Stash the return address on the stack.
Find the update routine for the type of the object.
25450 LD HL,25470 HL=JumpTable_Main.
25453 LD A,(IX+0) A=*IX+0 (the object state).
25456 RLCA Rotate A left once.
25457 AND %01111110 Keep only bits 1-6 (the object type, held in bits 0-5 of the state, multiplied by two).
PerformJump 25459 LD C,A BC=the offset into the jump table.
25460 LD B,0
25462 ADD HL,BC HL=the address of the entry in the jump table.
25463 LD A,(HL) HL=the address of the update routine from the jump table.
25464 INC HL
25465 LD H,(HL)
25466 LD L,A
25467 JP IndirectJump Jump to IndirectJump which does an indirect jump to the jump address.
Prev: 25389 Up: Map Next: 25470