MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Tiles_LoadICNFile

Function Tiles_LoadICNFile

src/sprites.c:215–253  ·  view source on GitHub ↗

* Loads an ICN file. * NOTE : should be called "tiles" * * @param filename The name of the file to load. * @param screenID The index of a memory block where to store loaded sprites. */

Source from the content-addressed store, hash-verified

213 * @param screenID The index of a memory block where to store loaded sprites.
214 */
215static void Tiles_LoadICNFile(const char *filename)
216{
217 uint8 fileIndex;
218
219 uint32 tilesDataLength;
220 uint32 tableLength;
221 uint32 paletteLength;
222 int8 info[4];
223
224 fileIndex = ChunkFile_Open(filename);
225
226 /* Get the length of the chunks */
227 tilesDataLength = ChunkFile_Seek(fileIndex, HTOBE32(CC_SSET));
228 tableLength = ChunkFile_Seek(fileIndex, HTOBE32(CC_RTBL));
229 paletteLength = ChunkFile_Seek(fileIndex, HTOBE32(CC_RPAL));
230
231 /* Read the header information */
232 ChunkFile_Read(fileIndex, HTOBE32(CC_SINF), info, 4);
233 GFX_Init_TilesInfo(info[0], info[1]);
234
235 /* Get the SpritePixels chunk */
236 free(g_tilesPixels);
237 g_tilesPixels = calloc(1, tilesDataLength);
238 ChunkFile_Read(fileIndex, HTOBE32(CC_SSET), g_tilesPixels, tilesDataLength);
239 tilesDataLength = Sprites_Decode(g_tilesPixels, g_tilesPixels);
240 /*g_tilesPixels = realloc(g_tilesPixels, tilesDataLength);*/
241
242 /* Get the Table chunk */
243 free(g_iconRTBL);
244 g_iconRTBL = calloc(1, tableLength);
245 ChunkFile_Read(fileIndex, HTOBE32(CC_RTBL), g_iconRTBL, tableLength);
246
247 /* Get the Palette chunk */
248 free(g_iconRPAL);
249 g_iconRPAL = calloc(1, paletteLength);
250 ChunkFile_Read(fileIndex, HTOBE32(CC_RPAL), g_iconRPAL, paletteLength);
251
252 ChunkFile_Close(fileIndex);
253}
254
255/**
256 * Loads the sprites for tiles.

Callers 1

Sprites_LoadTilesFunction · 0.85

Calls 6

ChunkFile_SeekFunction · 0.85
ChunkFile_ReadFunction · 0.85
GFX_Init_TilesInfoFunction · 0.85
freeFunction · 0.85
Sprites_DecodeFunction · 0.85
ChunkFile_CloseFunction · 0.85

Tested by

no test coverage detected