Fixed MAKEPATH to handle filename <8 chars

This commit is contained in:
Bobbi Webber-Manners 2019-10-17 18:39:10 -04:00
parent 18ee4b693c
commit 9b1f44dab6
3 changed files with 39 additions and 28 deletions

View File

@ -2,6 +2,7 @@
; Z80 code running on Softcard
; Implements CP/M style BDOS interface
; Requires the companion SOFTCARD65 6502 code
; Assemble using Udo Munk's Z80asm
; Bobbi 2019
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -136,13 +137,13 @@ S1 LD C,B_C_STAT ;
LD (FCB1NAM+2),A ;
LD A,'T' ; Filename
LD (FCB1NAM+3),A ;
LD A,'F' ; Filename
LD A,' ' ; Filename
LD (FCB1NAM+4),A ;
LD A,'I' ; Filename
LD A,' ' ; Filename
LD (FCB1NAM+5),A ;
LD A,'L' ; Filename
LD A,' ' ; Filename
LD (FCB1NAM+6),A ;
LD A,'E' ; Filename
LD A,' ' ; Filename
LD (FCB1NAM+7),A ;
LD A,'T' ; Extension
LD (FCB1NAM+8),A ;
@ -152,7 +153,7 @@ S1 LD C,B_C_STAT ;
LD (FCB1NAM+10),A ;
; Create and open a file using ProDOS MLI
; Creates 'A/TESTFILE.TMP'
; Creates 'A/TEST.TMP'
; Directory 'A' needs to exist already
LD DE,CMSG ; Address of string
@ -326,27 +327,27 @@ WELCOME DEFB 13
DEFB 13, '$'
CMSG DEFB 13
DEFM 'Creating & opening A/TESTFILE.TMP'
DEFM 'Creating & opening A/TEST.TMP'
DEFB 13, '$'
WMSG DEFB 13
DEFM 'Writing record to A/TESTFILE.TMP'
DEFM 'Writing record to A/TEST.TMP'
DEFB 13, '$'
CLMSG DEFB 13
DEFM 'Closing A/TESTFILE.TMP'
DEFM 'Closing A/TEST.TMP'
DEFB 13, '$'
OMSG DEFB 13
DEFM 'Opening A/TESTFILE.TMP'
DEFM 'Opening A/TEST.TMP'
DEFB 13, '$'
RMSG DEFB 13
DEFM 'Reading record from A/TESTFILE.TMP'
DEFM 'Reading record from A/TEST.TMP'
DEFB 13, '$'
DMSG DEFB 13
DEFM 'Deleting A/TESTFILE.TMP'
DEFM 'Deleting A/TEST.TMP'
DEFB 13, '$'
SUCCMSG DEFM 'Success!'
@ -1022,8 +1023,6 @@ PRODOS LD BC,OFFSET ; Add offset to convert Z80->6502 address
; Populate the PATH buffer (and PATHLEN) by copying from FCB
; DE contains a pointer to the FCB
; IX contains pointer to the path buffer into which to write
; Be sure not to trash DE
; TODO FINISH THIS - NEEDS TO HANDLE EXTENSION TOO!!!
MAKEPATH PUSH IX ; Copy IX->IY
POP IY ; So IY keeps track of size byte at start
INC IX ; Advance past the size byte before writing
@ -1034,17 +1033,18 @@ MAKEPATH PUSH IX ; Copy IX->IY
INC A ; CURDRV is zero based
MPS1 ADD A,'A'-1 ; Convert to drive letter
LD (IX+0),A ; Store as first char of path
INC IX ; Advance IX to next char of path to write
LD A,'/' ; Second char of path is '/'
LD (IX+1),A ; ...
LD (IX+0),A ; Store as second char of path
INC IX ; Advance IX to next char of path to write
LD C,2 ; Use C to count chars in filename
LD H,D ; Copy address of FCB from DE ...
LD L,E ; ... to HL
INC HL ; HL points to filename in FCB
INC IX ; Advance IX to next char of path to write
INC IX ; ...
MPL1 ; Filename
MPL1 ; Handle the filename - up to 8 characters
LD A,(HL) ; Obtain filename character
CP ' ' ; See if it is a space (? or NULL maybe?)
CP ' ' ; See if it is a space
JP Z,MPS3 ; If so we are done with filename
EX AF,AF' ; We need to re-use A here
LD A,C ; Get character count
@ -1052,34 +1052,45 @@ MPL1 ; Filename
JP Z,MPS2 ; If so we are done with filename
EX AF,AF' ; Swap back to original A reg
LD (IX+0),A ; Copy to PATH buffer
INC C ; Count the chars
INC C ; Increment filename char count
INC HL ; Next byte of filename in FCB
INC IX ; Next byte of PATH buffer
JP MPL1 ; Loop till done
MPS2 EX AF,AF' ; Swap back to original A reg
MPS3 ; Extension
; TODO: Eat any space characters at end of filename
LD A,'.' ; Separator is a period
MPS3 ; Eat any space characters at end of filename
MPL2 LD A,(HL) ; Read next character from FCB
CP ' ' ; Is it space?
JP NZ,MPS4 ; If not, we are done eating!
INC HL ; Otherwise advance to next char
JP MPL2 ; And loop
MPS4 LD A,'.' ; Separator is a period
LD (IX+0),A ; Write to buffer
INC C ; Count the character!
INC IX ; Advance to next character in buffer
LD B,0 ; Use B to track num chars in extension
MPL2 LD A,(HL) ; Obtain filename character
; Handle the extension - up to 3 characters
MPL3 LD A,(HL) ; Obtain extension character
CP ' ' ; See if it is a space (? or NULL maybe?)
JP Z,MPS5 ; If so we are done with extension
JP Z,MPS6 ; If so we are done with extension
EX AF,AF' ; We need to re-use A here
LD A,B ; Get character count
CP 3 ; Extension can be up to 3 chars
JP Z,MPS4 ; If so we are done with filename
JP Z,MPS5 ; If so we are done with filename
EX AF,AF' ; Swap back to original A reg
LD (IX+0),A ; Copy to PATH buffer
INC C ; Count the chars (overall)
INC B ; Count the chars (in extension)
INC HL ; Next byte of filename in FCB
INC IX ; Next byte of PATH buffer
JP MPL2 ; Loop till done
MPS4 EX AF,AF' ; Swap back to original A reg
MPS5 LD A,C ; Store length of string
JP MPL3 ; Loop till done
MPS5 EX AF,AF' ; Swap back to original A reg
MPS6 LD A,C ; Store length of string
LD (IY+0),A ; We kept size byte in IY at start
RET

Binary file not shown.

Binary file not shown.