| The Hobbit (v1.0) | Routines |
| Prev: 8B26 | Up: Map | Next: 8B93 |
|
Draws a line of L+1 pixels from (D,E) in one of eight directions (bits 0-2 of C). Bit 0 says whether the line is mostly vertical or mostly horizontal; bits 1 and 2 give the vertical and horizontal directions. The line moves one pixel along its main direction every step, and one pixel along the other direction every B steps, so lines have slopes of 1, 1/2, 1/3 and so on rather than arbitrary angles. Drawing stops early at the edge of the picture area.
|
||||||||||||||
| 8B2F | BIT 0,C | Mostly vertical (bit 0 set)? | ||||||||||||
| 8B31 | JR NZ,$8B63 | Yes | ||||||||||||
| 8B33 | PUSH HL | MOSTLY HORIZONTAL: | ||||||||||||
| 8B34 | PUSH BC | |||||||||||||
| 8B35 | CALL $8B93 | Plot the pixel | ||||||||||||
| 8B38 | BIT 2,C | Leftwards (bit 2)? | ||||||||||||
| 8B3A | JR Z,$8B43 | |||||||||||||
| 8B3C | CALL $8B26 | Step left | ||||||||||||
| 8B3F | JR Z,$8B60 | Stop at the edge | ||||||||||||
| 8B41 | JR $8B48 | |||||||||||||
| 8B43 | CALL $8B1F | Step right | ||||||||||||
| 8B46 | JR Z,$8B60 | Stop at the edge | ||||||||||||
| 8B48 | DEC B | Time for a vertical step? | ||||||||||||
| 8B49 | JR NZ,$8B5D | Not yet | ||||||||||||
| 8B4B | BIT 1,C | Downwards (bit 1)? | ||||||||||||
| 8B4D | JR Z,$8B56 | |||||||||||||
| 8B4F | CALL $8B18 | Step down | ||||||||||||
| 8B52 | JR Z,$8B60 | Stop at the edge | ||||||||||||
| 8B54 | JR $8B5B | |||||||||||||
| 8B56 | CALL $8B09 | Step up | ||||||||||||
| 8B59 | JR Z,$8B60 | Stop at the edge | ||||||||||||
| 8B5B | POP BC | Reload the step counter B | ||||||||||||
| 8B5C | PUSH BC | |||||||||||||
| 8B5D | DEC L | One pixel fewer to draw | ||||||||||||
| 8B5E | JR NZ,$8B35 | Loop | ||||||||||||
| 8B60 | POP BC | |||||||||||||
| 8B61 | POP HL | |||||||||||||
| 8B62 | RET | |||||||||||||
| 8B63 | PUSH HL | MOSTLY VERTICAL: | ||||||||||||
| 8B64 | PUSH BC | |||||||||||||
| 8B65 | CALL $8B93 | Plot the pixel | ||||||||||||
| 8B68 | BIT 1,C | Downwards (bit 1)? | ||||||||||||
| 8B6A | JR Z,$8B73 | |||||||||||||
| 8B6C | CALL $8B18 | Step down | ||||||||||||
| 8B6F | JR Z,$8B90 | Stop at the edge | ||||||||||||
| 8B71 | JR $8B78 | |||||||||||||
| 8B73 | CALL $8B09 | Step up | ||||||||||||
| 8B76 | JR Z,$8B90 | Stop at the edge | ||||||||||||
| 8B78 | DEC B | Time for a sideways step? | ||||||||||||
| 8B79 | JR NZ,$8B8D | Not yet | ||||||||||||
| 8B7B | BIT 2,C | Leftwards (bit 2)? | ||||||||||||
| 8B7D | JR Z,$8B86 | |||||||||||||
| 8B7F | CALL $8B26 | Step left | ||||||||||||
| 8B82 | JR Z,$8B90 | Stop at the edge | ||||||||||||
| 8B84 | JR $8B8B | |||||||||||||
| 8B86 | CALL $8B1F | Step right | ||||||||||||
| 8B89 | JR Z,$8B90 | Stop at the edge | ||||||||||||
| 8B8B | POP BC | Reload the step counter | ||||||||||||
| 8B8C | PUSH BC | |||||||||||||
| 8B8D | DEC L | One pixel fewer to draw | ||||||||||||
| 8B8E | JR NZ,$8B65 | Loop | ||||||||||||
| 8B90 | POP BC | |||||||||||||
| 8B91 | POP HL | |||||||||||||
| 8B92 | RET | |||||||||||||
| Prev: 8B26 | Up: Map | Next: 8B93 |