![]() |
Routines |
| Prev: CCD2 | Up: Map | Next: CE59 |
|
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 | CD11 | LD A,($A2DF) | Fetch the countdown timer. | |
| CD14 | AND A | Test it. | ||
| CD15 | JR Z,RunFrame_Gauge | Jump to RunFrame_Gauge if it has stopped. | ||
| CD17 | DEC A | Decrease the timer by one and store it. | ||
| CD18 | LD ($A2DF),A | |||
|
Drain the first gauge by 10 and redraw it. If it has run out then the player bursts, provided that it is still the player.
|
||||
| RunFrame_Gauge | CD1B | LD HL,($A59F) | Fetch the target of the first gauge. | |
| CD1E | LD DE,$0010 | Set the amount to drain, 10. | ||
| CD21 | AND A | Take the amount away. | ||
| CD22 | SBC HL,DE | |||
| CD24 | JR C,RunFrame_Burst | Jump to RunFrame_Burst if the gauge has run out. | ||
| CD26 | LD ($A59F),HL | Store the new target of the gauge. | ||
| CD29 | LD IX,$A59D | Point IX at Gauges. | ||
| CD2D | CALL UpdateGauge | Move the bar of the gauge one step towards its target. | ||
| CD30 | JR RunFrame_Spawn | Jump to RunFrame_Spawn. | ||
| RunFrame_Burst | CD32 | LD A,($B540) | Fetch the type of the player entity. | |
| CD35 | DEC A | Decrease it by one. | ||
| CD36 | JR NZ,RunFrame_Spawn | Jump to RunFrame_Spawn if it is not of type 01. | ||
| CD38 | LD IX,$B540 | Point IX at Entities. | ||
| CD3C | CALL StartBurst | Burst the player. | ||
|
Update the points where creatures appear, on every fourth frame.
|
||||
| RunFrame_Spawn | CD3F | LD A,($A2DD) | Fetch the frame counter. | |
| CD42 | AND %00000011 | Use bits 0-1. | ||
| CD44 | CALL Z,UpdateSpawnPoints | Update the spawn points if this is a fourth frame. | ||
|
Control the player, if it is still an entity of type 01. Animate it, and update the direction gauge if the heading has changed.
|
||||
| RunFrame_Player | CD47 | LD IX,$B540 | Point IX at Entities. | |
| CD4B | LD A,(IX+$00) | Fetch the type of the player entity. | ||
| CD4E | DEC A | Decrease it by one. | ||
| CD4F | JP NZ,RunFrame_Draw | Jump to RunFrame_Draw if the player is not of type 01. | ||
| CD52 | CALL ControlPlayer | Read the controls and turn or speed up the player. | ||
| CD55 | CALL AnimateEntity | Animate the player. | ||
| CD58 | LD A,(IX+$11) | Fetch the heading of the player. | ||
| CD5B | XOR (IX+$22) | Find which bits of it have changed since the heading that is shown on the gauge. | ||
| CD5E | AND %00111111 | Keep the bits that give the direction. | ||
| CD60 | 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 01 to 05 is not yet known; the player is held still for them, and the values from F0 on are the player landing.
|
||||
| RunFrame_Counter | CD63 | LD A,($5D00) | Fetch the counter. | |
| CD66 | AND A | Test it. | ||
| CD67 | JR Z,RunFrame_Ground | Jump to RunFrame_Ground if it is not running. | ||
| CD69 | INC A | Add one to the counter. | ||
| CD6A | LD ($5D00),A | Store it. | ||
| CD6D | CP $F0 | Jump to RunFrame_Fall if the player is landing. | ||
| CD6F | JR NC,RunFrame_Fall | |||
| CD71 | CP $02 | Jump to SettlePlayer to settle the player and set the landing frame if it is 02. | ||
| CD73 | JP Z,SettlePlayer | |||
| CD76 | SUB $05 | Take away 05. | ||
| CD78 | JR NZ,SettlePlayer_Continue | Settle the player if the counter is not at 05. | ||
| CD7A | LD ($5D00),A | Stop the counter. | ||
| CD7D | CALL PlayShortRisingSweep | Play the short rising sweep. | ||
| CD80 | JR RunFrame_Update | Jump to RunFrame_Update. | ||
|
Move the player. If it is on the ground then it is not animated.
|
||||
| RunFrame_Ground | CD82 | BIT 7,(IX+$1E) | Jump to RunFrame_Update if it is not on the ground. | |
| CD86 | JR Z,RunFrame_Update | |||
| CD88 | CALL MoveEntity | Move the player. | ||
| CD8B | JR RunFrame_Entities | Jump to RunFrame_Entities. | ||
| RunFrame_Update | CD8D | LD E,(IX+$1F) | Fetch the height of the player above the ground before it moves. | |
| CD90 | PUSH DE | Stash it on the stack. | ||
| CD91 | CALL MoveEntity | Move the player. | ||
| CD94 | POP DE | Restore the old height. | ||
| CD95 | LD A,(IX+$1E) | Read field 1E of the player. | ||
| CD98 | AND %00111111 | Use bits 0-5. | ||
| CD9A | JR NZ,RunFrame_Entities | Jump to RunFrame_Entities if any of them are set. | ||
| CD9C | LD A,(IX+$1F) | Fetch the new height of the player above the ground. | ||
| CD9F | AND A | Test it. | ||
| CDA0 | 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.
|
||||
| CDA2 | LD B,$02 | Use frame 02 if the player is lower than it was. | ||
| CDA4 | CP E | Compare the new height with the old height. | ||
| CDA5 | JR C,RunFrame_SetFrame | Jump to RunFrame_SetFrame if it is lower. | ||
| CDA7 | LD B,$03 | Use frame 03 if the height is less than 04. | ||
| CDA9 | CP $04 | Jump to RunFrame_SetFrame if the height is below 04. | ||
| CDAB | JR C,RunFrame_SetFrame | |||
| CDAD | LD B,$01 | Use frame 01 if the height is less than 0C. | ||
| CDAF | CP $0C | Jump to RunFrame_SetFrame if the height is below 0C. | ||
| CDB1 | JR C,RunFrame_SetFrame | |||
| CDB3 | INC B | Use frame 02 if the height is less than 10. | ||
| CDB4 | CP $10 | Jump to RunFrame_SetFrame if the height is below 10. | ||
| CDB6 | JR C,RunFrame_SetFrame | |||
| CDB8 | LD B,$04 | Use frame 04 if the height is less than 16. | ||
| CDBA | CP $16 | Jump to RunFrame_SetFrame if the height is below 16. | ||
| CDBC | JR C,RunFrame_SetFrame | |||
| CDBE | LD B,$02 | Otherwise use frame 02. | ||
| CDC0 | 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 F0.
|
||||
| RunFrame_Still | CDC2 | OR E | Combine the old height with the new height. | |
| CDC3 | JR Z,RunFrame_Entities | Jump to RunFrame_Entities if the player was already on the ground. | ||
| CDC5 | LD A,$F0 | Start the counter for the player landing. | ||
| CDC7 | LD ($5D00),A | Store it. | ||
| CDCA | JR RunFrame_Frame | Jump to RunFrame_Frame. | ||
| RunFrame_Fall | CDCC | CALL MoveEntity | Move the player. | |
|
Choose the frame of the player from the counter of the landing, which is frame 01 until the counter reaches F2 and then frame 03. The counter is stopped after F3.
|
||||
| RunFrame_Frame | CDCF | LD B,$01 | Use frame 01. | |
| CDD1 | LD A,($5D00) | Fetch the counter. | ||
| CDD4 | CP $F2 | Jump to RunFrame_SetFrame if it is lower. | ||
| CDD6 | JR C,RunFrame_SetFrame | |||
| CDD8 | LD B,$03 | Use frame 03. | ||
| CDDA | SUB $F3 | Take away F3. | ||
| CDDC | JR NZ,RunFrame_SetFrame | Jump to RunFrame_SetFrame if the landing has not finished. | ||
| CDDE | LD ($5D00),A | Stop the counter. | ||
| CDE1 | JR RunFrame_SetFrame | Jump to RunFrame_SetFrame. | ||
|
This entry point is used by the routine at SettlePlayer.
|
||||
| RunFrame_Land | CDE3 | LD B,$03 | Use frame 03. | |
|
Show the frame of the player, and set the size of its sprite, if it has changed.
|
||||
| RunFrame_SetFrame | CDE5 | LD A,(IX+$01) | Read field 01 of the player. | |
| CDE8 | LD C,A | Keep it in C. | ||
| CDE9 | AND %00011111 | Keep the number of the frame. | ||
| CDEB | CP B | Compare it with the new frame. | ||
| CDEC | JR Z,RunFrame_Entities | Jump to RunFrame_Entities if it has not changed. | ||
| CDEE | LD A,C | Fetch the flags in field 01. | ||
| CDEF | AND %11100000 | Keep the flags in bits 5-7. | ||
| CDF1 | OR B | Combine them with the new frame. | ||
| CDF2 | LD (IX+$01),A | Store them. | ||
| CDF5 | CALL SetEntitySize | Set the size of the sprite. | ||
|
This entry point is used by the routine at SettlePlayer.
|
||||
| RunFrame_Entities | CDF8 | LD A,($5CDE) | Read the byte at GameVariable. | |
| CDFB | AND %00010000 | Keep bit 4. | ||
| CDFD | CALL NZ,CreatePuff | Create an entity of type 05 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 | CE00 | CALL ProjectPlayerEntity | Project the player on to the screen. | |
| CE03 | LD IX,$B540 | Point IX at Entities. | ||
| CE07 | CALL ScrollView | Scroll the view to follow the player. | ||
| CE0A | CALL UpdateEntities | Update the other entities. | ||
| CE0D | CALL UpdateExtraRecords | Update the extra records. | ||
| CE10 | CALL BuildDrawList | Build the draw list. | ||
| CE13 | CALL SortDrawList | Sort the draw list. | ||
| CE16 | CALL DrawItems | Draw the items of the draw list. | ||
| CE19 | 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.
|
||||
| CE1C | LD A,($CE59) | Fetch the state of the message. | ||
| CE1F | AND A | Test it. | ||
| CE20 | JR Z,RunFrame_Message | Jump to RunFrame_Message if there is no message. | ||
| CE22 | LD DE,$CE5A | Point DE at ExitClosedMessages. | ||
| CE25 | DEC A | Decrease the state by one. | ||
| CE26 | JR Z,RunFrame_Skip | Jump to RunFrame_Skip if it is the first message. | ||
| CE28 | LD DE,$CE72 | Point DE at ExitClosedMessages_Second. | ||
| RunFrame_Skip | CE2B | CALL PrintText | Print the first part of the message. | |
| CE2E | CALL PrintText | Print the second part of the message. | ||
| CE31 | LD A,($CE59) | Fetch the state of the message. | ||
| CE34 | SRL A | Halve it. | ||
| CE36 | LD ($CE59),A | Store it. | ||
| RunFrame_Message | CE39 | CALL UpdateScreen | Copy the screen buffer to the screen. | |
|
Check what has happened to the player.
|
||||
| CE3C | LD A,($B540) | Fetch the type of the player entity. | ||
| CE3F | AND A | Test it. | ||
| CE40 | JR NZ,RunFrame_Dead | Jump to RunFrame_Dead if the player is still there. | ||
| CE42 | INC A | The player has gone, so set A to 01. | ||
| CE43 | LD ($AA5A),A | Store it to show that a life has been lost. | ||
| CE46 | LD A,($A5A0) | Fetch the high byte of the target of the first gauge. | ||
| CE49 | AND A | Test it. | ||
| CE4A | CALL Z,ScrollTimeOutMessage | Show the time out message if the gauge is empty. | ||
| CE4D | RET | Return. | ||
| RunFrame_Dead | CE4E | LD A,($B542) | Fetch the high byte of the x coordinate of the player. | |
| CE51 | AND A | Test it. | ||
| CE52 | RET Z | Return if it is zero, which is when the player has left the level. | ||
| CE53 | CALL RestoreItemRows | Put the rows of the screen buffer back. | ||
| CE56 | JP RunFrame | Run the next frame. | ||
| Prev: CCD2 | Up: Map | Next: CE59 |