Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,471,419
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-23-24 10:51 AM
Guest: Register | Login

0 users currently in ROM Hacking | 1 guest | 2 bots

Main - ROM Hacking - Do you want to learn 6502 ASM? (Think again) New thread | New reply

Pages: 1 2

Thanatos-Zero
Posted on 10-22-12 07:27 PM Link | Quote | ID: 152726


Nipper Plant
Level: 45

Posts: 284/423
EXP: 652670
Next: 7494

Since: 11-25-08
From: Germany - Rheinlandpfalz - Wittlich - Zur Phillippsburg 25

Last post: 1088 days
Last view: 1050 days
Posted by kuja killer
i know already... but what i really mean is, i dont know "what" to pick.. or take from other games. I know i can just do that, but i dont ever know what to think.

Well for that, you can ask us for opiniums, when you are unsure about your choices.

Posted by kuja killer
I really cant manage to explain. i even suck at trying to just explain THIS very sentence even. :| (above)

Happens to me all the time. Mistakes happen here and there.
When you are uneasy it is more often.

____________________
I was a prisoner enclosed in the void, were everything might end up just as myself.
There I was called the death in the void, but after a long sleep my drill was ready to pierce the void.
I came back... to guide those who are in doubt and to crush any corrupted mind.
"Just who in the hell do you think I am?!".

infidelity
Posted on 10-22-12 09:34 PM Link | Quote | ID: 152727


Fuzz Ball
Level: 66

Posts: 280/968
EXP: 2367478
Next: 94373

Since: 05-24-07

Last post: 955 days
Last view: 811 days
Ok, i feel this thread is getting a little crazy/off topic. I've got a few minutes to spare with free wifi, sp let me try to share some insights on asm.

For 6502 asm, I was taught by using opcodes, which by some die hard 6502 coders is frowned upon, but for me, it worked.

This is so cliche, but 6502 asm is not for those who think they can pick it up in a day, month, year, you name it. I've been doing this since 2005, and to this day i'll still need to look up some certain things to figure out what to do.

But enough about my past with asm, id like to share some quick examples, and share some quick insights on specificly working with .nes games.

Part 1. How To Hack *whatever*
If you are truely serious in wanting to hack a game, you have to learn how that particular game works. Every game is built differently. I thought from working with the Megaman games, that I could work with any game. That is not the case. A perfect example is Matrixz document on Megaman 4. He literaly started from beginning to end, on figuring out how Megaman 4 worked. Once you know how a game works, you can edit the shit out of it to your likeing.

Of course, you would have to know how to work with 6502 asm first. But mosr importantly, you need to know how the NES works.

Part 2. The NES
Before I begin, I have to note that I work based off of using opcodes, not writing text for asm.

I'm going to briefly summarize a few things with dealing with the NES.

"RAM" means the entire area from $0 to $7FF in the NES. That is where all sorts of shit takes place. This is where you want to start when trying to decypher a games inner workings. This area deals with, code, contoller inputs, gfx, sound, sprites, music, additional information, you name it.

"ROM" means the actual NES ROM. ROM means the NES Cartridge. ROM means the entire game.

"SRAM" means the entire area from $6000 to $7FFF. This is where *if the rom is setup for it* you save game content to a battery packed game. However, if the rom is not setup for saving, you can use this entire area for additonal RAM. I've only discovered this potential recently, and now use it for additonal RAM for my new hacks.

Now, i'd like to share one portion of "RAM" that is COMPLETELY universal, for every nes game, and should be one of the most important things to learn first when dealing with the NES.

"$200-$2FF" is the area that deals soley with sprites. Each sprite tile uses 4 bytes to determine what it is. For example, this is for 1 sprite tile, starting at at the address $200-$203

80 10 00 80

$200 = 80 (this is the Vertical Position of the sprite tile)
$201 = 10 (this is the tile from the PPU that will be displayed on the screen)
$202 = 00 (this is the palette to use for the tile)
$203 = 80 (this is the Horizontal Position of the sprite tile)

Here is a great example to mess with this area for yourself. Grab a copy of Megaman 3, and when you are on the title screen, begin messing with that entire area $200-$2FF, and you will see what i'm talking about.

Part 3. A Quick Example Working With Code

I'm going to demonstrate some very quick piece of code, to give you a visual idea of how to work with asm. It's very simplistic.



