Post subject: VBA Hacking
Ike
Joined: 4/25/2005
Posts: 9
Location: USA
This may be a good place to post information about hacking VBA to create tools for specific games. Here are links to a hacked version of VBA which creates shared memory in paging if anyone else wants to fiddle with it to create tools. (1.7.2shm) http://ikebo.hypermart.net/VisualBoyAdvance-1.7.2shm.zip [devel version] http://ikebo.hypermart.net/VisualBoyAdvance-1.7.2shm-debug.zip [debug version] http://ikebo.hypermart.net/VisualBoyAdvance-1.7.2shm-nodev.zip [non-devel version] http://ikebo.hypermart.net/VisualBoyAdvance-1.7.2shm-src.zip [modified source]
Emulator Coder, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
I'm a bit confused as to what you're trying to accomplish with this. I havn't downloaded it, but the description isn't clicking in my head as to what it does.
Player (206)
Joined: 5/29/2004
Posts: 5712
It's for cheating even more than usual!
put yourself in my rocketpack if that poochie is one outrageous dude
Ike
Joined: 4/25/2005
Posts: 9
Location: USA
Heheh, exactly. There was a discussion about how best to approach working on games with daunting randomness, and the idea of developing tools specific to certain games to try and make a TAS a little more accessible. http://tasvideos.org/forum/viewtopic.php?t=2023&postdays=0&postorder=asc&start=80 [thread for Aria of Sorrow] Basically the modifications to VBA allow any other interested programmers to write a program/tool to hook into the shared memory and fuddle around with the code/flow/memory even VRAM programmatically to make additional tools. It was Hoe's idea and shows some interesting potential. Hope that kinda makes sense.
Hoe
Joined: 7/31/2004
Posts: 183
Location: USA
I should have partialy decent program that uses this for Mario and Luigi (USA) and Castlevania: AoS (USA) out by the end of the week. :)
Hoe
Joined: 7/31/2004
Posts: 183
Location: USA
I currently have very preliminary support for damn near any thing in my program at the moment. I'm attempting to get the code base as flexable and useable as possible before I go ahead and impliment a million things. The source and binaries can be downloaded from http://red-stars.net/content/VBARead The source code needs more cleaning up and commenting, a timer included for refreshing, fixing up the generic game class, possibly other display options. To use as is, run Ike's VBA, load up Mario and Luigi's Super Star Saga, get into a saved or new game, then run \VBARead\bin\debug\VBARead.exe, and you'll see some basic stats displayed. This, as is, is not useful. I wanted to get the code base out there to allow people to start tinkering with it and not need to wait for me to release a full blown application/cleaned source before they get a chance to have a bit of fun. All in all, it should be simple enough for any one with some fundamental C#/.net experience to be able to impliment what they so desire. To build it, using microsoft's Visual Studio C# Express Beta2 should work just fine.
Emulator Coder, Skilled player (1310)
Joined: 12/21/2004
Posts: 2687
Do you think it's a good idea to put these changes (when completely done on the VBA side) into the supported VBA rerecording version, or will they necessarily impact performance or something? At some point I'll be putting up a minor update to VBA, and I haven't had a chance to look at what changes you've been making yet, I'm just wondering what you think about it.
Hoe
Joined: 7/31/2004
Posts: 183
Location: USA
nitsuja wrote:
Do you think it's a good idea to put these changes (when completely done on the VBA side) into the supported VBA rerecording version, or will they necessarily impact performance or something? At some point I'll be putting up a minor update to VBA, and I haven't had a chance to look at what changes you've been making yet, I'm just wondering what you think about it.
To my knowledge, there is no performance inpact. I, being a fan of this, would appreciate this being in the standard VBA-rerecording release. As a side note, I cleaned up the source a good deal, added in some new stuff and started working on Castlevania: AOS a bit, but it's difficult debugging to make sure my interpitation of the formulas are proper given the lack of break points in the non-sdl vba. I should have some thing else posted around 2pm (GMT-05) tomorrow.
Ike
Joined: 4/25/2005
Posts: 9
Location: USA
Looks solid, I can't wait to see some of the runs that take advantage of these tools. I think putting shared memory in the emulators is a good idea, I've seen no difference in CPU usage (surprisingly) on either operating system. The only problem is that Windows implements it differently than other more POSIX-compliant operating systems so it would be another subsystem that needs to be split up in the codebase. A linux version of the VBAshm client I slapped together can be perused here: [URL]http://ikebo.hypermart.net/VisualBoyAdvance-1.7.2shm.tar.bz2[/URL] It stores the shared mem in /dev/shm which can be read simply using standard file i/o. The win32 version is posted above. It only adds two very tiny modules shm.c and shm.h and replaces a few malloc/free calls with vba_shm_[malloc/free], and modifies the configure script to ensure shm libs are installed. Trivial changes, and no performance impact, but it may be a headache to sort out by operating system. It would make a great build-time option though.
Ike
Joined: 4/25/2005
Posts: 9
Location: USA
I'll put up a page later today that sorts out all these links and maybe a howto to explain the purpose.
Hoe
Joined: 7/31/2004
Posts: 183
Location: USA
I have finished most of my transitional steps from the last beta to the new one. I just hope that I can get some actual value behind the information provided before I release binaries and source again. As you can see, I moved over to a tree view. Sadly, this is a third party control and it's slow as shit. Since the code adds items via a named path, I even have a collections class caching the path to node lookups. The problem is in the third party control. It apears to not properly impliment BeingUpdate and EndUpdate since that seems to cause it to redraw even more. I'm going to have a look at his code and see if I can fix up at least that problem, if not, any one know any decent tree list views? The only game specific code for the above output is:
	public class MarioLuigi : GameGeneric {
		public MarioLuigi(EmuClient vba, MainForm mainform)
            : base(vba, mainform) {
			Title = "Mario and Luigi: Super Star Saga (USA)";
		}
		public override void UpdateDisplay() {
			AddItem("Mario\\HP", Emu.Short(0x02004866) + "\\" + Emu.Short(0x0200486A));
            AddItem("Mario\\BP", Emu.Short(0x0200486C) + "\\" + Emu.Short(0x02004870));
            AddItem("Luigi\\HP", Emu.Short(0x020048A2) + "\\" + Emu.Short(0x020048A6));
            AddItem("Luigi\\BP", Emu.Short(0x020048A8) + "\\" + Emu.Short(0x020048AC));
            AddItem("Luigi\\Level", Emu.Byte(0x020048C4));
            AddItem("Misc\\Coins", Emu.Short(0x020048E0));
		}
	}
