]> git.sur5r.net Git - cc65/blob - libsrc/c128/color.s
Fixed gcc compiler warning (#867)
[cc65] / libsrc / c128 / color.s
1 ;
2 ; Ullrich von Bassewitz, 06.08.1998
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         _textcolor, _bgcolor, _bordercolor
10         .import         return0
11
12         .include        "c128.inc"
13
14
15 _textcolor:
16         bit     MODE            ; Check 80/40 column mode
17         bmi     @L1             ; Jump if 80 columns
18
19 ; 40 column mode
20
21         ldx     CHARCOLOR       ; Get the old color
22         sta     CHARCOLOR       ; Set the new color
23         txa                     ; Old color -> A
24         ldx     #$00            ; Load high byte
25         rts
26
27 ; 80 column mode
28
29 @L1:    tax                     ; Move new color to X
30         lda     CHARCOLOR       ; Get old color + attributes
31         and     #$F0            ; Keep old attributes
32         ora     $CE5C,x         ; Translate VIC color -> VDC color
33         ldx     CHARCOLOR       ; Get the old color
34         sta     CHARCOLOR       ; Set the new color + old attributes
35         txa                     ; Old color -> A
36         and     #$0F            ; Mask out attributes
37         ldx     #$00            ; Load high byte
38
39 ; translate vdc->vic colour
40
41 vdctovic:
42         ldy     #16
43 @L2:    cmp     $CE5C-1,y
44         beq     @L3
45         dey
46         bne     @L2
47 @L3:    tya
48         rts
49
50
51 _bgcolor:
52         bit     MODE
53         bmi     @L1
54
55 ; 40 column mode
56
57         ldx     VIC_BG_COLOR0   ; get old value
58         sta     VIC_BG_COLOR0   ; set new value
59         txa
60         ldx     #$00
61         rts
62
63 ; 80 column mode
64
65 @L1:    tax                     ; Move new color to X
66         lda     $CE5C,x         ; Translate VIC color -> VDC color
67         pha
68         ldx     #26
69         jsr     $CDDA           ; Read vdc register 26
70         jsr     vdctovic
71         tay
72         pla
73         ldx     #26
74         jsr     $CDCC           ; Write vdc register 26
75         tya
76         ldx     #$00
77         rts
78
79
80 _bordercolor:
81         bit     MODE
82         bmi     @L1
83
84 ; 40 column mode
85
86         ldx     VIC_BORDERCOLOR ; get old value
87         sta     VIC_BORDERCOLOR ; set new value
88         txa
89         ldx     #$00
90         rts
91
92 ; 80 column mode
93
94 @L1:    jmp     return0
95