SaturnRingLibrary 0.6
SGL wrapper
 
Loading...
Searching...
No Matches
SRL::Tilemap::Interfaces::Bmp2Tile Struct Reference

Detailed Description

Interface to Convert Bitmap Image into Tilemap.

Note
Maximum Size of bitmap to convert is 0x20000 bytes (512x512 @ 4bpp, 512x256 @ 8bpp, or 512x128 @ 16bppp).
empty tiles in the source image are detected and removed from the tileset, but duplicate and mirrored tiles are not.

#include <srl_tilemap_interfaces.hpp>

Inheritance diagram for SRL::Tilemap::Interfaces::Bmp2Tile:
SRL::Tilemap::ITilemap

Public Member Functions

 Bmp2Tile (SRL::Bitmap::IBitmap &bmp, uint8_t pages=1)
 Create a Tilemap out of an existing Bitmap.
 
 ~Bmp2Tile ()
 Free allocated resources and destroy Bmp2Tile object.
 
void ApplyVdp2Offsets (uint32_t celOffset, uint32_t palOffset=0)
 manually apply a cel offset and Palette offset to all map data for cases when bypassing built in VDP2 tilemap loading functions (such as when performing DMA transfers to VDP2 VRAM)
 
void ClearPage (int pageIndex)
 clears all data of a page in the tilemap to zero
 
void CopyMap (uint8_t sourcePage, Tilemap::Coord topLeft, Tilemap::Coord botRight, uint8_t destPage, Tilemap::Coord destTile)
 Copies a rectangular selection of Tilemap data between 2 pages in the tilemap.
 
void FreeCellData ()
 Frees The Work Ram associated with Cell Data in cases where it is no longer required.
 
void FreeMapData ()
 Frees The Work Ram associated with Map Data in cases where it is no longer required.
 
void FreePalData ()
 Frees The Work Ram associated with Pal Data in cases where it is no longer required.
 
void * GetCellData () override
 Get Cell data(Tileset)
 
TilemapInfo GetInfo () override
 Get Tilemap Info.
 
void * GetMapData () override
 Get Map data(Tilemap)
 
uint16_t * GetPageAddress (uint8_t page, Tilemap::Coord &coord)
 Get address of tilemap page.
 
void * GetPalData () override
 Get Palette data.
 

Constructor & Destructor Documentation

◆ Bmp2Tile()

SRL::Tilemap::Interfaces::Bmp2Tile::Bmp2Tile ( SRL::Bitmap::IBitmap & bmp,
uint8_t pages = 1 )
inline

Create a Tilemap out of an existing Bitmap.

Parameters
bmpThe Bitmap Image to convert
pagesthe number of pages avaiable to the resulting tilemap
Note
A page is a unit of map data representing the tiling af a 512x512 pixel region (32x32 or 64x64 tiles depending on the base tile size). The resulting Tilemap always Contains at least 1 page with the default mapping of all tiles extracted from the bitmap, but more pages can be reserved here for further use

Member Function Documentation

◆ ApplyVdp2Offsets()

void SRL::Tilemap::Interfaces::Bmp2Tile::ApplyVdp2Offsets ( uint32_t celOffset,
uint32_t palOffset = 0 )
inline

manually apply a cel offset and Palette offset to all map data for cases when bypassing built in VDP2 tilemap loading functions (such as when performing DMA transfers to VDP2 VRAM)

Note
Do not use in conjuction with VDP2::ScrollScreen::LoadTilemap, as these offsets are applied automatically.
Parameters
celOffsetTile address offset to apply (obtain with VDP2::ScrollScreen::GetCelOffset())
palOffsetCRAM palette index to apply (obtain with VDP2::ScrollScreen::GetPalOffset())

◆ ClearPage()

void SRL::Tilemap::Interfaces::Bmp2Tile::ClearPage ( int pageIndex)
inline

clears all data of a page in the tilemap to zero

Parameters
pageIndexpageIndex Index of the page to clear in this Tilemap's Page Table

◆ CopyMap()

void SRL::Tilemap::Interfaces::Bmp2Tile::CopyMap ( uint8_t sourcePage,
Tilemap::Coord topLeft,
Tilemap::Coord botRight,
uint8_t destPage,
Tilemap::Coord destTile )
inline

Copies a rectangular selection of Tilemap data between 2 pages in the tilemap.

Parameters
sourcePageIndex of the Tilemap Page to copy from
topLeftPage Coordinates of Top left of region to Copy
botRightPage Coordinates of Bottom Right of region Copy
destPageIndex of the Tilemap page being copied to
destTileStarting Coordinate to copy to in the destination page (the new Top left)

◆ GetCellData()

void * SRL::Tilemap::Interfaces::Bmp2Tile::GetCellData ( )
inlineoverridevirtual

Get Cell data(Tileset)

Returns
Pointer to Cel data

Reimplemented from SRL::Tilemap::ITilemap.

◆ GetInfo()

TilemapInfo SRL::Tilemap::Interfaces::Bmp2Tile::GetInfo ( )
inlineoverridevirtual

Get Tilemap Info.

Returns
Tilemap Info

Reimplemented from SRL::Tilemap::ITilemap.

◆ GetMapData()

void * SRL::Tilemap::Interfaces::Bmp2Tile::GetMapData ( )
inlineoverridevirtual

Get Map data(Tilemap)

Returns
Pointer to Map data

Reimplemented from SRL::Tilemap::ITilemap.

◆ GetPageAddress()

uint16_t * SRL::Tilemap::Interfaces::Bmp2Tile::GetPageAddress ( uint8_t page,
Tilemap::Coord & coord )
inline

Get address of tilemap page.

Parameters
pagePage index
coordPage coordinate
Returns
Page address

◆ GetPalData()

void * SRL::Tilemap::Interfaces::Bmp2Tile::GetPalData ( )
inlineoverridevirtual

Get Palette data.

Returns
Pointer to palette data

Reimplemented from SRL::Tilemap::ITilemap.