Kuribo64
Views: 20,313,766 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
05-19-24 03:05 PM
Guest:

0 users reading Custom behaviour? | 1 bot

Main - General SM64DS hacking - Custom behaviour? Hide post layouts | New reply

Pages: 1 2
isceptul
Posted on 03-09-16 12:25 AM (rev. 2 of 03-09-16 12:25 AM) Link | #68362
I'm starting to familiarize myself with arm asm, and I keep learning more. I want to start making some custom behaviours. Im just not sure where to start. I want to make it without overwriting the current behavior. I'm also not sure if this classifys as custom behavior, but I'm curious how I can make things happen to mario with a button press. Similar to fiachra's flood that lets you hover when you press a button. Thanks in advance.

Fiachra
Posted on 03-09-16 07:57 PM Link | #68377
Have you looked at my examples here?

isceptul
Posted on 03-11-16 01:40 AM (rev. 2 of 03-11-16 01:40 AM) Link | #68418
Thank you, those examples are very helpful. Does it matter where I write the behavior in the games rom?

Fiachra
Posted on 03-11-16 05:43 PM Link | #68430
Yes, it does; if for example you wanted to set Mario's running speed to twice the current speed and the game calculated his speed at address 200, if you placed your hook at address 199 then your speed would be overwritten, rendering your hook useless. If however you placed it at address 201 then the original value gets ignored and yours used instead.

Usually it's not as simple as placing a single hook, there'll be several places where you need to modify the game's behaviour to allow your code to work as intended.

Also there are certain instructions that you can't safely hook over: any branch instruction or "ldr rx =..." instructions. This is because these are relative to their current address and so break when NSMBe moves them.

isceptul
Posted on 03-12-16 01:35 AM (rev. 3 of 03-12-16 01:50 AM) Link | #68438
Alright, im currently attempting to turn marios balloon power up into a fire flower. Do you think this will be very complicated, should I start off coding simpler stuff and work my way up to this? im very new to arm currently.

my theory is that when you press Y, one of the fire balls that bowser spits out will spawn, but im going to need to modify the fire balls behaviour to not target mario, and instead go in a straight line(in the players current facing direction when Y was pressing)

Fiachra
Posted on 03-13-16 10:24 AM Link | #68460
Start with something much simpler, you'll need to understand the basics first. As an example exercise you could try the following:
- Find where the coin count is incremented upon collecting a coin. You can use DeSmuME's RAM search feature to find the (byte) memory location that increments by one each time you collect a coin.
- Next, use No$gba to find the piece of code that sets that memory location using breakpoint: [00000000]! replacing the zeroes with the actual address.
- Next, see if you can write a hook (in C) to spawn three new coins near where Mario is standing (use the SpawnActor method).

isceptul
Posted on 03-13-16 03:28 PM (rev. 2 of 03-13-16 03:38 PM) Link | #68468
2 questions: 1. What program should i use to write C code in? I think on nsmbhd someone said something about using IDA Pro, but i'd rather confirm that its used for this purpose before installing it.

2. So this is what i should be using for step 2? https://gyazo.com/b4c1cb6757208fd686c9e385d89a603c

because im very confused if so

Fiachra
Posted on 03-13-16 04:06 PM Link | #68470
1. Any text editor should be fine. I use Notepad++.

2. Yes, you can find a brief description of the interface here.
Once you've completed step 1 and have your coin address:
- File>Cartridge menu (FileName)>select your SM64DS ROM.
- Let the game load and enter a level which has coins in it.
- In the lower left portion of the window ("data window"), right-click and select "Goto". Enter your coin address - this will let you see its current value which you should see increment as you collect coins.
- Debug>Define Break/Condition>enter "[XXXXXXXX]!" (without the quotes) where XXXXXXXX is your coin address.
- Collect another coin, you should find that the game pauses and the left portion of the screen "code window" shows the instruction which updated the value in the coin address.

isceptul
Posted on 03-13-16 05:23 PM Link | #68472
whenever i enter my address (0209F358) into the define break/condition it has some weird effects. First off, the game doesnt pause when i collect a coin, it either gives me 70 coins randomly, sets my coin count back to 0, and sometimes ill collect a coin and nothing will happen.