I'm rather pleased at how simple I was able to keep it. The Emu class will translate the provided GBA address into an internaly stored list of views and return what you desire from there. The AddItem member dosn't actualy add an item unless it's not found inside of the cache, otherwise it just updates the current. Should be simple and flexable enough for any one with mild {}; language knowledge to get what they want working. Once again, thanks Ike :)
Emulator Coder, Skilled player (1310)
Joined: 12/21/2004
Posts: 2687
Hoe wrote:
To my knowledge, there is no performance inpact. I, being a fan of this, would appreciate this being in the standard VBA-rerecording release.
BTW, maybe I should also mention here that this has been done. Your tools should work with any vba-rerecording v13 or newer (not requiring a separate modified shared-memory VBA anymore).
Former player
Joined: 8/1/2004
Posts: 2687
Location: Seattle, WA
nitsuja wrote:
BTW, maybe I should also mention here that this has been done. Your tools should work with any vba-rerecording v13 or newer (not requiring a separate modified shared-memory VBA anymore).
So how can we read into the game code with VBA?
hi nitrodon streamline: cyn-chine
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
From what I understand, it is a debugger but with details for specific games? It can be REALLY useful for RPGs for manipulating luck and for those that doesn't understand what are hexadecimal supposed to eat at winter.
Emulator Coder, Skilled player (1310)
Joined: 12/21/2004
Posts: 2687
Zurreco wrote:
So how can we read into the game code with VBA?
Actually VBA does have a disassembler built in (Tools->Disassemble) to look at the code, and a cheat finder and memory viewer to look at the RAM. But I meant, Hoe's external tools that need VBA's memory to be shared can be used with this version, because I made its memory shared. I think he already has something called VBARead on his page which is the tool you would need to run while the game is open - the only thing that's missing is the specific implementation of the item/soul drop checking code (in the case of what you're interested in).