Jo Engine  9
Jo Sega Saturn Engine
image.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2017, 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_IMAGE_H__
36 # define __JO_IMAGE_H__
37 
41 # define JO_TILE_COUNT(TILE_TABLE) (sizeof(TILE_TABLE) / sizeof(jo_tile))
42 
44 typedef struct
45 {
46  unsigned short width;
47  unsigned short height;
49 } jo_img;
50 
52 typedef struct
53 {
54  unsigned short width;
55  unsigned short height;
56  unsigned char *data;
57 } jo_img_8bits;
58 
60 typedef struct
61 {
62  unsigned short x;
63  unsigned short y;
64  unsigned short width;
65  unsigned short height;
66 } jo_tile;
67 
73 void jo_replace_color(const jo_img * const img, const jo_color src_color, const jo_color dest_color);
74 
75 #ifdef JO_COMPILE_WITH_FS_SUPPORT
76 
84 bool jo_bin_loader(jo_img *img, const char * const sub_dir, const char *const filename, const jo_color transparent_color);
85 
94 int jo_sprite_add_bin_tileset(const char * const sub_dir, const char * const filename, const jo_color transparent_color, const jo_tile * const tileset, const unsigned int tile_count);
95 
102 int jo_sprite_add_bin(const char * const sub_dir, const char * const filename, const jo_color transparent_color);
103 
114 int jo_sprite_add_image_pack(const char * const sub_dir, const char * const filename, const jo_color transparent_color);
115 
116 #endif /* !JO_COMPILE_WITH_FS_SUPPORT */
117 
124 bool jo_bin_loader_from_stream(jo_img *img, char *stream, const jo_color transparent_color);
125 
131 int jo_sprite_add_bin_from_stream(char *stream, const jo_color transparent_color);
132 
136 void jo_free_img(jo_img * const img);
137 
142 static __jo_force_inline void jo_set_palette_register(const unsigned char palette_index, const jo_color color)
143 {
144  *(jo_color *)(VDP2_COLRAM + ((palette_index) << 1)) = color;
145 }
146 
151 static __jo_force_inline jo_color jo_get_palette_register(const unsigned char palette_index)
152 {
153  return *(jo_color *)(VDP2_COLRAM + ((palette_index) << 1));
154 }
155 
156 #endif /* !__JO_IMAGE_H__ */
157 
158 /*
159 ** END OF FILE
160 */
static __jo_force_inline void jo_set_palette_register(const unsigned char palette_index, const jo_color color)
Set palette index color.
Definition: image.h:142
unsigned short height
Definition: image.h:55
void jo_free_img(jo_img *const img)
Free an image loaded from CD.
unsigned short jo_color
15 bits color type
Definition: types.h:39
void jo_replace_color(const jo_img *const img, const jo_color src_color, const jo_color dest_color)
Add a sprite.
unsigned short x
Definition: image.h:62
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition: conf.h:154
unsigned char * data
Definition: image.h:56
Struct of one tile (pos and size)
Definition: image.h:60
15 bits image struct
Definition: image.h:44
bool jo_bin_loader_from_stream(jo_img *img, char *stream, const jo_color transparent_color)
Load a BIN image from stream.
#define VDP2_COLRAM
Definition: sgl_prototypes.h:53
unsigned short height
Definition: image.h:65
static __jo_force_inline jo_color jo_get_palette_register(const unsigned char palette_index)
Get palette color from index.
Definition: image.h:151
unsigned short width
Definition: image.h:64
unsigned short width
Definition: image.h:46
unsigned short y
Definition: image.h:63
unsigned short height
Definition: image.h:47
8 bits image struct
Definition: image.h:52
jo_color * data
Definition: image.h:48
unsigned short width
Definition: image.h:54
int jo_sprite_add_bin_from_stream(char *stream, const jo_color transparent_color)
Add a sprite from a BIN file.