Skip to navigation

Elite on the BBC Micro and NES

Drawing circles: TT128

[NES version, Bank 0]

Name: TT128 [Show more] Type: Subroutine Category: Drawing circles Summary: Draw a circle on a chart Deep dive: Drawing circles
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * TT14 calls TT128

Draw a circle with the centre at (QQ19, QQ19+1) and radius K.
Arguments: QQ19 The x-coordinate of the centre of the circle QQ19+1 The y-coordinate of the centre of the circle K The radius of the circle
.TT128 LDA QQ19 ; Set K3 = the x-coordinate of the centre STA K3 LDA QQ19+1 ; Set K4 = the y-coordinate of the centre STA K4 LDX #0 ; Set the high bytes of K3(1 0) and K4(1 0) to 0 STX K4+1 STX K3+1 LDX #2 ; Set STP = 2, the step size for the circle STX STP LDX #1 ; Set the high byte of the pattern buffer address JSR SetPatternBuffer ; variables to that of pattern buffer 1, so the circle ; gets drawn into bitplane 1 only, giving a circle of ; colour %10 (2), which is green JMP CIRCLE2_b1 ; Jump to CIRCLE2 to draw a circle with the centre at ; (K3(1 0), K4(1 0)) and radius K, returning from the ; subroutine using a tail call