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

Author Topic: How to modify a ROM value at run-time? (NDS)  (Read 391 times)

rodyt

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
How to modify a ROM value at run-time? (NDS)
« on: August 11, 2020, 09:39:29 pm »
The ROM that I am trying to modify stores instructions for how to load from or save to save states. A value is stored in 2 bytes that equals to the character ID. The game then uses this character ID to save the data for that character. For example, a (hex) value of 0006 will mean the game tries to save/load data for character with ID = 0006.

At runtime, I insert an Action Replay code to change the character's ID to another value, say, 002D. However, when I save the game, the game still tries to save the data for the character with the old ID (0006). Since this ID has now been overridden by the AR code, yet the value in ROM has not been updated, the save becomes corrupted.

The question I'm asking is: How can I modify the value in ROM at a later time so that it corresponds with the new value I have specified in my Action Replay code? (i.e. change the value in ROM to 002D as well)

Note: I only want to enable the AR code during certain parts of the game, thus I cannot just change the value in ROM (which would change the value permanently). I also don't want to make another copy of the ROM for every character ID I want to override. What are my options here?

 

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 471
  • I am the baldest romhacker
    • View Profile
Re: How to modify a ROM value at run-time? (NDS)
« Reply #1 on: August 12, 2020, 07:51:59 am »
Have you tried to store this value in ram and change code to read it from there?
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

FAST6191

  • Hero Member
  • *****
  • Posts: 2896
    • View Profile
Re: How to modify a ROM value at run-time? (NDS)
« Reply #2 on: August 12, 2020, 02:50:55 pm »
What sort of edit is this?
Sometimes I find it easier to dump a save and fiddle with it in an emulator before firing it back to a flash cart/original game.

Anyway button activators are available for DS cheats -- most do a if this = this to the controller register(s) then do this. Make one or more odd button combos for your choice of ID and activate them accordingly to overwrite.

rodyt

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: How to modify a ROM value at run-time? (NDS)
« Reply #3 on: August 12, 2020, 05:26:23 pm »
@Fast6191 Good idea. Thanks for the suggestion

@Cyneprepou4uk How would I change the code to make it read from there instead? (I have no idea which process or which method is responsible for saving)

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 471
  • I am the baldest romhacker
    • View Profile
Re: How to modify a ROM value at run-time? (NDS)
« Reply #4 on: August 12, 2020, 08:58:59 pm »
Set a read breakpoint to the address with this value in order to find the code. Then use your nds assembly knowledge to change it.
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension