News:

11 March 2016 - Forum Rules

Main Menu

Trouble using an asm patcher to put in a rom.

Started by Valkyy, June 17, 2017, 02:27:53 PM

Previous topic - Next topic

Valkyy

My knowledge of asm is just a beginner's level, so i've tried a number of different patchers and none work when i try to patch my asm code into the rom. I'm trying to put this code into a super mario world rom:

LDA #$04
STA $19
RTS

I feel so stupid for asking and I feel like a ton of things are missing but could someone please help lol

(Also if you don't really know what this code is supposed to do, it's supposed to make mario's power up status 4 (a glitched power up) when he hits a block)

Mauron

Where are you trying to put that code? Do you have an address? The assembler needs to know where you want it, or it will default to the beginning of the ROM.

What assembler do you prefer? If you don't have a preference, just pick one - I'm sure any you have tried will work fine once it has the necessary instructions.

Do you have any references you're using that give further information?
Mauron wuz here.

Valkyy

I'm currently using asar v1.50 (Although since this is only snes based, do you know of any patchers that support nes and snes disassembly?)

And also how would I give the code an address? And would address would I have to give it to assign the code to a block? I've looked at about 5 (good) asm tutorials and none say how to actually put something in a rom. Asar says that it is missing org or freespace command? What does this mean?

nesrocks

The org command determines a new "start" address for everything that comes after it. First you do (forgive my sintax, it may be off) ".org $8000" and then everything you write after that will be inserted starting on address $8000. You need to know exactly where to do it because I think it overwrites the existing bytes? So you need to know of unused rom addresses.

Valkyy

how would I find unused addresses in a rom? I mean, there are sites that tell what almost every single address is for in a game, but not every site has that. This is one of the reasons why I chose smw to hack, as smw central is the best ram map of the rom. But let's say I wanted to hack a random nes game (which I did before smw and kind of still do, another reason why I quit to SNES). Data crystal does not specify unused ram addresses, how would I determine this?

nesrocks

For NES games I play them in fceux with the code/data logger running. Turn the logger on, do a power on, hit reset once, and play the entire game and do everything you can imagine the game does, every situation. Different types of deaths, kill enemies in different ways, enter every secret room, get all different endings, pause, etc etc. Make it so you know that every code was executed and every data was read. Then go to the hex editor and every bytes that aren't marked are probably unused, unless you missed something. You can freely use savestates for this process, I think.

Valkyy

alirght, thanks. So just to clarify, lets say in a rom 900-9FF is unused. would I just put .org 900 at the beginning?

KingMike

Just want to be sure...
say 900-9FF were unused, you could insert your code there.
But you know you need a JSR (or JSL, with an RTL at the end of your routine, if you are not in the same bank) from the original code to jump there? (and you would need to be able to disassemble code to find where the appropriate place in the original code to place that jump is)
"My watch says 30 chickens" Google, 2018

nesrocks

See this is why when hacking I prefer to go all out byte code writing on fceux's hex editor. That way I can do it in real time and see it working instantly. I just insert the code but I keep a notes file to know what I altered in case I used an actually used section of the rom (causing later bugs). I also keep many many backups as I work on the same game so I can locate when (and where, by doing file hex compare) the bug started.
So, maybe I'm not the best person to give him advice, as I hack the bad way.  ::)

pianohombre

This code below worked for me, although I don't remember if I used xkas or asar, but those programs are about 90% the same. It's for Super Mario World (I expanded the rom to get it working correctly with following asm).

lorom ;set Xkas to lo-rom mapping

ORG $808F25 ; coin-handling programming starts here
;original author used 2 CLC but this just executed the first statements and did not include flower power save or 99 lives.
autoclean JSL Cheats ; goes to the code I've added in the expanded part of the rom
freedata

Cheats: ; cheat programming starts here
LDA #$09    ; put the number 9 in the accumulator
STA $0F31   ; put the accumulator value 9 in the timer's 100s digit
STA $0F32   ; put the accumulator value 9 in the timer's 10s digit
STA $0F33   ; put the accumulator value 9 in the timer's 1s digit
LDA #$02    ; put the number 2 in the accumulator
STA $0019   ; put the accumulator value 2 in the memory location for currently active item, and 2 corresponds to the cape
STA $0DC2   ; put the accumulator value 2 in the memory location for currently reserve item, and 2 corresponds to the Fire Flower here
LDA #$63    ; put the number 99 in the accumulator
STA $0DBE   ; put the accumulator value 99 in the memory location for current number of lives
RTL ; go back to the next line in the game's main code, so game can continue
"Programming in itself is beauty,
whether or not the operating system actually functions." - Steve Wozniak