Pages: 12 »
Posted on 08-22-11, 06:49 pm (rev. 7 by ImageBot on 11-21-16, 02:08 am)
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 682/4457
Since: 06-08-11
UPDATE: It doesn't work with latest devkitARM because the Makefile is outdated.
Grab the Makefile from the ASM hack template instead, and it will work!
===

This nice hack allows you to draw tiles while you're playing.


Controls
- Draw with the touchscreen to place tiles.
- Hold Down and draw to erase tiles.

How to compile.
IMPORTANT: It doesnt work with latest DevkitPro! I'm already aware of this and I'll fix it sometime in the future
- You need the DS homebrew toolchain installed (devkitARM, libnds, downloadable at http://devkitpro.org)
- Unzip the zip in a path that does not contain spaces. For example: C:/Users/Dirbaio/Documents/nsmb is good, but C:/Documents and Settings/... is NOT good.
- Put a NSMB U ROM in that folder. THE HACK IS MADE FOR THE U REGION!
- Open the ROM in NSMB Editor.
- Go to the Tools tab, and then click "Run Make and insert"
- A black window should open and close itself. If you get any errors and a "Press any key to continue" message, then there's something wrong. Check that you've properly installed the *latest* devkitARM.
- Open the ROM and play!

Some stuff

You might want to take a look at the source code to know how it's done. It's pretty simple because it's coded in C++.
Also, I recommend you set levels to display on the bottom screen when using this. Makes drawing much easier ;D

Download
http://nsmbhd.net/get.php?id=41
Posted on 08-22-11, 06:53 pm (rev. 1 by ImageBot on 11-21-16, 02:08 am)
Banned for being a complete idiot.

Karma: 529
Posts: 222/987
Since: 07-09-11
Found download link here.
Posted on 08-22-11, 06:54 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 683/4457
Since: 06-08-11
LOL, I forgot to put it. I'll put it in
Posted on 08-22-11, 07:19 pm
Roy Koopa


Karma: 4011
Posts: 475/2722
Since: 06-26-11
OMG! This is epic Haveto look into the source
_________________________
See a lots of creative DS Hacking here
If you want to support me, you might check out my Patreon Page : )
Posted on 08-23-11, 05:17 am (rev. 2)
Porcupo
Did you win the game?

Karma: 211
Posts: 76/322
Since: 06-28-11
Wow This is really cool.
Two VERY minor things though:

I think that it would have been epic if you included a lcdMainOnBottom in the hook code.(or have it in there but commented out)
Also I think that in the instructions it should have stated to open the NSMBe 5.2 on windoze and click Make and insert.

REALLY COOL ASM HACK

btw: Thanks for sharing that linker script with us!
Posted on 08-23-11, 10:32 am
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 688/4457
Since: 06-08-11
No problem

I did think about the lcdMainOnBottom thing. Though i think the "good" way of doing it is somehow figure out how NSMB reads the "display on bottom screen" bit on the entrances and force it to be true. That way you wont get the saved powerup activating when you touch its area.
That's why I didn't do it yet.

I still need to make a tutorial/explanation of how does stuff like hook_02xxxxx works.
Posted on 08-23-11, 11:25 pm (rev. 1)
Porcupo
Did you win the game?

Karma: 211
Posts: 77/322
Since: 06-28-11
Well I understand how hock_02BLAH(){}
I think that currently because you say it is buggy that you should not document it.
If you have to ability to ASM hack and understand the risk's currently you will automatically understand what those hook functions mean.

Thanks for that offset in that nonintendo.cpp, the one that you modify to remove minigames and the nintendo sign.

Two questions though
Can we use grit and background.cpp?
What is a hock for when the level has finished loading? (So we can instantly modify it)

Also, Look at what I did (tiletest.cpp):

xD no sprites...
Posted on 08-23-11, 11:27 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 706/4457
Since: 06-08-11
yay, cool

Be careful though: spriteblock += 4. When doing pointer arithmetics, that adds 4 times sizeof(int), not 4 bytes, so you're adding there 16 bytes.

Also, int's are 4 bytes. I think you wanted to use u16.


