Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/Scene/Legacy/v4/ScriptLegacyv4.hpp
1175 views
1
2
namespace Legacy
3
{
4
5
namespace v4
6
{
7
8
#define LEGACY_v4_SCRIPTCODE_COUNT (0x40000)
9
#define LEGACY_v4_JUMPTABLE_COUNT (0x4000)
10
#define LEGACY_v4_FUNCTION_COUNT (0x200)
11
12
#define LEGACY_v4_JUMPSTACK_COUNT (0x400)
13
#define LEGACY_v4_FUNCSTACK_COUNT (0x400)
14
#define LEGACY_v4_FORSTACK_COUNT (0x400)
15
16
struct ScriptPtr {
17
int32 scriptCodePtr;
18
int32 jumpTablePtr;
19
};
20
21
struct ScriptFunction {
22
uint8 access;
23
#if LEGACY_RETRO_USE_COMPILER
24
char name[0x20];
25
#endif
26
ScriptPtr ptr;
27
};
28
29
struct ObjectScript {
30
int32 frameCount;
31
int32 spriteSheetID;
32
ScriptPtr eventUpdate;
33
ScriptPtr eventDraw;
34
ScriptPtr eventStartup;
35
int32 frameListOffset;
36
AnimationFile *animFile;
37
};
38
39
struct ScriptEngine {
40
int32 operands[0x10];
41
int32 temp[8];
42
int32 arrayPosition[9];
43
int32 checkResult;
44
};
45
46
enum ScriptSubs { EVENT_MAIN = 0, EVENT_DRAW = 1, EVENT_SETUP = 2 };
47
48
extern ObjectScript objectScriptList[LEGACY_v4_OBJECT_COUNT];
49
extern ScriptFunction scriptFunctionList[LEGACY_v4_FUNCTION_COUNT];
50
51
extern int32 scriptCode[LEGACY_v4_SCRIPTCODE_COUNT];
52
extern int32 jumpTable[LEGACY_v4_JUMPTABLE_COUNT];
53
54
extern int32 jumpTableStack[LEGACY_v4_JUMPSTACK_COUNT];
55
extern int32 functionStack[LEGACY_v4_FUNCSTACK_COUNT];
56
extern int32 foreachStack[LEGACY_v4_FORSTACK_COUNT];
57
58
extern int32 scriptCodePos;
59
extern int32 scriptCodeOffset;
60
extern int32 jumpTablePos;
61
extern int32 jumpTableOffset;
62
extern int32 jumpTableStackPos;
63
extern int32 functionStackPos;
64
extern int32 foreachStackPos;
65
66
extern ScriptEngine scriptEng;
67
extern char scriptText[0x4000];
68
69
#if LEGACY_RETRO_USE_COMPILER
70
extern int32 scriptFunctionCount;
71
extern char scriptFunctionNames[LEGACY_v4_FUNCTION_COUNT][0x40];
72
73
extern int32 lineID;
74
75
void CheckAliasText(char *text);
76
void CheckStaticText(char *text);
77
bool32 CheckTableText(char *text);
78
void ConvertArithmaticSyntax(char *text);
79
void ConvertConditionalStatement(char *text);
80
bool32 ConvertSwitchStatement(char *text);
81
void ConvertFunctionText(char *text);
82
void CheckCaseNumber(char *text);
83
bool32 ReadSwitchCase(char *text);
84
void ReadTableValues(char *text);
85
void AppendIntegerToString(char *text, int32 value);
86
void CopyAliasStr(char *dest, char *text, bool32 arrayIndex);
87
bool32 CheckOpcodeType(char *text); // Never actually used
88
89
void ParseScriptFile(char *scriptName, int32 scriptID);
90
#endif
91
void LoadBytecode(int32 scriptID, bool32 globalCode);
92
93
void ProcessScript(int32 scriptCodeStart, int32 jumpTableStart, uint8 scriptEvent);
94
95
void ClearScriptData();
96
97
} // namespace v4
98
99
} // namespace Legacy
100