1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-15 10:29:00 +00:00
cc65/libsrc/telestrat/gotoxy.s
2019-07-21 14:11:51 -04:00

60 lines
1.3 KiB
ArmAsm

;
; 2017-02-25, jede <jede@oric.org>
; 2017-06-15, Greg King
;
; void gotoxy (unsigned char x, unsigned char y);
;
.export gotoxy, _gotoxy, update_adscr
.import popa, OLD_CHARCOLOR, OLD_BGCOLOR
.include "telestrat.inc"
gotoxy: jsr popa ; Get Y
.proc _gotoxy
; This function moves only the display cursor; it does not move the prompt position.
; In telemon, there is a position for the prompt, and another for the cursor.
sta SCRY
jsr update_adscr ; Update adress video ram position when SCRY is modified
jsr popa
sta SCRX
rts
.endproc
.proc update_adscr
; Force to set again color if cursor moves
; $FF is used because we know that it's impossible to have this value with a color
; It prevents a bug : If bgcolor or textcolor is set to black for example with no char displays,
; next cputsxy will not set the attribute if y coordinate changes
lda #$FF
sta OLD_CHARCOLOR
sta OLD_BGCOLOR
lda #<SCREEN
sta ADSCRL
lda #>SCREEN
sta ADSCRH
ldy SCRY
beq out
loop:
lda ADSCRL
clc
adc #$28
bcc skip
inc ADSCRH
skip:
sta ADSCRL
dey
bne loop
out:
rts
.endproc