Prev: 42544 Up: Map Next: 42707
42642: Draw Needle Tip
Used by the routine at DrawDirectionGauge.
Draws the ball at the tip of the needle of a direction gauge into the buffer at 62743 using self-modifying versions of the sprite drawing code at DrawShiftedRows. The ball is drawn from six pairs of mask and picture values at NeedleTipShapes (or the shifted version at 42719), which are taken from the stack. The value of DrawingPosition selects the version by bit 0, and the table of shifts to use by bits 1-2.
Input
HL The address in the buffer
DrawNeedleTip 42642 LD (23770),SP Save the stack pointer.
42646 LD A,(23772) Fetch the position of the tip of the needle from DrawingPosition.
42649 LD SP,42707 Point the stack at the shape of the ball.
42652 BIT 0,A Jump to DrawNeedleTip_Shift if bit 0 of the position is reset.
42654 JR Z,DrawNeedleTip_Shift
42656 LD SP,42719 Point the stack at the shifted shape of the ball.
DrawNeedleTip_Shift 42659 AND %00000110 Use bits 1-2, the shift in pixels.
42661 JR Z,DrawNeedleTip_Unshifted Jump to DrawNeedleTip_Unshifted if the ball is not to be shifted.
42663 EX DE,HL Exchange DE and HL, so that DE is the address in the buffer.
42664 ADD A,248 Add 248 to make the high byte of the address of the shift table.
42666 LD H,A Set the high byte of HL to select the shift table.
42667 LD A,8 Set the number of bytes to step back to the next row to 8...
42669 LD (46384),A ...in the operand of the instruction at 46383.
42672 LD A,6 Set the counter of rows to 6...
42674 EX AF,AF' ...and store it in the alternate A.
42675 LD BC,46360 Set BC to the address of the code at 46360.
42678 LD (46388),BC Patch the jump at 46387 to go there.
42682 LD (46393),BC Patch the jump at 46392 to go there.
42686 LD A,(DE) Fetch the byte of the buffer.
42687 JP DrawShiftedRows_One Jump to 46360 to draw the ball.
DrawNeedleTip_Unshifted 42690 LD A,249 Set the low byte of the operand of the instruction at 46299 to 249...
42692 LD (46300),A ...to make the offset to the next row 65529.
42695 LD B,6 Set the counter of rows to 6.
42697 LD DE,46293 Point DE at the code at 46293.
42700 LD (46305),DE Patch the jump at 46304 to go there.
42704 JP DrawUnshiftedRows_One Jump to 46293 to draw the ball.
Prev: 42544 Up: Map Next: 42707