ROM Hack Question [Cheat] [Code Creation] Is there a way to set a value to specified address from resister's value

Jun_Bon_Jovi

New Member
OP
Newbie
Joined
Apr 24, 2020
Messages
3
Trophies
0
XP
50
Country
Japan
Hello,
I'm a beginner in creating switch games cheat codes, and reading "SX OS Cheat Hacker Guide".

So now, I want to make a code like this,
  1. Get a value from an address, and set the value to resister f.
    • it would be "5TMFI0AA AAAAAAAA"
  2. Set resister f's value to a specified address.
    • idk how to write..
Thank you.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,796
Trophies
3
XP
28,424
Country
United Kingdom
If someone asks me to set something from a resistor I assume they want to be able to dial in a code from an external source (be it a proper decade setup or an analogue stick).
If someone wants me to set something from a register (that being a little dedicated area of memory within a computer that is used for operations or system states) that is a different matter entirely. It sounds like you are going for this.

Reading the guide it seems the SX OS engine peeps have also provided the would be cheat maker with a selection of registers of their own as well. Do you mean these?

If so it looks like you have two options, possibly 3 if the new address you want to set is mathematically related and you can do some maths on it. Here code type 4 is what you want unless you have a memory address elsewhere in memory
# Code Type 4: Load register with value

400R0000 VVVVVVVV VVVVVVVV

This code type will load one of the registers with a specific value

R = Register to be filled
V = Value to be put in register

# Code Type 5: Load register with value from memory

5TMRI0AA AAAAAAAA

T = Width of value to be loaded from memory (1/2/4/8)
M = memory type (0 = main nso, 1 = heap)
R = Load from register index
I = Load from register flag, set to 1 to load from register R instead of address A
A = Address relative to (M)
 

Jun_Bon_Jovi

New Member
OP
Newbie
Joined
Apr 24, 2020
Messages
3
Trophies
0
XP
50
Country
Japan
Thank you for replying :D

But actually, I'm not thinking about what you guessed.

Let me give an example,
Here is an action game, and a character in the game has "current HP" and "max HP".
And "max HP" gains by level up.
Then, I want to set the current HP to max always dynamically.

Like this,
1. get max HP's value, and store it to an resister
2. set current HP's value from the resister's value(max HP)

Is this impossible by any code types...?
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,796
Trophies
3
XP
28,424
Country
United Kingdom
Is there a reason for this? The only problems typically I ever encounter with setting values in health is when it is set too low (late game enemy then hits for say 999 when it is being held at 700 or something and thus you get a dead character even if max is way beyond that, or if the game has some kind of low HP frenzy type mode), or when they are doing some kind of mirrored value cheat prevention. Setting it to max that the memory can store, or something similar, tends to be just fine.

Could you read a value from memory and back in again (without doing some kind of program mod)? Sure.
The trouble will likely come with data types -- if the health uses bog standard unsigned however many bit value but the max health is either undefined (say by being created as and when it needs it) or something else then a copy has no reliable/meaningful idea.

Does health in this game regen out of battles? If so it might be possible then to detect when you get in battle and then grab a value then to use for the rest of the battle.
If doing it on a system that is nice to debug I would probably also look at the behaviours of potions and see if I could mimic something there, however that would be a serious trick to pull off on the Switch compared to something with proper debug tools and a nice emulator.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: Still thinking about a deep freezer so I can hide psis limbs