Hey guys,
I've recently started getting into LUA scripting for NES games, and oh my god it's so much fun. I've been playing around with using the select button in Mega Man games to quickly switch weapons. It can be a pain figuring out where in memory some of this stuff takes place though. Here's the script and a link to the video. Let me know what you think. I'll be updating this thread as I make progress.
video -> http://www.youtube.com/watch?v=cBcOoNtULVQ
the script -> https://gist.github.com/614747
I'd code it like this:
weapon_names = {"Arm Cannon","Atomic Fire",...}
Then use "if next_weapon > max_weapon" or "if next_weapon > table.maxn(...)" or "> #weapon_names"
Keep in mind that in lua arrays (which really are tables) start with 1 as their lowest index (which really is a key) per default though.
Nice work.
For what it's worth I dug up an old script I was working on for MM 1, 2 and 3. Not sure if it is even in a working state, though it was at some point. I got hung up on the graphical issues. Would love to see a TAS using your script someday!
http://lua.pastebin.com/Y5MS2nyR
awesome. the script has been updated to define the tables in a single line (and all the array indexes fixed likewise)
looks awesome (same as mine, but for mm1 2 and 3, correct?), but i could not get it to work :(
Hmm yeah it might not be working at all. But perhaps you could decode some of the memory addresses for the other games? I guess you could figure it out for yourself anyways :P
Anyway, good luck!
Ok maybe I'm crazy trying to crack memory address that affect sprite issue.
Here my finding:
03B6 - PPU row pointer (I think you need to set it to 09 for weapon graphic)
03B7 - PPU column pointer (00, 20, 40, 60, 80, A0, C0, E0 in order from left to right)
0008 - I think it may have something to do with graphic
00FD - I think it also may have something to do with graphic or pausing
No idea if you can change them frame for frame, or all at once with lua memory.writebyte().
If you put 03B7 in debugger, make it break on WRITE, then try open or close menu in game, you'll notice it'll pause each time a tile in PPU viewer is changed.
Set PPU viewer refresh rate to max.