diff --git a/auxmem.init.s b/auxmem.init.s index ddce13d..3f0efcd 100644 --- a/auxmem.init.s +++ b/auxmem.init.s @@ -7,18 +7,18 @@ * BBC Micro 'virtual machine' in Apple //e aux memory *********************************************************** -MAXROM EQU $F9 ; Max sideways ROM number +MAXROM EQU $F9 ; Max sideways ROM number -ZP1 EQU $90 ; $90-$9f are spare Econet space - ; so safe to use +ZP1 EQU $90 ; $90-$9f are spare Econet space + ; so safe to use ZP2 EQU $92 ZP3 EQU $94 -STRTBCKL EQU $9D ; *TO DO* don't need to preserve +STRTBCKL EQU $9D ; *TO DO* No longer needed to preserve STRTBCKH EQU $9E MOSSHIM - ORG AUXMOS ; MOS shim implementation + ORG AUXMOS ; MOS shim implementation * * Shim code to service Acorn MOS entry points using @@ -28,8 +28,8 @@ MOSSHIM * * Initially executing at $3000 until copied to $D000 -MOSINIT SEI ; Disable IRQ while initializing - LDX #$FF ; Initialize Alt SP to $1FF +MOSINIT SEI ; Ensure IRQs disabled + LDX #$FF ; Initialize Alt SP to $1FF TXS STA WRCARDRAM ; Make sure we are writing aux @@ -105,11 +105,11 @@ MOSINIT SEI ; Disable IRQ while initializing :NORELOC :S8 STA SET80VID ; 80 col on - STA CLRALTCHAR ; Alt charset off (?) + STA CLRALTCHAR ; Alt charset off STA PAGE2 ; PAGE2 JMP MOSHIGH ; Ensure executing in high memory here -MOSHIGH SEI ; Disable IRQ while initializing +MOSHIGH SEI ; Ensure IRQs disabled LDX #$FF TXS ; Initialise stack INX ; X=$00 @@ -137,70 +137,70 @@ MOSHIGH SEI ; Disable IRQ while initializing LDA #7 JSR OSWRCH JSR OSNEWL - LDX MAXROM ; TEMP X=language to enter + LDX MAXROM ; *TEMP* X=language to enter CLC * OSBYTE $8E - Enter language ROM +********************************* * X=ROM number to select * -BYTE8E PHP ; Save CLC=RESET, SEC=Not RESET - JSR ROMSELECT ; Bring ROM X into memory - STX BYTEVARBASE+$FC ; Set current language ROM +BYTE8E PHP ; Save CLC=RESET, SEC=Not RESET + JSR ROMSELECT ; Bring ROM X into memory + STX BYTEVARBASE+$FC ; Set current language ROM LDA #$00 STA FAULT+0 LDA #$80 STA FAULT+1 LDY #$09 - JSR PRERRLP ; Print ROM name with PRERR to set - STY FAULT+0 ; FAULT pointing to version string + JSR PRERRLP ; Print ROM name with PRERR to set + STY FAULT+0 ; FAULT pointing to version string JSR OSNEWL JSR OSNEWL - PLP ; Get entry type back - LDA #$01 + PLP ; Get entry type back + LDA #$01 ; $01=Entering code with a header JMP ROMAUXADDR + * OSBYTE $8F - Issue service call +********************************* * X=service call, Y=parameter * -SERVICE TAX ; Enter here with A=Service Num +SERVICE TAX ; Enter here with A=Service Num BYTE8F SERVICEX LDA $F4 - PHA ; Save current ROM - -* LDA $E0 ; *DEBUG* -* AND #$20 -* BEQ :SERVDEBUG -* TXA -* JSR PRHEX -* LDA OSLPTR+1 -* JSR PRHEX -* LDA OSLPTR+0 -* JSR PRHEX ; *DEBUG* -*:SERVDEBUG + PHA ; Save current ROM +*DEBUG + LDA $E0 + AND #$20 ; Test debug *OPT255,32 + BEQ :SERVDEBUG + CPX #$06 + BEQ :SERVDONE ; If debug on, ignore SERV06 +:SERVDEBUG +*DEBUG TXA - LDX MAXROM ; Start at highest ROM -:SERVLP JSR ROMSELECT ; Bring it into memory + LDX MAXROM ; Start at highest ROM +:SERVLP JSR ROMSELECT ; Bring it into memory BIT $8006 - BPL :SERVSKIP ; No service entry - JSR $8003 ; Call service entry + BPL :SERVSKIP ; No service entry + JSR $8003 ; Call service entry TAX BEQ :SERVDONE -:SERVSKIP LDX $F4 ; Restore X=current ROM - DEX ; Step down to next - BPL :SERVLP ; Loop until ROM 0 done -:SERVDONE PLA ; Get caller's ROM back - PHX ; Save return from service call +:SERVSKIP LDX $F4 ; Restore X=current ROM + DEX ; Step down to next + BPL :SERVLP ; Loop until ROM 0 done +:SERVDONE PLA ; Get caller's ROM back + PHX ; Save return from service call TAX - JSR ROMSELECT ; Restore caller's ROM - PLX ; Get return value back - TXA ; Return in A and X and set EQ/NE + JSR ROMSELECT ; Restore caller's ROM + PLX ; Get return value back + TXA ; Return in A and X and set EQ/NE RTS -PRHELLO LDA #HELLO - JSR PRSTR + JSR OSPRSTR JMP OSNEWL BYTE00XX @@ -211,12 +211,6 @@ BYTE00A BRK DB $F7 HELLO ASC 'Applecorn MOS 2022-10-15' DB $00 ; Unify MOS messages +* TO DO: Move into RAM GSSPEED DB $00 ; $80 if GS is fast, $00 for slow - - - - - - - diff --git a/auxmem.misc.s b/auxmem.misc.s index b9bbce7..8f56a14 100644 --- a/auxmem.misc.s +++ b/auxmem.misc.s @@ -9,7 +9,7 @@ * 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. +* 08-Oct-2022 ROMSEL doesn't call loader if already paged in. * OSBYTE $80 - ADVAL @@ -35,18 +35,14 @@ ADVALBUF INX BEQ :ADVALOK ; Serial input, return 0 LDX #$01 ; For outputs, return 1 char free RTS -:ADVALKBD BIT KEYBOARD ; Test keyboard data/strobe +:ADVALKBD BIT KBDDATA ; Test keyboard data/strobe BPL :ADVALOK ; No Strobe, return 0 INX ; Strobe, return 1 :ADVALOK RTS -****************** -* Helper functions -****************** - * Beep -* +****** * Sound measurement shows the tone formula is: * 1.230 MHz * ------------- = cycles @@ -61,7 +57,7 @@ ADVALBUF INX * (------------- - 10 ) / 5 * (8 * frequency ) -* BEEPX EQU #57 ; note=C5 +* BEEPX EQU #57 ; note=C5 BEEPX EQU #116 ; note=C4 BEEP PHA PHX @@ -79,23 +75,26 @@ BEEP PHA PLY ; PLX PLA - RTS +PRSTROK RTS -* Print string pointed to by X,Y to the screen +* OSPRSTR - Print string at XY +****************************** +* On exit, X,Y preserved, A=$00 OUTSTR TXA * Print string pointed to by A,Y to the screen PRSTR STA OSTEXT+0 ; String in A,Y STY OSTEXT+1 :L1 LDA (OSTEXT) ; Ptr to string in OSTEXT - BEQ PRSTROK - JSR OSASCI + PHP ; Save EQ INC OSTEXT - BNE :L1 + BNE :L2 INC OSTEXT+1 +:L2 PLP ; Get EQ back + BEQ PRSTROK ; End of string + JSR OSASCI BRA :L1 -PRSTROK RTS * Print NL if not already at column 0 FORCENL LDA #$86 @@ -104,12 +103,14 @@ FORCENL LDA #$86 BEQ PRSTROK JMP OSNEWL -* Print XY in hex +* OSPR2HEX - Print XY in hex +**************************** OUT2HEX TYA JSR OUTHEX TXA ; Continue into OUTHEX -* Print hex byte in A +* OSPR1HEX - Print hex byte in A +******************************** OUTHEX PHA LSR LSR @@ -130,19 +131,8 @@ PRNIB CMP #$0A :S1 ADC #'0' ; < $0A JMP OSWRCH -* TEMP ENTRY * -* Print 16-bit value in XY in decimal -OSNUM EQU OSTEXT+0 -OSPAD EQU OSTEXT+4 -*PRDECXY -*PRDECPAD STX OSNUM+0 -* STY OSNUM+1 -* STZ OSNUM+2 -* STZ OSNUM+3 -*:PRDEC16 LDY #$05 ; 5 digits -* LDX #OSNUM ; number stored in OSNUM - -* Print up to 32-bit decimal number +* OSPRDEC - Print up to 32-bit decimal number +********************************************* * See forum.6502.org/viewtopic.php?f=2&t=4894 * and groups.google.com/g/comp.sys.apple2/c/_y27d_TxDHA * @@ -318,27 +308,31 @@ GSREADOK INY ; Step to next character * VC=not control character -* Read a byte from sideways ROM +* OSRDROM - Read a byte from sideways ROM +***************************************** * On entry, Y=ROM to read from +* (ROMPTR)=>byte to read * On exit, A=byte read, X=current ROM, Y=$00 RDROM LDA ROMID PHA ; Save current ROM TYA TAX ; X=ROM to read from JSR ROMSELECT ; Page in the required ROM - LDY #$00 + LDY #$00 ; NOTE BBC sets Y=0, Master preserves LDA (ROMPTR),Y ; Read the byte PLX -* Select a sideways ROM -* X=ROM to select -* All registers must be preserved +* ROMSELECT - Select a sideways ROM +*********************************** +* On entry, X=ROM to select +* On exit, All registers must be preserved +* 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 + BEQ ROMSELOK ; already paged in * BUG: This needs ROMID an invalid value on startup so first access works PHA PHX @@ -354,11 +348,6 @@ ROMSELDONE >>> ENTAUX ROMSELOK PLP RTS - - -EVENT RTS - - * Initialize ROMTAB according to user selection in menu ROMINIT STZ MAXROM ; One sideways ROM only STA RDMAINRAM ; Read main mem @@ -371,7 +360,12 @@ ROMINIT STZ MAXROM ; One sideways ROM only :X1 CMP #7 BNE :X2 STA MAXROM -:X2 RTS +:X2 LDA #$FF + STA ROMID ; Ensure set to invalid value + RTS + + +EVENT RTS ********************************************************** @@ -384,6 +378,7 @@ GSBRKAUX >>> IENTAUX ; IENTAUX does not do CLI * TO DO: Check, IENTAUX modifies X * IRQ/BRK handler +***************** IRQBRKHDLR PHA * Mustn't enable IRQs within the IRQ handler * Do not use WRTMAIN/WRTAUX macros @@ -428,6 +423,20 @@ IRQBRKRET PLA NULLRTI RTI +* Default BRK handler +********************* +MOSBRKHDLR LDX #MSGBRK + JSR OSPRSTR + JSR PRERR +* JSR OSNEWL +* JSR OSNEWL +STOP JMP STOP ; Cannot return from a BRK + +MSGBRK DB $0D + ASC 'ERROR: ' + DB $00 + PRERR LDY #$01 PRERRLP LDA (FAULT),Y BEQ PRERR1 @@ -437,20 +446,9 @@ PRERRLP LDA (FAULT),Y NULLRTS PRERR1 RTS -MOSBRKHDLR LDA #MSGBRK - JSR PRSTR - JSR PRERR - JSR OSNEWL - JSR OSNEWL -STOP JMP STOP ; Cannot return from a BRK - -MSGBRK DB $0D - ASC 'ERROR: ' - DB $00 - * Default page 2 contents +************************* DEFVEC DW NULLRTS ; $200 USERV DW MOSBRKHDLR ; $202 BRKV DW NULLRTI ; $204 IRQ1V @@ -500,7 +498,8 @@ 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 +PRHEX +PR1HEX JMP OUTHEX ; FFAA PRHEX PR2HEX JMP OUT2HEX ; FFAD PR2HEX OSFFB0 JMP PRINTDEC ; FFB0 (USERINT) OSWRRM JMP NULLRTS ; FFB3 OSWRRM @@ -544,8 +543,6 @@ MOSVEND * Buffer for one 512 byte disk block in aux mem AUXBLK -;ASC '**ENDOFCODE**' -; DS $200-13 - - +; ASC '**ENDOFCODE**' +; DS $200-13 diff --git a/auxmem.mosequ.s b/auxmem.mosequ.s index ff6cb49..1f939d8 100644 --- a/auxmem.mosequ.s +++ b/auxmem.mosequ.s @@ -17,34 +17,36 @@ * $EF-$FF MOS API workspace * DEBUG EQU $00 ; $00=*OPT 255 debug code removed -DEBUG EQU $E0 ; $E0=*OPT 255 debug code included -* ; $E1 -FSFLAG1 EQU $E2 ; $E2 -FSFLAG2 EQU $E3 ; $E3 HOSTFS *OPT settings -GSFLAG EQU $E4 ; $E4 GSREAD processing flags -GSCHAR EQU $E5 ; $E5 GSREAD accumulator -OSTEXT EQU $E6 ; $E6 => text string $E6 OSNUM+0 -MAXLEN EQU OSTEXT+2 ; $E8 $E8 OSNUM+2 -MINCHAR EQU OSTEXT+3 ; $E9 $E9 OSNUM+3 -MAXCHAR EQU OSTEXT+4 ; $EA $EA OSPAD -OSTEMP EQU $EB ; $EB $EB OSTEMP -OSKBD1 EQU $EC ; $EC kbd ws -OSKBD2 EQU OSKBD1+1 ; $ED kbd ws -OSKBD3 EQU OSKBD1+2 ; $EE kbd ws -OSAREG EQU $EF ; $EF A register -OSXREG EQU OSAREG+1 ; $F0 X register -OSYREG EQU OSXREG+1 ; $F1 Y register -OSCTRL EQU OSXREG ; $F0 (XY)=>control block -OSLPTR EQU $F2 ; $F2 => command line -ROMID EQU $F4 ; $F4 current ROM -ROMTMP EQU $F5 ; $F5 -ROMPTR EQU $F6 ; $F6 => -* ; $F8 *TEMP* pseudo-SROM settings -* ; $F9 *TEMP* pseudo-SROM settings -OSINTWS EQU $FA ; $FA IRQ ZP pointer, use when IRQs off -OSINTA EQU $FC ; $FC IRQ register A store -FAULT EQU $FD ; $FD Error message pointer -ESCFLAG EQU $FF ; $FF Escape status +DEBUG EQU $E0 ; $E0=*OPT 255 debug code included +* GSSPEED EQU $E1 ; $E1 **TEMP** +FSFLAG1 EQU $E2 ; $E2 +FSFLAG2 EQU $E3 ; $E3 HOSTFS *OPT settings +GSFLAG EQU $E4 ; $E4 GSREAD processing flags +GSCHAR EQU $E5 ; $E5 GSREAD accumulator +OSTEXT EQU $E6 ; $E6 => text string $E6 OSNUM+0 +MAXLEN EQU OSTEXT+2 ; $E8 $E8 OSNUM+2 +MINCHAR EQU OSTEXT+3 ; $E9 $E9 OSNUM+3 +MAXCHAR EQU OSTEXT+4 ; $EA $EA OSPAD +OSNUM EQU OSTEXT ; $E6 +OSPAD EQU OSNUM+4 ; $EA +OSTEMP EQU $EB ; $EB +OSKBD1 EQU $EC ; $EC kbd ws +OSKBD2 EQU OSKBD1+1 ; $ED kbd ws +OSKBD3 EQU OSKBD1+2 ; $EE kbd ws +OSAREG EQU $EF ; $EF A register +OSXREG EQU OSAREG+1 ; $F0 X register +OSYREG EQU OSXREG+1 ; $F1 Y register +OSCTRL EQU OSXREG ; $F0 (XY)=>control block +OSLPTR EQU $F2 ; $F2 => command line +ROMID EQU $F4 ; $F4 current ROM +ROMTMP EQU $F5 ; $F5 +ROMPTR EQU $F6 ; $F6 => ROM addresses +* ; $F8 pseudo-SROM settings +ROMMAX EQU $F9 ; $F9 pseudo-SROM settings: maximum ROM number +OSINTWS EQU $FA ; $FA IRQ ZP pointer, use when IRQs off +OSINTA EQU $FC ; $FC IRQ register A store +FAULT EQU $FD ; $FD Error message pointer +ESCFLAG EQU $FF ; $FF Escape status * $0200-$0235 Vectors @@ -52,31 +54,25 @@ ESCFLAG EQU $FF ; $FF Escape status * $0290-$02ED * $02EE-$02FF MOS control block -USERV EQU $200 ; USER vector -BRKV EQU $202 ; BRK vector -CLIV EQU $208 ; OSCLI vector -BYTEV EQU $20A ; OSBYTE vector -WORDV EQU $20C ; OSWORD vector -WRCHV EQU $20E ; OSWRCH vector -RDCHV EQU $210 ; OSRDCH vector -FILEV EQU $212 ; OSFILE vector -ARGSV EQU $214 ; OSARGS vector -BGETV EQU $216 ; OSBGET vector -BPUTV EQU $218 ; OSBPUT vector -GBPBV EQU $21A ; OSGBPB vector -FINDV EQU $21C ; OSFIND vector -FSCV EQU $21E ; FSCV misc file ops +USERV EQU $200 ; USER vector +BRKV EQU $202 ; BRK vector +CLIV EQU $208 ; OSCLI vector +BYTEV EQU $20A ; OSBYTE vector +WORDV EQU $20C ; OSWORD vector +WRCHV EQU $20E ; OSWRCH vector +RDCHV EQU $210 ; OSRDCH vector +FILEV EQU $212 ; OSFILE vector +ARGSV EQU $214 ; OSARGS vector +BGETV EQU $216 ; OSBGET vector +BPUTV EQU $218 ; OSBPUT vector +GBPBV EQU $21A ; OSGBPB vector +FINDV EQU $21C ; OSFIND vector +FSCV EQU $21E ; FSCV misc file ops -BYTEVARBASE EQU $190 ; Base of OSBYTE variables -OSFILECB EQU $2EE ; OSFILE control block -OSGBPBCB EQU OSFILECB+1 ; OSGBPB control block +BYTEVARBASE EQU $190 ; Base of OSBYTE variables +OSFILECB EQU $2EE ; OSFILE control block +OSGBPBCB EQU OSFILECB+1 ; OSGBPB control block * $0300-$03DF * $03E0-$03FF Used for interfacing with ProDOS XFER - - - - - - diff --git a/mainmem.audio.s b/mainmem.audio.s index 3a90441..5e5b674 100644 --- a/mainmem.audio.s +++ b/mainmem.audio.s @@ -176,9 +176,10 @@ MAININS >>> ENTMAIN * Remove value from buffer or examine buffer (API same as Acorn MOS REMV) +* NOTE OS1.20 has a bug in the EXAMINE path * On entry: X is buffer number, V=1 if only examination is requested -* On exit: If examination, A next byte, X preserved, Y=offset to next char -* If removal, A undef, X preserved, Y value of byte removed +* On exit: If examination, A next byte, X preserved, Y=next byte +* If removal, A undef, X preserved, Y=value of byte removed * If buffer already empty C=1, else C=0 REM PHP ; Save flags, turn off interrupts SEI @@ -201,6 +202,7 @@ REM PHP ; Save flags, turn off interrupts CLC ; Success RTS :EXAM PLA ; Char read from buffer + TAY ; BUGFIX: Omitted on OS1.20 PLP CLC ; Success RTS