Skip to navigation

Revs on the BBC Micro

Screen buffer: DrawTrackLine (Part 1 of 2)

Name: DrawTrackLine (Part 1 of 2) [Show more] Type: Subroutine Category: Screen buffer Summary: Draw a pixel line across the screen in the track view, broken up into bytes Deep dive: Drawing around the dashboard Drawing the track view
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawTrackView (Part 1 of 4) calls DrawTrackLine * DrawTrackView (Part 2 of 4) calls DrawTrackLine

Arguments: X The offset within the dash data of the data to be drawn on the screen (from &7F down, as the dash data lives at the end of each dash data block) (Q P) The screen address of the leftmost pixel of the line above where we want to draw the horizontal pixel line (S R) Contains (Q P) + &100
.DrawTrackLine \ We start by incrementing (Q P) and (S R) to point to \ the next pixel row down the screen LDY P \ Set Y = P + 1, which is the low byte of (Q P) + 1 INY TYA \ If Y mod 8 = 0 then incrementing (Q P) will take us AND #&07 \ into the next character block (i.e. from pixel row 7 BEQ prow1 \ to pixel row 8), so jump to prow1 to update the screen \ addresses accordingly STY P \ Otherwise set the low bytes of (Q P) and (S R) to Y, STY R \ so this does: \ \ (Q P) = (Q P) + 1 \ \ (S R) = (S R) + 1 \ \ so they point to the next pixel row down the screen JMP prow2 \ Jump to part 2 to draw this pixel row .prow1 TYA \ Set (Q P) = Y + &138 CLC \ ADC #&38 \ starting with the low bytes STA P STA R LDA Q \ And then the high bytes, so (Q P) points to the start ADC #&01 \ of the character block on the next character row STA Q \ (i.e. the next pixel row down) ADC #&01 \ Set (S R) = (Q P) + &100 STA S JMP prow2 \ Jump to part 2 to draw this pixel row