![]() |
Routines |
| Prev: 52434 | Up: Map | Next: 52825 |
|
Used by the routine at RunGame.
Runs one frame of the game. First the timers are updated and then the player is controlled, updated and projected. The view is scrolled, the other entities are updated, and then the draw list is built, sorted and drawn. Finally the messages are updated.
The counter in JumpCounter is used for the player jumping and for the death of the player. Purpose of its values is not yet known.
|
||||
|
Count down the timer, if it is running.
|
||||
| RunFrame | 52497 | LD A,(41695) | Fetch the countdown timer. | |
| 52500 | AND A | Test it. | ||
| 52501 | JR Z,RunFrame_Gauge | Jump to RunFrame_Gauge if it has stopped. | ||
| 52503 | DEC A | Decrease the timer by one and store it. | ||
| 52504 | LD (41695),A | |||
|
Drain the first gauge by 16 and redraw it. If it has run out then the player bursts, provided that it is still the player.
|
||||
| RunFrame_Gauge | 52507 | LD HL,(42399) | Fetch the target of the first gauge. | |
| 52510 | LD DE,16 | Set the amount to drain, 16. | ||
| 52513 | AND A | Take the amount away. | ||
| 52514 | SBC HL,DE | |||
| 52516 | JR C,RunFrame_Burst | Jump to RunFrame_Burst if the gauge has run out. | ||
| 52518 | LD (42399),HL | Store the new target of the gauge. | ||
| 52521 | LD IX,42397 | Point IX at Gauges. | ||
| 52525 | CALL UpdateGauge | Move the bar of the gauge one step towards its target. | ||
| 52528 | JR RunFrame_Spawn | Jump to RunFrame_Spawn. | ||
| RunFrame_Burst | 52530 | LD A,(46400) | Fetch the type of the player entity. | |
| 52533 | DEC A | Decrease it by one. | ||
| 52534 | JR NZ,RunFrame_Spawn | Jump to RunFrame_Spawn if it is not of type 1. | ||
| 52536 | LD IX,46400 | Point IX at Entities. | ||
| 52540 | CALL StartBurst | Burst the player. | ||
|
Update the points where creatures appear, on every fourth frame.
|
||||
| RunFrame_Spawn | 52543 | LD A,(41693) | Fetch the frame counter. | |
| 52546 | AND %00000011 | Use bits 0-1. | ||
| 52548 | CALL Z,UpdateSpawnPoints | Update the spawn points if this is a fourth frame. | ||
|
Control the player, if it is still an entity of type 1. Animate it, and update the direction gauge if the heading has changed.
|
||||
| RunFrame_Player | 52551 | LD IX,46400 | Point IX at Entities. | |
| 52555 | LD A,(IX+0) | Fetch the type of the player entity. | ||
| 52558 | DEC A | Decrease it by one. | ||
| 52559 | JP NZ,RunFrame_Draw | Jump to RunFrame_Draw if the player is not of type 1. | ||
| 52562 | CALL ControlPlayer | Read the controls and turn or speed up the player. | ||
| 52565 | CALL AnimateEntity | Animate the player. | ||
| 52568 | LD A,(IX+17) | Fetch the heading of the player. | ||
| 52571 | XOR (IX+34) | Find which bits of it have changed since the heading that is shown on the gauge. | ||
| 52574 | AND %00111111 | Keep the bits that give the direction. | ||
| 52576 | CALL NZ,UpdateDirectionGauge | Update the direction gauge if the heading has changed. | ||
|
Count the frames of the counter at JumpCounter, if it is running. Purpose of its values from 1 to 5 is not yet known; the player is held still for them, and the values from 240 on are the player landing.
|
||||
| RunFrame_Counter | 52579 | LD A,(23808) | Fetch the counter. | |
| 52582 | AND A | Test it. | ||
| 52583 | JR Z,RunFrame_Ground | Jump to RunFrame_Ground if it is not running. | ||
| 52585 | INC A | Add one to the counter. | ||
| 52586 | LD (23808),A | Store it. | ||
| 52589 | CP 240 | Jump to RunFrame_Fall if the player is landing. | ||
| 52591 | JR NC,RunFrame_Fall | |||
| 52593 | CP 2 | Jump to SettlePlayer to settle the player and set the landing frame if it is 2. | ||
| 52595 | JP Z,SettlePlayer | |||
| 52598 | SUB 5 | Take away 5. | ||
| 52600 | JR NZ,SettlePlayer_Continue | Settle the player if the counter is not at 5. | ||
| 52602 | LD (23808),A | Stop the counter. | ||
| 52605 | CALL PlayShortRisingSweep | Play the short rising sweep. | ||
| 52608 | JR RunFrame_Update | Jump to RunFrame_Update. | ||
|
Move the player. If it is on the ground then it is not animated.
|
||||
| RunFrame_Ground | 52610 | BIT 7,(IX+30) | Jump to RunFrame_Update if it is not on the ground. | |
| 52614 | JR Z,RunFrame_Update | |||
| 52616 | CALL MoveEntity | Move the player. | ||
| 52619 | JR RunFrame_Entities | Jump to RunFrame_Entities. | ||
| RunFrame_Update | 52621 | LD E,(IX+31) | Fetch the height of the player above the ground before it moves. | |
| 52624 | PUSH DE | Stash it on the stack. | ||
| 52625 | CALL MoveEntity | Move the player. | ||
| 52628 | POP DE | Restore the old height. | ||
| 52629 | LD A,(IX+30) | Read field 30 of the player. | ||
| 52632 | AND %00111111 | Use bits 0-5. | ||
| 52634 | JR NZ,RunFrame_Entities | Jump to RunFrame_Entities if any of them are set. | ||
| 52636 | LD A,(IX+31) | Fetch the new height of the player above the ground. | ||
| 52639 | AND A | Test it. | ||
| 52640 | JR Z,RunFrame_Still | Jump to RunFrame_Still if the player is on the ground. | ||
|
Choose the frame of the player from its height above the ground.
|
||||
| 52642 | LD B,2 | Use frame 2 if the player is lower than it was. | ||
| 52644 | CP E | Compare the new height with the old height. | ||
| 52645 | JR C,RunFrame_SetFrame | Jump to RunFrame_SetFrame if it is lower. | ||
| 52647 | LD B,3 | Use frame 3 if the height is less than 4. | ||
| 52649 | CP 4 | Jump to RunFrame_SetFrame if the height is below 4. | ||
| 52651 | JR C,RunFrame_SetFrame | |||
| 52653 | LD B,1 | Use frame 1 if the height is less than 12. | ||
| 52655 | CP 12 | Jump to RunFrame_SetFrame if the height is below 12. | ||
| 52657 | JR C,RunFrame_SetFrame | |||
| 52659 | INC B | Use frame 2 if the height is less than 16. | ||
| 52660 | CP 16 | Jump to RunFrame_SetFrame if the height is below 16. | ||
| 52662 | JR C,RunFrame_SetFrame | |||
| 52664 | LD B,4 | Use frame 4 if the height is less than 22. | ||
| 52666 | CP 22 | Jump to RunFrame_SetFrame if the height is below 22. | ||
| 52668 | JR C,RunFrame_SetFrame | |||
| 52670 | LD B,2 | Otherwise use frame 2. | ||
| 52672 | JR RunFrame_SetFrame | Jump to RunFrame_SetFrame. | ||
|
The player is on the ground. If it was in the air a moment ago it has just landed, so start the counter at 240.
|
||||
| RunFrame_Still | 52674 | OR E | Combine the old height with the new height. | |
| 52675 | JR Z,RunFrame_Entities | Jump to RunFrame_Entities if the player was already on the ground. | ||
| 52677 | LD A,240 | Start the counter for the player landing. | ||
| 52679 | LD (23808),A | Store it. | ||
| 52682 | JR RunFrame_Frame | Jump to RunFrame_Frame. | ||
| RunFrame_Fall | 52684 | CALL MoveEntity | Move the player. | |
|
Choose the frame of the player from the counter of the landing, which is frame 1 until the counter reaches 242 and then frame 3. The counter is stopped after 243.
|
||||
| RunFrame_Frame | 52687 | LD B,1 | Use frame 1. | |
| 52689 | LD A,(23808) | Fetch the counter. | ||
| 52692 | CP 242 | Jump to RunFrame_SetFrame if it is lower. | ||
| 52694 | JR C,RunFrame_SetFrame | |||
| 52696 | LD B,3 | Use frame 3. | ||
| 52698 | SUB 243 | Take away 243. | ||
| 52700 | JR NZ,RunFrame_SetFrame | Jump to RunFrame_SetFrame if the landing has not finished. | ||
| 52702 | LD (23808),A | Stop the counter. | ||
| 52705 | JR RunFrame_SetFrame | Jump to RunFrame_SetFrame. | ||
|
This entry point is used by the routine at SettlePlayer.
|
||||
| RunFrame_Land | 52707 | LD B,3 | Use frame 3. | |
|
Show the frame of the player, and set the size of its sprite, if it has changed.
|
||||
| RunFrame_SetFrame | 52709 | LD A,(IX+1) | Read field 1 of the player. | |
| 52712 | LD C,A | Keep it in C. | ||
| 52713 | AND %00011111 | Keep the number of the frame. | ||
| 52715 | CP B | Compare it with the new frame. | ||
| 52716 | JR Z,RunFrame_Entities | Jump to RunFrame_Entities if it has not changed. | ||
| 52718 | LD A,C | Fetch the flags in field 1. | ||
| 52719 | AND %11100000 | Keep the flags in bits 5-7. | ||
| 52721 | OR B | Combine them with the new frame. | ||
| 52722 | LD (IX+1),A | Store them. | ||
| 52725 | CALL SetEntitySize | Set the size of the sprite. | ||
|
This entry point is used by the routine at SettlePlayer.
|
||||
| RunFrame_Entities | 52728 | LD A,(23774) | Read the byte at GameVariable. | |
| 52731 | AND %00010000 | Keep bit 4. | ||
| 52733 | CALL NZ,CreatePuff | Create an entity of type 5 if the bit is set. | ||
|
Work out where the player is on the screen and scroll the view to follow it. Then update the entities and the extra records, build and sort the draw list, and draw it. If SPACE or CAPS SHIFT is pressed the game is paused here.
|
||||
| RunFrame_Draw | 52736 | CALL ProjectPlayerEntity | Project the player on to the screen. | |
| 52739 | LD IX,46400 | Point IX at Entities. | ||
| 52743 | CALL ScrollView | Scroll the view to follow the player. | ||
| 52746 | CALL UpdateEntities | Update the other entities. | ||
| 52749 | CALL UpdateExtraRecords | Update the extra records. | ||
| 52752 | CALL BuildDrawList | Build the draw list. | ||
| 52755 | CALL SortDrawList | Sort the draw list. | ||
| 52758 | CALL DrawItems | Draw the items of the draw list. | ||
| 52761 | CALL PauseGame | Pause the game if a key is pressed. | ||
|
Print the message that is scrolling in or out, if there is one. It is printed in two parts, one of which is chosen by the state of the message.
|
||||
| 52764 | LD A,(52825) | Fetch the state of the message. | ||
| 52767 | AND A | Test it. | ||
| 52768 | JR Z,RunFrame_Message | Jump to RunFrame_Message if there is no message. | ||
| 52770 | LD DE,52826 | Point DE at ExitClosedMessages. | ||
| 52773 | DEC A | Decrease the state by one. | ||
| 52774 | JR Z,RunFrame_Skip | Jump to RunFrame_Skip if it is the first message. | ||
| 52776 | LD DE,52850 | Point DE at ExitClosedMessages_Second. | ||
| RunFrame_Skip | 52779 | CALL PrintText | Print the first part of the message. | |
| 52782 | CALL PrintText | Print the second part of the message. | ||
| 52785 | LD A,(52825) | Fetch the state of the message. | ||
| 52788 | SRL A | Halve it. | ||
| 52790 | LD (52825),A | Store it. | ||
| RunFrame_Message | 52793 | CALL UpdateScreen | Copy the screen buffer to the screen. | |
|
Check what has happened to the player.
|
||||
| 52796 | LD A,(46400) | Fetch the type of the player entity. | ||
| 52799 | AND A | Test it. | ||
| 52800 | JR NZ,RunFrame_Dead | Jump to RunFrame_Dead if the player is still there. | ||
| 52802 | INC A | The player has gone, so set A to 1. | ||
| 52803 | LD (43610),A | Store it to show that a life has been lost. | ||
| 52806 | LD A,(42400) | Fetch the high byte of the target of the first gauge. | ||
| 52809 | AND A | Test it. | ||
| 52810 | CALL Z,ScrollTimeOutMessage | Show the time out message if the gauge is empty. | ||
| 52813 | RET | Return. | ||
| RunFrame_Dead | 52814 | LD A,(46402) | Fetch the high byte of the x coordinate of the player. | |
| 52817 | AND A | Test it. | ||
| 52818 | RET Z | Return if it is zero, which is when the player has left the level. | ||
| 52819 | CALL RestoreItemRows | Put the rows of the screen buffer back. | ||
| 52822 | JP RunFrame | Run the next frame. | ||
| Prev: 52434 | Up: Map | Next: 52825 |