mirror of
https://github.com/bobbimanners/Zapple-II.git
synced 2024-06-12 16:29:28 +00:00
Fixes to CCP command line argument handling
This commit is contained in:
parent
66908d66d4
commit
d9b231e6f4
|
@ -20,6 +20,8 @@
|
||||||
; BDOS TODOs
|
; BDOS TODOs
|
||||||
; ----------
|
; ----------
|
||||||
; TODO: F_WRITE bug turns out to be bug in ProDOS 2.5.0a7 (SET_MARK)
|
; TODO: F_WRITE bug turns out to be bug in ProDOS 2.5.0a7 (SET_MARK)
|
||||||
|
; TODO: Maybe I should eliminate use of "EX AF,AF'" in BDOS since CP/M apps may
|
||||||
|
; expect exclusive use of alternate register set.
|
||||||
; TODO: Implement missing system calls:
|
; TODO: Implement missing system calls:
|
||||||
; - F_ATTRIB (needs to support wildcards, leave FCB at DMAADDR)
|
; - F_ATTRIB (needs to support wildcards, leave FCB at DMAADDR)
|
||||||
; - RS232 (A_READ, A_WRITE)
|
; - RS232 (A_READ, A_WRITE)
|
||||||
|
@ -1535,13 +1537,13 @@ F2PS6 LD A,C ; Store length of string
|
||||||
; Trashes pretty much all registers (except IX, IY)
|
; Trashes pretty much all registers (except IX, IY)
|
||||||
NAME2FCB EX DE,HL ; Stash HL in DE so we can use HL here
|
NAME2FCB EX DE,HL ; Stash HL in DE so we can use HL here
|
||||||
|
|
||||||
LD HL,(DMAADDR) ; Set all 32 bytes to FCB to zero
|
LD HL,(DMAADDR) ; Set all 16 bytes to FCB to zero
|
||||||
LD C,0 ; ...
|
LD C,0 ; ...
|
||||||
XOR A ; ...
|
XOR A ; ...
|
||||||
N2FL1 LD (HL),C ; ...
|
N2FL1 LD (HL),C ; ...
|
||||||
INC HL ; ...
|
INC HL ; ...
|
||||||
INC A ; ...
|
INC A ; ...
|
||||||
CP 32 ; ...
|
CP 16 ; ...
|
||||||
JP NZ,N2FL1 ; ...
|
JP NZ,N2FL1 ; ...
|
||||||
|
|
||||||
LD HL,(DMAADDR) ; Set all filename chars in FCB to space
|
LD HL,(DMAADDR) ; Set all filename chars in FCB to space
|
||||||
|
@ -1593,22 +1595,24 @@ N2FS2 LD DE,(DMAADDR) ; Destination is start of extension
|
||||||
JP N2FS1 ; Jump back into the read-write loop
|
JP N2FS1 ; Jump back into the read-write loop
|
||||||
|
|
||||||
; Handle file size info
|
; Handle file size info
|
||||||
N2FS3 LD DE,(DMAADDR) ; Pointer to start of FCB
|
; TODO This is commented out because it causes problems when called from parse
|
||||||
LD IX,PATHBUF ; Destination buffer
|
; We need a mode switch to turn this part of the function on and off
|
||||||
CALL FCB2PATH ; Populate PATHLEN and PATH from new FCB
|
N2FS3 ; LD DE,(DMAADDR) ; Pointer to start of FCB
|
||||||
LD HL,GFIMLI ; Pass address of 6502 JSR instruction
|
; LD IX,PATHBUF ; Destination buffer
|
||||||
CALL PRODOS ; Invoke ProDOS MLI
|
; CALL FCB2PATH ; Populate PATHLEN and PATH from new FCB
|
||||||
CP 0 ; See if there was an error
|
; LD HL,GFIMLI ; Pass address of 6502 JSR instruction
|
||||||
JP NZ,N2FERR ; Handle error
|
; CALL PRODOS ; Invoke ProDOS MLI
|
||||||
LD HL,(GFIMLIBU) ; Obtain the blocks used field
|
; CP 0 ; See if there was an error
|
||||||
ADD HL,HL ; Mult x 4 to get 128 byte records
|
; JP NZ,N2FERR ; Handle error
|
||||||
ADD HL,HL ; ...
|
; LD HL,(GFIMLIBU) ; Obtain the blocks used field
|
||||||
CALL RECS2EXRC ; Puts extent in B, recs in A
|
; ADD HL,HL ; Mult x 4 to get 128 byte records
|
||||||
LD DE,(DMAADDR) ; Pointer to start of FCB
|
; ADD HL,HL ; ...
|
||||||
PUSH DE ; Copy into IX
|
; CALL RECS2EXRC ; Puts extent in B, recs in A
|
||||||
POP IX ; ...
|
; LD DE,(DMAADDR) ; Pointer to start of FCB
|
||||||
LD (IX+0CH),B ; Store num extents in EX field of FCB
|
; PUSH DE ; Copy into IX
|
||||||
LD (IX+0FH),A ; Store num recs in RC field of FCB
|
; POP IX ; ...
|
||||||
|
; LD (IX+0CH),B ; Store num extents in EX field of FCB
|
||||||
|
; LD (IX+0FH),A ; Store num recs in RC field of FCB
|
||||||
RET
|
RET
|
||||||
N2FERR LD DE,(DMAADDR) ; Pointer to start of FCB
|
N2FERR LD DE,(DMAADDR) ; Pointer to start of FCB
|
||||||
PUSH DE ; Copy into IX
|
PUSH DE ; Copy into IX
|
||||||
|
@ -1890,7 +1894,7 @@ N2H2 OR 0F0H ;
|
||||||
; - FILENAME.COM - Load and run FILENAME.COM at 0100H
|
; - FILENAME.COM - Load and run FILENAME.COM at 0100H
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
; TODO: BUG-- F_OPEN is trashing FILEBUF with it's damn DIRENT!
|
; TODO: Implement support for ^C in C_READ
|
||||||
; TODO: Implement the built-in commands using a table
|
; TODO: Implement the built-in commands using a table
|
||||||
; TODO: Built-in commands argument handling
|
; TODO: Built-in commands argument handling
|
||||||
; TODO: Parse * wildcard and generate FCB with ?s
|
; TODO: Parse * wildcard and generate FCB with ?s
|
||||||
|
@ -1949,6 +1953,7 @@ CCPS1 CP 3 ; Check if three chars
|
||||||
|
|
||||||
; Attempt to load .COM file from disk
|
; Attempt to load .COM file from disk
|
||||||
CCPS2 CALL PARSE ; Parse the command line
|
CCPS2 CALL PARSE ; Parse the command line
|
||||||
|
; TODO Put in check for built-in commands here
|
||||||
LD DE,PATHBUF2 ; Point to the FCB in PATHBUF2
|
LD DE,PATHBUF2 ; Point to the FCB in PATHBUF2
|
||||||
CALL RUNCOM ; Try to run .COM file
|
CALL RUNCOM ; Try to run .COM file
|
||||||
|
|
||||||
|
@ -1982,16 +1987,13 @@ UCS1 LD (HL),A ; Put converted char back
|
||||||
; 4 in whitespace segment following first argument
|
; 4 in whitespace segment following first argument
|
||||||
; 5 in second argument
|
; 5 in second argument
|
||||||
; 6 in whitespace segment following second arg (or later)
|
; 6 in whitespace segment following second arg (or later)
|
||||||
PARSE LD HL,PATHBUF+1 ; Skip first byte - buffer capacity
|
PARSE CALL RSTPATHBUF ; Set IY and E for writing PATHBUF
|
||||||
PUSH HL ; HL->IY. Use IY as dest pointer into PATHBUF
|
|
||||||
POP IY ; ...
|
|
||||||
LD HL,FILEBUF+1 ; Skip first byte - buffer capacity
|
LD HL,FILEBUF+1 ; Skip first byte - buffer capacity
|
||||||
PUSH HL ; HL->IX. Use IX as dest pointer into FILEBUF
|
PUSH HL ; HL->IX. Use IX as dest pointer into FILEBUF
|
||||||
POP IX ; ...
|
POP IX ; ...
|
||||||
LD C,(HL) ; Get the length of source string
|
|
||||||
LD B,0 ; B is the state of the parser
|
|
||||||
LD D,0 ; D is the count of chars for FILEBUF
|
LD D,0 ; D is the count of chars for FILEBUF
|
||||||
LD E,0 ; E is the count of chars for PATHBUF
|
LD B,0 ; B is the state of the parser
|
||||||
|
LD C,(HL) ; Get the length of source string
|
||||||
CTL1 LD A,C ; See if any chars are left in input
|
CTL1 LD A,C ; See if any chars are left in input
|
||||||
CP 0 ; ...
|
CP 0 ; ...
|
||||||
JP Z,CTS2 ; If 0, go update the length byte
|
JP Z,CTS2 ; If 0, go update the length byte
|
||||||
|
@ -2010,6 +2012,18 @@ CTS2 LD A,' ' ; Fake an additional space on the end ...
|
||||||
LD (HL),D ; Write string length
|
LD (HL),D ; Write string length
|
||||||
RET
|
RET
|
||||||
|
|
||||||
|
; Helper function to reset the PATHBUF buffer pointer & character count
|
||||||
|
; PATHBUF is used to store the filename for creating an FCB
|
||||||
|
; Sets IY to point to first character to be written to PATHBUF
|
||||||
|
; Resets count of chars written E
|
||||||
|
RSTPATHBUF PUSH HL ; Preserve HL
|
||||||
|
LD HL,PATHBUF+1 ; Use HL to initialize IY
|
||||||
|
PUSH HL ; HL->IY. Use IY as dest ptr into PATHBUF
|
||||||
|
POP IY ; ...
|
||||||
|
POP HL ; Restore original HL
|
||||||
|
LD E,0 ; Reset count of chars in PATHBUF
|
||||||
|
RET
|
||||||
|
|
||||||
; Examines Pascal string pointed to by HL to see if it begins with a drive
|
; Examines Pascal string pointed to by HL to see if it begins with a drive
|
||||||
; letter and a colon. If so, reduces string length by 2 and advances HL two
|
; letter and a colon. If so, reduces string length by 2 and advances HL two
|
||||||
; positions, sets B to the drive number. If no drive is specified, sets B
|
; positions, sets B to the drive number. If no drive is specified, sets B
|
||||||
|
@ -2041,16 +2055,16 @@ DLS1 DEC HL ; Put HL back to the beginning
|
||||||
; Handle a space character in the command line
|
; Handle a space character in the command line
|
||||||
; Character is passed in A
|
; Character is passed in A
|
||||||
; State 0: Do not emit space to FILEBUF
|
; State 0: Do not emit space to FILEBUF
|
||||||
; State 1: Do not emit space to FILEBUF
|
; State 1: Do space to FILEBUF
|
||||||
; Set length byte for PATHBUF & create FCB in PATHBUF2
|
; Set length byte for PATHBUF & create FCB in PATHBUF2
|
||||||
; -> State 2
|
; -> State 2
|
||||||
; State 2: Do not emit space to FILEBUF
|
; State 2: Do not emit space to FILEBUF
|
||||||
; State 3: Emit space to FILEBUF
|
; State 3: Emit space to FILEBUF
|
||||||
; Set length byte for PATHBUF & create FCB in FCB1 TODO
|
; Set length byte for PATHBUF & create FCB in FCB1
|
||||||
; -> State 4
|
; -> State 4
|
||||||
; State 4: Do not emit space to FILEBUF
|
; State 4: Do not emit space to FILEBUF
|
||||||
; State 5: Emit space to FILEBUF
|
; State 5: Emit space to FILEBUF
|
||||||
; Set length byte for PATHBUF & create FCB in FCB1 TODO
|
; Set length byte for PATHBUF & create FCB in FCB2
|
||||||
; -> State 6
|
; -> State 6
|
||||||
; State 6: Emit space to FILEBUF
|
; State 6: Emit space to FILEBUF
|
||||||
CMDSPC EX AF,AF' ; Save character for later
|
CMDSPC EX AF,AF' ; Save character for later
|
||||||
|
@ -2060,11 +2074,14 @@ CMDSPC EX AF,AF' ; Save character for later
|
||||||
RET ;
|
RET ;
|
||||||
CSS1 CP 1 ; State 1 - eat the space
|
CSS1 CP 1 ; State 1 - eat the space
|
||||||
JP NZ,CSS2 ;
|
JP NZ,CSS2 ;
|
||||||
|
EX AF,AF' ; Get character back
|
||||||
|
CALL EMTFILBUF ; Emit char to FILEBUF
|
||||||
LD A,E ; Write length byte to PATHBUF
|
LD A,E ; Write length byte to PATHBUF
|
||||||
LD (PATHBUF),A ; ...
|
LD (PATHBUF),A ; ...
|
||||||
LD E,0 ; Reset length for next time
|
CALL RSTPATHBUF ; Reset IY & E for next use
|
||||||
; TODO RESET IY
|
PUSH HL ; Preserve HL, BC, DE
|
||||||
PUSH HL ; Preserve HL
|
PUSH BC ; ...
|
||||||
|
PUSH DE ; ...
|
||||||
LD HL,PATHBUF2 ; DMAADDR to PATHBUF2 - will put FCB there
|
LD HL,PATHBUF2 ; DMAADDR to PATHBUF2 - will put FCB there
|
||||||
LD (DMAADDR),HL ; ...
|
LD (DMAADDR),HL ; ...
|
||||||
LD HL,PATHBUF ; NAME2FCB will use filename at PATHBUF
|
LD HL,PATHBUF ; NAME2FCB will use filename at PATHBUF
|
||||||
|
@ -2076,8 +2093,10 @@ CSS1 CP 1 ; State 1 - eat the space
|
||||||
LD (PATHBUF2+10),A ; ...
|
LD (PATHBUF2+10),A ; ...
|
||||||
LD A,'M' ; ...
|
LD A,'M' ; ...
|
||||||
LD (PATHBUF2+11),A ; ...
|
LD (PATHBUF2+11),A ; ...
|
||||||
|
POP DE ; Restore DE, BC, HL
|
||||||
|
POP BC ; ...
|
||||||
|
POP HL ; ...
|
||||||
INC B ; Transition to state 2
|
INC B ; Transition to state 2
|
||||||
POP HL ; Restore HL
|
|
||||||
RET ;
|
RET ;
|
||||||
CSS2 CP 2 ; State 2 - eat the space
|
CSS2 CP 2 ; State 2 - eat the space
|
||||||
JP NZ,CSS3 ;
|
JP NZ,CSS3 ;
|
||||||
|
@ -2086,6 +2105,20 @@ CSS3 CP 3 ; State 3
|
||||||
JP NZ,CSS4 ;
|
JP NZ,CSS4 ;
|
||||||
EX AF,AF' ; Get character back
|
EX AF,AF' ; Get character back
|
||||||
CALL EMTFILBUF ; Emit char to FILEBUF
|
CALL EMTFILBUF ; Emit char to FILEBUF
|
||||||
|
LD A,E ; Write length byte to PATHBUF
|
||||||
|
LD (PATHBUF),A ; ...
|
||||||
|
CALL RSTPATHBUF ; Reset IY & E for next use
|
||||||
|
PUSH HL ; Preserve HL, BC, DE
|
||||||
|
PUSH BC ; ...
|
||||||
|
PUSH DE ; ...
|
||||||
|
LD HL,FCB1 ; DMAADDR to FCB1 - will put FCB there
|
||||||
|
LD (DMAADDR),HL ; ...
|
||||||
|
LD HL,PATHBUF ; NAME2FCB will use filename at PATHBUF
|
||||||
|
CALL DRVLETTER ; Handle any x: drive letter prefix
|
||||||
|
CALL NAME2FCB ; Create FCB at FCB1
|
||||||
|
POP DE ; Restore DE, BC, HL
|
||||||
|
POP BC ; ...
|
||||||
|
POP HL ; ...
|
||||||
INC B ; Transition to state 4
|
INC B ; Transition to state 4
|
||||||
RET ;
|
RET ;
|
||||||
CSS4 CP 4 ; State 4 - eat the space
|
CSS4 CP 4 ; State 4 - eat the space
|
||||||
|
@ -2095,8 +2128,22 @@ CSS5 CP 5 ; State 5
|
||||||
JP NZ,CSS6 ;
|
JP NZ,CSS6 ;
|
||||||
EX AF,AF' ; Get character back
|
EX AF,AF' ; Get character back
|
||||||
CALL EMTFILBUF ; Emit char to FILEBUF
|
CALL EMTFILBUF ; Emit char to FILEBUF
|
||||||
|
LD A,E ; Write length byte to PATHBUF
|
||||||
|
LD (PATHBUF),A ; ...
|
||||||
|
CALL RSTPATHBUF ; Reset IY & E for next use
|
||||||
|
PUSH HL ; Preserve HL, BC, DE
|
||||||
|
PUSH BC ; ...
|
||||||
|
PUSH DE ; ...
|
||||||
|
LD HL,FCB2 ; DMAADDR to FCB2 - will put FCB there
|
||||||
|
LD (DMAADDR),HL ; ...
|
||||||
|
LD HL,PATHBUF ; NAME2FCB will use filename at PATHBUF
|
||||||
|
CALL DRVLETTER ; Handle any x: drive letter prefix
|
||||||
|
CALL NAME2FCB ; Create FCB at FCB2
|
||||||
|
POP DE ; Restore DE, BC, HL
|
||||||
|
POP BC ; ...
|
||||||
|
POP HL ; ...
|
||||||
INC B ; Transition to state 6
|
INC B ; Transition to state 6
|
||||||
RET
|
RET ;
|
||||||
CSS6 CP 6 ; State 6
|
CSS6 CP 6 ; State 6
|
||||||
JP NZ,CSS7 ;
|
JP NZ,CSS7 ;
|
||||||
EX AF,AF' ; Get character back
|
EX AF,AF' ; Get character back
|
||||||
|
|
Binary file not shown.
BIN
zapple2.po
BIN
zapple2.po
Binary file not shown.
Loading…
Reference in New Issue
Block a user