-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen.S
198 lines (174 loc) · 2.15 KB
/
screen.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
rel
mx %11
ent erase_line
ent erase_line_0
ent erase_line_1
ent erase_line_2
erase_line
; a = 0 - erase x - eol (inclusive)
; a = 1 - erase 0 - x (inclusive)
; a = 2 - erase 0 - eol
cmp #2
bcs :rts
asl
tax
jmp (:table,x)
:rts rts
:table
dw erase_line_0
dw erase_line_1
dw erase_line_2
erase_line_2
* erase entire line.
php
rep #$30
ldy #38
lda #" "
:loop
sta [text01],y
sta (text00),y
dey
dey
bpl :loop
plp
rts
mx %11
erase_line_0
* erase to eol
lda x
lsr
tay
lda #" "
bcs :half
:loop
sta [text01],y
:half sta (text00),y
iny
cpy #40
bcc :loop
rts
erase_line_1
* erase to x (inclusive)
lda x
lsr
tay
lda #" "
bcc :half
:loop
sta (text00),y
:half sta [text01],y
dey
bpl :loop
rts
erase_screen ent
; a = 0 - erase [cursor, end] (inclusive)
; a = 1 - erase [start, cursor] (inclusive)
; a = 2 - erase [start, end]
cmp #2
bcs :rts
asl
tax
jmp (:table,x)
:rts rts
:table
dw erase_screen_0
dw erase_screen_1
dw erase_screen_2
erase_screen_2 ent
* erase the entire screen.
php
rep #$30
lda #" " ; high bit set.
c00 cc $0400
c01 cc $0480
c02 cc $0500
c03 cc $0580
c04 cc $0600
c05 cc $0680
c06 cc $0700
c07 cc $0780
c08 cc $0428
c09 cc $04a8
c10 cc $0528
c11 cc $05a8
c12 cc $0628
c13 cc $06a8
c14 cc $0728
c15 cc $07a8
c16 cc $0450
c17 cc $04d0
c18 cc $0550
c19 cc $05d0
c20 cc $0650
c21 cc $06d0
c22 cc $0750
c23 cc $07d0
plp
rts
mx %11
erase_screen_0 ent
* erase from cursor to the end.
mx %11
ldx #0 ; for jmp (,x)
lda x
ora y
beq :all
lda x
beq :x0
jsr erase_line_0
lda y
inc
bra :x1
:x0
lda y
:x1 cmp #23
bcs :rts
asl
tax
:all php ; clear_table will plp.
rep #$30
lda #" "
jmp (clear_table,x)
:rts rts
erase_screen_1 ent
* erase from start to cursor.
jsr erase_line_1
lda y
bne :ok
rts
:ok
php
rep #$30
lda y
dey
asl
tax
lda #" "
jmp (:clear_table,x)
:clear_table
c23 cc $07d0
c22 cc $0750
c21 cc $06d0
c20 cc $0650
c19 cc $05d0
c18 cc $0550
c17 cc $04d0
c16 cc $0450
c15 cc $07a8
c14 cc $0728
c13 cc $06a8
c12 cc $0628
c11 cc $05a8
c10 cc $0528
c09 cc $04a8
c08 cc $0428
c07 cc $0780
c06 cc $0700
c05 cc $0680
c04 cc $0600
c03 cc $0580
c02 cc $0500
c01 cc $0480
c00 cc $0400
plp
rts