|
@@ -0,0 +1,160 @@
|
|
1
|
+/*
|
|
2
|
+ * script.bfft - Tomb Raider 1 - 3 Engine Script Format Description
|
|
3
|
+ * 2014, Thomas Buck <xythobuz@xythobuz.de>
|
|
4
|
+ *
|
|
5
|
+ * Based on the TR Rosetta Stone (http://www.tnlc.com/eep/tr/TRosettaStone.html),
|
|
6
|
+ * this document (http://xythobuz.de/tr_docs/TombPC_TR2.pdf),
|
|
7
|
+ * and my own reverse-engineering efforts.
|
|
8
|
+ * Developed for Binspector (https://github.com/binspector/binspector)
|
|
9
|
+ */
|
|
10
|
+
|
|
11
|
+// ########## General data structures ##########
|
|
12
|
+
|
|
13
|
+struct strings_t {
|
|
14
|
+ unsigned 16 little stringOffsets[stringsInPackage];
|
|
15
|
+ unsigned 16 little stringDataSize;
|
|
16
|
+ unsigned 8 little stringData[stringDataSize];
|
|
17
|
+}
|
|
18
|
+
|
|
19
|
+struct script_t {
|
|
20
|
+ unsigned 16 little sciprOffsets[stringsInPackage];
|
|
21
|
+ unsigned 16 little scriptDataSize;
|
|
22
|
+ unsigned 16 little scriptData[scriptDataSize / 2];
|
|
23
|
+}
|
|
24
|
+
|
|
25
|
+struct hack_t {
|
|
26
|
+ signal isTR2 = 0;
|
|
27
|
+ signal isPCVersion = 1;
|
|
28
|
+
|
|
29
|
+ if ((peek() == 0x13) || (peek() == 0x15)) {
|
|
30
|
+ // TR2 for PC and PSX has 6 "filler bytes" hex 13 00 14 00 15 00
|
|
31
|
+ // (for TR3 for PSX, the filler is hex 15 00 16 00 17 00 instead)
|
|
32
|
+ // at the end of the script block. We need to skip these...
|
|
33
|
+ if (peek() == 0x13) {
|
|
34
|
+ signal isTR2 = 1;
|
|
35
|
+ } else {
|
|
36
|
+ signal isTR2 = 0;
|
|
37
|
+ signal isPCVersion = 0;
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ skip hack[6];
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ if (peek() == 0x01) {
|
|
44
|
+ // TR2 for PSX has 64 bytes with unknown content (not zero!) here,
|
|
45
|
+ // TR3 for PSX has 40 bytes. We try to identify and skip them (both start with 1)...
|
|
46
|
+ // This is also currently used to set the platform specific string count
|
|
47
|
+ if (isTR2 == 1) {
|
|
48
|
+ signal isPCVersion = 0;
|
|
49
|
+ skip hackPSX[64];
|
|
50
|
+ } else {
|
|
51
|
+ skip hackPSX[40];
|
|
52
|
+ }
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ if (isTR2 == 1) {
|
|
56
|
+ if (isPCVersion == 1) {
|
|
57
|
+ notify "TR2 PC Version detected!";
|
|
58
|
+ signal numPCStrings = 41;
|
|
59
|
+ } else {
|
|
60
|
+ notify "TR2 PSX Version detected!";
|
|
61
|
+ signal numPCStrings = 80;
|
|
62
|
+ }
|
|
63
|
+ } else {
|
|
64
|
+ if (isPCVersion == 1) {
|
|
65
|
+ notify "TR3 PC Version detected!";
|
|
66
|
+ signal numPCStrings = 41;
|
|
67
|
+ } else {
|
|
68
|
+ notify "TR3 PSX Version detected!";
|
|
69
|
+ signal numPCStrings = 80;
|
|
70
|
+ }
|
|
71
|
+ }
|
|
72
|
+}
|
|
73
|
+
|
|
74
|
+// ########## Main file layout ##########
|
|
75
|
+
|
|
76
|
+struct main {
|
|
77
|
+ unsigned 32 little version;
|
|
78
|
+
|
|
79
|
+ unsigned 8 little description[256];
|
|
80
|
+
|
|
81
|
+ unsigned 16 little gameflowSize;
|
|
82
|
+ if (gameflowSize != 128)
|
|
83
|
+ die "Invalid gameflow size!";
|
|
84
|
+
|
|
85
|
+ unsigned 32 little firstOption;
|
|
86
|
+ signed 32 little titleReplace;
|
|
87
|
+ unsigned 32 little onDeathDemoMode;
|
|
88
|
+ unsigned 32 little onDeathInGame;
|
|
89
|
+
|
|
90
|
+ // Scaled * 100 in TR3
|
|
91
|
+ unsigned 32 little noInputTime;
|
|
92
|
+
|
|
93
|
+ unsigned 32 little onDemoInterrupt;
|
|
94
|
+ unsigned 32 little onDemoEnd;
|
|
95
|
+
|
|
96
|
+ skip filler1[36];
|
|
97
|
+
|
|
98
|
+ unsigned 16 little numLevels;
|
|
99
|
+ unsigned 16 little numPictures;
|
|
100
|
+ unsigned 16 little numTitles;
|
|
101
|
+ unsigned 16 little numFMVs;
|
|
102
|
+ unsigned 16 little numCutscenes;
|
|
103
|
+ unsigned 16 little numDemos;
|
|
104
|
+ unsigned 16 little titleTrack;
|
|
105
|
+ signed 16 little singleLevel;
|
|
106
|
+
|
|
107
|
+ skip filler2[32];
|
|
108
|
+
|
|
109
|
+ unsigned 16 little flags;
|
|
110
|
+
|
|
111
|
+ skip filler3[6];
|
|
112
|
+
|
|
113
|
+ unsigned 8 little cypherCode;
|
|
114
|
+ unsigned 8 little language;
|
|
115
|
+
|
|
116
|
+ // Zero in TR3, Part of filler or real number?
|
|
117
|
+ unsigned 16 little secretTrack;
|
|
118
|
+
|
|
119
|
+ skip filler4[4];
|
|
120
|
+
|
|
121
|
+ slot stringsInPackage = numLevels;
|
|
122
|
+ strings_t levelDisplayNames;
|
|
123
|
+
|
|
124
|
+ signal stringsInPackage = numPictures;
|
|
125
|
+ strings_t pictures;
|
|
126
|
+
|
|
127
|
+ signal stringsInPackage = numTitles;
|
|
128
|
+ strings_t titleFilenames;
|
|
129
|
+
|
|
130
|
+ signal stringsInPackage = numFMVs;
|
|
131
|
+ strings_t fmvFilenames;
|
|
132
|
+
|
|
133
|
+ signal stringsInPackage = numLevels;
|
|
134
|
+ strings_t levelFilenames;
|
|
135
|
+
|
|
136
|
+ signal stringsInPackage = numCutscenes;
|
|
137
|
+ strings_t cutsceneFilenames;
|
|
138
|
+
|
|
139
|
+ signal stringsInPackage = numLevels + 1;
|
|
140
|
+ script_t script;
|
|
141
|
+
|
|
142
|
+ slot numPCStrings = 41; // PC Version has 41 pcStrings
|
|
143
|
+ slot isPCVersion = 1;
|
|
144
|
+ slot isTR2 = 1;
|
|
145
|
+ hack_t hack;
|
|
146
|
+
|
|
147
|
+ unsigned 16 little numGameStrings;
|
|
148
|
+
|
|
149
|
+ signal stringsInPackage = numGameStrings;
|
|
150
|
+ strings_t gameStrings;
|
|
151
|
+
|
|
152
|
+ signal stringsInPackage = numPCStrings;
|
|
153
|
+ strings_t pcStrings;
|
|
154
|
+
|
|
155
|
+ signal stringsInPackage = numLevels;
|
|
156
|
+ strings_t puzzles[4];
|
|
157
|
+ strings_t pickups[2];
|
|
158
|
+ strings_t keys[4];
|
|
159
|
+}
|
|
160
|
+
|