diff --git a/src/4cade.a b/src/4cade.a index 361ad0273..3eea90b1e 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -101,8 +101,14 @@ gGamesListStore !word Reenter ; IRQ vector ($FFFE-F) } LastMover +!pseudopc $D600 { !source "src/ui.font.data.a" !source "src/prodos.impl.a" +!warn * + !if * > $DEFF { + !error "code is too large: ends at ", * + } +} EvenLasterMover !if RELBASE = $2000 { !ifdef PASS2 { diff --git a/src/4cade.init.a b/src/4cade.init.a index e06bb5bca..3e9bc6598 100644 --- a/src/4cade.init.a +++ b/src/4cade.init.a @@ -183,19 +183,20 @@ OneTimeSetup jsr SaveOrRestoreScreenHoles ; save initial copy of screen hole content lda #$91 sta holepatch ; enable restoring of copy from now on + lda $43 + sta promote + ProDOS_unit - $bf00 + ; save unit in LC bank 2 while overriding !pseudopc + lda hddopendir+1 ; save current directory as 'root' ldy hddopendir+3 +READ_RAM1_WRITE_RAM1 +STAY gRootDirectory - lda $43 - sta promote + ProDOS_unit - $bf00 - ; save unit while overriding !pseudopc - jsr LoadFile ; load preferences file into its default address ($8000) !word kRootDirectory !word kGlobalPrefsFilename !word 0 + jsr ParseKeyValueList ; parse contents into OKVS data structure into LC RAM bank !word gGlobalPrefsStore !word ldrlo2 ; (ldrlo2) points to last load address, so $8000 diff --git a/src/constants.a b/src/constants.a index dd263bac4..f3bcfcd53 100644 --- a/src/constants.a +++ b/src/constants.a @@ -9,8 +9,8 @@ ; D000..E500 - persistent data structures (gGlobalPrefsStore, gGamesListStore) ; ...end of data and start of code are approximate, in between is unused... ; ...if they ever overlap, things will go boom... -; E800..FFFB - main program code -; FFFC..FFFF - reset and other vectors +; E800..FFF9 - main program code +; FFFA..FFFF - NMI, reset, IRQ vectors ; ; LC RAM BANK 2 ; D000..D3FF - ProRWTS data diff --git a/src/glue.prorwts2.a b/src/glue.prorwts2.a index c4211c8e2..98460b774 100644 --- a/src/glue.prorwts2.a +++ b/src/glue.prorwts2.a @@ -7,8 +7,7 @@ ; - LoadFile ; - LoadDHRFile ; - SaveSmallFile -; - CloseHandles -; - SaveScreenHoles +; - SaveOrRestoreScreenHoles ; ; A general note about paths: ; @@ -166,190 +165,6 @@ SaveSmallFile +READ_RAM1_WRITE_RAM1 rts -;------------------------------------------------------------------------------ -; traverse [private] -; -; in: (namlo) points to length-prefixed pathname+filename -; out: all flags clobbered -; all registers clobbered -;------------------------------------------------------------------------------ -traverse - +LDAY gRootDirectory - sta (reloc + unrhddblocklo - unrelochdd) + 1 - sty (reloc + unrhddblockhi - unrelochdd) + 1 - sta @myreadblock+1 - sty @myreadblock+3 ; reset 'root' directory (saved at program start) - - ;search for '/' character in filename - - ldx #0 - ldy #0 - lda (namlo), y - tay -- inx - dey - bmi @go ; no '/', just do the read - lda (namlo), y - cmp #'/' - bne - - sty sizelo - txa - pha - -@myreadblock -@myx80_parms - ldx #2 - lda #0 - jsr hddreaddirsel - lda #NAME_LENGTH - sta bloklo - lda #>(hdddirbuf - 1) - sta blokhi - - ;there can be only one page crossed, so we can increment here - -@mynextent1 - inc blokhi -@mynextent - ldy #0 - lda (bloklo), y - pha - and #$0f - tax --- iny - lda (bloklo), y - cmp (namlo), y - beq @myfoundname - - ;match failed, move to next directory in this block, if possible - -- pla - -@myskiphdr - clc - lda bloklo - adc #ENTRY_SIZE - sta bloklo - bcs @mynextent1 - cmp #$ff ;4 + ($27 * $0d) - bne @mynextent - - ;read next directory block when we reach the end of this block - - lda hdddirbuf + NEXT_BLOCK_LO - ldx hdddirbuf + NEXT_BLOCK_HI - bcs + - -@myfoundname - dex - bne -- - - ;parse path until last directory is seen - - iny - lda (namlo), y - cmp #'/' - bne - - pla - and #$20 ;Volume Directory Header XOR subdirectory - bne @myskiphdr - tya - eor #$ff - adc sizelo - sta sizelo - clc - tya - adc namlo - sta namlo - - ;cache block number of current directory - ;as starting position for subsequent searches - - ldy #(KEY_POINTER + 1) - lda (bloklo), y - tax - dey - lda (bloklo), y - sta (reloc + unrhddblocklo - unrelochdd) + 1 - stx (reloc + unrhddblockhi - unrelochdd) + 1 -+ sta @myx80_parms + 1 - stx @myx80_parms + 3 -++ lda sizelo - bne @myreadblock - tay - - pla - sta (namlo), y -@go - rts - -;------------------------------------------------------------------------------ -; promote [private] -; -; tiny ProDOS-style interface for ProRWTS -; in: whatever ProDOS expects for the supported functions -; out: carry clear, A=0 -; X, Y, and other flags clobbered -;------------------------------------------------------------------------------ - -promote -!pseudopc $bf00 { - php - sei - lda $c012 - !byte $24 - !if * != $bf06 { - !error "$BF06 misplaced (",*,")" - } - rts ;clock interface, must be RTS on real ProDOS if program uses $20x - - asl - lda $c011 - bit $c083 - jmp ProDOS_LC - !text "4Q" - !if * != $bf13 { - !error "$BF13 misplaced (",*,")" - } - !byte $c1 - !word $c2d1, $c3d1, $c4d1, $c5d1, $c6d1, $c7d1 -ProDOS_LC - bit $c083 - jmp ProDOS_enter -ProDOS_exit - sta $c082, x -ProDOS_savedX - ldx #$d1 -ProDOS_savedY - ldy #$d1 - plp - clc - !byte $24 -ProDOS_unit - !if * != $bf30 { - !error "$BF30 misplaced (",*,")" - } - !byte $d1 - - lda #0 - rts - -ProDOS_fatal ;only for debugging, will be removed - bit $c081 - pha - jsr $fe89 - jsr $fe93 - pla - jsr $fdda - jmp $ff65 -*=$bf58 - !fill $18 - -ProDOS_prefix=$bfd0 -; !fill $2e -} -end_promote - ;------------------------------------------------------------------------------ ; SaveOrRestoreScreenHoles ; preserve screen hole contents across demo execution diff --git a/src/prodos.impl.a b/src/prodos.impl.a index aab6ecd31..ae5b8e0db 100644 --- a/src/prodos.impl.a +++ b/src/prodos.impl.a @@ -362,4 +362,189 @@ ProDOS_enter @saved_zp !fill (last_zp - first_zp) + 1 + +;------------------------------------------------------------------------------ +; traverse [private] +; +; in: (namlo) points to length-prefixed pathname+filename +; out: all flags clobbered +; all registers clobbered +;------------------------------------------------------------------------------ +traverse + +LDAY gRootDirectory + sta (reloc + unrhddblocklo - unrelochdd) + 1 + sty (reloc + unrhddblockhi - unrelochdd) + 1 + sta @myreadblock+1 + sty @myreadblock+3 ; reset 'root' directory (saved at program start) + + ;search for '/' character in filename + + ldx #0 + ldy #0 + lda (namlo), y + tay +- inx + dey + bmi @go ; no '/', just do the read + lda (namlo), y + cmp #'/' + bne - + sty sizelo + txa + pha + +@myreadblock +@myx80_parms + ldx #2 + lda #0 + jsr hddreaddirsel + lda #NAME_LENGTH + sta bloklo + lda #>(hdddirbuf - 1) + sta blokhi + + ;there can be only one page crossed, so we can increment here + +@mynextent1 + inc blokhi +@mynextent + ldy #0 + lda (bloklo), y + pha + and #$0f + tax +-- iny + lda (bloklo), y + cmp (namlo), y + beq @myfoundname + + ;match failed, move to next directory in this block, if possible + +- pla + +@myskiphdr + clc + lda bloklo + adc #ENTRY_SIZE + sta bloklo + bcs @mynextent1 + cmp #$ff ;4 + ($27 * $0d) + bne @mynextent + + ;read next directory block when we reach the end of this block + + lda hdddirbuf + NEXT_BLOCK_LO + ldx hdddirbuf + NEXT_BLOCK_HI + bcs + + +@myfoundname + dex + bne -- + + ;parse path until last directory is seen + + iny + lda (namlo), y + cmp #'/' + bne - + pla + and #$20 ;Volume Directory Header XOR subdirectory + bne @myskiphdr + tya + eor #$ff + adc sizelo + sta sizelo + clc + tya + adc namlo + sta namlo + + ;cache block number of current directory + ;as starting position for subsequent searches + + ldy #(KEY_POINTER + 1) + lda (bloklo), y + tax + dey + lda (bloklo), y + sta (reloc + unrhddblocklo - unrelochdd) + 1 + stx (reloc + unrhddblockhi - unrelochdd) + 1 ++ sta @myx80_parms + 1 + stx @myx80_parms + 3 +++ lda sizelo + bne @myreadblock + tay + + pla + sta (namlo), y +@go + rts + +;------------------------------------------------------------------------------ +; promote [private] +; +; tiny ProDOS-style interface for ProRWTS +; in: whatever ProDOS expects for the supported functions +; out: carry clear, A=0 +; X, Y, and other flags clobbered +;------------------------------------------------------------------------------ + +promote +!pseudopc $bf00 { + php + sei + lda $c012 + !byte $24 + !if * != $bf06 { + !error "$BF06 misplaced (",*,")" + } + rts ;clock interface, must be RTS on real ProDOS if program uses $20x + + asl + lda $c011 + bit $c083 + jmp ProDOS_LC + !text "4Q" + !if * != $bf13 { + !error "$BF13 misplaced (",*,")" + } + !byte $c1 + !word $c2d1, $c3d1, $c4d1, $c5d1, $c6d1, $c7d1 +ProDOS_LC + bit $c083 + jmp ProDOS_enter +ProDOS_exit + sta $c082, x +ProDOS_savedX + ldx #$d1 +ProDOS_savedY + ldy #$d1 + plp + clc + !byte $24 +ProDOS_unit + !if * != $bf30 { + !error "$BF30 misplaced (",*,")" + } + !byte $d1 + + lda #0 + rts + +ProDOS_fatal ;only for debugging, will be removed + bit $c081 + pha + jsr $fe89 + jsr $fe93 + pla + jsr $fdda + jmp $ff65 +*=$bf58 + !fill $18 + +ProDOS_prefix=$bfd0 +; !fill $2e +} +end_promote + } diff --git a/src/ui.font.data.a b/src/ui.font.data.a index d6558972d..52ba8628a 100644 --- a/src/ui.font.data.a +++ b/src/ui.font.data.a @@ -4,7 +4,6 @@ ; 'Circuitous' hi-res font data ; -!pseudopc $D600 { FontDataRow0 !byte $80 !byte $80 @@ -1037,4 +1036,3 @@ FontDataRow7 !byte $86 !byte $80 !byte $FF -} diff --git a/winmake.bat b/winmake.bat index ddc66c93d..0398546b3 100644 --- a/winmake.bat +++ b/winmake.bat @@ -34,8 +34,8 @@ if "%1" equ "asm" ( 2>nul md build\FX 2>build\out.txt %ACME% -r build\4cade.lst src\4cade.a -for /f "tokens=2,3 delims=)" %%q in ('find "RELBASE =" build\out.txt') do set _make=%%q -%ACME% -DRELBASE=$%_make:~-4% -r build\4cade.lst src\4cade.a +for /f "tokens=*" %%q in (build\out.txt) do set _make=%%q +%ACME% -DRELBASE=$!_make:~-5,4! -r build\4cade.lst src\4cade.a %ACME% src\fx\fx.cover.fade.a %ACME% src\fx\fx.dhgr.fizzle.a %ACME% src\fx\fx.dhgr.fizzle.white.a