How can FEB users directly use wizardry’s hack patches without modifying source code?
1.
Suppose you made a hack as below, to make Eirika get +5 aid:
#include "global.h"
#include "bmunit.h"
#include "constants/characters.h"
/* LynJump! */
int GetUnitAid(struct Unit * unit)
{
int status = UNIT_CON(unit) - 1;
if (UNIT_CHAR_ID(unit) == CHARACTER_EIRIKA)
status += 5;
return status;
}
2.
Now you want to enbale other users to config characters by themselves. However, lots of freshers have no ideas how to compile C. So you decide to put the config table outside:
/* file: hack.c */
#include "global.h"
#include "bmunit.h"
struct AidHack {
u8 pid;
s8 modifier;
};
extern const struct AidHack gAidHackData[];
/* LynJump! */
int GetUnitAid(struct Unit * unit)
{
const struct AidHack * it;
int status = UNIT_CON(unit) - 1;
for (it = gAidHackData; it->pid != 0; it++)
{
if (UNIT_CHAR_ID(unit) == it->pid)
{
status += it->modifier;
break;
}
}
LIMIT_AREA(status, 0, 127);
return status;
}
And then add the config table in *.event file:
/* file: hack.event */
#include "hack.lyn.event"
#include "EAstdlib.event"
gAidHackData:
/* pid modifier */
BYTE Eirika 5
/* Terminator */
BYTE 0 0
3.
Here comes a question, if users just get your released .ups file, or they were just FEB users with no knowledge on coding, how can you make them use your excellent work?
“Why not study on coding!” Yeah that’s not a bed iead
How can you make them use your excellent work?
4
On following to 7743’s FEB PATCH toturial, you may write such a FEB patch script as below:
# file name: PATCH_UntAidConfig.txt
NAME=AidHackData
INFO=My aid hack patch for FEBuilder
AUTHOR=Mokha
PATCHED_IF:0xB2A604=0x6D 0x6F 0x6B 0x68 0x61 0x00
TYPE=STRUCT
TAG=#ENGINE
POINTER=0xB2A60C
DATASIZE=0x2
DATACOUNT=$GREP2 0x0 0x0
LISTNAME=DECIMAL
B0:UNIT=pid
b1:DECIMAL=modifier
For a detailed interpretation of the above code, you can refer to the FEB tutorial, here I may emphasize a few important points:
-
PATCHED_IF:0xB2A604=0x6D 0x6F 0x6B 0x68 0x61 0x00
This identifies whether this patch is valid, here, we defined the judgement as if data from0xB2A604
as0x6D 0x6F 0x6B 0x68 0x61 0x00
(ascii stringmokha\0
if you wonder WTF it is). -
POINTER=0xB2A60C
This identifies where can FEB get the pointer to the data table.
Thus, we should modify on hack.event as below:
PUSH
/* Enable FEB patch */
ORG 0xB2A604
BYTE 0x6D 0x6F 0x6B 0x68 0x61 0x00
/* Set the pointer */
ORG 0xB2A60C
POIN gAidHackData
POP
Now, put your patch to FEBuilder’s patch dir and now your patch got work!
5
But wait, it is not convenient if we always put the pointer to the fix address. FEBuilder offers another method to get the pointer:
magic word.
POINTER=$GREP4END 0x67 0x41 0x69 0x64 0x48 0x61 0x63 0x6B 0x44 0x61 0x74 0x61
Meanwhile, put your magic to the event file:
ALIGN 4
/* Ascii string "gAidHackData\0" */
BYTE 0x67 0x41 0x69 0x64 0x48 0x61 0x63 0x6B 0x44 0x61 0x74 0x61 0x00 0x00 0x00 0x00
POIN gAidHackData
6
Now, we are able to not care about how freshers config data, shall we directly define your data in C?
/* Add a magic for FEB PATCH to auto find the pointer */
#define FEB_IDENTIFIER(PTR) \
const struct { \
char magic[sizeof(#PTR)]; \
const void * addr; \
} FEB_##PTR##_Identifier = { \
.magic = #PTR, \
.addr = PTR, \
};
const struct AidHack gAidHackData[] = {
{
.pid = CHARACTER_EIRIKA,
.modifier = 5
},
{0}
};
FEB_IDENTIFIER(gAidHackData);