Implemented OSARGS flush cmds. Auxmem code cleanup.

This commit is contained in:
Bobbi Webber-Manners 2021-07-30 15:47:36 -04:00
parent eea38f083e
commit aebc3d261f
4 changed files with 124 additions and 74 deletions

Binary file not shown.

View File

@ -45,6 +45,7 @@ OPENCMD EQU $C8
READCMD EQU $CA READCMD EQU $CA
WRITECMD EQU $CB WRITECMD EQU $CB
CLSCMD EQU $CC CLSCMD EQU $CC
FLSHCMD EQU $CD
GMARKCMD EQU $CF GMARKCMD EQU $CF
GEOFCMD EQU $D1 GEOFCMD EQU $D1

172
auxmem.s
View File

@ -10,6 +10,8 @@ ZP3 EQU $94
ROW EQU $96 ; Cursor row ROW EQU $96 ; Cursor row
COL EQU $97 ; Cursor column COL EQU $97 ; Cursor column
STRTBCKL EQU $9D
STRTBCKH EQU $9E
WARMSTRT EQU $9F ; Cold or warm start WARMSTRT EQU $9F ; Cold or warm start
* $00-$8F Language workspace * $00-$8F Language workspace
@ -56,8 +58,7 @@ MOSSHIM
* *
* Initially executing at $3000 until copied to $D000 * Initially executing at $3000 until copied to $D000
MOSINIT MOSINIT STA $C005 ; Make sure we are writing aux
STA $C005 ; Make sure we are writing aux
STA $C000 ; Make sure 80STORE is off STA $C000 ; Make sure 80STORE is off
LDA $C08B ; LC RAM Rd/Wt, 1st 4K bank LDA $C08B ; LC RAM Rd/Wt, 1st 4K bank
@ -137,10 +138,10 @@ MOSINIT
STZ ESCFLAG STZ ESCFLAG
LDX #$35 LDX #$35
INITPG2 LDA DEFVEC,X :INITPG2 LDA DEFVEC,X
STA $200,X STA $200,X
DEX DEX
BPL INITPG2 BPL :INITPG2
LDA #<:HELLO LDA #<:HELLO
LDY #>:HELLO LDY #>:HELLO
@ -171,6 +172,21 @@ INITPG2 LDA DEFVEC,X
:OLDM ASC '(Use OLD to recover any program)' :OLDM ASC '(Use OLD to recover any program)'
DB $0D,$0D,$00 DB $0D,$0D,$00
* Backup STRTL and STRTH to STRTBCKL/STRTBCKH
* STRTL/STRTH are used by Apple II XFER, but we need to
* preserve these for the BBC Micro
BCKSTRT LDA STRTL
STA STRTBCKL
LDA STRTH
STA STRTBCKH
RTS
* Restore STRTL and STRTH from STRTBCKL/STRTBCKH
RSTSTRT LDA STRTBCKL
STA STRTL
LDA STRTBCKH
STA STRTH
RTS
* Clear to EOL * Clear to EOL
CLREOL LDA ROW CLREOL LDA ROW
@ -286,10 +302,7 @@ FINDHND PHX
STX ZP1 ; Points to filename STX ZP1 ; Points to filename
STY ZP1+1 STY ZP1+1
LDA STRTL ; Backup STRTL/STRTH JSR BCKSTRT
STA TEMP1
LDA STRTH
STA TEMP2
TSX ; Stash alt ZP TSX ; Stash alt ZP
STX $0101 STX $0101
@ -339,10 +352,7 @@ OSFINDRET
LDX $0101 ; Recover alt SP from $0101 LDX $0101 ; Recover alt SP from $0101
TXS TXS
PHA ; Return value PHA ; Return value
LDA TEMP1 ; Restore STRTL/STRTH JSR RSTSTRT
STA STRTL
LDA TEMP2
STA STRTH
PLA ; Return value PLA ; Return value
PLY ; Value of A on entry PLY ; Value of A on entry
CPY #$00 ; Was it close? CPY #$00 ; Was it close?
@ -371,10 +381,7 @@ OSGBPBM ASC 'OSGBPB.'
BPUTHND PHX BPUTHND PHX
PHY PHY
PHA ; Stash char to write PHA ; Stash char to write
LDA STRTL ; Backup STRTL/STRTH JSR BCKSTRT
STA TEMP1
LDA STRTH
STA TEMP2
STA $C004 ; Write to main memory STA $C004 ; Write to main memory
STY MOSFILE ; File reference number STY MOSFILE ; File reference number
STA $C005 ; Write to aux memory STA $C005 ; Write to aux memory
@ -392,10 +399,7 @@ BPUTHND PHX
OSBPUTRET OSBPUTRET
LDX $0101 ; Recover alt SP from $0101 LDX $0101 ; Recover alt SP from $0101
TXS TXS
LDA TEMP1 ; Recover STRTL/STRTH JSR RSTSTRT
STA STRTL
LDA TEMP2
STA STRTH
CLC ; Means no error CLC ; Means no error
PLA PLA
PLY PLY
@ -405,10 +409,7 @@ OSBPUTRET
* OSBGET - read one byte from an open file * OSBGET - read one byte from an open file
BGETHND PHX BGETHND PHX
PHY PHY
LDA STRTL ; Backup STRTL/STRTH JSR BCKSTRT
STA TEMP1
LDA STRTH
STA TEMP2
STA $C004 ; Write to main memory STA $C004 ; Write to main memory
STY MOSFILE ; File ref number STY MOSFILE ; File ref number
STA $C005 ; Write to aux memory STA $C005 ; Write to aux memory
@ -425,10 +426,7 @@ OSBGETRET
LDX $0101 ; Recover alt SP from $0101 LDX $0101 ; Recover alt SP from $0101
TXS TXS
PHA ; Return code PHA ; Return code
LDA TEMP1 ; Recover STRTL/STRTH JSR RSTSTRT
STA STRTL
LDA TEMP2
STA STRTH
PLA ; Return code (ie: char read) PLA ; Return code (ie: char read)
CLC ; Means no error CLC ; Means no error
CPY #$00 ; Check error status CPY #$00 ; Check error status
@ -439,11 +437,69 @@ OSBGETRET
RTS RTS
* OSARGS - adjust file arguments * OSARGS - adjust file arguments
ARGSHND LDA #<OSARGSM * On entry, A=action
LDY #>OSARGSM * X=>4 byte ZP control block
JMP PRSTR * Y=file handle
OSARGSM ASC 'OSARGS.' ARGSHND PHA
DB $00 PHX
PHY
CPY #$00
BNE :HASFILE
CMP #$00 ; Y=0,A=0 => current file sys
BNE :S1
PLY
PLX
PLA
LDA #$04 ; DFS
RTS
:S1 CMP #$01 ; Y=0,A=1 => addr of CLI
BNE :S2
* TODO: Implement this for *RUN and *command
JSR BEEP
BRA :EXIT
:S2 CMP #$FF ; Y=0,A=FF => flush all files
STA $C004 ; Write main memory
STZ MOSFILE ; Zero means flush all
STA $C005 ; Write aux memory
BRA :FLUSH
:HASFILE CMP #$00 ; Y!=0,A=0 => read seq ptr
BNE :S3
*TODO READ SEQ PTR
BRA :EXIT
:S3 CMP #$01 ; Y!=0,A=1 => write seq ptr
BNE :S4
*TODO WRT SEQ PTR
BRA :EXIT
:S4 CMP #$02 ; Y!=0,A=2 => read file len
BNE :S5
*TODO READ FILE LEN
:S5 CMP #$FF ; Y!=0,A=FF => flush file
BNE :EXIT
STA $C004 ; Write main memory
STY MOSFILE ; File ref num
STA $C005 ; Write aux memory
:FLUSH JSR BCKSTRT
LDA #<FLUSH
STA STRTL
LDA #>FLUSH
STA STRTH
CLC ; Use main memory
CLV ; Use main ZP and LC
JMP XFER
:EXIT PLY
PLX
PLA
RTS
* When there is no return value
OSARGSRET1
LDX $0101 ; Recover alt ZP from $0101
TXS
JSR RSTSTRT
PLY
PLX
PLA
RTS
* OSFILE - perform actions on entire files * OSFILE - perform actions on entire files
* On entry, A=action * On entry, A=action
@ -495,11 +551,7 @@ FILEHND PHX
STY MOSFILE ; Length (Pascal string) STY MOSFILE ; Length (Pascal string)
STA $C005 ; Write aux STA $C005 ; Write aux
LDA STRTL ; Backup STRTL/STRTH JSR BCKSTRT
STA TEMP1
LDA STRTH
STA TEMP2
TSX TSX
STX $0101 ; Store alt SP in $0101 STX $0101 ; Store alt SP in $0101
@ -540,10 +592,7 @@ OSFILERET
LDX $0101 ; Recover alt SP from $0101 LDX $0101 ; Recover alt SP from $0101
TXS TXS
PHA ; Return value PHA ; Return value
LDA TEMP1 ; Restore STRTL/STRTH JSR RSTSTRT
STA STRTL
LDA TEMP2
STA STRTH
PLA ; Return value PLA ; Return value
PLY ; Value of A on entry PLY ; Value of A on entry
CPY #$FF ; LOAD CPY #$FF ; LOAD
@ -593,8 +642,6 @@ OSFILEM ASC 'OSFILE($'
DB $00 DB $00
OSFILEM2 ASC ')' OSFILEM2 ASC ')'
DB $00 DB $00
TEMP1 DB $00
TEMP2 DB $00
RDCHHND PHX RDCHHND PHX
PHY PHY
@ -1260,10 +1307,7 @@ STARQUIT LDA #<QUIT
CLV ; Main ZP & LC CLV ; Main ZP & LC
JMP XFER JMP XFER
STARCAT LDA STRTL STARCAT JSR BCKSTRT
STA TEMP1
LDA STRTH
STA TEMP2
TSX TSX
STX $0101 ; Stash alt SP STX $0101 ; Stash alt SP
LDA #<CATALOG LDA #<CATALOG
@ -1276,10 +1320,7 @@ STARCAT LDA STRTL
STARCATRET STARCATRET
LDX $0101 ; Recover alt SP LDX $0101 ; Recover alt SP
TXS TXS
LDA TEMP1 JSR RSTSTRT
STA STRTL
LDA TEMP2
STA STRTH
RTS RTS
* Print one block of a catalog. Called by CATALOG * Print one block of a catalog. Called by CATALOG
@ -1303,11 +1344,7 @@ PRONEBLK LDX $0101 ; Recover alt SP
BNE :L1 BNE :L1
BRA :END BRA :END
:END LDA STRTL :END JSR BCKSTRT
STA TEMP1
LDA STRTH
STA TEMP2
LDA #<CATALOGRET LDA #<CATALOGRET
STA STRTL STA STRTL
LDA #>CATALOGRET LDA #>CATALOGRET
@ -1387,11 +1424,7 @@ STARDIR LDA ZP1 ; Move ZP1->ZP3 (OSWRCH uses ZP1)
STA $C004 ; Write main STA $C004 ; Write main
STX MOSFILE ; Length byte STX MOSFILE ; Length byte
STA $C005 ; Write aux STA $C005 ; Write aux
JSR BCKSTRT
LDA STRTL
STA TEMP1
LDA STRTH
STA TEMP2
TSX TSX
STX $0101 ; Stash alt SP STX $0101 ; Stash alt SP
LDA #<SETPFX LDA #<SETPFX
@ -1404,10 +1437,7 @@ STARDIR LDA ZP1 ; Move ZP1->ZP3 (OSWRCH uses ZP1)
STARDIRRET STARDIRRET
LDX $0101 ; Recover Alt SP LDX $0101 ; Recover Alt SP
TXS TXS
LDA TEMP1 JSR RSTSTRT
STA STRTL
LDA TEMP2
STA STRTH
RTS RTS
* Performs OSBYTE $80 function * Performs OSBYTE $80 function
@ -1432,10 +1462,7 @@ OSBYTE80 CPX #$00 ; X=0 Last ADC channel
* Performs OSBYTE $7F EOF function * Performs OSBYTE $7F EOF function
* File ref number is in X * File ref number is in X
CHKEOF LDA STRTL ; Backup STRTL/STRTH CHKEOF JSR BCKSTRT
STA TEMP1
LDA STRTH
STA TEMP2
STA $C004 ; Write main mem STA $C004 ; Write main mem
STX MOSFILE ; File reference number STX MOSFILE ; File reference number
STA $C005 ; Write aux mem STA $C005 ; Write aux mem
@ -1452,10 +1479,7 @@ CHKEOFRET
LDX $0101 ; Recover alt SP from $0101 LDX $0101 ; Recover alt SP from $0101
TXS TXS
PHA ; Return code in A PHA ; Return code in A
LDA TEMP1 JSR RSTSTRT
STA STRTL
LDA TEMP2
STA STRTH
PLX ; Recover return code -> X PLX ; Recover return code -> X
RTS RTS

