]> git.sur5r.net Git - cc65/blob - libsrc/c64/soft80_color.s
added some more comments and -headers
[cc65] / libsrc / c64 / soft80_color.s
1 ;
2 ; Groepaz/Hitmen, 12.10.2015
3 ;
4 ; unsigned char __fastcall__ textcolor (unsigned char color);
5 ; unsigned char __fastcall__ bgcolor (unsigned char color);
6 ; unsigned char __fastcall__ bordercolor (unsigned char color);
7 ;
8
9         .export         soft80_textcolor, soft80_bgcolor, soft80_bordercolor
10         .export         __textcolor, __bgcolor
11
12         .importzp       tmp1, tmp2
13
14         .include        "c64.inc"
15         .include        "soft80.inc"
16
17 soft80_textcolor:
18         ldx     __textcolor             ; get old value
19         sta     __textcolor             ; set new value
20
21         jsr     mkcharcolor
22
23         txa                             ; get old value
24         rts
25
26 soft80_bgcolor:
27         ldx     __bgcolor               ; get old value
28         stx     tmp2                    ; save old value
29         sta     __bgcolor               ; set new value
30
31         jsr     mkcharcolor
32
33 .if SOFT80COLORVOODOO = 1
34         ; if the old bg color is equal to color ram of that cell, then also
35         ; update the color ram to the new value.
36         ; FIXME: perhaps we must also check if the non visible character is not
37         ;        a space, and NOT update the color ram in that case.
38         ldx     #$00
39 lp1:
40         .repeat $4,page
41         .scope
42         lda     soft80_colram+(page*250),x
43         and     #$0f
44         cmp     tmp2                    ; old bg color
45         bne     @sk1
46         lda     __bgcolor               ; new bg color
47         sta     soft80_colram+(page*250),x
48 @sk1:
49         .endscope
50         .endrepeat
51
52         inx
53         bne     lp1
54 .endif
55
56         sei
57         ldy     $01
58         lda     #$34                    ; disable I/O
59         sta     $01
60
61         ; if the old bg color is equal to text color in this cell, then also
62         ; update the text color to the new value.
63         ; FIXME: perhaps we need to check for space, see note above
64         ldx     #$00
65 lp2:
66         .repeat $4,page
67         .scope
68         lda     soft80_vram+(page*250),x
69         and     #$0f
70         cmp     tmp2                    ; old bg color
71         bne     @sk2
72         lda     __bgcolor               ; new bg color
73 @sk2:
74         ora     tmp1                    ; new bg color (high nibble)
75         sta     soft80_vram+(page*250),x
76         .endscope
77         .endrepeat
78
79         inx
80         bne     lp2
81
82         sty     $01                     ; enable I/O
83         cli
84
85         lda     tmp2                    ; get old value
86         rts
87
88 mkcharcolor:
89         lda     __bgcolor
90         asl     a
91         asl     a
92         asl     a
93         asl     a
94         sta     tmp1                    ; remember new bg color (high nibble)
95         ora     __textcolor
96         sta     CHARCOLOR               ; text/bg combo for new chars
97         rts
98
99 soft80_bordercolor:
100         ldx     VIC_BORDERCOLOR         ; get old value
101         sta     VIC_BORDERCOLOR         ; set new value
102         txa
103         rts
104
105         .bss
106 __textcolor:
107         .res 1
108 __bgcolor:
109         .res 1
110
111 ;-------------------------------------------------------------------------------
112 ; force the init constructor to be imported
113
114         .import soft80_init
115 conio_init      = soft80_init