File: gotoxy.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (60 lines) | stat: -rw-r--r-- 1,374 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;
; 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     popa
    sta     SCRX

; Update adress video ram position when SCRY is modified (update_adscr)
; Fall through
.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     #SCREEN_XSIZE
    bcc     skip
    inc     ADSCRH
skip:
    sta     ADSCRL        
    dey
    bne     loop
out:        
    rts
.endproc