;license:BSD-3-Clause ;minimal open/read binary file in ProDOS filesystem ;copyright (c) Peter Ferrie 2016-2019 !cpu 6502 !to "build/proboothd",plain *=$800 !src "src/macros.a" ;zpage usage, arbitrary selection except for the "ProDOS constant" ones command = $42 ;ProDOS constant unit = $43 ;ProDOS constant adrlo = $44 ;ProDOS constant adrhi = $45 ;ProDOS constant bloklo = $46 ;ProDOS constant blokhi = $47 ;ProDOS constant A2L = $3e A2H = $3f sizehi = $53 ;constants scrn2p2 = $f87b dirbuf = $1e00 ;for size-optimisation !byte 1 txa pha !src "src/4cade.init.machine.a" lda KBD cmp #$D3 ; 'S' beq @s cmp #$F3 ; 's' bne + @s jsr seasons + !src "src/4cade.init.screen.a" ; print text title in same place as graphical title will appear jsr PrintBranding pla sta unit tax ; X = boot slot x16 ; Y = 0 ; set up ProDOS shim - txa jsr scrn2p2 and #7 ora #$c0 sta $be30, y sta slot+2 sta entry+2 slot lda $cfff sta entry+1 lda fakeMLI_e-$100, y sta $be00+fakeMLI_e-fakeMLI, y iny bne - sty adrlo stx $bf30 sty $200 opendir ;read volume directory key block ldx #2 ;include volume directory header in count firstent lda #>dirbuf sta adrhi sta A2H jsr seekread lda #4 sta A2L nextent ldy #0 ;match name lengths before attempting to match names lda (A2L), y and #$0f tax inx - cmp filename, y beq foundname ;move to next directory in this block clc lda A2L adc #$27 sta A2L bcc + ;there can be only one page crossed, so we can increment instead of adc inc A2H + cmp #$ff ;4+($27*$0d) bne nextent ;read next directory block when we reach the end of this block ldx dirbuf+2 ldy dirbuf+3 bcs firstent foundname iny lda (A2L), y dex bne - stx $ff ;cache KEY_POINTER ldy #$11 lda (A2L), y tax iny lda (A2L), y tay readfile jsr seekread inc adrhi inc adrhi ;fetch data block and read it blockind ldy $ff inc $ff ldx dirbuf, y lda dirbuf+256, y tay bne readfile txa bne readfile readdone jmp ProBootEntry seekread stx bloklo sty blokhi lda #1 sta command lda adrhi pha entry jsr $d1d1 pla sta adrhi rts fakeMLI bne retcall readblk dey dey sty adrhi tay jsr $bf00+seekread-fakeMLI retcall pla tax inx inx inx txa pha - rts fakeMLI_e ; Interactive Seasons demo ; based on Apple II Seasons -=DESiRE=- 128B Demo for Outline 2020 ; based on the code in Hellmood's 64B x86 demo 'Autumn' ; by deater (Vince Weaver) ; adapted by 4am for use within this bootloader ; /!\ While demo is running, press 1-4 to change color palettes ; or Esc to quit demo and continue the boot HGR2 = $F3D8 ; Set full-screen hi-res mode using page 2 ($4000) HPLOT0 = $F457 ; Plot point, (Y,X) = Horizontal, (A=Vertical) HCOLOR = $F6EC ; Set color in X, must be 0..7 seasons: bit $c010 jsr HGR2 ldx #(copy_seasons_e-copy_seasons) - lda copy_seasons-1, x sta $30, x dex bne - jmp seasons_forever copy_seasons: ; HGR ROM routines use ; $1C mask for color ; $26/$27 address for plot ; $30 color value * 17 ; $E0/$E1 X coord of last hplot ; so code starts at $31 and must end before $E0 !pseudopc $31 { EBP1 !byte 0 EBP2 !byte 0 EBP3 !byte 0 EBP4 !byte 0 color_lookup_lookup: !byte $9f7) { !serious "Bootloader is too large" } *=$9f8 !byte $D3,$C1,$CE,$A0,$C9,$CE,$C3,$AE