View File

@ -357,6 +357,28 @@ FILEEOF LDX $0100 ; Recover SP
JMP XFER JMP XFER
:REMAIN DS 3 ; Remaining bytes :REMAIN DS 3 ; Remaining bytes
* ProDOS file handling for OSARGS flush commands
FLUSH LDX $0100 ; Recover SP
TXS
LDA $C081 ; ROM, please
LDA $C081
LDA MOSFILE ; File ref number
STA FLSHPL+1
JSR MLI
DB FLSHCMD
DW FLSHPL
LDA $C08B ; R/W RAM, LC bank 1
LDA $C08B
LDA #<OSARGSRET1
STA STRTL
LDA #>OSARGSRET1
STA STRTH
SEC
BIT RTSINST
JMP XFER
* ProDOS file handling for MOS OSFILE LOAD call * ProDOS file handling for MOS OSFILE LOAD call
* Return A=0 if successful * Return A=0 if successful
* A=1 if file not found * A=1 if file not found
@ -761,6 +783,9 @@ WRITEPL HEX 04 ; Number of parameters
CLSPL HEX 01 ; Number of parameters CLSPL HEX 01 ; Number of parameters
DB $00 ; Reference number DB $00 ; Reference number
FLSHPL HEX 01 ; Number of parameters
DB $00 ; Reference number
ONLPL HEX 02 ; Number of parameters ONLPL HEX 02 ; Number of parameters
DB $00 ; Unit num DB $00 ; Unit num
DW $301 ; Buffer DW $301 ; Buffer