// HEL Library \\ |
HEL's tile-system implementation dynamically reloads tile graphics and can therefore bypass the hardware limit of 1024 tiles which allows you to design more extended levels. The maximum amount of tiles what can be handled by HEL's tile-system is 32767
tiles. A few functions of HEL's tile-system are located in IWRAM, because they have to be fast. If you don't use dynamic tile reloading, these functions will not be linked into the ELF and therefore consume no extra memory.
HEL's tile-system does not dynamically allocate any memory from EWRAM. You have to pass allocated buffers instead. This option allows to use an own memory manager, in case it is necessary.
It can share tilesetdata between backgrounds. This is helpful if you have one (huge) tileset which is used by several backgrounds. When you share 16 color graphics, you can specify a different palettenumber for the shared data. This makes it possible to use the same tileset with different colors.
It comes with a function to check if specific tiles are loaded to videoram and reload their graphics to perform tileanimations.
16 and 256 color graphics are supported, all associated calculations are done for you automatically. You only have to pass the colormode when initing the tile-system.
In debugmode it displays an errormessage when it tries to load a new tile into videoram but cannot find enough space.
|
Deinit a Tile-System. The hel_TileDeInit function deinits the tilesystem for the background specified by BgNo.
|
|
Init a Tile-System.
#define RAM_SLOTS (224) u16 BufferA[451] ATTR_MEM_IN_EWRAM; u16 BufferB[RAM_SLOTS*3] ATTR_MEM_IN_EWRAM; hel_TileInit ( 0, // BgNo world_Tiles, // Source GraphicData (Tileset) SIZEOF_16BIT(BufferA), // Amount of tiles in GraphicData BufferA, // BufferA RAM_SLOTS, // Amount of tiles to use in videoram BufferB, // BufferB 1, // Colormode (1=256 Colors, 0=16 Colors) 0, // Palettenumber (0..15) TRUE // CbbOnlyMode ); // Create a Map here and enable dynamic tile reloading // This can be done with hel_MapInit and hel_MapSetDynamicTileReloading
|
|
Check if a graphic is loaded. The hel_TileIsGraphicLoaded function can be used to check if a tile is currently loaded or not.
|
|
Reload tile-graphic(s).
#define MAP_WORLD_WIDTH (3552/8) #define MAP_WORLD_HEIGHT (512/8) extern const unsigned char world_Tiles[]; extern const unsigned short world_Map[MAP_WORLD_WIDTH*MAP_WORLD_HEIGHT]; extern const unsigned char item_heart_Tiles[8*64]; void ReloadWorldGraphic(u32 X, u32 Y, const u8 *pSource) { // get tilenumber from worldmap u32 TileToReload = world_Map[(Y*MAP_WORLD_WIDTH)+X]; // is the tile currently loaded/visible? if(hel_TileIsGraphicLoaded(0, TileToReload)) { // YES it is! So lets load some new graphic in. hel_TileReloadGraphic(0, TileToReload, pSource); } } void ReloadHeart() { u32 SourceOffset=256; // Reload graphic when currently used ReloadWorldGraphic(30, 34, &item_heart_Tiles[SourceOffset]); // TopLeft ReloadWorldGraphic(31, 34, &item_heart_Tiles[SourceOffset+64]); // TopRight ReloadWorldGraphic(30, 35, &item_heart_Tiles[SourceOffset+128]); // BottomLeft ReloadWorldGraphic(31, 35, &item_heart_Tiles[SourceOffset+192]); // BottomRight } |
|
Share tilesetdata. The hel_TileShare function can be used to share tilesetdata. This is helpful if you have one tileset which is used by several backgrounds. Instead of initing for each background an own TileSystem, you can (re)use the tilesetdata of an existing TileSystem. This has a big plus, because it requires less memory!
|