What you see here, is the Hex Editor of FCEUX, looking at an example ROM.

Look at line $4010. In actuality, to the NES, this is really $4000. This may be confusing to some, but this is because of what is called the "iNES Header" at the beginning of the ROM. At $0 in every single ROM, that is available for emulators, is vital information for all of the NES Emulators. This tells the emulators what kind of mapper it uses, how big it programming and graphics sections are, etc.

Now with that out of the way. Lets look at the example at $4010

A900 8500 A900 8D0001 4C0080

A900 stands for, Load 00, or, LDA #$00
8500 stands for, Store into 00, or, STA $00
A900 stands for, Load 00, or LDA #$00
8D0001 stands for, Store into 100, or, STA $100
4C0080 stands for, Jump to $8000, or, JMP $8000

A quick note on Jumps. To wherever it is you want to jump to in the current bank, take your mouse cursor, and click above the actual spot you want to jump. That is the actual address you want to jump to. Again, 4C0080 stands for JMP $8000. See the A9 at 4010? What is the spot right above it? It's 4000 *aka $8000*

Now, lets look at the example at $4070.

206480 60 A510 C910 D0F9 E610 60

206480 stands for, Jump To Subroutine $8064, or, JSR $8064
60 stands for, Return From Subroutine, or, RTS
A510 stands for, Load register 10, or LDA $10
C910 stands for, Compare for the value 10, or, CMP #$10
D0F9 stands for, if register 10 does not have the value of 10 in it, then branch to a specific location, or BNE #$F9
E610 stands for, increase register $10, or, INC $10
60 stands for, Return From Subroutine, or RTS

i'm really sorry but i have to jet, if anyone would like to finish the examples, or even this one, please do so.

Oh, and this is a MUST HAVE for all 6502 rom hackers! I still use this to this day!

6502 Opcode List
http://acmlm.kafuka.org/uploader/get.php?id=4327

mickevincent
Posted on 10-22-12 10:39 PM (rev. 2 of 10-22-12 11:09 PM) Link | Quote | ID: 152728


Leever
Level: 32

Posts: 163/193
EXP: 205958
Next: 484

Since: 02-26-08

Last post: 3354 days
Last view: 967 days
Ok this topic turned out to be a real chatter room That's good, keep on talking! Hehe.

And thanx for everything Infidel! The part with 200 - 2FF was realy nice. But... it doesnt make any sense at all ... I mean, it did work... a bit..

I tried to just add something to the screen, wathever from the PPU. So I wanted to make $2F0 become 16. I added a write breakpoint to it and it appeared. I changed the LDA to 16 and succes! Something poped up. Problem is something poped up everywhere... and it changed when I walked and it were there on the boss select screen, level intro and everything... wich to me.. well Iam getting dizzy..

Edit - Now I know 2F0 would be the vertical part of it, but since the other once after said 00 I didn't expect anything to come up.

NovaYoshi
Posted on 10-22-12 11:04 PM Link | Quote | ID: 152729


Red Goomba
Level: 15

Posts: 34/35
EXP: 14356
Next: 2028

Since: 02-24-11

Last post: 4195 days
Last view: 1284 days

I wouldn't necessarily say $200-$2ff for sprites is "completely universal" since you're actually allowed to put the sprite info on any page; it just makes sense to put them there since the zeropage is *always* at $000-$0ff, and the stack is *always* at $100-$1ff so if you've got another required thing you might as well put it in the next page and leave a continuous of free RAM after that.
But yeah, you can probably get away with counting on it always being there, and I've always put it there in all my own stuff.

____________________


infidelity
Posted on 10-23-12 01:31 PM Link | Quote | ID: 152731


Fuzz Ball
Level: 66

Posts: 281/968
EXP: 2367478
Next: 94373

Since: 05-24-07

Last post: 955 days
Last view: 811 days
@NovaYoshi, i see your point. :-) Im just speaking from personal expierence, with viewing roms in the hex viewer. @mickevincent, the purpose of my $200 example, was just to demonstrate how to edit a sprite tile's position, image, color.

za909
Posted on 10-23-12 03:11 PM Link | Quote | ID: 152732


Cheep-cheep
Level: 32

Posts: 153/196
EXP: 189013
Next: 17429

Since: 04-27-11

Last post: 3049 days
Last view: 2760 days
Oh, nice to know that $200-$2FF is a general sprite RAM area, it's not just Megaman 3 (I noticed the Tile IDs there and that's how I figured out how to edit the sprite parts of the faces on the stage select)

