Joined: 8/25/2023
Posts: 1
Location: Norway
Hi! Probably a sub-optimal question, but I'm asking anyways: Can I use a lua script to perform a RAM search? I know you can interact with TAS studio this way. I want to search for an unchanging value over x amount of frames and then at frame #y, search for a changed value and then spit out the results if possible. Cheers! Forgot to mention I'm using BizHawk! Cheers.
YoshiRulz
Any
Editor
Joined: 8/30/2020
Posts: 80
Location: Sydney, Australia
Untested: Download search.lua
Language: lua

local CUTOFF = 40; memory.usememorydomain("WRAM"); local LENGTH = 0x10000; local mem_prev = memory.read_bytes_as_array(0, LENGTH); local matching = {}; for addr = 0, LENGTH - 1 do table.insert(matching, addr); end while true do emu.frameadvance(); local mem = memory.read_bytes_as_array(0, LENGTH); local filtered = {}; if emu.framecount() < CUTOFF then for _, addr in pairs(matching) do if mem[addr] == mem_prev[addr] then table.insert(filtered, addr); end end else for _, addr in pairs(matching) do if mem[addr] ~= mem_prev[addr] then table.insert(filtered, addr); end end -- probably want to write to file at this point end matching = filtered; mem_prev = mem; end
I contribute to BizHawk as Linux/cross-platform lead, testing and automation lead, and UI designer. This year, I'm experimenting with streaming BizHawk development on Twitch. nope Links to find me elsewhere and to some of my side projects are on my personal site. I will respond on Discord faster than to PMs on this site.
Hey look buddy, I'm an engineer. That means I solve problems. Not problems like "What is software," because that would fall within the purview of your conundrums of philosophy. I solve practical problems. For instance, how am I gonna stop some high-wattage thread-ripping monster of a CPU dead in its tracks? The answer: use code. And if that don't work? Use more code.