diff --git a/src/constants.a b/src/constants.a index 10d518d65..d458bda90 100644 --- a/src/constants.a +++ b/src/constants.a @@ -11,21 +11,20 @@ ; ...unused... ; E000..E3FF - HGR font data ; ...unused... -; E8FF..FFEE - main program code +; E8F2..FFEE - main program code ; FFEF..FFF9 - API functions and global constants available for main program ; code, prelaunchers, transition effects, &c. ; (LoadFileDirect, Wait/UnwaitForVBL, MockingboardStuff, MachineStatus) ; FFFA..FFFF - NMI, reset, IRQ vectors ; ; LC RAM BANK 2 -; D000..D3FF - ProRWTS data -; D400..D6C3 - ProRWTS code -; D6C4..DAB9 - ProRWTS glue code -; DABA..DABF - backup of stack (during gameplay and self-running demos) -; DAC0..DAC5 - okvs cache (attract state saved across self-running demo) +; D000..D5FF - ProRWTS data +; D600..D8B4 - ProRWTS code +; D8C5..DC86 - ProRWTS glue code +; DC87..DC8C - backup of stack (during gameplay and self-running demos) +; DC8D..DC92 - okvs cache (attract state saved across self-running demo) ; ...unused... -; DBB4..DBFF - (de)acceleration function -; DC00..DFFF - unused +; DFB4..DFFF - (de)acceleration function ; ; MAIN MEMORY DURING SEARCH/BROWSE MODE ; 6000..9FFF - search index @@ -176,7 +175,7 @@ MockingboardStuff = $FFF8 ; bit 7 = 1 if speech chip present (Mockingboard "C" MachineStatus = $FFF9 ; LC RAM 2 -DisableAccelerator = $DBB4 +DisableAccelerator = $DFB4 EnableAccelerator = DisableAccelerator+3 ; AND masks for MockingboardStuff @@ -198,11 +197,11 @@ CHEATS_ENABLED = %00001000 PRELAUNCH_STANDARD_SIZE = 61 ; LoadStandardPrelaunch, eventually to be determined at build-time ; shared symbols for prelaunch and effects to call ProRWTS2 functions -iCurBlockLo = $D401 ; constant -iCurBlockHi = $D403 ; constant -launchpatch = $D662 ; glue.launch.a -iAddToPath = $FEA5 ; Roger Rabbit, avoid, use Infiltrator 2 style instead -itraverse = $D964 ; Roger Rabbit, avoid, use Infiltrator 2 style instead +iCurBlockLo = $D601 ; constant +iCurBlockHi = $D603 ; constant +launchpatch = $D853 ; glue.launch.a +iAddToPath = $FEC7 ; Roger Rabbit, avoid, use Infiltrator 2 style instead +itraverse = $DB31 ; Roger Rabbit, avoid, use Infiltrator 2 style instead ldrlo = $55 ; constant ldrhi = $56 ; constant namlo = $57 ; constant diff --git a/src/prodos.impl.lc2.a b/src/prodos.impl.lc2.a index 5d5cc0ce5..d87f85bed 100644 --- a/src/prodos.impl.lc2.a +++ b/src/prodos.impl.lc2.a @@ -1,5 +1,5 @@ ;license:MIT -;(c) 2019-2020 by 4am & qkumba +;(c) 2019-2021 by 4am & qkumba ; ; Pseudo-ProDOS environment ; @@ -218,63 +218,37 @@ ProDOS_enter resetval=$f0 @imp_seek jsr @set_rdwrbuff - ldx #0 - stx blkidx - stx treeidx - stx blkofflo - stx blkoffhi - stx reqcmd - ldy sizelo - beq @testzero -@seekloop - jsr @reset - ldy sizelo - bne @seek64 - cmp ldrhi - bcc @seek64 - bne @seek32 - cpx ldrlo - bne @seek64 - -@seek32 + lda sizelo + lsr + pha lda ldrhi - ldx ldrlo -@seek64 - sta sizehi - stx sizelo - lda ldrhi - pha - lda sizehi - pha - lda ldrlo - pha - txa - pha - tya - pha - jsr @seekreset + ror + sta blkidx pla tay - sec - pla - sta ldrlo - pla - sbc ldrlo - sta ldrlo - pla - sta ldrhi - pla - sbc ldrhi - sta ldrhi -@testzero - tya - sbc #0 + tax + lda istree + beq @sametree + inx + cpx treeidx + beq @sametree + stx treeidx + ldx hddtreebuf, y + lda hddtreebuf + 256, y + jsr hddreaddirsel + +@sametree + lda ldrlo sta sizelo - ora ldrlo - ora ldrhi - bne @seekloop + lda ldrhi + and #1 + sta sizehi + ora sizelo + beq @link_jmpzp + jsr @seekreset + @link_jmpzp - jmp @jmp_zp + jmp @restore_zp @seekreset jsr hddrdwrpart @@ -341,12 +315,14 @@ resetval=$f0 stx dirbufpatch9+2 stx dirbufpatch10+1 stx dirbufpatch11+1 - stx dirbufpatch12+1 - stx dirbufpatch13+2 inx stx dirbufpatch5+2 stx dirbufpatch8+2 - stx dirbufpatch14+2 + inx + stx treebufpatch1+1 + stx treebufpatch2+2 + inx + stx treebufpatch3+2 @close_ret rts diff --git a/src/prorwts2.a b/src/prorwts2.a index 4c3b82fca..45be242b3 100644 --- a/src/prorwts2.a +++ b/src/prorwts2.a @@ -45,12 +45,12 @@ ver_02 = 1 allow_saplings=1 ;enable support for saplings allow_trees = 1 ;enable support for tree files, as opposed to only seedlings and saplings ;required in RWTS mode if file > 128kb - fast_trees = 0 ;keep tree block in memory, requires an additional 512 bytes of RAM + fast_trees = 1 ;keep tree block in memory, requires an additional 512 bytes of RAM always_trees = 0 ;set to 1 if the only file access involves tree files ;not compatible with allow_subdir, allow_saplings ;required in RWTS mode if allow_trees is enabled detect_treof = 0 ;detect EOF during read of tree files - fast_subindex= 0 ;keep subindex block in memory, requires an additional 512 bytes of RAM + fast_subindex= 1 ;keep subindex block in memory, requires an additional 512 bytes of RAM ;halves the disk access for double the speed (ideal for RWTS mode) allow_sparse = 1 ;enable support for reading sparse files write_sparse = 0 ;enable support for writing to sparse files (blocks are allocated even if empty) @@ -93,7 +93,7 @@ ver_02 = 1 reloc = $fe00 ;page-aligned, as high as possible, the ideal value will be shown on mismatch } ;PASS2 } else { ;load_high = 0 - reloc = $d400 ;page-aligned, but otherwise wherever you want + reloc = $d600 ;page-aligned, but otherwise wherever you want } ;load_high = 1 } else { ;load_banked = 0 !if load_high = 1 { @@ -1453,9 +1453,6 @@ rdwrloop !if aligned_read = 0 { php } ;aligned_read = 0 - lda #>dirbuf - sta adrhi - sty adrlo ;fetch tree data block and read it @@ -1490,6 +1487,8 @@ noteof1 } ;detect_treof = 1 !if fast_trees = 0 { + lda #>dirbuf + sta adrhi jsr seekrd } else { ;fast_trees = 1 jsr readdirsel @@ -2528,8 +2527,20 @@ seek1 sta blkidx hddopendir unrhddblocklo = unrelochdd + (* - reloc) +!ifdef PASS2 { +} else { ;PASS2 + !if (* + 1) != iCurBlockLo { + !error "iCurBlockLo=",* + 1, ", fix constants.a, rebuild prelaunch" + } +} ldx #2 unrhddblockhi = unrelochdd + (* - reloc) +!ifdef PASS2 { +} else { ;PASS2 + !if (* + 1) != iCurBlockHi { + !error "iCurBlockHi=",* + 1, ", fix constants.a, rebuild prelaunch" + } +} lda #0 jsr hddreaddirsel @@ -2794,6 +2805,7 @@ dirbufpatch11 ldy #>hdddirbuf bvc + !if fast_trees = 1 { +treebufpatch1 ldy #>hddtreebuf } ;fast_trees = 1 sty istree @@ -3070,10 +3082,6 @@ encbufpatch2 !if aligned_read = 0 { php } ;aligned_read = 0 -dirbufpatch12 - lda #>hdddirbuf - sta adrhi - sty adrlo } else { ;rwts_mode = 1 !if fast_subindex = 0 { ;read whenever block index changes @@ -3148,16 +3156,16 @@ blkidx = * + 1 !if rwts_mode = 0 { inc treeidx } ;rwts_mode = 0 -dirbufpatch13 ldx hdddirbuf, y -dirbufpatch14 lda hdddirbuf + 256, y } else { ;fast_trees = 1 ldy treeidx !if rwts_mode = 0 { inc treeidx } ;rwts_mode = 0 +treebufpatch2 ldx hddtreebuf, y +treebufpatch3 lda hddtreebuf + 256, y } ;fast_trees = 0 !if detect_treof = 1 { @@ -3182,6 +3190,9 @@ hddnoteof1 } ;detect_treof = 1 !if fast_trees = 0 { +dirbufpatch12 + lda #>hdddirbuf + sta adrhi jsr hddseekrd } else { ;fast_trees = 1 jsr hddreaddirsel @@ -3752,7 +3763,7 @@ hdddataend !pseudopc ((dataend + $ff) & -256) { dirbuf = * } - !if aligned_read = 0 { + !if ((aligned_read xor 1) + enable_write) > 0 { encbuf = dirbuf + $200 } ;aligned_read !if allow_trees = 1 { @@ -3892,15 +3903,15 @@ hdddataend } !if ((aligned_read xor 1) + rwts_mode) > 0 { !if fast_subindex = 0 { - hddencbuf = hdddirbuf - $200 + hddencbuf = hdddirbuf ;writes come from cache } else { ;fast_subindex = 1 - hddencbuf = hdddirbuf + $200 + hddencbuf = hdddirbuf - $200 } ;fast_subindex } ;aligned_read = 0 or rwts_mode = 1 !if allow_trees = 1 { !if fast_trees = 1 { !if ((aligned_read xor 1) + enable_write) > 0 { - hddtreebuf = hddencbuf + $200 + hddtreebuf = hddencbuf + $400 } else { ;aligned_read = 1 and enable_write = 0 hddtreebuf = hdddirbuf + $200 } ;aligned_read = 0 or enable_write = 1