]> git.sur5r.net Git - cc65/blob - libsrc/atari/setcursor.s
Optimized mul20 & mul40 and extracted to new library.
[cc65] / libsrc / atari / setcursor.s
1 ;
2 ; Christian Groessler, November-2002
3 ;
4 ; cursor handling, internal function
5
6         .include "atari.inc"
7         .import cursor,_mul40
8         .export setcursor
9
10 .proc   setcursor
11
12         ldy     #0
13         lda     OLDCHR
14         sta     (OLDADR),y
15
16         lda     ROWCRS
17         jsr     _mul40          ; function leaves with carry clear!
18         adc     SAVMSC          ; add start of screen memory
19         sta     OLDADR
20         txa
21         adc     SAVMSC+1
22         sta     OLDADR+1
23         lda     COLCRS
24         adc     OLDADR
25         sta     OLDADR
26         bcc     nc
27         inc     OLDADR+1
28 nc:     lda     (OLDADR),y
29         sta     OLDCHR
30
31         ldx     cursor          ; current cursor setting as requested by the user
32         beq     off
33         ldx     #0
34         beq     cont
35
36 off:    inx
37 cont:   stx     CRSINH          ; update system variable
38
39         beq     turnon
40         and     #$7f            ; clear high bit / inverse flag
41 finish: sta     (OLDADR),y      ; update on-screen display
42         rts
43
44 turnon: ora     #$80            ; set high bit / inverse flag
45         bne     finish
46
47 .endproc