SGDK RESCOMP and the quest for two pallets on a single background layer
Posted: Sat Jan 19, 2019 8:32 pm
So this is going to need some explaining. I want to put two pallets on a single background layer. I know this can be done because I've already done some tests to prove it. The question is how to make this efficient. So consider this code for updating a Foreground row to the buffer:
Notice how the base tile is set in the loop. I will be able to set the pallet on the play with either a array or a separate function that looks at the tile being loaded and then it loads the proper pallet onto the buffer.
The problem I'm running into is Rescomp as far as I can tell has no provision for loading up maps with more than one pallet. Admittedly I could get around this problem by compiling the resource in a single pallet and then defining which tiles need other pallets later. But this will be a pain to hand define myself but if that's what needs to happen so be it.
However, this still means I have a problem with Rescomp's outputs. it exports images in assembly 16 bit words when the method I have needs 32 bit unsigned integers.
The output I need is a C array such as this one:
Does anyone know of a good solution to my problem? I would like to convert the Rescomp outputs into C arrays. I've though about writing a small program that would just turn everything into text. If there is a better way I would like to hear it.
Code: Select all
void redrawForegroundColumn(u16 columnToUpdate)
{
// Calculate where in the tilemap the new row's tiles are located.
const u16* mapDataAddr = fgMap.tilemap + fgRowGroupOffsets[fgCameraTileY >> 3] + fgRowOffsets[fgCameraTileY & 7] + columnToUpdate;
u16 columnBufferIdx = fgCameraTileY;
// Copy the tiles into the buffer.
u16 i;
for (i = VDP_PLANE_TILE_HEIGHT; i != 0; i--)
{
u16 baseTile = TILE_ATTR_FULL(PALLET, 0, 0, 0, fgTilesetStartIdx);
columnBufferIdx &= 0x1F; // columnBufferIdx MOD 32 (VDP_PLANE_TILE_HEIGHT)
fgColumnBuffer[columnBufferIdx] = baseTile + *mapDataAddr;
columnBufferIdx++;
mapDataAddr += fgMap.w;
}
// Queue copying the buffer into VRAM.
DMA_queueDma(DMA_VRAM, (u32) fgColumnBuffer, PLANE_FG + ((columnToUpdate & VDP_PLANE_TILE_WIDTH_MINUS_ONE) << 1), VDP_PLANE_TILE_HEIGHT, VDP_PLANE_TILE_WIDTH_TIMES_TWO);
}
The problem I'm running into is Rescomp as far as I can tell has no provision for loading up maps with more than one pallet. Admittedly I could get around this problem by compiling the resource in a single pallet and then defining which tiles need other pallets later. But this will be a pain to hand define myself but if that's what needs to happen so be it.
However, this still means I have a problem with Rescomp's outputs. it exports images in assembly 16 bit words when the method I have needs 32 bit unsigned integers.
Code: Select all
nightGrass_tileset_tiles:
dc.w 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555
dc.w 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555
Code: Select all
const u32 TILEMAP_TEST_FG_TILES[TILEMAP_TEST_FG_TILE_COUNT][TILE_PIXEL_ROW_COUNT] =
{
{
0x11111111,
0x14444444,
0x14444444,
0x14444444,
0x14444444,
0x14444444,
0x14444444,
0x14444444
},
{
0x11111111,
0x44444441,
0x44444441,
0x44444441,
0x44444441,
0x44444441,
0x44444441,
0x44444441
},
etc.