-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresenter.asm
357 lines (253 loc) · 5.78 KB
/
presenter.asm
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
;---------------------------------------
;--- Copyright (c) 2019 Greg Nacu ------
;---------------------------------------
;----[ presenter.a ]--------------------
.include "/s/:basic.s"
.include "/s/:io.s"
.include "/s/:io_joy.s"
.include "/s/ker/:file.s"
.include "/s/ker/:io.s"
.include "/s/ker/:key.s"
.include "/s/ker/:mem.s"
.include "/s/:pointer.s"
lfn = $05
clrscr = $93
cr = $0d ;Carriage Return
c_bang = "!" ;New Slide
c_pause = "," ;Pause Output
c_end = "." ;End Marker
ptr = $fb ;$fc
ystore = $07
slideptr = $fd ;$fe
slideidx = $02
slidehi = $ce00 ;Ptr's page byte
slidelo = $cf00 ;Y Index into page
;Configure IRQ
#rdxy $0314
#stxy romirq+1
#ldxy scanbut
sei
#stxy $0314
cli
;Prepare Screen for Output
;---------------------------------------
lda #clrscr
jsr chrout
lda #$0e ;Upper/Lower
jsr chrout
lda #$97 ;DkGrey PETSCII
jsr chrout
lda #1 ;White
sta vic+$20 ;Border
sta vic+$21 ;Background
;Clear Slide Pointer Buffer
lda #0
ldx #$ff
stx slideidx
inx
sta slidehi,x
sta slidelo,x
inx
bne *-7
;Load Presentation Data
;---------------------------------------
lda #lfn ;Logical File #
ldx $ba ;Current Dev #
ldy #$05 ;Secondary Address
jsr setlfs
lda #14 ;strlen(introc64os.pet)
#ldxy filename
jsr setnam
jsr open
ldx #lfn
jsr chkin
#ldxy buffer
#stxy ptr
;Read data into memory
.block
ldy #0
next jsr chrin
sta (ptr),y
iny
bne *+4
inc ptr+1
jsr readst
beq next
lda #0 ;Data Terminator
sta (ptr),y
.bend
lda #lfn
jsr close
jsr clrchn
;Output Presenter Data
;---------------------------------------
#ldxy buffer
#stxy ptr
.block
ldy #0
next lda (ptr),y
beq done ;Data End
sty ystore
jsr procchr
ldy ystore
iny
bne next
inc ptr+1
bne next
done
;Restore screen properties
;---------------------------------------
lda #clrscr
jsr chrout
lda #$8e ;Graphix/Upper
jsr chrout
lda #$9a ;Blue PETSCII
jsr chrout
lda #14 ;Lt.Blue
sta vic+$20 ;Border
lda #6 ;Blue
sta vic+$21 ;Background
rts
.bend
;Fallthrough if no end marker present.
endslide ;End Slide Marker Encountered
.block
iloop jsr getbut
beq iloop
cmp #jbut_up
bne *+5
jmp slidetop
cmp #jbut_lt
bne *+5
jmp slidebak
sei
jsr restor
cli
rts
.bend
newslide ;New Slide Marker Encountered
.block
ldx slideidx
bmi first
iloop jsr getbut
beq iloop
cmp #jbut_up
bne *+5
jmp slidetop
cmp #jbut_lt
bne *+5
jmp slidebak
first inc slideidx
ldx slideidx
lda ptr+1
sta slidehi,x
lda ystore
sta slidelo,x
lda #clrscr
jmp chrout
.bend
pause ;Output Pause Encountered
.block
iloop jsr getbut
beq iloop
cmp #jbut_up
bne *+5
jmp slidetop
cmp #jbut_lt
bne *+5
jmp slidebak
rts
.bend
slidebak ;Go back one slide
.block
ldx slideidx
dex
bpl *+3
inx
stx slideidx
;Fallthrough to slidetop
.bend
slidetop ;Go to top of current slide
.block
ldx slideidx
lda slidehi,x
sta ptr+1
lda slidelo,x
sta ystore
lda #clrscr
jmp chrout
.bend
procchr ;Process Character
;A -> Character
.block
cmp #cr
bne notcr
ldx #1
stx codechk
bne output
notcr ldx codechk
beq output
ldx #0
stx codechk
;Check for Control Code
cmp #c_bang
bne *+5
jmp newslide
cmp #c_pause
bne *+5
jmp pause
cmp #c_end
bne *+5
jmp endslide
output jmp chrout
codechk .byte 0
.bend
;filename .null "introc64os.pet"
filename .null "video1541u.pet"
getbut ;Get Joystick Button Event
.block
;A <- Button Event
ldx #0
lda butevt
and #jbut_f1
cmp #jbut_f1
beq done
lda butevt
and #jbut_up
cmp #jbut_up
beq done
lda butevt
and #jbut_lt
cmp #jbut_lt
beq done
lda #0
rts
done cmp #0
stx butevt
rts
.bend
scanbut ;Scan the Joystick Buttons
.block
;port = 1 for control port 1
;port = 0 for control port 2
port = 0
lda cia1+port ;Scan PRB
cmp cia1+port
bne *-6 ;Debounce
eor #$ff ;Invert
and #%00011111 ;Mask
cmp butstat
beq romirq
sta butstat
cmp #0
beq romirq
sta butevt
.bend
romirq jmp $ffff ;Self Mod
butstat .byte 0
butevt .byte 0
;Adjust to page align the buffer, but
;keep it a minimum distance from the end
;of the presenter main code.
*= $1000
buffer ;Free Memory following the binary