I cant check the hook value right now because I'm in Linux and IDA Pro is windows-only
(btw, the IDA Pro DB in the uploader is impossible to download because a bug in ABXD which is being fixed, i hope.

Will post it tomorrow
Posted on 08-23-11, 11:41 pm (rev. 2)
Porcupo
Did you win the game?

Karma: 211
Posts: 80/322
Since: 06-28-11
Posted by Dirbaio
Be careful though: spriteblock += 4. When doing pointer arithmetics, that adds 4 times sizeof(int), not 4 bytes, so you're adding there 16 bytes.

LOL xD, but when using ASM you must do a +=4(I think), I am used to ASM too much when ASM hacking.

Is this better?

#include
#include "nsmb.h"
u16* levelblocks = ((u16*)0x0208B168);
u16* levelblocksizes = ((u16*) 0x0208B130);
void hook_0211f840(MarioActor *athis)
{
u16* spriteblock=levelblocks[7];
*spriteblock=0xFFFF;
spriteblock+=1;
*spriteblock=0xFFFF;
}

Also I think 104MB is a bit too much for me to download, (and I do not want to pay for IDA Pro at the moment.)
Could we compress 5 times? (xD kinda silly but if you do it first with .zip then .7z then .tar.bz2 then .tar.gz it will reduce the size ( I have not downloaded this so if this is already done, I did not know about it))
Posted on 08-23-11, 11:50 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 708/4457
Since: 06-08-11
True, I haven't thought about compressing it.
Will see what I can do.

Also, here's a more standard way of doing the pointers. Requires less casts. It's way cleaner. Also, be careful because block sizes are 32bit.

u16** levelblocks = ((u16**)0x0208B168);
u32* levelblocksizes = ((u32*) 0x0208B130);
void hook_0211f840(MarioActor *athis)
{
levelblocks[7][0] = 0xFFFF;
levelblocks[7][1] = 0xFFFF;
}
Posted on 08-24-11, 04:41 pm
Fuzzy
Full mod

Karma: 1183
Posts: 122/785
Since: 06-28-11
I tried to make a simple modification to set Mario's position to the stylus position, but it doesn't work. I just changed part of your code to this:

void hook_0211f840(MarioActor *athis) {     if(*penDown)     {         int x = *camX + *penX;         int y = *camY + *penY;         athis->xPos = x;         athis->yPos = y;     } }

Posted on 08-24-11, 04:59 pm (rev. 1)
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 712/4457
Since: 06-08-11
void hook_0211f840(MarioActor *athis) { if(*penDown) { int x = *camX + *penX; int y = *camY + *penY; athis->xPos = x<<12; athis->yPos = -y<<12; } }

Mario's position (and all sprites) is 20.12 fixed point number. So to convert from int to fixed you have to <<12.
And also, the Y position is flipped. I guess that's the difference between "screen coordinates" and "world coordinates".

(I haven't tested it, but it should work this way)
Posted on 08-24-11, 05:07 pm
Fuzzy
Full mod

Karma: 1183
Posts: 123/785
Since: 06-28-11
Thanks! It works, but is pretty much unusable since the game constantly tries to update the camera position. I'll see if I can write some code to fix this.
Posted on 08-24-11, 05:10 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 713/4457
Since: 06-08-11
You can make Mario teleport only when the pen goes down. Something like


bool oldPenDown = false; void hook_0211f840(MarioActor *athis) { if(*penDown && !oldPenDown) { int x = *camX + *penX; int y = *camY + *penY; athis->xPos = x<<12; athis->yPos = -y<<12; } oldPenDown = *penDown; }
Posted on 08-24-11, 05:24 pm
Fuzzy
Full mod

Karma: 1183
Posts: 124/785
Since: 06-28-11
Well, my idea was to save the camera position when the pen goes down, then rewrite it every frame, but it appears that the game only writes to those values and doesn't actually use them.
Posted on 08-24-11, 05:47 pm
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 10010
Posts: 714/4457
Since: 06-08-11
Yeah...
NSMB does that a lot. To actually modify the camera position, one would have to trace back where those values are being written. I think the camera data is calculated on the fly and then passed to other functions that actually do the scrolling, so it's not that easy to modify.
Posted on 08-24-11, 10:58 pm (rev. 2)
Porcupo
Did you win the game?

Karma: 211
Posts: 82/322
Since: 06-28-11
I do not know how or why but I just got rid of all of the power-ups. (and sprites, but I know why there are no sprites)
You can hit the power-up block but then nothing will come out.
(Ignore the comments(Or try to change them to something more understandable))
#include<nds.h> #include "nsmb.h" u16** levelblocks = ((u16**)0x0208B168); char** levelblocks8 = ((char**)0x0208B168); u32* levelblocksizes = ((u32*) 0x0208B130); bool* penDown = (bool*)0x020888E5; u8* penX = (u8*) 0x020888E6; u8* penY = (u8*) 0x020888E7; u32* camX = (u32*) 0x020ca2ec; u32* camY = (u32*) 0x020ca2e4; void hook_0211f840(MarioActor *athis) { levelblocks[7][0] = 0xFFFF; levelblocks[7][1] = 0xFFFF; levelblocks[1][6] = 0x0008; // tileset levelblocks[1][3] = 12; //Background levelblocks[1][9] =16; //foreground levelblocks[3][1] = 12;//Background Tile levelblocks[3][2] = 12;//Background Palette levelblocks[4][2] = 8;//Tileset palette levelblocks[5][1] = 16;//Forground Tiles levelblocks[5][2] = 16; // Forground palette }


EDIT: Added [.code] tags
Posted on 08-29-11, 01:20 pm
Roy Koopa
The guy who does things.

Karma: 12694
Posts: 67/2796
Since: 07-01-11
Hey, this is awesome, it would be fun to implement this into a hack! Imagine the possibilities!
New Super Mario Bros.: Clone Tag Team 1+2 / New Super Mario Advance + Take 2 / Super Mario: Endless Earth
My two greatest assets have been mental stability and being, like, really smart.
Posted on 08-29-11, 01:22 pm
Roy Koopa


Karma: 4011
Posts: 568/2722
Since: 06-26-11
Posted by MARIOFANATIC64
Hey, this is awesome, it would be fun to implement this into a hack! Imagine the possibilities!


Minecraft Mario xD
_________________________
See a lots of creative DS Hacking here
If you want to support me, you might check out my Patreon Page : )
Posted on 09-10-11, 12:10 am
☭ coffee and cream


Karma: 10415
Posts: 117/2768
Since: 06-26-11
This hack made me think of a possible variant, similar to Reuben and Lunar Magic's 'direct map16 access'. Basically, the editor would let one paint level tiles directly, instead of using preset objects.

I once tried to find how to do that, but was unable to track where the level block arrays were being written to, and quickly gave up. However, you seem to know a lot more than me about NSMB's internals, so perhaps it can be done

Perhaps NSMBWii would also support it (and that would please Treeki), but that's not our department
_________________________
Kuribo64 - RH-fucking-cafe - Kafuka

zrghij
Pages: 12 »