From a7b327892749bb8389317615a6f9442793c3351a Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 19 Jan 2025 13:51:12 -0500 Subject: [PATCH] Add ApplyGraphicsSheet(sheet,dest) macro --- Overworld/custom_gfx.asm | 44 ++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/Overworld/custom_gfx.asm b/Overworld/custom_gfx.asm index bb77509..26fbbc5 100644 --- a/Overworld/custom_gfx.asm +++ b/Overworld/custom_gfx.asm @@ -1,29 +1,30 @@ CheckForChangeGraphicsNormalLoadBoat: { - LDA $8A : CMP.b #$30 : BNE .boat_area + LDA $8A : CMP.b #$30 : BNE .boat_area PHB : PHK : PLB JSR ApplyGraphics1 JSR ApplyGraphics2 PLB - RTL .boat_area - RTL + RTL } +macro ApplyGraphicsSheet(sheet, dest) + REP #$20 ; A = 16, XY = 8 + LDX #$80 : STX $2115 ; Set the video port register every time we write it increase by 1 + LDA # : STA $2116 ; Destination of the DMA $7800 in vram <- this need to be divided by 2 + LDA #$1801 : STA $4300 ; DMA Transfer Mode and destination register + ; "001 => 2 registers write once (2 bytes: p, p+1)" + LDA.w # : STA $4302 + LDX.b #>>16 : STX $4304 + LDA #$2000 : STA $4305 ; Size of the transfer 4 sheets of $800 each + LDX #$01 : STX $420B ; Execute the DMA + SEP #$30 +endmacro + ApplyGraphics1: { - REP #$20 ; A = 16, XY = 8 - LDX #$80 : STX $2115 ; Set the video port register every time we write it increase by 1 - LDA #$2C00 : STA $2116 ; Destination of the DMA $5800 in vram <- this need to be divided by 2 - LDA #$1801 : STA $4300 ; DMA Transfer Mode and destination register - ; "001 => 2 registers write once (2 bytes: p, p+1)" - LDA.w #BoatBitmap : STA $4302 ; Source address where you want gfx from ROM - LDX.b #BoatBitmap>>16 : STX $4304 - LDA #$2000 : STA $4305 ; size of the transfer 4 sheets of $800 each - LDX #$01 : STX $420B ; Do the DMA - - SEP #$30 - + %ApplyGraphicsSheet(BoatBitmap, $2C00) RTS BoatBitmap: @@ -32,18 +33,7 @@ ApplyGraphics1: ApplyGraphics2: { - REP #$20 ; A = 16, XY = 8 - LDX #$80 : STX $2115 ; Set the video port register every time we write it increase by 1 - LDA #$5000 : STA $2116 ; Destination of the DMA $7800 in vram <- this need to be divided by 2 - LDA #$1801 : STA $4300 ; DMA Transfer Mode and destination register - ; "001 => 2 registers write once (2 bytes: p, p+1)" - LDA.w #AdditionalBitmap : STA $4302 ; Source address where you want gfx from ROM - LDX.b #AdditionalBitmap>>16 : STX $4304 - LDA #$2000 : STA $4305 ; size of the transfer 4 sheets of $800 each - LDX #$01 : STX $420B ; Do the DMA - - SEP #$30 - + %ApplyGraphicsSheet(AdditionalBitmap, $5000) RTS AdditionalBitmap: