diff --git a/patches/ips/vanilla_bugfixes.ips b/patches/ips/vanilla_bugfixes.ips index 7787949c8..457f9bb25 100644 Binary files a/patches/ips/vanilla_bugfixes.ips and b/patches/ips/vanilla_bugfixes.ips differ diff --git a/patches/rom_map/Bank 82.txt b/patches/rom_map/Bank 82.txt index 7a6e78e64..5ca9c5edb 100644 --- a/patches/rom_map/Bank 82.txt +++ b/patches/rom_map/Bank 82.txt @@ -1,6 +1,5 @@ [unused vanilla code] 8B18 - 8B1F: [free] [unused vanilla code] - 8 bytes -8D51 - 8DBC: [free] [vanilla bg2 code, patched out in vanilla_bugfixes] - 108 bytes A3D9 - A424: [free] [unused vanilla code] - 76 bytes B5E8 - B62A: [free] [unused vanilla code] - 67 bytes B650 - B671: [free] [unused vanilla code] - 34 bytes diff --git a/patches/rom_map/RAM.txt b/patches/rom_map/RAM.txt index 434235e4f..3496ce83d 100644 --- a/patches/rom_map/RAM.txt +++ b/patches/rom_map/RAM.txt @@ -36,7 +36,7 @@ $7ED823: randomizer-specific event flags: $0010: metal pirates room door unlocked $7ED825: pause menu room name enabled (map_area.asm) $7ed86c: bomb_torizo.asm -$7EDF5C-$7EEF5B: [FREE] (vanilla_bugfixes removes the BG2 backup that used this block of ram.) +$7EE01E-$7EEF5B: [FREE] (vanilla_bugfixes removes most of the BG2 backup that used this block of ram.) $7EF4A0-$7EF4AF: temp storage for special tile (reserve_hud.asm) $7EF4B0-$7EF4E0: backup of DMA registers in decompression.asm $7EF4E0-$7EF4E4: pending MSU/SPC playback state (msu1.asm) diff --git a/patches/src/vanilla_bugfixes.asm b/patches/src/vanilla_bugfixes.asm index ec86d16e4..d79f8e6ee 100644 --- a/patches/src/vanilla_bugfixes.asm +++ b/patches/src/vanilla_bugfixes.asm @@ -252,19 +252,40 @@ assert pc() <= !bank_82_free_space_end ; Pause menu tiles routine DMA transfer size bug fix. ; Vanilla code transfers too many bytes, destroying the BG2 tilemap. -; Correcting the DMA transfer size means the backup/restore BG2 pause hook isn't needed. -; Which also frees up the 4k block of ram used for the backup / restore. +; Correcting the DMA transfer size means the full backup/restore isn't needed. +; The Typewriter text is written directly to VRAM so we backup just those rows instead. ; nn_357 ;org $828ed2 ; Correct DMA transfer size $1000, [hud_expansion_opaque already fixes this, included for reference]. ; db $10 -org $828d08 ; Back up BG2 tilemap for pause menu - bra + - nop -+ - -org $829377 ; Restore BG2 tilemap from pause menu - bra + - nop -+ \ No newline at end of file +org $828D51 ;;; $8D51: Back up BG2 tilemap for pause menu (save typewrite text during pause) ;;; +BackupBG2Tilemap: + PHP + SEP #$20 + LDA #$00 : STA $2116 ; VRAM $4900 (BG2 row 8) + LDA #$49 : STA $2117 + REP #$20 + LDA #$3981 : STA $4310 ; VRAM -> WRAM, reads $2139/$213A + LDA #$DF5C : STA $4312 + LDA #$00C2 : STA $4315 ; 194 bytes: 2 junk (prefetch glitch) + 192 real (rows 8-Ah) + SEP #$20 + LDA #$7E : STA $4314 + LDA #$02 : STA $420B + PLP + RTS +assert pc() <= $828D96 + +org $828D96 ;;; $8D96: Restore BG2 tilemap from pause menu ;;; +RestoreBG2Tilemap: + PHP + SEP #$20 + LDA #$00 : STA $2116 + LDA #$49 : STA $2117 + LDA #$80 : STA $2115 + JSL $8091A9 + db $01,$01,$18 : dl $7EDF5E : dw $00C0 ; skip the 2 junk bytes + LDA #$02 : STA $420B + PLP + RTS +assert pc() <= $828DBD \ No newline at end of file