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-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
|
|
|
|
2021-09-22 00:16:36 +00:00
|
|
|
START JSR CROUT
|
2021-07-28 04:17:47 +00:00
|
|
|
JSR SETPRFX
|
|
|
|
JSR DISCONN
|
|
|
|
|
2021-08-17 19:49:27 +00:00
|
|
|
LDA #$20 ; PAGE2 shadow on ROM3 GS
|
|
|
|
TRB $C035
|
|
|
|
|
2021-09-22 00:16:36 +00:00
|
|
|
JSR ROMMENU
|
2021-09-22 02:05:42 +00:00
|
|
|
LDA #>AUXADDR ; Address in aux
|
|
|
|
LDX #<AUXADDR
|
|
|
|
SEC ; Load into aux
|
|
|
|
JSR LOADCODE ; Load lang ROM
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
LDA #<MOSSHIM ; Start address of MOS shim
|
|
|
|
STA A1L
|
|
|
|
LDA #>MOSSHIM
|
|
|
|
STA A1H
|
|
|
|
|
|
|
|
LDA #<MOSSHIM+$2000 ; End address of MOS shim
|
|
|
|
STA A2L
|
|
|
|
LDA #>MOSSHIM+$2000
|
|
|
|
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
|
|
|
|
STA $C005 ; Write to aux
|
|
|
|
STX $0100
|
|
|
|
STA $C004 ; Write to main
|
|
|
|
>>> XF2AUX,AUXMOS1
|
|
|
|
|
2021-09-22 02:05:42 +00:00
|
|
|
:FDFILE STR 'FDRAW.FAST' ; Filename for FDraw lib
|
2021-09-22 00:16:36 +00:00
|
|
|
|
2021-09-22 02:05:42 +00:00
|
|
|
* Load image from file into memory
|
|
|
|
* On entry: OPENPL set up to point to file to load
|
|
|
|
* 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-07-28 04:17:47 +00:00
|
|
|
JSR OPENFILE ; Open ROM file
|
2021-09-22 02:05:42 +00:00
|
|
|
BCC :S1
|
2021-07-28 04:17:47 +00:00
|
|
|
LDX #$00
|
2021-09-22 02:05:42 +00:00
|
|
|
:L1A LDA :CANTOPEN,X ; Part one of error msg
|
|
|
|
BEQ :S0
|
2021-07-28 04:17:47 +00:00
|
|
|
JSR COUT1
|
|
|
|
INX
|
2021-09-22 02:05:42 +00:00
|
|
|
BRA :L1A
|
|
|
|
:S0 LDA OPENPL+1 ; Print filename
|
|
|
|
STA A1L
|
|
|
|
LDA OPENPL+2
|
|
|
|
STA A1H
|
|
|
|
LDY #$00
|
|
|
|
LDA (A1L),Y
|
|
|
|
STA :LEN
|
|
|
|
:L1B CPY :LEN
|
|
|
|
BEQ :ERR1
|
|
|
|
INY
|
|
|
|
LDA (A1L),Y
|
|
|
|
JSR COUT1
|
|
|
|
BRA :L1B
|
|
|
|
: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-09-22 02:05:42 +00:00
|
|
|
:L2 LDA #'.'+$80 ; Read file block by block
|
2021-07-28 04:17:47 +00:00
|
|
|
JSR COUT1
|
2021-07-29 00:47:26 +00:00
|
|
|
JSR RDFILE
|
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-09-22 00:16:36 +00:00
|
|
|
RTS
|
2021-09-22 02:05:42 +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
|
|
|
|
:CANTOPEN ASC "Unable to open "
|
2021-08-10 19:10:15 +00:00
|
|
|
DB $00
|
2021-09-10 18:53:24 +00:00
|
|
|
|