-
Notifications
You must be signed in to change notification settings - Fork 0
/
textstuff.h
71 lines (47 loc) · 1.76 KB
/
textstuff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/////////////////////////////////////////////////////////////////////////////////////////////////
// textstuff.h: definitions for stuff :D
#define TYPE_CODE 0
#define TYPE_ARGLIST 1
// Control code node structure
// (Linked tree-list)
struct CCNode {
// Node properties
int level; // depth, i.e., CC byte # (sorta)
int value; // byte value (-1 for arguments)
int type; // code byte or argument
int num_arg; // number of argument bytes
int args[32]; // argument list
bool arg_multiplier; // if true, number of arguments remaining is multiplied by the
// value of the first
bool isTerminator;
// Parent node
CCNode *parent;
// Child nodes
int num_nodes;
CCNode *nodes;
};
// Contains info about a string in the ROM
struct String {
int address;
char* str;
int len;
};
void CreateCCTable(CCNode table[32]);
CCNode* AddNode(CCNode *node, int level, int value, int type, int num_arg, bool multi, bool terminate);
void CreateCompressionTable(FILE* rom, char* tbl[]);
String ReadString(FILE* rom, unsigned long address, CCNode ccTable);
char* ParseString(char str[], int len, CCNode ccTable, char* comprTable[]);
char* ParseHeader(char str[], int len, CCNode ccTable, char* comprTable[]);
char* ParseGrouping(char str[]);
int GetStringLength(char str[]);
char* DeparseString(char str[]);
int WriteString(FILE* rom, String s, int address);
int SearchNode(CCNode *node, int val);
void AddCode(char* str, int val, int pos);
bool isCC(char ch);
int LoadRawText(FILE* rom, String strlist[], CCNode ccTable, char* comprTable[]);
int LoadEXPText(FILE *rom, String strlist[], CCNode ccTable);
int LoadTPTText(FILE* rom, String strlist[], CCNode ccTable);
bool CheckFile(CString szFile);
unsigned int HexToSNES(unsigned int);
unsigned int SNESToHex(unsigned int);