Prev: C374 Up: Map Next: C5FF
C4ED: Draw Ship Top
Used by the routines at UpdateCrystalStack and ExplodeShip.
Draws the top of the ship, which is one of the six sprites for types 01 to 06: the one that is used depends on the horizontal speed of the ship, and type 06 is used while the ship has just been hit. Then it checks for the pause keys with CheckPauseAndSilence and fires the weapons with FireWeapons. Carries on with DrawMainFlame or DrawSideFlames on alternate frames. This is a best reading of the code.
DrawShipTop C4ED LD HL,$0000 HL=00.
C4F0 LD ($5C1C),HL No saved row count.
C4F3 LD IX,$C7BC The ship top object.
C4F7 CALL FetchObjectFrameTable Call FetchObjectFrameTable.
C4FA LD HL,($C7BD) Fetch the word at C7BD into HL.
C4FD LD ($BF83),HL The position of the ship top.
C500 CALL ReadSpriteSize Call ReadSpriteSize.
C503 CALL SetFirstRowGroup Call SetFirstRowGroup.
C506 LD HL,($BF83) Fetch the word at BF83 into HL.
C509 CALL GetScreenAddress Call GetScreenAddress.
C50C LD IY,$A647 The sixth aligned-row erase.
C510 CALL TestDirection Call TestDirection.
C513 JR NZ,DrawShipTop_Frame Jump to DrawShipTop_Frame if the zero flag is clear.
C515 LD IY,$A7CC The sixth mirrored-row erase.
DrawShipTop_Frame C519 EXX Switch to the alternate registers.
C51A LD E,(IX+$00) Read offset 00 of IX into E.
C51D LD A,($C904) The item the ship is about to pick up.
C520 AND A Jump to DrawShipTop_Speed if A is zero.
C521 JR Z,DrawShipTop_Speed
C523 LD A,($5C38) The ship row.
C526 SUB $09 Subtract 09 from A.
C528 LD ($C7BE),A The row of the carried item.
C52B LD ($BF84),A The row the item is drawn on.
C52E LD E,$FF E=FF.
C530 XOR A Clear A.
C531 LD ($C904),A Update the item the ship is about to pick up.
DrawShipTop_Speed C534 LD HL,($C8FE) Fetch the word at C8FE into HL.
C537 LD A,H A=H.
C538 LD H,L H=L.
C539 LD L,A L=A.
C53A LD A,H A=H.
C53B AND A Jump to DrawShipTop_Fast if A is not zero.
C53C JR NZ,DrawShipTop_Fast
C53E LD A,L A=L.
C53F CP $80 Compare A with 80.
C541 LD A,H A=H.
C542 JR NC,DrawShipTop_Fast Jump to DrawShipTop_Fast if the carry flag is clear.
C544 LD A,$80 A=80.
C546 LD ($C7BF),A The ship top faces left.
C549 JR DrawShipTop_Select Jump to DrawShipTop_Select.
DrawShipTop_Fast C54B AND %10000000 Keep the bits of A that are set in 80.
C54D LD ($C7BF),A The facing of the ship top.
C550 CALL NZ,NegateNumber Call NegateNumber if the zero flag is clear.
DrawShipTop_Select C553 LD A,L A=L.
C554 AND %10000000 Keep the bits of A that are set in 80.
C556 RLCA Rotate A left.
C557 SLA H Shift H left.
C559 ADD A,H A gains H.
C55A INC A Advance A.
C55B LD (IX+$00),A Write A to offset 00 of IX.
C55E LD A,($5C3E) The horizontal scroll limit.
C561 LD B,A B=A.
C562 LD A,H A=H.
C563 CP B Jump to DrawShipTop_Hit if A is less than B.
C564 JR C,DrawShipTop_Hit
C566 INC B Advance B.
C567 LD (IX+$00),B Write B to offset 00 of IX.
DrawShipTop_Hit C56A LD A,($8F53) The ship state.
C56D AND A Jump to DrawShipTop_Show if A is not zero.
C56E JR NZ,DrawShipTop_Show
C570 LD A,($C7C1) The hit-flash timer.
C573 AND A Jump to DrawShipTop_Show if A is zero.
C574 JR Z,DrawShipTop_Show
C576 DEC A Step A back.
C577 LD ($C7C1),A Update the hit-flash timer.
C57A LD (IX+$00),$06 Store 06 at offset 00 of IX.
C57E JR DrawShipTop_Position Jump to DrawShipTop_Position.
DrawShipTop_Show C580 LD A,($8F53) The ship state.
C583 CP $0A Jump to DrawShipTop_Draw if A is 0A or more.
C585 JR NC,DrawShipTop_Draw
C587 LD A,($D0BC) The collision kind.
C58A AND A Jump to DrawShipTop_Position if A is not zero.
C58B JR NZ,DrawShipTop_Position
C58D LD A,(IX+$00) Read offset 00 of IX.
C590 CP E Jump to DrawShipTop_Position if A is not E.
C591 JR NZ,DrawShipTop_Position
C593 LD A,($C7C0) The turn flag.
C596 AND A Jump to DrawShipTop_Position if A is not zero.
C597 JR NZ,DrawShipTop_Position
C599 LD ($5C1C),A The ship is not turning.
DrawShipTop_Position C59C CALL FetchObjectFrameTable Call FetchObjectFrameTable.
C59F LD B,$68 B=68.
C5A1 LD A,($C8FD) The ship's facing.
C5A4 BIT 7,A Jump to DrawShipTop_Store if bit 7 of A is clear.
C5A6 JR Z,DrawShipTop_Store
C5A8 LD B,$78 B=78.
DrawShipTop_Store C5AA LD A,B A=B.
C5AB LD ($C7BD),A The column of the ship top.
C5AE LD ($BF83),A The column of the ship top.
C5B1 CALL FetchObjectFrameTable Call FetchObjectFrameTable.
C5B4 CALL ReadSpriteSize Call ReadSpriteSize.
C5B7 CALL SetSecondRowGroup Call SetSecondRowGroup.
C5BA LD IX,$A691 The sixth aligned-row draw.
C5BE CALL TestDirection Call TestDirection.
C5C1 JR NZ,DrawShipTop_Draw Jump to DrawShipTop_Draw if the zero flag is clear.
C5C3 LD IX,$A7F9 The sixth mirrored-row draw.
C5C7 LD A,($BF83) The column of the ship top.
C5CA ADD A,$08 Add 08 to A.
C5CC LD ($BF83),A The column one byte to the right.
DrawShipTop_Draw C5CF CALL DrawSpritesDirectly Call DrawSpritesDirectly.
C5D2 XOR A Clear A.
C5D3 LD ($D0BC),A Update the collision kind.
C5D6 LD A,($C7BC) The ship top object.
C5D9 CP $06 Jump to DrawShipTop_Pause if A is 06.
C5DB JP Z,DrawShipTop_Pause
C5DE LD HL,($BF83) Fetch the word at BF83 into HL.
C5E1 LD A,H A=H.
C5E2 SUB $07 Subtract 07 from A.
C5E4 LD H,A H=A.
C5E5 CALL AttributeAddress Call AttributeAddress.
C5E8 LD (HL),$47 Store 47 at the address in HL.
This entry point is used by the routine at RunFrame.
DrawShipTop_Pause C5EA CALL CheckPauseAndSilence Call CheckPauseAndSilence.
C5ED CALL FireWeapons Call FireWeapons.
C5F0 LD A,($8F53) The ship state.
C5F3 CP $0A Jump to DrawSideFlames if A is 0A or more.
C5F5 JR NC,DrawSideFlames
C5F7 LD A,($9A64) The frame counter.
C5FA AND %00000001 Keep the bits of A that are set in 01.
C5FC JP Z,DrawMainFlame Jump to DrawMainFlame if the zero flag is set.
Continue on to DrawSideFlames.
Prev: C374 Up: Map Next: C5FF