Endian fixes for Toaplan drivers from FBANext - Toaplan drivers should be endian-safe

This commit is contained in:
Barry Harris 2011-12-27 20:51:53 +00:00
parent fb8166563e
commit cee3344d2c
5 changed files with 16 additions and 16 deletions

View File

@ -237,11 +237,11 @@ INT32 ToaExtraTextLayer()
#if 1
y = 0;
do {
nLine = ((UINT16*)ExtraTSelect)[y];
nOffset = ((UINT16*)ExtraTScroll)[y];
nLine = BURN_ENDIAN_SWAP_INT16(((UINT16*)ExtraTSelect)[y]);
nOffset = BURN_ENDIAN_SWAP_INT16(((UINT16*)ExtraTScroll)[y]);
if (y < 233) {
for (i = 1; i < 8 && ((UINT16*)ExtraTSelect)[y + i] == (nLine + i) && ((UINT16*)ExtraTScroll)[y + i] == nOffset; i++) { }
for (i = 1; i < 8 && BURN_ENDIAN_SWAP_INT16(((UINT16*)ExtraTSelect)[y + i]) == (nLine + i) && BURN_ENDIAN_SWAP_INT16(((UINT16*)ExtraTScroll)[y + i]) == nOffset; i++) { }
// draw whole tiles in one go
if (i == 8) {
@ -252,7 +252,7 @@ INT32 ToaExtraTextLayer()
nOffset &= 7;
for (x = 0, pTile = pCurrentRow - nOffset * nBurnColumn; x < 41; x++, pTile += nTileLeft) {
UINT32 nTile = pTileRow[(x + nStartX) & 0x3F];
UINT32 nTile = BURN_ENDIAN_SWAP_INT16(pTileRow[(x + nStartX) & 0x3F]);
if (nTile && nTile != 0x20) {
pTileData = ExtraTROM + ((nTile & 0x3FF) << 5);
pTilePalette = &pTextPalette[((nTile >> 6) & 0x03F0)];
@ -279,7 +279,7 @@ INT32 ToaExtraTextLayer()
nOffset &= 7;
for (x = 0, pTile = pCurrentRow - nOffset * nBurnColumn; x < 41; x++, pTile += nTileLeft) {
UINT32 nTile = pTileRow[(x + nStartX) & 0x3F];
UINT32 nTile = BURN_ENDIAN_SWAP_INT16(pTileRow[(x + nStartX) & 0x3F]);
if (nTile && nTile != 0x20) {
pTileData = ExtraTROM + ((nTile & 0x3FF) << 5) + ((nLine & 7) << 2);
pTilePalette = &pTextPalette[((nTile >> 6) & 0x03F0)];

View File

@ -176,10 +176,10 @@ static void QueueLayer(INT32 i, UINT16* pTilemap, INT32 nXPos, INT32 nYPos)
for (x = 0; x < 21; x++) {
nTileColumn = (((nXPos >> 4) + x) << 1) & 0x3E;
nTileNumber = pTilemap[nTileRow + nTileColumn + 1];
nTileNumber = BURN_ENDIAN_SWAP_INT16(pTilemap[nTileRow + nTileColumn + 1]);
if (nTileNumber > 0 && nTileNumber <= nMaxTile[i]) {
nTileAttrib = pTilemap[nTileRow + nTileColumn];
nTileAttrib = BURN_ENDIAN_SWAP_INT16(pTilemap[nTileRow + nTileColumn]);
*pMyTileQueue[(nTileAttrib >> 8) & 0x0F]++ = (nTileAttrib << 16) | nTileNumber;
nTileXPos = (x << 4) - (nXPos & 15);
nTileYPos = (y << 4) - (nYPos & 15);
@ -206,10 +206,10 @@ static void QueueLayer2(INT32 i, UINT16* pTilemap, INT32 nXPos, INT32 nYPos)
for (x = 0; x < 21; x++) {
nTileColumn = (((nXPos >> 4) + x) << 1) & 0x3E;
nTileNumber = pTilemap[nTileRow + nTileColumn + 1];
nTileNumber = BURN_ENDIAN_SWAP_INT16(pTilemap[nTileRow + nTileColumn + 1]);
if (nTileNumber > 0 && nTileNumber <= nMaxTile[i]) {
nTileAttrib = pTilemap[nTileRow + nTileColumn];
nTileAttrib = BURN_ENDIAN_SWAP_INT16(pTilemap[nTileRow + nTileColumn]);
if ((nTileAttrib & 0x0F00) == 0) {
nTileAttrib |= 0x0100;
}

View File

@ -140,7 +140,7 @@ static void FUNCTIONNAME(BPP,ROT,FLIP,CLIP,OPACITY)()
#endif
#endif
nColour = *pTileData++;
nColour = BURN_ENDIAN_SWAP_INT32(*pTileData++);
PLOTPIXEL(OFFSET(0), nColour & 0x0F);
ADVANCECOLUMN;
nColour >>= 4;

View File

@ -23,11 +23,11 @@ inline static UINT32 CalcCol(UINT16 nColour)
{
INT32 r, g, b;
r = (nColour & 0x001F) << 3; // Red
r = (BURN_ENDIAN_SWAP_INT16(nColour) & 0x001F) << 3; // Red
r |= r >> 5;
g = (nColour & 0x03E0) >> 2; // Green
g = (BURN_ENDIAN_SWAP_INT16(nColour) & 0x03E0) >> 2; // Green
g |= g >> 5;
b = (nColour & 0x7C00) >> 7; // Blue
b = (BURN_ENDIAN_SWAP_INT16(nColour) & 0x7C00) >> 7; // Blue
b |= b >> 5;
return BurnHighCol(r, g, b, 0);

View File

@ -111,7 +111,7 @@ inline static void ToaGP9001WriteRAM(const UINT16 wordValue, const INT32 nContro
{
extern UINT8* GP9001Pointer[2];
*((UINT16*)(GP9001Pointer[nController])) = wordValue;
*((UINT16*)(GP9001Pointer[nController])) = BURN_ENDIAN_SWAP_INT16(wordValue);
GP9001Pointer[nController] += 2;
}
@ -119,14 +119,14 @@ inline static UINT16 ToaGP9001ReadRAM_Hi(const INT32 nController)
{
extern UINT8* GP9001Pointer[2];
return *((UINT16*)(GP9001Pointer[nController]));
return BURN_ENDIAN_SWAP_INT16(*((UINT16*)(GP9001Pointer[nController])));
}
inline static UINT16 ToaGP9001ReadRAM_Lo(const INT32 nController)
{
extern UINT8* GP9001Pointer[2];
return *((UINT16*)(GP9001Pointer[nController] + 2));
return BURN_ENDIAN_SWAP_INT16(*((UINT16*)(GP9001Pointer[nController] + 2)));
}
inline static void ToaGP9001SelectRegister(const UINT16 wordValue, const INT32 nController = 0)