News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Question on implementing multiplayer  (Read 6519 times)

BossRoss93

  • Guest
Question on implementing multiplayer
« on: April 27, 2013, 04:29:52 am »
Hey guys, so I'm new to the hacking scene, and honestly not very skilled at this stuff. I was however, interested in maybe hacking some games to allow for multiplayer. Honestly, I don't even know if I could do it, but I really have no idea where to start. I was looking to maybe do this for A link to the past or perhaps Minish Cap. Just an idea that has been floating around in my head for a while. I'm not looking to get like a step by step or anything, perhaps just being pointed in the right direction would be best.
If anyone has any idea on how I would go about starting a project like this, please let me know. Thanks!

FAST6191

  • Hero Member
  • *****
  • Posts: 2593
    • View Profile
Re: Question on implementing multiplayer
« Reply #1 on: April 27, 2013, 07:32:27 am »
This tends to happen more if a multiplayer mode was dropped from a game but still in the code somewhere, multiplayer was available in another region (though most would approach it from a porting the translation to the other region rather than porting multiplayer code), on the PC where engines can be swapped and fiddled with (though such things are not unheard of on consoles- see total conversions) or if you have an AI partner in a game that you could stop the AI from and input commands instead.

Minish cap is GBA so I should also note that where console multiplayer of the 16 bit and 8 bit eras was local and multiplayer amounts to transmitting a screen and button presses the handhelds run full standalone programs and have a set communication protocol that you will have to account for. This might not be such a problem here depending upon how you want to work it (emulator only being far more appealing from a lazy bastard perspective).

If you wanted to take the NES mario approach of alternating characters when deaths happen/levels are finished then that might work but it would be an awful lot of effort to do that rather than make a level select, double the lives or something and tell the others to pass the controller.

Throughout this I have said nothing of the games being designed to handle multiplayer from the level design and enemy AI upwards but that might also trouble things on games. In code this would also extend to making sure characters left by the same exit/were near enough that it did not trouble resources and other such things.

BossRoss93

  • Guest
Re: Question on implementing multiplayer
« Reply #2 on: April 27, 2013, 12:29:04 pm »
Thanks so much for the informative approach FAST, yeah minish cap seemed a little iffy, but perhaps a link to the past may still work? I mean early on you have zelda as a companion, not sure if that is relevant or not. The only reason I see that working is due to the Ocarina of tie four player hack. But regardless, though it seems difficult, would I have to open up the actual code to the game and examine it? I'd love to do that, I am just not really sure how I would actually do that. Any ideas man?

FAST6191

  • Hero Member
  • *****
  • Posts: 2593
    • View Profile
Re: Question on implementing multiplayer
« Reply #3 on: April 27, 2013, 08:48:49 pm »
Link to the past SNES it would be like any other. GBA link to the past does come with four swords which is a multiplayer game (though again it is four GBAs doing their thing).

"Open up the game code"
Yeah but it probably does not work like you think.
Most older devices and still a lot of PC programs use compiled code. The idea is though you can write fancy readable things in a text editor (see also programming language) and call it code the CPU has no idea how to decode that and do anything with it, compared to some of those languages the CPU is also pretty limited too if you look at its raw functions.
One of the other niceties if you are a person writing programs for a living is that once you convert from text to machine code it is exceptionally difficult to go backwards (see "the halting problem").
On top of this developers learned that although you can feed the CPU instructions it gets far easier if you kick data outside code and have the code read it in, interpret it and act upon it at runtime. This is what a large chunk of ROM hacking is concerned with figuring out for various games. You can get languages that take this data and use it to act like a programming language at runtime, these are somewhat slower but are known as interpreted languages and they have all sorts of benefits. Being slower and typically more resource hungry it meant they are not really used until you get to the likes of the PS2 though the DS has a few goes at it and GBA homebrew can do a bit here as well.
Back to code once the human readable has been turned from human readable text to the instructions as they run on the CPU you can still look at it and try to figure it out. Trouble is every CPU is different (though some concepts are shared and things like the ARM7 are not that different to the ARM9) and on top of that every class of device has different hardware that is spoken to in different ways (some of which even makes up for shortcomings in CPUs- not every CPU has a divide instruction or a divide instruction that is of great use in general operations for instance) where your nice human readable language will hopefully be far less troubled by this if it is troubled at all.
The human readable code rendered in a stream of hex numbers is known as machine code, the immediate level up from that where each machine code instruction is turned into a human readable piece of text (note this is not the same human readable text as the original programmer made) is known as assembler, assembly or ASM (roughly they are synonyms). As you control everything at this level you can do what you like including adding a multiplayer mode, however you do have to account for everything and thus this is why assembly hacking is considered the hardest part of ROM hacking and those that can do it make the most far reaching hacks and have the least trouble figuring out formats (if you can watch the game do what it does and follow along you basically have no guesswork where everybody else does).
Programming like this, especially with a premade piece of code as your base, is a nightmare if you want to do anything drastic which is why basically nobody codes in it in real life and most ROM hackers will make the least amount of changes possible when hacking.
This is why I mentioned the mario 1 NES style thing and the "stop the partner AI" types of multiplayer. Zelda as a companion... possible that something could be done the AI there would be extremely basic (probably not even worthy of the term and instead I would probably call it an animation).

That over how to open up the game code (by which I assume you mean the actual stuff the CPU sees).
As you assemble code so you can disassemble code and the tool you want to do it is called as disassembler. Though all different devices use different things if the CPU is the same then it disassembles the same so you can get generic ones (the most popular generic/multi purpose one is IDA). However as things can sit in different memory locations and might have extras you can get a more specialist one for the given console/device you are playing on. If it has games it probably has as disassembler built for it (it the badge on the front says Sega, Nintendo or Sony then it definitely does) if in no other place than an emulator that runs it, again though IDA makes an appearance as people do build disassemblers for that. Disassemblers are pretty dumb tools so most people working in it will flank it with several other tools like debugging emulators.
Also though I mentioned code being converted up a level it rarely actually comes out like that and disassembled code will not be able to be reassembled wholesale so you have to take your changes and patch them onto the original game.

