ref: 719bba66e54eb8983e6318a0df1894c41ffba16c
parent: cacca8bf549892c85f3e9e7351a2090f1f314d3d
author: Snesrev <snesrev@protonmail.com>
date: Fri Sep 23 12:00:14 EDT 2022
Fix some ram validation regressions
--- a/hud.c
+++ b/hud.c
@@ -517,7 +517,16 @@
Hud_DrawEquipmentBox();
Hud_DrawSelectedYButtonItem();
- if (Hud_HaveAnyItems()) {
+ if (Hud_HaveAnyItems()) {
+ // This causes bottle flicker because it's not early enough
+ int first_bottle = 0;
+ while (first_bottle < 4 && link_bottle_info[first_bottle] == 0)
+ first_bottle++;
+ if (first_bottle == 4)
+ link_item_bottle_index = 0;
+ else if (link_item_bottle_index == 0)
+ link_item_bottle_index = first_bottle + 1;
+
if (hud_cur_item == kHudItem_BottleOld && !kNewStyleInventory) {
timer_for_flashing_circle = 16;
Hud_DrawBottleMenu();
@@ -885,14 +894,6 @@
}
void Hud_SearchForEquippedItem() { // 8de399
- int first_bottle = 0;
- while (first_bottle < 4 && link_bottle_info[first_bottle] == 0)
- first_bottle++;
- if (first_bottle == 4)
- link_item_bottle_index = 0;
- else if (link_item_bottle_index == 0)
- link_item_bottle_index = first_bottle + 1;
-
if (!Hud_HaveAnyItems()) {
hud_cur_item = 0;
hud_var1 = 0;
--- a/zelda_cpu_infra.c
+++ b/zelda_cpu_infra.c
@@ -112,6 +112,7 @@
memcpy(a->ram + 0x1DBA0, b->ram + 0x1DBA0, 240 * 2); // hdma_table
memcpy(b->ram + 0x1B00, b->ram + 0x1DBA0, 224 * 2); // hdma_table (partial)
+ memcpy(a->ram + 0x1cc0, b->ram + 0x1cc0, 2); // some leftover stuff in hdma table
if (memcmp(b->ram, a->ram, 0x20000)) {
fprintf(stderr, "@%d: Memory compare failed (mine != theirs, prev):\n", frame_counter);
@@ -801,6 +802,17 @@
rom[(addr >> 16) << 15 | (addr & 0x7fff)] = 0;
}
+void PatchRomByte(uint8_t *rom, uint32_t addr, uint8 old_value, uint8 value) {
+ assert(rom[(addr >> 16) << 15 | (addr & 0x7fff)] == old_value);
+ rom[(addr >> 16) << 15 | (addr & 0x7fff)] = value;
+}
+
+void PatchRomWord(uint8_t *rom, uint32_t addr, uint16 old_value, uint16 value) {
+ assert(WORD(rom[(addr >> 16) << 15 | (addr & 0x7fff)]) == old_value);
+ WORD(rom[(addr >> 16) << 15 | (addr & 0x7fff)]) = value;
+}
+
+
void PatchRom(uint8_t *rom) {
// fix a bug with unitialized memory
{
@@ -937,6 +949,9 @@
// Prevent LoadSongBank from executing in the rom because it hangs
rom[0x888] = 0x60;
+
+ // CleanUpAndPrepDesertPrayerHDMA clearing too much
+ PatchRomWord(rom, 0x2C7E5 + 1, 0x1df, 0x1cf);
}