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