forked from frankmilliron/play.vids.system
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplay.vids.system.a
More file actions
executable file
·624 lines (504 loc) · 19.1 KB
/
play.vids.system.a
File metadata and controls
executable file
·624 lines (504 loc) · 19.1 KB
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
x
; play.vids.system.a
; Play video files in all graphics modes
; December 25, 2022
; (c) 2022 by Frank Milliron, Lombard $oftware
; https://github.com/frankmilliron/play.vids.system
; Includes ProRWTS2 by Peter Ferrie AKA qkumba
; https://github.com/peterferrie/prorwts2
; "acme play.vids.system.a" to assemble
; Playback Modes set in VidType:
; #1 - file_type $5B (ANM) - aux_type $1001 = GR mode playback
; #2 - file_type $5B (ANM) - aux_type $1002 = DGR mode playback
; #3 - file_type $5B (ANM) - aux_type $1003 = HGR mode playback
; #4 - file_type $5B (ANM) - aux_type $1004 = DHGR mode playback
; #5 - file_type $5B (ANM) - aux_type $1005 = 40-col text mode
; #6 - file_type $5B (ANM) - aux_type $1006 = 80-col text mode
; * ANM "Animation"
; Memory Map:
; Player core relocated to $C00-1000 ($400)
; ProRWTS2 installed to $1000-1300 ($300)
; ProRWTS tree buffer $1300-1500 ($200)
; ProRWTS block buffer $1700-1900 ($200)
; Video loaded directly to video buffers at $400/$800 & $2000/$4000
; TODO:
; MAKE PLAYBACK WORK IN ALL MODES, ON ALL MACHINES, WITH ALL MASS STORAGE
; load lores and double-lores file natively (use b2d output, avoid screen holes)
; "scanline oriented single file"
; Compute file size on load (EOF tracking)
; Save //gs speed on load - set slow to play - restore on exit
; //gs text page 2 fix - detect if Alternate Screen Mode is on
; hangs on ][+ waiting for VBL
; text mode ascii animation?
!cpu 6502
!to "BASIS.SYSTEM#ff0000",plain
;!symbollist "BASIS.SYSTEM.list.txt"
*=$2000
; ****************************************************************
; * Constants *
; ****************************************************************
EmuVar = $76 ; used for emulator test & playback
HGR_Page = $77 ; used by ROM graphics clear routine
LoadEOR = $78 ; switch between loading to page 1 or 2
VidType = $79 ; picked up from GET_FILE_ATTRIBUTES
VidSize = $7A ; set based on video type
VidName = $300 ; video file to play
Reloc = $C00 ; video player code relocated here
MLI = $BF00 ; ProDOS Machine Language Interface entry
MACHID = $BF98 ; ProDOS Machine Identification Byte
Keyboard = $C000 ; get keypress
KeyStrobe = $C010 ; clear keyboard strobe
VBL = $C019 ; vertical blank
SS_Main = $C004 ; write to main mem
SS_Aux = $C005 ; write to aux mem
SS_40col = $C00C ; set 40-column mode
SS_80col = $C00D ; set 80-column mode
SS_Border = $C034 ; set //gs border color
SS_Speed = $C036 ; set //gs processor speed
SS_Float = $C04F ; test for floating bus
SS_Grfx = $C050 ; graphics mode
SS_Full = $C052 ; full-screen mode
SS_Page1 = $C054 ; show graphics page 1
SS_Page2 = $C055 ; show graphics page 2
SS_Lores = $C056 ; turn on lores graphics
SS_Hires = $C057 ; turn on hires graphics
SS_DblOn = $C05E ; turn on double graphics modes
SS_DblOff = $C05F ; turn off double graphics modes
ROM_Text2Copy = $F962 ; turn on alternate display mode on //gs
ROM_Home = $FC58 ; clear text screen 1
ROM_Text = $FB2F ; exit graphics mode
ROM_Pwrup = $FB6F ; set reset vector checksum
ROM_Wait = $FCA8 ; not critical, only used for VBL check on //gs
ROM_TestGS = $FE1F ; test for //gs
;ProRWTS2-specific:
auxreq = $51 ; set to 1 to read to aux memory
sizelo = $52 ; size of data to load
sizehi = $53 ; size of data to load
reqcmd = $54 ; set to 1 for cmdread
ldrlo = $55 ; address to load the data
ldrhi = $56 ; address to load the data
namlo = $57 ; name of file to access
namhi = $58 ; name of file to access
treeidx = $5B ; tree index
blkindx = $F8 ; block index
hddrdwrpart = $1000 ; read part of file
; ****************************************************************
; * Create BASIS.SYSTEM Format *
; ****************************************************************
; When a file is selected, ProDOS launches /VOL/BASIS.SYSTEM with:
; 1) The ProDOS prefix set to the directory containing the selected file
; 2) The filename of the selected file stored at $2006
; 3) $280 is set to the name of the root volume (Bitsy Bye only)
; 4) $380 is set to the name of the launched SYS file (ie, /VOL/BASIS.SYSTEM)
; NOTE: Bitsy Bye may leave some of the paths lowercased and high bits set (!)
jmp BASIS
!hex EE EE ; signifies launchable prodos file
!byte $41 ; prodos path buffer length (65 bytes)
!fill 65,0 ; prodos full path buffer
BASIS ; *=$2047
sta KeyStrobe ; clear stray keypresses
MoveFilename
ldy $2006 ; copy filename from BASIS buffer
- lda $2006,y
and #$7F ; strip high bit
cmp #$60 ; in lowercase range?
bcc ++ ; no, leave it alone
and #$DF ; yes, make uppercase
++ sta VidName,y
dey
bpl -
GetAttributes
jsr MLI
!byte $C4 ; get file attributes
!word C4_Parms
lda C4_Parms+4 ; file_type must be $5B (ANM) "Animation"
cmp #$5B
beq AuxType
jmp Exit+Reloc ; we haven't relocated yet
AuxType lda C4_Parms+6 ; high byte of aux_type must be $10 ($10xx)
cmp #$10
beq SetType
jmp Exit+Reloc ; we haven't relocated yet
SetType lda C4_Parms+5 ; low byte of aux_type is video type (see table)
sta VidType
ProRWTS2 jsr init ; sets up ProRWTS2, relocates itself to $1000
lda #>VidName ; set filename
sta namhi
lda #<VidName
sta namlo
ldx #1 ; cmdread
stx reqcmd
dex
stx ldrlo
stx sizelo
ldy #0
Move lda Relocated,y
sta Reloc,y
dey
bne Move
inc Move+2
inc Move+5
lda Move+5
cmp #$10 ; stop moving at $1000
bne Move
jmp Reloc
C4_Parms ; GET_FILE_INFO ($C4) Parameters
!byte $0a ; param_count
!word VidName ; pathname
!byte 0 ; access
!byte 0 ; file_type
!word 0 ; aux_type
!byte 0 ; storage_type
!word 0 ; blocks_used
!word 0 ; mod_date
!word 0 ; mod_time
!word 0 ; create_date
!word 0 ; create_time
; ****************************************************************
; * Initialize Everything *
; ****************************************************************
Relocated
!pseudopc Reloc {
jsr TestGS
jsr SetReset
jsr TestVBL ; wait until v blank to change modes
lda VidType ; jump table?
cmp #1
beq SetupGR
cmp #2
beq SetupDGR
cmp #3
beq SetupHGR
cmp #4
beq SetupDHGR
jmp Exit
SetupGR
lda #$04 ; $400 bytes at $400
sta VidSize
sta sizehi
lda #$08 ; first load to page 2
sta ldrhi
lda #$0C
sta LoadEOR ; swap ldrhi between $400 & $800
jsr EmuTest
jsr hddopendir
jmp Play
SetupDGR
lda #$04 ; $400 bytes at $400, two times per frame, AUX then Main
sta VidSize
sta sizehi
lda #$08 ; first load to page 2
sta ldrhi
lda #$0C ; swap ldrhi between $400 & $800
sta LoadEOR
jmp SetupAux
SetupHGR
lda #$20
sta VidSize ; $2000 bytes at $2000
sta sizehi
lda #$40 ; first load to page 2
sta ldrhi
lda #$60
sta LoadEOR ; swap ldrhi between $2000 & $4000
jsr EmuTest
jsr hddopendir
jmp Play
SetupDHGR
lda #$20
sta VidSize ; $2000 bytes at $2000, two times per frame, AUX then Main
sta sizehi
lda #$40 ; first load to page 2
sta ldrhi
lda #$10
sta BlkIndex+1 ; has to be larger for DHGR ???
lda #$60
sta LoadEOR ; fall through
SetupAux jsr EmuTest
sta SS_Aux
ldy #0
CopyPro lda $1000,y ; copy ProRWTS2 to AUX
sta $1000,y
lda $1100,y
sta $1100,y
lda $1200,y
sta $1200,y
iny
bne CopyPro
sta SS_Main
;SetupAux jsr hddopendir
sta SS_Aux
CopyTree lda $1700,x ; X is set by hddopendir
sta $1700,x
lda $1800,x
sta $1800,x ; copy ProRWTS2 tree buffer to AUX
inx
bne CopyTree
Adjust sta SS_Aux
CopyBlk lda $1300,x
sta $1300,x
lda $1400,x
sta $1400,x ; copy ProRWTS2 block buffer to AUX
inx
bne CopyBlk
beq Resume ;Single
; ****************************************************************
; * Main Playback Routine *
; ****************************************************************
Play lda VidType ; single or double load?
cmp #1
beq Single
cmp #3
beq Single
Double lda #1
sta auxreq ; first half of frame loaded to aux first
lda VidSize
sta sizehi ; refresh on each load
jsr hddrdwrpart
bcs Exit1 ; quit at end of file <----Fix
lda blkindx
BlkIndex cmp #2 ; watch for 64kb wrap-around
beq Adjust
Resume lda #0 ; load second part in main
sta auxreq
lda VidSize
sta sizehi ; refresh on each load
jsr hddrdwrpart
bcs Exit1
bcc SetGrfx
Single lda #0
sta auxreq ; single modes main only
lda VidSize
sta sizehi
jsr hddrdwrpart
bcs Exit1
SetGrfx jsr Grfx ; page loaded, switch graphics modes **self-modified
PageFlip bit SS_Page2 ; start showing page 2 **self-modified
lda PageFlip+1
eor #1 ; flip between showing page 1 & 2
sta PageFlip+1
lda ldrhi
eor LoadEOR ; flip between loading to page 1 & 2
sta ldrhi
ChkKey lda Keyboard
bpl Play ; no key pressed
jmp Key
Exit1 jmp Exit
; ****************************************************************
; * Keypress Handler *
; ****************************************************************
;TODO double modes increment 2 for ff/rew?
Key sta KeyStrobe
Rew cmp #$88 ; left arrow key pressed? ($08+80)
bne FastFor
ldx treeidx
beq Play ; if treeidx is already 0 don't rewind
dex
beq Rew1 ; if it's 1, decrement 1
dex ; otherwise decrement 2
Rew1 stx treeidx
jmp DoReset1 ; restart playback using reset routine
FastFor cmp #$95 ; right arrow key pressed? ($15+80)
bne Pause
inc treeidx
jmp DoReset1
Pause cmp #$A0 ; space bar pressed? ($20+80)
bne OneKey
Pause1 lda Keyboard
bpl Pause1 ; test for second keypress
cmp #$9B ; escape key pressed? ($1B+80)
beq Exit2
cmp #$A0
beq Pause2
bit KeyStrobe
jmp Pause1
Pause2 bit KeyStrobe
jmp Play
OneKey cmp #$B1 ; "1" key pressed? ($31+80)
bne TwoKey
bit SS_DblOff ; turn off double graphics mode
jmp Play
TwoKey cmp #$B2 ; "2" key pressed? ($32+80)
bne Esc
bit SS_DblOn ; turn on double graphics mode
jmp Play
Esc cmp #$9B ; escape key pressed? ($1B+80)
beq Exit2
jmp Play
Exit2 jmp Exit
; ****************************************************************
; * Turn on Graphics Modes *
; ****************************************************************
Grfx lda #$2C ; BIT
sta SetGrfx ; only need to call once
sta SS_Grfx
sta SS_Full
lda VidType ; jump table instead???
cmp #1
beq GrfxGR
cmp #2
beq GrfxDGR
cmp #3
beq GrfxHGR
cmp #4
beq GrfxDHGR
GrfxGR sta SS_40col
sta SS_Lores
sta SS_DblOff
rts
GrfxDGR sta SS_80col
sta SS_Lores
sta SS_DblOn
rts
GrfxHGR sta SS_40col
sta SS_Hires
sta SS_DblOff
rts
GrfxDHGR sta SS_80col
sta SS_Hires
sta SS_DblOn
rts
; ****************************************************************
; * Vertical Blank *
; ****************************************************************
TestVBL lda MACHID
cmp #%01000000 ; Do we have a ][+?
beq IIplus ; ][+ doesn't have VBL --- floating bus??
cmp #%10001000 ; Do we have a //c?
beq NoVBL ; //c does VBL as interrupt
VBLon bit VBL ; Wait for full vertical blank (every 1/60th sec)
bpl VBLon
VBLoff bit VBL
bmi VBLoff
NoVBL rts
IIplus lda VidType ; we can't play DGR or DHGR on ][+ --message?
cmp #2
beq Exit2
cmp #4
beq Exit2
rts
; ****************************************************************
; * Control-Reset Handler *
; ****************************************************************
SetReset lda #<DoReset
sta $3F2
lda #>DoReset
sta $3F3
jsr ROM_Pwrup ; set checksum
rts
DoReset sta KeyStrobe
jsr TestGS ; re-setup //gs border color & speed
jsr Grfx
lda treeidx
beq DoReset1 ; already at the beginning, don't adjust
dec treeidx ; play last section again
DoReset1 lda #0 ; set load to main memory
sta auxreq
sta blkindx ; clear entries
lda VidSize
sta sizehi
jsr hddrdwrpart
bcs Exit3
jmp Play
Exit3 jmp Exit
; ****************************************************************
; * Emulator-specific Routines *
; ****************************************************************
EmuTest ldx #$FF ; Test floating bus 255 times
lda #0
sta EmuVar ; zero out count of positive tests
Emu1 sta SS_Float ; tickle Sweet16
lda SS_Float ; load value from bus
cmp #0 ; Virtual ][? (always returns $00)
beq Emu3
cmp #$16 ; Sweet16? (returns $16 when tickled, $30 otherwise)
beq Emu3
Emu2 dex ; keep counting
cpx #0
beq Emu4 ; done with 255 tests yet?
jmp Emu1 ; If not, keep going
Emu3 inc EmuVar ; found potential emulator, increment count
jmp Emu2
Emu4 lda EmuVar ; load counts
cmp #$FF ; 255 tests of 255 runs positive for emulation?
beq EmuFix ; if yes, patch the code
rts ; otherwise, just exit cuz we're on "normal" "hardware"
EmuFix lda #$4C ; JMP
sta PageFlip
lda #<EmuWait ; set branch from normal playback routine
sta PageFlip+1 ; during page flipping operations
lda #>EmuWait ; (which emulators can't display properly)
sta PageFlip+2 ; to slightly revised EmuWait routine
lda VidSize ; first load to page 1
sta ldrhi
lda #5 ; number of VBL to wait
sta EmuVar
rts
EmuWait ldx EmuVar ; wait for 6 vertical blank periods (10fps)
- jsr TestVBL ; sync next vertical blank period
dex
bpl -
bit SS_Page1 ; always show Page 1
lda VidSize
sta ldrhi ; always load to page 1
jmp ChkKey ; Resume playback using PLAY after keypress check
; ****************************************************************
; * //gs-specific routines *
; ****************************************************************
TestGS sec
jsr ROM_TestGS ; does RTS on //e, clears carry on //gs
bcc SetGS
clc
rts ; not a //gs, just exit
SetGS lda #0
sta SS_Border ; turn border color black - store/restore?
lda SS_Speed
and #%01111111
sta SS_Speed ; sets processor speed to normal - store/restore?
TestADM tya ; GS ID routine returns with ROM version in Y
cpy #0 ; ROM 0?
beq +
cpy #1 ; ROM 1?
beq +
lda #$20
sta $0800 ; Alternate Display Mode already on?
lda #$FF
jsr ROM_Wait ; skip a VBL cycle
!cpu 65816
lda $E00800 ; If yes, we shadow copied to bank $E0
cmp #$20
beq + ; only call TEXT2COPY if we know it's off
!cpu 6502 ; https://archive.org/details/develop-04_9010_October_1990/page/n51/mode/1up
+ jsr ROM_Text2Copy ; set Alternate Display Mode on IIgs
;+
++ rts
; lda #$30 ; //gs reverses VBL, so
; sta VBLon+3 ; swap BPL for BMI
; lda #$10
; sta VBLoff+3 ; swap BMI for BPL
; ****************************************************************
; * Goodbye! *
; ****************************************************************
Exit jsr TestVBL ; wait until v blank to change modes
sta KeyStrobe
sta SS_Main
sta SS_40col
sta SS_DblOff
jsr ROM_Text
jsr ROM_Home
inc $3F4 ; invalidate reset vector
jsr MLI
!byte $65 ; ProDOS QUIT
!word ExitParms
ExitParms
!byte 4 ; 4 parameters
!byte 0
!word 0 ; none used
!byte 0
!word 0
EndReloc
}
; ****************************************************************
; * Pack In ProRWTS2 *
; ****************************************************************
!source "prorwts2.a"
!warn "Relocated code is ", EndReloc-Reloc, "bytes. Must be less than $400."