Pages: « 1234 »
Posted on 11-28-12, 07:02 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2933/4434
Since: 06-08-11
If you want to get the value of a register, you can read r0-3 as parameters to the function.
void hook_02xxxxxx(int r0, int r1, int r2, int r3) {
    ...
}


You can't read the other regs like that because only r0..3 are used as params. If there's more than 4 params, the rest goes in the stack.

To read the others, or write, you'll need to write the hook in ASM. You can call C/C++ functions from ASM. Also keep in mind that hooking destroys R14. Also hooks of type "hook" push all registers to stack so you won't be able to modify them, use a "repl" instead.
Posted on 11-29-12, 02:23 pm
Shyguy


Karma: 120
Posts: 42/90
Since: 07-10-12
Is it possible to insert some custom code everywhere? Also inside a function?
Posted on 11-29-12, 02:31 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2934/4434
Since: 06-08-11
Yes, absolutely everywhere as long as it's ARM code (I'll add Thumb support sometime soon). When you do a hook, NSMBe replaces the instruction at the address you entered with a branch to your code.
Posted on 11-29-12, 02:54 pm (rev. 6 by  Gericom on 11-29-12, 04:08 pm)
Shyguy


Karma: 120
Posts: 43/90
Since: 07-10-12
I get this error:
Error: garbage following instruction

