Joined: 5/22/2024
Posts: 5
Can someone help me get the source code from mega man DOS 1 and 3 please? Not do it for me but teach me how to please?
Editor, Active player (459)
Joined: 2/11/2018
Posts: 240
There will be other people more knowledgeable, but since no one has else responded. There's no simple or automatic way to get a game's source code. Technically it's impossible unless it gets leaked or released, but even taking a compiled executable and turning it into readable code can take a lot of effort. In Mega Man's case, the executable was packed with EXEPACK, so you'd probably want to start with an unpacker. There are pages like ScummVM's reverse engineering howto with further resources.
Joined: 5/22/2024
Posts: 5
How exactly did sand get the code for the sewer rat then?
Editor, Active player (459)
Joined: 2/11/2018
Posts: 240
Analyzing the assembly, writing out the logic and adding comments I assume. I don't think these games were even written in C.
Sand
He/Him
Player (143)
Joined: 6/26/2018
Posts: 175
TheAllmightyStegosaurus, what are you hoping to be able to do? If you're working on a TAS, you don't necessarily need the full source code for a game. You do need to spend time learning and understanding the game, but there's a lot you can accomplish just using savestates and observing what happens onscreen. Reverse engineering the binary code of a game to understand how it works is a big job in itself. For a game like Mega Man 3, even something as seemingly simple as, say, understanding the map file format could take dozens of hours of work. My advice, if you're working on a TAS, is not to start at such a low level. Watch the fastest RTA runs (megamanleaderboards.net, speedrun.com) and learn what tricks they use. Try making a TAS of a full stage, using RTA strategies but with no mistakes. An intermediate step, before you dive into full reverse engineering of the code, is finding useful RAM addresses, such as Mega Man's (x, y) coordinates, HP, and weapon energy. Learning how to use RAM search is a good step towards acquiring the other skills you will need. Randomno is correct, there's no automatic way to rip the source code from a compiled program. It's not like the source code is hidden in the program somewhere. The best you can do is look at the compiled binary code and infer what the source code would have been. I'm not certain about Mega Man 3, but Mega Man 1 for DOS was written in assembly, not C or some other high-level language. You can tell this (when you have enough experience) just by observing the way functions are called, for example, but in this case there's definitive evidence in the form of a fragment of source code visible in Gaming Historian's video. When I reverse engineered the Sewer Rat AI in Mega Man 1, for example, I did it just as Randomno says: I looked at the assembly language disassembled from the program executable, identified the loops, figured out what the function calls did, etc. Then I wrote C code (C-like pseudocode really) with equivalent behavior because C is easier to read and understand than assembly—but the game was definitely not originally written in C. The comments are my interpretation: there are no comments or even variable names in the program itself. Randomno recommended the ScummVM's reverse engineering howto which is a good place to start. There are lots of reverse engineering guides online if it's something you want to learn. I use Rizin for disassembling the machine code, annotating memory locations, giving names to functions, etc. Honestly it's not an ideal tool for this purpose; in particular, it's not very good with the memory segments of 16-bit DOS code. But I haven't spent a lot of time looking for alternative tools. But any of these tools is going to require substantial background knowledge. You will need to know how a CPU works and how to read assembly language, at least. If you're not able to do those things yet, you will have to build a foundation of knowledge first. Start by doing some experiments with savestates and RAM search, and document your progress in the Mega Man 3 thread because we're interested in seeing what you come up with :)