Inline CopyChars subroutine back to Bank 3

refactor
Christophe Parent 2023-12-29 00:18:08 -08:00
parent 9711b4ecc1
commit 8eed2bd31a
2 changed files with 20 additions and 30 deletions

View File

@ -20,7 +20,6 @@ SEGMENTS {
AREADATA: load = PRG1, type = ro, optional = yes;
ENEMYDATA: load = PRG1, type = ro, optional = yes;
CHARS: load = PRG2, type = ro, optional = yes;
COPYCHARS: load = PRG2, type = ro, optional = yes;
SOUNDENGINE: load = PRG2, type = ro, optional = yes;
BANK3: load = PRG3, type = ro, optional = yes;
BANKSWITCH: load = PRG3, type = ro, optional = yes;

View File

@ -714,7 +714,7 @@ ColdBoot:
jsr MoveAllSpritesOffscreen
jsr InitializeNameTables ; initialize both name tables
inc DisableScreenFlag ; set flag to disable screen output
jsr CopyCharsBankSwitch
jsr CopyChars ; Copy graphic tiles to CHR RAM
lda Mirror_PPU_CTRL_REG1
ora #%10000000 ; enable NMIs
jsr WritePPUReg1
@ -17340,11 +17340,27 @@ EnemyDataBankSwitch:
ldx XStore
rts
; Graphic tiles and the graphics init copy routine are located in Bank 2; we switch back to Bank 0 when we are done
CopyCharsBankSwitch:
; Graphic tiles are located in Bank 2; we switch back to Bank 0 when we are done
CopyChars:
ldx #$02
jsr BankSwitch
jsr CopyChars
lda #<Chars ; load the source address into a pointer in zero page
sta CharsCopy
lda #>Chars
sta CharsCopy+1
ldy #$0 ; starting index into the first page
sty PPU_CTRL_REG2 ; turn off rendering just in case
sty PPU_ADDRESS ; load the destination address into the PPU
sty PPU_ADDRESS
ldx #$20 ; number of 256-byte pages to copy
LoopCopyChars:
lda (CharsCopy),y ; copy one byte
sta PPU_DATA
iny
bne LoopCopyChars ; repeat until we finish the page
inc CharsCopy+1 ; go to the next page
dex
bne LoopCopyChars ; repeat until we've copied enough pages
ldx #$00
jsr BankSwitch
rts
@ -17382,28 +17398,3 @@ BankTable:
Chars:
.incbin "chars.bin"
;-------------------------------------------------------------------------------------
; GRAPHICS INIT LOADING
.segment "COPYCHARS"
CopyChars:
lda #<Chars ; load the source address into a pointer in zero page
sta CharsCopy
lda #>Chars
sta CharsCopy+1
ldy #$0 ; starting index into the first page
sty PPU_CTRL_REG2 ; turn off rendering just in case
sty PPU_ADDRESS ; load the destination address into the PPU
sty PPU_ADDRESS
ldx #$20 ; number of 256-byte pages to copy
LoopCopyChars:
lda (CharsCopy),y ; copy one byte
sta PPU_DATA
iny
bne LoopCopyChars ; repeat until we finish the page
inc CharsCopy+1 ; go to the next page
dex
bne LoopCopyChars ; repeat until we've copied enough pages
rts