Jo Engine  2020.06.22
Jo Sega Saturn Engine
types.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2020, 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 typedef unsigned short jo_color;
40 
46 typedef int jo_fixed;
47 
49 typedef struct
50 {
51  int x;
52  int y;
53 } jo_pos2D;
54 
56 typedef struct
57 {
61 
65 typedef struct
66 {
67  int x;
68  int y;
69  int z;
70 } jo_pos3D;
71 
74 typedef struct
75 {
76  float x;
77  float y;
78  float z;
79 } jo_pos3Df;
80 
83 typedef struct
84 {
89 
92 typedef struct
93 {
94  int rx;
95  int ry;
96  int rz;
97 } jo_rot3D;
98 
101 typedef struct
102 {
103  float rx;
104  float ry;
105  float rz;
106 } jo_rot3Df;
107 
111 typedef struct
112 {
114  short rz;
116 
120 typedef struct
121 {
123  short rx;
124  short ry;
126 
128 typedef struct
129 {
130  float x;
131  float y;
132  float z;
133 } jo_vectorf;
134 
138 typedef struct
139 {
141 } jo_vector;
142 
146 typedef struct
147 {
150 
152 typedef union
153 {
154  float m[4][4];
155  float table[16];
156  struct
157  {
158  float m00, m01, m02, m03;
159  float m10, m11, m12, m13;
160  float m20, m21, m22, m23;
161  float m30, m31, m32, m33;
162  };
163 } jo_matrixf;
164 
166 typedef union
167 {
168  int m[4][4];
169  int table[16];
170  struct
171  {
172  int m00, m01, m02, m03;
173  int m10, m11, m12, m13;
174  int m20, m21, m22, m23;
175  int m30, m31, m32, m33;
176  };
177 } jo_matrix;
178 
180 typedef struct __jo_size
181 {
182  unsigned short width;
183  unsigned short height;
185 
189 typedef struct
190 {
191  unsigned short width;
192  unsigned short height;
193  unsigned short adr;
194  unsigned short size;
196 
198 typedef struct
199 {
200  unsigned short index;
201  unsigned short color_mode;
202  void *data;
204 
206 typedef struct
207 {
208  unsigned short width;
209  unsigned short height;
211 } jo_img;
212 
214 typedef struct
215 {
216  unsigned short width;
217  unsigned short height;
218  unsigned char *data;
219 } jo_img_8bits;
220 
222 typedef struct
223 {
224  unsigned short width;
225  unsigned short height;
226  void *data;
227 } jo_raw_img;
228 
230 typedef struct
231 {
233  int id;
234 } jo_palette;
235 
237 typedef struct
238 {
239  int x;
240  int y;
241  unsigned short width;
242  unsigned short height;
243 } jo_tile;
244 
246 typedef struct
247 {
248  unsigned short effect;
249  unsigned short direction;
250  unsigned int color_table_index;
251  unsigned int gouraud_shading_index;
254  unsigned int clipping;
256 
258 typedef union
259 {
260  float f;
261  struct
262  {
263  unsigned int sign : 1;
264  unsigned int exponent : 8;
265  unsigned int mantissa : 23;
266 
267  } field;
268 } jo_IEEE754;
269 
271 typedef struct
272 {
273  int id;
274  int size;
275  int read;
276  void *handle;
277  char *read_buffer;
279 } jo_file;
280 
282 typedef enum
283 {
287  UP,
292  DOWN_RIGHT
294 
296 typedef enum
297 {
298  /* Technical Name */
299  JO_NBG0_SCREEN = (1<<0),
300  JO_NBG1_SCREEN = (1<<1),
301  JO_NBG2_SCREEN = (1<<2),
302  JO_NBG3_SCREEN = (1<<3),
303  JO_RBG0_SCREEN = (1<<4),
304  JO_BACK_SCREEN = (1<<5),
306  /* User friendly alias */
309  /* Helper */
312 
313 #endif /* !__JO_TYPES_H__ */
314 
315 /*
316 ** END OF FILE
317 */
jo_picture_definition::color_mode
unsigned short color_mode
Definition: types.h:201
jo_vector
Vector for 3D computation using integer.
Definition: types.h:139
RIGHT
@ RIGHT
Definition: types.h:286
jo_file::read
int read
Definition: types.h:275
jo_img_8bits::height
unsigned short height
Definition: types.h:217
JO_NBG1_SCREEN
@ JO_NBG1_SCREEN
Definition: types.h:300
jo_rot3Df::ry
float ry
Definition: types.h:104
UP_RIGHT
@ UP_RIGHT
Definition: types.h:290
jo_vectorf::y
float y
Definition: types.h:131
jo_img_8bits::width
unsigned short width
Definition: types.h:216
jo_pos3Df::z
float z
Definition: types.h:78
jo_file::read_index
int read_index
Definition: types.h:278
jo_file::read_buffer
char * read_buffer
Definition: types.h:277
UP_LEFT
@ UP_LEFT
Definition: types.h:289
jo_raw_img::width
unsigned short width
Definition: types.h:224
__jo_size
Size struct.
Definition: types.h:181
jo_3d_object_attributes::rx
short rx
Definition: types.h:123
jo_vectorf::z
float z
Definition: types.h:132
jo_pos2D_fixed::y
jo_fixed y
Definition: types.h:59
jo_palette::data
jo_color * data
Definition: types.h:232
jo_picture_definition::data
void * data
Definition: types.h:202
jo_pos3Df
3D position using floating numbers
Definition: types.h:75
jo_sprite_attributes::effect
unsigned short effect
Definition: types.h:248
jo_pos3D_fixed::x
jo_fixed x
Definition: types.h:85
__jo_size::height
unsigned short height
Definition: types.h:183
DOWN_RIGHT
@ DOWN_RIGHT
Definition: types.h:292
jo_texture_definition
Texture definition.
Definition: types.h:190
JO_NBG3_SCREEN
@ JO_NBG3_SCREEN
Definition: types.h:302
UP
@ UP
Definition: types.h:287
JO_SPRITE_SCREEN
@ JO_SPRITE_SCREEN
Definition: types.h:305
jo_tile::width
unsigned short width
Definition: types.h:241
jo_picture_definition::index
unsigned short index
Definition: types.h:200
jo_texture_definition::adr
unsigned short adr
Definition: types.h:193
jo_pos3Df::x
float x
Definition: types.h:76
jo_pos3Df::y
float y
Definition: types.h:77
jo_palette
Palette contents struct.
Definition: types.h:231
jo_sprite_attributes::color_table_index
unsigned int color_table_index
Definition: types.h:250
jo_texture_definition::size
unsigned short size
Definition: types.h:194
jo_tile
Struct of one tile (pos and size)
Definition: types.h:238
jo_size
struct __jo_size jo_size
Size struct.
jo_sprite_attributes::fixed_scale_y
jo_fixed fixed_scale_y
Definition: types.h:253
jo_pos3D::z
int z
Definition: types.h:69
jo_texture_definition::height
unsigned short height
Definition: types.h:192
jo_color
unsigned short jo_color
15 bits color type
Definition: types.h:39
jo_rot3Df::rx
float rx
Definition: types.h:103
jo_vector_fixed::jo_pos3D_fixed
jo_pos3D_fixed
Definition: types.h:148
jo_3d_object_attributes::jo_2d_object_attributes
jo_2d_object_attributes
Definition: types.h:122
jo_sprite_attributes::direction
unsigned short direction
Definition: types.h:249
jo_picture_definition
Picture definition.
Definition: types.h:199
JO_ALL_SCROLL_SCREEN
@ JO_ALL_SCROLL_SCREEN
Definition: types.h:310
jo_vector::jo_pos3D
jo_pos3D
Definition: types.h:140
jo_img_8bits::data
unsigned char * data
Definition: types.h:218
jo_tile::x
int x
Definition: types.h:239
jo_img_8bits
8 bits image struct
Definition: types.h:215
JO_NBG2_SCREEN
@ JO_NBG2_SCREEN
Definition: types.h:301
jo_fixed
int jo_fixed
Fixed point Q16.16 number.
Definition: types.h:46
JO_RBG0_SCREEN
@ JO_RBG0_SCREEN
Definition: types.h:303
jo_matrix
4x4 MATRIX for 3D computation using fixed number
Definition: types.h:167
jo_pos3D::y
int y
Definition: types.h:68
jo_tile::y
int y
Definition: types.h:240
NONE
@ NONE
Definition: types.h:284
JO_NBG0_SCREEN
@ JO_NBG0_SCREEN
Definition: types.h:299
jo_rot3D
3D rotation angles
Definition: types.h:93
jo_vector_fixed
Vector for 3D computation using fixed number.
Definition: types.h:147
jo_2d_object_attributes
Object for 2D manipulation (storyboard) using fixed number.
Definition: types.h:112
jo_3d_object_attributes::ry
short ry
Definition: types.h:124
jo_vectorf::x
float x
Definition: types.h:130
jo_img::data
jo_color * data
Definition: types.h:210
jo_rot3Df
3D rotation angles
Definition: types.h:102
__jo_size::width
unsigned short width
Definition: types.h:182
jo_pos3D_fixed::z
jo_fixed z
Definition: types.h:87
jo_sprite_attributes::gouraud_shading_index
unsigned int gouraud_shading_index
Definition: types.h:251
jo_img::height
unsigned short height
Definition: types.h:209
DOWN
@ DOWN
Definition: types.h:288
jo_raw_img::data
void * data
Definition: types.h:226
jo_rot3D::rz
int rz
Definition: types.h:96
jo_pos3D
3D position
Definition: types.h:66
jo_IEEE754
Float IEEE 754 format.
Definition: types.h:259
jo_pos3D::x
int x
Definition: types.h:67
jo_file::handle
void * handle
Definition: types.h:276
jo_matrixf
4x4 MATRIX for 3D computation using floating numbers
Definition: types.h:153
jo_IEEE754::f
float f
Definition: types.h:260
jo_sprite_attributes::fixed_scale_x
jo_fixed fixed_scale_x
Definition: types.h:252
jo_rot3D::ry
int ry
Definition: types.h:95
jo_file::size
int size
Definition: types.h:274
jo_pos2D_fixed::x
jo_fixed x
Definition: types.h:58
jo_pos3D_fixed::y
jo_fixed y
Definition: types.h:86
jo_2d_object_attributes::rz
short rz
Definition: types.h:114
jo_8_directions
jo_8_directions
8 directions definition
Definition: types.h:283
jo_sprite_attributes::clipping
unsigned int clipping
Definition: types.h:254
jo_file::id
int id
Definition: types.h:273
jo_sprite_attributes
Sprite attributes.
Definition: types.h:247
jo_pos2D
2D position
Definition: types.h:50
jo_2d_object_attributes::jo_pos3D
jo_pos3D
Definition: types.h:113
jo_texture_definition::width
unsigned short width
Definition: types.h:191
jo_pos3D_fixed
3D position using fixed numbers
Definition: types.h:84
JO_VDP2_3D_PLANE_SCREEN
@ JO_VDP2_3D_PLANE_SCREEN
Definition: types.h:307
jo_rot3Df::rz
float rz
Definition: types.h:105
jo_pos2D::x
int x
Definition: types.h:51
DOWN_LEFT
@ DOWN_LEFT
Definition: types.h:291
jo_file
File definition.
Definition: types.h:272
jo_img::width
unsigned short width
Definition: types.h:208
JO_BACK_SCREEN
@ JO_BACK_SCREEN
Definition: types.h:304
jo_pos2D_fixed
2D position using fixed number
Definition: types.h:57
jo_tile::height
unsigned short height
Definition: types.h:242
jo_raw_img::height
unsigned short height
Definition: types.h:225
jo_vectorf
Vector for 3D computation using floating numbers.
Definition: types.h:129
jo_raw_img
Raw image struct.
Definition: types.h:223
JO_LNCL_SCREEN
@ JO_LNCL_SCREEN
Definition: types.h:308
jo_pos2D::y
int y
Definition: types.h:52
jo_rot3D::rx
int rx
Definition: types.h:94
jo_palette::id
int id
Definition: types.h:233
jo_img
15 bits image struct
Definition: types.h:207
jo_3d_object_attributes
Object for 3D manipulation (storyboard) using fixed number.
Definition: types.h:121
LEFT
@ LEFT
Definition: types.h:285
jo_scroll_screen
jo_scroll_screen
Sega Saturn Scroll Screen Ids.
Definition: types.h:297