-
Notifications
You must be signed in to change notification settings - Fork 22
/
showthumbnail.a65
265 lines (231 loc) · 3.67 KB
/
showthumbnail.a65
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
.outfile "thumbnail.prg"
.word $0801
.org $0801
.scope
.word _next, 10 ; Next line and current line number
.byte $97, "2,0:", $9e, " 2014", $AA, "65",0 ; POKE 2,0 : SYS 2014+65
_next: .word 0
iter1: .byte 0
.checkpc 2079
.advance 2079
; C65GS IO
lda #$47
sta $d02f
lda #$53
sta $d02f
sei
jsr set_palette
jsr redraw_fullcolour_area
; clear $2000-$3FFF to make transparent
lda #$00
ldy #$00
l7: sta $2d00,y
sta $2e00,y
sta $2f00,y
sta $3000,y
sta $3100,y
iny
bne l7
inc $d020
; raster interrupt to toggle normal/full-colour mode
lda #$00
sta $d012
lda #$1b
sta $d011
lda #$81
sta $d01a
lda #$7f
sta $dc0d
sta $dd0d
lda #<irq_00
sta $0314
lda #>irq_00
sta $0315
cli
rts
irq_a0:
; wait a bit to clear raster line
ldx #$00
l5: nop
nop
dex
bne l5
; enable full-colour mode
lda #$02
sta $d054
lda #$00
sta $d012
lda #$1b
sta $d011
; switch to irq split at top of screen
lda #<irq_00
sta $0314
lda #>irq_00
sta $0315
dec $d019
jmp $ea81
irq_00:
; disable full-colour mode
lda #$00
sta $d054
lda #$c2
sta $d012
lda #$1b
sta $d011
jsr redraw_fullcolour_area
; copy thumbnail data into our full-colour display
; read $D630 to reset read pointer
lda $d630
; now read 4000 bytes out and store into the grid at $2000.
; thumbnail data is written linearly, so every 8 pixels we need to add
; 64-8 bytes, and at the end of every row, i.e., every 80 bytes, we need
; to subtract 9*64 = $240.
lda #<$2000
sta tw+1
lda #>$2000
sta tw+2
lda #<4000
sta count
lda #>4000
sta count+1
ldx #8
ldy #80
twloop:
; get thumbnail byte, and do palette lookup
phy
ldy $d631
lda colour_table,y
ply
tw: ; store it in place
sta $2000
; advance write address by 1
inc tw+1
bne tw2
inc tw+2
tw2: ; see if we need to advance write address by (64*7)-8 = 440
dex
bne tw3
ldx #8
lda tw+1
clc
adc #<440
sta tw+1
lda tw+2
adc #>440
sta tw+2
tw3: ; see if we need to retreat write address by (10*(64*7)-8) = 4472
dey
bne tw4
ldy #80
lda tw+1
sec
sbc #<4472
sta tw+1
lda tw+2
sbc #>4472
sta tw+2
tw4:
dec count
bne twloop
dec count+1
bne twloop
; switch to irq split at bottom
lda #<irq_a0
sta $0314
lda #>irq_a0
sta $0315
; do keyboard input
dec $d019
jmp $ea31
; number of bytes to copy from thumbnail
count: .byte $00,$00
redraw_fullcolour_area:
; arrange tiles in lower part of the screen to display the thumbnail.
; char $80-$FF are @ $2000-$3FFF.
; start by filling the region with $FF, and clearing that tile.
lda #$ff
ldy #$00
l2: sta $06d0,y
sta $0700,y
iny
bne l2
; now clear glyph $FF
ldy #$3f
lda #$00
l3: sta $3fc0,y
dey
bpl l3
; now draw the 80x50 space for the thumbnail.
; this will be 10x7 glyphs, numbered sequentially vertically,
; not horizontally.
lda #<$06ee
sta l4+1
lda #>$06ee
sta l4+2
lda #$80
ldx #$00
ldy #$00
l4: sta $06ee,x
clc
adc #$07
inx
cpx #$0a
bne l4
iny
tya
clc
adc #$80
pha
clc
lda l4+1
adc #$28
sta l4+1
lda #$00
adc l4+2
sta l4+2
pla
ldx #$00
cpy #$07
bne l4
rts
set_palette:
; generate colour cube
ldy #$10
pl: tya
lsr
lsr
lsr
lsr
ora #$00
sta $d100,y
tya
lsr
and #$0f
ora #$00
sta $d200,y
tya
asl
asl
and #$0f
ora #$00
sta $d300,y
iny
bne pl
; make basic colour lookup table
ldy #$00
pl1: tya
sta colour_table,y
iny
bne pl1
; now patch values for VIC-II colours so that there is no colour drift
;
; blue
lda #$06
sta colour_table+$03
; light blue
lda #$0e
sta colour_table+$93
rts
colour_table:
.advance colour_table+$100
.scend