added documentation on gm8 .exe format
[gaemu.git] / gaem / ungmk / EXEFormat.txt
blob97a90c875256c90862af60198ed8fe20c1de2b5e
1 GM8 EXE Format
2 v1.2 - Zach, original by Charlie
4 This document loosely follows IsmAvatar's documenting style, mostly because my typical
5 documentation style doesn't work well with GM formats, seeing as how it expects the format
6 to not be completely fucked.
8 Note that many of the structures in the EXE follow closely to the GMK format.
9 Also note that types such as timestamps, booleans, doubles, etc use the same format as the
10 GMK. Refer to IsmAvatar's GMK documentation for more detail.
12 Comments will be inside of brackets, [ ]
14 GMK Format (>=v5.3a): http://www.ismavatar.com/lgm/formats/gmformat8.txt
16 Please let me know if you find any errors or can fill in an unknown field.
18 Cheers, Zach.
21 --- Main Format ---
23  0 4b Magic
24  4 4b Version
25  8 4b Debug flag
27  0 4b Version                                                                   [ Settings ]
28  4 4b LenOfData         { Compressed <Settings> }
30  0 4b LenOfStr          { String }                                              [ DX8 Wrapper ]
31  4 4b LenOfData         { Compressed <d3dx8.dll> }
33  0 4b NumberOfDwords                                                            [ d1 ]
34  4 4b NumberOfDwords                                                            [ d2 ]
35  8 ?b Junk size of d1 * 4
36  0 512b Swap Table
37  0 ?b Junk size of d2 * 4
39  0 4b LenOfData         { Data }                                                [ Encrypted ]
41          0 4b NumberOfDwords                                                    [ d3 ]
42          4 4b Junk size of d3 * 4
44          0 4b Pro
45          4 4b GameID
46          8 16b Unknown
48         18 4b Version                                                           [ Extensions ]
49         1C 4b ExtensionCount
50         For ExtensionCount {
51                 <Extension>
52         }
54          0 4b Version                                                           [ Triggers ]
55          4 4b TriggerCount
56         For TriggerCount {
57                 0 4b LenOfData  { Compressed <Trigger> }
58         }
60          0 4b Version                                                           [ Constants ]
61          4 4b ConstantCount
62         For ConstantCount {
63                 <Constant>
64         }
66         <Sounds, Sprites, Backgrounds, Paths, Scripts, Fonts, TimeLines, Objects, Rooms>
67          0 4b Version
68          4 4b Count
69         For Count {
70                 0 4b LenOfData  { Compressed data }
71         }
73          0 4b ID of last object placed
74          4 4b ID of last tile placed
76          0 4b Version                                                           [ Includes ]
77          4 4b IncludeCount
78         For IncludeCount {
79                 0 4b LenOfData  { Compressed <Include> }
80         }
82          0 4b Version                                                           [ Help ]
83          4 4b LenOfData { Compressed <Help> }
85          0 4b Version                                                           [ Library Init Code ]
86          4 4b Count
87         For Count {
88                 0 4b LenOfString  { String }
89         }
91          0 4b Version                                                           [ Room order ]
92          4 4b Count
93         For Count {
94                 0 4b RoomID
95         }
97         <More junk>
100 <End Of File>
102 --- Resource Formats ---
104 <Settings> {
105          0 4b Full screen
106          4 4b Interpolate colors
107          8 4b No border around window
108          C 4b Show cursor
109         10 4b Scale
110         14 4b Resizable
111         18 4b Always on top
112         1C 4b Color outside room
113         20 4b Set resolution/refresh rate/bit depth
114         24 4b Bit depth option
115         28 4b Resolution option
116         2C 4b Refresh rate option
117         30 4b No buttons in window caption
118         34 4b Use vsync to avoid tearing
119         38 4b Disable screensavers
120         3C 4b F4 changes to fullscreen
121         40 4b F1 shows info
122         44 4b Esc closes game
123         48 4b F5 and F6 save and load respectively
124         4C 4b F9 takes a screenshot
125         50 4b Close button treated as Esc
126         54 4b Priority
127         58 4b Freeze on loss of focus
129         5C 4b ShowBar
130         If ShowBar {
131                 60 4b ProgressBack Present
132                 If Present {
133                         64 4b LenOfData { Compressed <Bitmap> }
134                 }
136                  0 4b ProgessFore Present
137                 If Present {
138                         4 4b LenOfData { Compressed <Bitmap> }
139                 }
140         }
142          0 4b Background Present
143         If Presents {
144                  4 4b LenOfData { Compressed <Bitmap> }
145         }
147          0 4b Loading screen is translucent
148          4 4b Loading screen translucency
149          8 4b Scale progress bar indicator
150          C 4b Show errors
151         10 4b Log errors
152         14 4b Errors are all fatal
153         18 4b Treat uninitialized vars as 0
156 <Extension> {
157          0 4b Version
158          4 4b Length    { String <Name> }
159          0 4b Length    { String <TempName> }
160          0 4b Count
161         For Count {
162                  0 4b Version
163                  4 4b Length    { String <Filename> }
164                  0 4b Type                                              [ GML, DLL, Lib, Other ]
165                  4 4b Length    { String <InitializationCode> }
166                  0 4b Length    { String <FinalizationCode> }
168                  0 4b Count*
169                 For Count {
170                          0 4b Version
171                          4 4b Length    { String <Name> }
172                          0 4b Length    { String <ExternalName> }
173                          0 4b CallType                  [ 2 = GML, 12 = stdcall, 13 = cdecl ]
174                          4 4b Internal ID?              [ Starts at 0x100 ]
175                          8 4b ArgumentCount
176                         For ArgumentCount {
177                                  0 4b ArgumentKind      [ 1 = String, 2 = Real ]
178                         }
180                          0 4b ConstantCount
181                         For ConstantCount {
182                                  0 4b Version
183                                  4 4b Length    { String <Name> }
184                                  0 4b Length    { String <Value> }
185                         }
186                 }
188                 [ Note: This section is a bit odd, Mark flip-flops
189                         standards here a whole lot, sorry :/            ]
190                  0 4b LenOfData { <Data> }
191                 {
192                          0 4b Seed                              [ Signed ]
193                         Encrypted {                             [ Length = CurPos - ExtensionSize ]
194                                 For Count* {                    [ Count = Count*? Not sure ]
195                                         0 4b LenOfData  { Compressed <File> }
196                                 }
197                         }
198                 }
199         }
202 <Trigger> {
203          0 4b Exists
204         If Exists {
205                  4 4b Version
206                  8 4b Length    { String <Name> }
207                  0 4b Length    { String <Condition> }
208                  4 4b When to execute
209                  8 4b Length    { String <ConstantName> }
210         }
213 <Constant> {
214          0 4b Length    { String <Name> }
215          0 4b Length    { String <Value> }
218 <Sound> {
219          0 4b Exists
220         If Exists {
221                  0 4b Length    { String <Name> }
222                  0 4b Version
223                  4 4b Kind
224                  8 4b Length    { String <Filetype (".wav")> }
225                  0 4b Length    { String <Filename ("sound.wav")> }
226                  0 4b Exists
227                 If Exists {
228                          0 4b Length    { <File> }
229                 }
231                  0 4b Effects
232                  4 8b Volume
233                  C 8b Pan
234                 14 4b Preload
235         }
238 <Sprite> {
239          0 4b Exists
240         If Exists {
241                  0 4b Length    { String <Name> }
242                  0 4b Version
243                  4 4b X-Origin
244                  8 4b Y-Origin
245                 [ Note: Again, this section is a little strange, I didn't even notice
246                         that the If {} condition existed until Goomba Online stopped decompiling
247                         at random, turns out spr_blank, which had no frames was causing it.     ]
249                  C 4b NumberOfFrames*
250                 If NumberOfFrames > 0 {
251                         For NumberOfFrames {
252                                  0 4b Version
253                                  4 4b Width
254                                  8 4b Height
255                                  C 4b LenOfData { <Raw RGBA> }
256                         }
258                          0 4b Separate Collision Mask
259                         If SepCollMask {
260                                 For NumberOfFrames* {
261                                          0 4b Version
262                                          4 4b Width
263                                          8 4b Height
264                                          C 4b Left
265                                         10 4b Right
266                                         14 4b Bottom
267                                         18 4b Top
269                                         [ Note: If you find a 1 in the following array then
270                                                 "precise collision checking" will be ticked.    ]
272                                         For Width * Height {
273                                                  0 4b Mask data
274                                         }
275                                 }
276                         } else {
277                                  0 4b Version
278                                  4 4b Width
279                                  8 4b Height
280                                  C 4b Left
281                                 10 4b Right
282                                 14 4b Bottom
283                                 18 4b Top
285                                 [ Note: If you find a 1 in the following array then
286                                                 "precise collision checking" will be ticked.    ]
288                                 For Width * Height {
289                                          0 4b Mask data
290                                 }
291                         }
292                 }
293         }
296 <Background> {
297          0 4b Exists
298         If Exists {
299                  4 4b Length    { String <Name> }
300                  0 4b Version
301                 [ Note: I believe that Mark once had tileset information that has since been removed
302                         in GM8, this may explain why there are two versions here.               ]
304                  0 4b Version
305                  4 4b Width
306                  8 4b Height
307                 If Width != 0 && Height != 0 {
308                          0 4b Length    { <Raw RGBA> }
309                 }
310         }
313 <Path> {
314          0 4b Exists
315         If Exists {
316                  4 4b Length    { String <Name> }
317                  0 4b Version
318                  4 4b Connection type
319                  8 4b Closed
320                  C 4b Precision
321                 10 4b Count
322                 For Count {
323                          0 8b X
324                          8 8b Y
325                         10 8b Speed
326                 }
327         }
330 <Script> {
331          0 4b Exists
332         If Exists {
333                  4 4b Length    { String <Name> }
334                  0 4b Version
335                  4 4b Length    { String <Script> }
336         }
339 <Font> {
340          0 4b Exists
341         If Exists {
342                  4 4b Length    { String <Name> }
343                  0 4b Version
344                  4 4b Length    { String <FontName> }
345                  0 4b Font size
346                  4 4b Bold
347                  8 4b Italic
348                  C 4b Range start
349                 10 4b Range end
350                 14 1808b Unknown                        [ Kerning? ]
351                 61C 4b Length   { <Unknown data> }      [ Font header? ]
352         }
355 <Actions*> {                                            [ Here to prevent re-documenting ]
356          0 4b Version
357          4 4b ActionCount
358         For ActionCount {
359                  0 4b Version
360                  4 4b LibID
361                  8 4b ActionID
362                  C 4b Action kind
363                 10 4b May be relative
364                 14 4b Question
365                 18 4b Applies to something
366                 1C 4b Type
367                 20 4b Length    { String <Name> }
368                  0 4b Length    { String <Code> }
370                  0 4b Arguments actually used
371                  4 4b Total number of arguments (always 8)
372                 For 8 {
373                          0 4b Argument kind
374                 }
376                  0 4b Applies to ObjectIndex
377                  4 4b Relative
379                  8 4b Number of arguments (always 8)
380                 For 8 {
381                          0 4b Length    { String <Argument> }
382                 }
384                  0 4b Not flag
385         }
388 <TimeLine> {
389          0 4b Exists
390         If Exists {
391                  4 4b Length    { String <Name> }
392                  0 4b Version
393                  4 4b MomentCount
394                 For MomentCount {
395                          0 4b Moment position
396                          <Actions*>                     [ Documented above ]
397                 }
398         }
401 <Object> {
402          0 4b Exists
403         If Exists {
404                  0 4b Length    { String <Name> }
405                  0 4b Version
406                  4 4b SpriteIndex                       [ -1 = None ]
407                  8 4b Solid
408                  C 4b Visible
409                 10 4b Depth
410                 14 4b Persistent
411                 18 4b Parent ObjectIndex
412                 1C 4b Mask SpriteIndex
414                 [ Note: I would check out LGM's SVN and the GMK documentation
415                         provided by IsmAvatar for this section, it's very, very,
416                         very, very, very, very fucked. She explains it much better than
417                         I.      ]
419                 20 4b Number of events - 1              [ Unknown reason ]
420                 For 12 {
421                         Until EventNumber == -1 {
422                                  0 4b EventNumber
423                                 If EventNumber >= 0 {
424                                         <Actions*>
425                                 }
426                         }
428                          0 4b -1                        [ Marks end of primary event ]
429                 }
430         }
433 <Room> {
434          0 4b Exists
435         If Exists {
436                  0 4b Length    { String <Name> }
437                  0 4b Version
438                  4 4b Length    { String <Room caption> }
439                  0 4b Width
440                  4 4b Height
441                  8 4b Speed
442                  C 4b Persistent
443                 10 4b BG Color
444                 14 4b Draw BG Color
445                 1C 4b Length    { String <Creation Code> }
447                  0 4b Number of backgrounds (Always 8)
448                 For 8 {
449                          0 4b Visible
450                          4 4b Foreground
451                          8 4b BackgroundIndex
452                          C 4b X
453                         10 4b Y
454                         14 4b Tile horizontal
455                         18 4b Tile vertical
456                         1C 4b Horizontal speed
457                         20 4b Vertical speed
458                         24 4b Stretch
459                 }
461                  0 4b Enable views
462                  4 4b Number of views (Always 8)
463                 For 8 {
464                          0 4b Visible
465                          4 4b View X
466                          8 4b View Y
467                          C 4b View Width
468                         10 4b View Height
469                         14 4b Port X
470                         18 4b Port Y
471                         1C 4b Port Width
472                         20 4b Port Height
473                         24 4b Horizontal border
474                         28 4b Vertical border
475                         2C 4b Horizontal speed
476                         30 4b Vertical speed
477                         34 4b Following ObjectIndex
478                 }
480                  0 4b Number of instances
481                 For NumberOfInstances {
482                          0 4b X
483                          4 4b Y
484                          8 4b ObjectIndex
485                          C 4b ID
486                         10 4b Length    { String <Creation Code> }
487                 }
489                  0 4b Number of tiles {
490                          0 4b X
491                          4 4b Y
492                          8 4b BackgroundIndex
493                          C 4b Tile X
494                         10 4b Tile Y
495                         14 4b Width
496                         18 4b Height
497                         1C 4b Layer
498                         20 4b ID
499                 }
500         }
503 <Include> {
504          0 4b Version
505          4 4b Length    { String <Filename> }
506          0 4b Length    { String <Original filename> }
507          0 4b Original file chosen
508          4 4b Original file size
509          8 4b Store in GMK
510         If OriginalFileChosen && StoreInGMK {
511                  0 4b Length    { File }
512         }
514          0 4b Export
515          4 4b Length    { String <Folder to export to> }
516          0 4b Overwrite
517          4 4b Free memory
518          8 4b Remove at end of game
521 <Help> {
522          0 4b BG Color
523          4 4b Show in separate window
524          8 4b Length    { String <Window caption> }
525          0 4b Left
526          4 4b Top
527          8 4b Width
528          C 4b Height
529         10 4b Show border
530         14 4b Allow player to resize
531         18 4b Stay on top
532         1C 4b Freeze game while help form is in focus
533         20 4b Length    { String <Game Information> }