Spikeman

  • Hero Member
  • *****
  • Posts: 1063
  • *unce unce unce*
    • View Profile
    • None at the moment, check out my Last.fm page instead?
Re: Question on implementing multiplayer
« Reply #4 on: May 09, 2013, 06:26:20 pm »
Implementing multiplayer would require some very extensive assembly hacking, and a detailed understanding of the game's engine. I've done a fair amount of work disassembling The Minish Cap, and just to give you an example of the scope of the complexity of the game: it took me several weeks to code a map viewer, that still doesn't handle a few of the edge cases properly; it took me a full day to understand how the using weapons/items is handled. And this is with the help of powerful tools like IDA disassembler and No$GBA debugger (both cost money). I'd actually disagree and say you might have an easier time doing this on the GBA, since there exist much better tools. As far as I'm aware IDA doesn't work with SNES, and the SNES debuggers are not nearly as good as No$GBA. Also, if you want this to work like real GBA multiplayer would, you'd have to code from scratch all the link cable stuff, which to the best of my knowledge, is poorly documented, and the emulation for it isn't that great.

The route I would recommend is taking advantage of Lua scripting capabilities that many emulators now have. VBA supports it, and I believe SNES9x does, if you'd like to go the SNES route. Here's an example of online multiplayer added to NES Tetris with Lua: http://www.youtube.com/watch?v=LT1eiLiMWkk

I can also post some code for a rudimentary Pokemon multiplayer Lua script if you'd like a starting point. (And if time permits, could probably help out with Minish Cap stuff - love that game! At the very least I can offer you my notes and disassembly files for the game.)
Open Source Hacking Projects: Guru Logic Champ, Telefang 2, (Want more? Check out my GitHub!)

neige

  • Jr. Member
  • **
  • Posts: 36
    • View Profile
Re: Question on implementing multiplayer
« Reply #5 on: May 10, 2013, 05:38:10 pm »
As far as I'm aware IDA doesn't work with SNES
IDA Pro supports the 65816 processor since version 6.2 and as a SNES ROM loader.

Alternatively, you can use my own IDA Pro plugins whose output is somewhat compatible with WLADX and use explicit operand size suffixes.

Ti_

  • Jr. Member
  • **
  • Posts: 39
    • View Profile
Re: Question on implementing multiplayer
« Reply #6 on: May 27, 2013, 09:17:08 am »
IDA Pro supports the 65816 processor since version 6.2 and as a SNES ROM loader.

Alternatively, you can use my own IDA Pro plugins whose output is somewhat compatible with WLADX and use explicit operand size suffixes.
Is it possible to use this plugins with versions <6.1  or lower? Unfortanely, 6.2 version is not freeware.

neige

  • Jr. Member
  • **
  • Posts: 36
    • View Profile
Re: Question on implementing multiplayer
« Reply #7 on: May 27, 2013, 06:34:09 pm »
You will have to try as I don't have access to an old version to test.

Ti_

  • Jr. Member
  • **
  • Posts: 39
    • View Profile
Re: Question on implementing multiplayer
« Reply #8 on: May 28, 2013, 01:51:11 am »
You will have to try as I don't have access to an old version to test.
Crashes with version 6,1 (windows).  with v. 5.2  'don't find entry point in dll'.
Is that plugins exists as open-source code in ida-SDK? may be it possible it to compile it to previous versions.

neige

  • Jr. Member
  • **
  • Posts: 36
    • View Profile
Re: Question on implementing multiplayer
« Reply #9 on: May 28, 2013, 08:17:09 pm »
I don't have Windows anymore so I can't really help you with that crash.

My 65816 processor module is a modified version of the m7700 processor module that is included in the IDA SDK but is not itself in the SDK. Also since it's based on the SDK, I can't share the source. I also don't have access to a copy of an old SDK to compile.

Stabwound

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: Question on implementing multiplayer
« Reply #10 on: May 30, 2013, 11:40:52 am »
The only multiplayer hack I can think of is one for Super Mario World, and it looked like it took a ton of work and is still full of issues, mainly the 2nd player not being able to do all of the actions they should be able to do.

Not to be a dick, but if you're asking a question like this then it's going to take a lot of effort. It would be like deciding "I'm going to climb Mt. Everest."

Celice

  • Hero Member
  • *****
  • Posts: 622
    • View Profile
Re: Question on implementing multiplayer
« Reply #11 on: June 01, 2013, 03:43:53 pm »
Ocarina of Time had a pseudo-multiplayer mode being made a year or so back:

http://www.youtube.com/watch?v=ZT2IBWKpUAI

And a link to a working multiplayer patch and some other assorted files:

http://spinout182.com/2player/

The original video and its account has been terminated for copyright violations, but this video shows pretty much what the original project was. They shifted the control of the other Link-objects to Controllers 2, 3, and 4 respectively, and it worked fairly well, albeit you only shared on screen.

I know Fallout 3 on the PC has a similar mod that allows another player to control a generic NPC model, and there were efforts to create real LAN-like multiplayer for Morrowind and Oblivion, but I don't remember what became of those projects...

Next to that, Super Mario Galaxy has a legit multiplayer, split-screen mode hacked in:

http://www.youtube.com/watch?v=Pqef07U0LNs

So there are more projects than just Super Mario World's floating around :p