2021-08-15 03:42:06 +00:00
|
|
|
* AUXMEM.OSCLI.S
|
|
|
|
* (c) BOBBI 2021 GPLv3
|
2021-08-10 01:27:44 +00:00
|
|
|
*
|
2021-08-15 03:42:06 +00:00
|
|
|
* Handle OSCLI system calls
|
2021-08-08 02:48:24 +00:00
|
|
|
|
2021-08-22 23:04:30 +00:00
|
|
|
* 22-Aug-2021 Uses dispatch table
|
|
|
|
* Prepares parameters and hands on to API call
|
2021-08-25 02:01:41 +00:00
|
|
|
* 24-Aug-2021 Combined *LOAD and *SAVE, full address parsing.
|
2021-09-02 19:47:03 +00:00
|
|
|
* 02-Sep-2021 *LOAD/*SAVE now uses GSTRANS.
|
2021-09-12 03:07:05 +00:00
|
|
|
* 12-Sep-2021 *HELP uses subject lookup, *HELP MOS, *HELP HOSTFS.
|
2021-10-26 00:01:10 +00:00
|
|
|
* 25-Oct-2021 Implemented *BASIC.
|
2022-10-07 11:35:38 +00:00
|
|
|
* 07-Oct-2022 *CLOSE is a host command, fixed *EXEC.
|
2022-10-08 14:45:44 +00:00
|
|
|
* 08-Oct-2022 Rewrote *TYPE, *DUMP, *SPOOL, shares code with *EXEC.
|
2022-10-08 22:39:38 +00:00
|
|
|
* Sorted command table, added *HELP FILE.
|
2021-08-22 23:04:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
* COMMAND TABLE
|
|
|
|
***************
|
2021-08-26 21:36:46 +00:00
|
|
|
* Table structure is: { string, byte OR $80, destword-1 } $00
|
2022-10-08 14:45:44 +00:00
|
|
|
* Commands are entered with A=command byte with b7=1
|
2022-10-08 22:39:38 +00:00
|
|
|
*
|
|
|
|
* Ok, let's get around to sorting these
|
|
|
|
CMDTABLE
|
|
|
|
CMDFILE ASC 'CAT' ; Must be first command so matches '*.'
|
2021-09-12 06:05:17 +00:00
|
|
|
DB $85
|
|
|
|
DW STARFSC-1 ; CAT -> FSC 5, XY=>params
|
2022-10-08 22:39:38 +00:00
|
|
|
ASC 'CDIR'
|
|
|
|
DB $88
|
|
|
|
DW STARFILE-1 ; CDIR -> OSFILE 08, CBLK=>filename
|
|
|
|
ASC 'CLOSE'
|
|
|
|
DB $80
|
|
|
|
DW CMDCLOSE-1 ; CLOSE -> (LPTR)=>params
|
|
|
|
ASC 'DELETE'
|
|
|
|
DB $86
|
|
|
|
DW STARFILE-1 ; DELETE -> OSFILE 06, CBLK=>filename
|
|
|
|
ASC 'DUMP'
|
|
|
|
DB $80
|
|
|
|
DW CMDDUMP-1 ; DUMP -> (LPTR)=>params
|
|
|
|
ASC 'EXEC'
|
|
|
|
DB $80
|
|
|
|
DW CMDEXEC-1 ; EXEC -> (LPTR)=>params
|
2021-09-12 06:05:17 +00:00
|
|
|
ASC 'EX'
|
|
|
|
DB $89
|
|
|
|
DW STARFSC-1 ; EX -> FSC 9, XY=>params
|
|
|
|
ASC 'INFO'
|
|
|
|
DB $8A
|
|
|
|
DW STARFSC-1 ; INFO -> FSC 10, XY=>params
|
|
|
|
ASC 'LOAD'
|
|
|
|
DB $FF
|
|
|
|
DW STARLOAD-1 ; LOAD -> OSFILE FF, CBLK=>filename
|
|
|
|
ASC 'MKDIR'
|
|
|
|
DB $88
|
|
|
|
DW STARFILE-1 ; MKDIR -> OSFILE 08, CBLK=>filename
|
|
|
|
ASC 'OPT'
|
|
|
|
DB $8B
|
|
|
|
DW STARBYTE-1 ; OPT -> OSBYTE &8B,X,Y XY=>params
|
2022-10-08 22:39:38 +00:00
|
|
|
ASC 'RUN'
|
|
|
|
DB $84
|
|
|
|
DW STARFSC-1 ; RUN -> FSC 4, XY=>params
|
|
|
|
ASC 'RENAME'
|
|
|
|
DB $8C
|
|
|
|
DW STARFSC-1 ; RENAME -> FSC 12, XY=>params
|
|
|
|
ASC 'SAVE'
|
2021-09-12 06:05:17 +00:00
|
|
|
DB $FF
|
2022-10-08 22:39:38 +00:00
|
|
|
DW STARSAVE-1 ; SAVE -> OSFILE 00, CBLK=>filename
|
|
|
|
ASC 'SPOOL'
|
2021-09-12 06:05:17 +00:00
|
|
|
DB $80
|
2022-10-08 22:39:38 +00:00
|
|
|
DW CMDSPOOL-1 ; SPOOL -> (LPTR)=>params
|
|
|
|
ASC 'TYPE'
|
2021-09-12 06:05:17 +00:00
|
|
|
DB $80
|
2022-10-08 22:39:38 +00:00
|
|
|
DW CMDTYPE-1 ; TYPE -> (LPTR)=>params
|
|
|
|
DB $00 ; Split between HELP lists
|
|
|
|
*
|
|
|
|
CMDMOS ASC 'BASIC'
|
|
|
|
DB $80
|
|
|
|
DW STARBASIC-1 ; BASIC -> (LPTR)=>params
|
2021-09-12 06:05:17 +00:00
|
|
|
ASC 'ECHO'
|
|
|
|
DB $80
|
|
|
|
DW ECHO-1 ; ECHO -> (LPTR)=>params
|
2022-10-08 22:39:38 +00:00
|
|
|
ASC 'FX'
|
|
|
|
DB $80
|
|
|
|
DW STARFX-1 ; FX -> OSBYTE A,X,Y (LPTR)=>params
|
2022-10-07 11:35:38 +00:00
|
|
|
ASC 'FAST'
|
|
|
|
DB $80
|
|
|
|
DW FAST-1 ; FAST -> (LPTR)=>params
|
2022-10-08 22:39:38 +00:00
|
|
|
ASC 'HELP'
|
|
|
|
DB $FF
|
|
|
|
DW STARHELP-1 ; HELP -> XY=>params
|
|
|
|
ASC 'KEY'
|
2022-09-21 04:21:13 +00:00
|
|
|
DB $80
|
2022-10-08 22:39:38 +00:00
|
|
|
DW STARKEY-1 ; KEY -> (LPTR)=>params
|
|
|
|
ASC 'QUIT'
|
2022-09-21 04:21:13 +00:00
|
|
|
DB $80
|
2022-10-08 22:39:38 +00:00
|
|
|
DW STARQUIT-1 ; QUIT -> (LPTR)=>params
|
|
|
|
ASC 'SLOW'
|
2022-09-24 01:36:49 +00:00
|
|
|
DB $80
|
2022-10-08 22:39:38 +00:00
|
|
|
DW SLOW-1 ; SLOW -> (LPTR)=>params
|
2021-08-22 23:04:30 +00:00
|
|
|
* terminator
|
2021-09-12 06:05:17 +00:00
|
|
|
DB $FF
|
2021-08-22 23:04:30 +00:00
|
|
|
|
2022-10-08 22:39:38 +00:00
|
|
|
|
2021-09-12 03:07:05 +00:00
|
|
|
* *HELP TABLE
|
|
|
|
*************
|
2021-09-12 06:05:17 +00:00
|
|
|
HLPTABLE ASC 'MOS'
|
|
|
|
DB $80
|
|
|
|
DW HELPMOS-1 ; *HELP MOS
|
2022-10-08 22:39:38 +00:00
|
|
|
ASC 'FILE'
|
|
|
|
DB $80
|
|
|
|
DW HELPFILE-1 ; *HELP FILE
|
2021-09-12 06:05:17 +00:00
|
|
|
ASC 'HOSTFS'
|
|
|
|
DB $80
|
|
|
|
DW HELPHOSTFS-1 ; *HELP HOSTFS
|
|
|
|
DB $FF
|
2021-09-12 03:07:05 +00:00
|
|
|
|
2021-08-22 23:04:30 +00:00
|
|
|
|
2021-08-30 23:08:22 +00:00
|
|
|
* Command table lookup
|
|
|
|
* On entry, (OSLPTR)=>command string
|
|
|
|
* XY=>command table
|
|
|
|
* On exit, A=0 done, command called
|
|
|
|
* A<>0 no match
|
2021-08-25 02:01:41 +00:00
|
|
|
*
|
2021-08-22 23:04:30 +00:00
|
|
|
* Search command table
|
2021-09-12 06:05:17 +00:00
|
|
|
CLILOOKUP STX OSTEXT+0 ; Start of command table
|
|
|
|
STY OSTEXT+1
|
|
|
|
LDX #0 ; (ZP,X)=>command table
|
|
|
|
CLILP4 LDY #0 ; Start of command line
|
|
|
|
CLILP5 LDA (OSTEXT,X)
|
|
|
|
BMI CLIMATCH ; End of table string
|
|
|
|
EOR (OSLPTR),Y
|
|
|
|
AND #$DF ; Force upper case match
|
|
|
|
BNE CLINOMATCH
|
|
|
|
JSR CLISTEP ; Step to next table char
|
|
|
|
INY ; Step to next command char
|
|
|
|
BNE CLILP5 ; Loop to check
|
|
|
|
|
|
|
|
CLINOMATCH LDA (OSLPTR),Y
|
|
|
|
CMP #'.' ; Abbreviation?
|
|
|
|
BEQ CLIDOT
|
|
|
|
CLINEXT JSR CLISTEP ; No match, step to next entry
|
|
|
|
BPL CLINEXT
|
|
|
|
CLINEXT2 JSR CLISTEP ; Step past byte, address
|
|
|
|
JSR CLISTEP
|
|
|
|
JSR CLISTEP
|
2022-10-08 22:39:38 +00:00
|
|
|
BNE CLINEXT3
|
|
|
|
JSR CLISTEP
|
|
|
|
CLINEXT3 BPL CLILP4 ; Loop to check next
|
2021-09-12 06:05:17 +00:00
|
|
|
RTS ; Exit, A>$7F
|
|
|
|
|
|
|
|
CLIDOT LDA (OSTEXT,X)
|
|
|
|
BMI CLINEXT2 ; Dot after full word, no match
|
|
|
|
CLIDOT2 JSR CLISTEP ; Step to command address
|
|
|
|
BPL CLIDOT2
|
|
|
|
INY ; Step past dot
|
|
|
|
BNE CLIMATCH2 ; Jump to this command
|
|
|
|
|
|
|
|
CLIMATCH LDA (OSLPTR),Y
|
|
|
|
CMP #'.'
|
|
|
|
BEQ CLINEXT ; Longer abbreviation, eg 'CAT.'
|
|
|
|
CMP #'A'
|
|
|
|
BCS CLINEXT ; More letters, eg 'HELPER'
|
|
|
|
CLIMATCH2 JSR CLIMATCH3 ; Call the routine
|
|
|
|
LDA #0
|
|
|
|
RTS ; Return A=0 to claim
|
|
|
|
|
|
|
|
CLIMATCH3 JSR SKIPSPC ; (OSLPTR),Y=>parameters
|
|
|
|
LDA (OSTEXT,X) ; Command byte
|
|
|
|
PHA
|
|
|
|
JSR CLISTEP ; Address low byte
|
|
|
|
STA OSTEMP
|
|
|
|
JSR CLISTEP ; Address high byte
|
|
|
|
PLX ; Get command byte
|
|
|
|
PHA ; Push address high
|
|
|
|
LDA OSTEMP
|
|
|
|
PHA ; Push address low
|
|
|
|
TXA ; Command byte
|
|
|
|
PHA
|
2022-10-08 14:45:44 +00:00
|
|
|
ASL A ; Move bit 6 into bit 7
|
|
|
|
BEQ CLICALL ; If $80-&BF don't convert LPTR
|
2021-09-12 06:05:17 +00:00
|
|
|
JSR LPTRtoXY ; XY=>parameters
|
|
|
|
CLICALL PLA ; A=command parameter
|
|
|
|
RTS ; Call command routine
|
|
|
|
|
|
|
|
CLISTEP INC OSTEXT+0,X ; Point to next table byte
|
|
|
|
BNE CLISTEP2
|
|
|
|
INC OSTEXT+1,X
|
|
|
|
CLISTEP2 LDA (OSTEXT,X) ; Get next byte
|
|
|
|
RTS
|
2021-08-30 23:08:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
* OSCLI HANDLER
|
|
|
|
* On entry, XY=>command string
|
|
|
|
* On exit, AXY corrupted or error generated
|
|
|
|
*
|
2021-09-12 06:05:17 +00:00
|
|
|
CLIHND JSR XYtoLPTR ; LPTR=>command line
|
|
|
|
CLILP1 LDA (OSLPTR),Y
|
|
|
|
CMP #$0D
|
|
|
|
BEQ CLI2
|
|
|
|
INY
|
|
|
|
BNE CLILP1
|
|
|
|
CLIEXIT1 RTS ; No terminating <cr>
|
|
|
|
CLI2 LDY #$FF
|
|
|
|
CLILP2 JSR SKIPSPC1 ; Skip leading spaces
|
|
|
|
CMP #'*' ; Skip leading stars
|
|
|
|
BEQ CLILP2
|
|
|
|
CMP #$0D
|
|
|
|
BEQ CLIEXIT1 ; Null string
|
|
|
|
CMP #'|'
|
|
|
|
BEQ CLIEXIT1 ; Comment
|
|
|
|
CMP #'/'
|
|
|
|
BEQ CLISLASH
|
|
|
|
JSR LPTRtoXY ; Add Y to LPTR
|
|
|
|
JSR XYtoLPTR ; LPTR=>start of actual command
|
|
|
|
LDX #<CMDTABLE ; XY=>command table
|
|
|
|
LDY #>CMDTABLE
|
|
|
|
JSR CLILOOKUP ; Look for command
|
|
|
|
BNE CLIUNKNOWN ; No match
|
|
|
|
CLIDONE RTS
|
|
|
|
|
|
|
|
CLISLASH JSR SKIPSPC1
|
|
|
|
BEQ CLIDONE ; */<cr>
|
|
|
|
LDA #$02
|
|
|
|
BNE STARFSC2 ; FSC 2 = */filename
|
|
|
|
|
|
|
|
CLIUNKNOWN LDA #$04
|
|
|
|
JSR SERVICE ; Offer to sideways ROM(s)
|
|
|
|
BEQ CLIDONE ; Claimed
|
|
|
|
LDA #$03 ; FSC 3 = unknown command
|
|
|
|
STARFSC2 PHA
|
|
|
|
JSR LPTRtoXY ; XY=>command
|
|
|
|
PLA
|
|
|
|
STARFSC AND #$7F ; A=command, XY=>parameters
|
|
|
|
JSR CALLFSCV ; Hand on to filing system
|
|
|
|
TAX
|
|
|
|
BEQ CLIDONE ; A=0, FSC call implemented
|
|
|
|
ERRBADCMD BRK
|
|
|
|
DB $FE
|
|
|
|
ASC 'Bad command'
|
|
|
|
ERRBADNUM BRK
|
|
|
|
DB $FC
|
|
|
|
ASC 'Bad number'
|
|
|
|
ERRBADADD BRK
|
|
|
|
DB $FC
|
|
|
|
ASC 'Bad address'
|
|
|
|
BRK
|
2021-08-22 23:04:30 +00:00
|
|
|
|
2021-08-25 02:01:41 +00:00
|
|
|
|
2021-08-22 23:04:30 +00:00
|
|
|
* *FX num(,num(,num))
|
|
|
|
*********************
|
2021-09-12 06:05:17 +00:00
|
|
|
STARFX JSR SCANDEC
|
|
|
|
BRA STARBYTE1
|
2021-08-25 02:01:41 +00:00
|
|
|
|
2021-08-22 23:04:30 +00:00
|
|
|
* Commands passed to OSBYTE
|
|
|
|
***************************
|
2021-09-12 06:05:17 +00:00
|
|
|
STARBYTE JSR XYtoLPTR
|
|
|
|
STARBYTE1 STA OSAREG ; Save OSBYTE number
|
|
|
|
LDA #$00 ; Default X and Y
|
|
|
|
STA OSXREG
|
|
|
|
STA OSYREG
|
|
|
|
JSR SKIPCOMMA ; Step past any comma/spaces
|
|
|
|
BEQ STARBYTE2 ; End of line, do it
|
|
|
|
JSR SCANDEC ; Scan for X param
|
|
|
|
STA OSXREG ; Store it
|
|
|
|
JSR SKIPCOMMA ; Step past any comma/spaces
|
|
|
|
BEQ STARBYTE2 ; End of line, do it
|
|
|
|
JSR SCANDEC ; Scan for Y param
|
|
|
|
STA OSYREG ; Store it
|
|
|
|
JSR SKIPSPC
|
|
|
|
BNE ERRBADCMD ; More params, error
|
|
|
|
STARBYTE2 LDY OSYREG
|
|
|
|
LDX OSXREG
|
|
|
|
LDA OSAREG
|
|
|
|
JSR OSBYTE
|
|
|
|
BVS ERRBADCMD
|
|
|
|
RTS
|
2021-08-22 23:04:30 +00:00
|
|
|
|
|
|
|
* Scan decimal number
|
2021-09-12 06:05:17 +00:00
|
|
|
SCANDEC JSR SKIPSPC
|
|
|
|
JSR SCANDIGIT ; Check first digit
|
|
|
|
BCS ERRBADNUM ; Doesn't start with a digit
|
|
|
|
SCANDECLP STA OSTEMP ; Store as current number
|
|
|
|
JSR SCANDIGIT ; Check next digit
|
|
|
|
BCS SCANDECOK ; No more digits
|
|
|
|
PHA
|
|
|
|
LDA OSTEMP
|
|
|
|
CMP #26
|
|
|
|
BCS ERRBADNUM ; num>25, num*25>255
|
|
|
|
ASL A ; num*2
|
|
|
|
ASL A ; num*4
|
|
|
|
ADC OSTEMP ; num*4+num = num*5
|
|
|
|
ASL A ; num*10
|
|
|
|
STA OSTEMP
|
|
|
|
PLA
|
|
|
|
ADC OSTEMP ; num=num*10+digit
|
|
|
|
BCC SCANDECLP
|
|
|
|
BCS ERRBADNUM ; Overflowed
|
|
|
|
|
|
|
|
SCANDECOK LDA OSTEMP ; Return A=number
|
|
|
|
SCANDIG2 SEC
|
|
|
|
RTS
|
|
|
|
|
|
|
|
SCANDIGIT LDA (OSLPTR),Y
|
|
|
|
CMP #'0'
|
|
|
|
BCC SCANDIG2 ; <'0'
|
|
|
|
CMP #'9'+1
|
|
|
|
BCS SCANDIG2 ; >'9'
|
|
|
|
INY
|
|
|
|
AND #$0F
|
|
|
|
RTS
|
|
|
|
|
|
|
|
HEXDIGIT JSR SCANDIGIT
|
|
|
|
BCC HEXDIGIT2 ; Decimal digit
|
|
|
|
AND #$DF
|
|
|
|
CMP #'A'
|
|
|
|
BCC SCANDIG2 ; Bad hex character
|
|
|
|
CMP #'G'
|
|
|
|
BCS HEXDIGIT2 ; Bad hex character
|
|
|
|
SBC #$36 ; Convert 'A'-'F' to $0A-$0F
|
|
|
|
INY
|
|
|
|
CLC
|
|
|
|
HEXDIGIT2 RTS
|
2021-08-25 02:01:41 +00:00
|
|
|
|
|
|
|
* Scan hex address
|
|
|
|
* (OSLPTR),Y=>first character
|
|
|
|
* $200,X = 4-byte accumulator
|
2021-09-12 06:05:17 +00:00
|
|
|
SCANHEX JSR HEXDIGIT ; Get first digit
|
|
|
|
BCS ERRBADADD1 ; Not a hex character
|
|
|
|
STA $200,X ; Store first digit
|
|
|
|
LDA #0
|
|
|
|
STA $201,X ; Clear rest of accumulator
|
|
|
|
STA $202,X
|
|
|
|
STA $203,X
|
|
|
|
SCANHEXLP1 JSR HEXDIGIT ; Get next digit
|
|
|
|
BCS SKIPSPC ; Done, exit by skipping spaces
|
|
|
|
STY OSTEMP
|
|
|
|
LDY #4 ; Four bits to rotate
|
|
|
|
SCANHEXLP2 ASL $200,X ; Multiple accumulator by 16
|
|
|
|
ROL $201,X
|
|
|
|
ROL $202,X
|
|
|
|
ROL $203,X
|
|
|
|
BCS ERRBADADD1 ; Overflowed
|
|
|
|
DEY
|
|
|
|
BNE SCANHEXLP2 ; Loop for four bits
|
|
|
|
ORA $200,X ; Add in current digit
|
|
|
|
STA $200,X
|
|
|
|
LDY OSTEMP ; Get Y back
|
|
|
|
BNE SCANHEXLP1
|
|
|
|
ERRBADADD1 JMP ERRBADADD
|
|
|
|
|
|
|
|
SKIPCOMMA LDA (OSLPTR),Y
|
|
|
|
CMP #$2C
|
|
|
|
BNE SKIPSPC ; Drop through
|
2021-08-25 02:01:41 +00:00
|
|
|
*
|
2021-08-22 23:04:30 +00:00
|
|
|
* Skip spaces
|
2021-09-12 06:05:17 +00:00
|
|
|
SKIPSPC1 INY ; Step past a character
|
|
|
|
SKIPSPC LDA (OSLPTR),Y
|
|
|
|
CMP #' '
|
|
|
|
BEQ SKIPSPC1
|
|
|
|
CMP #$0D ; Return EQ=<cr>
|
|
|
|
RTS
|
2021-08-22 23:04:30 +00:00
|
|
|
|
2021-09-02 19:47:03 +00:00
|
|
|
* Skip a string
|
2021-09-12 06:05:17 +00:00
|
|
|
SKIPWORD CLC
|
|
|
|
JSR GSINIT
|
|
|
|
SKIPWORDLP JSR GSREAD
|
|
|
|
BCC SKIPWORDLP
|
|
|
|
RTS
|
2021-08-31 22:47:35 +00:00
|
|
|
|
2021-08-22 23:04:30 +00:00
|
|
|
* Convert (LPTR),Y to XY
|
2021-09-12 06:05:17 +00:00
|
|
|
LPTRtoXY CLC
|
|
|
|
TYA
|
|
|
|
ADC OSLPTR+0
|
|
|
|
TAX
|
|
|
|
LDA #0
|
|
|
|
ADC OSLPTR+1
|
|
|
|
TAY
|
|
|
|
RTS
|
2021-08-22 23:04:30 +00:00
|
|
|
|
2021-08-25 02:01:41 +00:00
|
|
|
* Convert XY to (LPTR),Y
|
2021-09-12 06:05:17 +00:00
|
|
|
XYtoLPTR STX OSLPTR+0
|
|
|
|
STY OSLPTR+1
|
|
|
|
LDY #0
|
2022-10-08 14:45:44 +00:00
|
|
|
STARHELP9 RTS
|
2021-08-22 23:04:30 +00:00
|
|
|
|
|
|
|
* Print *HELP text
|
2021-09-12 06:05:17 +00:00
|
|
|
STARHELP JSR XYtoLPTR ; (OSLPTR),Y=>parameters
|
|
|
|
JSR PRHELLO ; Unify version message
|
|
|
|
LDX #<HLPTABLE ; XY=>command table
|
|
|
|
LDY #>HLPTABLE
|
|
|
|
JSR CLILOOKUP ; Look for *HELP subject
|
2022-10-08 14:45:44 +00:00
|
|
|
BEQ STARHELP9 ; Matched
|
2021-09-12 06:05:17 +00:00
|
|
|
LDA $8006 ; Does ROM have service entry?
|
2022-10-08 14:45:44 +00:00
|
|
|
BMI STARHELP6 ; Yes, skip to send service call
|
2021-09-12 06:05:17 +00:00
|
|
|
JSR OSNEWL
|
|
|
|
LDA #$09 ; Language name
|
|
|
|
LDY #$80 ; *TO DO* make this and BYTE8E
|
|
|
|
JSR PRSTR ; use same code
|
|
|
|
JSR OSNEWL
|
|
|
|
STARHELP6 LDY #0 ; (OSLPTR),Y=>parameters
|
|
|
|
LDA #9
|
|
|
|
JMP SERVICE ; Pass to sideways ROM(s)
|
|
|
|
|
|
|
|
HELPHOSTFS LDX #<FSCCOMMAND ; *HELP HOSTFS
|
|
|
|
LDY #>FSCCOMMAND
|
|
|
|
BNE HELPLIST
|
2022-10-08 22:39:38 +00:00
|
|
|
HELPFILE LDX #<CMDFILE ; *HELP FILE
|
|
|
|
LDY #>CMDFILE
|
|
|
|
BNE HELPLIST
|
|
|
|
HELPMOS LDX #<CMDMOS ; *HELP MOS
|
|
|
|
LDY #>CMDMOS
|
|
|
|
*
|
2021-09-12 06:05:17 +00:00
|
|
|
HELPLIST STX OSTEXT+0 ; Start of command table
|
|
|
|
STY OSTEXT+1
|
|
|
|
LDX #0
|
|
|
|
HELPLP1 LDA #32
|
|
|
|
JSR OSWRCH
|
|
|
|
JSR OSWRCH
|
|
|
|
HELPLP2 LDY #10
|
|
|
|
HELPLP3 LDA (OSTEXT,X)
|
|
|
|
BMI HELPLP4
|
|
|
|
JSR OSWRCH
|
|
|
|
DEY
|
|
|
|
JSR CLISTEP
|
|
|
|
BPL HELPLP3
|
|
|
|
HELPLP4 LDA #32
|
|
|
|
JSR OSWRCH
|
|
|
|
DEY
|
|
|
|
BNE HELPLP4
|
|
|
|
JSR CLISTEP
|
|
|
|
JSR CLISTEP
|
|
|
|
JSR CLISTEP
|
2022-10-08 22:39:38 +00:00
|
|
|
BEQ STARHELP4
|
2021-09-12 06:05:17 +00:00
|
|
|
BPL HELPLP2
|
|
|
|
STARHELP4 LDA #$08
|
|
|
|
JSR OSWRCH
|
|
|
|
JSR OSWRCH
|
|
|
|
JMP FORCENL
|
2021-09-12 03:07:05 +00:00
|
|
|
|
2021-08-08 02:48:24 +00:00
|
|
|
|
|
|
|
* Handle *QUIT command
|
2021-09-12 06:05:17 +00:00
|
|
|
STARQUIT >>> XF2MAIN,QUIT
|
2021-08-08 02:48:24 +00:00
|
|
|
|
|
|
|
|
2021-09-12 06:05:17 +00:00
|
|
|
STARSAVE LDA #$00 ; Set A=0 - SAVE
|
|
|
|
STARLOAD PHA ; Entered with A=$FF - LOAD
|
|
|
|
JSR XYtoLPTR ; OSLPTR=>filename
|
|
|
|
JSR SKIPWORD ; Step past filename
|
|
|
|
BNE STARLDSV3 ; filename followed by addr
|
2021-09-02 19:47:03 +00:00
|
|
|
*
|
|
|
|
* filename followed by no address, must be *LOAD name
|
2021-09-12 06:05:17 +00:00
|
|
|
STARLDSV1 LDA #$FF ; $FF=load to file's address
|
|
|
|
STARLOAD2 STA OSFILECB+6
|
|
|
|
PLA
|
|
|
|
BEQ ERRBADADD2 ; *save name <no addr>
|
|
|
|
LDA #$7F ; Will become A=$FF
|
|
|
|
JMP STARLDSVGO ; Do the load
|
2021-08-25 02:01:41 +00:00
|
|
|
|
2021-09-02 19:47:03 +00:00
|
|
|
* At least one address specified
|
2021-09-12 06:05:17 +00:00
|
|
|
STARLDSV3 LDX #OSFILECB+2-$200 ; X=>load
|
|
|
|
JSR SCANHEX
|
|
|
|
BNE STARSAVE3 ; Another address
|
|
|
|
LDA #$00 ; $00=load to supplied address
|
|
|
|
BEQ STARLOAD2 ; Only one address, must be *LOAD
|
2021-08-25 02:01:41 +00:00
|
|
|
|
|
|
|
* More than one address, must be *SAVE
|
2021-09-12 06:05:17 +00:00
|
|
|
STARSAVE3 PLA
|
|
|
|
BNE ERRBADADD2 ; Can't be *LOAD
|
|
|
|
LDX #3
|
|
|
|
STARSAVE4 LDA OSFILECB+2,X ; Get load
|
|
|
|
STA OSFILECB+6,X ; copy to exec
|
|
|
|
STA OSFILECB+10,X ; and to start
|
|
|
|
DEX
|
|
|
|
BPL STARSAVE4
|
|
|
|
LDA (OSLPTR),Y
|
|
|
|
CMP #'+'
|
|
|
|
PHP
|
|
|
|
BNE STARSAVE5 ; Not start+length
|
|
|
|
JSR SKIPSPC1 ; Step past '+' and spaces
|
|
|
|
STARSAVE5 LDX #OSFILECB+14-$200
|
|
|
|
JSR SCANHEX ; Get end or length
|
|
|
|
PLP
|
|
|
|
BNE STARSAVE7 ; Not +length
|
|
|
|
LDX #0
|
|
|
|
CLC
|
|
|
|
STARSAVE6 LDA OSFILECB+10,X ; end=start+length
|
|
|
|
ADC OSFILECB+14,X
|
|
|
|
STA OSFILECB+14,X
|
|
|
|
INX
|
|
|
|
TXA
|
|
|
|
AND #3
|
|
|
|
BNE STARSAVE6
|
2021-08-25 02:01:41 +00:00
|
|
|
* load =start
|
|
|
|
* exec =start
|
|
|
|
* start=start
|
|
|
|
* end =end or start+length
|
2021-09-12 06:05:17 +00:00
|
|
|
STARSAVE7 JSR SKIPSPC
|
|
|
|
BEQ STARSAVE10 ; No more, do it
|
|
|
|
LDX #OSFILECB+6-$200
|
|
|
|
JSR SCANHEX ; Get exec
|
|
|
|
BEQ STARSAVE10 ; No more, do it
|
|
|
|
LDX #OSFILECB+2-$200
|
|
|
|
JSR SCANHEX ; Get load
|
|
|
|
BEQ STARSAVE10 ; No more, do it
|
|
|
|
ERRBADADD2 JMP ERRBADADD ; Too many parameters
|
|
|
|
|
|
|
|
STARSAVE10 LDA #$80 ; Will become $00 - SAVE
|
|
|
|
STARLDSVGO LDX OSLPTR+0
|
|
|
|
LDY OSLPTR+1 ; Continue through...
|
2021-08-25 02:01:41 +00:00
|
|
|
*
|
|
|
|
|
|
|
|
* Commands passed to OSFILE
|
|
|
|
***************************
|
2021-09-12 06:05:17 +00:00
|
|
|
STARFILE EOR #$80
|
|
|
|
STX OSFILECB+0
|
|
|
|
STY OSFILECB+1
|
|
|
|
LDX #<OSFILECB
|
|
|
|
LDY #>OSFILECB
|
|
|
|
JSR OSFILE
|
|
|
|
TAX
|
|
|
|
BNE STARDONE
|
|
|
|
JMP ERRNOTFND
|
2021-08-25 02:01:41 +00:00
|
|
|
|
2021-08-26 21:36:46 +00:00
|
|
|
STARKEY
|
2021-09-12 06:05:17 +00:00
|
|
|
STARDONE RTS
|
2021-08-25 02:01:41 +00:00
|
|
|
|
|
|
|
|
2021-10-26 00:01:10 +00:00
|
|
|
* *BASIC
|
|
|
|
********
|
|
|
|
STARBASIC LDX MAXROM
|
|
|
|
:BASICLP JSR ROMSELECT
|
|
|
|
BIT $8006
|
|
|
|
BPL :BASICGO ; No service, must be BASIC
|
|
|
|
DEX
|
|
|
|
BPL :BASICLP
|
|
|
|
JMP ERRBADCMD ; No BASIC, give an error
|
|
|
|
:BASICGO JMP BYTE8E
|
|
|
|
|
|
|
|
|
2021-09-12 03:07:05 +00:00
|
|
|
* *ECHO <GSTRANS string>
|
|
|
|
************************
|
2021-09-20 21:02:31 +00:00
|
|
|
ECHO SEC
|
2021-09-12 06:05:17 +00:00
|
|
|
ECHO0 JSR GSINIT
|
|
|
|
ECHOLP1 JSR GSREAD
|
|
|
|
BCS STARDONE
|
|
|
|
JSR OSWRCH
|
|
|
|
JMP ECHOLP1
|
2021-09-17 21:51:11 +00:00
|
|
|
|
2022-10-07 11:35:38 +00:00
|
|
|
* FILING UTILITIES
|
2022-10-08 14:45:44 +00:00
|
|
|
* ================
|
2022-10-07 11:35:38 +00:00
|
|
|
|
|
|
|
* *CLOSE
|
|
|
|
********
|
2022-10-08 14:45:44 +00:00
|
|
|
CMDCLOSE LDA #$00
|
2022-10-07 11:35:38 +00:00
|
|
|
TAY
|
|
|
|
JSR OSFIND ; Close all files
|
2022-10-08 14:45:44 +00:00
|
|
|
STA FXEXEC ; Ensure Spool/Exec handles cleared
|
2022-10-07 11:35:38 +00:00
|
|
|
STA FXSPOOL
|
|
|
|
RTS
|
2021-10-26 13:31:34 +00:00
|
|
|
|
2022-10-08 14:45:44 +00:00
|
|
|
* *TYPE <afsp>
|
|
|
|
**************
|
2022-09-21 04:21:13 +00:00
|
|
|
* LPTR=>parameters string
|
|
|
|
*
|
2022-10-08 14:45:44 +00:00
|
|
|
CMDTYPE
|
|
|
|
LDA (OSLPTR),Y ; TEMP
|
|
|
|
CMP #$0D ; TEMP
|
|
|
|
BEQ ERRTYPE ; No filename
|
|
|
|
JSR LPTRtoXY ; TEMP
|
|
|
|
*
|
|
|
|
JSR OPENINFILE ; Try to open file
|
|
|
|
:LOOP JSR OSBGET ; Read a byte
|
|
|
|
BCS TYPDMPEND ; EOF
|
|
|
|
CMP #$0A
|
|
|
|
BEQ :LOOP ; Ignore <lf>
|
|
|
|
TAX ; Remember last character
|
|
|
|
JSR OSASCI ; Print the character
|
|
|
|
BIT ESCFLAG
|
|
|
|
BPL :LOOP ; No Escape, keep going
|
|
|
|
TYPEESC JSR TYPCLOSE
|
|
|
|
ERRESCAPE BRK
|
2022-09-21 04:21:13 +00:00
|
|
|
DB $11
|
|
|
|
ASC 'Escape'
|
|
|
|
BRK
|
2022-10-08 14:45:44 +00:00
|
|
|
TYPDMPEND CPX #$0D
|
|
|
|
BEQ TYPCLOSE
|
|
|
|
JSR OSNEWL
|
|
|
|
TYPCLOSE LDA #$00
|
|
|
|
JMP OSFIND ; Close file
|
|
|
|
ERRTYPE BRK
|
|
|
|
DB $DC
|
|
|
|
ASC 'Syntax: TYPE <afsp>'
|
2022-10-08 22:39:38 +00:00
|
|
|
ERRDUMP BRK
|
|
|
|
DB $DC
|
|
|
|
ASC 'Syntax: DUMP <afsp>'
|
2022-10-08 14:45:44 +00:00
|
|
|
BRK
|
2022-09-21 04:21:13 +00:00
|
|
|
|
2022-10-08 22:39:38 +00:00
|
|
|
|
2022-09-22 23:56:17 +00:00
|
|
|
* Handle *DUMP command
|
|
|
|
* LPTR=>parameters string
|
|
|
|
*
|
2022-10-08 14:45:44 +00:00
|
|
|
CMDDUMP
|
|
|
|
LDA (OSLPTR),Y ; TEMP
|
|
|
|
CMP #$0D ; TEMP
|
2022-10-08 22:39:38 +00:00
|
|
|
BEQ ERRDUMP ; No filename
|
2022-10-08 14:45:44 +00:00
|
|
|
JSR LPTRtoXY ; TEMP
|
|
|
|
*
|
|
|
|
JSR OPENINFILE ; Try to open file
|
|
|
|
STZ OSNUM+0 ; Offset = zero
|
|
|
|
STZ OSNUM+1
|
|
|
|
:LOOP1 BIT ESCFLAG
|
|
|
|
BMI TYPEESC ; Escape pressed
|
|
|
|
PHY ; Save handle
|
2022-10-08 22:39:38 +00:00
|
|
|
TYA
|
|
|
|
TAX ; X=handle
|
|
|
|
LDA #$7F
|
|
|
|
JSR OSBYTE ; Read EOF
|
2022-10-08 14:45:44 +00:00
|
|
|
PLY ; Get handle back
|
2022-10-08 22:39:38 +00:00
|
|
|
TXA
|
|
|
|
BNE TYPCLOSE ; At EOF
|
|
|
|
LDA OSNUM+1 ; Print file offset
|
|
|
|
JSR PRHEX
|
|
|
|
LDA OSNUM+0
|
|
|
|
JSR PRHEX
|
|
|
|
JSR PRSPACE
|
2022-10-08 14:45:44 +00:00
|
|
|
LDA #8 ; 8 bytes to dump
|
|
|
|
STA OSNUM+2
|
|
|
|
TSX ; Reserve bytes on stack
|
|
|
|
TXA
|
|
|
|
SEC
|
|
|
|
SBC OSNUM+2
|
|
|
|
TAX
|
|
|
|
TXS ; X=>space on stack
|
|
|
|
:LOOP2 JSR OSBGET ; Read a byte
|
|
|
|
BCS :DUMPEOF
|
|
|
|
STA $0101,X ; Store on stack
|
|
|
|
JSR PRHEX ; Print as hex
|
|
|
|
JSR PRSPACE
|
2022-09-22 23:56:17 +00:00
|
|
|
INX
|
2022-10-08 14:45:44 +00:00
|
|
|
DEC OSNUM+2
|
|
|
|
BNE :LOOP2 ; Loop to do 8 bytes
|
|
|
|
CLC ; CLC=Not EOF
|
|
|
|
BCC :DUMPCHRS ; Jump to display characters
|
2022-10-08 22:39:38 +00:00
|
|
|
:DUMPEOF LDA #'*' ; EOF met, pad with '**'
|
2022-10-08 14:45:44 +00:00
|
|
|
JSR OSWRCH
|
|
|
|
JSR OSWRCH
|
|
|
|
JSR PRSPACE
|
2022-09-22 23:56:17 +00:00
|
|
|
LDA #$00
|
2022-10-08 14:45:44 +00:00
|
|
|
STA $0101,X
|
2022-09-22 23:56:17 +00:00
|
|
|
INX
|
2022-10-08 14:45:44 +00:00
|
|
|
DEC OSNUM+2
|
|
|
|
BNE :DUMPEOF ; Loop to do 8 bytes
|
|
|
|
SEC ; SEC=EOF
|
|
|
|
:DUMPCHRS LDX #8 ; 8 bytes to print
|
|
|
|
:LOOP4 PLA ; Get character
|
|
|
|
PHP ; Save EOF flag
|
2022-09-22 23:56:17 +00:00
|
|
|
CMP #$7F
|
2022-10-08 14:45:44 +00:00
|
|
|
BEQ :DUMPDOT
|
2022-10-08 22:39:38 +00:00
|
|
|
CMP #' '
|
2022-10-08 14:45:44 +00:00
|
|
|
BCS :DUMPCHR
|
2022-10-08 22:39:38 +00:00
|
|
|
:DUMPDOT LDA #'.'
|
2022-10-08 14:45:44 +00:00
|
|
|
:DUMPCHR JSR OSWRCH ; Print character
|
|
|
|
INC OSNUM+0 ; Increment offset
|
|
|
|
BNE :DUMPNXT
|
|
|
|
INC OSNUM+1
|
|
|
|
:DUMPNXT PLP ; Get EOF flag back
|
|
|
|
DEX
|
|
|
|
BNE :LOOP4 ; Loop to do 8 bytes
|
|
|
|
PHP
|
2022-09-22 23:56:17 +00:00
|
|
|
JSR OSNEWL
|
2022-10-08 14:45:44 +00:00
|
|
|
PLP
|
|
|
|
BCC :LOOP1
|
|
|
|
JMP TYPCLOSE ; Close and finish
|
|
|
|
|
2022-09-22 23:56:17 +00:00
|
|
|
|
2022-09-21 04:21:13 +00:00
|
|
|
* Handle *SPOOL command
|
|
|
|
* LPTR=>parameters string
|
|
|
|
*
|
2022-10-08 14:45:44 +00:00
|
|
|
CMDSPOOL
|
|
|
|
LDA (OSLPTR),Y ; TEMP
|
|
|
|
CMP #$0D ; TEMP
|
|
|
|
PHP ; TEMP
|
|
|
|
JSR LPTRtoXY ; TEMP
|
|
|
|
*
|
|
|
|
PHY ; Save Y
|
|
|
|
LDY FXSPOOL ; Get SPOOL handle
|
|
|
|
BEQ :SPOOL1 ; Wasn't open, skip closing
|
|
|
|
LDA #$00 ; A=CLOSE
|
|
|
|
STA FXSPOOL ; Clear SPOOL handle
|
|
|
|
JSR OSFIND ; Close SPOOL file
|
|
|
|
:SPOOL1 PLY ; Get Y back, XY=>filename
|
|
|
|
PLP ; Get NE=filename, EQ=no filename
|
|
|
|
BEQ :DONE ; No filename, all done
|
|
|
|
LDA #$80 ; A=OPENOUT, for writing
|
|
|
|
JSR OUTPUTFILE ; Try to open file
|
|
|
|
STA FXSPOOL ; Store SPOOL handle
|
2022-09-21 04:21:13 +00:00
|
|
|
:DONE RTS
|
|
|
|
|
|
|
|
|
|
|
|
* Handle *EXEC command
|
|
|
|
* LPTR=>parameters string
|
|
|
|
*
|
2022-10-08 14:45:44 +00:00
|
|
|
CMDEXEC
|
|
|
|
LDA (OSLPTR),Y ; TEMP
|
|
|
|
CMP #$0D ; TEMP
|
|
|
|
PHP ; TEMP
|
|
|
|
JSR LPTRtoXY ; TEMP
|
|
|
|
*
|
|
|
|
PHY ; Save Y
|
|
|
|
LDY FXEXEC ; Get EXEC handle
|
|
|
|
BEQ :EXEC1 ; Wasn't open, skip closing it
|
|
|
|
LDA #$00 ; A=CLOSE
|
|
|
|
STA FXEXEC ; Clear EXEC handle
|
|
|
|
JSR OSFIND ; Close EXEC file
|
|
|
|
:EXEC1 PLY ; Get Y back, XY=>filename
|
|
|
|
PLP ; Get NE=filename, EQ=no filename
|
|
|
|
BEQ EXECDONE ; No filename, all done
|
|
|
|
JSR OPENINFILE ; Try to open file
|
|
|
|
STA FXEXEC ; Store EXEC file handle
|
|
|
|
EXECDONE RTS
|
|
|
|
|
|
|
|
OPENINFILE LDA #$40 ; Open for input
|
|
|
|
OUTPUTFILE JSR OSFIND ; Try to open file
|
|
|
|
TAY ; Was file opened?
|
|
|
|
BNE EXECDONE ; File opened
|
2022-10-08 22:39:38 +00:00
|
|
|
EXECNOTFND JMP ERRNOTFND ; File not found
|
2022-10-08 14:45:44 +00:00
|
|
|
|
2022-09-21 04:21:13 +00:00
|
|
|
|
2022-09-24 01:36:49 +00:00
|
|
|
*
|
|
|
|
* Handle *FAST command
|
|
|
|
* Turn Apple II accelerators on
|
|
|
|
FAST LDA #$80 ; Apple IIgs
|
|
|
|
TSB $C036
|
|
|
|
STA GSSPEED
|
2022-09-24 02:55:17 +00:00
|
|
|
JSR UNLOCKZIP ; ZipChip
|
2022-09-24 04:19:04 +00:00
|
|
|
JSR DETECTZIP
|
|
|
|
BCC :NOZIP
|
2022-09-24 02:55:17 +00:00
|
|
|
STA $C05B ; Enable
|
2022-09-24 04:19:04 +00:00
|
|
|
JMP LOCKZIP
|
|
|
|
:NOZIP STA $C05C ; Ultrawarp fast
|
2022-09-24 01:36:49 +00:00
|
|
|
RTS
|
|
|
|
|
|
|
|
*
|
|
|
|
* Handle *SLOW command
|
|
|
|
* Turn Apple II accelerators off
|
|
|
|
SLOW LDA #$80 ; Apple IIgs
|
|
|
|
TRB $C036
|
|
|
|
STZ GSSPEED
|
2022-09-24 02:55:17 +00:00
|
|
|
JSR UNLOCKZIP ; ZipChip
|
2022-09-24 04:19:04 +00:00
|
|
|
JSR DETECTZIP
|
|
|
|
BCC :NOZIP
|
2022-09-24 03:17:32 +00:00
|
|
|
STZ $C05A ; Disable
|
2022-09-24 04:19:04 +00:00
|
|
|
JMP LOCKZIP
|
|
|
|
:NOZIP STA $C05D ; Ultrawarp slow
|
2022-09-24 01:36:49 +00:00
|
|
|
RTS
|
2022-09-21 04:21:13 +00:00
|
|
|
|
2022-09-24 04:19:04 +00:00
|
|
|
* Detect a ZipChip
|
|
|
|
* Set carry is ZipChip found
|
|
|
|
DETECTZIP LDA $C05C ; ZipChip manual p25
|
|
|
|
EOR #$FF
|
|
|
|
STA $C05C
|
|
|
|
CMP $C05C
|
|
|
|
BNE :NOZIP
|
|
|
|
EOR #$FF
|
|
|
|
STA $C05C
|
|
|
|
CMP $C05C
|
|
|
|
BNE :NOZIP
|
|
|
|
SEC
|
|
|
|
RTS
|
|
|
|
:NOZIP CLC
|
|
|
|
RTS
|
|
|
|
|
2022-09-24 02:55:17 +00:00
|
|
|
* Unlock ZipChip registers
|
2022-09-24 03:17:32 +00:00
|
|
|
UNLOCKZIP PHP
|
|
|
|
SEI ; Timing sensitive
|
|
|
|
LDA #$5A
|
2022-09-24 02:55:17 +00:00
|
|
|
STA $C05A
|
|
|
|
STA $C05A
|
|
|
|
STA $C05A
|
|
|
|
STA $C05A
|
2022-09-24 03:26:17 +00:00
|
|
|
PLP
|
2022-09-24 02:55:17 +00:00
|
|
|
RTS
|
|
|
|
|
|
|
|
* Lock ZipChip registers
|
|
|
|
LOCKZIP LDA #$A5
|
|
|
|
STA $C05A
|
|
|
|
RTS
|
2021-10-26 13:31:34 +00:00
|
|
|
|