; lenser -- Apple II HGR boot loader + viewer (self-contained, no DOS) ; ; The Disk II boot ROM loads track 0 sector 0 to $0800 and JMPs $0801. This ; re-entrant loader reads the 32 sectors of the 8K HGR bitmap into $2000-$3FFF ; (track 0 sectors 1-15, then tracks 1 and 2), seeking the head between tracks ; with the standard phase-overlap step, then switches on HGR and loops. The ROM ; read at $Cn5C verifies the address field against BOTH the sector ($3D) and the ; track ($41), then reads into page $27 and JMPs back to $0801. ; ; assembled by apple/viewer/assemble.py via xa * = $0800 .byte $01 ; ROM scratch (boot sector byte 0) entry: ; $0801, (re)entered after every ROM read lda dpage cmp #$40 bcs done ; loaded $2000..$3FFF -> show it lda psec cmp #$10 bcc readit ; still sectors left on this track jsr seeknext ; finished a track -> step to the next lda #$00 sta psec readit: lda psec sta $3d ; desired sector lda curtrk sta $41 ; desired track (ROM read verifies both) lda #$00 sta $26 ; buffer lo lda dpage sta $27 ; buffer hi inc psec inc dpage ldx $2b ; slot*16 (set by boot ROM) jmp $c65c ; slot 6 ROM read; reads sector then JMP $0801 done: lda $c050 ; graphics lda $c052 ; full screen (not mixed) lda $c054 ; page 1 lda $c057 ; hi-res #include "awyt.i" ; advance the head one track (two half-steps) with the standard phase-overlap ; step. energize the next phase while the current one is still on, then release ; the old phase, using on/off settle delays from an acceleration table. seeknext: inc curtrk lda #$00 sta $0a jsr onestep jsr onestep lda halftrk ; release final phase before reading and #$03 asl ora $2b tax lda $c080,x rts onestep: lda halftrk ; energize NEXT phase (old still on -> overlap) clc adc #$01 and #$03 asl ora $2b tax lda $c081,x ldx $0a lda ontable,x jsr wait lda halftrk ; release OLD phase 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 ; ---- loader state (initial values; updated in place during the load) ---- psec: .byte $01 ; next physical sector (track 0 starts at 1) dpage: .byte $20 ; next destination page ($2000) halftrk: .byte $00 ; current half-track curtrk: .byte $00 ; current track