Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified patches/ips/vanilla_bugfixes.ips
Binary file not shown.
1 change: 0 additions & 1 deletion patches/rom_map/Bank 82.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion patches/rom_map/RAM.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
43 changes: 32 additions & 11 deletions patches/src/vanilla_bugfixes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
+
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
Loading