Jo Engine  2024.04.28
Jo Sega Saturn Engine
types.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2024, 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 */
35 #ifndef __JO_TYPES_H__
36 # define __JO_TYPES_H__
37 
39 # define __jo_force_inline __attribute__((always_inline)) inline
40 
42 typedef unsigned short jo_color;
43 
49 typedef int jo_fixed;
50 
52 typedef struct
53 {
54  int x;
55  int y;
56 } jo_pos2D;
57 
59 typedef struct
60 {
64 
68 typedef struct
69 {
70  int x;
71  int y;
72  int z;
73 } jo_pos3D;
74 
77 typedef struct
78 {
79  float x;
80  float y;
81  float z;
82 } jo_pos3Df;
83 
86 typedef struct
87 {
92 
95 typedef struct
96 {
97  int rx;
98  int ry;
99  int rz;
100 } jo_rot3D;
101 
104 typedef struct
105 {
106  float rx;
107  float ry;
108  float rz;
109 } jo_rot3Df;
110 
114 typedef struct
115 {
117  short rz;
119 
123 typedef struct
124 {
126  short rx;
127  short ry;
129 
131 typedef struct
132 {
133  float x;
134  float y;
135  float z;
136 } jo_vectorf;
137 
141 typedef struct
142 {
144 } jo_vector;
145 
149 typedef struct
150 {
153 
155 typedef struct
156 {
160 
164 typedef struct
165 {
169 
171 typedef union
172 {
173  float m[4][4];
174  float table[16];
175  struct
176  {
177  float m00, m01, m02, m03;
178  float m10, m11, m12, m13;
179  float m20, m21, m22, m23;
180  float m30, m31, m32, m33;
181  };
182 } jo_matrixf;
183 
185 typedef union
186 {
187  jo_fixed m[4][4];
188  jo_fixed table[16];
189  struct
190  {
191  jo_fixed m00, m01, m02, m03;
192  jo_fixed m10, m11, m12, m13;
193  jo_fixed m20, m21, m22, m23;
194  jo_fixed m30, m31, m32, m33;
195  };
196 } jo_matrix;
197 
199 typedef struct __jo_size
200 {
201  unsigned short width;
202  unsigned short height;
204 
208 typedef struct
209 {
210  unsigned short width;
211  unsigned short height;
212  unsigned short adr;
213  unsigned short size;
215 
217 typedef struct
218 {
219  unsigned short index;
220  unsigned short color_mode;
221  void *data;
223 
225 typedef struct
226 {
227  unsigned short width;
228  unsigned short height;
230 } jo_img;
231 
233 typedef struct
234 {
235  unsigned short width;
236  unsigned short height;
237  unsigned char *data;
238 } jo_img_8bits;
239 
241 typedef struct
242 {
243  unsigned short width;
244  unsigned short height;
245  void *data;
246 } jo_raw_img;
247 
249 typedef struct
250 {
252  int id;
253 } jo_palette;
254 
256 typedef struct
257 {
258  int x;
259  int y;
260  unsigned short width;
261  unsigned short height;
262 } jo_tile;
263 
265 typedef struct
266 {
267  unsigned short effect;
268  unsigned short direction;
269  unsigned int color_table_index;
270  unsigned int gouraud_shading_index;
273  unsigned int clipping;
275 
277 typedef union
278 {
279  float f;
280  struct
281  {
282  unsigned int sign : 1;
283  unsigned int exponent : 8;
284  unsigned int mantissa : 23;
285 
286  } field;
287 } jo_IEEE754;
288 
290 typedef struct
291 {
292  int id;
293  int size;
294  int read;
295  void *handle;
296  char *read_buffer;
298 } jo_file;
299 
301 typedef enum
302 {
306  UP,
311  DOWN_RIGHT
313 
315 typedef enum
316 {
317  /* Technical Name */
318  JO_NBG0_SCREEN = (1<<0),
319  JO_NBG1_SCREEN = (1<<1),
320  JO_NBG2_SCREEN = (1<<2),
321  JO_NBG3_SCREEN = (1<<3),
322  JO_RBG0_SCREEN = (1<<4),
323  JO_BACK_SCREEN = (1<<5),
325  /* User friendly alias */
328  /* Helper */
331 
332 #endif /* !__JO_TYPES_H__ */
333 
334 /*
335 ** END OF FILE
336 */
jo_picture_definition::color_mode
unsigned short color_mode
Definition: types.h:220
jo_vector
Vector for 3D computation using integer.
Definition: types.h:142
RIGHT
@ RIGHT
Definition: types.h:305
jo_file::read
int read
Definition: types.h:294
jo_img_8bits::height
unsigned short height
Definition: types.h:236
JO_NBG1_SCREEN
@ JO_NBG1_SCREEN
Definition: types.h:319
jo_rot3Df::ry
float ry
Definition: types.h:107
UP_RIGHT
@ UP_RIGHT
Definition: types.h:309
jo_vectorf::y
float y
Definition: types.h:134
jo_img_8bits::width
unsigned short width
Definition: types.h:235
jo_pos3Df::z
float z
Definition: types.h:81
jo_file::read_index
int read_index
Definition: types.h:297
jo_file::read_buffer
char * read_buffer
Definition: types.h:296
UP_LEFT
@ UP_LEFT
Definition: types.h:308
jo_raw_img::width
unsigned short width
Definition: types.h:243
__jo_size
Size struct.
Definition: types.h:200
jo_3d_object_attributes::rx
short rx
Definition: types.h:126
jo_vectorf::z
float z
Definition: types.h:135
jo_pos2D_fixed::y
jo_fixed y
Definition: types.h:62
jo_palette::data
jo_color * data
Definition: types.h:251
jo_picture_definition::data
void * data
Definition: types.h:221
jo_pos3Df
3D position using floating numbers
Definition: types.h:78
jo_sprite_attributes::effect
unsigned short effect
Definition: types.h:267
jo_pos3D_fixed::x
jo_fixed x
Definition: types.h:88
__jo_size::height
unsigned short height
Definition: types.h:202
DOWN_RIGHT
@ DOWN_RIGHT
Definition: types.h:311
jo_texture_definition
Texture definition.
Definition: types.h:209
jo_vector4_fixed
Vector4 for 3D computation using fixed number.
Definition: types.h:165
JO_NBG3_SCREEN
@ JO_NBG3_SCREEN
Definition: types.h:321
jo_vector2_fixed
Vector for 2D computation using fixed number.
Definition: types.h:156
UP
@ UP
Definition: types.h:306
JO_SPRITE_SCREEN
@ JO_SPRITE_SCREEN
Definition: types.h:324
jo_tile::width
unsigned short width
Definition: types.h:260
jo_picture_definition::index
unsigned short index
Definition: types.h:219
jo_texture_definition::adr
unsigned short adr
Definition: types.h:212
jo_pos3Df::x
float x
Definition: types.h:79
jo_vector4_fixed::jo_pos3D_fixed
jo_pos3D_fixed
Definition: types.h:166
jo_pos3Df::y
float y
Definition: types.h:80
jo_palette
Palette contents struct.
Definition: types.h:250
jo_sprite_attributes::color_table_index
unsigned int color_table_index
Definition: types.h:269
jo_texture_definition::size
unsigned short size
Definition: types.h:213
jo_tile
Struct of one tile (pos and size)
Definition: types.h:257
jo_size
struct __jo_size jo_size
Size struct.
jo_sprite_attributes::fixed_scale_y
jo_fixed fixed_scale_y
Definition: types.h:272
jo_pos3D::z
int z
Definition: types.h:72
jo_texture_definition::height
unsigned short height
Definition: types.h:211
jo_color
unsigned short jo_color
15 bits color type
Definition: types.h:42
jo_rot3Df::rx
float rx
Definition: types.h:106
jo_vector_fixed::jo_pos3D_fixed
jo_pos3D_fixed
Definition: types.h:151
jo_3d_object_attributes::jo_2d_object_attributes
jo_2d_object_attributes
Definition: types.h:125
jo_sprite_attributes::direction
unsigned short direction
Definition: types.h:268
jo_picture_definition
Picture definition.
Definition: types.h:218
JO_ALL_SCROLL_SCREEN
@ JO_ALL_SCROLL_SCREEN
Definition: types.h:329
jo_vector::jo_pos3D
jo_pos3D
Definition: types.h:143
jo_img_8bits::data
unsigned char * data
Definition: types.h:237
jo_tile::x
int x
Definition: types.h:258
jo_img_8bits
8 bits image struct
Definition: types.h:234
JO_NBG2_SCREEN
@ JO_NBG2_SCREEN
Definition: types.h:320
jo_fixed
int jo_fixed
Fixed point Q16.16 number.
Definition: types.h:49
JO_RBG0_SCREEN
@ JO_RBG0_SCREEN
Definition: types.h:322
jo_matrix
4x4 MATRIX for 3D computation using fixed number
Definition: types.h:186
jo_pos3D::y
int y
Definition: types.h:71
jo_vector2_fixed::x
jo_fixed x
Definition: types.h:157
jo_tile::y
int y
Definition: types.h:259
NONE
@ NONE
Definition: types.h:303
JO_NBG0_SCREEN
@ JO_NBG0_SCREEN
Definition: types.h:318
jo_rot3D
3D rotation angles
Definition: types.h:96
jo_vector_fixed
Vector for 3D computation using fixed number.
Definition: types.h:150
jo_2d_object_attributes
Object for 2D manipulation (storyboard) using fixed number.
Definition: types.h:115
jo_3d_object_attributes::ry
short ry
Definition: types.h:127
jo_vectorf::x
float x
Definition: types.h:133
jo_img::data
jo_color * data
Definition: types.h:229
jo_vector2_fixed::y
jo_fixed y
Definition: types.h:158
jo_rot3Df
3D rotation angles
Definition: types.h:105
jo_vector4_fixed::w
jo_fixed w
Definition: types.h:167
__jo_size::width
unsigned short width
Definition: types.h:201
jo_pos3D_fixed::z
jo_fixed z
Definition: types.h:90
jo_sprite_attributes::gouraud_shading_index
unsigned int gouraud_shading_index
Definition: types.h:270
jo_img::height
unsigned short height
Definition: types.h:228
DOWN
@ DOWN
Definition: types.h:307
jo_raw_img::data
void * data
Definition: types.h:245
jo_rot3D::rz
int rz
Definition: types.h:99
jo_pos3D
3D position
Definition: types.h:69
jo_IEEE754
Float IEEE 754 format.
Definition: types.h:278
jo_pos3D::x
int x
Definition: types.h:70
jo_file::handle
void * handle
Definition: types.h:295
jo_matrixf
4x4 MATRIX for 3D computation using floating numbers
Definition: types.h:172
jo_IEEE754::f
float f
Definition: types.h:279
jo_sprite_attributes::fixed_scale_x
jo_fixed fixed_scale_x
Definition: types.h:271
jo_rot3D::ry
int ry
Definition: types.h:98
jo_file::size
int size
Definition: types.h:293
jo_pos2D_fixed::x
jo_fixed x
Definition: types.h:61
jo_pos3D_fixed::y
jo_fixed y
Definition: types.h:89
jo_2d_object_attributes::rz
short rz
Definition: types.h:117
jo_8_directions
jo_8_directions
8 directions definition
Definition: types.h:302
jo_sprite_attributes::clipping
unsigned int clipping
Definition: types.h:273
jo_file::id
int id
Definition: types.h:292
jo_sprite_attributes
Sprite attributes.
Definition: types.h:266
jo_pos2D
2D position
Definition: types.h:53
jo_2d_object_attributes::jo_pos3D
jo_pos3D
Definition: types.h:116
jo_texture_definition::width
unsigned short width
Definition: types.h:210
jo_pos3D_fixed
3D position using fixed numbers
Definition: types.h:87
JO_VDP2_3D_PLANE_SCREEN
@ JO_VDP2_3D_PLANE_SCREEN
Definition: types.h:326
jo_rot3Df::rz
float rz
Definition: types.h:108
jo_pos2D::x
int x
Definition: types.h:54
DOWN_LEFT
@ DOWN_LEFT
Definition: types.h:310
jo_file
File definition.
Definition: types.h:291
jo_img::width
unsigned short width
Definition: types.h:227
JO_BACK_SCREEN
@ JO_BACK_SCREEN
Definition: types.h:323
jo_pos2D_fixed
2D position using fixed number
Definition: types.h:60
jo_tile::height
unsigned short height
Definition: types.h:261
jo_raw_img::height
unsigned short height
Definition: types.h:244
jo_vectorf
Vector for 3D computation using floating numbers.
Definition: types.h:132
jo_raw_img
Raw image struct.
Definition: types.h:242
JO_LNCL_SCREEN
@ JO_LNCL_SCREEN
Definition: types.h:327
jo_pos2D::y
int y
Definition: types.h:55
jo_rot3D::rx
int rx
Definition: types.h:97
jo_palette::id
int id
Definition: types.h:252
jo_img
15 bits image struct
Definition: types.h:226
jo_3d_object_attributes
Object for 3D manipulation (storyboard) using fixed number.
Definition: types.h:124
LEFT
@ LEFT
Definition: types.h:304
jo_scroll_screen
jo_scroll_screen
Sega Saturn Scroll Screen Ids.
Definition: types.h:316