From 88a0bbdd4a09304a7c6044851aba02b4815d1aa7 Mon Sep 17 00:00:00 2001 From: Daniel Finke Date: Tue, 6 Oct 2020 15:16:27 -0700 Subject: [PATCH] OoT: add some extra ROM checks (ROM loaded, main memory size) Should make #51, #39, #26, and #21 less likely to occur (may be enough to solve them entirely) (fix #51, fix #39, fix #26, fix #21) --- bizhawk-co-op/ramcontroller/Ocarina of Time.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bizhawk-co-op/ramcontroller/Ocarina of Time.lua b/bizhawk-co-op/ramcontroller/Ocarina of Time.lua index 4ac7bb0..e5083a2 100644 --- a/bizhawk-co-op/ramcontroller/Ocarina of Time.lua +++ b/bizhawk-co-op/ramcontroller/Ocarina of Time.lua @@ -10,10 +10,23 @@ local function declare (name, initval) rawset(_G, name, initval or false) end +-- Expect a minimum of 4MB RAM +local EXPECTED_MEMORY_SIZE_MIN = 0x400000 + local oot = require('bizhawk-co-op\\helpers\\oot') local oot_rom = {} +if (gameinfo.getromname() == "Null") then + setmetatable(_G, old_global_metatable) + error("The OoT ROM needs to be loaded prior to hosting/joining a room") +end + +if (mainmemory.getcurrentmemorydomainsize() < EXPECTED_MEMORY_SIZE_MIN) then + setmetatable(_G, old_global_metatable) + error("Unexpected main memory size. Did you load a ROM from another console?") +end + local rando_context = mainmemory.read_u32_be(0x1C6E90 + 0x15D4) - 0x80000000 if (rando_context == 0) then setmetatable(_G, old_global_metatable)