Revert merge of JGH's PR.

This commit is contained in:
Bobbi Webber-Manners 2022-10-08 17:37:45 -04:00
parent a775bc2f87
commit b5a1b7019b
5 changed files with 600 additions and 354 deletions

Binary file not shown.

View File

@ -209,7 +209,7 @@ BYTE00 BEQ BYTE00A ; OSBYTE 0,0 - generate error
RTS ; %000x1xxx host type, 'A'pple
BYTE00A BRK
DB $F7
HELLO ASC 'Applecorn MOS 2022-10-07'
HELLO ASC 'Applecorn MOS 2022-10-08'
DB $00 ; Unify MOS messages
GSSPEED DB $00 ; $80 if GS is fast, $00 for slow

View File

@ -9,35 +9,34 @@
* 26-Oct-2021 Corrected entry parameters to OSRDRM.
* 03-Nov-2021 Temp'y fix, if can't find SROM, ignores it.
* 13-Nov-2021 ROMSELECT calls mainmem to load ROM.
* 08-Oct-2022 ROMSEL doesn't call loder if already paged in.
* OSBYTE $80 - ADVAL
************************************
* Read input device or buffer status
BYTE80 LDY #$00 ; Prepare return=&00xx
TXA ; X<0 - info about buffers
BMI ADVALBUF ; X>=0 - read input devices
BYTE80 LDY #$00 ; Prepare return=&00xx
TXA ; X<0 - info about buffers
BMI ADVALBUF ; X>=0 - read input devices
CPX #$7F
BNE ADVALNONE
ADVALWAIT JSR KBDREAD
BCS ADVALWAIT
TAX
BPL ADVALOK1 ; &00xx for normal keys
INY ; &01xx for function/edit keys
BPL ADVALOK1 ; &00xx for normal keys
INY ; &01xx for function/edit keys
ADVALOK1 RTS
ADVALNONE LDX #$00 ; Input, just return 0
ADVALNONE LDX #$00 ; Input, just return 0
RTS
ADVALBUF INX
BEQ :ADVALKBD ; Fake keyboard buffer
BEQ :ADVALKBD ; Fake keyboard buffer
INX
BEQ :ADVALOK ; Serial input, return 0
LDX #$01 ; For outputs, return 1 char free
BEQ :ADVALOK ; Serial input, return 0
LDX #$01 ; For outputs, return 1 char free
RTS
:ADVALKBD BIT $C000 ; Test keyboard data/strobe
BPL :ADVALOK ; No Strobe, return 0
INX ; Strobe, return 1
:ADVALKBD BIT $C000 ; Test keyboard data/strobe
BPL :ADVALOK ; No Strobe, return 0
INX ; Strobe, return 1
:ADVALOK RTS
@ -62,21 +61,21 @@ ADVALBUF INX
* (8 * frequency )
* BEEPX EQU #57 ; note=C5
BEEPX EQU #116 ; note=C4
BEEPX EQU #116 ; note=C4
BEEP PHA
PHX
PHY
LDY #$00 ; duration
:L1 LDX #BEEPX ; 2cy pitch 2cy
LDY #$00 ; duration
:L1 LDX #BEEPX ; 2cy pitch 2cy
*------------------------------------------------------
:L2 DEX ; 2cy BEEPX * 2cy
BNE :L2 ; 3cy/2cy (BEEPX-1) * 3cy + 1 * 2cy
:L2 DEX ; 2cy BEEPX * 2cy
BNE :L2 ; 3cy/2cy (BEEPX-1) * 3cy + 1 * 2cy
*------------------------------------------------------
* BEEPX*5-1cy
LDA $C030 ; 4cy BEEPX*5+5
DEY ; 2cy BEEPX*5+7
BNE :L1 ; 3cy/2cy BEEPX*5+10
PLY ;
LDA $C030 ; 4cy BEEPX*5+5
DEY ; 2cy BEEPX*5+7
BNE :L1 ; 3cy/2cy BEEPX*5+10
PLY ;
PLX
PLA
RTS
@ -86,9 +85,9 @@ BEEP PHA
OUTSTR TXA
* Print string pointed to by A,Y to the screen
PRSTR STA OSTEXT+0 ; String in A,Y
PRSTR STA OSTEXT+0 ; String in A,Y
STY OSTEXT+1
:L1 LDA (OSTEXT) ; Ptr to string in OSTEXT
:L1 LDA (OSTEXT) ; Ptr to string in OSTEXT
BEQ PRSTROK
JSR OSASCI
INC OSTEXT
@ -107,7 +106,7 @@ FORCENL LDA #$86
* Print XY in hex
OUT2HEX TYA
JSR OUTHEX
TXA ; Continue into OUTHEX
TXA ; Continue into OUTHEX
* Print hex byte in A
OUTHEX PHA
@ -118,16 +117,16 @@ OUTHEX PHA
AND #$0F
JSR PRNIB
PLA
AND #$0F ; Continue into PRNIB
AND #$0F ; Continue into PRNIB
* Print hex nibble in A
PRNIB CMP #$0A
BCC :S1
CLC ; >= $0A
CLC ; >= $0A
ADC #'A'-$0A
JSR OSWRCH
RTS
:S1 ADC #'0' ; < $0A
:S1 ADC #'0' ; < $0A
JMP OSWRCH
* TEMP ENTRY *
@ -149,35 +148,35 @@ OSPAD EQU OSTEXT+4
* X=>four byte zero page locations
* Y= number of digits to pad to, 0 for no padding
*
PRINTDEC sty OSPAD ; Number of padding+digits
ldy #0 ; Digit counter
PRDECDIGIT lda #32 ; 32-bit divide
PRINTDEC sty OSPAD ; Number of padding+digits
ldy #0 ; Digit counter
PRDECDIGIT lda #32 ; 32-bit divide
sta OSTEMP
lda #0 ; Remainder=0
clv ; V=0 means div result = 0
PRDECDIV10 cmp #10/2 ; Calculate OSNUM/10
lda #0 ; Remainder=0
clv ; V=0 means div result = 0
PRDECDIV10 cmp #10/2 ; Calculate OSNUM/10
bcc PRDEC10
sbc #10/2+$80 ; Remove digit & set V=1 to show div result > 0
sec ; Shift 1 into div result
PRDEC10 rol 0,x ; Shift /10 result into OSNUM
sbc #10/2+$80 ; Remove digit & set V=1 to show div result > 0
sec ; Shift 1 into div result
PRDEC10 rol 0,x ; Shift /10 result into OSNUM
rol 1,x
rol 2,x
rol 3,x
rol a ; Shift bits of input into acc (input mod 10)
rol a ; Shift bits of input into acc (input mod 10)
dec OSTEMP
bne PRDECDIV10 ; Continue 32-bit divide
bne PRDECDIV10 ; Continue 32-bit divide
ora #48
pha ; Push low digit 0-9 to print
pha ; Push low digit 0-9 to print
iny
bvs PRDECDIGIT ; If V=1, result of /10 was > 0 & do next digit
bvs PRDECDIGIT ; If V=1, result of /10 was > 0 & do next digit
lda #32
PRDECLP1 cpy OSPAD
bcs PRDECLP2 ; Enough padding pushed
pha ; Push leading space characters
bcs PRDECLP2 ; Enough padding pushed
pha ; Push leading space characters
iny
bne PRDECLP1
PRDECLP2 pla ; Pop character left to right
jsr OSWRCH ; Print it
PRDECLP2 pla ; Pop character left to right
jsr OSWRCH ; Print it
dey
bne PRDECLP2
rts
@ -198,16 +197,16 @@ PRDECLP2 pla ; Pop character left to right
* Very difficult to write this without it being a direct clone
* from the BBC MOS. ;)
*
GSINTGO ROR GSFLAG ; CY initially into bit 7
JSR SKIPSPC ; Skip any spaces
INY ; Step past in case it's a quote
CMP #$22 ; Is it a quote?
GSINTGO ROR GSFLAG ; CY initially into bit 7
JSR SKIPSPC ; Skip any spaces
INY ; Step past in case it's a quote
CMP #$22 ; Is it a quote?
BEQ GSINTGO1
DEY ; Wasn't a quote, step back
CLC ; Prepare CC=no leading quote
GSINTGO1 ROR GSFLAG ; Rotate 'leading-quote' into flags
DEY ; Wasn't a quote, step back
CLC ; Prepare CC=no leading quote
GSINTGO1 ROR GSFLAG ; Rotate 'leading-quote' into flags
CMP #$0D
RTS ; Return EQ if end of line
RTS ; Return EQ if end of line
* GSFLAG set to:
* bit7: leading quote found
* bit6: CC=filename CS=*KEY
@ -250,13 +249,13 @@ GSINTGO1 ROR GSFLAG ; Rotate 'leading-quote' into flags
* INX:BNE loop
* done
*
GSRDGO LDA #$00 ; Prepare to clear accumulator
GSREADLP STA GSCHAR ; Update accumulator
LDA (OSLPTR),Y ; Get current character
CMP #$0D ; End of line?
BNE GSREAD2 ; No, check character
GSRDGO LDA #$00 ; Prepare to clear accumulator
GSREADLP STA GSCHAR ; Update accumulator
LDA (OSLPTR),Y ; Get current character
CMP #$0D ; End of line?
BNE GSREAD2 ; No, check character
BIT GSFLAG
BPL GSREADEND ; We aren't waiting for a closing quote
BPL GSREADEND ; We aren't waiting for a closing quote
* ; End of line before closing quote
ERRBADSTR BRK
DB $FD
@ -264,54 +263,54 @@ ERRBADSTR BRK
BRK
GSREAD2 CMP #' '
BCC ERRBADSTR ; Embedded control char
BNE GSREAD3 ; Not a space, process it
BIT GSFLAG ; Can space terminate string?
BMI GSREADCHAR ; We're waiting for a terminating quote
BCC ERRBADSTR ; Embedded control char
BNE GSREAD3 ; Not a space, process it
BIT GSFLAG ; Can space terminate string?
BMI GSREADCHAR ; We're waiting for a terminating quote
* ; so return the space character
BVC GSREADEND ; Space is a terminator, finish
GSREAD3 CMP #$22 ; Is it a quote?
BNE GSREADESC ; Not quote, check for escapes
BIT GSFLAG ; Was there an opening quote?
BPL GSREADCHAR ; Not waiting for a closing quote
INY ; Waiting for quote, check next character
BVC GSREADEND ; Space is a terminator, finish
GSREAD3 CMP #$22 ; Is it a quote?
BNE GSREADESC ; Not quote, check for escapes
BIT GSFLAG ; Was there an opening quote?
BPL GSREADCHAR ; Not waiting for a closing quote
INY ; Waiting for quote, check next character
LDA (OSLPTR),Y
CMP #$22 ; Is it another quote?
BEQ GSREADCHAR ; Quote-Quote, expand to single quote
CMP #$22 ; Is it another quote?
BEQ GSREADCHAR ; Quote-Quote, expand to single quote
* End of string
* Either closing quote, or a space seperator, or end of line
GSREADEND JSR SKIPSPC ; Skip any spaces to next word
SEC ; SEC=end of string
RTS ; and (OSLPTR),Y=>next word or end of line
GSREADEND JSR SKIPSPC ; Skip any spaces to next word
SEC ; SEC=end of string
RTS ; and (OSLPTR),Y=>next word or end of line
* CS=end of string
* EQ=end of line
* NE=not end of line, more words follow
GSREADESC CMP #$7C ; Is it '|' escape character
BNE GSREADCHAR ; No, return as character
INY ; Step to next character
GSREADESC CMP #$7C ; Is it '|' escape character
BNE GSREADCHAR ; No, return as character
INY ; Step to next character
LDA (OSLPTR),Y
CMP #$7C
BEQ GSREADCHAR ; bar-bar expands to bar
BEQ GSREADCHAR ; bar-bar expands to bar
CMP #$22
BEQ GSREADCHAR ; bar-quote expands to quote
CMP #'!' ; Is it bar-pling?
BNE GSREAD5 ; No, check for bar-letter
INY ; Step past it
LDA #$80 ; Set bit 7 in accumulator
BNE GSREADLP ; Loop back to check next character(s)
BEQ GSREADCHAR ; bar-quote expands to quote
CMP #'!' ; Is it bar-pling?
BNE GSREAD5 ; No, check for bar-letter
INY ; Step past it
LDA #$80 ; Set bit 7 in accumulator
BNE GSREADLP ; Loop back to check next character(s)
GSREAD5 CMP #'?' ; Check for '?'
BCC ERRBADSTR ; <'?', bad character
BEQ GSREADDEL ; bar-query -> DEL
AND #$1F ; Convert bar-letter to control code
BIT SETV ; SEV=control character
GSREAD5 CMP #'?' ; Check for '?'
BCC ERRBADSTR ; <'?', bad character
BEQ GSREADDEL ; bar-query -> DEL
AND #$1F ; Convert bar-letter to control code
BIT SETV ; SEV=control character
BVS GSREADOK
GSREADDEL LDA #$7F
GSREADCHAR CLV ; CLV=not control character
GSREADOK INY ; Step to next character
ORA GSCHAR ; Add in any bit 7 from |! prefix
CLC ; CLC=not end of string
GSREADCHAR CLV ; CLV=not control character
GSREADOK INY ; Step to next character
ORA GSCHAR ; Add in any bit 7 from |! prefix
CLC ; CLC=not end of string
RTS
* CC=not end of string
* VS=control character
@ -321,13 +320,13 @@ GSREADOK INY ; Step to next character
* Read a byte from sideways ROM
* On entry, Y=ROM to read from
* On exit, A=byte read, X=current ROM, Y=$00
RDROM LDA ROMID
PHA ; Save current ROM
RDROM LDA $F4
PHA ; Save current ROM
TYA
TAX ; X=ROM to read from
JSR ROMSELECT ; Page in the required ROM
TAX ; X=ROM to read from
JSR ROMSELECT ; Page in the required ROM
LDY #$00
LDA (ROMPTR),Y ; Read the byte
LDA ($F6),Y ; Read the byte
PLX
* Select a sideways ROM
@ -336,33 +335,106 @@ RDROM LDA ROMID
ROMSELECT
* Insert code here for faking sideways ROMs by loading or otherwise
* fetching code to $8000. All registers must be preserved.
PHP
CPX ROMID ; Speed up by checking if
BEQ ROMSELOK ; already paged in
:ROMSEL PHP
PHA
PHX
PHY
SEI
TXA ; A=ROM to select
TXA ; A=ROM to select
>>> XF2MAIN,SELECTROM
ROMSELDONE >>> ENTAUX
PLY
PLX
PLA
STX ROMID ; Set Current ROM number
ROMSELOK PLP
PLP
:ROMSELOK STX $F4 ; Set Current ROM number
RTS
ROMXX
* CPX $F8
* BEQ :ROMSELOK ; Already selected
*
** Insert code here for faking sideways ROMs by loading or otherwise
** fetching code to $8000. All registers must be preserved.
* CPX MAXROM
* BEQ :ROMSEL
* BCS :ROMSELOK ; Out of range, ignore
*:ROMSEL PHA
* PHX
* PHY
*
* LDA OSLPTR+0
* PHA
* LDA OSLPTR+1
* PHA
*
* TXA
* ASL A
* TAX
* LDA ROMTAB+0,X ; LSB of pointer to name
* STA OSFILECB+0
* LDA ROMTAB+1,X ; MSB of pointer to name
* STA OSFILECB+1
*
* LDX #<OSFILECB
* LDY #>OSFILECB
* LDA #$05 ; Means 'INFO'
* JSR OSFILE
* CMP #$01
* BNE :ROMNOTFND ; File not found
*
* STZ OSFILECB+2 ; Dest address $8000
* LDA #$80
* STA OSFILECB+3
* STZ OSFILECB+4
* STZ OSFILECB+5
* STZ OSFILECB+6 ; Load to specified address
* LDX #<OSFILECB
* LDY #>OSFILECB
* LDA #$FF ; Means 'LOAD'
* JSR OSFILE
*:ROMNOTFND
* PLA
* STA OSLPTR+1
* PLA
* STA OSLPTR+0
* PLY
* PLX
* PLA
* STX $F8 ; Set ROM loaded
*:ROMSELOK STX $F4 ; Set Current ROM number
EVENT RTS
*BASICROM ASC 'BASIC2.ROM'
* DB $0D,$00
*
*COMALROM ASC 'COMAL.ROM'
* DB $0D,$00
*
*LISPROM ASC 'LISP501.ROM'
* DB $0D,$00
*
*FORTHROM ASC 'FORTH103.ROM'
* DB $0D,$00
*
*PROLOGROM ASC 'MPROLOG310.ROM'
* DB $0D,$00
*
*BCPLROM ASC 'BCPL7.0.ROM'
* DB $0D,$00
*
*PASCROM1 ASC 'PASC.1.10.1.ROM'
* DB $0D,$00
*
*PASCROM2 ASC 'PASC.1.10.2.ROM'
* DB $0D,$00
*
* Initialize ROMTAB according to user selection in menu
ROMINIT STZ MAXROM ; One sideways ROM only
STA $C002 ; Read main mem
LDA USERSEL ; *TO DO* Should be actual number of ROMs
STA $C003 ; Read aux mem
ROMINIT STZ MAXROM ; One sideways ROM only
STA $C002 ; Read main mem
LDA USERSEL
STA $C003 ; Read aux mem
CMP #6
BNE :X1
@ -372,13 +444,112 @@ ROMINIT STZ MAXROM ; One sideways ROM only
STA MAXROM
:X2 RTS
* ASL ; x2
* CLC
* ADC #<ROMS
* STA OSLPTR+0
* LDA #>ROMS
* ADC #$00
* STA OSLPTR+1
* LDY #$00
* LDA (OSLPTR),Y
* STA ROMTAB+0
* INY
* LDA (OSLPTR),Y
* STA ROMTAB+1
* STA $C002 ; Read main mem
* LDA USERSEL
* STA $C003 ; Read aux mem
* CMP #6 ; Menu entry 7 has two ROMs
* BNE :S1
* LDA #<PASCROM2
* STA ROMTAB+2
* LDA #>PASCROM2
* STA ROMTAB+3
* INC MAXROM ; Two ROMs
* BRA :DONE
*:S1 CMP #7 ; Menu entry 8
* BNE :DONE
* LDA #<PASCROM1
* STA ROMTAB+0
* LDA #>PASCROM1
* STA ROMTAB+1
* LDA #<PASCROM2
* STA ROMTAB+2
* LDA #>PASCROM2
* STA ROMTAB+3
* LDA #<LISPROM
* STA ROMTAB+4
* LDA #>LISPROM
* STA ROMTAB+5
* LDA #<FORTHROM
* STA ROMTAB+6
* LDA #>FORTHROM
* STA ROMTAB+7
* LDA #<PROLOGROM
* STA ROMTAB+8
* LDA #>PROLOGROM
* STA ROMTAB+9
* LDA #<BCPLROM
* STA ROMTAB+10
* LDA #>BCPLROM
* STA ROMTAB+11
* LDA #<COMALROM
* STA ROMTAB+12
* LDA #>COMALROM
* STA ROMTAB+13
* LDA #<BASICROM
* STA ROMTAB+14
* LDA #>BASICROM
* STA ROMTAB+15
* LDA #7 ; 8 sideways ROMs
* STA MAXROM
*:DONE LDA #$FF
* STA $F8 ; Force ROM to load
* RTS
*
** Active sideways ROMs
*ROMTAB DW $0000 ; ROM0
* DW $0000 ; ROM1
* DW $0000 ; ROM2
* DW $0000 ; ROM3
* DW $0000 ; ROM4
* DW $0000 ; ROM5
* DW $0000 ; ROM6
* DW $0000 ; ROM7
* DW $0000 ; ROM8
* DW $0000 ; ROM9
* DW $0000 ; ROMA
* DW $0000 ; ROMB
* DW $0000 ; ROMC
* DW $0000 ; ROMD
* DW $0000 ; ROME
* DW $0000 ; ROMF
*
** ROM filenames in same order as in the menu
** ROMMENU copies these to ROMTAB upon user selection
*ROMS DW BASICROM
* DW COMALROM
* DW LISPROM
* DW FORTHROM
* DW PROLOGROM
* DW BCPLROM
* DW PASCROM1
* DW PASCROM2
*EVENT LDA #<OSEVENM
* LDY #>OSEVENM
* JMP PRSTR
*OSEVENM ASC 'OSEVEN.'
* DB $00
**********************************************************
* Interrupt Handlers, MOS redirection vectors etc.
**********************************************************
* Invoked from GSBRK in main memory. On IIgs only.
GSBRKAUX >>> IENTAUX ; IENTAUX does not do CLI
GSBRKAUX >>> IENTAUX ; IENTAUX does not do CLI
* Continue into IRQBRKHDLR
* TO DO: Check, IENTAUX modifies X
@ -386,43 +557,56 @@ GSBRKAUX >>> IENTAUX ; IENTAUX does not do CLI
IRQBRKHDLR PHA
* Mustn't enable IRQs within the IRQ handler
* Do not use WRTMAIN/WRTAUX macros
STA $C004 ; Write to main memory
STA $45 ; $45=A for ProDOS IRQ handlers
STA $C005 ; Write to aux memory
BIT $C014 ; Set N if aux write active
STA $C004 ; Write to main memory
STA $45 ; $45=A for ProDOS IRQ handlers
BPL :S1 ; If aux write wasn't active, skip
STA $C005 ; Write to aux memory
:S1 LDA GSSPEED ; See if GS was set to 2.8MHz
CMP #$80
BNE :S2 ; Nope, continue slow
TSB $C036 ; GS: Enable 'fast' speed
TXA
:S2 TXA
PHA
CLD
TSX
LDA $103,X ; Get PSW from stack
PHX
INX
INX
INX
LDA $100,X ; Get PSW from stack
AND #$10
BEQ :IRQ ; IRQ
BEQ :IRQ ; IRQ
SEC
LDA $0104,X
INX
LDA $0100,X
SBC #$01
STA FAULT+0 ; FAULT=>error block after BRK
LDA $0105,X
STA FAULT+0 ; FAULT=>error block after BRK
INX
LDA $0100,X
SBC #$00
STA FAULT+1
LDA $F4 ; Get current ROM
STA BYTEVARBASE+$BA ; Set ROM at last BRK
STX OSXREG ; Pass stack pointer
LDA #$06 ; Service Call 6 = BRK occured
LDA $F4 ; Get current ROM
STA BYTEVARBASE+$BA ; Set ROM at last BRK
PLX
STX OSXREG ; Pass stack pointer
LDA #$06 ; Service Call 6 = BRK occured
JSR SERVICE
LDX BYTEVARBASE+$FC ; Get current language
JSR ROMSELECT ; Bring it into memory
LDX BYTEVARBASE+$FC ; Get current language
JSR ROMSELECT ; Bring it into memory
PLA
TAX
PLA
CLI
JMP (BRKV) ; Pass on to BRK handler
JMP (BRKV) ; Pass on to BRK handler
:IRQ >>> XF2MAIN,A2IRQ ; Bounce to Apple IRQ handler
:IRQ >>> XF2MAIN,A2IRQ ; Bounce to Apple IRQ handler
IRQBRKRET
>>> IENTAUX ; IENTAUX does not do CLI
PLA ; TODO: Pass on to IRQ1V
>>> IENTAUX ; IENTAUX does not do CLI
PLA ; TODO: Pass on to IRQ1V
TAX
PLA
NULLRTI RTI
@ -442,7 +626,7 @@ MOSBRKHDLR LDA #<MSGBRK
JSR PRERR
JSR OSNEWL
JSR OSNEWL
STOP JMP STOP ; Cannot return from a BRK
STOP JMP STOP ; Cannot return from a BRK
MSGBRK DB $0D
ASC 'ERROR: '
@ -450,33 +634,33 @@ MSGBRK DB $0D
* Default page 2 contents
DEFVEC DW NULLRTS ; $200 USERV
DW MOSBRKHDLR ; $202 BRKV
DW NULLRTI ; $204 IRQ1V
DW NULLRTI ; $206 IRQ2V
DW CLIHND ; $208 CLIV
DW BYTEHND ; $20A BYTEV
DW WORDHND ; $20C WORDV
DW WRCHHND ; $20E WRCHV
DW RDCHHND ; $210 RDCHV
DW FILEHND ; $212 FILEV
DW ARGSHND ; $214 ARGSV
DW BGETHND ; $216 BGETV
DW BPUTHND ; $218 BPUTV
DW GBPBHND ; $21A GBPBV
DW FINDHND ; $21C FINDV
DW FSCHND ; $21E FSCV
DW NULLRTS ; $220 EVENTV
DW NULLRTS ; $222
DW NULLRTS ; $224
DW NULLRTS ; $226
DW NULLRTS ; $228
DW NULLRTS ; $22A
DW NULLRTS ; $22C
DW NULLRTS ; $22E
DW NULLRTS ; $230 SPARE1V
DW NULLRTS ; $232 SPARE2V
DW NULLRTS ; $234 SPARE3V
DEFVEC DW NULLRTS ; $200 USERV
DW MOSBRKHDLR ; $202 BRKV
DW NULLRTI ; $204 IRQ1V
DW NULLRTI ; $206 IRQ2V
DW CLIHND ; $208 CLIV
DW BYTEHND ; $20A BYTEV
DW WORDHND ; $20C WORDV
DW WRCHHND ; $20E WRCHV
DW RDCHHND ; $210 RDCHV
DW FILEHND ; $212 FILEV
DW ARGSHND ; $214 ARGSV
DW BGETHND ; $216 BGETV
DW BPUTHND ; $218 BPUTV
DW GBPBHND ; $21A GBPBV
DW FINDHND ; $21C FINDV
DW FSCHND ; $21E FSCV
DW NULLRTS ; $220 EVENTV
DW NULLRTS ; $222
DW NULLRTS ; $224
DW NULLRTS ; $226
DW NULLRTS ; $228
DW NULLRTS ; $22A
DW NULLRTS ; $22C
DW NULLRTS ; $22E
DW NULLRTS ; $230 SPARE1V
DW NULLRTS ; $232 SPARE2V
DW NULLRTS ; $234 SPARE3V
ENDVEC
*
@ -492,53 +676,53 @@ MOSAPI EQU $FF95
* OPTIONAL ENTRIES
* ----------------
OSSERV JMP SERVICE ; FF95 OSSERV
OSCOLD JMP NULLRTS ; FF98 OSCOLD
OSPRSTR JMP OUTSTR ; FF9B OSPRSTR
OSSCANDEC JMP SCANDEC ; FF9E SCANDEC
OSSCANHEX JMP SCANHEX ; FFA1 SCANHEX
OSFFA4 JMP NULLRTS ; FFA4 (DISKACC)
OSFFA7 JMP NULLRTS ; FFA7 (DISKCCP)
PRHEX JMP OUTHEX ; FFAA PRHEX
PR2HEX JMP OUT2HEX ; FFAD PR2HEX
OSFFB0 JMP PRINTDEC ; FFB0 (USERINT)
OSWRRM JMP NULLRTS ; FFB3 OSWRRM
OSSERV JMP SERVICE ; FF95 OSSERV
OSCOLD JMP NULLRTS ; FF98 OSCOLD
OSPRSTR JMP OUTSTR ; FF9B OSPRSTR
OSSCANDEC JMP SCANDEC ; FF9E SCANDEC
OSSCANHEX JMP SCANHEX ; FFA1 SCANHEX
OSFFA4 JMP NULLRTS ; FFA4 (DISKACC)
OSFFA7 JMP NULLRTS ; FFA7 (DISKCCP)
PRHEX JMP OUTHEX ; FFAA PRHEX
PR2HEX JMP OUT2HEX ; FFAD PR2HEX
OSFFB0 JMP PRINTDEC ; FFB0 (USERINT)
OSWRRM JMP NULLRTS ; FFB3 OSWRRM
* COMPULSARY ENTRIES
* ------------------
VECSIZE DB ENDVEC-DEFVEC ; FFB6 VECSIZE Size of vectors
VECBASE DW DEFVEC ; FFB7 VECBASE Base of default vectors
OSRDRM JMP RDROM ; FFB9 OSRDRM Read byte from paged ROM
OSCHROUT JMP OUTCHAR ; FFBC CHROUT Send char to VDU driver
OSEVEN JMP EVENT ; FFBF OSEVEN Signal an event
GSINIT JMP GSINTGO ; FFC2 GSINIT Init string reading
GSREAD JMP GSRDGO ; FFC5 GSREAD Parse general string
NVWRCH JMP WRCHHND ; FFC8 NVWRCH Nonvectored WRCH
NVRDCH JMP RDCHHND ; FFCB NVRDCH Nonvectored RDCH
OSFIND JMP (FINDV) ; FFCE OSFIND
OSGBPB JMP (GBPBV) ; FFD1 OSGBPB
OSBPUT JMP (BPUTV) ; FFD4 OSBPUT
OSBGET JMP (BGETV) ; FFD7 OSBGET
OSARGS JMP (ARGSV) ; FFDA OSARGS
OSFILE JMP (FILEV) ; FFDD OSFILE
OSRDCH JMP (RDCHV) ; FFE0 OSRDCH
OSASCI CMP #$0D ; FFE3 OSASCI
VECSIZE DB ENDVEC-DEFVEC ; FFB6 VECSIZE Size of vectors
VECBASE DW DEFVEC ; FFB7 VECBASE Base of default vectors
OSRDRM JMP RDROM ; FFB9 OSRDRM Read byte from paged ROM
OSCHROUT JMP OUTCHAR ; FFBC CHROUT Send char to VDU driver
OSEVEN JMP EVENT ; FFBF OSEVEN Signal an event
GSINIT JMP GSINTGO ; FFC2 GSINIT Init string reading
GSREAD JMP GSRDGO ; FFC5 GSREAD Parse general string
NVWRCH JMP WRCHHND ; FFC8 NVWRCH Nonvectored WRCH
NVRDCH JMP RDCHHND ; FFCB NVRDCH Nonvectored RDCH
OSFIND JMP (FINDV) ; FFCE OSFIND
OSGBPB JMP (GBPBV) ; FFD1 OSGBPB
OSBPUT JMP (BPUTV) ; FFD4 OSBPUT
OSBGET JMP (BGETV) ; FFD7 OSBGET
OSARGS JMP (ARGSV) ; FFDA OSARGS
OSFILE JMP (FILEV) ; FFDD OSFILE
OSRDCH JMP (RDCHV) ; FFE0 OSRDCH
OSASCI CMP #$0D ; FFE3 OSASCI
BNE OSWRCH
OSNEWL LDA #$0A ; FFE7 OSNEWL
OSNEWL LDA #$0A ; FFE7 OSNEWL
JSR OSWRCH
OSWRCR LDA #$0D ; FFEC OSWRCR
OSWRCH JMP (WRCHV) ; FFEE OSWRCH
OSWORD JMP (WORDV) ; FFF1 OSWORD
OSBYTE JMP (BYTEV) ; FFF4 OSBYTE
OSCLI JMP (CLIV) ; FFF7 OSCLI
NMIVEC DW NULLRTI ; FFFA NMIVEC
RSTVEC DW STOP ; FFFC RSTVEC
OSWRCR LDA #$0D ; FFEC OSWRCR
OSWRCH JMP (WRCHV) ; FFEE OSWRCH
OSWORD JMP (WORDV) ; FFF1 OSWORD
OSBYTE JMP (BYTEV) ; FFF4 OSBYTE
OSCLI JMP (CLIV) ; FFF7 OSCLI
NMIVEC DW NULLRTI ; FFFA NMIVEC
RSTVEC DW STOP ; FFFC RSTVEC
IRQVEC
* Assembler doesn't like running up to $FFFF, so we bodge a bit
MOSEND
ORG MOSEND-MOSAPI+MOSVEC
DW IRQBRKHDLR ; FFFE IRQVEC
DW IRQBRKHDLR ; FFFE IRQVEC
MOSVEND
* Buffer for one 512 byte disk block in aux mem
@ -547,3 +731,7 @@ AUXBLK ASC '**ENDOFCODE**'