Is there a sort of "half-assembler" program that simply converts my asm input to hex code? That would be very convenient for hacking if I don't have a complete disassembly of a game.

infidelity
Posted on 10-23-12 04:43 PM Link | Quote | ID: 152733


Fuzz Ball
Level: 66

Posts: 282/968
EXP: 2367478
Next: 94373

Since: 05-24-07

Last post: 955 days
Last view: 811 days
Exactly, za909. Itr not just Megaman 3 that does this. The reason i chose that game for my example, is that the entire area from $200-$2FF is not written to while on the title screen, and, you can see your results cause nearly 50% of the bg is black.

mickevincent
Posted on 10-23-12 10:35 PM (rev. 4 of 10-23-12 11:19 PM) Link | Quote | ID: 152738


Leever
Level: 32

Posts: 164/193
EXP: 205958
Next: 484

Since: 02-26-08

Last post: 3354 days
Last view: 967 days
So I have now written my first asm code that works, and don't makes the game crash It does absolutely nothing... haha, well it does. But not that you can see. I have moved a routine for the health bar in MM4 to another part were I hope there was some free mem, and then I did a return. If I want to, I guess I could code something right after that health bar routine now I just have to move the end of it to the other side of wathever I wanna do there. Feels very good ! Iam very glad now

Edit - So I have actualy managed to do something with it. I have put an letter under the health bar And when you enter the menu, it's gone. It's only there when you are on a stage and fighting. Hehe. Well, at least Iam getting somewhere!

infidelity
Posted on 10-24-12 12:11 PM Link | Quote | ID: 152743


Fuzz Ball
Level: 66

Posts: 283/968
EXP: 2367478
Next: 94373

Since: 05-24-07

Last post: 955 days
Last view: 811 days
Excellent! Thats good that you understand JSR's. Its also good that you know how to write the proper address for the JSR. The very basic things people should learn, is loading and storing, compares, branches, jsr's and jmp's.

mickevincent
Posted on 10-24-12 12:36 PM Link | Quote | ID: 152744


Leever
Level: 32

Posts: 165/193
EXP: 205958
Next: 484

Since: 02-26-08

Last post: 3354 days
Last view: 967 days
Posted by infidelity
Excellent! Thats good that you understand JSR's. Its also good that you know how to write the proper address for the JSR. The very basic things people should learn, is loading and storing, compares, branches, jsr's and jmp's.


Yeah, thanx But wathever I writes to $200-2ff is flickering. I see that it wants to write f8 to many of those places. But the place were mega man is stored is also flickering in the ram, but mega man himself doesnt flicker. I dont get why.

infidelity
Posted on 10-24-12 03:34 PM Link | Quote | ID: 152745


Fuzz Ball
Level: 66

Posts: 284/968
EXP: 2367478
Next: 94373

Since: 05-24-07

Last post: 955 days
Last view: 811 days
Trying to remember off the top of my head with megaman4. The F8's are constantly stored there, so that nothing appears on the screen that isnt supposed to be there. There is very technical asm that goes on, that constantly updates that entire area.

mickevincent
Posted on 10-24-12 04:10 PM Link | Quote | ID: 152746


Leever
Level: 32

Posts: 166/193
EXP: 205958
Next: 484

Since: 02-26-08

Last post: 3354 days
Last view: 967 days
Posted by infidelity
Trying to remember off the top of my head with megaman4. The F8's are constantly stored there, so that nothing appears on the screen that isnt supposed to be there. There is very technical asm that goes on, that constantly updates that entire area.


That was what I was thinking. Hmmm.. also, I took a routine that is for the health bar to write what I want on the level screen. It works and disappears when in menu. But it shows during the intro and for about 1 sec at boss intro screen. Wierd...

infidelity
Posted on 10-24-12 05:22 PM Link | Quote | ID: 152747


Fuzz Ball
Level: 66

Posts: 285/968
EXP: 2367478
Next: 94373

Since: 05-24-07

Last post: 955 days
Last view: 811 days
I never messed with the weapon menu asm extensively, but i assume its an entire separate entity. If it wasnt, an you opened the menu, then megaman, the health bar, enemies/boss, would appear on the weapon menu.

