|
本帖最后由 jiangzhengwenjz 于 2016-3-21 23:04 编辑
源码请在github下载zip压缩包:https://github.com/jiangzhengwenjz/cmda6
请注意需自行安装devikitarm并把它的bin路径加到PATH变量,而且要装make
好久没改版了,这次拿C语言小试牛刀,不得不说用C语言改版还是很方便的,唯一搞不懂的是怎么确定函数写入的相对位置,所以这个问题暂时没解决只能手动来:|
使用方法则因为没有时间,所以暂时直接拿发到外网的版本凑下数,看最近有没有空翻成中文:
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)- #org 0x163D54
- cmda6 0x4 //the command we're hacking
- end
复制代码 (Type 1)- special 0x135 //I've rewritten this one
- end
复制代码 (Type 2)- //---------------
- #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:
Block Description Block index Block behavior byte
ICE 0x359 0x26
BROKEN ICE 0x35A 0x27
ICE HOLE 0x35B 0x66(But we don't care)
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:- cmda6 8 //if you add more to the table we've repointed, it should be 9, 10, 11...
- end
复制代码 Type1:- 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.- #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. |
|