Fiachra
Posted on 03-13-16 05:42 PM Link | #68473
Are you typing exactly:
[0209F358]!

isceptul
Posted on 03-13-16 05:45 PM (rev. 3 of 03-13-16 07:25 PM by Fiachra) Link | #68474
im just stupid and didnt put the exclamation mark XD, thanks, i found the value, its 0202A7D4

what are the arguments for SpawnActor? I'm very confused as I dont know the syntax for C

isceptul
(post deleted) #68475

Fiachra
Posted on 03-13-16 07:36 PM Link | #68486
It's explained in SM64DS.h; it needs to be called like:
short int TmpRot[3] = { 0x0000, 0x0000, 0x0000 }; // this will hold the X, Y and Z rotation of the spawned object
int TmpPos[3] = { 0x0000, 0x0000, 0x0000 }; // this will hold the X, Y and Z position of the spawned object

// Use the object DB to get the actor ID which corresponds to the
// object ID of the object that you want to spawn
const short int OBJ_ZZZ_ACTOR_ID = 0xFFFF;

void hook_XXXXXXXX_ov_YY()
{
// calculate your desired rotation and position here,
// assume they're stored in xRot, xPos etc.
short int param01 = 0x0000; // parameter 1 as in SM64DSe
TmpRot[0] = xRot;
// ...
TmpPos[0] = xPos;
// ...
unsigned int spawnedObject = SpawnActor(OBJ_ZZZ_ACTOR_ID, param01, TmpPos, TmpRot);
}

isceptul
Posted on 03-13-16 08:47 PM (rev. 3 of 03-13-16 08:48 PM) Link | #68495
so would this be correct?

short int TmpRot[3] = { 0x0000, 0x0000, 0x0000 }; // this will hold the X, Y and Z rotation of the spawned object
int TmpPos[3] = { 0x0100, 0x0100, 0x0100 }; // this will hold the X, Y and Z position of the spawned object

// Use the object DB to get the actor ID which corresponds to the
// object ID of the object that you want to spawn
const short int OBJ_ZZZ_ACTOR_ID = 0x0025;

void hook_0202A7D4_ov_YY()
{
// calculate your desired rotation and position here,
// assume they're stored in xRot, xPos etc.
short int param01 = 0x0000; // parameter 1 as in SM64DSe
TmpRot[0] = xRot;
TmpRot[1] = yRot;
TmpRot[2] = zRot;
TmpPos[0] = xPos;
TmpPos[1] = yPos;
TmpPos[2] = zPos;
unsigned int spawnedObject = SpawnActor(OBJ_ZZZ_ACTOR_ID, param01, TmpPos, TmpRot);

Fiachra
Posted on 03-13-16 09:49 PM Link | #68499
Yes.

isceptul
Posted on 03-14-16 12:48 AM Link | #68518
out of curiosity, how would i be able to find the instruction that tells mario to bonk when he hits a wall? with coins, its easy, because your coins go up by 1, and i assume its the same method for 1 ups, but what if i wanted to find the code that made mario bonk when he hit a wall?

Fiachra
Posted on 03-14-16 07:49 PM Link | #68540
Easiest way would probably be to perform a long jump against a wall but pause whilst midair and place a breakpoint on the method 0x020BEF2C. This method is called to change Mario's animation with r0 containing the action id eg. for walking it's 0x48 or for running it's 0x3F. I have documented most of them in SM64DS.h. Once the breakpoint is hit upon hitting the wall you can find where it's called from by looking at the value in r14.

isceptul
Posted on 03-15-16 05:10 AM (rev. 3 of 03-15-16 07:21 PM by Fiachra) Link | #68607
So I could use this for any animation change such as ground pounding or ducking? This would actually be really cool to mess around with. Instead of ground pounding I could modify it to make mario spin mid air as if he bounced off a spin drift or something.

im just curious if i can put in cheat codes in no$gba debugger because i have a 100% cheat code that would make debugging a million times easier. (action replay)

isceptul
(post deleted) #68609

isceptul
(post deleted) #68610
Pages: 1 2

Main - General SM64DS hacking - Custom behaviour? Hide post layouts | New reply

Page rendered in 0.031 seconds. (2048KB of memory used)
MySQL - queries: 28, rows: 234/234, time: 0.012 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.