-
Notifications
You must be signed in to change notification settings - Fork 1
/
soft80_color.s
146 lines (118 loc) · 3.78 KB
/
soft80_color.s
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// Groepaz/Hitmen, 12.10.2015
//
// high level implementation for the soft80 implementation
//
// unsigned char __fastcall__ textcolor (unsigned char color)//
// unsigned char __fastcall__ bgcolor (unsigned char color)//
//
#import "soft80.inc"
soft80_textcolor:
ldx CHARCOLOR // get old value
sta CHARCOLOR // set new value
mkcharcolor:
lda soft80_internal_bgcolor
asl //a
asl //a
asl //a
asl //a
sta soft80.tmp1 // remember new bg color (high nibble)
ora CHARCOLOR
sta soft80_internal_cellcolor // text/bg combo for new chars
txa // get old value
rts
soft80_bgcolor:
ldx soft80_internal_bgcolor // get old value
stx soft80.tmp2 // save old value
sta soft80_internal_bgcolor // set new value
jsr mkcharcolor
lda CURS_X
pha
lda CURS_Y
pha
ldy #0
ldx #0
clc
jsr soft80_kplot
sei
lda $01
pha
ldx #$34
stx $01 // $34
//ldy #0 // is still 0
lda #24
sta CURS_Y
lpy:
lda #39
sta CURS_X
lpx:
#if SOFT80COLORVOODOO
// if the old bg color is equal to color ram of that cell, then also
// update the color ram to the new value.
inc $01 // $35
lda (CRAM_PTR),y // colram
stx $01 // $34
and #$0f
cmp soft80.tmp2 // old bg color
bne !sk1+
// if the left character in the cell is not a space, then dont update
// the color ram
lda #1
sta soft80_internal_cursorxlsb
jsr soft80_checkchar
bcc !sk1+
lda soft80_internal_bgcolor // new bg color
inc $01 // $35
sta (CRAM_PTR),y // colram
stx $01 // $34
!sk1:
#endif
// if the old bg color is equal to text color in this cell, then also
// update the text color to the new value.
lda (CRAM_PTR),y // vram
and #$0f
cmp soft80.tmp2 // old bg color
bne !sk2+
// if there are non space characters in the cell, do not update the
// color ram
pha
lda #0
sta soft80_internal_cursorxlsb
jsr soft80_checkchar
pla
bcc !sk2+
pha
inc soft80_internal_cursorxlsb
jsr soft80_checkchar
pla
bcc !sk2+
lda soft80_internal_bgcolor // new bg color
!sk2:
ora soft80.tmp1 // new bg color (high nibble)
sta (CRAM_PTR),y // vram
inc CRAM_PTR
bne !sk3+
inc CRAM_PTR+1
!sk3:
lda SCREEN_PTR
clc
adc #8
sta SCREEN_PTR
bcc !sk4+
inc SCREEN_PTR+1
!sk4:
dec CURS_X
bpl lpx
dec CURS_Y
bpl lpy
pla
sta $01 // enable I/O
cli
pla // CURS_Y
tax
pla // CURS_X
tay
clc
jsr soft80_kplot
lda soft80.tmp2 // get old value
rts