get = FFA9
xpos = 41
xposh = 42
ypos = 43
yposh = 44
yorig = 27
yorigh = A

jsr get		20 A9 FF	;line in A
sta xpos	85 41
asla		0A		;2 * line
clc		18		;defensive
adc xpos	65 41		;3 * line
asla		0A
asla		0A		;(12 * line) % 256
sta xpos	85 41
lda #0		A9 00
sta xposh	85 42
rol xposh	26 42		;12 * line in xposh,xpos
lda yorig	A5 27
sta ypos	85 43
lda yorigh	A5 0A
and #1		29 01
sta yposh	85 44		;Yorigin in yposh,ypos
lda #f5		A9 F5
clc		18
adc ypos	65 43
sta ypos	85 43
lda #1		A9 01
adc yposh	65 44
sta yposh	85 44		;501 + Yorigin
lda ypos	A5 43
sec		38		;clear borrow
sbc xpos	E5 41
sta ypos	85 43
lda yposh	A5 44
sbc xposh	E5 42
and #1		29 01
sta yposh	85 44		;(501 + Yorigin - 12 * line) % 512
jsr get		20 A9 FF	;column in A
clc		18
asla		0A
asla		0A
asla		0A
ora #1		09 01		;add 1
sta xpos	85 41		;(1 + 8 * column) % 256
lda #0		A9 00
sta xposh	85 42
rol xposh	26 42		;high bit
rts		60
