Skip to navigation

Elite on the BBC Micro

Version analysis of LL9 (Part 12 of 12)

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

Name: LL9 (Part 12 of 12) Type: Subroutine Category: Drawing ships Summary: Draw ship: Draw all the visible edges from the ship line heap Deep dive: Drawing ships

Code variation 1 of 8A variation in the comments only

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Flight, Docked, 6502SP, Electron

Master

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.
This part draws any remaining lines from the old ship that are still in the ship line heap.

Code variation 2 of 8A variation in the comments only

This variation is blank in the Cassette, Disc (flight), Disc (docked), Master and Electron versions.

6502SP

If NEEDKEY is non-zero, then this routine also scans the keyboard for a key press and returns the internal key number in X (or 0 for no key press).
.LL155

Code variation 3 of 8Related to Elite's use of the Tube

This variation is blank in the Cassette, Disc (flight), Disc (docked), Master and Electron versions.

6502SP

LDA NEEDKEY \ If NEEDKEY is zero, jump to notneed to skip the next BEQ notneed \ two instructions, so we only read the keyboard if \ NEEDKEY is non-zero STZ NEEDKEY \ Set NEEDKEY = 0 JSR RDKEY \ Scan the keyboard for a key press and return the \ internal key number in X (or 0 for no key press) .notneed

Code variation 4 of 8Related to Elite's use of the Tube

This variation is blank in the Master version.

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Flight, Docked, Electron

6502SP

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)
LDA (XX19) \ Fetch the first byte from the ship line heap into A, \ which contains the number of bytes in the heap CMP #5 \ If the heap size is less than 5, there is nothing to BCC nolines \ draw, so return from the subroutine (as nolines \ contains an RTS) LDA #129 \ Send an OSWRCH 129 command to the I/O processor to JSR OSWRCH \ tell it to start receiving a new line to draw (so \ when we send it OSWRCH commands from now on, the I/O \ processor will add these bytes to this line until \ they are all sent, at which point it will draw the \ line)

Code variation 5 of 8Related to the Master version

The cassette, disc and 6502SP versions do all their line drawing at the very end of the LL9 ship-drawing routine, but the Master has already redrawn most of the ship by this point and only needs to erase any remaining lines.

See below for more variations related to this code.

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Flight, Docked, Electron

Master

6502SP

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)
LDY XX14 \ Set Y to the offset in the line heap XX14
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
.LL27

Code variation 6 of 8Related to the Master version

See variation 5 above for details.

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Flight, Docked, Electron

Master

6502SP

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)
CPY XX14+1 \ If Y >= XX14+1, jump to LLEX to return from the ship BCS LLEX \ drawing routine, because the index in Y is greater \ than the size of the existing ship line heap, which \ means we have alrady erased all the old ships lines \ when drawing the new ship \ If we get here then Y < XX14+1, which means Y is \ pointing to an on-screen line from the old ship that \ we need to erase LDA (XX19),Y \ Fetch the X1 line coordinate from the heap and store INY \ it in XX15, incrementing the heap pointer STA XX15 LDA (XX19),Y \ Fetch the Y1 line coordinate from the heap and store INY \ it in XX15+1, incrementing the heap pointer STA XX15+1 LDA (XX19),Y \ Fetch the X2 line coordinate from the heap and store INY \ it in XX15+2, incrementing the heap pointer STA XX15+2 LDA (XX19),Y \ Fetch the Y2 line coordinate from the heap and store INY \ it in XX15+3, incrementing the heap pointer STA XX15+3 JSR LL30 \ Draw a line from (X1, Y1) to (X2, Y2) to erase it from \ the screen
LDA (XX19),Y \ Fetch the Y-th line coordinate from the heap and send JSR OSWRCH \ it to the I/O processor to add to the line buffer

Code variation 7 of 8Related to the Master version

See variation 5 above for details.

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Flight, Docked, 6502SP, Electron

Master

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
JMP LL27 \ Loop back to LL27 to draw (i.e. erase) the next line \ from the heap .LLEX LDA XX14 \ Store XX14 in the first byte of the ship line heap LDY #0 STA (XX19),Y .LL82

Code variation 8 of 8A variation in the comments only

This variation is blank in the Disc (flight), Disc (docked), Master and Electron versions.

Tap on a version to expand it, and tap it again to show to all variations.

Cassette

6502SP

\.LL82 \ This label is commented out in the original source
\ By the time we get here, we have sent all the line \ coordinates to the I/O processor, so it will have \ drawn the line after we sent the last one .nolines
 RTS                    \ Return from the subroutine

RSS Feed