From 1a2d2151142842e6e33d577068269ea66d89b22a Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Wed, 18 May 2016 14:38:00 -0700 Subject: [PATCH] rename, reduce, separate renamed to reflect write support; reduced code size a bit; separated optional components into conditional blocks --- PRORTS.S => PRORWTS.S | 336 ++++++++++++++++++++++++++---------------- 1 file changed, 206 insertions(+), 130 deletions(-) rename PRORTS.S => PRORWTS.S (86%) diff --git a/PRORTS.S b/PRORWTS.S similarity index 86% rename from PRORTS.S rename to PRORWTS.S index b151f39..190d658 100644 --- a/PRORTS.S +++ b/PRORWTS.S @@ -1,15 +1,21 @@ ;open/read/write binary file in ProDOS filesystem ;copyright (c) Peter Ferrie 2013-16 !cpu 6502 -!to "prorts",plain +!to "prorwts",plain *=$800 + enable_floppy = 0 ;set to 1 to enable floppy drive support override_adr = 0 ;set to 1 to require an explicit load address enable_write = 0 ;set to 1 to enable write support ;file must exist already and its size cannot be altered ;writes occur in multiples of block size (256 bytes for floppy, 512 bytes for HDD) + allow_subdir = 0 ;set to 1 to allow opening subdirectories to access files + ;note that if enable_floppy=1, then override_adr must be 1, or allow_subdir must be 0 + ;unless the reloc address is changed +!if enable_floppy=1 { tmpsec = $3c reqsec = $3d +} A1L = $3c A1H = $3d A2L = $3e @@ -18,7 +24,9 @@ A3L = $40 A3H = $41 } +!if enable_floppy=1 { curtrk = $40 +} command = $42 ;ProDOS constant unit = $43 ;ProDOS constant @@ -39,28 +47,31 @@ ldrhi = $fa ;used if override_adr=1 namlo = $fb namhi = $fc +!if enable_floppy=1 { step = $fd ;state for stepper motor tmptrk = $fe ;temporary copy of current track phase = $ff ;current phase for seek -!if enable_write=1 { + !if enable_write=1 { reloc = $bc00 dirbuf = $ba00 encbuf = $b900 - xlattbl = dataend -} else { + } else { ;enable_write reloc = $bd00 dirbuf = $bb00 + } +} else { ;enable_floppy + reloc = $be00 + dirbuf = $bc00 } -init - jsr $fe93 +init jsr $fe93 jsr $fe89 lda $bf30 sta x80_parms+1 sta unrunit+1 and #$70 - sta $2b pha +!if enable_floppy=1 { ora #$80 sta unrseek+1 ora #8 @@ -72,7 +83,7 @@ init sta unrread1+1 sta unrread2+1 sta unrread3+1 -!if enable_write=1 { + !if enable_write=1 { sta unrread4+1 sta unrread5+1 sta unrread6+1 @@ -87,7 +98,8 @@ init stx unrlatchin+1 inx stx unrlatchout+1 -} + } ;enable_write +} ;enable_floppy ldx #1 stx namlo inx @@ -174,8 +186,10 @@ ifoundname iny dey lda (A1L), y tay +!if enable_floppy=1 { sty unrblocklo+1 stx unrblockhi+1 +} sty unrhddblocklo+1 stx unrhddblockhi+1 plus03 sty x80_parms+4 @@ -191,9 +205,9 @@ plus05 pla ora #$c0 sta slot+2 sta unrentry+2 +!if enable_floppy=1 { ldx #>unrelocdsk ldy #dirbuf lda #dirbuf lda #