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
|
|
|
|
STA $BFFC ; IBAKVER (minimum P8 version)
|
|
|
|
LDA #$01
|
|
|
|
STA $BFFD ; IVERSION (version of me)
|
|
|
|
|
|
|
|
SED ; Check for 65C02
|
|
|
|
LDA #$99
|
|
|
|
CLC
|
|
|
|
ADC #$01
|
|
|
|
CLD
|
|
|
|
BPL GOODCPU
|
|
|
|
JMP UNSUPPORTED
|
|
|
|
|
|
|
|
GOODCPU LDA $BF98 ; MACHID
|
|
|
|
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
|
|
|
|
STA $BF58
|
|
|
|
LDA #$F0 ; Protect pages $8-$B
|
|
|
|
STA $BF59
|
|
|
|
LDA #$FF ; Protect HGR1
|
|
|
|
STA $BF5C
|
|
|
|
STA $BF5D
|
|
|
|
STA $BF5E
|
|
|
|
STA $BF5F
|
|
|
|
JMP START
|
|
|
|
|
|
|
|
UNSUPPORTED JSR HOME
|
|
|
|
LDX #$00
|
|
|
|
UNSUPLP LDA UNSUPMSG,X
|
|
|
|
BEQ UNSUPWAIT
|
|
|
|
JSR COUT1
|
|
|
|
INX
|
|
|
|
BNE UNSUPLP
|
|
|
|
UNSUPWAIT STA $C010
|
|
|
|
UNSUPKEY LDA $C000
|
|
|
|
BPL UNSUPKEY
|
|
|
|
STA $C010
|
|
|
|
|
|
|
|
JSR MLI
|
|
|
|
DB QUITCMD
|
|
|
|
DW UNSUPQPARM
|
|
|
|
UNSUPQPARM DB $04,$00,$00,$00,$00,$00,$00
|
|
|
|
|
|
|
|
UNSUPMSG ASC "APPLECORN REQUIRES AN APPLE IIGS, APPLE"
|
|
|
|
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
|
|
|
|
|
|
|
|
PADDING ASC '***THISISPROTOTYPECODE***'
|
|
|
|
DS $4000-*
|
|
|
|
|
|
|
|
; Original APPLECORN.BIN code starts here
|
|
|
|
|
2021-09-22 00:16:36 +00:00
|
|
|
START JSR CROUT
|
2021-07-28 04:17:47 +00:00
|
|
|
JSR SETPRFX
|
|
|
|
JSR DISCONN
|
|
|
|
|
2021-09-22 00:16:36 +00:00
|
|
|
JSR ROMMENU
|
2021-10-24 21:02:12 +00:00
|
|
|
* LDA #>AUXADDR ; Address in aux
|
|
|
|
* LDX #<AUXADDR
|
|
|
|
* SEC ; Load into aux
|
|
|
|
* JSR LOADCODE ; Load lang ROM
|
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
|
|
|
|
STA RSTV+2
|
|
|
|
|
|
|
|
LDA #<GSBRK ; Set BRK vector in main mem
|
|
|
|
STA $3F0
|
|
|
|
LDA #>GSBRK
|
|
|
|
STA $3F0+1
|
|
|
|
|
|
|
|
JSR GFXINIT ; Initialize FDraw graphics
|
|
|
|
|
|
|
|
TSX ; Save SP at $0100 in aux
|
2022-09-20 03:20:35 +00:00
|
|
|
>>> ALTZP
|
2021-09-22 00:16:36 +00:00
|
|
|
STX $0100
|
2022-09-20 03:20:35 +00:00
|
|
|
>>> MAINZP
|
2021-09-22 00:16:36 +00:00
|
|
|
>>> XF2AUX,AUXMOS1
|
|
|
|
|
2021-09-22 22:55:41 +00:00
|
|
|
:FDFILE STR "FDRAW.FAST" ; Filename for FDraw lib
|
2021-09-23 16:59:36 +00:00
|
|
|
:FNTFILE STR "FONT.DAT" ; Filename for bitmap font
|
2021-09-22 00:16:36 +00:00
|
|
|
|
2021-09-22 02:05:42 +00:00
|
|
|
* Load image from file into memory
|
2021-11-13 18:58:20 +00:00
|
|
|
* On entry: OPENPL set up to point to leafname of file to load
|
|
|
|
* Loads file from directory applecorn started from
|
|
|
|
* Uses BLKBUF at loading buffer
|
2021-09-22 02:05:42 +00:00
|
|
|
* Load address in A,X
|
|
|
|
* Carry set->load to aux, carry clear->load to main
|
|
|
|
LOADCODE PHP ; Save carry flag
|
|
|
|
STA :ADDRH ; MSB of load address
|
|
|
|
STX :ADDRL ; LSB of load address
|
|
|
|
STZ :BLOCKS
|
2021-11-13 18:58:20 +00:00
|
|
|
|
|
|
|
LDX #0
|
|
|
|
:LP1 LDA CMDPATH+1,X ; Copy Applecorn path to MOSFILE
|
|
|
|
STA MOSFILE2+1,X
|
|
|
|
INX
|
|
|
|
CPX CMDPATH
|
|
|
|
BCC :LP1
|
|
|
|
:LP2 DEX
|
|
|
|
LDA MOSFILE2+1,X
|
|
|
|
CMP #'/'
|
|
|
|
BNE :LP2
|
|
|
|
LDA OPENPL+1
|
|
|
|
STA A1L
|
|
|
|
LDA OPENPL+2
|
|
|
|
STA A1H
|
|
|
|
LDY #1
|
|
|
|
LDA (A1L),Y
|
|
|
|
CMP #'/'
|
|
|
|
BEQ :L4 ; Already absolute path
|
|
|
|
:LP3 LDA (A1L),Y
|
|
|
|
STA MOSFILE2+2,X
|
|
|
|
INX
|
|
|
|
INY
|
|
|
|
TYA
|
|
|
|
CMP (A1L)
|
|
|
|
BCC :LP3
|
|
|
|
BEQ :LP3
|
|
|
|
INX
|
|
|
|
STX MOSFILE2+0
|
|
|
|
LDA #<MOSFILE2 ; Point to absolute path
|
|
|
|
STA OPENPL+1
|
|
|
|
LDA #>MOSFILE2
|
|
|
|
STA OPENPL+2
|
|
|
|
|
|
|
|
:L4 JSR OPENFILE ; Open ROM file
|
2021-09-22 02:05:42 +00:00
|
|
|
BCC :S1
|
2021-11-13 18:58:20 +00:00
|
|
|
PLP
|
|
|
|
BCC :L1A ; Load to main, report error
|
|
|
|
RTS ; Load to aux, return CS=Failed
|
|
|
|
:L1A LDX #$00
|
|
|
|
:L1B LDA :CANTOPEN,X ; Part one of error msg
|
2021-09-22 02:05:42 +00:00
|
|
|
BEQ :S0
|
2021-07-28 04:17:47 +00:00
|
|
|
JSR COUT1
|
|
|
|
INX
|
2021-11-13 18:58:20 +00:00
|
|
|
BRA :L1B
|
2021-09-22 02:05:42 +00:00
|
|
|
:S0 LDA OPENPL+1 ; Print filename
|
|
|
|
STA A1L
|
|
|
|
LDA OPENPL+2
|
|
|
|
STA A1H
|
|
|
|
LDY #$00
|
|
|
|
LDA (A1L),Y
|
|
|
|
STA :LEN
|
2021-11-13 19:35:02 +00:00
|
|
|
:L1C CPY :LEN
|
2021-09-22 02:05:42 +00:00
|
|
|
BEQ :ERR1
|
|
|
|
INY
|
|
|
|
LDA (A1L),Y
|
|
|
|
JSR COUT1
|
2021-11-13 19:35:02 +00:00
|
|
|
BRA :L1C
|
2021-09-22 02:05:42 +00:00
|
|
|
:ERR1 JSR CROUT
|
2021-07-28 04:17:47 +00:00
|
|
|
JSR BELL
|
2021-09-22 00:16:36 +00:00
|
|
|
:SPIN BRA :SPIN
|
2021-09-22 02:05:42 +00:00
|
|
|
:S1 LDA OPENPL+5 ; File reference number
|
2021-07-28 04:17:47 +00:00
|
|
|
STA READPL+1
|
2021-11-13 18:58:20 +00:00
|
|
|
:L2 PLP
|
|
|
|
PHP
|
|
|
|
BCS :L2A ; Loading to aux, skip dots
|
|
|
|
LDA #'.'+$80 ; Print progress dots
|
2021-07-28 04:17:47 +00:00
|
|
|
JSR COUT1
|
2021-11-13 18:58:20 +00:00
|
|
|
:L2A JSR RDFILE ; Read file block by block
|
2021-09-22 02:05:42 +00:00
|
|
|
BCS :CLOSE ; EOF (0 bytes left) or some error
|
2021-07-29 00:47:26 +00:00
|
|
|
LDA #<BLKBUF ; Source start addr -> A1L,A1H
|
2021-07-28 04:17:47 +00:00
|
|
|
STA A1L
|
2021-07-29 00:47:26 +00:00
|
|
|
LDA #>BLKBUF
|
2021-07-28 04:17:47 +00:00
|
|
|
STA A1H
|
2021-07-29 00:47:26 +00:00
|
|
|
LDA #<BLKBUFEND ; Source end addr -> A2L,A2H
|
2021-07-28 04:17:47 +00:00
|
|
|
STA A2L
|
2021-07-29 00:47:26 +00:00
|
|
|
LDA #>BLKBUFEND
|
2021-07-28 04:17:47 +00:00
|
|
|
STA A2H
|
2021-09-22 02:05:42 +00:00
|
|
|
LDA :ADDRL ; Dest in aux -> A4L, A4H
|
2021-07-28 04:17:47 +00:00
|
|
|
STA A4L
|
2021-09-22 02:05:42 +00:00
|
|
|
LDA :ADDRH
|
2021-07-28 04:17:47 +00:00
|
|
|
LDX :BLOCKS
|
2021-09-22 02:05:42 +00:00
|
|
|
:L3 CPX #$00
|
|
|
|
BEQ :S2
|
2021-07-28 04:17:47 +00:00
|
|
|
INC
|
|
|
|
INC
|
|
|
|
DEX
|
|
|
|
BRA :L3
|
2021-09-22 02:05:42 +00:00
|
|
|
:S2 STA A4H
|
|
|
|
PLP ; Recover carry flag
|
|
|
|
PHP
|
|
|
|
BCS :TOAUX
|
|
|
|
JSR MEMCPY ; Destination in main mem
|
|
|
|
BRA :S3
|
|
|
|
:TOAUX JSR AUXMOVE ; Carry already set (so to aux)
|
|
|
|
:S3 INC :BLOCKS
|
|
|
|
BRA :L2
|
|
|
|
:CLOSE LDA OPENPL+5 ; File reference number
|
2021-07-28 04:17:47 +00:00
|
|
|
STA CLSPL+1
|
|
|
|
JSR CLSFILE
|
2021-09-22 02:05:42 +00:00
|
|
|
JSR CROUT
|
|
|
|
PLP
|
2021-11-13 18:58:20 +00:00
|
|
|
CLC ; CC=Ok
|
2021-09-22 00:16:36 +00:00
|
|
|
RTS
|
2021-09-22 02:59:11 +00:00
|
|
|
:ADDRL DB $00 ; Destination address (LSB)
|
|
|
|
:ADDRH DB $00 ; Destination address (MSB)
|
|
|
|
:BLOCKS DB $00 ; Counter for blocks read
|
|
|
|
:LEN DB $00 ; Length of filename
|
2021-09-22 02:05:42 +00:00
|
|
|
:CANTOPEN ASC "Unable to open "
|
2021-08-10 19:10:15 +00:00
|
|
|
DB $00
|
2021-09-10 18:53:24 +00:00
|
|
|
|
2021-09-23 16:59:36 +00:00
|
|
|
|
|
|
|
|
2021-09-23 22:16:21 +00:00
|
|
|
|
|
|
|
|
2021-09-24 02:07:36 +00:00
|
|
|
|
|
|
|
|
2021-09-25 16:50:08 +00:00
|
|
|
|
|
|
|
|
2021-10-14 00:57:16 +00:00
|
|
|
|
|
|
|
|
2021-10-14 23:24:26 +00:00
|
|
|
|
|
|
|
|
2021-10-18 22:46:52 +00:00
|
|
|
|
|
|
|
|
2021-10-25 00:38:32 +00:00
|
|
|
|
2021-10-26 13:31:34 +00:00
|
|
|
|
2021-11-13 19:57:05 +00:00
|
|
|
|
2021-11-14 23:04:10 +00:00
|
|
|
|
|
|
|
|
2021-11-13 19:57:05 +00:00
|
|
|
|