Registrarse

[C] FR | A Custom cmdA6

jiangzhengwenjz

Usuario mítico
Been a while after my last thread of hacking, right? I haven't been hacking for about 2 months but I've learned C and I've figured out how to use it in GBA hacking. I did it today and it's my first attempt to hack in C. Actually I'm wondering if I should post the thread in the section Script and ASM, but as it's C instead of ASM, I decide to post here. :hmm:

Please read carefully or you won't be able to handle it.

Download:
The source codes are available on my github here: https://github.com/jiangzhengwenjz/cmda6
Just Download it in zip.

Introduction:
cmdA6 means the command in script whose index is 0xA6. As we all know, it is used in the level script in the map 1.111 in FR (in ICEFALL CAVE)
Let's see the original scripts:
(Type 5)
Código:
#org 0x163D54
cmda6 0x4 //the command we're hacking
end
(Type 1)
Código:
special 0x135 //I've rewritten this one
end
(Type 2)
Código:
//---------------
#org 0x163D65
lockall
pause 0x14
applymovement 0xFF 0x8163D7F
waitmovement 0x0
sound 0x25
pause 0x3C
warphole 0x1 0x70
waitstate
releaseall
end
//-----------
// Movements
//-----------
#org 0x163D7F
#raw 0x60 //Hide
#raw 0xFE //End of Movements
Note that the script has a var of 0x4001 and the var value is 0x0001.

The tile blocks used and their information:
[tabla][fila][celda]Block Description[/celda][celda]Block index[/celda][celda]Block behavior byte[/celda][/fila][fila][celda]ICE[/celda][celda]0x359[/celda][celda]0x26[/celda][/fila][fila][celda]BROKEN ICE[/celda][celda]0x35A[/celda][celda]0x27[/celda][/fila][fila][celda]ICE HOLE[/celda][celda]0x35B[/celda][celda]0x66(But we don't care)[/celda][/fila]
[/tabla]

How does it work:
(I suppose that you know nothing about ASM)
You can think that the type 5 script is always running (cmda6), and when you walk on the ICE block, it changes it to BROKEN ICE block. When you walk on the BROKEN ICE block, it changes it to ICE HOLE block, and do the same thing as "setvar 0x4001 1" to trigger the type 2 script. (warphole, etc.) I think the type 3 script is bugged so I've rewritten it to make the BROKEN ICE remain what they look like after entering the map.

How to use:
1. Download the zip archive and decompress it.
2. In that directory, you create a new folder called "build". (No quotation marks)
3. Modify the customization.h to meet your requirement. (See the next section) Don't forget to modify the offset to insert in the linker.lsc and linker2.lsc. For example, I make one of them 0x800000 and another 0x900000.
4. Press shift + right click and open the command line prompt (or your mintty), and type in make and press enter.
5. Now you can see that main.bin and sp135.bin are generated.
6. Prepare your BPRE ROM, and place FF at 0x6E8FC.
7. Insert them at the offsets you've defined in the 2 .lsc files. (linker.lsc for main.bin, linker2.lsc for sp135.bin)
8. Search 70 B5 81 B0 around the insert offset of main.bin. (For example, I inserted in at 0x800000 and I've found the hex value "70 B5 81 B0" at 0x8000BC. Repoint the table at 0x3A7310 and add a pointer at the end of it (+1) to the function you've found. (In this case, BD 00 80 08)
9. Goto the map you want and add 3 scripts:
Type5:
Código:
cmda6 8 //if you add more to the table we've repointed, it should be 9, 10, 11...
end
Type1:
Código:
callasm sp135.bin+1 //in this case, 0x8900001
end
Type2:
Please define it yourself because I don't know what you want to do. Be sure to use the variable you've defined in the "customization.h" and the value 1.
10. Done! Try to test it! (Don't forget to set the behavior bytes of your selected tileblocks in Advance Map)


How to define your own settings:
Open your decompressed archive and find the file "customization.h" in the \src\header folder. Use your text editor to open it. (like notepad, notepad++, vim, or any other things)
Then you just modify them as the comments said.
Código:
#ifndef _CUSTOMIZATION_H
#define _CUSTOMIZATION_H

/*behavior bytes*/
#define behavior_byte1 0x26
#define behavior_byte2 0x27

/*flags*/
#define flag_start 0x1000 /* a series of flags to be used and they should be stable ones. The number of the flags are judged by the size of array.*/ 

/*sound*/
#define Snd_1 0x24 /*the sound index of "ice breaks"*/
#define Snd_2 0x23 /*the sound index of "broken ice is transformed to a hole"*/

/*tile block number*/
#define tblock_1 0x359
#define tblock_2 0x35A
#define tblock_3 0x35B

/*variable*/
#define var_sc 0x4001

/*coordinates*/
/*These are the coordinates of your "ice blocks", don't forget to update the "9" after changing it. */
const u8 coord_array[9][2] = 
{
	{8,3},
	{0xA,5},
	{0xF,5},
	{8,9},
	{9,9},
	{0x10,9},
	{8,0xA},
	{9,0xA},
	{8,0xE},
};

#endif
Credits:
Nintendo: for the game and its header file.
Knizz: for his idb.
Sturmvogel & Wodka: I took a look at the makefile they used to write my version.


Last section: what if you don't want the "block remaining function"?
1. Don't insert and use the sp135.bin.
2. Goto main.c and add "//" (comment mark) at the beginning of line 76 and 91 to deactivate the function calling.
 
M

Miembro eliminado 28262

Invitado
Respuesta: FR | C | A Custom cmdA6 (Source Available)

Nice!
but i cant understand what it serves yet :/

EDIT:
It's just a modification of cmda6 0x4 and special 0x135, so that you can make some instant tile change and trigger specific script.
Oh.. Oh! I get it... that's gona be so usefull.
Thanx!
 
Última edición por un moderador:

Gold

Porrero a tiempo parcial
Miembro insignia
Respuesta: FR | C | A Custom cmdA6 (Source Available)

Nice hack, is very useful to make puzzles, but this work different than the ice floor on the icefall cave on Sevii islands?
 

jiangzhengwenjz

Usuario mítico
Re: Respuesta: FR | C | A Custom cmdA6 (Source Available)

Nice hack, is very useful to make puzzles, but this work different than the ice floor on the icefall cave on Sevii islands?
If you don't touch customization.h, the main.bin is almost the same as cmda6 0x4. The sp135.bin is a rebuild, and it uses some stable flags instead of the temporary ones in the original special 0x135. (Acutally, I have no idea of what the game is trying to do via special 0x135, because it seems that it will simply do nothing.
 
Arriba