Prev: 49980 Up: Map Next: 50413
50036: Run Frame
Used by the routines at RunLife and ExplodeShip.
Does the work for one frame of the game: increases the frame counter at FrameCounter, saves the position where the ship can restart with SaveRestartPosition (every fourth frame) and clears the scroll speeds. Unless the ship is out of control, it is then moved by UpdateShipSpeeds and tested against the terrain and the map objects. The shots are moved by UpdateShots and the rest of the world by ScrollWorld, which comes back at RunFrame_Draw. Then a part that has just been collected is fitted and the ship is drawn.
RunFrame 50036 LD HL,(39524) The frame counter.
50039 INC HL The next frame.
50040 LD (39524),HL Write the frame counter back.
50043 BIT 0,L On even frames the falling timer is left alone.
50045 JR Z,RunFrame_Counter
50047 LD A,(35183) The falling timer.
50050 AND A Leave it once it has run out.
50051 JR Z,RunFrame_Counter
50053 DEC A One frame less on the timer.
50054 LD (35183),A Write the falling timer back.
RunFrame_Counter 50057 LD A,L The low byte of the frame counter.
50058 AND %00000011 Only the bottom two bits of the frame.
50060 CALL Z,SaveRestartPosition Save the restart position every fourth frame.
50063 PUSH IY Keep the pointer that was in IY.
50065 XOR A The scroll starts at rest.
50066 LD (52411),A No horizontal scroll yet.
50069 LD (52410),A No vertical scroll yet.
50072 LD A,(36691) The ship state.
50075 CP 11 State 11 or more means the ship is gone.
50077 JR NC,RunFrame_Shots
50079 LD IX,51429 The ship.
50083 CALL UpdateShipSpeeds Change the ship's speeds from the controls.
50086 LD A,255 The ship uses collision mode 255.
50088 LD (23589),A Remember that mode for the terrain test.
50091 LD A,(38571) The crystal-delivery flag.
50094 AND A A delivered stack skips the terrain test.
50095 JR NZ,RunFrame_Shots
50097 CALL SetShipSpeeds Give the ship the opposite of the scroll, so it stays put.
50100 LD C,48 The ship's collision width is 48.
50102 LD A,(62966) The ninth part flag.
50105 AND A Is the ninth part fitted?
50106 LD B,4 Four extra rows of height without that part.
50108 JR Z,RunFrame_Add Jump to RunFrame_Add if the zero flag is set.
50110 LD B,0 No extra rows.
RunFrame_Add 50112 LD A,(49577) The height of the ship.
50115 ADD A,B Add the extra rows.
50116 LD B,A That is the collision height.
50117 CALL CheckTerrainCollision Test the ship against the terrain.
50120 CALL CheckMapObjectCollisions Test the ship against the map objects.
50123 LD HL,(51436) The ship's horizontal speed.
50126 LD (51454),HL Keep it for the end of the frame.
50129 LD HL,(51438) The ship's vertical speed.
50132 LD (51456),HL Keep it for the end of the frame.
50135 CALL SetShipSpeeds Set the ship speeds from the scroll again.
50138 CALL MoveObject Move the ship by those speeds.
RunFrame_Shots 50141 CALL UpdateShots Call UpdateShots.
50144 JP ScrollWorld Jump to ScrollWorld.
This entry point is used by the routine at ScrollWorld.
RunFrame_Draw 50147 POP IY Back to the pointer saved at the start of the frame.
50149 LD A,(38571) The crystal-delivery flag.
50152 AND A A delivered stack draws nothing more this frame.
50153 RET NZ
50154 LD A,(36691) The ship state.
50157 CP 11 An explosion past ten draws nothing more.
50159 RET NC
50160 CALL StartCrystalObject Call StartCrystalObject.
50163 LD A,(39524) The frame counter.
50166 AND %00000001 Bit 0 set means an odd frame.
50168 JR NZ,RunFrame_Ship Jump to RunFrame_Ship if the zero flag is clear.
50170 CALL CheckItemDelivery Call CheckItemDelivery.
50173 LD A,(51460) The carried-item marker.
50176 AND A Jump to RunFrame_Ship if A is not zero.
50177 JR NZ,RunFrame_Ship
50179 LD A,(36691) The ship state.
50182 CP 10 State ten skips the flame test.
50184 JR Z,RunFrame_Ship
50186 LD A,(48146) A finished slope check skips the flames.
50189 AND A Jump to RunFrame_Ship if A is not zero.
50190 JR NZ,RunFrame_Ship
50192 LD A,(23606) The steering direction.
50195 AND A Jump to DrawShipTop_Pause if A is zero.
50196 JP Z,DrawShipTop_Pause
50199 LD B,A The direction being steered.
50200 LD A,(51453) The ship's facing.
50203 XOR B Flip the bits of A that are set in B.
50204 BIT 7,A Jump to DrawShipTop_Pause if bit 7 of A is clear.
50206 JP Z,DrawShipTop_Pause
This entry point is used by the routine at UpdateCrystalStack.
RunFrame_Ship 50209 LD HL,0 The draw scratch starts clear.
50212 LD (23580),HL The draw scratch starts at zero.
50215 LD A,(51459) The ship's screen row.
50218 LD (41609),A The row the sprites are drawn on.
50221 LD HL,1542 A width and height of six.
50224 LD (23592),HL The sprite size is six by six.
50227 LD IX,51429 The ship.
50231 LD A,(36691) The ship state.
50234 CP 10 State ten skips the flame colour.
50236 JR Z,RunFrame_Erase
50238 LD C,(IX+24) The ship's facing.
50241 LD A,(23606) The direction being steered.
50244 AND A Jump to RunFrame_Check if A is zero.
50245 JR Z,RunFrame_Check
50247 XOR C Compare it with the facing byte.
50248 AND %10000000 Only the facing bit.
50250 LD (51136),A Note that the steering and the facing differ.
50253 JR Z,RunFrame_Check Jump to RunFrame_Check if the zero flag is set.
50255 XOR A Clear A.
50256 LD (23609),A Clear the shot scratch.
RunFrame_Erase 50259 LD HL,(51458) Where the ship was drawn.
50262 LD (49027),HL Keep that, so it can be erased.
50265 LD DE,(49578) The ship graphic in the buffer.
50269 LD A,(49577) The height of the ship.
50272 LD (23580),A The height, kept for the draw.
50275 LD IY,42537 The erase aligned row directly.
50279 CALL SelectMirroredErase Call SelectMirroredErase.
50282 LD HL,(49027) Fetch the word at 49027 into HL.
50285 CALL GetScreenAddress Call GetScreenAddress.
50288 EXX Switch to the alternate registers.
50289 LD A,(IX+31) Read offset 31 of IX.
50292 AND A Jump to RunFrame_Check if A is zero.
50293 JR Z,RunFrame_Check
50295 BIT 7,A Jump to RunFrame_FitPart if bit 7 of A is clear.
50297 JR Z,RunFrame_FitPart
50299 CALL BuildCarriedItemGraphic Call BuildCarriedItemGraphic.
50302 LD A,128 A=128.
50304 LD (49786),A A piece has been drawn.
50307 JR RunFrame_Facing Jump to RunFrame_Facing.
RunFrame_FitPart 50309 LD B,A B=A.
50310 DEC A Step A back.
50311 LD HL,62958 The first part flag.
50314 CALL AddAToHL Call AddAToHL.
50317 LD (HL),B Write B where HL points.
50318 CALL DrawSpritesDirectly Call DrawSpritesDirectly.
50321 CALL BuildShip Call BuildShip.
50324 LD A,128 A=128.
50326 LD (49786),A A piece has been drawn.
50329 LD IX,51429 The ship.
50333 LD HL,0 HL=0.
50336 LD (23580),HL No saved row count.
50339 LD HL,1542 HL=1542.
50342 LD (23592),HL The ship sprite is six bytes wide.
50345 JR RunFrame_Facing Jump to RunFrame_Facing.
RunFrame_Check 50347 LD A,(IX+31) Read offset 31 of IX.
50350 AND A Jump to RunFrame_Erase if A is not zero.
50351 JR NZ,RunFrame_Erase
RunFrame_Facing 50353 LD A,(23606) The steering direction.
50356 AND A Jump to RunFrame_Explosion if A is zero.
50357 JR Z,RunFrame_Explosion
50359 LD (IX+24),A Write A to offset 24 of IX.
RunFrame_Explosion 50362 LD A,(36691) The ship state.
50365 CP 10 Jump to RunFrame_DrawShip if A is 10.
50367 JR Z,RunFrame_DrawShip
50369 LD A,(51459) The row the ship was drawn on.
50372 LD (41610),A The row the ship was drawn on.
50375 LD DE,(49578) Fetch the word at ShipBufferAddress into DE.
50379 LD HL,(51458) Fetch the word at 51458 into HL.
50382 LD (49027),HL The position the ship was drawn at.
50385 CALL GetScreenAddress Call GetScreenAddress.
50388 LD A,(49577) The height of the ship.
50391 LD (23581),A The height of the ship.
50394 LD IX,42616 The draw aligned row directly.
50398 CALL SelectMirroredDraw Call SelectMirroredDraw.
RunFrame_DrawShip 50401 CALL DrawSpritesDirectly Call DrawSpritesDirectly.
50404 CALL ColourShip Call ColourShip.
50407 LD A,(36691) The ship state.
50410 CP 10 Return if A is 10 or more.
50412 RET NC
Continue on to DrawShipTop.
Prev: 49980 Up: Map Next: 50413