Maps


Data Structures

struct  OSL_MAP

Enumerations

enum  OSL_MAP_FORMATS { OSL_MF_U16 = 1, OSL_MF_U16_GBA = 2 }
enum  OSL_MAP_FLAGS { OSL_MF_SIMPLE = 1, OSL_MF_TILE1_TRANSPARENT = 2 }

Functions

OSL_MAPoslCreateMap (OSL_IMAGE *img, void *map_data, int tileX, int tileY, int mapSizeX, int mapSizeY, int map_format)
void oslDrawMap (OSL_MAP *m)
void oslDrawMapSimple (OSL_MAP *m)
void oslDeleteMap (OSL_MAP *m)

Detailed Description

Map functions in OSLib.

Enumeration Type Documentation

Available map formats.

Enumerator:
OSL_MF_U16  16 bit format
OSL_MF_U16_GBA  16 bit, 10 bit for the tile number, 2 for the mirror, palette is unsupported - addit1 holds the number of tile bits (10 by default), the two next bits are for mirroring (11 = horizontal and 12 = vertical)

Internal map flags.

Enumerator:
OSL_MF_SIMPLE  Defines if the map is "simple" (oslDrawMapSimple) - UNSUPPORTED YET, DO NOT USE IT!
OSL_MF_TILE1_TRANSPARENT  Defines if the first tile is always transparent, no matter its pattern.


Function Documentation

OSL_MAP* oslCreateMap ( OSL_IMAGE img,
void *  map_data,
int  tileX,
int  tileY,
int  mapSizeX,
int  mapSizeY,
int  map_format 
)

Creates a new map.

Parameters:
img Image used as tileset. Remember the maximum size of images is 512x512, neither the width or the height can exceed 512. In a tileset image, tiles are placed from in lines from left to right and from top to bottom. Each tile has a specific size.
map_data Binary data representing the map data in its raw format. This is a table of entries, where each entry is 16-bit (or something else depending on the map format) and represents a tile number to be displayed. Please note that tile entries, just like tilesets, are placed from left to right, and then from top to bottom. To retrieve a specific map entry (x = horizontal position, y = vertical position), the algorithm is the following: ((map_type*)map_data)[y * width + x].
tileX,tileY Size of a tile in the tileset.
mapSizeX,mapSizeY Width and height of the map. Maps are wrapped around (that is, when you're all to the right, the left is displayed again, same vertically).
map_format One of the OSL_MAP_FORMATS values.
Returns:
NULL in case of error, a pointer to a map object in case of success.

void oslDrawMap ( OSL_MAP m  ) 

Draws a map on the screen, using the map properties:

  • scrollX, scrollY: respectively horizontal and vertical scrolling values (in pixels). The map is always drawn on the whole screen.

void oslDrawMapSimple ( OSL_MAP m  ) 

Same as oslDrawMap, only here for backward compatibility. Do not use!

void oslDeleteMap ( OSL_MAP m  ) 

Deletes a map. Call this after you've finished with a map. Please note that the map data you supplied to oslCreateMap was your own data, passed by reference, and thus it will not be freed! Example:

unsigned short *mapData;
OSL_MAP *map;
//Data for a 128x64 map
mapData = malloc(128 * 64 * sizeof(*mapData));
//Create a map with this
map = oslCreateMap(anImage, mapData, 16, 16, 128, 64, OSL_MF_U16);
//Now delete this map
oslDeleteMap(map);
//Don't forget to free the map data too
free(mapData);


Generated on Wed Feb 24 10:25:35 2010 by  doxygen 1.5.9