2021-08-20 22:57:14 +00:00
|
|
|
* AUXMEM.INIT.S
|
|
|
|
* (c) Bobbi 2021 GPL v3
|
|
|
|
*
|
|
|
|
* Initialization code running in Apple //e aux memory
|
|
|
|
|
2021-08-08 02:48:24 +00:00
|
|
|
***********************************************************
|
|
|
|
* BBC Micro 'virtual machine' in Apple //e aux memory
|
|
|
|
***********************************************************
|
|
|
|
|
2021-10-29 03:13:47 +00:00
|
|
|
MAXROM EQU $F9 ; Max sideways ROM number
|
|
|
|
|
2021-09-12 06:05:17 +00:00
|
|
|
ZP1 EQU $90 ; $90-$9f are spare Econet space
|
|
|
|
; so safe to use
|
2021-08-08 02:48:24 +00:00
|
|
|
ZP2 EQU $92
|
|
|
|
ZP3 EQU $94
|
|
|
|
|
2021-09-12 06:05:17 +00:00
|
|
|
STRTBCKL EQU $9D ; *TO DO* don't need to preserve
|
2021-08-08 02:48:24 +00:00
|
|
|
STRTBCKH EQU $9E
|
|
|
|
|
|
|
|
MOSSHIM
|
2021-09-12 06:05:17 +00:00
|
|
|
ORG AUXMOS ; MOS shim implementation
|
2021-08-08 02:48:24 +00:00
|
|
|
|
|
|
|
*
|
|
|
|
* Shim code to service Acorn MOS entry points using
|
|
|
|
* Apple II monitor routines
|
|
|
|
* This code is initially loaded into aux mem at AUXMOS1
|
|
|
|
* Then relocated into aux LC at AUXMOS by MOSINIT
|
|
|
|
*
|
|
|
|
* Initially executing at $3000 until copied to $D000
|
|
|
|
|
2022-09-20 20:58:28 +00:00
|
|
|
MOSINIT SEI ; Disable IRQ while initializing
|
|
|
|
LDX #$FF ; Initialize Alt SP to $1FF
|
2021-08-12 21:14:03 +00:00
|
|
|
TXS
|
|
|
|
|
2021-09-12 06:05:17 +00:00
|
|
|
STA $C005 ; Make sure we are writing aux
|
|
|
|
STA $C000 ; Make sure 80STORE is off
|
2021-08-08 02:48:24 +00:00
|
|
|
|
2021-09-12 06:05:17 +00:00
|
|
|
LDA $C08B ; LC RAM Rd/Wt, 1st 4K bank
|
2021-08-08 02:48:24 +00:00
|
|
|
LDA $C08B
|
|
|
|
|
2021-09-12 06:05:17 +00:00
|
|
|
:MODBRA BRA :RELOC ; NOPped out on first run
|
2021-08-14 06:16:58 +00:00
|
|
|
BRA :NORELOC
|
2021-08-08 02:48:24 +00:00
|
|
|
|
2021-09-12 06:05:17 +00:00
|
|
|
LDA #$EA ; NOP opcode
|
2021-08-14 06:16:58 +00:00
|
|
|
STA :MODBRA
|
|
|
|
STA :MODBRA+1
|
|
|
|
|
2021-09-12 06:05:17 +00:00
|
|
|
:RELOC LDA #<AUXMOS1 ; Relocate MOS shim
|
2021-08-08 02:48:24 +00:00
|
|
|
STA A1L
|
|
|
|
LDA #>AUXMOS1
|
|
|
|
STA A1H
|
|
|
|
LDA #<EAUXMOS1
|
|
|
|
STA A2L
|
|
|
|
LDA #>EAUXMOS1
|
|
|
|
STA A2H
|
|
|
|
LDA #<AUXMOS
|
|
|
|
STA A4L
|
|
|
|
LDA #>AUXMOS
|
|
|
|
STA A4H
|
|
|
|
:L1 LDA (A1L)
|
|
|
|
STA (A4L)
|
|
|
|
LDA A1H
|
|
|
|
CMP A2H
|
|
|
|
BNE :S1
|
|
|
|
LDA A1L
|
|
|
|
CMP A2L
|
|
|
|
BNE :S1
|
|
|
|
BRA :S4
|
|
|
|
:S1 INC A1L
|
|
|
|
BNE :S2
|
|
|
|
INC A1H
|
|
|
|
:S2 INC A4L
|
|
|
|
BNE :S3
|
|
|
|
INC A4H
|
|
|
|
:S3 BRA :L1
|
|
|
|
|
|
|
|
:S4 LDA #<MOSVEC-MOSINIT+AUXMOS1
|
|
|
|
STA A1L
|
|
|
|
LDA #>MOSVEC-MOSINIT+AUXMOS1
|
|
|
|
STA A1H
|
|
|
|
LDA #<MOSVEND-MOSINIT+AUXMOS1
|
|
|
|
STA A2L
|
|
|
|
LDA #>MOSVEND-MOSINIT+AUXMOS1
|
|
|
|
STA A2H
|
|
|
|
LDA #<MOSAPI
|
|
|
|
STA A4L
|
|
|
|
LDA #>MOSAPI
|
|
|
|
STA A4H
|
|
|
|
:L2 LDA (A1L)
|
|
|
|
STA (A4L)
|
|
|
|
LDA A1H
|
|
|
|
CMP A2H
|
|
|
|
BNE :S5
|
|
|
|
LDA A1L
|
|
|
|
CMP A2L
|
|
|
|
BNE :S5
|
|
|
|
BRA :S8
|
|
|
|
:S5 INC A1L
|
|
|
|
BNE :S6
|
|
|
|
INC A1H
|
|
|
|
:S6 INC A4L
|
|
|
|
BNE :S7
|
|
|
|
INC A4H
|
|
|
|
:S7 BRA :L2
|
|
|
|
|
2021-08-20 22:57:14 +00:00
|
|
|
:NORELOC
|
2021-09-12 06:05:17 +00:00
|
|
|
:S8 STA $C00D ; 80 col on
|
|
|
|
STA $C003 ; Alt charset off
|
|
|
|
STA $C055 ; PAGE2
|
|
|
|
JMP MOSHIGH ; Ensure executing in high memory here
|
2021-08-08 02:48:24 +00:00
|
|
|
|
2022-09-20 20:58:28 +00:00
|
|
|
MOSHIGH SEI ; Disable IRQ while initializing
|
2021-08-10 01:27:44 +00:00
|
|
|
LDX #$FF
|
2021-09-12 06:05:17 +00:00
|
|
|
TXS ; Initialise stack
|
|
|
|
INX ; X=$00
|
2021-08-10 01:27:44 +00:00
|
|
|
TXA
|
2021-09-12 06:05:17 +00:00
|
|
|
:SCLR STA $0000,X ; Clear Kernel memory
|
2021-08-10 01:27:44 +00:00
|
|
|
STA $0200,X
|
|
|
|
STA $0300,X
|
|
|
|
INX
|
|
|
|
BNE :SCLR
|
|
|
|
|
|
|
|
LDX #ENDVEC-DEFVEC-1
|
2021-09-12 06:05:17 +00:00
|
|
|
:INITPG2 LDA DEFVEC,X ; Set up vectors
|
2021-08-08 02:48:24 +00:00
|
|
|
STA $200,X
|
|
|
|
DEX
|
|
|
|
BPL :INITPG2
|
2021-08-10 01:27:44 +00:00
|
|
|
|
2022-09-24 00:24:39 +00:00
|
|
|
LDA $C036 ; GS speed register
|
|
|
|
AND #$80 ; Speed bit only
|
|
|
|
STA GSSPEED ; In Alt LC for IRQ/BRK hdlr
|
|
|
|
|
2021-10-29 03:13:47 +00:00
|
|
|
JSR ROMINIT ; Build list of sideways ROMs
|
2021-09-12 06:05:17 +00:00
|
|
|
JSR KBDINIT ; Returns A=startup MODE
|
|
|
|
JSR VDUINIT ; Initialise VDU driver
|
2021-08-26 21:36:46 +00:00
|
|
|
JSR PRHELLO
|
|
|
|
LDA #7
|
|
|
|
JSR OSWRCH
|
|
|
|
JSR OSNEWL
|
2021-11-05 23:16:22 +00:00
|
|
|
LDX MAXROM ; TEMP X=language to enter
|
2021-08-20 22:35:31 +00:00
|
|
|
CLC
|
2021-09-12 03:07:05 +00:00
|
|
|
|
|
|
|
* OSBYTE $8E - Enter language ROM
|
2021-10-23 18:41:47 +00:00
|
|
|
* X=ROM number to select
|
2021-09-12 03:07:05 +00:00
|
|
|
*
|
2021-09-12 06:05:17 +00:00
|
|
|
BYTE8E PHP ; Save CLC=RESET, SEC=Not RESET
|
2021-11-05 23:16:22 +00:00
|
|
|
JSR ROMSELECT ; Bring ROM X into memory
|
|
|
|
STX BYTEVARBASE+$FC ; Set current language ROM
|
2021-09-12 06:05:17 +00:00
|
|
|
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 OSNEWL
|
|
|
|
JSR OSNEWL
|
|
|
|
PLP ; Get entry type back
|
|
|
|
LDA #$01
|
|
|
|
JMP AUXADDR
|
2021-09-12 03:07:05 +00:00
|
|
|
|
|
|
|
* OSBYTE $8F - Issue service call
|
|
|
|
* X=service call, Y=parameter
|
|
|
|
*
|
2021-11-05 23:16:22 +00:00
|
|
|
SERVICE TAX ; Enter here with A=Service Num
|
2021-09-12 03:07:05 +00:00
|
|
|
BYTE8F
|
2021-10-23 18:41:47 +00:00
|
|
|
SERVICEX LDA $F4
|
2021-11-05 23:16:22 +00:00
|
|
|
PHA ; Save current ROM
|
2021-10-29 03:13:47 +00:00
|
|
|
|
|
|
|
* LDA $E0 ; *DEBUG*
|
|
|
|
* AND #$20
|
|
|
|
* BEQ :SERVDEBUG
|
|
|
|
* TXA
|
|
|
|
* JSR PRHEX
|
|
|
|
* LDA OSLPTR+1
|
|
|
|
* JSR PRHEX
|
|
|
|
* LDA OSLPTR+0
|
|
|
|
* JSR PRHEX ; *DEBUG*
|
|
|
|
*:SERVDEBUG
|
|
|
|
|
2021-10-23 18:41:47 +00:00
|
|
|
TXA
|
2021-11-05 23:16:22 +00:00
|
|
|
LDX MAXROM ; Start at highest ROM
|
|
|
|
:SERVLP JSR ROMSELECT ; Bring it into memory
|
2021-09-12 06:05:17 +00:00
|
|
|
BIT $8006
|
2021-11-05 23:16:22 +00:00
|
|
|
BPL :SERVSKIP ; No service entry
|
|
|
|
JSR $8003 ; Call service entry
|
2021-09-12 06:05:17 +00:00
|
|
|
TAX
|
|
|
|
BEQ :SERVDONE
|
2021-11-05 23:16:22 +00:00
|
|
|
: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
|
2021-10-23 18:41:47 +00:00
|
|
|
TAX
|
2021-11-05 23:16:22 +00:00
|
|
|
JSR ROMSELECT ; Restore caller's ROM
|
|
|
|
PLX ; Get return value back
|
|
|
|
TXA ; Return in A and X and set EQ/NE
|
2021-10-23 18:41:47 +00:00
|
|
|
RTS
|
2021-09-12 03:07:05 +00:00
|
|
|
|
2021-08-08 02:48:24 +00:00
|
|
|
|
2021-08-26 21:36:46 +00:00
|
|
|
PRHELLO LDA #<HELLO
|
|
|
|
LDY #>HELLO
|
|
|
|
JSR PRSTR
|
|
|
|
JMP OSNEWL
|
|
|
|
|
2021-10-14 23:10:11 +00:00
|
|
|
BYTE00XX
|
|
|
|
BYTE00 BEQ BYTE00A ; OSBYTE 0,0 - generate error
|
|
|
|
LDX #$0A ; Identify Host
|
2021-09-12 06:05:17 +00:00
|
|
|
RTS ; %000x1xxx host type, 'A'pple
|
2021-08-26 21:36:46 +00:00
|
|
|
BYTE00A BRK
|
|
|
|
DB $F7
|
2022-09-24 05:30:57 +00:00
|
|
|
HELLO ASC 'Applecorn MOS 2022-09-24'
|
2021-09-12 06:05:17 +00:00
|
|
|
DB $00 ; Unify MOS messages
|
2022-09-24 00:24:39 +00:00
|
|
|
GSSPEED DB $00 ; $80 if GS is fast, $00 for slow
|
2021-09-12 06:05:17 +00:00
|
|
|
|
2021-10-26 13:31:34 +00:00
|
|
|
|
2021-11-05 23:16:22 +00:00
|
|
|
|
|
|
|
|
2021-11-13 19:57:05 +00:00
|
|
|
|
|
|
|
|
2021-11-14 23:04:10 +00:00
|
|
|
|
|
|
|
|