Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,481,652
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-25-24 12:11 PM
Guest: Register | Login

0 users currently in ROM Hacking | 2 guests | 1 bot

Main - ROM Hacking - Want to get started in ASM hacking? New thread | New reply


RetroRain
Posted on 06-25-08 10:10 AM (rev. 3 of 06-25-08 10:28 AM) Link | Quote | ID: 85878


Fuzz Ball
Level: 66

Posts: 143/994
EXP: 2437998
Next: 23853

Since: 09-30-07

Last post: 1934 days
Last view: 956 days
I was typing this in my word document for myself, so I can look back on it for future reference. But, it may prove to be useful to some people as well. This helps you get started into ASM hacking. There is a lot of reading here, and even with all that I typed, there is still so much more I could type, but it would take too long. Enjoy. I hope this will help you get started in ASM hacking.



All you need to do ASM hacking to any game on any system, is a Debugger, a Cheat Search, an ASM opcode list of the system you are hacking, and a hex editor. That's all you really need, when it comes down to it. ASM hacking the NES can still be done without FCEUXD, but it would just take a lot longer. FCEUXD makes the process faster and easier. So, say you want to ASM hack a GameBoy game. You need an emulator that has a cheat search, and a debugger. The hex editor isn't a problem, since you can get those anywhere. If an emulator has just one of those two, then you'll have to find another emulator to use. You may have to use two. But the chances of one emulator not having those two together, are probably slim. It doesn't make any sense to have one, and not the other. So, if you wanted to ASM hack Super Mario Land 2, for example, here is how you would go about doing it.

1. First, you need to know what you are going to do, obviously. Once you know what you are going to do, you need data. You need all of the data and RAM addresses you need to accomplish the ASM hack in its entirety. Now, unless there is documentation somewhere, and the odds of that are pretty slim, especially considering that GameBoy hacking is rarely touched, you will need to find the data yourself. But finding the data yourself, in itself, can be a fun and rewarding process! This is where the Cheat Search comes in. This baby will help you incredibly. You can find tons of data with this thing. The cheat search console is usually pretty easy to use, but if you do not know how to use it, consult the documentation that comes with the emulator. This is usually in a text file called a "readme", which a lot of people do not like to read. If you are having trouble finding data, there are documents on the web which will help you with this. Once you have the RAM addresses and data you need, and you have tested them, then congratulations! You finished the first step into doing an ASM hack!

2. With the RAM addresses and data you now have, unless you know the system's opcodes by heart, its time to get out the opcodes document. This is, put simply, an ASM document for the system you are using. You should be able to find some on the Internet. With the opcodes document, you can now look up code in the game that controls certain functions. If you are going to attempt ASM hacking, you should at the very least, have a basic understanding of programming. A couple of courses in basic programming is all you would need. You don't really even need C++ or something more advanced, but it wouldn't hurt you. What I mean by a basic understanding in programming, is that you should know about variables, counters, loops, goto statements, etc. Knowing basic programming language will help you to understand how ASM language works. ASM language is a lot more cumbersome, but not too difficult to grasp. For example, in a basic programming language, you would load a variable like so:

QBASIC:

a = 1

C:

int a = 1;

In ASM language, it works like this:

