Prev: C279 Up: Map Next: C331
C27F: Draw Piece
Used by the routine at CheckItemDelivery.
Draws one of the two pieces that are next to the ship, if there is one. The position of the piece is at IX and its sprite is in DE. Pieces that are being delivered are drawn directly to the screen with DrawSpritesDirectly.
Input
DE Address of the sprite
IX Address of the position
DrawPiece C27F PUSH DE Stash DE on the stack.
C280 LD A,($C279) The piece flags.
C283 BIT 6,A Jump to DrawPiece_Draw if bit 6 of A is set.
C285 JR NZ,DrawPiece_Draw
C287 AND A Jump to DrawPiece_Done if A is zero.
C288 JR Z,DrawPiece_Done
C28A LD B,A B=A.
C28B LD A,($C27A) A piece has already been drawn.
C28E AND A Jump to DrawPiece_Draw if A is not zero.
C28F JR NZ,DrawPiece_Draw
C291 LD A,($C8FD) The ship's facing.
C294 XOR B Flip the bits of A that are set in B.
C295 BIT 7,A Jump to DrawPiece_Done if bit 7 of A is clear.
C297 JR Z,DrawPiece_Done
DrawPiece_Draw C299 LD A,($5C1D) The height of the piece.
C29C LD ($5C1C),A Keep the height of the piece.
C29F LD L,(IX+$00) Read offset 00 of IX into L.
C2A2 LD H,(IX+$01) Read offset 01 of IX into H.
C2A5 LD A,H A=H.
C2A6 LD ($A289),A Update the row offsets.
C2A9 LD A,($5C1C) The height of the piece.
C2AC CALL LimitHeight Call LimitHeight.
C2AF LD A,B A=B.
C2B0 LD ($5C1C),A The height, kept below the top of the playfield.
C2B3 LD ($BF83),HL The position of the piece.
C2B6 LD IY,$A62F The second aligned-row erase.
C2BA LD A,($5C28) The piece width in bytes.
C2BD CP $05 Jump to DrawPiece_Draw2 if A is 05.
C2BF JR Z,DrawPiece_Draw2
C2C1 LD IY,$A63B The fourth aligned-row erase.
DrawPiece_Draw2 C2C5 LD A,($C279) The piece flags.
C2C8 CALL SelectMirroredErase_Entry Call SelectMirroredErase_Entry.
C2CB LD HL,($BF83) Fetch the word at BF83 into HL.
C2CE CALL GetScreenAddress Call GetScreenAddress.
C2D1 EXX Switch to the alternate registers.
DrawPiece_Done C2D2 POP DE Bring DE back off the stack.
C2D3 LD A,($C279) The piece flags.
C2D6 BIT 6,A Jump to DrawPiece_Ship if bit 6 of A is clear.
C2D8 JR Z,DrawPiece_Ship
C2DA XOR A Clear A.
C2DB LD ($5C1D),A Draw the piece straight to the screen.
C2DE JP DrawSpritesDirectly Jump to DrawSpritesDirectly.
DrawPiece_Ship C2E1 LD (IX+$00),$68 Store 68 at offset 00 of IX.
C2E5 LD A,($5C38) The ship row.
C2E8 SUB $0D Subtract 0D from A.
C2EA LD (IX+$01),A Write A to offset 01 of IX.
C2ED LD HL,$A67D The second aligned-row draw.
C2F0 LD A,($5C29) The piece width in bytes.
C2F3 CP $05 Jump to DrawPiece_Mask if A is 05.
C2F5 JR Z,DrawPiece_Mask
C2F7 LD (IX+$00),$78 Store 78 at offset 00 of IX.
C2FB LD A,(IX+$01) Read offset 01 of IX.
C2FE SUB $23 Subtract 23 from A.
C300 LD (IX+$01),A Write A to offset 01 of IX.
C303 LD HL,$A687 The fourth aligned-row draw.
DrawPiece_Mask C306 LD A,($C8FD) The ship's facing.
C309 BIT 7,A Jump to DrawPiece_Position if bit 7 of A is clear.
C30B JR Z,DrawPiece_Position
C30D LD (IX+$00),$60 Store 60 at offset 00 of IX.
DrawPiece_Position C311 PUSH HL Stash HL on the stack.
C312 LD L,(IX+$00) Read offset 00 of IX into L.
C315 LD H,(IX+$01) Read offset 01 of IX into H.
C318 LD A,H A=H.
C319 LD ($A28A),A The row the piece is drawn on.
C31C LD A,($5C1D) The height of the piece.
C31F CALL LimitHeight Call LimitHeight.
C322 LD A,B A=B.
C323 LD ($5C1D),A The height of the piece.
C326 CALL GetScreenAddress Call GetScreenAddress.
C329 POP IX Bring IX back off the stack.
C32B CALL SelectMirroredDraw Call SelectMirroredDraw.
C32E JP DrawSpritesDirectly Jump to DrawSpritesDirectly.
Prev: C279 Up: Map Next: C331