Jo Engine
2026.11.6
Jo Sega Saturn Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
jo_engine
jo
types.h
Go to the documentation of this file.
1
/*
2
** Jo Sega Saturn Engine
3
** Copyright (c) 2012-2026, Johannes Fetz (johannesfetz@gmail.com)
4
** All rights reserved.
5
**
6
** Redistribution and use in source and binary forms, with or without
7
** modification, are permitted provided that the following conditions are met:
8
** * Redistributions of source code must retain the above copyright
9
** notice, this list of conditions and the following disclaimer.
10
** * Redistributions in binary form must reproduce the above copyright
11
** notice, this list of conditions and the following disclaimer in the
12
** documentation and/or other materials provided with the distribution.
13
** * Neither the name of the Johannes Fetz nor the
14
** names of its contributors may be used to endorse or promote products
15
** derived from this software without specific prior written permission.
16
**
17
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
34
35
#ifndef __JO_TYPES_H__
36
# define __JO_TYPES_H__
37
39
# define __jo_force_inline __attribute__((always_inline)) inline
40
44
# define __jo_may_alias __attribute__((__may_alias__))
45
47
typedef
unsigned
int
__jo_may_alias
__jo_uint32_alias;
48
50
typedef
unsigned
short
__jo_may_alias
__jo_uint16_alias;
51
53
typedef
unsigned
short
jo_color
;
54
59
typedef
int
jo_fixed
;
60
65
typedef
short
jo_angle
;
66
68
typedef
struct
69
{
70
int
x
;
71
int
y
;
72
}
jo_pos2D
;
73
75
typedef
struct
76
{
77
jo_fixed
x
;
78
jo_fixed
y
;
79
}
jo_pos2D_fixed
;
80
84
typedef
struct
85
{
86
int
x
;
87
int
y
;
88
int
z
;
89
}
jo_pos3D
;
90
93
typedef
struct
94
{
95
float
x
;
96
float
y
;
97
float
z
;
98
}
jo_pos3Df
;
99
102
typedef
struct
103
{
104
jo_fixed
x
;
105
jo_fixed
y
;
106
jo_fixed
z
;
107
}
jo_pos3D_fixed
;
108
111
typedef
struct
112
{
113
int
rx
;
114
int
ry
;
115
int
rz
;
116
}
jo_rot3D
;
117
120
typedef
struct
121
{
122
float
rx
;
123
float
ry
;
124
float
rz
;
125
}
jo_rot3Df
;
126
130
typedef
struct
131
{
132
jo_pos3D
;
133
short
rz
;
134
}
jo_2d_object_attributes
;
135
139
typedef
struct
140
{
141
jo_2d_object_attributes
;
142
short
rx
;
143
short
ry
;
144
}
jo_3d_object_attributes
;
145
147
typedef
struct
148
{
149
float
x
;
150
float
y
;
151
float
z
;
152
}
jo_vectorf
;
153
157
typedef
struct
158
{
159
jo_pos3D
;
160
}
jo_vector
;
161
165
typedef
struct
166
{
167
jo_pos3D_fixed
;
168
}
jo_vector_fixed
;
169
171
typedef
struct
172
{
173
jo_fixed
x
;
174
jo_fixed
y
;
175
}
jo_vector2_fixed
;
176
180
typedef
struct
181
{
182
jo_pos3D_fixed
;
183
jo_fixed
w
;
184
}
jo_vector4_fixed
;
185
187
typedef
union
188
{
189
float
m
[4][4];
190
float
table
[16];
191
struct
192
{
193
float
m00
,
m01
,
m02
,
m03
;
194
float
m10
,
m11
,
m12
,
m13
;
195
float
m20
,
m21
,
m22
,
m23
;
196
float
m30
,
m31
,
m32
,
m33
;
197
};
198
}
jo_matrixf
;
199
201
typedef
union
202
{
203
jo_fixed
m
[4][4];
204
jo_fixed
table
[16];
205
struct
206
{
207
jo_fixed
m00
,
m01
,
m02
,
m03
;
208
jo_fixed
m10
,
m11
,
m12
,
m13
;
209
jo_fixed
m20
,
m21
,
m22
,
m23
;
210
jo_fixed
m30
,
m31
,
m32
,
m33
;
211
};
212
}
jo_matrix
;
213
215
typedef
struct
__jo_size
216
{
217
unsigned
short
width
;
218
unsigned
short
height
;
219
}
jo_size
;
220
224
typedef
struct
225
{
226
unsigned
short
width
;
227
unsigned
short
height
;
228
unsigned
short
adr
;
229
unsigned
short
size
;
230
}
jo_texture_definition
;
231
233
typedef
struct
234
{
235
unsigned
short
index
;
236
unsigned
short
color_mode
;
237
void
*
data
;
238
}
jo_picture_definition
;
239
241
typedef
struct
242
{
243
unsigned
short
width
;
244
unsigned
short
height
;
245
jo_color
*
data
;
246
}
jo_img
;
247
249
typedef
struct
250
{
251
unsigned
short
width
;
252
unsigned
short
height
;
253
unsigned
char
*
data
;
254
}
jo_img_8bits
;
255
259
typedef
struct
__jo_may_alias
260
{
261
unsigned
short
width;
262
unsigned
short
height
;
263
void
*
data
;
264
}
jo_raw_img
;
265
267
typedef
struct
268
{
269
jo_color
*
data
;
270
int
id
;
271
}
jo_palette
;
272
274
typedef
struct
275
{
276
int
x
;
277
int
y
;
278
unsigned
short
width
;
279
unsigned
short
height
;
280
}
jo_tile
;
281
283
typedef
struct
284
{
285
unsigned
short
effect
;
286
unsigned
short
direction
;
287
unsigned
int
color_table_index
;
288
unsigned
int
gouraud_shading_index
;
289
jo_fixed
fixed_scale_x
;
290
jo_fixed
fixed_scale_y
;
291
unsigned
int
clipping
;
292
unsigned
int
mask_lut
;
// The 16 colors textures drawn as masks: this color lookup table (VRAM address / 8,
293
// all its colors 0) instead of their own, 0: none (see jo_3d_transparency_mask_begin())
294
}
jo_sprite_attributes
;
295
297
typedef
union
298
{
299
float
f
;
300
struct
301
{
302
unsigned
int
sign
: 1;
303
unsigned
int
exponent
: 8;
304
unsigned
int
mantissa
: 23;
305
306
} field;
307
}
jo_IEEE754
;
308
310
typedef
struct
311
{
312
int
id
;
313
int
size
;
314
int
read
;
315
void
*
handle
;
316
char
*
read_buffer
;
317
int
read_index
;
318
int
read_buffer_size
;
319
void
*
lz
;
// Compressed file (see jo_fs_open()): the state of the decompression, JO_NULL: not compressed
320
int
raw_size
;
// Compressed file: its size on the CD (size: the data once decompressed)
321
int
raw_read
;
// Compressed file: the bytes read on the CD
322
}
jo_file
;
323
325
typedef
enum
326
{
327
NONE
,
328
LEFT
,
329
RIGHT
,
330
UP
,
331
DOWN
,
332
UP_LEFT
,
333
UP_RIGHT
,
334
DOWN_LEFT
,
335
DOWN_RIGHT
336
}
jo_8_directions
;
337
339
typedef
enum
340
{
341
/* Technical Name */
342
JO_NBG0_SCREEN
= (1<<0),
343
JO_NBG1_SCREEN
= (1<<1),
344
JO_NBG2_SCREEN
= (1<<2),
345
JO_NBG3_SCREEN
= (1<<3),
346
JO_RBG0_SCREEN
= (1<<4),
347
JO_BACK_SCREEN
= (1<<5),
348
JO_SPRITE_SCREEN
= (1<<6),
349
/* User friendly alias */
350
JO_VDP2_3D_PLANE_SCREEN
=
JO_RBG0_SCREEN
,
351
JO_LNCL_SCREEN
=
JO_BACK_SCREEN
,
352
/* Helper */
353
JO_ALL_SCROLL_SCREEN
=
JO_NBG0_SCREEN
|
JO_NBG1_SCREEN
|
JO_NBG2_SCREEN
|
JO_NBG3_SCREEN
|
JO_RBG0_SCREEN
|
JO_BACK_SCREEN
|
JO_SPRITE_SCREEN
354
}
jo_scroll_screen
;
355
356
#endif
/* !__JO_TYPES_H__ */
357
358
/*
359
** END OF FILE
360
*/
data
void * data
Definition
entity.h:19
height
int height
Definition
entity.h:4
jo_vectorf::y
float y
Definition
types.h:150
jo_IEEE754::[struct].field::exponent
unsigned int exponent
jo_vector4_fixed::w
jo_fixed w
Definition
types.h:183
jo_file::handle
void * handle
Definition
types.h:315
jo_img_8bits::height
unsigned short height
Definition
types.h:252
jo_rot3D::ry
int ry
Definition
types.h:114
jo_IEEE754::[struct].field::mantissa
unsigned int mantissa
jo_file::read_buffer
char * read_buffer
Definition
types.h:316
__jo_may_alias
#define __jo_may_alias
The memory of an object of another type can be accessed through this type (the strict aliasing rule o...
Definition
types.h:44
__jo_size::width
unsigned short width
Definition
types.h:217
jo_picture_definition::data
void * data
Definition
types.h:237
jo_pos3D_fixed::z
jo_fixed z
Definition
types.h:106
jo_pos2D::y
int y
Definition
types.h:71
jo_angle
short jo_angle
Angle.
Definition
types.h:65
jo_IEEE754::f
float f
Definition
types.h:299
jo_pos3D::y
int y
Definition
types.h:87
jo_tile::width
unsigned short width
Definition
types.h:278
jo_file::raw_read
int raw_read
Definition
types.h:321
jo_rot3Df::rz
float rz
Definition
types.h:124
jo_sprite_attributes::color_table_index
unsigned int color_table_index
Definition
types.h:287
jo_pos2D_fixed::y
jo_fixed y
Definition
types.h:78
jo_pos3Df::y
float y
Definition
types.h:96
jo_img::height
unsigned short height
Definition
types.h:244
jo_rot3D::rx
int rx
Definition
types.h:113
jo_tile::y
int y
Definition
types.h:277
jo_color
unsigned short jo_color
15 bits color type
Definition
types.h:53
jo_texture_definition::height
unsigned short height
Definition
types.h:227
jo_file::read_index
int read_index
Definition
types.h:317
jo_2d_object_attributes::rz
short rz
Definition
types.h:133
jo_file::read_buffer_size
int read_buffer_size
Definition
types.h:318
jo_vector::jo_pos3D
jo_pos3D
Definition
types.h:159
jo_sprite_attributes::effect
unsigned short effect
Definition
types.h:285
jo_vector2_fixed::x
jo_fixed x
Definition
types.h:173
jo_pos3Df::z
float z
Definition
types.h:97
jo_picture_definition::index
unsigned short index
Definition
types.h:235
__jo_size::height
unsigned short height
Definition
types.h:218
jo_vector_fixed::jo_pos3D_fixed
jo_pos3D_fixed
Definition
types.h:167
jo_sprite_attributes::clipping
unsigned int clipping
Definition
types.h:291
jo_vectorf::x
float x
Definition
types.h:149
jo_pos3D_fixed::x
jo_fixed x
Definition
types.h:104
jo_pos2D::x
int x
Definition
types.h:70
jo_pos3D_fixed::y
jo_fixed y
Definition
types.h:105
jo_texture_definition::size
unsigned short size
Definition
types.h:229
jo_2d_object_attributes::jo_pos3D
jo_pos3D
Definition
types.h:132
jo_file::size
int size
Definition
types.h:313
jo_texture_definition::width
unsigned short width
Definition
types.h:226
jo_img::data
jo_color * data
Definition
types.h:245
jo_palette::id
int id
Definition
types.h:270
jo_img::width
unsigned short width
Definition
types.h:243
jo_vectorf::z
float z
Definition
types.h:151
jo_3d_object_attributes::rx
short rx
Definition
types.h:142
jo_sprite_attributes::fixed_scale_y
jo_fixed fixed_scale_y
Definition
types.h:290
jo_vector2_fixed::y
jo_fixed y
Definition
types.h:174
jo_fixed
int jo_fixed
Fixed point Q16.16 number.
Definition
types.h:59
jo_tile::x
int x
Definition
types.h:276
jo_img_8bits::data
unsigned char * data
Definition
types.h:253
jo_vector4_fixed::jo_pos3D_fixed
jo_pos3D_fixed
Definition
types.h:182
jo_size
struct __jo_size jo_size
Size struct.
jo_3d_object_attributes::jo_2d_object_attributes
jo_2d_object_attributes
Definition
types.h:141
jo_palette::data
jo_color * data
Definition
types.h:269
jo_file::read
int read
Definition
types.h:314
jo_img_8bits::width
unsigned short width
Definition
types.h:251
jo_texture_definition::adr
unsigned short adr
Definition
types.h:228
jo_file::id
int id
Definition
types.h:312
jo_pos3D::x
int x
Definition
types.h:86
jo_tile::height
unsigned short height
Definition
types.h:279
jo_file::raw_size
int raw_size
Definition
types.h:320
jo_rot3Df::rx
float rx
Definition
types.h:122
jo_sprite_attributes::mask_lut
unsigned int mask_lut
Definition
types.h:292
jo_IEEE754::[struct].field::sign
unsigned int sign
jo_pos3D::z
int z
Definition
types.h:88
jo_pos3Df::x
float x
Definition
types.h:95
jo_8_directions
jo_8_directions
8 directions definition
Definition
types.h:326
DOWN_LEFT
@ DOWN_LEFT
Definition
types.h:334
DOWN_RIGHT
@ DOWN_RIGHT
Definition
types.h:335
UP_RIGHT
@ UP_RIGHT
Definition
types.h:333
DOWN
@ DOWN
Definition
types.h:331
UP_LEFT
@ UP_LEFT
Definition
types.h:332
UP
@ UP
Definition
types.h:330
NONE
@ NONE
Definition
types.h:327
LEFT
@ LEFT
Definition
types.h:328
RIGHT
@ RIGHT
Definition
types.h:329
jo_sprite_attributes::gouraud_shading_index
unsigned int gouraud_shading_index
Definition
types.h:288
jo_pos2D_fixed::x
jo_fixed x
Definition
types.h:77
jo_sprite_attributes::direction
unsigned short direction
Definition
types.h:286
jo_file::lz
void * lz
Definition
types.h:319
jo_3d_object_attributes::ry
short ry
Definition
types.h:143
jo_picture_definition::color_mode
unsigned short color_mode
Definition
types.h:236
jo_raw_img
jo_raw_img
Definition
types.h:264
jo_scroll_screen
jo_scroll_screen
Sega Saturn Scroll Screen Ids.
Definition
types.h:340
JO_NBG3_SCREEN
@ JO_NBG3_SCREEN
Definition
types.h:345
JO_ALL_SCROLL_SCREEN
@ JO_ALL_SCROLL_SCREEN
Definition
types.h:353
JO_NBG2_SCREEN
@ JO_NBG2_SCREEN
Definition
types.h:344
JO_NBG0_SCREEN
@ JO_NBG0_SCREEN
Definition
types.h:342
JO_RBG0_SCREEN
@ JO_RBG0_SCREEN
Definition
types.h:346
JO_BACK_SCREEN
@ JO_BACK_SCREEN
Definition
types.h:347
JO_LNCL_SCREEN
@ JO_LNCL_SCREEN
Definition
types.h:351
JO_SPRITE_SCREEN
@ JO_SPRITE_SCREEN
Definition
types.h:348
JO_VDP2_3D_PLANE_SCREEN
@ JO_VDP2_3D_PLANE_SCREEN
Definition
types.h:350
JO_NBG1_SCREEN
@ JO_NBG1_SCREEN
Definition
types.h:343
jo_sprite_attributes::fixed_scale_x
jo_fixed fixed_scale_x
Definition
types.h:289
jo_rot3D::rz
int rz
Definition
types.h:115
jo_rot3Df::ry
float ry
Definition
types.h:123
__jo_size
Size struct.
Definition
types.h:216
jo_2d_object_attributes
Object for 2D manipulation (storyboard) using fixed number.
Definition
types.h:131
jo_3d_object_attributes
Object for 3D manipulation (storyboard) using fixed number.
Definition
types.h:140
jo_file
File definition.
Definition
types.h:311
jo_img
15 bits image struct
Definition
types.h:242
jo_img_8bits
8 bits image struct
Definition
types.h:250
jo_palette
Palette contents struct.
Definition
types.h:268
jo_picture_definition
Picture definition.
Definition
types.h:234
jo_pos2D
2D position
Definition
types.h:69
jo_pos2D_fixed
2D position using fixed number
Definition
types.h:76
jo_pos3D
3D position
Definition
types.h:85
jo_pos3D_fixed
3D position using fixed numbers
Definition
types.h:103
jo_pos3Df
3D position using floating numbers
Definition
types.h:94
jo_rot3D
3D rotation angles
Definition
types.h:112
jo_rot3Df
3D rotation angles
Definition
types.h:121
jo_sprite_attributes
Sprite attributes.
Definition
types.h:284
jo_texture_definition
Texture definition.
Definition
types.h:225
jo_tile
Struct of one tile (pos and size).
Definition
types.h:275
jo_vector
Vector for 3D computation using integer.
Definition
types.h:158
jo_vector2_fixed
Vector for 2D computation using fixed number.
Definition
types.h:172
jo_vector4_fixed
Vector4 for 3D computation using fixed number.
Definition
types.h:181
jo_vector_fixed
Vector for 3D computation using fixed number.
Definition
types.h:166
jo_vectorf
Vector for 3D computation using floating numbers.
Definition
types.h:148
jo_IEEE754
Float IEEE 754 format.
Definition
types.h:298
jo_matrix
4x4 MATRIX for 3D computation using fixed number
Definition
types.h:202
jo_matrix::[struct].__unnamed0__::m31
jo_fixed m31
jo_matrix::[struct].__unnamed0__::m13
jo_fixed m13
jo_matrix::table
jo_fixed table[16]
Definition
types.h:204
jo_matrix::[struct].__unnamed0__::m11
jo_fixed m11
jo_matrix::[struct].__unnamed0__::m00
jo_fixed m00
jo_matrix::[struct].__unnamed0__::m23
jo_fixed m23
jo_matrix::[struct].__unnamed0__::m12
jo_fixed m12
jo_matrix::[struct].__unnamed0__::m03
jo_fixed m03
jo_matrix::[struct].__unnamed0__::m30
jo_fixed m30
jo_matrix::m
jo_fixed m[4][4]
Definition
types.h:203
jo_matrix::[struct].__unnamed0__::m01
jo_fixed m01
jo_matrix::[struct].__unnamed0__::m22
jo_fixed m22
jo_matrix::[struct].__unnamed0__::m32
jo_fixed m32
jo_matrix::[struct].__unnamed0__::m02
jo_fixed m02
jo_matrix::[struct].__unnamed0__::m21
jo_fixed m21
jo_matrix::[struct].__unnamed0__::m10
jo_fixed m10
jo_matrix::[struct].__unnamed0__::m33
jo_fixed m33
jo_matrix::[struct].__unnamed0__::m20
jo_fixed m20
jo_matrixf
4x4 MATRIX for 3D computation using floating numbers
Definition
types.h:188
jo_matrixf::table
float table[16]
Definition
types.h:190
jo_matrixf::[struct].__unnamed0__::m11
float m11
jo_matrixf::[struct].__unnamed0__::m10
float m10
jo_matrixf::[struct].__unnamed0__::m23
float m23
jo_matrixf::[struct].__unnamed0__::m02
float m02
jo_matrixf::[struct].__unnamed0__::m20
float m20
jo_matrixf::m
float m[4][4]
Definition
types.h:189
jo_matrixf::[struct].__unnamed0__::m21
float m21
jo_matrixf::[struct].__unnamed0__::m31
float m31
jo_matrixf::[struct].__unnamed0__::m12
float m12
jo_matrixf::[struct].__unnamed0__::m00
float m00
jo_matrixf::[struct].__unnamed0__::m22
float m22
jo_matrixf::[struct].__unnamed0__::m32
float m32
jo_matrixf::[struct].__unnamed0__::m01
float m01
jo_matrixf::[struct].__unnamed0__::m33
float m33
jo_matrixf::[struct].__unnamed0__::m30
float m30
jo_matrixf::[struct].__unnamed0__::m13
float m13
jo_matrixf::[struct].__unnamed0__::m03
float m03
Generated by
1.18.0