Dirbaio |
Posted on 12-06-12, 05:44 pm (rev. 4 by RicBent on 11-03-18, 11:11 am)
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10071 Posts: 2944/4458 Since: 06-08-11 |
You will need
About the ASM patch templateThe template contains everything you need to start creating ASM hacks. Here's an explanation of what each file does.
How to compile an ASM hackPlace a ROM in the template folder (NOT in data/ or source/. In the main folder). Also the path to the template may not include spaces ("C:\this\is\very wrong\" "C:\this\works\"). Open it with NSMB Editor. Go to the Tools tab and click "Run make and insert". Yes, it's that easy. You will see some new files appear when you compile your hack:
When you run "make clean" all these temporary files will be deleted. (except the bak/ folder). How to make an ASM hackNow comes the cool part! ASM hacks are made with hooks. You hook an address in the game's code, this means the code in your hook gets executed when the code you hooked gets executed. There are multiple types of hooks:
To create a hook, simply make a function, or a label in ASM, with the hook name. See examples below. Example 1: replacing getCoin() functionSo... We know the function at 02020354 is called when Mario gets a coin. It increments the coin counter and gives an 1up if there's 100 coins. It basically "gives a coin to Mario". Now, what if we replace that function with an empty function, hmm? void nsub_02020354() { } We put that code into a file named noCoin.cpp in the source folder and compile... Now what happens? When Mario gets a coin, the coin counter doesn't go up! Yay! Example 2: calling a function from the game's codeNow let's make Mario get a 1up every time he gets a coin! extern "C" { void get1up(int something, int somethingElse); } void nsub_02020354(int something) { get1up(8, something); } The first part of the code "declares" that there's a function named get1up() so the compiler allows us to call it. The compiler already knows the address for the function because it's listed in symbols.x. The "something" is a value the get1up function needs. If we look at getCoin in IDA Pro, we see that it's passed as a param to getCoin, and getCoin passes it to get1up. We don't really care what it really is, we just pass it around and it will work. (If you're curious, I think it's the player number. In singleplayer it's always 0) Now every time Mario gets a coin, he gets a 1up instead! |
Powerline |
Posted on 06-26-13, 09:39 am
|
Karma: 228 Posts: 12/22 Since: 10-18-12 |
I don't know how symbols.x works, but is it possible to make GCC believe we derived a class from any other classes such as the enemy or player base classes? Kinda like how Microsoft Component Object Model (COM) works thanks to the vtable being the first data member in the class.
Even if we cheat and have a dummy class call the original classes, getting the connection (I don't know if it is CONNECT that is displayed on the debug screen) to other objects for free is intriguing! |
Dirbaio |
Posted on 06-26-13, 11:28 am
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10071 Posts: 3456/4458 Since: 06-08-11 |
What you say is very possible. Treeki already did that with nsmbw and I'm halfway done with it in NSMB.
Basically you have to put the mangled names for the vtables and functions, then make the headers for the classes and you can then subclass them. |
Powerline |
Posted on 06-26-13, 12:28 pm
|
Karma: 228 Posts: 13/22 Since: 10-18-12 |
Posted by Dirbaio What you say is very possible. Treeki already did that with nsmbw and I'm halfway done with it in NSMB. Basically you have to put the mangled names for the vtables and functions, then make the headers for the classes and you can then subclass them. Sounds like a lot of work. But it is worth it in the end for sure. I was trying to do mangled names but several virtual functions are very annoying to decode, and then there are the two destructors for each derived class, both handling either delete ClassPtr; or delete [] ClassPtr; ... I think. |
Dirbaio |
Posted on 06-26-13, 12:53 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10071 Posts: 3458/4458 Since: 06-08-11 |
Yeah there are two destructors. First one destructs, second one destructs and frees. I think there's even a third one that's called from the derived classes destructors.
I think that's not a problem when making our own classes, GCC also follows that convention. |
Arisotura |
Posted on 06-26-13, 12:54 pm
|
☭ coffee and cream
Karma: 10542 Posts: 997/2780 Since: 06-26-11 |
Dirbaio |
Posted on 06-26-13, 02:39 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10071 Posts: 3460/4458 Since: 06-08-11 |
It is different in case of the Wii (PPC compiler) but on ARM it seems to be compatible. I still haven't seen anything that could cause incompatibilities.
|
snake block |
Posted on 09-06-13, 10:38 am (rev. 1 by snake block on 09-06-13, 04:30 pm)
|
a
Karma: 1589 Posts: 82/1290 Since: 02-12-13 |
I can't do it!
I put the ASM in the folder with all the files because there is no "main" folder and do it but instead it says "make" is not a valid command in cmd. EDIT: Accid. said that I put the asm in the folder with all the files. I meant, i put the rom in the folder with the asm hack files. |
Dirbaio |
Posted on 09-06-13, 10:41 am (rev. 1 by Dirbaio on 09-06-13, 10:41 am)
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10071 Posts: 3723/4458 Since: 06-08-11 |
You need to put the source files in source/ and install DevkitARM.
|
snake block |
Posted on 09-06-13, 12:19 pm (rev. 7 by ImageBot on 11-21-16, 02:37 am)
|
a
Karma: 1589 Posts: 84/1290 Since: 02-12-13 |
What source files and where to install DevkitARM (Can not find it )
EDIT: OK, done downloading devkitARM. is version r24 fine? And again, what source files? EDIT2: Tried putting the devkitARM files in the source folder so it looks like: B ut it still ain't no gonna work! |
Dirbaio |
Posted on 09-06-13, 05:49 pm (rev. 1 by Dirbaio on 09-06-13, 05:49 pm)
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10071 Posts: 3724/4458 Since: 06-08-11 |
No.
You just need to install DevkitARM. Use the automated installer and install it: http://sourceforge.net/projects/devkitpro/files/Automated%20Installer/devkitProUpdater-1.5.3.exe/download You just need to have it installed, you don't need to do anything with its files. Then download the ASM Patch Template, put the ROM in the main folder, and the source files in the "source" folder. Then open the ROM with NSMBe, go to Tools tab and click "Run make and insert". |
snake block |
Posted on 09-07-13, 04:34 am (rev. 1 by snake block on 09-07-13, 04:51 am)
|
a
Karma: 1589 Posts: 95/1290 Since: 02-12-13 |
OK, but will it work with the community remix asm? (Don't worry, I am not gonna use it since I don't have any project to use it in just gonna test it)
EDIT: Oh gosh it works now but I still have a problem which I will ask at the Community Remix forum. Thank you Dirbaio! |
Domich150 |
Posted on 04-22-14, 06:31 pm (rev. 1 by Domich150 on 04-22-14, 06:31 pm)
|
Newcomer
Karma: 42 Posts: 8/9 Since: 12-21-12 |
I followed the steps in the first post,but when I clicked on "run make and insert",it gave me an error:
My rom's region is U,I have the latest devkitpro release,and I have the latest NSMBe build (build 337). It gives me an error even when I don't add anything. It also doesn't create the files it should. What have I done wrong? |
Dirbaio |
Posted on 04-23-14, 11:02 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10071 Posts: 4018/4458 Since: 06-08-11 |
I'm... not sure.
There has been a new devkitPro release on April 4th (r42), which updates GCC and other stuff, maybe it has broken the ASM patch template. Try either of these two things, maybe they help: 1. Remove -lgcc in the Makefile or: 2. Install dekvitPro r41 instead (I don't know if there's any easy way to install older versions of DKP though ) (but if you do add the -lgcc back or it won't work) I'll try to check what's wrong and update the template ASAP, in the meantime you could try these two solutions. |
Domich150 |
Posted on 04-24-14, 08:59 pm
|
Newcomer
Karma: 42 Posts: 9/9 Since: 12-21-12 |
I removed -lgcc in the Makefile and now it works. Thanks!
|
koopa95 |
Posted on 04-30-14, 04:09 pm (rev. 2 by koopa95 on 04-30-14, 04:13 pm)
|
Karma: 2 Posts: 1/3 Since: 09-18-13 |
When I -Run 'make' and insert- the code provided from ASMPatchTemplate-master unmodified as a test I get
make: make: Command not found make: *** [build] Error 127 Press any key to continue . . . Thanks |
Piranhaplant |
Posted on 04-30-14, 08:19 pm
|
Fuzzy
Full mod Karma: 1183 Posts: 746/785 Since: 06-28-11 |
Have you installed devkitPro? Make is included in the installation. You can download it for Windows here.
|
koopa95 |
Posted on 04-30-14, 09:13 pm
|
Karma: 2 Posts: 2/3 Since: 09-18-13 |
Yes twice, I'm at a loss.
|
Piranhaplant |
Posted on 05-01-14, 12:11 am
|
Fuzzy
Full mod Karma: 1183 Posts: 747/785 Since: 06-28-11 |
Then I would first check to see if make.exe actually exists. It should be located in devkitPro/msys/bin/. If it exists, then add that to your PATH environment variable. If not, then download a copy of make.exe, I can upload mine if you need.
|
koopa95 |
Posted on 05-01-14, 06:25 pm
|
Karma: 2 Posts: 3/3 Since: 09-18-13 |
Yes, I've found the file and set the PATH environment variable like suggested and still nothing. I'll have to play around some more, but at least I have a direction to pursue.
|