2021-09-07 02:28:07 +00:00
|
|
|
* MAINMEM.LDR.S
|
2021-07-28 04:17:47 +00:00
|
|
|
* (c) Bobbi 2021 GPLv3
|
|
|
|
*
|
2021-09-07 02:28:07 +00:00
|
|
|
* Applecorn loader code. Runs in main memory.
|
2021-10-01 22:37:30 +00:00
|
|
|
* 01-Oct-2021 Copies MOS code to whole $D000-$FFFF.
|
2021-11-13 18:58:20 +00:00
|
|
|
* 13-Nov-2021 LOADCODE uses absolute path to Applecorn directory.
|
|
|
|
|
2021-07-31 22:58:59 +00:00
|
|
|
|
2021-08-01 00:19:15 +00:00
|
|
|
* Loads Acorn ROM file (16KB) from disk and writes it
|
|
|
|
* to aux memory starting at $08000. Copies Applecorn MOS
|
|
|
|
* to aux memory starting at AUXMOS1 and jumps to it.
|
2021-08-30 23:08:22 +00:00
|
|
|
* (Note that the MOS code will copy itself to $D000.)
|
2021-09-07 02:28:07 +00:00
|
|
|
|
2022-10-07 03:09:29 +00:00
|
|
|
SYSTEM LDX #$FF ; Init stack pointer
|
|
|
|
TXS
|
|
|
|
|
|
|
|
LDA #$00
|
2022-10-08 09:17:19 +00:00
|
|
|
STA IBAKVER ; Minimum compatible P8 version
|
2022-10-07 03:09:29 +00:00
|
|
|
LDA #$01
|
2022-10-08 09:17:19 +00:00
|
|
|
STA IVERSION ; Version of .SYSTEM program
|
2022-10-07 03:09:29 +00:00
|
|
|
|
|
|
|
SED ; Check for 65C02
|
|
|
|
LDA #$99
|
|
|
|
CLC
|
|
|
|
ADC #$01
|
|
|
|
CLD
|
|
|
|
BPL GOODCPU
|
|
|
|
JMP UNSUPPORTED
|
|
|
|
|
2022-10-08 09:17:19 +00:00
|
|
|
GOODCPU LDA MACHID
|
2022-10-07 03:09:29 +00:00
|
|
|
AND #$F2 ; Clear bits 0,2,3
|
|
|
|
CMP #$B2 ; Are we on a //e or //c w/ 80col and 128K or a IIgs?
|
|
|
|
BEQ SUPPORTED ; Supported machine
|
|
|
|
JMP UNSUPPORTED ; Unsupported machine
|
|
|
|
|
|
|
|
SUPPORTED LDA #$DF ; Protect pages $0,$1,and $3-$7
|
2022-10-08 09:17:19 +00:00
|
|
|
STA P8BMAP0007
|
2022-10-07 03:09:29 +00:00
|
|
|
LDA #$F0 ; Protect pages $8-$B
|
2022-10-08 09:17:19 +00:00
|
|
|
STA P8BMAP080F
|
2022-10-07 03:09:29 +00:00
|
|
|
LDA #$FF ; Protect HGR1
|
2022-10-08 09:17:19 +00:00
|
|
|
STA P8BMAP2027
|
|
|
|
STA P8BMAP282F
|
|
|
|
STA P8BMAP3037
|
|
|
|
STA P8BMAP383F
|
2022-10-10 06:38:13 +00:00
|
|
|
|
|
|
|
* Set prefix if not already set
|
|
|
|
SETPRFX LDA #GPFXCMD
|
|
|
|
STA :OPC7 ; Initialize cmd byte to $C7
|
|
|
|
:L1 JSR MLI
|
|
|
|
:OPC7 DB $00
|
|
|
|
DW GSPFXPL
|
|
|
|
LDX DRVBUF1 ; was $0300
|
|
|
|
BNE RTSINST
|
|
|
|
LDA DEVNUM
|
|
|
|
STA ONLNPL+1 ; Device number
|
|
|
|
JSR MLI
|
|
|
|
DB ONLNCMD
|
|
|
|
DW ONLNPL
|
|
|
|
LDA DRVBUF2 ; was $0301
|
|
|
|
AND #$0F
|
|
|
|
TAX
|
|
|
|
INX
|
|
|
|
STX DRVBUF1 ; was $0300
|
|
|
|
LDA #'/'
|
|
|
|
STA DRVBUF2 ; was $0301
|
|
|
|
DEC :OPC7
|
|
|
|
BNE :L1
|
|
|
|
RTSINST LDA CMDPATH
|
|
|
|
BEQ :GETPFX ; CMDPATH empty
|
|
|
|
LDA CMDPATH+1
|
|
|
|
CMP #'/'
|
|
|
|
BEQ DISCONN ; CMDPATH already absolute path
|
|
|
|
:GETPFX JSR MLI
|
2022-10-12 04:00:36 +00:00
|
|
|
DB GPFXCMD ; Get Prefix
|
2022-10-10 06:38:13 +00:00
|
|
|
DW GETPFXPARM
|
|
|
|
|
|
|
|
* Disconnect /RAM ramdrive to avoid aux corruption
|
|
|
|
* Stolen from Beagle Bros Extra K
|
|
|
|
DISCONN LDA MACHID
|
|
|
|
AND #$30
|
|
|
|
CMP #$30
|
|
|
|
BNE :S1
|
|
|
|
LDA DEVADR32
|
|
|
|
CMP DEVADR01
|
|
|
|
BNE :S2
|
|
|
|
LDA DEVADR32+1
|
|
|
|
CMP DEVADR01+1
|
|
|
|
BEQ :S1
|
|
|
|
:S2 LDY DEVCNT
|
|
|
|
:L1 LDA DEVLST,Y
|
|
|
|
AND #$F3
|
|
|
|
CMP #$B3
|
|
|
|
BEQ :S3
|
|
|
|
DEY
|
|
|
|
BPL :L1
|
|
|
|
BMI :S1
|
|
|
|
:S3 LDA DEVLST,Y
|
|
|
|
STA DRVBUF2+1 ; was $0302
|
|
|
|
:L2 LDA DEVLST+1,Y
|
|
|
|
STA DEVLST,Y
|
|
|
|
BEQ :S4
|
|
|
|
INY
|
|
|
|
BNE :L2
|
|
|
|
:S4 LDA DEVADR32
|
|
|
|
STA DRVBUF1 ; was $0300
|
|
|
|
LDA DEVADR32+1
|
|
|
|
STA DRVBUF2 ; was $0301
|
|
|
|
LDA DEVADR01
|
|
|
|
STA DEVADR32
|
|
|
|
LDA DEVADR01+1
|
|
|
|
STA DEVADR32+1
|
|
|
|
DEC DEVCNT
|
2022-10-14 04:47:42 +00:00
|
|
|
|
|
|
|
:S1 SEC
|
|
|
|
JSR IDROUTINE ; See if we have a GS
|
|
|
|
BCS :NOTGS
|
|
|
|
JSR ENSQINIT ; Initialize Ensoniq
|
|
|
|
|
|
|
|
:NOTGS JSR ROMMENU ; This really needs to happen elsewhere
|
2021-09-22 02:05:42 +00:00
|
|
|
|
|
|
|
LDA #<:FDFILE
|
|
|
|
STA OPENPL+1
|
|
|
|
LDA #>:FDFILE
|
|
|
|
STA OPENPL+2
|
|
|
|
LDA #>FDRAWADDR ; Address in main
|
|
|
|
LDX #<FDRAWADDR
|
|
|
|
CLC ; Load into main
|
|
|
|
JSR LOADCODE
|
2021-09-22 00:16:36 +00:00
|
|
|
|
2021-09-23 16:59:36 +00:00
|
|
|
LDA #<:FNTFILE
|
|
|
|
STA OPENPL+1
|
|
|
|
LDA #>:FNTFILE
|
|
|
|
STA OPENPL+2
|
|
|
|
LDA #>FONTADDR ; Address in main
|
|
|
|
LDX #<FONTADDR
|
|
|
|
CLC ; Load into main
|
|
|
|
JSR LOADCODE
|
|
|
|
|
2021-09-22 00:16:36 +00:00
|
|
|
LDA #<MOSSHIM ; Start address of MOS shim
|
|
|
|
STA A1L
|
|
|
|
LDA #>MOSSHIM
|
|
|
|
STA A1H
|
|
|
|
|
2021-10-01 22:37:30 +00:00
|
|
|
LDA #<MOSSHIM+$3000 ; End address of MOS shim
|
2021-09-22 00:16:36 +00:00
|
|
|
STA A2L
|
2021-10-01 22:37:30 +00:00
|
|
|
LDA #>MOSSHIM+$3000
|
2021-09-22 00:16:36 +00:00
|
|
|
STA A2H
|
|
|
|
|
|
|
|
LDA #<AUXMOS1 ; To AUXMOS1 in aux memory
|
|
|
|
STA A4L
|
|
|
|
LDA #>AUXMOS1
|
|
|
|
STA A4H
|
|
|
|
|
|
|
|
SEC ; Copy MOS from Main->Aux
|
|
|
|
JSR AUXMOVE
|
|
|
|
|
|
|
|
LDA #<RESET ; Set reset vector->RESET
|
|
|
|
STA RSTV
|
|
|
|
LDA #>RESET
|
|
|
|
STA RSTV+1
|
|
|
|
EOR #$A5 ; Checksum
|
2022-10-12 04:00:36 +00:00
|
|
|
STA PWRDUP
|
2021-09-22 00:16:36 +00:00
|
|
|
|
2022-10-12 04:00:36 +00:00
|
|
|
LDA #<GSBRK ; Set BREAK vector in main mem
|
|
|
|
STA BREAKV
|
2021-09-22 00:16:36 +00:00
|
|
|
LDA #>GSBRK
|
2022-10-12 04:00:36 +00:00
|
|
|
STA BREAKV+1
|
2021-09-22 00:16:36 +00:00
|
|
|
|
2022-10-11 00:17:17 +00:00
|
|
|
JSR GFXINIT ; Initialize FDraw graphics
|
|
|
|
|
|
|
|
TSX ; Save SP at $0100 in aux
|
|
|
|
>>> ALTZP
|
|
|
|
STX $0100
|
|
|
|
>>> MAINZP
|
|
|
|
>>> XF2AUX,AUXMOS1
|
2022-10-10 07:18:42 +00:00
|
|
|
|
|
|
|
* Filenames for loaded binaries - we're gonna address these later
|
|
|
|
|
|
|
|
:FDFILE STR "FDRAW.FAST" ; Filename for FDraw lib
|
|
|
|
:FNTFILE STR "FONT.DAT" ; Filename for bitmap font
|
|
|
|
|
|
|
|
GETPFXPARM HEX 01 ; One parameter
|
|
|
|
DW CMDPATH ; Get prefix to CMDPATH
|
|
|
|
|
|
|
|
UNSUPPORTED JSR HOME
|
|
|
|
LDX #$00
|
|
|
|
UNSUPLP LDA UNSUPMSG,X
|
|
|
|
BEQ UNSUPWAIT
|
|
|
|
JSR COUT1
|
|
|
|
INX
|
|
|
|
BNE UNSUPLP
|
2022-10-12 04:00:36 +00:00
|
|
|
UNSUPWAIT STA KBDSTRB
|
|
|
|
UNSUPKEY LDA KEYBOARD
|
2022-10-10 07:18:42 +00:00
|
|
|
BPL UNSUPKEY
|
2022-10-12 04:00:36 +00:00
|
|
|
STA KBDSTRB
|
2022-10-10 07:18:42 +00:00
|
|
|
|
|
|
|
JSR MLI
|
2022-10-12 04:00:36 +00:00
|
|
|
DB QUITCMD
|
|
|
|
DW UNSUPQPARM
|
2022-10-10 07:18:42 +00:00
|
|
|
UNSUPQPARM DB $04,$00,$00,$00,$00,$00,$00
|
|
|
|
|
|
|
|
UNSUPMSG ASC "APPLECORN REQUIRES AN APPLE IIGS, APPLE", 8D
|
|
|
|
ASC "//C, OR ENHANCED APPLE //E WITH AN", 8D
|
|
|
|
ASC "80-COLUMN CARD AND AT LEAST 128K", 8D, 8D
|
|
|
|
ASC "PRESS ANY KEY TO QUIT TO PRODOS", 00
|
|
|
|
|
2022-10-10 09:23:15 +00:00
|
|
|
ENDSYSTEM
|