Prev: A331 Up: Map Next: A39E
A379: Divide, for a line's slope
Used by the routine at DRAW_LINE.
Eight rounds of shift, trial subtract and set a quotient bit: the shorter side of a line over the longer, as an 8-bit fraction. Its only callers are the two halves of DRAW_LINE.
DIVIDE_SLOPE A379 LD L,H
A37A LD H,$00
A37C EXX
A37D LD HL,$0000
A380 LD B,$08
DIVIDE_SLOPE_0 A382 EXX
A383 SLA L
A385 RL H
A387 PUSH HL
A388 AND A
A389 SBC HL,DE
A38B JR C,DIVIDE_SLOPE_2
A38D POP AF
A38E EXX
A38F ADD HL,HL
A390 INC HL
DIVIDE_SLOPE_1 A391 DJNZ DIVIDE_SLOPE_0
A393 PUSH HL
A394 EXX
A395 LD E,L
A396 LD D,H
A397 POP HL
A398 RET
DIVIDE_SLOPE_2 A399 POP HL
A39A EXX
A39B ADD HL,HL
A39C JR DIVIDE_SLOPE_1
Prev: A331 Up: Map Next: A39E