Elite on the BBC Micro

# Drawing ships: LL9 (Part 12 of 12) (Cassette version)

```       Name: LL9 (Part 12 of 12)                               [View in context]
Type: Subroutine                                       [Compare versions]
Category: Drawing ships
Summary: Draw ship: Draw all the visible edges from the ship line heap
Deep dive: Drawing ships

This part draws the lines in the ship line heap, which is used both to draw
the ship, and to remove it from the screen.

.LL155

LDY #0                 \ Fetch the first byte from the ship line heap into A,
LDA (XX19),Y           \ which contains the number of bytes in the heap

STA XX20               \ Store the heap size in XX20

CMP #4                 \ If the heap size is less than 4, there is nothing to
BCC LL118-1            \ draw, so return from the subroutine (as LL118-1
\ contains an RTS)

INY                    \ Set Y = 1, which we will use as an index into the ship
\ line heap, starting at byte #1 (as byte #0 contains
\ the heap size)

.LL27

LDA (XX19),Y           \ Fetch the X1 line coordinate from the heap and store
STA XX15               \ it in XX15

INY                    \ Increment the heap pointer

LDA (XX19),Y           \ Fetch the Y1 line coordinate from the heap and store
STA XX15+1             \ it in XX15+1

INY                    \ Increment the heap pointer

LDA (XX19),Y           \ Fetch the X2 line coordinate from the heap and store
STA XX15+2             \ it in XX15+2

INY                    \ Increment the heap pointer

LDA (XX19),Y           \ Fetch the Y2 line coordinate from the heap and store
STA XX15+3             \ it in XX15+3

JSR LL30               \ Draw a line from (X1, Y1) to (X2, Y2)

INY                    \ Increment the heap pointer

CPY XX20               \ If the heap counter is less than the size of the heap,
BCC LL27               \ loop back to LL27 to draw the next line from the heap

\LL82                   \ This label is commented out in the original source

RTS                    \ Return from the subroutine
```