1
0
mirror of https://github.com/ScrelliCopter/tmx2gba.git synced 2025-02-21 03:29:25 +11:00

Fixed overridden palette indices overwriting tile data.

This commit is contained in:
2015-10-27 00:32:15 +11:00
parent b7e320824b
commit d861e9193c

View File

@@ -163,7 +163,7 @@ int main ( int argc, char** argv )
{ {
uint32_t uiRead = (*pRead++); uint32_t uiRead = (*pRead++);
uint8_t ucTile = (uint8_t)std::max<uint32_t> ( 0, tmx.LidFromGid ( uiRead & ~FLIP_MASK ) + params.offset ); uint16_t usTile = (uint16_t)std::max<int32_t> ( 0, tmx.LidFromGid ( uiRead & ~FLIP_MASK ) + params.offset );
uint8_t ucFlags = 0x0; uint8_t ucFlags = 0x0;
// Get flipped! // Get flipped!
@@ -174,15 +174,15 @@ int main ( int argc, char** argv )
uint32_t uiIndex = 0; uint32_t uiIndex = 0;
if ( pPalRead != nullptr ) if ( pPalRead != nullptr )
{ {
uiIndex = tmx.LidFromGid ( *pPalRead++ & ~FLIP_MASK ); uiIndex = tmx.LidFromGid ( (*pPalRead++) & ~FLIP_MASK );
} }
if ( uiIndex == 0 ) if ( uiIndex == 0 )
{ {
uiIndex = ( params.palette << 4 ) + 1; uiIndex = params.palette + 1;
} }
ucFlags |= (uint8_t)(uiIndex - 1); ucFlags |= (uint8_t)(uiIndex - 1) << 4;
vucCharDat.push_back ( (uint16_t)ucTile | (uint16_t)ucFlags << 8 ); vucCharDat.push_back ( usTile | ( uint16_t(ucFlags) << 8 ) );
} }
// Save out charmap. // Save out charmap.