mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-23 13:09:56 +00:00
Use enum for FlagJudge operations
This commit is contained in:
parent
b5bb921ade
commit
e2e085f33b
@ -1,6 +1,20 @@
|
||||
#ifndef GUARD_EVENT_FLAG_H
|
||||
#define GUARD_EVENT_FLAG_H
|
||||
|
||||
enum FlagJudgeOperation {
|
||||
JUDGE_TRUE,
|
||||
JUDGE_FALSE,
|
||||
JUDGE_EQ,
|
||||
JUDGE_GT,
|
||||
JUDGE_LT,
|
||||
JUDGE_GE,
|
||||
JUDGE_LE,
|
||||
JUDGE_NE,
|
||||
JUDGE_AND_NONZERO,
|
||||
JUDGE_XOR_NONZERO, // logically identical to JUDGE_NE
|
||||
JUDGE_BIT_SET,
|
||||
};
|
||||
|
||||
// size: 0x10
|
||||
struct ScriptVarInfo {
|
||||
s16 type;
|
||||
@ -37,13 +51,13 @@ bool8 ScriptVarScenarioEqual(s16 param_1, u32 param_2, s32 param_3);
|
||||
bool8 ScriptVarScenarioAfter(s16 param_1, u32 param_2, s32 param_3);
|
||||
void sub_8001D88(void);
|
||||
u32 _FlagCalc(s32 param_1, s32 param_2, u32 operation);
|
||||
bool8 _FlagJudge(s32 param_1, s32 param_2, u32 operation);
|
||||
bool8 _FlagJudge(s32 param_1, s32 param_2, enum FlagJudgeOperation operation);
|
||||
u32 FlagCalc(s32 r0, s32 r1, u32 operation);
|
||||
void UpdateScriptVarWithImmediate(u8 *localVarBuf, s16 varId, s32 val, u32 operation);
|
||||
void UpdateScriptVarWithVar(u8 *localVarBuf, s16 dstVarId, s16 srcVarId, u32 operation);
|
||||
bool8 FlagJudge(s32 r0, s32 r1, u32 operation);
|
||||
bool8 JudgeVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, u32 operation);
|
||||
bool8 JudgeVarWithVar(u8 *param_1, s16 param_2, s16 param_3, u32 operation);
|
||||
bool8 FlagJudge(s32 r0, s32 r1, enum FlagJudgeOperation operation);
|
||||
bool8 JudgeVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, enum FlagJudgeOperation operation);
|
||||
bool8 JudgeVarWithVar(u8 *param_1, s16 param_2, s16 param_3, enum FlagJudgeOperation operation);
|
||||
bool8 sub_80023E4(u32 param_1);
|
||||
u8 sub_8002658(s16 param_1);
|
||||
s16 sub_8002694(u8 param_1);
|
||||
|
@ -353,30 +353,30 @@ u32 _FlagCalc(s32 param_1, s32 param_2, u32 operation)
|
||||
}
|
||||
}
|
||||
|
||||
bool8 _FlagJudge(s32 param_1, s32 param_2, u32 operation)
|
||||
bool8 _FlagJudge(s32 param_1, s32 param_2, enum FlagJudgeOperation operation)
|
||||
{
|
||||
switch(operation) {
|
||||
case 0:
|
||||
return 1;
|
||||
case 1:
|
||||
return 0;
|
||||
case 2:
|
||||
case JUDGE_TRUE:
|
||||
return TRUE;
|
||||
case JUDGE_FALSE:
|
||||
return FALSE;
|
||||
case JUDGE_EQ:
|
||||
return param_1 == param_2;
|
||||
case 7:
|
||||
case JUDGE_NE:
|
||||
return param_1 != param_2;
|
||||
case 3:
|
||||
case JUDGE_GT:
|
||||
return param_1 > param_2;
|
||||
case 5:
|
||||
case JUDGE_GE:
|
||||
return param_1 >= param_2;
|
||||
case 4:
|
||||
case JUDGE_LT:
|
||||
return param_1 < param_2;
|
||||
case 6:
|
||||
case JUDGE_LE:
|
||||
return param_1 <= param_2;
|
||||
case 8:
|
||||
case JUDGE_AND_NONZERO:
|
||||
return (param_1 & param_2) != 0;
|
||||
case 9:
|
||||
case JUDGE_XOR_NONZERO:
|
||||
return (param_1 ^ param_2) != 0;
|
||||
case 10:
|
||||
case JUDGE_BIT_SET:
|
||||
return param_1 >> (param_2) & 1;
|
||||
default:
|
||||
FatalError(&gUnknown_80B7350,gUnknown_80B735C, operation); // event flag rule error %d
|
||||
@ -414,12 +414,12 @@ void UpdateScriptVarWithVar(u8 *param_1, s16 param_2, s16 param_3, u32 operation
|
||||
SetScriptVarValue(param_1,param_2_s32,uVar3);
|
||||
}
|
||||
|
||||
bool8 FlagJudge(s32 r0, s32 r1, u32 operation)
|
||||
bool8 FlagJudge(s32 r0, s32 r1, enum FlagJudgeOperation operation)
|
||||
{
|
||||
return _FlagJudge(r0, r1, operation);
|
||||
}
|
||||
|
||||
bool8 JudgeVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, u32 operation)
|
||||
bool8 JudgeVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, enum FlagJudgeOperation operation)
|
||||
{
|
||||
s32 uVar1;
|
||||
|
||||
@ -427,7 +427,7 @@ bool8 JudgeVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, u32 operation
|
||||
return _FlagJudge(uVar1,param_3,operation);
|
||||
}
|
||||
|
||||
bool8 JudgeVarWithVar(u8 *param_1, s16 param_2, s16 param_3, u32 operation)
|
||||
bool8 JudgeVarWithVar(u8 *param_1, s16 param_2, s16 param_3, enum FlagJudgeOperation operation)
|
||||
{
|
||||
s32 uVar1;
|
||||
s32 uVar2;
|
||||
|
@ -1499,7 +1499,7 @@ s32 ExecuteScriptCommand(Action *action) {
|
||||
break;
|
||||
}
|
||||
case 0xb3: {
|
||||
if ((u8)JudgeVarWithImmediate(NULL, curCmd.argShort, curCmd.arg1, 2)) {
|
||||
if ((u8)JudgeVarWithImmediate(NULL, curCmd.argShort, curCmd.arg1, JUDGE_EQ)) {
|
||||
scriptData->script.ptr = FindLabel(action, (u8)curCmd.argByte);
|
||||
}
|
||||
break;
|
||||
|
@ -90,7 +90,7 @@ ScriptCommand *ResolveJump(Action *action, s32 r1)
|
||||
|
||||
if (script.op == 0xCC)
|
||||
{
|
||||
if(FlagJudge(r1, script.arg1, 0x2))
|
||||
if(FlagJudge(r1, script.arg1, JUDGE_EQ))
|
||||
return FindLabel(action, script.argShort);
|
||||
}
|
||||
else if (script.op == 0xCD)
|
||||
|
Loading…
Reference in New Issue
Block a user