View File

@ -10,15 +10,11 @@
* 12-Sep-2021 *HELP uses subject lookup, *HELP MOS, *HELP HOSTFS.
* 25-Oct-2021 Implemented *BASIC.
* 07-Oct-2022 *CLOSE is a host command, fixed *EXEC.
* 08-Oct-2022 Rewrote *TYPE, *DUMP, *SPOOL, shares code with *EXEC.
* COMMAND TABLE
***************
* Table structure is: { string, byte OR $80, destword-1 } $00
* Commands are entered with A=command byte with b7=1
* if b6=1 (LPTR),Y=>parameters
* if b6=0 XY=>parameters
* fsc commands
CMDTABLE ASC 'CAT' ; Must be first command so matches '*.'
DB $85
@ -83,19 +79,19 @@ CMDTABLE ASC 'CAT' ; Must be first command so matches '*.'
* filing utilities
ASC 'TYPE'
DB $80
DW CMDTYPE-1 ; TYPE -> (LPTR)=>params
DW TYPE-1 ; TYPE -> (LPTR)=>params
ASC 'DUMP'
DB $80
DW CMDDUMP-1 ; DUMP -> (LPTR)=>params
DW DUMP-1 ; DUMP -> (LPTR)=>params
ASC 'SPOOL'
DB $80
DW CMDSPOOL-1 ; SPOOL -> (LPTR)=>params
DW SPOOL-1 ; SPOOL -> (LPTR)=>params
ASC 'EXEC'
DB $80
DW CMDEXEC-1 ; EXEC -> (LPTR)=>params
DW EXEC-1 ; EXEC -> (LPTR)=>params
ASC 'CLOSE'
DB $80
DW CMDCLOSE-1 ; CLOSE -> (LPTR)=>params
DW STARCLOSE-1 ; CLOSE -> (LPTR)=>params
* BUILD <file>
* terminator
DB $FF
@ -170,8 +166,8 @@ CLIMATCH3 JSR SKIPSPC ; (OSLPTR),Y=>parameters
PHA ; Push address low
TXA ; Command byte
PHA
ASL A ; Move bit 6 into bit 7
BEQ CLICALL ; If $80-&BF don't convert LPTR
ASL A ; Drop bit 7
BEQ CLICALL ; If $80 don't convert LPTR
JSR LPTRtoXY ; XY=>parameters
CLICALL PLA ; A=command parameter
RTS ; Call command routine
@ -375,7 +371,7 @@ LPTRtoXY CLC
XYtoLPTR STX OSLPTR+0
STY OSLPTR+1
LDY #0
STARHELP9 RTS
RTS
* Print *HELP text
STARHELP JSR XYtoLPTR ; (OSLPTR),Y=>parameters
@ -383,9 +379,8 @@ STARHELP JSR XYtoLPTR ; (OSLPTR),Y=>parameters
LDX #<HLPTABLE ; XY=>command table
LDY #>HLPTABLE
JSR CLILOOKUP ; Look for *HELP subject
BEQ STARHELP9 ; Matched
LDA $8006 ; Does ROM have service entry?
BMI STARHELP6 ; Yes, skip to send service call
BMI STARHELP6 ; Yes, send service call
JSR OSNEWL
LDA #$09 ; Language name
LDY #$80 ; *TO DO* make this and BYTE8E
@ -538,179 +533,236 @@ ECHOLP1 JSR GSREAD
JMP ECHOLP1
* FILING UTILITIES
* ================
******************
* *CLOSE
********
CMDCLOSE LDA #$00
STARCLOSE LDA #$00
TAY
JSR OSFIND ; Close all files
STA FXEXEC ; Ensure Spool/Exec handles cleared
STA FXEXEC ; Clear Spool/Exec handles
STA FXSPOOL
RTS
* *TYPE <afsp>
**************
* Handle *TYPE command
* LPTR=>parameters string
*
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
TYPE JSR LPTRtoXY
PHX
PHY
JSR XYtoLPTR
JSR PARSLPTR ; Just for error handling
BEQ :SYNTAX ; No filename
PLY
PLX
LDA #$40 ; Open for input
JSR OSFIND ; Try to open file
CMP #$00 ; Was file opened?
BEQ :NOTFOUND
TAY ; File handle in Y
:L1 JSR BGETHND ; Read a byte
BCS :CLOSE ; EOF
CMP #$0A ; Don't print LF
BEQ :S1
JSR OSASCI ; Print the character
:S1 LDA ESCFLAG
BMI :ESC
BRA :L1
:CLOSE LDA #$00
JSR OSFIND ; Close file
:DONE RTS
:SYNTAX BRK
DB $DC
ASC 'Syntax: TYPE <*objspec*>'
BRK
:NOTFOUND BRK
DB $D6
ASC 'Not found'
BRK
:ESC LDA #$00 ; Close file
JSR OSFIND
BRK
DB $11
ASC 'Escape'
BRK
TYPDMPEND CPX #$0D
BEQ TYPCLOSE
JSR OSNEWL
TYPCLOSE LDA #$00
JMP OSFIND ; Close file
ERRTYPE BRK
DB $DC
ASC 'Syntax: TYPE <afsp>'
BRK
* Handle *DUMP command
* LPTR=>parameters string
*
CMDDUMP
LDA (OSLPTR),Y ; TEMP
CMP #$0D ; TEMP
BEQ :ERRDUMP ; No filename
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
LDX OSNUM+0 ; Print file offset
LDY OSNUM+1
JSR PR2HEX
JSR PRSPACE
PLY ; Get handle back
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
INX
DEC OSNUM+2
BNE :LOOP2 ; Loop to do 8 bytes
CLC ; CLC=Not EOF
BCC :DUMPCHRS ; Jump to display characters
:DUMPEOF LDA #$2A ; EOF met, pad with '**'
JSR OSWRCH
JSR OSWRCH
JSR PRSPACE
LDA #$00
STA $0101,X
INX
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
CMP #$7F
BEQ :DUMPDOT
CMP #$20
BCS :DUMPCHR
:DUMPDOT LDA #$2E
:DUMPCHR JSR OSWRCH ; Print character
INC OSNUM+0 ; Increment offset
BNE :DUMPNXT
INC OSNUM+1
:DUMPNXT PLP ; Get EOF flag back
DUMP JSR LPTRtoXY
PHX
PHY
JSR XYtoLPTR
JSR PARSLPTR ; Just for error handling
BEQ :SYNTAX ; No filename
PLY
PLX
LDA #$40 ; Open for input
JSR OSFIND ; Try to open file
CMP #$00 ; Was file opened?
BEQ :NOTFOUND
TAY ; File handle in Y
STZ DUMPOFF
STZ DUMPOFF+1
:L1 JSR BGETHND ; Read a byte
BCS :CLOSE ; EOF
PHA
LDA DUMPOFF+0
AND #$07
BNE :INC
LDA DUMPOFF+1 ; Print file offset
JSR PRHEXBYTE
LDA DUMPOFF+0
JSR PRHEXBYTE
LDA #' '
JSR OSASCI
LDX #$07
LDA #' ' ; Clear ASCII buffer
:L2 STA DUMPASCI,X
DEX
BNE :LOOP4 ; Loop to do 8 bytes
PHP
JSR OSNEWL
PLP
BCC :LOOP1
JMP TYPCLOSE ; Close and finish
:ERRDUMP BRK
BNE :L2
:INC INC DUMPOFF+0 ; Increment file offset
BNE :S1
INC DUMPOFF+1
:S1 PLA
STA DUMPASCI,X
JSR PRHEXBYTE
INX
LDA #' '
JSR OSASCI
CPX #$08 ; If EOL ..
BNE :S2
JSR PRCHARS ; Print ASCII representation
:S2 LDA ESCFLAG
BMI :ESC
BRA :L1
:CLOSE JSR PRCHARS ; Print ASCII representation
LDA #$00
JSR OSFIND ; Close file
:DONE RTS
:SYNTAX BRK
DB $DC
ASC 'Syntax: DUMP <afsp>'
ASC 'Syntax: DUMP <*objspec*>'
BRK
:NOTFOUND BRK
DB $D6
ASC 'Not found'
BRK
:ESC LDA #$00 ; Close file
JSR OSFIND
BRK
DB $11
ASC 'Escape'
BRK
DUMPOFF DW $0000
DUMPASCI DS 8
* Print byte in A in hex format
PRHEXBYTE PHA
LSR A
LSR A
LSR A
LSR A
JSR PRHEXNIB
PLA
JSR PRHEXNIB
RTS
* Print nibble in A in hex format
PRHEXNIB AND #$0F
CMP #10
BPL :LETTER
CLC
ADC #'0'
BRA :PRINT
:LETTER CLC
ADC #'A'-10
:PRINT JSR OSASCI
RTS
* Print ASCII char buffer
* with non-printing chars shown as '.'
PRCHARS CPX #$00
BEQ :DONE
CPX #$08 ; Pad final line
BEQ :S0
LDA #' '
JSR OSASCI
JSR OSASCI
JSR OSASCI
INX
BRA PRCHARS
:S0 LDX #$00
:L2 LDA DUMPASCI,X
CMP #$20
BMI :NOTPRINT
CMP #$7F
BPL :NOTPRINT
JSR OSASCI
:S1 INX
CPX #$08
BNE :L2
JSR OSNEWL
LDX #$00
:DONE RTS
:NOTPRINT LDA #'.'
JSR OSASCI
BRA :S1
* Handle *SPOOL command
* LPTR=>parameters string
*
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
SPOOL JSR LPTRtoXY
PHX
PHY
JSR XYtoLPTR
JSR PARSLPTR ; Just for error handling
BEQ :CLOSE ; No filename - stop spooling
LDY FXSPOOL ; Already spooling?
BEQ :OPEN
LDA #$00 ; If so, close file
JSR OSFIND
:OPEN PLY
PLX
LDA #$80 ; Open for writing
JSR OSFIND ; Try to open file
STA FXSPOOL ; Store SPOOL file handle
RTS
:CLOSE PLY ; Clean up stack
PLX
LDY FXSPOOL
BEQ :DONE
LDA #$00
JSR OSFIND ; Close file
STZ FXSPOOL
:DONE RTS
* Handle *EXEC command
* LPTR=>parameters string
*
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
EXECNOTFND LDA #$46
JMP MKERROR ; File not found
EXEC PHY
LDY FXEXEC
BEQ :EXEC1
LDA #$00
STA FXEXEC
JSR OSFIND ; If Exec open, close it
:EXEC1 PLY
LDA (OSLPTR),Y
CMP #$0D
BEQ :DONE ; No filename, all done
JSR LPTRtoXY ; XY=>filename
LDA #$40 ; Open for input
JSR OSFIND ; Try to open file
TAY ; Was file opened?
BEQ :NOTFOUND
STA FXEXEC ; Store EXEC file handle
:DONE RTS
:NOTFOUND BRK
DB $D6
ASC 'Not found'
BRK
*
* Handle *FAST command
@ -772,3 +824,9 @@ LOCKZIP LDA #$A5
STA $C05A
RTS

View File

@ -6,7 +6,7 @@
# SOUND statements.
#
base=123.47
base=123.47 / 10.0
print("\nFREQHIGH");
for i in range(0,256):