News: 11 March 2016 - Forum Rules, Mobile Version
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia

Author Topic: Trouble using an asm patcher to put in a rom.  (Read 822 times)

Valkyy

  • Newbie
  • *
  • Posts: 4
    • View Profile
Trouble using an asm patcher to put in a rom.
« on: June 17, 2017, 02:27:53 pm »
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

  • Sr. Member
  • ****
  • Posts: 386
    • View Profile
Re: Trouble using an asm patcher to put in a rom.
« Reply #1 on: June 18, 2017, 02:43:06 am »
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

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Trouble using an asm patcher to put in a rom.
« Reply #2 on: June 18, 2017, 08:44:07 am »
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

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
Re: Trouble using an asm patcher to put in a rom.
« Reply #3 on: June 18, 2017, 10:09:35 am »
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

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Trouble using an asm patcher to put in a rom.
« Reply #4 on: June 18, 2017, 11:55:27 am »
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

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
Re: Trouble using an asm patcher to put in a rom.
« Reply #5 on: June 18, 2017, 01:13:12 pm »
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

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Trouble using an asm patcher to put in a rom.
« Reply #6 on: June 18, 2017, 05:00:05 pm »
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

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Trouble using an asm patcher to put in a rom.
« Reply #7 on: June 18, 2017, 11:07:04 pm »
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)
Quote
Sir Howard Stringer, chief executive of Sony, on Christmas sales of the PS3:
"It's a little fortuitous that the Wii is running out of hardware."

nesrocks

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
Re: Trouble using an asm patcher to put in a rom.
« Reply #8 on: June 19, 2017, 12:52:32 am »
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

  • Full Member
  • ***
  • Posts: 194
    • View Profile
    • My personal website of short stories and comics
Re: Trouble using an asm patcher to put in a rom.
« Reply #9 on: June 22, 2017, 06:40:34 am »
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).

Code: [Select]
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
One small step for man,
one giant leap for mankind. -Neil Armstrong