Acmlm's Board - I2 Archive - Rom Hacking - Rom ASM question
User | Post |
HyperLamer
Posts: 3766/8210 |
I bet that A+B thing would have activated the debug menu that lets you choose a world and stuff. I wonder if that's the deal with some of the useless code in Pok |
BMF98567
Posts: 700/1261 |
Ever think of downloading an opcode list? It's very useful. I'm sure Zophar's Domain has a couple.
Anyway, JMP is 4C, JML (JMP Long) is 5C. The only difference is JML can jump anywhere in the ROM, thanks to the extra bank byte (ex: $82309F would be 5C 9F 30 82).
If you're jumping a rather small distance, though, BRA would be much more efficient (as d4s mentioned). Just use 80 ##, where ## is the number of bytes you want to jump ahead. Start at 00 and count from the byte immediately after ## (00, 01, 02...). You can also branch in reverse by counting backwards (00, FF, FE, FD...). |
Sukasa
Posts: 207/1981 |
Yea. I just wanted to re-code the coin counter in SMW, and my new code was a number of bytes shorter, and I don't know JMP in machine code |
BMF98567
Posts: 693/1261 |
Originally posted by MathOnNapkins I've seen this in professional SNES roms. And usually it's when you're waiting for a result from hardware divide or multiply. It takes like 8 - 16 cycles or something.
Yeah, and the rest of the time, it indicates a spot where debugging code of some kind used to reside. For example, SMB3 waits for input from controller 2 on the title screen (A+B), but all it activates is a string of 6 NOPs. |
d4s
Posts: 133/325 |
another idea if your number of unused bytes is greater than 2, is to branch to skip the unwanted bytes. it looks cleaner in your sourcecode and only uses 2 bytes.
personally, i always prefer just placing hooks in the program that jump to my subroutines instead of writing my stuff over the games code. its more flexible and you dont have to worry about thight space and such.
|
HyperLamer
Posts: 3754/8210 |
Yeah, but that's not filling empty space, that's delaying. Having space filler actually be executed is rare, but it's generally left as 00 or FF and just ignored. (It mainly depends on your setup... Some flash carts write FF faster than 00 since the empty ROM contains all FF by default; one instruction might be better to have than the other in the event that the game crashes and tries to execute it somehow. On Gameboy/Z80, 00 is NOP while FF is essentially JP $38 (actually RST $38, but that's all it does ), so if you used FF, you could make $38 an error handler and not risk screwing things up.) |
MathOnNapkins
Posts: 1589/2189 |
Originally posted by Parasyte If you are referring to "filler" in code that actually gets executed... (though I can't figure out why you would do this, in such a situation) using NOP is the only real option.
I've seen this in professional SNES roms. And usually it's when you're waiting for a result from hardware divide or multiply. It takes like 8 - 16 cycles or something. |
Sukasa
Posts: 200/1981 |
The reason for that is it was preexisting code and this is my first try working with Machine code. I'd say i'm doing pretty good for it. |
Parasyte
Posts: 364/514 |
If you are referring to "filler" outside of the routines you write, just any byte will work fine. I usually use 0xFF, myself. Just so I can visually see where my free space is, if I ever need it. If you are referring to "filler" in code that actually gets executed... (though I can't figure out why you would do this, in such a situation) using NOP is the only real option. |
Sukasa
Posts: 199/1981 |
Okay, thanks!
I wondered if I was doing something wrong... nothing ever works the first time for me. |
Jathys
Posts: 12/48 |
Set Carry shoul work just fine, as it's not effecting anything but the carry bit... Just in case Carry is checked by another operation when you leave this section of code, I'd use EA.
EA = NOP = No Operation = Nothing at all gets done to anything. |
Apophis
Posts: 385/882 |
Try using NOP (No Operation). |
Sukasa
Posts: 196/1981 |
Hey!
I was writing new code over existing code in my ROM, and I need to know one thing. I'm using smaller code than the original, and I need to know how to add filler to take up space. right now i filled the empty spaces with 38 (SEC). is this the right code? It worked in ZSNES, but I'm wondering if that will work in a ral SNES. if not, could anyone tell me what code to use? I don't want to delete code because JSR and JSL routines would be broken. |
|