Applecorn/loader.s

119 lines
3.0 KiB
ArmAsm
Raw Normal View History

* LOADER.S
* (c) Bobbi 2021 GPLv3
*
2021-07-31 22:58:59 +00:00
* Applecorn loader code
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.
* (Note that the MOS code will copy itself to $D000.)
2021-08-10 19:10:15 +00:00
START JSR ROMMENU
2021-08-10 19:10:15 +00:00
STZ :BLOCKS
LDX #$00
:S1 JSR CROUT
JSR SETPRFX
JSR DISCONN
2021-08-17 19:49:27 +00:00
LDA #$20 ; PAGE2 shadow on ROM3 GS
TRB $C035
JSR OPENFILE ; Open ROM file
BCC :S2
LDX #$00
:L2 LDA CANTOPEN,X
BEQ :ER1
JSR COUT1
INX
BRA :L2
BRA :S2
:ER1 JSR CROUT
JSR BELL
RTS
:S2 LDA OPENPL+5 ; File reference number
STA READPL+1
:L3 LDA #'.'+$80 ; Read file block by block
JSR COUT1
2021-07-29 00:47:26 +00:00
JSR RDFILE
BCS :S3 ; EOF (0 bytes left) or some error
2021-07-29 00:47:26 +00:00
LDA #<BLKBUF ; Source start addr -> A1L,A1H
STA A1L
2021-07-29 00:47:26 +00:00
LDA #>BLKBUF
STA A1H
2021-07-29 00:47:26 +00:00
LDA #<BLKBUFEND ; Source end addr -> A2L,A2H
STA A2L
2021-07-29 00:47:26 +00:00
LDA #>BLKBUFEND
STA A2H
LDA #<AUXADDR ; Dest in aux -> A4L, A4H
STA A4L
LDA #>AUXADDR
LDX :BLOCKS
:L4 CPX #$00
BEQ :S25
INC
INC
DEX
BRA :L4
:S25 STA A4H
SEC ; Copy Main -> Aux
JSR AUXMOVE
INC :BLOCKS
BRA :L3
:S3 LDA OPENPL+5 ; File reference number
STA CLSPL+1
JSR CLSFILE
LDA #<MOSSHIM ; Start address of MOS shim
STA A1L
LDA #>MOSSHIM
STA A1H
2021-08-15 05:25:43 +00:00
LDA #<MOSSHIM+$2000 ; End address of MOS shim
STA A2L
2021-08-15 05:25:43 +00:00
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
2021-08-15 22:18:52 +00:00
LDA #<GSBRK ; Set BRK vector in main mem
STA $3F0
LDA #>GSBRK
STA $3F0+1
2021-08-14 05:18:35 +00:00
TSX ; Save SP at $0100 in aux
STA $C005 ; Write to aux
2021-08-14 05:18:35 +00:00
STX $0100
STA $C004 ; Write to main
2021-08-01 00:37:18 +00:00
>>> XF2AUX,AUXMOS1
:BLOCKS DB 0 ; Counter for blocks read
2021-08-10 19:10:15 +00:00
CANTOPEN ASC "Unable to open ROM file"
DB $00