Map functions in OSLib.
More...
Map functions in OSLib.
◆ OSL_MAP_FLAGS
Enum representing internal map flags.
These flags are used internally to define certain properties of the map, such as transparency and drawing methods.
◆ OSL_MAP_FORMATS
Enum representing the available map formats.
This enum defines the possible formats a map can have, such as 16-bit formats with different tile numbering schemes.
Enumerator |
---|
OSL_MF_U16 | 16-bit format.
|
OSL_MF_U16_GBA | 16-bit, 10 bits for the tile number, 2 bits for mirroring. Palette is unsupported. addit1 holds the number of tile bits (default 10), and the next two bits are for mirroring (11 = horizontal, 12 = vertical).
|
◆ OSL_MAP_FLAGS
Enum representing internal map flags.
These flags are used internally to define certain properties of the map, such as transparency and drawing methods.
Enumerator |
---|
OSL_MF_SIMPLE | Defines if the map is "simple" (oslDrawMapSimple ). Currently unsupported, do not use.
|
OSL_MF_TILE1_TRANSPARENT | Defines if the first tile is always transparent, regardless of its pattern.
|
◆ oslCreateMap()
OSL_MAP * oslCreateMap |
( |
OSL_IMAGE * | img, |
|
|
void * | map_data, |
|
|
int | tileX, |
|
|
int | tileY, |
|
|
int | mapSizeX, |
|
|
int | mapSizeY, |
|
|
int | map_format ) |
|
extern |
Creates a new map.
This function initializes a new map using the provided tileset image and raw map data. It sets up the map's dimensions and format, returning a pointer to the created OSL_MAP
structure.
- Parameters
-
img | Pointer to the tileset image. The maximum size of images is 512x512 pixels. In the tileset image, tiles are arranged from left to right and top to bottom. |
map_data | Pointer to the raw binary map data. This is an array where each entry represents a tile number to be displayed. |
tileX | Width of a tile in the tileset (in pixels). |
tileY | Height of a tile in the tileset (in pixels). |
mapSizeX | Width of the map (in tiles). |
mapSizeY | Height of the map (in tiles). |
map_format | Format of the map, one of the OSL_MAP_FORMATS values. |
- Returns
- Pointer to the created
OSL_MAP
structure, or NULL
in case of error.
◆ oslDrawMap()
Draws a map on the screen.
This function renders the map on the screen using the properties defined in the OSL_MAP
structure, such as scroll positions and tile sizes.
- Parameters
-
m | Pointer to the OSL_MAP structure to be drawn. |
◆ oslDrawMapSimple()
void oslDrawMapSimple |
( |
OSL_MAP * | m | ) |
|
|
extern |
Draws a map using a simple method (deprecated).
This function is provided for backward compatibility. It draws a map similarly to oslDrawMap
, but is not recommended for use in new code.
- Parameters
-
m | Pointer to the OSL_MAP structure to be drawn. |
- Deprecated
- This function is deprecated and should not be used.
◆ oslDeleteMap()
Deletes a map.
This function frees the resources associated with a map. Note that the raw map data passed to oslCreateMap
is not freed by this function and must be managed separately by the user.
- Parameters
-
m | Pointer to the OSL_MAP structure to be deleted. |
Example:
unsigned short *mapData;
mapData = malloc(128 * 64 * sizeof(*mapData));
free(mapData);
void oslDeleteMap(OSL_MAP *m)
Deletes a map.
OSL_MAP * oslCreateMap(OSL_IMAGE *img, void *map_data, int tileX, int tileY, int mapSizeX, int mapSizeY, int map_format)
Creates a new map.
@ OSL_MF_U16
Definition map.h:52
Structure representing a map.
Definition map.h:29