source: Readingame/tools/init.rehex.bt@ c52dd7b

main
Last change on this file since c52dd7b was c52dd7b, checked in by PulkoMandy <pulkomandy@…>, 8 weeks ago

Add rehex scripts in easy to use form

This is more convenient than having them on the wiki

  • Property mode set to 100644
File size: 2.6 KB
Line 
1LittleEndian();
2
3// A generic struct for a NULL terminated string (until rehex can do it more easily)
4struct NullTerminatedString {
5 local int64_t start = FTell();
6 local int64_t end = start;
7
8 while (ReadU8(end) != 0) {
9 end++;
10 }
11
12 local int64_t size = end - start + 1;
13 char string[size];
14};
15
16FSeek(32); // Skip the header, to be decoded later...
17
18struct TextAndShortcut {
19 struct NullTerminatedString label;
20 struct NullTerminatedString shortcut;
21};
22
23struct Point {
24 uint16_t xpos;
25 uint16_t ypos;
26};
27
28enum <uint16_t> Color {
29 BLACK,
30 BLUE,
31 GREEN,
32 CYAN,
33 RED,
34 MAGENTA,
35 YELLOW,
36 GRAY
37};
38
39struct GlobalButton {
40 struct Point position;
41 enum Color bgcolor;
42 uint16_t unknown[3];
43 uint16_t buttonID;
44 struct TextAndShortcut label;
45};
46
47struct ButtonChunk {
48 uint8_t undecodedData[48];
49 struct GlobalButton globalButtons[0];
50
51 while(ReadU32(FTell()) != 0) {
52 ArrayExtend(globalButtons);
53 }
54 struct Point terminator;
55};
56
57struct Action {
58 uint8_t id;
59 struct TextAndShortcut label;
60};
61
62struct ActionsChunk {
63 struct Action actions[0];
64
65 while(ReadU8(FTell()) != 0) {
66 ArrayExtend(actions);
67 }
68
69 uint8_t chunkTerminator;
70};
71
72struct Object {
73 uint16_t unknowprefix[4];
74 struct NullTerminatedString objectName;
75 struct NullTerminatedString objectDescription;
76 uint8_t actionsWhenFound[3];
77 uint8_t actionsWhenOwned[3]; // ID of the matching actions in the actions list
78};
79
80struct ObjectsChunk {
81 uint16_t unknown;
82 struct Object objects[0];
83
84 while(ReadU8(FTell()) != 0) {
85 ArrayExtend(objects);
86 }
87
88 uint8_t chunkTerminator;
89};
90
91struct StringListChunk {
92 struct NullTerminatedString stringlist[0];
93
94 while(ReadU8(FTell()) != 0x24) {
95 ArrayExtend(stringlist);
96 }
97
98 uint8_t chunkTerminator;
99};
100
101struct InitChunk {
102 uint16_t id;
103
104 if (id == 1) {
105 struct ButtonChunk buttonChunk;
106 } else if (id == 2) {
107 struct ActionsChunk actionsChunk;
108 } else if (id == 3) {
109 struct ObjectsChunk objectsChunk;
110 } else if (id == 4) {
111 struct StringListChunk toolscreensChunk;
112 } else if (id == 5) {
113 struct StringListChunk invalidactionsChunk;
114 } else if (id == 6) {
115 struct StringListChunk availableDirectionsChunk;
116 // Each of the string consists of some of the characters from "nseohbx", each corresponding
117 // to a compass direction (North, South, East, West (Ouest), Up (Haut), Down (Bas), eXit)
118 // It can also be a NULL string or a single _ char (I guess one of them hides the compass
119 // completely and the other just disables all the buttons)
120 } else if (id == 7) {
121 uint16_t unknown_chunk_7;
122 } else if (id == 8) {
123 uint16_t unknown_chunk_8[2];
124 } else if (id == 9) {
125 // This chunk is empty
126 } else {
127 uint16_t unknown_chunk;
128 }
129};
130
131struct InitChunk chunk[9];
Note: See TracBrowser for help on using the repository browser.