LDA #$01
STA $300 (Can be any address within the system's limits)

It takes two parts to store a piece of data. First, you load the accumulator with a 1, and then you store it. 6502 ASM language is pretty easy to grasp, and I would recommend learning it before taking on something else. Learn ASM hacking the NES first. It will save you a lot of grief in the process.

Now, when it comes to ASM hacking the NES, you can just dive right in. But, if you really want to learn, what you want to do is build a homebrew from scratch. And there are tutorials out there on the internet, that show you how to do this. That way, you learn more about the NES, and have a much better understanding. Buidling a homebrew ROM, which help you incredibly, when it comes to reverse engineering already-made commercial games. Now, I'm not saying, go ahead and see the homebrew to completion. Just get in there and create enough that you can see how everything works. You can code the whole thing in a text editor, such as notepad. I'm not going to explain all of this though, as it would take forever, but there are documents on the web. You just have to search for them. One incredibly useful site I recommend, is nesdev.parodius.com. Now, lets continue on. Again, if you don't know have a basic understanding of how ASM works, then stop reading right now, and go learn about that.

Okay, you have the data you need, and now you need to put it to use! With this data, you can find out how it is used in the game's code. The two most important opcodes you will be using, are the load and store. With the opcodes list, and the debugger, you will be able to take the RAM addresses you have, and find the location of them in the game's code. Find the opcode for store, take the two bytes that make up the RAM address, reverse their order, and plug them into your hex editor. You may get a result. If not, then the code is being stored in a different way. Maybe its being stored indirectly. Try an indirect store opcode. Either way, you will be able to find what you are looking for, through hex editor searches, and through the use of the debugger.

Okay, you have now completed steps 1 & 2! You found the RAM addresses/data you need, and you found the location of the code in the hex editor/debugger. Congratulations! You are one more step away from completing an ASM hack.

3. The most fun step, in my opinion. Creating the ASM hack! This is the part where you change the code, to create something entirely different. Know what your programming function opcodes are (jump, jump-to-subroutine, load, store, compare, return-from-subroutine, branch-if-not-equal, etc.) All you need are these opcodes, combined with the RAM addresses, to make an ASM hack. Remember, in hex, the addresses are in reverse. For example, if you want to write to $580, here is how you would do it:

In the way we read it, what the code actually reads:

LDA #$03
STA $580

But, the ASM code is actually in hex:

LDA #$02

In 6502, it would be A9 02. LDA Immediate, is A9. The 02 is 02.

STA $580

In 6502, it would be 8D 80 05. Store Absolute, is 8D. Now, notice how the RAM address is in reverse.

80 05

05 80, or just 580. But in reverse, since it has to be two digits, it has to be 05. That should be simple enough for you to understand.

Word of wisdom: ASM Hacking is not hard. Not hard at all. Despite the fact that it is cumbersome, it is in fact very easy to do. What is hard, is that it is time consuming. Yes, that's all. So, if you are a patient person, that ASM hacking is for you. If not, you'll need to learn patience. It took me a few hours one time, just to do one single ASM hack. It's not that the coding was a problem, its the fact that I had to find all of the data/addresses/code I needed, and then properly put it into code that suits my purpose.

Think of it, like writing your own program function. You need to call on the function, you have to define/declare your variables, parameters, and then you have to return to the main program. Well, ASM hacking is the same way.

But, I say this again, as a part of my word of wisdom. ASM hacking will never be hard. It just takes lots of time to grasp, and to code. It is time which makes ASM hard. Not the ASM itself. I say this based on experience. I used to think ASM was impossible to grasp, until the more I learned, I realized it was not that hard at all. I still don't know everything. Right now, I'm learning about the NES Sprite DMA Register.

If we didn't take the time to properly map out all of necessary data, then the ASM hack would come out sloppy. You may be missing a sound effect, or the palette didn't change like it was supposed to, or because you forget to include a certain piece of data, the ASM hack is affecting other areas of the game. Thats why you need to map out everything first, and then, when you are coding it, make sure it is coded properly. When ASM coding, be prepared to go back, and have to change some code, or push code up a little bit, so you can fit new code in, etc. As humans, we are not perfect, and we make mistakes. It happens. Which is also another reason why you are going to need patience, when ASM hacking.

Like I said, if you really want to get your foot in the door the easy way, start with NES ASM hacking. Get the latest vesion of FCEUXD SP, get your favorite ROM, think of some cool ASM hack you want to do, and take the steps I have outlined for you.

Good luck!



If any experienced ASM hackers feel I need to make a change to this post, because of something that may be incorrect, feel free to let me know. I was typing this up, like free-writing. I just kept typing what came to mind.

____________________
My YouTube Channel

Googie
Posted on 06-25-08 02:52 PM Link | Quote | ID: 85888


Giant Red Paratroopa
Level: 77

Posts: 279/1407
EXP: 4180782
Next: 10347

Since: 02-19-07
From: Brooklyn, NY

Last post: 8 days
Last view: 8 days
I'll be honest with ya's, I wanna learn the language. I gotta head out now, but I'll be sure to look at this later on in the afternoon. At times I feel ashamed cause I don't know ASM, even if I don't have time now but I wanna make the time. I guess that shows I'm not gonna quit just yet...

____________________
My Linktree

Insectduel
Posted on 06-25-08 08:23 PM Link | Quote | ID: 85896


Hammer Brother
Level: 68

Posts: 88/1069
EXP: 2687553
Next: 41247

Since: 02-16-08
From: Insectduel's office

Last post: 1256 days
Last view: 1255 days
I already started doing ASM, but I haven't learn much of it. It's best for me to review all tutorials.

Yeah I found a better tutorial for people who need to get started with ASM here.

RetroRain
Posted on 06-26-08 12:19 AM Link | Quote | ID: 85900


Fuzz Ball
Level: 66

Posts: 146/994
EXP: 2437998
Next: 23853

Since: 09-30-07

Last post: 1934 days
Last view: 956 days
That document is awesome. Such a valuable tool. But there are a lot more documents that I have read, that are extremely useful. When I wrote this thing up last night, I was basically free writing to myself. I didn't expect to type up that much information.

____________________
My YouTube Channel

infidelity
Posted on 06-26-08 02:25 AM Link | Quote | ID: 85903


Fuzz Ball
Level: 66

Posts: 42/968
EXP: 2367872
Next: 93979

Since: 05-24-07

Last post: 957 days
Last view: 813 days
i've been trying my hardest since 2005 on asm. over the past year & a half, kuja killer has been giving me advice, and i've been able to understand what he's done for me, and what he's shown me. Now, 3 years later, I'm doing asm on my own. I'm getting better with identifying what an opcode is by just looking at it. About 10 opcodes I can name off the top of my head when working.

the first major thing i started doing was adding sfx to certain things. that was awesome. then i began doing simple cmp's with beq/bne's. Now I'm dong bank swappings, chr-rom switches, i can now look at an address, and off the top of my head, create either the pointer of the address, or just come up with the address itself "depending if i'm in either 8000-9FFF or A000-BFFF - :p still in MM4 mode here "

so I owe alot to kuja killer for helping me out. I'm still not at the level he's at, but I'm still learning. It's the time that I just don't have. If I was 16 again, and found out about rom hacking, everything today would be a different story for me.

Rock on ASM!!!

Arbe
Posted on 06-27-08 01:48 PM Link | Quote | ID: 86006

go away
Level: 86

Posts: 922/1788
EXP: 5986888
Next: 155219

Since: 02-23-07

Last post: 4968 days
Last view: 1537 days
This is a genuinely useful tutorial for someone that doesn't know anything. That's not me, of course, I have a lot of ASM knowledge. But yeah, looking forward to the next one.

Main - ROM Hacking - Want to get started in ASM hacking? New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.021 seconds. (347KB of memory used)
MySQL - queries: 57, rows: 83/83, time: 0.016 seconds.