From 8eed2bd31aab3bc6c013f52b44db84d30fb24b19 Mon Sep 17 00:00:00 2001 From: Christophe Parent Date: Fri, 29 Dec 2023 00:18:08 -0800 Subject: [PATCH] Inline CopyChars subroutine back to Bank 3 --- src/linker.cfg | 1 - src/main.asm | 49 ++++++++++++++++++++----------------------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/linker.cfg b/src/linker.cfg index ac83dba..ce569d2 100644 --- a/src/linker.cfg +++ b/src/linker.cfg @@ -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; diff --git a/src/main.asm b/src/main.asm index af69758..66dfa6b 100644 --- a/src/main.asm +++ b/src/main.asm @@ -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 + 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 - 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