Sherlock: annotated disassembly

Routines

Prev: F54A Up: Map Next: F5D2
F56E: Draw a line from the pen
L = the number of steps, B the run length before a step on the minor axis, C the directions (bit 0: which axis is major; bits 1 and 2: up or down, left or right). Plots each point with F5D2.
Input
L The number of steps
B The run length before a step on the other axis
C The direction bits
D, E The pen
Output
D, E The pen after the line
BC, HL Kept
F56E BIT 0,C Test bit 0 of C - Bit 0 set: the line is mostly along E
F570 JR NZ,$F5A2 If bit 0 of C is set, jump on to F5A2
F572 PUSH HL Save HL on the stack
F573 PUSH BC Save BC on the stack
F574 CALL $F5D2 Mostly along D: plot the point
F577 BIT 2,C Test bit 2 of C - Step along D: left with bit 2, right without
F579 JR Z,$F582 If bit 2 of C is clear, skip ahead to F582
F57B CALL $F565 Call F565 (inside "Move the pen one pixel (Z when it would...")
F57E JR Z,$F59F If the zero flag is set, skip ahead to F59F
F580 JR $F587 Skip ahead to F587
F582 CALL $F55E Call F55E (inside "Move the pen one pixel (Z when it would...")
F585 JR Z,$F59F If the zero flag is set, skip ahead to F59F
F587 DEC B Subtract one from B - End of a run?
F588 JR NZ,$F59C If B is not zero, skip ahead to F59C
F58A BIT 1,C Test bit 1 of C - Then one step along E: E - 1 with bit 1, E + 1 without
F58C JR Z,$F595 If bit 1 of C is clear, skip ahead to F595
F58E CALL $F555 Call F555 (inside "Move the pen one pixel (Z when it would...")
F591 JR Z,$F59F If the zero flag is set, skip ahead to F59F
F593 JR $F59A Skip ahead to F59A
F595 CALL $F54A Call the routine "Move the pen one pixel (Z when it would leave the..." (F54A)
F598 JR Z,$F59F If the zero flag is set, skip ahead to F59F
F59A POP BC Restore BC from the stack - and the run length again
F59B PUSH BC Save BC on the stack
F59C DEC L Subtract one from L - L points in all
F59D JR NZ,$F574 If L is not zero, go back to F574
F59F POP BC Restore BC from the stack - (or until the pen meets the edge of the picture)
F5A0 POP HL Restore HL from the stack
F5A1 RET Return to the caller
F5A2 PUSH HL Save HL on the stack
F5A3 PUSH BC Save BC on the stack
F5A4 CALL $F5D2 Mostly along E: plot the point
F5A7 BIT 1,C Test bit 1 of C - Step along E: E - 1 with bit 1, E + 1 without
F5A9 JR Z,$F5B2 If bit 1 of C is clear, skip ahead to F5B2
F5AB CALL $F555 Call F555 (inside "Move the pen one pixel (Z when it would...")
F5AE JR Z,$F5CF If the zero flag is set, skip ahead to F5CF
F5B0 JR $F5B7 Skip ahead to F5B7
F5B2 CALL $F54A Call the routine "Move the pen one pixel (Z when it would leave the..." (F54A)
F5B5 JR Z,$F5CF If the zero flag is set, skip ahead to F5CF
F5B7 DEC B Subtract one from B - End of a run?
F5B8 JR NZ,$F5CC If B is not zero, skip ahead to F5CC
F5BA BIT 2,C Test bit 2 of C - Then one step along D: left with bit 2, right without
F5BC JR Z,$F5C5 If bit 2 of C is clear, skip ahead to F5C5
F5BE CALL $F565 Call F565 (inside "Move the pen one pixel (Z when it would...")
F5C1 JR Z,$F5CF If the zero flag is set, skip ahead to F5CF
F5C3 JR $F5CA Skip ahead to F5CA
F5C5 CALL $F55E Call F55E (inside "Move the pen one pixel (Z when it would...")
F5C8 JR Z,$F5CF If the zero flag is set, skip ahead to F5CF
F5CA POP BC Restore BC from the stack - and the run length again
F5CB PUSH BC Save BC on the stack
F5CC DEC L Subtract one from L - L points in all
F5CD JR NZ,$F5A4 If L is not zero, go back to F5A4
F5CF POP BC Restore BC from the stack
F5D0 POP HL Restore HL from the stack
F5D1 RET Return to the caller
Prev: F54A Up: Map Next: F5D2