Prev: 49785 Up: Map Next: 49969
49791: 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 49791 PUSH DE Stash DE on the stack.
49792 LD A,(49785) The piece flags.
49795 BIT 6,A Jump to DrawPiece_Draw if bit 6 of A is set.
49797 JR NZ,DrawPiece_Draw
49799 AND A Jump to DrawPiece_Done if A is zero.
49800 JR Z,DrawPiece_Done
49802 LD B,A B=A.
49803 LD A,(49786) A piece has already been drawn.
49806 AND A Jump to DrawPiece_Draw if A is not zero.
49807 JR NZ,DrawPiece_Draw
49809 LD A,(51453) The ship's facing.
49812 XOR B Flip the bits of A that are set in B.
49813 BIT 7,A Jump to DrawPiece_Done if bit 7 of A is clear.
49815 JR Z,DrawPiece_Done
DrawPiece_Draw 49817 LD A,(23581) The height of the piece.
49820 LD (23580),A Keep the height of the piece.
49823 LD L,(IX+0) Read offset 0 of IX into L.
49826 LD H,(IX+1) Read offset 1 of IX into H.
49829 LD A,H A=H.
49830 LD (41609),A Update the row offsets.
49833 LD A,(23580) The height of the piece.
49836 CALL LimitHeight Call LimitHeight.
49839 LD A,B A=B.
49840 LD (23580),A The height, kept below the top of the playfield.
49843 LD (49027),HL The position of the piece.
49846 LD IY,42543 The second aligned-row erase.
49850 LD A,(23592) The piece width in bytes.
49853 CP 5 Jump to DrawPiece_Draw2 if A is 5.
49855 JR Z,DrawPiece_Draw2
49857 LD IY,42555 The fourth aligned-row erase.
DrawPiece_Draw2 49861 LD A,(49785) The piece flags.
49864 CALL SelectMirroredErase_Entry Call SelectMirroredErase_Entry.
49867 LD HL,(49027) Fetch the word at 49027 into HL.
49870 CALL GetScreenAddress Call GetScreenAddress.
49873 EXX Switch to the alternate registers.
DrawPiece_Done 49874 POP DE Bring DE back off the stack.
49875 LD A,(49785) The piece flags.
49878 BIT 6,A Jump to DrawPiece_Ship if bit 6 of A is clear.
49880 JR Z,DrawPiece_Ship
49882 XOR A Clear A.
49883 LD (23581),A Draw the piece straight to the screen.
49886 JP DrawSpritesDirectly Jump to DrawSpritesDirectly.
DrawPiece_Ship 49889 LD (IX+0),104 Store 104 at offset 0 of IX.
49893 LD A,(23608) The ship row.
49896 SUB 13 Subtract 13 from A.
49898 LD (IX+1),A Write A to offset 1 of IX.
49901 LD HL,42621 The second aligned-row draw.
49904 LD A,(23593) The piece width in bytes.
49907 CP 5 Jump to DrawPiece_Mask if A is 5.
49909 JR Z,DrawPiece_Mask
49911 LD (IX+0),120 Store 120 at offset 0 of IX.
49915 LD A,(IX+1) Read offset 1 of IX.
49918 SUB 35 Subtract 35 from A.
49920 LD (IX+1),A Write A to offset 1 of IX.
49923 LD HL,42631 The fourth aligned-row draw.
DrawPiece_Mask 49926 LD A,(51453) The ship's facing.
49929 BIT 7,A Jump to DrawPiece_Position if bit 7 of A is clear.
49931 JR Z,DrawPiece_Position
49933 LD (IX+0),96 Store 96 at offset 0 of IX.
DrawPiece_Position 49937 PUSH HL Stash HL on the stack.
49938 LD L,(IX+0) Read offset 0 of IX into L.
49941 LD H,(IX+1) Read offset 1 of IX into H.
49944 LD A,H A=H.
49945 LD (41610),A The row the piece is drawn on.
49948 LD A,(23581) The height of the piece.
49951 CALL LimitHeight Call LimitHeight.
49954 LD A,B A=B.
49955 LD (23581),A The height of the piece.
49958 CALL GetScreenAddress Call GetScreenAddress.
49961 POP IX Bring IX back off the stack.
49963 CALL SelectMirroredDraw Call SelectMirroredDraw.
49966 JP DrawSpritesDirectly Jump to DrawSpritesDirectly.
Prev: 49785 Up: Map Next: 49969