Main Page | Modules | Related Pages

Tile Functions

Description. More...

Functions


Detailed Description

Description.

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 initializing the tile-system.

In debugmode it displays an errormessage when it tries to load a new tile into videoram but cannot find enough space.

Note:
Dynamic tile reloading with rotatation maps is not supported yet.

Function Documentation

void hel_TileDeInit u32  BgNo  ) 
 

Deinitialize a Tile-System.

The hel_TileDeInit function deinits the tilesystem for the background specified by BgNo.

Parameters:
BgNo Backgroundnumber to deinit the tilesystem from.
See also:
hel_TileInit

void hel_TileInit u32  BgNo,
const u8 *  pTileData,
u16  NumTilesRom,
u16 *  pBufferA,
u16  NumTilesRam,
u16 *  pBufferB,
u8  ColMode,
u8  PalNo,
u8  CbbOnlyMode
 

Init a Tile-System.

Parameters:
BgNo Backgroundnumber to init the tilesystem for.
pTileData Pointer to source tilesetdata.
NumTilesRom Amount of tiles in the source tileset.
pBufferA A buffer of NumTilesRom allocated halfwords (u16's). pBufferA should be located in EWRAM.
NumTilesRam Amount of tiles you want to use in videoram. It's the maximum amount of tiles what can be displayed at the same time. For example the screen consists entirely of unique tiles, then NumTilesRam has to be set to 21*31.
pBufferB A buffer of NumTilesRam*3 allocated halfwords (u16's). pBufferB should be located in EWRAM.
ColMode Colormode of pTileData. Set it to 0 when using 4bit graphics, otherwise to 1.
PalNo When using 4bit graphics, set PalNo to palette number the graphic uses, otherwise set it to 0.
CbbOnlyMode Please consult your HAM documentation, see ham_InitTileSet
  #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

See also:
hel_TileDeInit, hel_TileShare, hel_MapSetDynamicTileReloading

u32 hel_TileIsGraphicLoaded u32  BgNo,
u32  RomTileNo
 

Check if a graphic is loaded.

The hel_TileIsGraphicLoaded function can be used to check if a tile is currently loaded or not.

Parameters:
BgNo Backgroundnumber the tilesystem is assigned to
RomTileNo The tilenumber to check
Returns:
TRUE if loaded, otherwise FALSE

void hel_TilePreloadGraphic u32  BgNo,
u32  RomTileNo
 

Preload a graphic.

The hel_TilePreloadGraphic function loads the graphic for the tile referenced by RomTileNo to Vram.

Parameters:
BgNo Backgroundnumber the tilesystem is assigned to
RomTileNo The tilenumber in ROM to preload
Note:
Preloaded graphics must be manually released when they are no longer needed. Releasing the graphics must be done with hel_TileReleaseGraphic.
See also:
hel_TileReleaseGraphic

void hel_TileReleaseGraphic u32  BgNo,
u32  RomTileNo
 

Release a graphic.

The hel_TileReleaseGraphic function releases the graphic for the tile referenced by RomTileNo in Vram.

Parameters:
BgNo Backgroundnumber the tilesystem is assigned to
RomTileNo The tilenumber in ROM to release
Note:
Only preloaded graphics must be manually released. If the graphic is used by another tile, it will not be released.
See also:
hel_TilePreloadGraphic

void hel_TileReloadGraphic u32  BgNo,
u32  TargetRomTileNo,
const u8 *  pSource
 

Reload tile-graphic(s).

The hel_TileReloadGraphic can be used to reload the graphic for a given tile with either 4bit or 8bit colordepth.

Parameters:
BgNo Backgroundnumber the tilesystem is assigned to
TargetRomTileNo The tilenumber for what you want to reload the graphic.
pSource Pointer to source graphicdata.
Note:
Since hel_TileReloadGraphic must first check the colordepth to compute the correct datasize before loading the new tile to vram, this functions is slightly slower than the more specific reloading functions like hel_TileReloadGraphic16 and hel_TileReloadGraphic256. Before reloading a tile, first check if it is already loaded. In case it is not, you cannot reload it. To check if a tile is loaded, use hel_TileIsGraphicLoaded.
See also:
hel_TileReloadGraphic16, hel_TileReloadGraphic256

void hel_TileReloadGraphic16 u32  BgNo,
u32  TargetRomTileNo,
const u8 *  pSource
 

Reload 4bit tile-graphic(s).

The hel_TileReloadGraphic16 can be used to reload the graphic for a given tile with 4bit colordepth (16 colors).

Parameters:
BgNo Backgroundnumber the tilesystem is assigned to
TargetRomTileNo The tilenumber for what you want to reload the graphic.
pSource Pointer to source graphicdata.
Note:
This function is faster than hel_TileReloadGraphic. Before reloading a tile, first check if it is already loaded. In case it is not, you cannot reload it. To check if a tile is loaded, use hel_TileIsGraphicLoaded.
See also:
hel_TileReloadGraphic, hel_TileReloadGraphic256

void hel_TileReloadGraphic256 u32  BgNo,
u32  TargetRomTileNo,
const u8 *  pSource
 

Reload 8bit tile-graphic(s).

The hel_TileReloadGraphic256 can be used to reload the graphic for a given tile with 8bit colordepth (16 colors).

Parameters:
BgNo Backgroundnumber the tilesystem is assigned to
TargetRomTileNo The tilenumber for what you want to reload the graphic.
pSource Pointer to source graphicdata.
Note:
This function is faster than hel_TileReloadGraphic. Before reloading a tile, first check if it is already loaded. In case it is not, you cannot reload it. To check if a tile is loaded, use hel_TileIsGraphicLoaded.
See also:
hel_TileReloadGraphic, hel_TileReloadGraphic16

void hel_TileShare u8  TargetBgNo,
u8  SourceBgNo,
u8  PalNo
 

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 initializing 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!

Parameters:
TargetBgNo Target, this is the backgroundnumber which receives the tilesetdata.
SourceBgNo Source, this is the backgroundnumber which provides the tilesetdata.
PalNo Palettenumber the target background should use. This makes it possible to use the same tilesetdata, but with different colors for each background. If you share 256 color graphics, set it to 0, otherwise to a palettenumber between 0 and 15.
When you no longer need the shared TileSystem, call hel_TileDeInit.

Note:
If you share tilesetdata, please keep in mind it is used by at least two backgrounds. This means it will probably display more tiles from the same tileset and therefore the TileSystem needs more tileslots to work with. To increase the tileslots, use NumTilesRam and pBufferB parameter which you pass to hel_TileInit, when initializing the source tileset.
See also:
hel_TileInit, hel_TileDeInit


Generated on Mon Aug 22 20:43:41 2005 by DoxyGen 1.4.4