Skip to content

Instantly share code, notes, and snippets.

@gocha
Created June 15, 2019 09:10
Show Gist options
  • Save gocha/3cb95bbc1cdf7c825ebe2b0a3411a367 to your computer and use it in GitHub Desktop.
Save gocha/3cb95bbc1cdf7c825ebe2b0a3411a367 to your computer and use it in GitHub Desktop.
Castlevania: Aria of Sorrow - Song Randomizer
-- Castlevania: Aria of Sorrow - Song Randomizer
-- Runs on VBA-RR v23 (DO NOT USE v24)
local serial = string.char(unpack(memory.readbyterange(0x80000ac, 4)))
local m4aSongNumStart
if (serial == "A2CJ") then
m4aSongNumStart = 0x80d7950
elseif (serial == "A2CE") then
m4aSongNumStart = 0x80d9378
elseif (serial == "A2CP") then
m4aSongNumStart = 0x827cd4c
else
error("Unsupported game " .. serial)
end
memory.registerexec(m4aSongNumStart, function()
local song = memory.getregister("r0")
-- BGM
if song >= 1 and song <= 36 then
if song ~= 15 and song ~= 27 then -- excluding oneshot songs
memory.setregister("r0", math.random(1, 36))
end
end
-- Voices
if song >= 400 and song <= 494 then
memory.setregister("r0", math.random(400, 494))
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment