]> git.sur5r.net Git - cc65/blob - libsrc/c64/soft80_color.s
initial commit of soft80 implementation
[cc65] / libsrc / c64 / soft80_color.s
1 ;
2 ; unsigned char __fastcall__ textcolor (unsigned char color);
3 ; unsigned char __fastcall__ bgcolor (unsigned char color);
4 ; unsigned char __fastcall__ bordercolor (unsigned char color);
5 ;
6
7         .export         soft80_textcolor, soft80_bgcolor, soft80_bordercolor
8         .export         __textcolor,__bgcolor   ; CHECK/FIX
9
10         .importzp       tmp1,tmp2
11
12         .import         soft80_checkchar
13
14         .include        "c64.inc"
15         .include        "soft80.inc"
16
17 soft80_textcolor:
18
19         ldx     __textcolor             ; get old value
20         sta     __textcolor             ; set new value
21
22         lda     __bgcolor
23         asl     a
24         asl     a
25         asl     a
26         asl     a
27         ora     __textcolor
28         sta     CHARCOLOR
29
30         txa                             ; get old value
31         rts
32
33
34 soft80_bgcolor:
35         cmp     __bgcolor
36         beq     _donothing
37         ldx     __bgcolor               ; get old value
38         sta     __bgcolor               ; set new value
39         asl     a
40         asl     a
41         asl     a
42         asl     a
43         sta     tmp2                    ; shifted new value
44         ora     __textcolor
45         sta     CHARCOLOR               ; text/bg combo for new chars
46         txa
47         pha                             ; save old value
48         sta     tmp1
49
50         sei
51         lda     $01
52         pha
53
54         lda     #$34
55         sta     $01
56
57         ldx     #$00
58
59 lp2:
60         .repeat $4,page
61
62         .scope
63         lda     soft80_vram+(page*$100),x
64         and     #$0f
65         cmp     tmp1                    ; old bg color
66         bne     as
67         ; is old bg color
68         ; is space
69         ;lda __bgcolor
70 as:
71         ora     tmp2                    ; new bg color
72         sta     soft80_vram+(page*$100),x
73         .endscope
74
75         .endrepeat
76
77         inx
78         bne     lp2
79
80         pla
81         sta     $01
82         cli
83
84         pla                             ; get old value
85 _donothing:
86         rts
87
88
89 soft80_bordercolor:
90         ldx     VIC_BORDERCOLOR         ; get old value
91         sta     VIC_BORDERCOLOR         ; set new value
92         txa
93         rts
94
95         ; FIXME: shouldnt they be in zeropage?
96         .bss
97 __textcolor:
98         .res 1
99 __bgcolor:
100         .res 1