Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
map.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_MAP_H__
36# define __JO_MAP_H__
37
41# define JO_MAP_NO_COLLISION (-2147483647)
42
59int jo_map_per_pixel_vertical_collision(const unsigned int layer, int x, int y, unsigned char *attribute);
60
69int jo_map_hitbox_detection_custom_boundaries(const unsigned int layer, const int x, const int y, const int w, const int h);
70
71#ifdef JO_COMPILE_WITH_FS_SUPPORT
72
87bool jo_map_load_from_file(const unsigned int layer, const short depth, const char * const sub_dir, const char * const filename);
88
89#endif /* !JO_COMPILE_WITH_FS_SUPPORT */
90
97bool jo_map_create(const unsigned int layer, const unsigned short max_tile_count, const short depth);
98
106void jo_map_add_tile(const unsigned int layer, const short x, const short y,
107#if JO_MAX_SPRITE > 255
108 const unsigned short sprite_id,
109#else
110 const unsigned char sprite_id,
111#endif
112 const unsigned char attribute);
113
121void jo_map_add_animated_tile(const unsigned int layer, const short x, const short y, const unsigned char anim_id, const unsigned char attribute);
122
126void jo_map_free(const unsigned int layer);
127
133void jo_map_draw(const unsigned int layer, const short screen_x, const short screen_y);
134
142void jo_map_draw_background(const unsigned int layer, const short x, const short y);
143
151static __jo_force_inline void jo_vdp2_map_draw_nbg1(const unsigned int layer, const short x, const short y)
152{
153 jo_map_draw_background(layer, x, y);
154}
155
166void jo_map_scroll_background(const unsigned int layer, const short x, const short y, const jo_color clear_color);
167
175static __jo_force_inline void jo_vdp2_map_scroll_nbg1(const unsigned int layer, const short x, const short y, const jo_color clear_color)
176{
177 jo_map_scroll_background(layer, x, y, clear_color);
178}
179
186void jo_map_move_tiles_by_attribute(const unsigned int layer, const unsigned char attribute_filter, const short incr_x, const short incr_y);
187
188#ifdef JO_COMPILE_WITH_3D_SUPPORT
189void jo_map_3d_draw(const unsigned int layer, const int x, const int y, const int z);
190#endif // JO_COMPILE_WITH_3D_SUPPORT
191
192#endif /* !__JO_MAP_H__ */
193
194/*
195** END OF FILE
196*/
int jo_map_hitbox_detection_custom_boundaries(const unsigned int layer, const int x, const int y, const int w, const int h)
Fast method to get if a square intersects with the map (HitBox processing) based on screen coord.
void jo_map_3d_draw(const unsigned int layer, const int x, const int y, const int z)
void jo_map_draw(const unsigned int layer, const short screen_x, const short screen_y)
Display the specific layer.
void jo_map_add_animated_tile(const unsigned int layer, const short x, const short y, const unsigned char anim_id, const unsigned char attribute)
Add an animated tile on the specific layer.
void jo_map_free(const unsigned int layer)
Destroy the specific layer.
void jo_map_scroll_background(const unsigned int layer, const short x, const short y, const jo_color clear_color)
Draw the specific layer on the background (NBG1) using the hardware scroll (no flickering).
void jo_map_add_tile(const unsigned int layer, const short x, const short y, const unsigned char sprite_id, const unsigned char attribute)
Add a tile on the specific layer.
void jo_map_draw_background(const unsigned int layer, const short x, const short y)
Draw the specific layer on the background (NBG1).
int jo_map_per_pixel_vertical_collision(const unsigned int layer, int x, int y, unsigned char *attribute)
Method to get vertical distance between our point (x, y) and the surface of the map (example: hill).
bool jo_map_load_from_file(const unsigned int layer, const short depth, const char *const sub_dir, const char *const filename)
Load a sprite map on a specific layer using MAP file format.
static __jo_force_inline void jo_vdp2_map_draw_nbg1(const unsigned int layer, const short x, const short y)
Draw the specific layer on the background (NBG1).
Definition map.h:151
static __jo_force_inline void jo_vdp2_map_scroll_nbg1(const unsigned int layer, const short x, const short y, const jo_color clear_color)
Draw the specific layer on the background (NBG1) using the hardware scroll (no flickering).
Definition map.h:175
bool jo_map_create(const unsigned int layer, const unsigned short max_tile_count, const short depth)
Create a new sprite map.
void jo_map_move_tiles_by_attribute(const unsigned int layer, const unsigned char attribute_filter, const short incr_x, const short incr_y)
Move specific tiles by their attributes.
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition types.h:39
unsigned short jo_color
15 bits color type
Definition types.h:42