Created
June 15, 2019 09:10
-
-
Save gocha/3cb95bbc1cdf7c825ebe2b0a3411a367 to your computer and use it in GitHub Desktop.
Castlevania: Aria of Sorrow - Song Randomizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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