Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
level_format.h
Go to the documentation of this file.
1/*
2** Jo Sega Saturn Engine: level file format (JOL)
3**
4** Made by Compiler/COMMON/jo_level/gen.py from Compiler/COMMON/jo_level/schema.py: change the schema, not this file.
5** Documentation: Documentation/level_format.md
6*/
7
8#ifndef __JO_LEVEL_FORMAT_H__
9# define __JO_LEVEL_FORMAT_H__
10
12# define JO_LEVEL_MAGIC (0x4A4F4C56)
14# define JO_LEVEL_FORMAT_VERSION (1)
16# define JO_LEVEL_FLAG_REQUIRED (0x0001)
18# define JO_LEVEL_NO_STRING (0xFFFFFFFFU)
20# define JO_LEVEL_NO_INDEX (0xFFFF)
21
23# define JO_LEVEL_ID(A, B, C, D) (((unsigned int)(A) << 24) | ((unsigned int)(B) << 16) | ((unsigned int)(C) << 8) | (unsigned int)(D))
24
26typedef struct
27{
28 unsigned int magic; // v1: 'JOLV'
29 unsigned short version; // v1: Version of the file format (FORMAT_VERSION: header and directory)
30 unsigned short flags; // v1: Reserved (0)
31 unsigned int size; // v1: Size of the file (bytes)
32 unsigned int section_count; // v1: Number of entries of the directory (after this header)
34
36typedef struct
37{
38 unsigned int id; // v1: Identifier: 4 characters
39 unsigned short version; // v1: Version of the section
40 unsigned short flags; // v1: FLAG_xxx (REQUIRED: 1)
41 unsigned int offset; // v1: Offset of the section from the start of the file (multiple of 4)
42 unsigned int size; // v1: Size of the section (bytes, header, records and arrays)
43 unsigned short header_size; // v1: Size of the header of the section (bytes)
44 unsigned short record_size; // v1: Size of a record (bytes)
45 unsigned int record_count; // v1: Number of records (after the header)
47
48/*
49** INFO: Level (version 1)
50*/
51# define JO_LEVEL_SECTION_INFO JO_LEVEL_ID('I', 'N', 'F', 'O')
52# define JO_LEVEL_INFO_VERSION (1)
53
55typedef struct
56{
57 unsigned int name; // v1: Name of the level
58 unsigned int flags; // v1: Reserved (0)
60
62# define JO_LEVEL_INFO_HEADER_DEFAULTS {.name = 0xFFFFFFFF}
63
64/*
65** STRS: Strings (version 1)
66*/
67# define JO_LEVEL_SECTION_STRS JO_LEVEL_ID('S', 'T', 'R', 'S')
68# define JO_LEVEL_STRS_VERSION (1)
69
70/*
71** TERR: Terrain (version 1)
72*/
73# define JO_LEVEL_SECTION_TERR JO_LEVEL_ID('T', 'E', 'R', 'R')
74# define JO_LEVEL_TERR_VERSION (1)
75
77typedef struct
78{
79 unsigned short n; // v1: Vertices per side
80 unsigned short cell; // v1: Distance between 2 vertices (world units)
81 int origin_x; // v1: Center of the height map (world units)
82 int origin_z; // v1: Center of the height map (world units)
83 unsigned int heights; // v1: Heights: n x n i16, row after row (j), Y up (world units)
84 unsigned int colors; // v1: Colors of the vertices: n x n RGB 555 of the Saturn (the light of the sun is baked)
85 unsigned int hole_count; // v1: Number of entries of holes
86 unsigned int holes; // v1: Vertices under a building: u16 j x n + i. A quad with its 4 vertices in this list is not drawn. With the flag 0x8000 the quad is drawn, sorted behind the building
88
90# define JO_LEVEL_TERR_HEADER_DEFAULTS {}
91
92/*
93** PLNT: Plants (version 1)
94*/
95# define JO_LEVEL_SECTION_PLNT JO_LEVEL_ID('P', 'L', 'N', 'T')
96# define JO_LEVEL_PLNT_VERSION (1)
97
99typedef struct
100{
101 int x; // v1: Position (world units)
102 int y; // v1: Height of the foot, Y up (world units)
103 int z; // v1: Position (world units)
104 unsigned short kind; // v1: Kind: 0 palm tree, 1 bush, 2 fern, 3 rock, 4 tree of the inland
105 short angle; // v1: Rotation around Y (degrees)
106 unsigned short scale; // v1: Scale x 256 (256: 1)
107 unsigned char __pad0[2];
109
111# define JO_LEVEL_PLNT_RECORD_DEFAULTS {}
112
113/*
114** MODL: Models (version 1)
115*/
116# define JO_LEVEL_SECTION_MODL JO_LEVEL_ID('M', 'O', 'D', 'L')
117# define JO_LEVEL_MODL_VERSION (1)
118
120typedef struct
121{
122 unsigned int file; // v1: JOM file (in the root directory of the CD)
123 unsigned short first_box; // v1: First collision box (MBOX)
124 unsigned short box_count; // v1: Number of collision boxes
125 unsigned short has_floor; // v1: 1: the model has a floor the player can walk on
126 short floor[5]; // v1: Floor: x0, z0, x1, z1 (model space), height (Y up) (world units)
128
130# define JO_LEVEL_MODL_RECORD_DEFAULTS {.file = 0xFFFFFFFF}
131
132/*
133** MBOX: Collision boxes (version 1)
134*/
135# define JO_LEVEL_SECTION_MBOX JO_LEVEL_ID('M', 'B', 'O', 'X')
136# define JO_LEVEL_MBOX_VERSION (1)
137
139typedef struct
140{
141 short x; // v1: Center (world units)
142 short z; // v1: Center (world units)
143 short half_x; // v1: Half size (world units)
144 short half_z; // v1: Half size (world units)
146
148# define JO_LEVEL_MBOX_RECORD_DEFAULTS {}
149
150/*
151** INST: Instances (version 1)
152*/
153# define JO_LEVEL_SECTION_INST JO_LEVEL_ID('I', 'N', 'S', 'T')
154# define JO_LEVEL_INST_VERSION (1)
155
157typedef struct
158{
159 unsigned short model; // v1: Model seen from far away (MODL)
160 unsigned short near_model; // v1: Model seen from near (MODL), NO_INDEX: the same
161 unsigned short inside_model; // v1: Model of the inside, drawn from near (MODL), NO_INDEX: none
162 short yaw; // v1: Rotation around Y (degrees)
163 int x; // v1: Position (world units)
164 int y; // v1: Position, Saturn Y (down) (world units)
165 int z; // v1: Position (world units)
166 short half_x; // v1: Collision box when the model has none (model space), 0: no collision (world units)
167 short half_z; // v1: Collision box when the model has none (world units)
169
171# define JO_LEVEL_INST_RECORD_DEFAULTS {.model = 0xFFFF, .near_model = 0xFFFF, .inside_model = 0xFFFF}
172
173/*
174** DECL: Decals (version 1)
175*/
176# define JO_LEVEL_SECTION_DECL JO_LEVEL_ID('D', 'E', 'C', 'L')
177# define JO_LEVEL_DECL_VERSION (1)
178
180typedef struct
181{
182 unsigned short kind; // v1: Kind: 0 coral, 1 brain coral, 2 starfish, 3 rocks, 4 sea grass, 5 anchor, 6 barrel
183 short angle; // v1: Rotation around Y (degrees)
184 unsigned short size; // v1: Size (world units)
185 unsigned char __pad0[2];
186 int x; // v1: Position (world units)
187 int z; // v1: Position (world units)
189
191# define JO_LEVEL_DECL_RECORD_DEFAULTS {}
192
193/*
194** ENTI: Entities (version 1)
195*/
196# define JO_LEVEL_SECTION_ENTI JO_LEVEL_ID('E', 'N', 'T', 'I')
197# define JO_LEVEL_ENTI_VERSION (1)
198
200typedef struct
201{
202 unsigned int name; // v1: Name (unique in the level: the links and the game find the entity by it)
203 unsigned int cls; // v1: Class: a class of the engine (explosive, relay, trigger...) or of the game
204 unsigned int model; // v1: JOM file drawn at its position, NO_STRING: none
205 int x; // v1: Position (world units)
206 int y; // v1: Position, Saturn Y (down): the foot of the entity (world units)
207 int z; // v1: Position (world units)
208 short yaw; // v1: Rotation around Y (degrees)
209 short health; // v1: Health at the start, 0: it can't be damaged
210 unsigned short flags; // v1: ENTITY_FLAG_xxx: DISABLED 1, SOLID 2, HIDDEN 4
211 unsigned short radius; // v1: Cylinder (collisions, bullets, zone of a trigger): radius (world units)
212 unsigned short height; // v1: Cylinder: height above the foot (world units)
213 unsigned short first_prop; // v1: First property (PROP)
214 unsigned short prop_count; // v1: Number of properties
215 unsigned short first_link; // v1: First link of which it is the source (LINK)
216 unsigned short link_count; // v1: Number of links
217 unsigned char __pad0[2];
219
221# define JO_LEVEL_ENTI_RECORD_DEFAULTS {.name = 0xFFFFFFFF, .cls = 0xFFFFFFFF, .model = 0xFFFFFFFF}
222
223/*
224** PROP: Properties (version 1)
225*/
226# define JO_LEVEL_SECTION_PROP JO_LEVEL_ID('P', 'R', 'O', 'P')
227# define JO_LEVEL_PROP_VERSION (1)
228
230typedef struct
231{
232 unsigned int key; // v1: Name
233 unsigned short type; // v1: PROPERTY_xxx: INT 0, FIXED 1, STRING 2
234 unsigned char __pad0[2];
235 int value; // v1: Value (the offset of the string for a STRING)
237
239# define JO_LEVEL_PROP_RECORD_DEFAULTS {.key = 0xFFFFFFFF}
240
241/*
242** LINK: Links (version 1)
243*/
244# define JO_LEVEL_SECTION_LINK JO_LEVEL_ID('L', 'I', 'N', 'K')
245# define JO_LEVEL_LINK_VERSION (1)
246
248typedef struct
249{
250 unsigned short event; // v1: EVENT_xxx of the source
251 unsigned short action; // v1: ACTION_xxx sent to the target
252 unsigned short target; // v1: Target (ENTI), NO_INDEX: the source itself
253 unsigned short delay; // v1: Delay (ms)
254 int param; // v1: Parameter of the action (the damage of DAMAGE), -1: the parameter of the event
256
258# define JO_LEVEL_LINK_RECORD_DEFAULTS {.target = 0xFFFF, .param = -1}
259
260/*
261** CELL: Cells (version 3)
262*/
263# define JO_LEVEL_SECTION_CELL JO_LEVEL_ID('C', 'E', 'L', 'L')
264# define JO_LEVEL_CELL_VERSION (3)
265
267typedef struct
268{
269 unsigned int model; // v1: JOM file of the cell (world coordinates)
270 int x0; // v1: Box where the player can walk: smallest X (world units)
271 int z0; // v1: Smallest Z (world units)
272 int x1; // v1: Biggest X (world units)
273 int z1; // v1: Biggest Z (world units)
274 int floor0; // v1: Floor, Saturn Y (down): at x0 (slope X), at z0 (slope Z) or everywhere (flat) (world units)
275 int floor1; // v1: Floor at x1 (slope X) or at z1 (slope Z) (world units)
276 unsigned short slope; // v1: CELL_SLOPE_xxx: FLAT 0, X 1, Z 2
277 unsigned short first_portal; // v1: First portal of the cell (PRTL)
278 unsigned short portal_count; // v1: Number of portals
279 short yaw; // v2: Rotation of the box around its center (Y axis, the same as the yaw of INST): a building turned on the terrain (degrees)
280 unsigned int reflection; // v3: JOM file drawn in the mirrors of the cell instead of its model (a simpler model: bigger quads, no floor), NO_STRING: its model and the cells next to it
282
284# define JO_LEVEL_CELL_RECORD_DEFAULTS {.model = 0xFFFFFFFF, .reflection = 0xFFFFFFFF}
285
286/*
287** PRTL: Portals (version 1)
288*/
289# define JO_LEVEL_SECTION_PRTL JO_LEVEL_ID('P', 'R', 'T', 'L')
290# define JO_LEVEL_PRTL_VERSION (1)
291
293typedef struct
294{
295 unsigned short cell; // v1: Cell seen through the portal (CELL), NO_INDEX: the outside (the terrain around a building, see jo_cells_outside_view())
296 unsigned short kind; // v1: PORTAL_xxx: DOOR 0 (an opening), MIRROR 1 (a mirror of the cell), WINDOW 2 (seen through from the cell only)
297 int points[12]; // v1: The 4 corners: x, y (Saturn Y), z of each corner (world units)
299
301# define JO_LEVEL_PRTL_RECORD_DEFAULTS {.cell = 0xFFFF}
302
303/*
304** WEAP: Weapons (version 1)
305*/
306# define JO_LEVEL_SECTION_WEAP JO_LEVEL_ID('W', 'E', 'A', 'P')
307# define JO_LEVEL_WEAP_VERSION (1)
308
310typedef struct
311{
312 unsigned int name; // v1: Name
313 unsigned int model; // v1: JOM file of the weapon and the hands (first person view)
314 jo_fixed x; // v1: Position of the model in front of the camera: right (world units, Q16.16)
315 jo_fixed y; // v1: Down (world units, Q16.16)
316 jo_fixed z; // v1: Forward (world units, Q16.16)
317 jo_fixed muzzle_y; // v1: The muzzle in the model: height (the axis of the barrel) (world units, Q16.16)
318 jo_fixed muzzle_z; // v1: The muzzle in the model: forward (world units, Q16.16)
319 unsigned short convergence; // v1: The axis of the barrel crosses the line of sight at this distance (the crosshair) (world units)
320 unsigned short automatic; // v1: 1: it fires while the button is held, 0: one shot per press
321 unsigned short fire_delay; // v1: Frames between 2 shots
322 unsigned short damage; // v1: Damage of a bullet
323 unsigned short spread; // v1: Spread of the bullets: the offset at 1000 units (world units)
324 unsigned short recoil; // v1: The model goes back (frames of recoil)
325 unsigned short kick; // v1: The view goes up at each shot (degrees)
326 unsigned short magazine; // v1: Bullets of a magazine
327 unsigned short ammo_type; // v1: Type of ammunition (the weapons with the same type share their reserve)
328 unsigned short ammo_start; // v1: Reserve at the start (not in the magazine)
329 unsigned short ammo_max; // v1: Reserve at most
330 unsigned short reload_time; // v1: Frames of the reload
331 unsigned short switch_time; // v1: Frames to take this weapon (it comes up), the other one goes down in the same time
332 unsigned char __pad0[2];
333 unsigned int flash; // v1: Base name of the muzzle flashes (FLASH: FLASH1.BIN, FLASH2.BIN, FLASH3.BIN)
334 unsigned short flash_size; // v1: Size of the muzzle flash (pixels)
335 unsigned short casing; // v1: 1: the casings are ejected
336 unsigned int sound_shot; // v1: PCM file of the shot
337 unsigned int sound_reload; // v1: PCM file of the reload
338 unsigned short shot_volume; // v1: Volume of the shot (0 to 127)
339 unsigned char __pad1[2];
341
343# define JO_LEVEL_WEAP_RECORD_DEFAULTS {.name = 0xFFFFFFFF, .model = 0xFFFFFFFF, .convergence = 0x258, .fire_delay = 4, .damage = 0x19, .recoil = 0xA, .kick = 2, .magazine = 0x1E, .ammo_max = 0x3E7, .reload_time = 0x32, .switch_time = 0xC, .flash = 0xFFFFFFFF, .flash_size = 0x16, .sound_shot = 0xFFFFFFFF, .sound_reload = 0xFFFFFFFF, .shot_volume = 0x78}
344
346# define JO_LEVEL_EVENT_TRIGGER (0)
347# define JO_LEVEL_EVENT_ENTER (1)
348# define JO_LEVEL_EVENT_EXIT (2)
349# define JO_LEVEL_EVENT_DAMAGE (3)
350# define JO_LEVEL_EVENT_DEATH (4)
351
353# define JO_LEVEL_ACTION_TRIGGER (0)
354# define JO_LEVEL_ACTION_DAMAGE (1)
355# define JO_LEVEL_ACTION_KILL (2)
356# define JO_LEVEL_ACTION_ENABLE (3)
357# define JO_LEVEL_ACTION_DISABLE (4)
358# define JO_LEVEL_ACTION_TOGGLE (5)
359# define JO_LEVEL_ACTION_USE (6)
360# define JO_LEVEL_ACTION_OPEN (7)
361# define JO_LEVEL_ACTION_CLOSE (8)
362
364# define JO_LEVEL_CELL_SLOPE_FLAT (0)
365# define JO_LEVEL_CELL_SLOPE_X (1)
366# define JO_LEVEL_CELL_SLOPE_Z (2)
367
369# define JO_LEVEL_PORTAL_DOOR (0)
370# define JO_LEVEL_PORTAL_MIRROR (1)
371# define JO_LEVEL_PORTAL_WINDOW (2)
372
374# define JO_LEVEL_PROPERTY_INT (0)
375# define JO_LEVEL_PROPERTY_FIXED (1)
376# define JO_LEVEL_PROPERTY_STRING (2)
377
379# define JO_LEVEL_ENTITY_FLAG_DISABLED (0x0001)
380# define JO_LEVEL_ENTITY_FLAG_SOLID (0x0002)
381# define JO_LEVEL_ENTITY_FLAG_HIDDEN (0x0004)
382
383#endif /* !__JO_LEVEL_FORMAT_H__ */
384
385/*
386** END OF FILE
387*/
unsigned char __pad0[2]
Definition level_format.h:217
int floor1
Definition level_format.h:275
unsigned short kick
Definition level_format.h:325
unsigned short first_box
Definition level_format.h:123
unsigned char __pad0[2]
Definition level_format.h:107
int value
Definition level_format.h:235
unsigned short ammo_start
Definition level_format.h:328
unsigned short shot_volume
Definition level_format.h:338
unsigned short cell
Definition level_format.h:80
unsigned short record_size
Definition level_format.h:44
unsigned int reflection
Definition level_format.h:280
int z
Definition level_format.h:103
unsigned char __pad0[2]
Definition level_format.h:234
short health
Definition level_format.h:209
unsigned short kind
Definition level_format.h:296
short half_z
Definition level_format.h:144
short x
Definition level_format.h:141
unsigned short type
Definition level_format.h:233
int z
Definition level_format.h:207
unsigned short header_size
Definition level_format.h:43
unsigned int sound_reload
Definition level_format.h:337
unsigned short version
Definition level_format.h:29
int y
Definition level_format.h:164
unsigned short first_portal
Definition level_format.h:277
short angle
Definition level_format.h:183
unsigned short spread
Definition level_format.h:323
unsigned int record_count
Definition level_format.h:45
int x1
Definition level_format.h:272
unsigned short height
Definition level_format.h:212
unsigned short magazine
Definition level_format.h:326
int x
Definition level_format.h:163
unsigned short target
Definition level_format.h:252
unsigned short kind
Definition level_format.h:182
unsigned short size
Definition level_format.h:184
unsigned int id
Definition level_format.h:38
unsigned int flags
Definition level_format.h:58
unsigned short event
Definition level_format.h:250
short half_x
Definition level_format.h:143
int param
Definition level_format.h:254
unsigned short convergence
Definition level_format.h:319
short yaw
Definition level_format.h:279
int z0
Definition level_format.h:271
short yaw
Definition level_format.h:208
unsigned int size
Definition level_format.h:31
jo_fixed muzzle_z
Definition level_format.h:318
unsigned short flags
Definition level_format.h:30
unsigned short switch_time
Definition level_format.h:331
unsigned short flash_size
Definition level_format.h:334
unsigned char __pad0[2]
Definition level_format.h:332
unsigned short reload_time
Definition level_format.h:330
int origin_x
Definition level_format.h:81
unsigned int sound_shot
Definition level_format.h:336
int floor0
Definition level_format.h:274
jo_fixed y
Definition level_format.h:315
unsigned int cls
Definition level_format.h:203
unsigned short first_prop
Definition level_format.h:213
unsigned short flags
Definition level_format.h:40
int points[12]
Definition level_format.h:297
jo_fixed z
Definition level_format.h:316
jo_fixed muzzle_y
Definition level_format.h:317
unsigned short automatic
Definition level_format.h:320
unsigned short ammo_max
Definition level_format.h:329
unsigned short n
Definition level_format.h:79
unsigned int model
Definition level_format.h:313
unsigned short casing
Definition level_format.h:335
unsigned short scale
Definition level_format.h:106
jo_fixed x
Definition level_format.h:314
int x0
Definition level_format.h:270
unsigned char __pad0[2]
Definition level_format.h:185
int origin_z
Definition level_format.h:82
unsigned short ammo_type
Definition level_format.h:327
unsigned int offset
Definition level_format.h:41
unsigned short delay
Definition level_format.h:253
int y
Definition level_format.h:102
short half_z
Definition level_format.h:167
unsigned short version
Definition level_format.h:39
unsigned short kind
Definition level_format.h:104
unsigned int key
Definition level_format.h:232
unsigned short inside_model
Definition level_format.h:161
unsigned short slope
Definition level_format.h:276
int z
Definition level_format.h:165
short angle
Definition level_format.h:105
unsigned int name
Definition level_format.h:57
short half_x
Definition level_format.h:166
unsigned short recoil
Definition level_format.h:324
unsigned short first_link
Definition level_format.h:215
int x
Definition level_format.h:186
unsigned int hole_count
Definition level_format.h:85
unsigned int magic
Definition level_format.h:28
unsigned short near_model
Definition level_format.h:160
unsigned short portal_count
Definition level_format.h:278
unsigned int name
Definition level_format.h:312
short yaw
Definition level_format.h:162
unsigned int heights
Definition level_format.h:83
unsigned int holes
Definition level_format.h:86
unsigned short flags
Definition level_format.h:210
int z
Definition level_format.h:187
unsigned short link_count
Definition level_format.h:216
unsigned int model
Definition level_format.h:269
unsigned short radius
Definition level_format.h:211
int x
Definition level_format.h:205
unsigned short action
Definition level_format.h:251
unsigned short model
Definition level_format.h:159
unsigned int colors
Definition level_format.h:84
unsigned int model
Definition level_format.h:204
unsigned int flash
Definition level_format.h:333
unsigned int file
Definition level_format.h:122
unsigned short prop_count
Definition level_format.h:214
unsigned short box_count
Definition level_format.h:124
short z
Definition level_format.h:142
unsigned int name
Definition level_format.h:202
int z1
Definition level_format.h:273
short floor[5]
Definition level_format.h:126
unsigned short cell
Definition level_format.h:295
int x
Definition level_format.h:101
unsigned short has_floor
Definition level_format.h:125
unsigned short damage
Definition level_format.h:322
unsigned int section_count
Definition level_format.h:32
unsigned char __pad1[2]
Definition level_format.h:339
unsigned short fire_delay
Definition level_format.h:321
unsigned int size
Definition level_format.h:42
int y
Definition level_format.h:206
Cells: record (40 bytes).
Definition level_format.h:268
Decals: record (16 bytes).
Definition level_format.h:181
Directory entry (one per section, after the file header) (24 bytes).
Definition level_format.h:37
Entities: record (44 bytes).
Definition level_format.h:201
File header (16 bytes).
Definition level_format.h:27
Level: header (8 bytes).
Definition level_format.h:56
Instances: record (24 bytes).
Definition level_format.h:158
Collision boxes: record (8 bytes).
Definition level_format.h:140
Models: record (20 bytes).
Definition level_format.h:121
Plants: record (20 bytes).
Definition level_format.h:100
Properties: record (12 bytes).
Definition level_format.h:231
Portals: record (52 bytes).
Definition level_format.h:294
Terrain: header (28 bytes).
Definition level_format.h:78
Weapons: record (76 bytes).
Definition level_format.h:311
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:48