💾 Archived View for mirrors.apple2.org.za › archive › www.textfiles.com › apple › ANATOMY › cmd.inte… captured on 2024-08-19 at 03:01:30.
View Raw
More Information
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
AVAILABLE'
DCI 'RANGE ERROR'
DCI 'WRITE PROTECTED'
DCI 'END OF DATA'
DCI 'FILE NOT FOUND'
DCI 'VOLUME MISMATCH'
DCI 'I/O ERROR'
DCI 'DISK FULL'
DCI 'FILE LOCKED'
DCI 'SYNTAX ERROR'
DCI 'NO BUFFERS AVAILABLE'
DCI 'FILE TYPE MISMATCH'
DCI 'PROGRAM TOO LARGE'
DCI 'NOT DIRECT COMMAND'
HEX 8D
EMSGOFFS HEX 0003191924333E4C5B646D788498AABB
BUFADR DS 2
CURSTAT DS 1
CSWSTATE DS 1
CSWL DS 2
KSWL DS 2
MAXFILES DS 2
SSAVE DS 1
XSAVE DS 1
YSAVE DS 1
ASAVE DS 1
CMDLNIDX DS 1
MONFLGS DS 1
CMDINDX DS 1
LOADLEN DS 2
PENDCMD DS 1
TEMP1 DS 1
KYWRDIDX DS 1
KYWRDFND DS 1
VOLVAL DS 2
DRVAL DS 2
SLOTVAL DS 2
LENVAL DS 2
RECVAL DS 2
BYTVAL DS 2
ADRVAL DS 2
MONVAL DS 1
FNAME DS 30
SFNAME DS 30
MXFLS HEX 03
CTLD HEX 84
EXFLG DS 1
EXCBUF DS 2
WHCBASIC DS 1
RUNINTRC DS 1
LAAB7 ASC "APPLESOFT"
-
-
- The following are overlapping
- with the equivalent defs in
- the FILE.MNGR file.
-
LAAC1 DA $B7E8
LAAC3 DA $B3BB
LAAC5 DA $B4BB
LACC7 DA $C000
RV = $B7EA
IOBSLOT = $B7E9
AJUSTBYT = $BFDC
SETWARM = $BFE6
ROM = $C081
RAM = $C080
JMPFPST = $D43C
SETFPPR = $D4F2
NEWSTT = $D7D2
JPFPERR = $D865
BASWRM = $E003
BASCLD = $E000
INTERR = $E3E3
IRUN = $E836
OLDBRK = $FA59
INPRT = $FE8B
OUTPRT = $FE95
RTS = $FF58
MON = $FF65
ORG $9D00
DBUFP DA DBUF-1
DOSKBD DA KBDINTR
DOSVID DA VIDINTRC
PFNADR DA FNAME
SFNADR DA SFNAME
LDRNGLEN DA LOADLEN
LOADADR DA $9D00
FMPARMS DA FMOP
-
-
- CSW STATE HANDLER ADDRESSES
-
CSWSTADR DA CSWST-1
DA CSWST3-1
DA CSWST4-1
DA CSWST5-1
DA CSWST6-1
DA CSWST7-1
DA CSWST8-1
ORG $9D1E
CMDTBL DA DOINIT-1
DA DOLOAD-1
DA DOSAVE-1
DA DORUN-1
DA DOCHAIN-1
DA DODELETE-1
DA DOLOCK-1
DA DOUNLCK-1
DA DOCLOSE-1
DA DOREAD-1
DA DOEXEC-1
DA DOWRITE-1
DA DOPTION-1
DA DOOPEN-1
DA DOAPND-1
DA DORENAME-1
DA DOCAT-1
DA DOMON-1
DA DONOMON-1
DA DOPRNUM-1
DA DOINNUM-1
DA DOMXFLS-1
DA DOFP-1
DA DOINT-1
DA DOBSAVE-1
DA DOBLOAD-1
DA DOBRUN-1
DA DOVERIFY-1
ORG $9D55
CHNADR DA IRUN
RUNADR DA DOSIRUN
BASERR DA INTERR
BASCOLD DA BASCLD
BASWARM DA BASWRM
ASFTREL DA SETFPPR
INTTBL DA IRUN
DA DOSIRUN
DA INTERR
DA BASCLD
DA BASWRM
FPTBL DA DOSARUN
DA DOSARUN
DA JPFPERR
DA BASCLD
DA JMPFPST
DA SETFPPR
RAMASTBL DA DOSA2RUN
DA DOSA2RUN
DA L1067
DA DOSSTRT
DA LC3C
DA LCF2
ORG $9D84
-
-
-
- DOS COLDSTART ADDRESS
-
-
-
- INIT DEFAULT SLOT & DRIVE
-
DOSSTRT LDA IOBSLOT
LSR
LSR
LSR
LSR
STA SLOTVAL
LDA IOBDRV
STA DRVAL
-
-
- See which BASIC is active
-
LDA BASCLD
EOR #$20
BNE LDFPBAS
-
-
- Integer BASIC is active,
- move all required addresses
- down there.
-
STA WHCBASIC
LDX #$A
LDINT LDA INTTBL-1,X
STA CHNADR-1,X
DEX
BNE LDINT
JMP CHSBASIC
-
-
- Applesoft BASIC is active,
- move A/S addresses to the
- active BASIC addresses area.
-
LDFPBAS LDA #$40
STA WHCBASIC
LDX #$C
LDFPTBL LDA FPTBL-1,X
STA CHNADR-1,X
DEX
BNE LDFPTBL
CHSBASIC SEC
BCS INITDOS
ORG $9DBF
DOSWARM LDA WHCBASIC
BNE DOSWARM1
-
- Cause integer BASIC to be
- selected.
-
LDA #$20
BNE DOSWARM2
DOSWARM1 ASL
BPL DOSWARM3
LDA #$4C
DOSWARM2 JSR SETBASIC
DOSWARM3 CLC
ORG $9DD1
INITDOS PHP
JSR INITPTR
LDA #$0 ;set NOMON O,I,C
STA MONFLGS
STA CSWSTATE ;init to state 0
PLP
ROR
STA CURSTAT
BMI INITDOS1
JMP (BASWARM)
INITDOS1 JMP (BASCOLD)
-
-
-
- FRSTIME is call after a DOS coldstart
- it checks for RAM A/S and takes
- care of other coldstart stuff
- that must be done after BASIC
- is initialized.
-
FRSTIME ASL ;check for RAM or ROM A/S
BPL MVRAMAS2
-
-
- If RAM A/S, move required pointers
- into the active BASIC area.
-
STA WHCBASIC
LDX #$C
MVRAMAS LDA RAMASTBL-1,X
STA CHNADR-1,X
DEX
BNE MVRAMAS
LDX #$1D
MVRAMAS1 LDA SFNAME,X
STA FNAME,X
DEX
BPL MVRAMAS1
ORG $9E06
-
- Init MAXFILES to the default
- value (usually 3)
-
MVRANAS2 LDA MXFLS
STA MAXFILES
-
- set up the DOS buffers chain
-
JSR INITBUFS
-
-
- if EXEC is active, cause it to
- become inactive on the next
- character input
-
LDA EXFLG
BEQ MVRAMAS3
PHA
JSR PNTEXEC
PLA
LDY #0
STA (FILEBUF),Y
-
-
- reset the CSW state to 0, set
- warmstart status.
-
MVRAMAS3 JSR RSET0
-
-
- check to see if we are in the
- middle of a command.
-
LDA CMDINDX
BNE TSTPEND
-
-
- If not, copy the page 3 stuff
- down to $3D0
-
LDX #$2F
MOV3D0 LDA PAG3,X
STA DOSRST,X
DEX
BPL MOV3D0
LDA PAG3+2
STA SOFTEV+1
EOR #$A5
STA PWREDUP
LDA PAG3+1
STA SOFTEV
LDA #$6
BNE TSTPEND1
-
-
- If there is a command pending
- (because RAM A/S was loaded?)
- then execute it, otherwise
- return to BASIC.
-
TSTPEND LDA PENDCMD
BEQ TSTPEND2
TSTPEND1 STA CMDINDX
JMP DOCMD
TSTPEND2 RTS
ORG $9E51
-
- Stuff that gets moved down to
- $3D0
-
PAG3 JMP DOSWARM
JMP DOSSTRT
JMP FMGR2
JMP CALLRWTS
LDA FMPARMS+1
LDY FMPARMS
RTS
LDA LAAC1+1
LDY LAAC1
RTS
JMP INITPTR
NOP
NOP
JMP OLDBRK
JMP MON
JMP RTS
JMP MON
JMP MON
DA $FF65
ORG $9E81
-
- Keyboard intercept routine.
- Called each time a character
- is requested.
- "HOOKS" at $38 and $39 point
- at this routine.
-
KBDINTR JSR SAVREG
LDA CURSTAT ;reading from a file?
BEQ KBDINTR2
-
- If so, remove cursor from screen
-
PHA
LDA ASAVE
STA (BASE),Y
PLA
BMI KBDINTR1 ;doing coldstart?
JMP READBYTE
ORG $9E95
-
- special case for coldstart
-
KBDINTR1 JSR FRSTIME
LDY CH
LDA #$60
STA (BASE),Y
KBDINTR2 LDA EXFLG
BEQ KBDINTR3
JSR EXECRD
KBDINTR3 LDA #3
STA CSWSTATE
JSR REGRST
JSR RDCHAR
STA ASAVE
STX XSAVE
JMP DOSXIT
RDCHAR JMP (KSW)
ORG $9EBD
-
- Video input state handler.
- Transfers control to the
- proper output handler.
-
VIDINTRC JSR SAVREG
LDA CSWSTATE
ASL
TAX
LDA CSWSTADR+1,X
PHA
LDA CSWSTADR,X
PHA
LDA ASAVE
RTS ;Funny JMP (--)
ORG $9ED1
SAVREG STA ASAVE
STX XSAVE
STY YSAVE
TSX
INX
INX
STX SSAVE
LDX #3
SAVREG1 LDA CSWL,X
STA CSW,X
DEX
BPL SAVREG1
RTS
ORG $9EEB
-
- CSW STATE 0: Start of line.
- Check for control-D at
- beginning of line.
-
- If RUN command was delayed while
- loading A/S, continue RUN cmd.
-
CSWST LDX RUNINTRC
BEQ CSWST1
JMP RUNDONE
-
- Check to see if a file is
- being read.
-
CSWST1 LDX CURSTAT
BEQ CSWST2
-
- If a file is being read, check
- to see if "?" prompt was output
-
CMP #"?" ;A/S PROMPT
BEQ CSWST8
-
-
- See if at beginning of line
-
CMP PROMPT
BEQ CSWST4A
-
- If not control-D at beginning
- of line, goto state 2,
-
- otherwise go to state one and
- collect possible DOS command.
-
CSWST2 LDX #2
STX CSWSTATE
CMP CTLD
BNE CSWST4
DEX
STX CSWSTATE
DEX
STX CMDLNIDX
-
- Collect DOS command from
- input line and parse
-
CSWST3 LDX CMDLNIDX
C1LP STA IN,X
INX
STX CMDLNIDX
CMP #$8D
BNE ECHOC
JMP PARSE
ORG $9F23
-
-
- CSW STATE 2 handler, Non-DOS
- command.
-
- If current input character isn't
- a return, exit DOS through ECHO,
- otherwise reset command state
- to zero.
-
CSWST4 CMP #$8D
BNE ECHO
CSWST4A LDX #0
STX CSWSTATE
JMP ECHO
ORG $9F2F
-
- STATE 3 handler- INPUT statement
- handler.
-
-
- set the command state to zero
- as a default (in case input
- ends).
-
CSWST5 LDX #0
STX CSWSTATE
CMP #$8D
BEQ CSWST5A
-
- If not at end of input, check
- the exec flag.
- If set, echo character only if
- MON I is set or exec is active
- In either case the state will be
- reset to three.
-
-
C3CHKEXC LDA EXFLG
BEQ ECHO
BNE ECHOI
-
-
- Come here if EOLN encountered.
- If BASIC is not running, or
- EXECing a file goto state one
- and check for a possible DOS
- command. Otherwise exit DOS
- echoing character as appropriate
- after switching to state 1
-
-
-
CSWST5A PHA
SEC
LDA EXFLG
BNE CSWST5B
JSR ISBASRUN
CSWST5B PLA
BCC C3CHKEXC
LDX XSAVE
JMP C1LP
ORG $9F52
-
- STATE 4 handler.
- Write data to a file.
-
- check for EOLN, switch to
- state 5 if <cr> encountered.
-
CSWST6 CMP #$8D
BNE CSWST6A
LDA #5
STA CSWSTATE
CSWST6A JSR WRTBYTE
JMP ECHOO
ORG $9F61
-
- STATE 5 handler, start of
- write data line; check for CTL-D
-
CSWST7 CMP CTLD
BEQ CSWST
-
- treat any linefeeds as a
- continuation of the previous
- line.
-
CMP #$8A
BEQ CSWST6A
-
- Otherwise revert to state 4
-
LDX #4
STX CSWSTATE
BNE CSWST6
ORG $9F71
-
- STATE 6 handler, skip output of
- prompt character.
-
CSWST8 LDA #0
STA CSWSTATE
BEQ ECHOI
ORG $9F78
-
-
- Finish RUN command interrupted
- by RAM A/S load.
-
RUNDONE LDA #0
STA RUNINTRC
JSR INITPTR
JMP DORUN2
-
-
- End of DOS cmd scan.
- Remove DOS command and pretend
- the user only pressed return
-
SCNXIT LDA IN
CMP CTLD
BEQ ECHOC
LDA #$8D
STA IN
LDX #0
STX XSAVE
ORG $9F95
-
- Echo character conditionally to
- the screen:
-
- ECHOC - IF MON C
- ECHOO - IF MON O
- ECHOI - IF MON I
-
- ECHO - UNCONDITIONALLY
-
ECHOC LDA #$40
BNE ECHOI1
ECHOO LDA #$10
BNE ECHOI1
ECHOI LDA #$20
ECHOI1 AND MONFLGS
BEQ DOSXIT
ECHO JSR REGRST
JSR COUT
STA ASAVE
STY YSAVE
STX XSAVE
ORG $9FB3
-
- Restore registers and exit DOS
-
DOSXIT JSR INITPTR
LDX SSAVE
TXS
REGRST LDA ASAVE
LDY YSAVE
LDX XSAVE
SEC
RTS
ORG $9FC5
COUT JMP (CSW)
CRLF LDA #$8D
JMP COUT
ORG $9FCD
-
- Parse DOS command and check
- syntax
-
PARSE LDY #$FF
STY CMDINDX ;set to 0 (see ADDCHR)
INY
STY PENDCMD
-
- get successive characters from
- input buffer and compare against
- current command in table
-
ADDCHR INC CMDINDX
LDX #0
PHP ;assume "="
LDA IN,X ;skip any control-D's
CMP CTLD
BNE ADDCHR1
INX
ADDCHR1 STX CMDLNIDX
ADDCHR2 JSR FLSHCMDL ;skip blanks
AND #$7F
EOR DOSCMDS,Y ;compare to char in table
INY
-
- the following code is a tricky
- way of determining if the entire
- string is equal to one of the
- DOS commands
-
ASL
BEQ ADDCHR3
PLA
PHP
ADDCHR3 BCC ADDCHR2
PLP
BEQ COMPIDX
LDA DOSCMDS,Y
BNE ADDCHR ;at last command?
-
- If command was not found, see if
- first character on the line was
- control-D, if so SYNTAX ERROR!!!
-
GETFRST LDA IN
CMP CTLD
BEQ GETFRST1
JMP ECHO
GETFRST1 LDA IN+1
CMP #$8D
BNE GETFRST2
JSR RSET0
JMP ECHOC
GETFRST2 JMP CSYNERR
ORG $A01B
-
- Valid DOS command, get its
- address and execute it.
-
COMPIDX ASL CMDINDX
LDY CMDINDX
JSR ISBASRUN
BCC COMPIDX1
-
- Certain commands (such as OPEN,
- etc.) can only be executed if
- BASIC is running. If such a
- command is executed and BASIC
- is not running, fall through
- to here.
-
LDA #2
AND KWRDPRMS,Y
BEQ COMPIDX1
LDA #$F
JMP DOERROR
COMPIDX1 CPY #6
BNE COMPIDX2
STY PROMPT
-
-
- See if a filename is required
-
COMPIDX2 LDA #$20
AND KWRDPRMS,Y
BEQ FNDNNAM
-
- If a filename is needed, blank
- out the filename arrays and
- collect a filename (if found)
-
JSR BLKNAME
PHP
CMDINP JSR FLSHCMDL
BEQ CLRNAME3
ASL
BCC CMDINP1
BMI CMDINP1
JMP GETFRST
CMPINP1 ROR
JMP CLRNAME1
CLRNAME JSR GNXTCHR
BEQ CLRNAME3
CLRNAME1 STA FNAME,Y
INY
CPY #$3C
BCC CLRNAME
CLRNAME2 JSR GNXTCHR
BNE CLRNAME2
CLRNAME3 PLP
BNE CLRNAME4
LDY CMDINDX
LDA #$10
AND KWRDPRMS,Y
BEQ CLRNAME5
LDY #$1E
PHP
BNE CMDINP
CLRNAME4 LDA SFNAME
CMP #$A0
BEQ CHKFRST
CLRNAME5 LDA FNAME
CMP #$A0
BNE SETDFLTS
LDY CMDINDX
LDA #$C0
AND KWRDPRMS,Y
BEQ CHKFRST
BPL SETDFLTS
CHKFRST JMP GETFRST
ORG $A095
-
- subroutine to blank out the
- filenames.
-
BLKNAME LDY #$3C
LDA #$A0
BLKNAME1 STA MONVAL,Y
DEY
BNE BLKNAME1
RTS
ORG $A0A0
-
- Branch here if no filename
- is required.
-
FNDNNAM STA FNAME
-
- check parameter table to see
- if a positional parameter is
- required.
-
LDA #$C
AND KWRDPRMS,Y
BEQ SETDFLTS
-
- If so, read in the number
-
JSR GETNUM
BCS FNDNNAM3
TAY
BNE FNDNNAM2
-
- check the range of the number
-
CPX #$11
BCS FNDNNAM2
LDY CMDINDX
LDA #8
AND KWRDPRMS,Y
BEQ FNDNNAM1
CPX #8
BCS CHKFRST
-
- if # within range, set defaults
-
BCC SETDFLTS
FNDNNAM1 TXA
BNE SETDFLTS
FNDNNAM2 LDA #2
JMP DOERROR
FNDNNAM3 JMP CSYNERR
ORG $A0D1
-
- Set up defaults for the
- positional values
-
SETDFLTS LDA #0
STA KYWRDFND
STA MONVAL
STA VOLVAL
STA LENVAL
STA LENVAL+1
JSR AJUSTBYT
LDA CMDLNIDX
-
- Come here if positionals are
- required.
-
-
- First, skip any leading blanks
-
GETNXT JSR FLSHCMDL
BNE GETNXT1
CMP #$8D
BNE GETNXT
-
- If at EOLN, make sure we
- have all the arguements
- we need.
-
LDX CMDINDX
LDA KYWRDFND
ORA KWRDPRMS+1,X
EOR KWRDPRMS+1,X
BNE CHKFRST
LDX TEMP1
BEQ PROCMD
STA TEMP1
STX CMDLNIDX
BNE GETNXT
GETNXT1 LDX #$A
GETNXT2 CMP PPARMS-1,X
BEQ ISLE1
DEX
BNE GETNXT2
ISLE BEQ FNDNNAM3
-
- As each positional arguement
- is encountered, make it as
- present in KYWRDFND
-
ISLE1 LDA PARMBITS-1,X
BMI UPDATMON
ORA KYWRDFND
STA KYWRDFND
DEX
STX KYWRDIDX
-
- get numeric value associated
- with the keyword.
-
JSR GETNUM
BCS FNDNNAM3
-
- check the range of the value
- following the keyword.
-
LDA KYWRDIDX
ASL
ASL
TAY
LDA OPRND+1
BNE ISLE2
LDA OPRND
CMP KWRANGE,Y
BCC FNDNNAM2
LDA OPRND+1
ISLE2 CMP KWRANGE+3,Y
BCC ISLE4
ISLE3 BNE FNDNNAM2
LDA OPRND
CMP KWRANGE+2,Y
BCC ISLE4
BNE ISLE3
ISLE4 LDA TEMP1
BNE GETNXT
-
- save value parsed in the keyword
- parameters table.
-
TYA
LSR
TAY
LDA OPRND+1
STA VOLVAL+1,Y
LDA OPRND
STA VOLVAL,Y
GNISLE JMP GETNXT
ORG $A164
-
- If O,I, or C was encountered in
- MON or NOMON, set appropriate
- bits.
-
UPDATMON PHA
LDA #$80
ORA KYWRDFND
STA KYWRDFND
PLA
AND #$7F
ORA MONVAL
STA MONVAL
BNE GNISLE
BEQ ISLE
ORG $A17A
-
-
- Process valid DOS command
-
PROCMD JSR DOCMD
JMP SCNXIT
DOCMD JSR RSET0
JSR CLRFMP
LDA CMDINDX
TAX
LDA CMDTBL+1,X
PHA
LDA CMDTBL,X
PHA
RTS
ORG $A193
-
- Get next character from command
- line and check for a <cr> or
- a comma.
-
GNXTCHR LDX CMDLNIDX
LDA IN,X
CMP #$8D
BEQ GNXTCHR1
INX
STX CMDLNIDX
CMP #","
GNXTCHR1 RTS
ORG $A1A4
-
- FLSHCMDL- deletes leading blanks
- from command line. Z-flag is
- returned set if "," or <cr> is
- first non-blank encountered.
-
-
FLSHCMDL JSR GNXTCHR
BEQ GNXTCHR1
CMP #$A0
BEQ FLSHCMDL
RTS
ORG $A1AE
-
- CLRFMP- clears file manager's
- parameter area.
-
CLRFMP LDA #0
LDY #$16
CLRFMP1 STA FMOP-1,Y
DEY
BNE CLRFMP1
RTS
ORG $A1B9
-
- GETNUM- converts numeric (in
- ASCII) arguement to binary.
-
- DECIMAL and HEX are supported.
-
GETNUM LDA #0
STA OPRND
STA OPRND+1
JSR FLSHCMDL
PHP
CMP #"$"
BEQ HEXCONV
PLP
JMP GETNUM2
-
- Decimal input routine here
-
GETNUM1 JSR FLSHCMDL
GETNUM2 BNE GETNUM3
LDX OPRND
LDA OPRND+1
CLC
RTS
-
- get current character, multiply
- OPRND by 10, and add in numeric
- value for current digit
-
GETNUM3 SEC
SBC #"0"
BMI BADNUM
CMP #$A
BCS BADNUM
-
- multiply OPRND by 10
- (OPRND*2 + OPRND*8)
-
- and add in digit value
-
-
JSR MUL2
ADC OPRND
TAX
LDA #0
ADC OPRND+1
TAY
JSR MUL2
JSR MUL2
TXA
ADC OPRND
STA OPRND
TYA
ADC OPRND+1
STA OPRND+1
BCC GETNUM1
BADNUM SEC
RTS
MUL2 ASL OPRND
ROL OPRND+1
RTS
ORG $A203
HEXCONV PLP
HEXLOOP JSR FLSHCMDL
BEQ GETNUM2
SEC
SBC #$B0
BMI BADNUM
CMP #$A
BCC HEXLOOP1
SBC #7
BMI BADNUM
CMP #$10
BCS BADNUM
HEXLOOP1 LDX #4
HEXLOOP2 JSR MUL2
DEX
BNE HEXLOOP2
ORA OPRND
STA OPRND
JMP HEXLOOP
ORG $A229
DOPRNUM LDA OPRND
JMP OUTPRT
ORG $A22E
DOINNUM LDA OPRND
JMP INPRT
ORG $A233
-
- Do MON and NOMON commands
-
DOMON LDA MONFLGS
ORA MONVAL
STA MONFLGS
RTS
DONOMON BIT MONVAL
BVC DONOMON1
JSR CRLF
DONOMON1 LDA #$70
EOR MONVAL
AND MONFLGS
STA MONFLGS
RTS
ORG $A251
DOMXFLS LDA #0
STA EXFLG
LDA OPRND
PHA
JSR CLOSALL
PLA
STA MAXFILES
JMP INITBUFS
ORG $A263
-
- Handle DOS DELETE command
-
DODELETE LDA #5
JSR CMDHNDL1 ;perform the delete.
-
- Free up the buffer used by
- the delete command.
-
JSR LOCBUF
LDY #0
TYA
STA (FILEBUF),Y
RTS
ORG $A271
DOLOCK LDA #7
BNE DOUNLCK1
DOUNLCK LDA #8
DOUNLCK1 JSR CMDHNDL1
JMP DOCLOSE
ORG $A27D
-
- Handle DOS verify command
-
DOVERIFY LDA #$C
BNE DOUNLCK1
ORG $A281
-
- Handle DOS RENAME command
-
DORENAME LDA SFNADR
STA NEWNAME
LDA SFNADR+1
STA NEWNAME+1
LDA #9
STA TEMP1
JSR CLOSOPN
JMP DOCLOSE
ORG $A298
-
- APPEND command is handled here.
- Just do an open and then read
- the file until a $00 is
- encountered.
-
DOAPND JSR DOOPEN
DOAPND1 JSR RDTEXT
BNE DOAPND1
JMP APTCH2
ORG $A2A3
DOOPEN LDA #0
JMP OPENTST
ORG $A2A8
-
- File manager setup used by the
- various DOS commands
-
CMDHNDLR LDA #1
CMDHNDL1 STA TEMP1
LDA LENVAL
BNE CMDHNDL2
LDA LENVAL+1
BNE CMDHNDL2
LDA #1
STA LENVAL
CMDHNDL2 LDA LENVAL
STA RECNUM
LDA LENVAL+1
STA RECNUM+1
-
- Close a file if already open.
-
CLOSOPN JSR DOCLOSE
LDA OPRND+1
BNE CLOSOPN1
JMP NOBUF
CLOSOPN1 STA FILEBUF+1
LDA OPRND
STA FILEBUF
JSR COPFNAM
JSR COPPTRS
JSR COPYPARM
LDA TEMP1
STA FMOP
JMP FMDRVR
ORG $A2EA
DOCLOSE LDA FNAME
CMP #$A0
BEQ CLOSALL
JSR LOCBUF
BCS RTS0
JSR CLOSFRE
JMP DOCLOSE
ORG $A2FC
-
- FREE any buffers used by file
- being closed.
-
CLOSFRE JSR ISEXBUF
BNE CLOSFRE1
LDA #0
STA EXFLG
CLOSFRE1 LDY #0
TYA
STA (FILEBUF),Y
JSR COPPTRS
LDA #2
STA FMOP
JMP FMDRVR
ORG $A316
CLOSALL JSR FRSTBUF
BNE CLOSALL2
CLOSALL1 JSR PTNXTBF
BEQ RTS0
CLOSALL2 JSR ISEXBUF
BEQ CLOSALL1
JSR GFBFNAM
BEQ CLOSALL1
JSR CLOSFRE
JMP CLOSALL
RTS0 RTS
ORG $A331
DOBSAVE LDA #9 ;check parameters
AND KYWRDFND
CMP #9
BEQ DOBSAVE1
JMP GETFRST
-
- Open file and make sure it's
- Binary.
-
DOBSAVE1 LDA #4
JSR OPENTST
LDA ADRVAL+1
LDY ADRVAL
JSR WRT2
LDA LENVAL+1
LDY LENVAL
JSR WRT2
LDA ADRVAL+1
LDY ADRVAL
JMP RWRANGE
ORG $A35D
DOBLOAD JSR CMDHNDLR
-
- Make sure it is a binary file
-
LDA #$7F
AND FILETYPE
CMP #4
BEQ DOBLOAD1
JMP FMISMTCH
DOBLOAD1 LDA #4
JSR OPENTST
-
- Read in length and address
- values.
-
JSR READDBYT
TAX
LDA KYWRDFND
AND #1
BNE DOBLOAD2
STX ADRVAL
STY ADRVAL+1
DOBLOAD2 JSR READDBYT
LDX ADRVAL
LDY ADRVAL+1
JMP RWSETUP
ORG $A38E
DOBRUN JSR DOBLOAD
JSR INITPTR
JMP (ADRVAL)
ORG $A397
DOSAVE LDA WHCBASIC
BEQ ISINT
-
- Applesoft BASIC at this point
-
-
- Is source protected?
-
LDA PROTECT
BPL DOSAVE1
JMP PTOOBIG
DOSAVE1 LDA #2
JSR OPENTST
SEC
LDA ASPEND
SBC ASPGMST
TAY
LDA ASPEND+1
SBC ASPGMST+1
JSR WRT2
LDA ASPGMST+1
LDY ASPGMST
JMP RWRANGE
ISINT LDA #1
JSR OPENTST
SEC
LDA INTHIMEM
SBC INTSTRT
TAY
LDA INTHIMEM+1
SBC INTSTRT+1
JSR WRT2
LDA INTSTRT+1
LDY INTSTRT
JMP RWRANGE
ORG $A3BC
-
- Open a file and check its type
-
OPENTST STA FILETYPE
PHA
JSR CMDHNDLR
PLA
JMP CHKTYPE
-
- Write two bytes out to a file
-
WRT2 STY RANGELEN
STY DATARANG
STA RANGELEN+1
LDA #4
STA FMOP
LDA #1
STA FMSUBOP
JSR FMDRVR
LDA RANGELEN+1
STA DATARANG
JMP FMDRVR
-
-
- Read or Write a range of bytes
-
RWRANGE STY DATARANG
STA DATARANG+1
LDA #2
JMP VFYPTCH
RWRANGE1 JSR FMDRVR
JMP DOCLOSE
FTMIS JMP FMISMTCH
ORG $A413
DOLOAD JSR CLOSALL
JSR CMDHNDLR
LDA #$23 ;is type INT, RAM A/S or ROM A/S?
AND FILETYPE
BEQ FTMIS
STA FILETYPE
LDA WHCBASIC
BEQ DOLOAD2
LDA #2
JSR SLBASIC
-
-
- Read in length of A/S program
-
JSR READDBYT
-
-
- compute A/S pointer values
-
CLC
ADC ASPGMST
TAX
TYA
ADC ASPGMST+1
CMP ASHIMEM+1
BCS PTOOLRG
STA ASPEND+1
STA ASVARS+1
STX ASPEND
STX ASVARS
LDX ASPGMST
LDY ASPGMST+1
JSR RWSETUP
JSR INITPTR
JMP (ASFTREL)
-
- select integer BASIC and load
- integer program
-
DOLOAD2 LDA #1
JSR SLBASIC
JSR READDBYT
SEC
LDA INTHIMEM
SBC LOADLEN
TAX
LDA INTHIMEM+1
SBC LOADLEN+1
BCC PTOOLRG
TAY
CPY INTLOMEM+1
BCC PTOOLRG
BEQ PTOOLRG
STY INTSTRT+1
STX INTSTRT
-
-
- Read or Write the range of bytes
- required.
-
RWSETUP STX DATARANG
STY DATARANG+1
JMP RWRANGE1
-
-
- Read two bytes from the
- specified file.
-
READDBYT LDA LDRNGLEN
STA DATARANG
LDA LDRNGLEN+1
STA DATARANG+1
LDA #0
STA RANGELEN+1
LDA #2
STA RANGELEN
LDA #3
STA FMOP
LDA #2
STA FMSUBOP
JSR FMDRVR
LDA LOADLEN+1
STA RANGELEN+1
TAY
LDA LOADLEN
STA RANGELEN
RTS
ORG $A4AB
-
- Print "PROGRAM TOO LARGE"
-
PTOOLRG JSR DOCLOSE
JMP PTOOBIG
-
- Select a BASIC.
- If BASIC matches filetype, quit.
- If not, select alternate BASIC.
-
-
- See if the proper BASIC is
- already selected.
-
SLBASIC CMP FILETYPE
BEQ RTS1
-
- If not, save CMDINDX and
- change BASICs
-
LDX CMDINDX
STX PENDCMD
LSR
BEQ SLBASIC1
JMP DOINT
-
- If changing to Applesoft,
- save filename in case RAM
- A/S is loading (remember,
- RAM A/S is an integer program
- called "APPLESOFT", during
- its load it will wipe out
- FNAME).
-
SLBASIC1 LDX #$1D
SLBASIC2 LDA FNAME,X
STA SFNAME,X
DEX
BPL SLBASIC2
JMP DOFP
RTS1 RTS
ORG $A4D1
DORUN LDA WHCBASIC
BEQ DORUN1
STA RUNINTRC
DORUN1 JSR DOLOAD
DORUN2 JSR CRLF
JSR INITPTR
JMP (RUNADR)
ORG $A4E5
-
- If integer BASIC, handle RUN
- command here.
-
DOSIRUN LDA INTLOMEM
STA INTVEND
LDA INTLOMEM+1
STA INTVEND+1
JMP (CHNADR)
ORG $A4F0
DOCHAIN JSR DOLD2
JSR CRLF
JSR INITPTR
JMP (CHNADR)
-
-
-
-
- Applesoft CHAIN is simply a RUN
-
DOSARUN JSR LD665
STA PROMPT
STA ASONERR
JMP NEWSTT
DOSA2RUN JSR LE65
STA PROMPT
STA ASONERR
JMP LFD4
ORG $A510
-
- Handle the DOS write command
-
DOWRITE JSR RWCOMON
LDA #5
STA CSWSTATE
JMP SCNXIT
ORG $A51B
DOREAD JSR RWCOMON
LDA #1
STA CURSTAT
JMP SCNXIT
-
- Code common to both read and
- write.
-
-
- First, see if a buffer is
- already allocated to the
- file.
-
RWCOMON JSR LOCBUF
BCC RWCOMON1
JSR DOOPEN
JMP RWCOMON2
-
- If so, copy file buffer workspc
- to the file manager workspace
-
RWCOMON1 JSR COPPTRS
-
- check to see if "R" or "B"
- parameters were specified.
-
RWCOMON2 LDA KYWRDFND
AND #6
BEQ RTS2
-
- If so, copy numeric operands
- to the parameter list.
-
LDX #3
RWCOMON3 LDA RECVAL,X
STA RECNUM,X
DEX
BPL RWCOMON3
-
- Because R or B parameter was
- specified, a POSITION command
- must be issued before the
- read or write command.
-
LDA #$A
STA FMOP
JSR FMDRVR
RTS2 RTS
ORG $A54F
-
- INIT command
-
-
- If "V" parameter not specified,
- or it was specified as 0,
- default to 254
-
DOINIT LDA #$40
AND KYWRDFND
BEQ DOINIT1
LDA VOLVAL
BNE DOINIT2
DOINIT1 LDA #254
STA VOLVAL
-
- Get page # of DOS ($9D for
- 48K) and store in subcode
- field.
-
DOINIT2 LDA LOADADR+1
STA FMSUBOP
LDA #$B
JSR CMDHNDL2
JMP DOSAVE
ORG $A56E
DOCAT LDA #6
JSR CMDHNDL2
-
- Set default volume to the
- volume number of the disk
- just cataloged.
-end of file-