mirror of
https://github.com/pret/pmd-sky.git
synced 2026-03-21 17:25:15 -05:00
Merge pull request #203 from slaw-22/Scripting3
Some checks failed
build / build (push) Has been cancelled
Some checks failed
build / build (push) Has been cancelled
Decomp FlagCalc
This commit is contained in:
commit
c5140f0b6d
|
|
@ -8,17 +8,15 @@
|
|||
.public LoadScriptVariableValue
|
||||
.public LoadScriptVariableValueAtIndex
|
||||
.public MemcpySimple
|
||||
.public RandInt
|
||||
.public SCRIPT_VARS_VALUES
|
||||
.public SaveScriptVariableValue
|
||||
.public SaveScriptVariableValueAtIndex
|
||||
.public ScenarioFlagBackup
|
||||
.public ZinitScriptVariable
|
||||
.public _0209CEAC
|
||||
.public _0209CF28
|
||||
.public EVENT_FLAG_PROG_POS_INFO
|
||||
.public _0209CF48
|
||||
.public _0209CF64
|
||||
.public _0209CF84
|
||||
.public _0209DFA0
|
||||
.public _s32_div_f
|
||||
.public FlagCalc
|
||||
.public sub_0204CBE8
|
||||
|
|
@ -1,87 +1,8 @@
|
|||
.include "asm/macros.inc"
|
||||
.include "main_0204BCAC.inc"
|
||||
.include "main_0204BD98.inc"
|
||||
|
||||
.text
|
||||
|
||||
arm_func_start sub_0204BCAC
|
||||
sub_0204BCAC: ; 0x0204BCAC
|
||||
stmdb sp!, {r3, lr}
|
||||
sub sp, sp, #8
|
||||
cmp r2, #0xb
|
||||
addls pc, pc, r2, lsl #2
|
||||
b _0204BD68
|
||||
_0204BCC0: ; jump table
|
||||
b _0204BCF0 ; case 0
|
||||
b _0204BCF8 ; case 1
|
||||
b _0204BD00 ; case 2
|
||||
b _0204BD08 ; case 3
|
||||
b _0204BD14 ; case 4
|
||||
b _0204BD1C ; case 5
|
||||
b _0204BD28 ; case 6
|
||||
b _0204BD30 ; case 7
|
||||
b _0204BD38 ; case 8
|
||||
b _0204BD40 ; case 9
|
||||
b _0204BD4C ; case 10
|
||||
b _0204BD5C ; case 11
|
||||
_0204BCF0:
|
||||
mov r0, r1
|
||||
b _0204BD88
|
||||
_0204BCF8:
|
||||
sub r0, r0, r1
|
||||
b _0204BD88
|
||||
_0204BD00:
|
||||
add r0, r0, r1
|
||||
b _0204BD88
|
||||
_0204BD08:
|
||||
mul r1, r0, r1
|
||||
mov r0, r1
|
||||
b _0204BD88
|
||||
_0204BD14:
|
||||
bl _s32_div_f
|
||||
b _0204BD88
|
||||
_0204BD1C:
|
||||
bl _s32_div_f
|
||||
mov r0, r1
|
||||
b _0204BD88
|
||||
_0204BD28:
|
||||
and r0, r0, r1
|
||||
b _0204BD88
|
||||
_0204BD30:
|
||||
orr r0, r0, r1
|
||||
b _0204BD88
|
||||
_0204BD38:
|
||||
eor r0, r0, r1
|
||||
b _0204BD88
|
||||
_0204BD40:
|
||||
mov r2, #1
|
||||
orr r0, r0, r2, lsl r1
|
||||
b _0204BD88
|
||||
_0204BD4C:
|
||||
mov r2, #1
|
||||
mvn r1, r2, lsl r1
|
||||
and r0, r0, r1
|
||||
b _0204BD88
|
||||
_0204BD5C:
|
||||
mov r0, r1
|
||||
bl RandInt
|
||||
b _0204BD88
|
||||
_0204BD68:
|
||||
ldr r1, _0204BD90 ; =_0209CEAC
|
||||
add r0, sp, #0
|
||||
ldr r3, [r1, #4]
|
||||
ldr ip, [r1]
|
||||
ldr r1, _0204BD94 ; =_0209CF28
|
||||
str ip, [sp]
|
||||
str r3, [sp, #4]
|
||||
bl Debug_FatalError
|
||||
_0204BD88:
|
||||
add sp, sp, #8
|
||||
ldmia sp!, {r3, pc}
|
||||
.align 2, 0
|
||||
_0204BD90: .word _0209CEAC
|
||||
_0204BD94: .word _0209CF28
|
||||
arm_func_end sub_0204BCAC
|
||||
|
||||
arm_func_start sub_0204BD98
|
||||
sub_0204BD98: ; 0x0204BD98
|
||||
stmdb sp!, {r3, lr}
|
||||
|
|
@ -162,7 +83,7 @@ _0204BE88:
|
|||
and r0, r2, #0xff
|
||||
b _0204BEBC
|
||||
_0204BE9C:
|
||||
ldr r1, _0204BEC4 ; =_0209CEAC
|
||||
ldr r1, _0204BEC4 ; =EVENT_FLAG_PROG_POS_INFO
|
||||
add r0, sp, #0
|
||||
ldr r3, [r1, #0xc]
|
||||
ldr ip, [r1, #8]
|
||||
|
|
@ -174,16 +95,16 @@ _0204BEBC:
|
|||
add sp, sp, #8
|
||||
ldmia sp!, {r3, pc}
|
||||
.align 2, 0
|
||||
_0204BEC4: .word _0209CEAC
|
||||
_0204BEC4: .word EVENT_FLAG_PROG_POS_INFO
|
||||
_0204BEC8: .word _0209CF48
|
||||
arm_func_end sub_0204BD98
|
||||
|
||||
arm_func_start sub_0204BECC
|
||||
sub_0204BECC: ; 0x0204BECC
|
||||
ldr ip, _0204BED4 ; =sub_0204BCAC
|
||||
ldr ip, _0204BED4 ; =FlagCalc
|
||||
bx ip
|
||||
.align 2, 0
|
||||
_0204BED4: .word sub_0204BCAC
|
||||
_0204BED4: .word FlagCalc
|
||||
arm_func_end sub_0204BECC
|
||||
|
||||
arm_func_start sub_0204BED8
|
||||
|
|
@ -196,7 +117,7 @@ sub_0204BED8: ; 0x0204BED8
|
|||
bl LoadScriptVariableValue
|
||||
mov r1, r5
|
||||
mov r2, r4
|
||||
bl sub_0204BCAC
|
||||
bl FlagCalc
|
||||
mov r2, r0
|
||||
mov r0, r7
|
||||
mov r1, r6
|
||||
|
|
@ -219,7 +140,7 @@ sub_0204BF10: ; 0x0204BF10
|
|||
mov r1, r0
|
||||
mov r0, r4
|
||||
mov r2, r5
|
||||
bl sub_0204BCAC
|
||||
bl FlagCalc
|
||||
mov r2, r0
|
||||
mov r0, r8
|
||||
mov r1, r7
|
||||
|
|
@ -8179,8 +8179,8 @@ _0209CE9C:
|
|||
.global _0209CEA4
|
||||
_0209CEA4:
|
||||
.byte 0x4C, 0x4F, 0x43, 0x41, 0x4C, 0x31, 0x00, 0x00
|
||||
.global _0209CEAC
|
||||
_0209CEAC:
|
||||
.global EVENT_FLAG_PROG_POS_INFO
|
||||
EVENT_FLAG_PROG_POS_INFO:
|
||||
.word _0209CEBC
|
||||
.byte 0xE9, 0x03, 0x00, 0x00
|
||||
.word _0209CEBC
|
||||
|
|
@ -8208,8 +8208,8 @@ _0209CF0C:
|
|||
.byte 0x45, 0x76, 0x65, 0x6E, 0x74, 0x46, 0x6C, 0x61
|
||||
.byte 0x67, 0x53, 0x69, 0x7A, 0x65, 0x20, 0x25, 0x30, 0x34, 0x78, 0x2F, 0x25, 0x30, 0x34, 0x78, 0x0A
|
||||
.byte 0x00, 0x00, 0x00, 0x00
|
||||
.global _0209CF28
|
||||
_0209CF28:
|
||||
.global EVENT_FLAG_EXPANSION_ERROR
|
||||
EVENT_FLAG_EXPANSION_ERROR:
|
||||
.byte 0x65, 0x76, 0x65, 0x6E, 0x74, 0x20, 0x66, 0x6C, 0x61, 0x67, 0x20, 0x65
|
||||
.byte 0x78, 0x70, 0x61, 0x6E, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x25
|
||||
.byte 0x64, 0x00, 0x00, 0x00
|
||||
|
|
|
|||
|
|
@ -3441,4 +3441,19 @@ enum game_mode
|
|||
// Possibly more?
|
||||
};
|
||||
|
||||
enum FlagCalcOperation {
|
||||
CALC_SET = 0,
|
||||
CALC_SUB = 1,
|
||||
CALC_ADD = 2,
|
||||
CALC_MUL = 3,
|
||||
CALC_DIV = 4,
|
||||
CALC_MOD = 5,
|
||||
CALC_AND = 6,
|
||||
CALC_OR = 7,
|
||||
CALC_XOR = 8,
|
||||
CALC_SETBIT = 9,
|
||||
CALC_CLEARBIT = 10,
|
||||
CALC_RANDOM = 11,
|
||||
};
|
||||
|
||||
#endif //PMDSKY_ENUMS_H
|
||||
|
|
|
|||
|
|
@ -41,5 +41,6 @@ void LoadScriptVariableValueBytes(const enum script_var_id sv_id, u8* result, s3
|
|||
void LoadScriptVariableValueString(const enum script_var_id sv_id, u8* result, u8 num_bytes);
|
||||
void SaveScriptVariableValueBytes(const enum script_var_id sv_id, u8* result, s32 num_bytes);
|
||||
s32 ScriptVariablesEqual(union script_var_value sv_val_ptr_local[], enum script_var_id sv_id_1, enum script_var_id sv_id_2);
|
||||
s32 FlagCalc(s32 param_1, s32 param_2, enum FlagCalcOperation operation);
|
||||
|
||||
#endif //PMDSKY_SCRIPTING_H
|
||||
|
|
|
|||
2
main.lsf
2
main.lsf
|
|
@ -81,7 +81,7 @@ Static main
|
|||
Object src/main_0204AFF8.o
|
||||
Object asm/main_0204B018.o
|
||||
Object src/scripting.o
|
||||
Object asm/main_0204BCAC.o
|
||||
Object asm/main_0204BD98.o
|
||||
Object src/main_0204C938.o
|
||||
Object asm/main_0204C94C.o
|
||||
Object src/dungeon_recruitment_3.o
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "debug.h"
|
||||
#include "enums.h"
|
||||
#include "main_0200224C.h"
|
||||
#include "scripting.h"
|
||||
|
||||
// Global script variable definitions
|
||||
|
|
@ -24,6 +26,9 @@ extern s32 sub_0204C928(s32 arg0);
|
|||
|
||||
const short LOCAL_SCRIPT_VAR_OFFSET = 0x400;
|
||||
|
||||
extern struct prog_pos_info EVENT_FLAG_PROG_POS_INFO;
|
||||
extern u8 EVENT_FLAG_EXPANSION_ERROR;
|
||||
|
||||
void LoadScriptVariableRaw(struct script_var_raw* sv_raw,
|
||||
union script_var_value sv_val_local[],
|
||||
const enum script_var_id sv_id) {
|
||||
|
|
@ -358,3 +363,39 @@ s32 ScriptVariablesEqual(union script_var_value sv_val_ptr_local[], enum script_
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
s32 FlagCalc(s32 param_1, s32 param_2, enum FlagCalcOperation operation)
|
||||
{
|
||||
switch (operation) {
|
||||
case CALC_SET:
|
||||
return param_2;
|
||||
case CALC_SUB:
|
||||
return param_1 - param_2;
|
||||
case CALC_ADD:
|
||||
return param_1 + param_2;
|
||||
case CALC_MUL:
|
||||
return param_1 * param_2;
|
||||
case CALC_DIV:
|
||||
return param_1 / param_2;
|
||||
case CALC_MOD:
|
||||
return param_1 % param_2;
|
||||
case CALC_AND:
|
||||
return param_1 & param_2;
|
||||
case CALC_OR:
|
||||
return param_1 | param_2;
|
||||
case CALC_XOR:
|
||||
return param_1 ^ param_2;
|
||||
case CALC_SETBIT:
|
||||
return (1 << param_2) | param_1;
|
||||
case CALC_CLEARBIT:
|
||||
return param_1 & ~(1 << param_2);
|
||||
case CALC_RANDOM:
|
||||
return RandInt(param_2);
|
||||
default:
|
||||
// EVENT_FLAG_PROG_POS_INFO contains a pointer to the filename event_flag.c
|
||||
// and a line number of 1001
|
||||
struct prog_pos_info prog_pos_info = EVENT_FLAG_PROG_POS_INFO;
|
||||
// EVENT_FLAG_EXPANSION_ERROR contains the string "event flag expansion error %d"
|
||||
Debug_FatalError(&prog_pos_info, &EVENT_FLAG_EXPANSION_ERROR, operation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user