![]() |
Routines |
| Prev: 42632 | Up: Map | Next: 42825 |
|
Used by the routine at LeaveRoomToWest.
The main game loop. The first call builds the objects of the room. Every pass through RunGame_Frame is one frame: each object is updated, the visible objects are sorted and drawn, the screen is refreshed and the panel is updated.
|
||||||
|
Build the objects of the room.
|
||||||
| RunGame | 42635 | CALL BuildRoomObjects | Call BuildRoomObjects. | |||
|
This entry point is used by the routine at GameOver.
Give every object a chance to update itself.
|
||||||
| RunGame_Frame | 42638 | LD IX,23432 | Point IX at PlayerBottomObject. | |||
| RunGame_NextObject | 42642 | LD SP,61696 | Set the stack pointer to ReversedByteTable. | |||
| 42645 | LD HL,42688 | Point HL at RunGame_ObjectUpdated. | ||||
| 42648 | PUSH HL | Stash the return address on the stack. | ||||
| 42649 | LD A,(IX+24) | Fetch the width of the sprite. | ||||
| 42652 | LD (IX+28),A | Store it as the previous width. | ||||
| 42655 | LD A,(IX+25) | Fetch the height of the sprite. | ||||
| 42658 | LD (IX+29),A | Store it as the previous height. | ||||
| 42661 | LD A,(IX+26) | Fetch the pixel x position of the sprite. | ||||
| 42664 | LD (IX+30),A | Store it as the previous x position. | ||||
| 42667 | LD A,(IX+27) | Fetch the pixel y position of the sprite. | ||||
| 42670 | LD (IX+31),A | Store it as the previous y position. | ||||
|
This entry point is used by the routine at HandleLastAppearingSparkle.
Jump to the update routine for the sprite.
|
||||||
| RunGame_UpdateObject | 42673 | LD L,(IX+0) | Fetch the sprite number into L. | |||
| 42676 | LD BC,42986 | Point BC at ObjectUpdateRoutines. | ||||
|
This entry point is used by the routines at SetPlayerSpeed and DrawObjectsInOrder.
|
||||||
| RunGame_JumpToHandler | 42679 | LD H,0 | Clear the high byte of HL. | |||
| 42681 | ADD HL,HL | Double the sprite number. | ||||
| 42682 | ADD HL,BC | Add the address of the table. | ||||
| 42683 | LD A,(HL) | Fetch the low byte of the routine. | ||||
| 42684 | INC HL | Move on to the high byte. | ||||
| 42685 | LD H,(HL) | Fetch the high byte of the routine. | ||||
| 42686 | LD L,A | Put the low byte in L. | ||||
| 42687 | JP (HL) | Jump to the update routine. | ||||
|
Stir RandomSeed2 from the refresh register.
|
||||||
| RunGame_ObjectUpdated | 42688 | LD A,R | Fetch the refresh register. | |||
| 42690 | LD C,A | Copy it to C. | ||||
| 42691 | LD A,(23301) | Fetch RandomSeed2. | ||||
| 42694 | ADD A,C | Add the refresh register to it. | ||||
| 42695 | LD (23301),A | Set RandomSeed2. | ||||
|
Move on to the next object.
|
||||||
| 42698 | LD BC,32 | Move IX on by 0032 bytes. | ||||
| 42701 | ADD IX,BC | |||||
| 42703 | PUSH IX | Copy IX to HL (using the stack). | ||||
| 42705 | POP HL | |||||
| 42706 | LD BC,25224 | Point BC at UnusedAfterObjects. | ||||
| 42709 | AND A | Subtract UnusedAfterObjects from HL. | ||||
| 42710 | SBC HL,BC | |||||
| 42712 | JR NC,RunGame_FinishFrame | Jump to RunGame_FinishFrame if there are no more objects. | ||||
| 42714 | JR RunGame_NextObject | Jump to RunGame_NextObject. | ||||
|
Stir RandomSeed2 from the ROM byte at FrameCounter.
|
||||||
| RunGame_FinishFrame | 42716 | LD HL,(23298) | Fetch FrameCounter. | |||
| 42719 | INC HL | Move on to the next address. | ||||
| 42720 | LD (23298),HL | Set FrameCounter. | ||||
| 42723 | LD A,(23301) | Fetch RandomSeed2. | ||||
| 42726 | ADD A,(HL) | Add the byte of ROM. | ||||
| 42727 | ADD A,L | Add the low byte of the address. | ||||
| 42728 | ADD A,H | Add the high byte of the address. | ||||
| 42729 | LD (23301),A | Set RandomSeed2. | ||||
| 42732 | LD HL,23314 | Point HL at RoomFlags. | ||||
| 42735 | SET 0,(HL) | Set bit 0 of RoomFlags. | ||||
|
Draw the room into the screen buffer.
|
||||||
| 42737 | CALL ListObjectsToDraw | Call ListObjectsToDraw. | ||||
| 42740 | CALL DrawChangedObjects | Call DrawChangedObjects. | ||||
| 42743 | LD A,(23332) | Fetch GameOverFlag. | ||||
| 42746 | AND A | Jump to RunGame_GameOver if it is set. | ||||
| 42747 | JP NZ,RunGame_GameOver | |||||
|
Slow the game down when few objects are drawn.
|
||||||
| 42750 | LD A,(23326) | Fetch ObjectsDrawn. | ||||
| 42753 | NEG | Negate it. | ||||
| 42755 | ADD A,6 | Add 6. | ||||
| 42757 | LD B,A | Keep the number of delay loops in B. | ||||
| 42758 | JP M,RunGame_UpdateDisplay | Jump to RunGame_UpdateDisplay if there were more than 6 objects. | ||||
| 42761 | JR Z,RunGame_UpdateDisplay | Jump to RunGame_UpdateDisplay if there were exactly 6 objects. | ||||
| RunGame_Delay | 42763 | LD HL,768 | Set the delay counter to 768. | |||
| RunGame_DelayLoop | 42766 | DEC HL | Decrease the delay counter. | |||
| 42767 | LD A,L | Jump to RunGame_DelayLoop until the delay counter is zero. | ||||
| 42768 | OR H | |||||
| 42769 | JR NZ,RunGame_DelayLoop | |||||
| 42771 | DJNZ RunGame_Delay | Jump to RunGame_Delay until all of the delay loops are done. | ||||
|
Update the status panel.
|
||||||
| RunGame_UpdateDisplay | 42773 | CALL UpdateLightYears | Call UpdateLightYears. | |||
| 42776 | LD A,(23319) | Fetch RedrawPanelFlag. | ||||
| 42779 | AND A | Jump to RunGame_Continue if it is not set. | ||||
| 42780 | JR Z,RunGame_Continue | |||||
| 42782 | CALL DrawPanel | Call DrawPanel. | ||||
| 42785 | CALL UpdatePanel | Call UpdatePanel. | ||||
| RunGame_RefreshScreen | 42788 | XOR A | Write 0 to RedrawPanelFlag. | |||
| 42789 | LD (23319),A | |||||
| 42792 | CALL UpdateScreen | Call UpdateScreen. | ||||
| 42795 | CALL ResetWipeFlags | Call ResetWipeFlags. | ||||
|
Check whether the game is paused and whether the player is alive.
|
||||||
| RunGame_Continue | 42798 | CALL PauseGame | Call PauseGame. | |||
| 42801 | LD IX,23432 | Point IX at PlayerBottomObject. | ||||
| 42805 | LD A,(IX+0) | Fetch the sprite number of the player. | ||||
| 42808 | OR (IX+32) | Combine it with the sprite number of PlayerTopObject. | ||||
| 42811 | JP Z,StartLife | Jump to StartLife if both are zero. | ||||
| 42814 | JP RunGame_Frame | Jump to RunGame_Frame. | ||||
|
Only refresh the screen if the panel needs to be redrawn.
|
||||||
| RunGame_GameOver | 42817 | LD A,(23319) | Fetch RedrawPanelFlag. | |||
| 42820 | AND A | Jump to RunGame_Continue if it is not set. | ||||
| 42821 | JR Z,RunGame_Continue | |||||
| 42823 | JR RunGame_RefreshScreen | Jump to RunGame_RefreshScreen. | ||||
|
View the equivalent code in;
|
||||||
| Prev: 42632 | Up: Map | Next: 42825 |