204 lines
4.4 KiB
ArmAsm
204 lines
4.4 KiB
ArmAsm
; lenser -- Apple II HGR slideshow loader + viewer (self-contained, no DOS).
|
|
;
|
|
; The Disk II boot ROM loads track 0 sector 0 to $0800 and JMPs $0801. This
|
|
; loader reads ALL the slideshow's HGR images (NIMAGES * 32 sectors) contiguously
|
|
; into a RAM buffer from $4000 up (image i at $4000 + i*$2000), then cycles --
|
|
; copying each image into HGR page 1 ($2000), switching on graphics, and waiting
|
|
; (key / seconds / both) before the next. Looping is RAM-only (no re-seek).
|
|
;
|
|
; #defines from the wrapper --
|
|
; WAITMODE 1 key / 2 seconds / 3 both WAITSECS seconds (~) NIMAGES count
|
|
; LOOPFLAG 1 wrap / 0 stop ENDPAGE one past the last buffer page ($40+N*$20)
|
|
;
|
|
; assembled by apple/viewer/assemble.py via xa
|
|
|
|
src = $06 ; zero-page copy pointers
|
|
dst = $08
|
|
ssidx = $19
|
|
|
|
* = $0800
|
|
.byte $01 ; ROM scratch (boot sector byte 0)
|
|
entry: ; $0801, (re)entered after every ROM read
|
|
lda dpage
|
|
cmp #ENDPAGE
|
|
bcs loaded ; whole buffer read -> start the show
|
|
lda psec
|
|
cmp #$10
|
|
bcc readit
|
|
jsr seeknext
|
|
lda #$00
|
|
sta psec
|
|
readit:
|
|
lda psec
|
|
sta $3d
|
|
lda curtrk
|
|
sta $41
|
|
lda #$00
|
|
sta $26
|
|
lda dpage
|
|
sta $27
|
|
inc psec
|
|
inc dpage
|
|
ldx $2b
|
|
jmp $c65c ; slot-6 ROM read; reads a sector then JMP $0801
|
|
|
|
loaded:
|
|
lda #$00
|
|
sta ssidx
|
|
cyc:
|
|
; ---- copy image ssidx ($4000 + ssidx*$2000) -> HGR page 1 ($2000) ----
|
|
lda ssidx
|
|
asl
|
|
asl
|
|
asl
|
|
asl
|
|
asl ; ssidx * $20 pages (carry clear, <=4 images)
|
|
adc #$40
|
|
sta src+1 ; source hi = $40 + ssidx*$20
|
|
lda #$00
|
|
sta src
|
|
sta dst
|
|
lda #$20
|
|
sta dst+1 ; dest = $2000
|
|
ldx #$20 ; 32 pages
|
|
ldy #$00
|
|
cpyl:
|
|
lda (src),y
|
|
sta (dst),y
|
|
iny
|
|
bne cpyl
|
|
inc src+1
|
|
inc dst+1
|
|
dex
|
|
bne cpyl
|
|
|
|
lda $c050 ; graphics
|
|
lda $c054 ; page 1
|
|
lda $c057 ; hi-res
|
|
|
|
jsr sswait
|
|
|
|
inc ssidx
|
|
lda ssidx
|
|
cmp #NIMAGES
|
|
bcc cyc
|
|
#if LOOPFLAG == 1
|
|
jmp loaded ; wrap (re-uses the ssidx=0 init at loaded)
|
|
#else
|
|
lda $c051 ; text
|
|
lda $c054
|
|
jmp $e000 ; Applesoft cold start
|
|
#endif
|
|
|
|
; ---- wait (returns); clears the key strobe first ----
|
|
sswait:
|
|
bit $c010
|
|
#if WAITMODE == 1
|
|
swk:
|
|
lda $c000
|
|
bpl swk
|
|
bit $c010
|
|
rts
|
|
#endif
|
|
#if WAITMODE == 2
|
|
lda #WAITSECS
|
|
sta $fd
|
|
so:
|
|
lda #$03
|
|
sta $fc
|
|
sm:
|
|
ldx #$00
|
|
sx:
|
|
ldy #$00
|
|
sy:
|
|
dey
|
|
bne sy
|
|
dex
|
|
bne sx
|
|
dec $fc
|
|
bne sm
|
|
dec $fd
|
|
bne so
|
|
rts
|
|
#endif
|
|
#if WAITMODE == 3
|
|
lda #WAITSECS
|
|
sta $fd
|
|
bo:
|
|
lda #$03
|
|
sta $fc
|
|
bm:
|
|
ldx #$00
|
|
bx:
|
|
lda $c000
|
|
bmi bdone ; a key ends the slide
|
|
ldy #$00
|
|
by:
|
|
dey
|
|
bne by
|
|
dex
|
|
bne bx
|
|
dec $fc
|
|
bne bm
|
|
dec $fd
|
|
bne bo
|
|
bdone:
|
|
bit $c010 ; (also harmless on timeout)
|
|
rts
|
|
#endif
|
|
|
|
; advance the head one track (two half-steps), phase-overlap step (from hgr.s)
|
|
seeknext:
|
|
inc curtrk
|
|
lda #$00
|
|
sta $0a
|
|
jsr onestep
|
|
jsr onestep
|
|
lda halftrk
|
|
and #$03
|
|
asl
|
|
ora $2b
|
|
tax
|
|
lda $c080,x
|
|
rts
|
|
onestep:
|
|
lda halftrk
|
|
clc
|
|
adc #$01
|
|
and #$03
|
|
asl
|
|
ora $2b
|
|
tax
|
|
lda $c081,x
|
|
ldx $0a
|
|
lda ontable,x
|
|
jsr wait
|
|
lda halftrk
|
|
and #$03
|
|
asl
|
|
ora $2b
|
|
tax
|
|
lda $c080,x
|
|
ldx $0a
|
|
lda offtable,x
|
|
jsr wait
|
|
inc halftrk
|
|
inc $0a
|
|
rts
|
|
ontable: .byte $13,$0a,$08,$06
|
|
offtable: .byte $46,$1a,$10,$0c
|
|
wait:
|
|
tay
|
|
w1:
|
|
ldx #$00
|
|
w2:
|
|
dex
|
|
bne w2
|
|
dey
|
|
bne w1
|
|
rts
|
|
|
|
psec: .byte $01 ; next physical sector (track 0 starts at 1)
|
|
dpage: .byte $40 ; next destination page ($4000)
|
|
halftrk: .byte $00
|
|
curtrk: .byte $00
|