NetSplit
Posted on 10-26-12 08:05 AM (rev. 2 of 10-26-12 08:08 AM) Link | Quote | ID: 152749


Level: 32

Posts: 172/178
EXP: 187986
Next: 18456

Since: 02-26-07

Last post: 2214 days
Last view: 2139 days
Posted by mickevincent
Yeah, thanx But wathever I writes to $200-2ff is flickering. I see that it wants to write f8 to many of those places. But the place were mega man is stored is also flickering in the ram, but mega man himself doesnt flicker. I dont get why.


Assuming you mean that values in the $200-$2FF page are getting moved around rapidly while the game is running, this is meant to constantly change sprite drawing priority. The NES can only draw up to 8 tiles on a single scanline; all other tiles on the same line won't be drawn on the screen. Rapidly rearranging the tiles in memory will change the order in which they're drawn and produce flicker if that limit is exceeded. Flicker is generally a better solution than having the same tiles not be drawn frame after frame. This strategy isn't universal; while the Mega Man games do it, I think Bubble Bobble doesn't, so you can get some sprites fully obscured by others on the same scanline.

Another reason to do flicker is because the order of the sprite tiles determines whether a sprite appears in front of or behind another sprite. Shuffling sprite data will make sprites flicker if they're drawn on top of each other, while keeping it stationary will make tiles consistently appear in front or behind others.


Also, to add to infidelity's earlier explanation, the byte that controls the palette of a sprite tile also controls its mirroring (x and y) and it's background priority (drawn in front of or behind the background).

Edit: But I think you may be saying that the tile you added visibly flickers onscreen, while the rest do not. I'm not sure what you're doing or not doing that would be causing that.

mickevincent
Posted on 10-26-12 10:29 AM (rev. 4 of 10-26-12 11:06 AM) Link | Quote | ID: 152750


Leever
Level: 32

Posts: 167/193
EXP: 205958
Next: 484

Since: 02-26-08

Last post: 3354 days
Last view: 967 days
Posted by NetSplit
Posted by mickevincent
Yeah, thanx But wathever I writes to $200-2ff is flickering. I see that it wants to write f8 to many of those places. But the place were mega man is stored is also flickering in the ram, but mega man himself doesnt flicker. I dont get why.


Assuming you mean that values in the $200-$2FF page are getting moved around rapidly while the game is running, this is meant to constantly change sprite drawing priority. The NES can only draw up to 8 tiles on a single scanline; all other tiles on the same line won't be drawn on the screen. Rapidly rearranging the tiles in memory will change the order in which they're drawn and produce flicker if that limit is exceeded. Flicker is generally a better solution than having the same tiles not be drawn frame after frame. This strategy isn't universal; while the Mega Man games do it, I think Bubble Bobble doesn't, so you can get some sprites fully obscured by others on the same scanline.

Another reason to do flicker is because the order of the sprite tiles determines whether a sprite appears in front of or behind another sprite. Shuffling sprite data will make sprites flicker if they're drawn on top of each other, while keeping it stationary will make tiles consistently appear in front or behind others.


Also, to add to infidelity's earlier explanation, the byte that controls the palette of a sprite tile also controls its mirroring (x and y) and it's background priority (drawn in front of or behind the background).

Edit: But I think you may be saying that the tile you added visibly flickers onscreen, while the rest do not. I'm not sure what you're doing or not doing that would be causing that.


Okey. Matrixz told me yesterday about ram $97 wich is the one controlling $200 - $2FF. It will write $F8 to every 4th adress from $200. I examined $97 yesterday without any of my own codes.


Now I can be totally wrong, but...
It seems that it will say the top adress value of what is used on $200 - 2FF.
Let's say only adress $200 - $215 is used, then $97 will say $15.
So.. I tried to write what I would need it to say, that's E9 with a simple LDA STA but that didn't work cause it looks like something else is also written at the same time so 97$ will jump fast between my value and another one.

I guess it's not as simple as STA something to it, but there's gotta be a way to controll it?


Edit - No I guess I can't just say E9 cause that would also mess things up depending on what is already on the screen. It has to be something like "write to adress+wathever is in 97.." it has to check whats already there.
Pages: 1 2


Main - ROM Hacking - Do you want to learn 6502 ASM? (Think again) New thread | New reply

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

Page rendered in 0.024 seconds. (340KB of memory used)
MySQL - queries: 102, rows: 137/137, time: 0.015 seconds.