Here is my asm code:
repl_02088098:
LDR     R0, [R9,#0x28]
CMP     R9, #217AB94
MOVEQ   R0, #0

(I have manually add the black. I will fix this soon.)

The 'LDR R0, [R9,#0x28]' is from the original asm code. Because it is replaced of course. The remaining part of the function have to be:
if(R9 == 0x0217AB94)
{
     R0 = 0;
}

I think I fixed it, but I get now an error in nsmb editor.


Edit: I know what's the problem, my rom is made with ndstool. And that causes problems with saving the arm9. Can you add support for patching the arm9.bin file? That would be nice!

I tried with a clean rom, but I still get the error in the spoiler.

How did you compile your mkdshax????????????
Posted on 11-29-12, 04:33 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2935/4434
Since: 06-08-11
Posted by Gericom
CMP R9, #217AB94

You're missing the "0x".
Also, immediate values in data processing instructions are limited to 8bit. To do that you'd need to do something like:
repl_02088098: LDR R0, [R9,#0x28] LDR R12, =0x0217AB94 CMP R9, R12 MOVEQ R0, #0

And you're missing "BX LR" at the end.

I'll have a look at that error now, but afaik I'm not getting it. Are you really sure you're using a clean ROM?
Posted on 11-29-12, 04:37 pm
Shyguy


Karma: 120
Posts: 44/90
Since: 07-10-12
Posted by Dirbaio
Posted by Gericom
CMP R9, #217AB94

You're missing the "0x".
Also, immediate values in data processing instructions are limited to 8bit. To do that you'd need to do something like:
repl_02088098: LDR R0, [R9,#0x28] LDR R12, =0x0217AB94 CMP R9, R12 MOVEQ R0, #0

And you're missing "BX LR" at the end.

I'll have a look at that error now, but afaik I'm not getting it. Are you really sure you're using a clean ROM?

Yes, I am sure!
Posted on 11-29-12, 04:38 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2936/4434
Since: 06-08-11
And does the error happen with *any* code you're trying to compile and patch?
Weird.
Posted on 11-29-12, 04:41 pm (rev. 1 by  Gericom on 11-29-12, 04:42 pm)
Shyguy


Karma: 120
Posts: 45/90
Since: 07-10-12
Posted by Dirbaio
And does the error happen with *any* code you're trying to compile and patch?
Weird.

I tried your mkdshax, and then the error does also appear. Do you want to have my files?
Posted on 11-29-12, 05:26 pm (rev. 1 by  Dirbaio on 11-29-12, 05:27 pm)
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2937/4434
Since: 06-08-11
Ok. New build is up. Fixes the error when ASM hacking MKDS.
EDIT: Now it fails when hacking NSMB. Yay.
Posted on 11-29-12, 05:42 pm
Shyguy


Karma: 120
Posts: 46/90
Since: 07-10-12
Posted by Dirbaio
Ok. New build is up. Fixes the error when ASM hacking MKDS.
EDIT: Now it fails when hacking NSMB. Yay.

Yay! It works!
Posted on 12-06-12, 03:51 pm
Porcupo
Captivated by Persona 4

Karma: 595
Posts: 233/306
Since: 01-06-12
Uhm, sorry if this is a very dumb question, but how can you actually open/load this into NSMB Editor?
I haven't seen here how to do it...
_________________________
I apologize to everyone for my horrible English.
Posted on 12-06-12, 05:46 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2945/4434
Since: 06-08-11
Posted by RiksKing
Uhm, sorry if this is a very dumb question, but how can you actually open/load this into NSMB Editor?
I haven't seen here how to do it...

I just wrote tutorial How ASM hacks are setup, hope it helps!
Posted on 12-06-12, 07:04 pm
Porcupo
Captivated by Persona 4

Karma: 595
Posts: 234/306
Since: 01-06-12
Posted by Dirbaio
Posted by RiksKing
Uhm, sorry if this is a very dumb question, but how can you actually open/load this into NSMB Editor?
I haven't seen here how to do it...

I just wrote tutorial How ASM hacks are setup, hope it helps!

Wow, thank you very much. I'm going to try this out ASAP
_________________________
I apologize to everyone for my horrible English.
Posted on 12-06-12, 08:06 pm


Karma: 3667
Posts: 1678/2112
Since: 06-28-11
goombaupdate (0x0209EF98) is not just the frame update of the goombas. It is some kind of redraw function for a lot of 2d sprites in the game. (Goomba, Koopa, Fireball, breaking bricks, ...)
Just in case anyone wants to know.
Posted on 12-06-12, 08:11 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2946/4434
Since: 06-08-11
Yeah, I know.
In fact the symbols.x file in the template is quite outdated. If you look at the one in the NSMBCR repo, that function is named "enemyActor_execute".

It reads a variable from the class that is some kind of "state" and executes a virtual function from the class depending on it.
That "state" variable is used for the "dying" states when stomped, hit with a fireball, etc etc.
Posted on 12-08-12, 11:32 am (rev. 1 by  Gericom on 12-08-12, 11:57 am)
Shyguy


Karma: 120
Posts: 47/90
Since: 07-10-12
@ Dirbaio
Can you work on the thumb code? You only need to make a thumb instuction instead of an arm instruction. Since thumb can link to arm don't the compiler (makefile) even have to be changed.

If you can make it, I can add more tracks to mkds!
Posted on 12-08-12, 11:34 am
☭ coffee and cream


Karma: 9941
Posts: 819/2663
Since: 06-26-11
Posted by Gericom
@ Dirbaio
Can you work on the thumb code? I need it. If you can make it, I can add more tracks to mkds!

Why don't you do it yourself? I thought you were a professional programmer?

I also think that Dirbaio has better things to do. I can't speak for him though, so we'll see when he comes here.
_________________________
Kuribo64 - RH-fucking-cafe - Kafuka

zrghij
Posted on 12-08-12, 01:55 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2970/4434
Since: 06-08-11
Well, it isn't at the top of my priority list because there's very very few Thumb code in NSMB.
I will do it at some point though. First I should reorganize how existing hooks work
Doing Thumb hooks could get tricky because of changing modes but it's doable
Posted on 12-08-12, 03:20 pm
Shyguy


Karma: 120
Posts: 48/90
Since: 07-10-12
Posted by Dirbaio
Well, it isn't at the top of my priority list because there's very very few Thumb code in NSMB.
I will do it at some point though. First I should reorganize how existing hooks work
Doing Thumb hooks could get tricky because of changing modes but it's doable

You could do it like this:
thook_02xxxxxx:
trepl_02xxxxxx:
tnsub_02xxxxxx:
or something like that.
Posted on 12-09-12, 11:40 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9030
Posts: 2980/4434
Since: 06-08-11
New update for the template!

- Fixes "make clean" not removing everything.
- Updated symbols.x
- Added ram viewer to the debug screen! Use start/select to switch, and arrow keys to navigate!
Pages: « 1234 »