From f72580a4201fd02f015b0cb3a41c9104a5040046 Mon Sep 17 00:00:00 2001 From: crystalct Date: Thu, 8 Jul 2021 16:15:08 +0200 Subject: [PATCH] sys16_gfx.cpp big endian fix #2 (#806) --- src/burn/drv/sega/sys16_gfx.cpp | 183 +++++++++++++++++++------------- 1 file changed, 112 insertions(+), 71 deletions(-) diff --git a/src/burn/drv/sega/sys16_gfx.cpp b/src/burn/drv/sega/sys16_gfx.cpp index 4d651a77ba..0c330cf99b 100644 --- a/src/burn/drv/sega/sys16_gfx.cpp +++ b/src/burn/drv/sega/sys16_gfx.cpp @@ -783,14 +783,14 @@ static void System16BCreateTileMaps() if (System16RecalcFgAltTileMap) { System16RecalcFgAltTileMap = 0; for (i = 0xf80/2 + 0 * 0x40/2; i < 0xf80/2 + 0 * 0x40/2 + 224/8; i++) { - if (TextRam[i] & 0x8000) System16RecalcFgAltTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TextRam[i]) & 0x8000) System16RecalcFgAltTileMap = 1; } } if (System16RecalcBgAltTileMap) { System16RecalcBgAltTileMap = 0; for (i = 0xf80/2 + 1 * 0x40/2; i < 0xf80/2 + 1 * 0x40/2 + 224/8; i++) { - if (TextRam[i] & 0x8000) System16RecalcBgAltTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TextRam[i]) & 0x8000) System16RecalcBgAltTileMap = 1; } } @@ -824,14 +824,14 @@ static void System16BAltCreateTileMaps() if (System16RecalcFgAltTileMap) { System16RecalcFgAltTileMap = 0; for (i = 0xf80/2 + 0 * 0x40/2; i < 0xf80/2 + 0 * 0x40/2 + 224/8; i++) { - if (TextRam[i] & 0x8000) System16RecalcFgAltTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TextRam[i]) & 0x8000) System16RecalcFgAltTileMap = 1; } } if (System16RecalcBgAltTileMap) { System16RecalcBgAltTileMap = 0; for (i = 0xf80/2 + 1 * 0x40/2; i < 0xf80/2 + 1 * 0x40/2 + 224/8; i++) { - if (TextRam[i] & 0x8000) System16RecalcBgAltTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TextRam[i]) & 0x8000) System16RecalcBgAltTileMap = 1; } } @@ -871,11 +871,11 @@ void System16ATileWordWrite(UINT32 Offset, UINT16 d) UINT32 BgPage4Addr = (((System16Page[1] >> 12) & 0xf) * (32 * 64)) << 1; if ((Offset >= FgPage1Addr && Offset <= (FgPage1Addr + 0xfff)) || (Offset >= FgPage2Addr && Offset <= (FgPage2Addr + 0xfff)) || (Offset >= FgPage3Addr && Offset <= (FgPage3Addr + 0xfff)) || (Offset >= FgPage4Addr && Offset <= (FgPage4Addr + 0xfff))) { - if (TileRam[Offset >> 1] != BURN_ENDIAN_SWAP_INT16(d)) System16RecalcFgTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TileRam[Offset >> 1]) != d) System16RecalcFgTileMap = 1; } if ((Offset >= BgPage1Addr && Offset <= (BgPage1Addr + 0xfff)) || (Offset >= BgPage2Addr && Offset <= (BgPage2Addr + 0xfff)) || (Offset >= BgPage3Addr && Offset <= (BgPage3Addr + 0xfff)) || (Offset >= BgPage4Addr && Offset <= (BgPage4Addr + 0xfff))) { - if (TileRam[Offset >> 1] != BURN_ENDIAN_SWAP_INT16(d)) System16RecalcBgTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TileRam[Offset >> 1]) != d) System16RecalcBgTileMap = 1; } TileRam[Offset >> 1] = BURN_ENDIAN_SWAP_INT16(d); @@ -929,19 +929,19 @@ void System16BTileWordWrite(UINT32 Offset, UINT16 d) UINT32 BgAltPage4Addr = (((System16Page[3] >> 12) & 0xf) * (32 * 64)) << 1; if ((Offset >= FgPage1Addr && Offset <= (FgPage1Addr + 0xfff)) || (Offset >= FgPage2Addr && Offset <= (FgPage2Addr + 0xfff)) || (Offset >= FgPage3Addr && Offset <= (FgPage3Addr + 0xfff)) || (Offset >= FgPage4Addr && Offset <= (FgPage4Addr + 0xfff))) { - if (TileRam[Offset >> 1] != BURN_ENDIAN_SWAP_INT16(d)) System16RecalcFgTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TileRam[Offset >> 1]) != d) System16RecalcFgTileMap = 1; } if ((Offset >= BgPage1Addr && Offset <= (BgPage1Addr + 0xfff)) || (Offset >= BgPage2Addr && Offset <= (BgPage2Addr + 0xfff)) || (Offset >= BgPage3Addr && Offset <= (BgPage3Addr + 0xfff)) || (Offset >= BgPage4Addr && Offset <= (BgPage4Addr + 0xfff))) { - if (TileRam[Offset >> 1] != BURN_ENDIAN_SWAP_INT16(d)) System16RecalcBgTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TileRam[Offset >> 1]) != d) System16RecalcBgTileMap = 1; } if ((Offset >= FgAltPage1Addr && Offset <= (FgAltPage1Addr + 0xfff)) || (Offset >= FgAltPage2Addr && Offset <= (FgAltPage2Addr + 0xfff)) || (Offset >= FgAltPage3Addr && Offset <= (FgAltPage3Addr + 0xfff)) || (Offset >= FgAltPage4Addr && Offset <= (FgAltPage4Addr + 0xfff))) { - if (TileRam[Offset >> 1] != BURN_ENDIAN_SWAP_INT16(d)) System16RecalcFgAltTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TileRam[Offset >> 1]) != d) System16RecalcFgAltTileMap = 1; } if ((Offset >= BgAltPage1Addr && Offset <= (BgAltPage1Addr + 0xfff)) || (Offset >= BgAltPage2Addr && Offset <= (BgAltPage2Addr + 0xfff)) || (Offset >= BgAltPage3Addr && Offset <= (BgAltPage3Addr + 0xfff)) || (Offset >= BgAltPage4Addr && Offset <= (BgAltPage4Addr + 0xfff))) { - if (TileRam[Offset >> 1] != BURN_ENDIAN_SWAP_INT16(d)) System16RecalcBgAltTileMap = 1; + if (BURN_ENDIAN_SWAP_INT16(TileRam[Offset >> 1]) != d) System16RecalcBgAltTileMap = 1; } TileRam[Offset >> 1] = BURN_ENDIAN_SWAP_INT16(d); @@ -1647,11 +1647,14 @@ static void System16ARenderSpriteLayer(INT32 Priority) INT32 x, y, pix, xdelta = 1; /* initialize the end address to the start address */ - data[7] = addr; + //data[7] = addr; + UINT16 d7 = addr; // data[7] cache /* if hidden, or top greater than/equal to bottom, or invalid bank, punt */ - if ((top >= bottom) || bank == 255) + if ((top >= bottom) || bank == 255) { + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 continue; + } /* clamp to within the memory region size */ if (numbanks) @@ -1672,9 +1675,10 @@ static void System16ARenderSpriteLayer(INT32 Priority) UINT16* pPixel = pTransDraw + (y * 320); if (!(addr & 0x8000)) { /* start at the word before because we preincrement below */ - data[7] = addr - 1; + //data[7] = addr - 1; + d7 = addr - 1; for (x = xpos; ((xpos - x) & 0x1ff) != 1; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++data[7] & 0x7fff]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++d7 & 0x7fff]); pix = (pixels >> 12) & 0xf; System16DrawPixel(x, pix, color, pPixel, PalRAM); x += xdelta; pix = (pixels >> 8) & 0xf; System16DrawPixel(x, pix, color, pPixel, PalRAM); x += xdelta; @@ -1684,9 +1688,10 @@ static void System16ARenderSpriteLayer(INT32 Priority) if (pix == 15) break; } } else { - data[7] = addr + 1; + //data[7] = addr + 1; + d7 = addr + 1; for (x = xpos; ((xpos - x) & 0x1ff) != 1; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--data[7] & 0x7fff]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--d7 & 0x7fff]); /* draw four pixels */ pix = (pixels >> 0) & 0xf; System16DrawPixel(x, pix, color, pPixel, PalRAM); x += xdelta; @@ -1700,6 +1705,7 @@ static void System16ARenderSpriteLayer(INT32 Priority) } } } + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 } } @@ -1739,11 +1745,14 @@ static void System16BRenderSpriteLayer(INT32 Priority) INT32 x, y, pix, xdelta = 1; /* initialize the end address to the start address */ - data[7] = addr; + //data[7] = addr; + UINT16 d7 = addr; // data[7] cache /* if hidden, or top greater than/equal to bottom, or invalid bank, punt */ - if (hide || (top >= bottom) || bank == 255) + if (hide || (top >= bottom) || bank == 255) { + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 continue; + } /* clamp to within the memory region size */ if (numbanks) @@ -1751,7 +1760,7 @@ static void System16BRenderSpriteLayer(INT32 Priority) spritedata = spritebase + 0x10000 * bank; /* reset the yzoom counter */ - data[5] &= 0x03ff; + data[5] &= BURN_ENDIAN_SWAP_INT16(0x03ff); if (System16ScreenFlip) { INT32 temp = top; @@ -1767,10 +1776,10 @@ static void System16BRenderSpriteLayer(INT32 Priority) addr += pitch; /* accumulate zoom factors; if we carry into the high bit, skip an extra row */ - data[5] += vzoom << 10; - if (data[5] & 0x8000) { + data[5] += BURN_ENDIAN_SWAP_INT16(vzoom << 10); + if (data[5] & BURN_ENDIAN_SWAP_INT16(0x8000)) { addr += pitch; - data[5] &= ~0x8000; + data[5] &= BURN_ENDIAN_SWAP_INT16(~0x8000); } /* skip drawing if not within the cliprect */ @@ -1784,9 +1793,10 @@ static void System16BRenderSpriteLayer(INT32 Priority) /* non-flipped case */ if (!flip) { /* start at the word before because we preincrement below */ - data[7] = addr - 1; + //data[7] = addr - 1; + d7 = addr - 1; for (x = xpos; ((xpos - x) & 0x1ff) != 1; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++data[7]]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++d7]); /* draw four pixels */ pix = (pixels >> 12) & 0xf; xacc = (xacc & 0x3f) + hzoom; if (xacc < 0x40) { System16DrawPixel(x, pix, color, pPixel, PalRAM); x += xdelta; } @@ -1799,9 +1809,10 @@ static void System16BRenderSpriteLayer(INT32 Priority) } } else { /* start at the word after because we predecrement below */ - data[7] = addr + 1; + //data[7] = addr + 1; + d7 = addr + 1; for (x = xpos; ((xpos - x) & 0x1ff) != 1; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--data[7]]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--d7]); /* draw four pixels */ pix = (pixels >> 0) & 0xf; xacc = (xacc & 0x3f) + hzoom; if (xacc < 0x40) { System16DrawPixel(x, pix, color, pPixel, PalRAM); x += xdelta; } @@ -1872,11 +1883,14 @@ static void OutrunRenderSpriteLayer(INT32 Priority) xpos -= 0xbe; /* initialize the end address to the start address */ - data[7] = BURN_ENDIAN_SWAP_INT16(addr); + //data[7] = BURN_ENDIAN_SWAP_INT16(addr); + UINT16 d7 = addr; // data[7] cache /* if hidden, or top greater than/equal to bottom, or invalid bank, punt */ - if (hide || height == 0) + if (hide || height == 0) { + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 continue; + } /* clamp to within the memory region size */ if (numbanks) @@ -1900,10 +1914,11 @@ static void OutrunRenderSpriteLayer(INT32 Priority) if (!flip) { /* start at the word before because we preincrement below */ - data[7] = addr - 1; + //data[7] = addr - 1; + d7 = addr - 1; for (x = xpos; (xdelta > 0 && x <= 319) || (xdelta < 0 && x >= 0); ) { - UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[++data[7]]); + UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[++d7]); /* draw four pixels */ pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { OutrunDrawPixel(x, pix, color, shadow, pPixel, PalRAM); x += xdelta; xacc += hzoom; } xacc -= 0x200; @@ -1925,10 +1940,11 @@ static void OutrunRenderSpriteLayer(INT32 Priority) else { /* start at the word after because we predecrement below */ - data[7] = addr + 1; + //data[7] = addr + 1; + d7 = addr + 1; for (x = xpos; (xdelta > 0 && x <= 319) || (xdelta < 0 && x >= 0); ) { - UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[--data[7]]); + UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[--d7]); /* draw four pixels */ pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { OutrunDrawPixel(x, pix, color, shadow, pPixel, PalRAM); x += xdelta; xacc += hzoom; } xacc -= 0x200; @@ -2000,11 +2016,14 @@ static void HangonRenderSpriteLayer(INT32 Priority) const UINT32 *spritedata; /* initialize the end address to the start address */ - data[7] = addr; + //data[7] = addr; + UINT16 d7 = addr; // data[7] cache /* if hidden, or top greater than/equal to bottom, or invalid bank, punt */ - if ((top >= bottom) || bank == 255) + if ((top >= bottom) || bank == 255) { + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 continue; + } /* clamp to within the memory region size */ if (numbanks) @@ -2028,9 +2047,10 @@ static void HangonRenderSpriteLayer(INT32 Priority) if (!(addr & 0x8000)) { /* start at the word before because we preincrement below */ - data[7] = addr - 1; + //data[7] = addr - 1; + d7 = addr - 1; for (x = xpos; x <= 319; ) { - UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[++data[7] & 0x7fff]); + UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[++d7 & 0x7fff]); pix = (pixels >> 28) & 0xf; xacc = (xacc & 0xff) + hzoom; if (xacc < 0x100) { if (x >= 0) HangonDrawPixel(x, pix, color, shadow, pPixel, PalRAM); x++; } pix = (pixels >> 24) & 0xf; xacc = (xacc & 0xff) + hzoom; if (xacc < 0x100) { if (x >= 0) HangonDrawPixel(x, pix, color, shadow, pPixel, PalRAM); x++; } @@ -2044,9 +2064,10 @@ static void HangonRenderSpriteLayer(INT32 Priority) if (pix == 15) break; } } else { - data[7] = addr + 1; + //data[7] = addr + 1; + d7 = addr + 1; for (x = xpos; x <= 319; ) { - UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[--data[7] & 0x7fff]); + UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[--d7 & 0x7fff]); pix = (pixels >> 0) & 0xf; xacc = (xacc & 0xff) + hzoom; if (xacc < 0x100) { if (x >= 0) HangonDrawPixel(x, pix, color, shadow, pPixel, PalRAM); x++; } pix = (pixels >> 4) & 0xf; xacc = (xacc & 0xff) + hzoom; if (xacc < 0x100) { if (x >= 0) HangonDrawPixel(x, pix, color, shadow, pPixel, PalRAM); x++; } @@ -2109,11 +2130,14 @@ static void HangonAltRenderSpriteLayer(INT32 Priority) const UINT16 *spritedata; /* initialize the end address to the start address */ - data[7] = addr; + //data[7] = addr; + UINT16 d7 = addr; // data[7] cache /* if hidden, or top greater than/equal to bottom, or invalid bank, punt */ - if ((top >= bottom) || bank == 255) + if ((top >= bottom) || bank == 255) { + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 continue; + } /* clamp to within the memory region size */ if (numbanks) @@ -2148,10 +2172,11 @@ static void HangonAltRenderSpriteLayer(INT32 Priority) if (!(addr & 0x8000)) { /* start at the word before because we preincrement below */ - data[7] = addr - 1; + //data[7] = addr - 1; + d7 = addr - 1; for (x = xpos; x <= 319; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++data[7] & 0x7fff]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++d7 & 0x7fff]); /* draw four pixels */ pix = (pixels >> 12) & 0xf; xacc = (xacc & 0xff) + hzoom; if (xacc < 0x100) { if (x >= 0) HangonAltDrawPixel(x, pix, color, pPixel); x++; } @@ -2169,10 +2194,11 @@ static void HangonAltRenderSpriteLayer(INT32 Priority) else { /* start at the word after because we predecrement below */ - data[7] = addr + 1; + //data[7] = addr + 1; + d7 = addr + 1; for (x = xpos; x <= 319; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--data[7] & 0x7fff]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--d7 & 0x7fff]); /* draw four pixels */ pix = (pixels >> 0) & 0xf; xacc = (xacc & 0xff) + hzoom; if (xacc < 0x100) { if (x >= 0) HangonAltDrawPixel(x, pix, color, pPixel); x++; } @@ -2244,11 +2270,14 @@ static void XBoardRenderSpriteLayer(INT32 Priority) xpos -= 0xbe; /* initialize the end address to the start address */ - data[7] = addr; + //data[7] = addr; + UINT16 d7 = addr; // data[7] cache /* if hidden, or top greater than/equal to bottom, or invalid bank, punt */ - if (hide || height == 0) + if (hide || height == 0) { + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 continue; + } /* clamp to within the memory region size */ if (numbanks) @@ -2272,10 +2301,11 @@ static void XBoardRenderSpriteLayer(INT32 Priority) if (!flip) { /* start at the word before because we preincrement below */ - data[7] = addr - 1; + //data[7] = addr - 1; + d7 = addr - 1; for (x = xpos; (xdelta > 0 && x <= 319) || (xdelta < 0 && x >= 0); ) { - UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[++data[7]]); + UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[++d7]); /* draw four pixels */ pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { BoardXDrawPixel(x, pix, color, shadow, pPixel, PalRAM); x += xdelta; xacc += hzoom; } xacc -= 0x200; @@ -2297,10 +2327,11 @@ static void XBoardRenderSpriteLayer(INT32 Priority) else { /* start at the word after because we predecrement below */ - data[7] = addr + 1; + //data[7] = addr + 1; + d7 = addr + 1; for (x = xpos; (xdelta > 0 && x <= 319) || (xdelta < 0 && x >= 0); ) { - UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[--data[7]]); + UINT32 pixels = BURN_ENDIAN_SWAP_INT32(spritedata[--d7]); /* draw four pixels */ pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { BoardXDrawPixel(x, pix, color, shadow, pPixel, PalRAM); x += xdelta; xacc += hzoom; } xacc -= 0x200; @@ -2357,7 +2388,7 @@ static void YBoardSystem16BRenderSpriteLayer() for (data = (UINT16*)System16SpriteRam; data < (UINT16*)System16SpriteRam + System16SpriteRamSize / 2; data += 8) { if (BURN_ENDIAN_SWAP_INT16(data[2]) & 0x8000) break; - INT32 sprpri = (data[1] >> 8) & 0x1e; + INT32 sprpri = (BURN_ENDIAN_SWAP_INT16(data[1]) >> 8) & 0x1e; INT32 bottom = BURN_ENDIAN_SWAP_INT16(data[0]) >> 8; INT32 top = BURN_ENDIAN_SWAP_INT16(data[0]) & 0xff; @@ -2374,11 +2405,14 @@ static void YBoardSystem16BRenderSpriteLayer() INT32 x, y, pix, xdelta = 1; /* initialize the end address to the start address */ - data[7] = BURN_ENDIAN_SWAP_INT16(addr); + //data[7] = BURN_ENDIAN_SWAP_INT16(addr); + UINT16 d7 = addr; /* if hidden, or top greater than/equal to bottom, or invalid bank, punt */ - if (hide || (top >= bottom) || bank == 255) + if (hide || (top >= bottom) || bank == 255) { + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 continue; + } /* clamp to within the memory region size */ if (numbanks) @@ -2386,7 +2420,7 @@ static void YBoardSystem16BRenderSpriteLayer() spritedata = spritebase + 0x10000 * bank; /* reset the yzoom counter */ - data[5] &= 0x03ff; + data[5] &= BURN_ENDIAN_SWAP_INT16(0x03ff); /* loop from top to bottom */ for (y = top; y < bottom; y++) { @@ -2394,10 +2428,10 @@ static void YBoardSystem16BRenderSpriteLayer() addr += pitch; /* accumulate zoom factors; if we carry into the high bit, skip an extra row */ - data[5] += vzoom << 10; - if (data[5] & 0x8000) { + data[5] += BURN_ENDIAN_SWAP_INT16(vzoom << 10); + if (data[5] & BURN_ENDIAN_SWAP_INT16(0x8000)) { addr += pitch; - data[5] &= ~0x8000; + data[5] &= BURN_ENDIAN_SWAP_INT16(~0x8000); } /* skip drawing if not within the cliprect */ @@ -2412,9 +2446,10 @@ static void YBoardSystem16BRenderSpriteLayer() /* non-flipped case */ if (!flip) { /* start at the word before because we preincrement below */ - data[7] = addr - 1; + //data[7] = addr - 1; + d7 = addr - 1; for (x = xpos; ((xpos - x) & 0x1ff) != 1; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++data[7]]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++d7]); /* draw four pixels */ pix = (pixels >> 12) & 0xf; xacc = (xacc & 0x3f) + hzoom; if (xacc < 0x40) { YBoardSystem16BDrawPixel(x, pix, sprpri, color, pPixel, pPrio, PalRAM); x += xdelta; } @@ -2427,9 +2462,10 @@ static void YBoardSystem16BRenderSpriteLayer() } } else { /* start at the word after because we predecrement below */ - data[7] = addr + 1; + //data[7] = addr + 1; + d7 = addr + 1; for (x = xpos; ((xpos - x) & 0x1ff) != 1; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--data[7]]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--d7]); /* draw four pixels */ pix = (pixels >> 0) & 0xf; xacc = (xacc & 0x3f) + hzoom; if (xacc < 0x40) { YBoardSystem16BDrawPixel(x, pix, sprpri, color, pPixel, pPrio, PalRAM); x += xdelta; } @@ -3393,11 +3429,14 @@ static void System18RenderSpriteLayer() INT32 x, y, pix, xdelta = 1; /* initialize the end address to the start address */ - data[7] = addr; + //data[7] = addr; + UINT16 d7 = addr; // data[7] cache /* if hidden, or top greater than/equal to bottom, or invalid bank, punt */ - if (hide || (top >= bottom) || bank == 255) + if (hide || (top >= bottom) || bank == 255) { + data[7] = BURN_ENDIAN_SWAP_INT16(d7); // un-cache d7 continue; + } /* clamp to within the memory region size */ if (numbanks) @@ -3405,7 +3444,7 @@ static void System18RenderSpriteLayer() spritedata = spritebase + 0x10000 * bank; /* reset the yzoom counter */ - data[5] &= 0x03ff; + data[5] &= BURN_ENDIAN_SWAP_INT16(0x03ff); if (System16ScreenFlip) { INT32 temp = top; @@ -3421,10 +3460,10 @@ static void System18RenderSpriteLayer() addr += pitch; /* accumulate zoom factors; if we carry into the high bit, skip an extra row */ - data[5] += vzoom << 10; - if (data[5] & 0x8000) { + data[5] += BURN_ENDIAN_SWAP_INT16(vzoom << 10); + if (data[5] & BURN_ENDIAN_SWAP_INT16(0x8000)) { addr += pitch; - data[5] &= ~0x8000; + data[5] &= BURN_ENDIAN_SWAP_INT16(~0x8000); } /* skip drawing if not within the cliprect */ @@ -3438,9 +3477,10 @@ static void System18RenderSpriteLayer() /* non-flipped case */ if (!flip) { /* start at the word before because we preincrement below */ - data[7] = addr - 1; + //data[7] = addr - 1; + d7 = addr - 1; for (x = xpos; ((xpos - x) & 0x1ff) != 1; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++data[7]]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[++d7]); /* draw four pixels */ pix = (pixels >> 12) & 0xf; xacc = (xacc & 0x3f) + hzoom; if (xacc < 0x40) { System18DrawPixel(x, pix, color, pPixel); x += xdelta; } @@ -3453,9 +3493,10 @@ static void System18RenderSpriteLayer() } } else { /* start at the word after because we predecrement below */ - data[7] = addr + 1; + //data[7] = addr + 1; + d7 = addr + 1; for (x = xpos; ((xpos - x) & 0x1ff) != 1; ) { - UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--data[7]]); + UINT16 pixels = BURN_ENDIAN_SWAP_INT16(spritedata[--d7]); /* draw four pixels */ pix = (pixels >> 0) & 0xf; xacc = (xacc & 0x3f) + hzoom; if (xacc < 0x40) { System18DrawPixel(x, pix, color, pPixel); x += xdelta; }