From 6b23bc80177ddcc963d03b1aa658870adf484564 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Fri, 28 Aug 2009 13:49:40 +0200 Subject: [PATCH] reorg gfx & tile code --- gfx.cpp | 236 ++++----------- gfx.h | 6 +- platform/sdlv.cpp | 9 +- tile.cpp | 848 ++++++++++++++++++++++++++++++++++++----------------- tile.h | 403 ++++++------------------- 5 files changed, 737 insertions(+), 765 deletions(-) diff --git a/gfx.cpp b/gfx.cpp index 27c1b0d..6889b82 100644 --- a/gfx.cpp +++ b/gfx.cpp @@ -47,23 +47,11 @@ #include "gfx.h" #include "apu.h" #include "cheats.h" -#include -//#include "asmmemfuncs.h" +#include "tile.h" +#include "misc.h" #define USE_CRAZY_OPTS -//misc.s -#ifdef __cplusplus -extern "C" { -#endif -extern void memcpy16(unsigned short *dest, unsigned short *src, int count); -extern void memcpy16bswap(unsigned short *dest, void *src, int count); -extern void memcpy32(uint32_t *dest, uint32_t *src, int count); -extern void memset32(uint32_t *dest, int c, int count); -#ifdef __cplusplus -} -#endif - #define M7 19 #define M8 19 @@ -114,109 +102,6 @@ extern uint8 Mode7Depths [2]; #define BLACK BUILD_PIXEL(0,0,0) -void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); -void DrawClippedTile (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); -void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); -void DrawClippedTilex2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); -void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); -void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); -void DrawLargePixel (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); -void DrawClippedTile16 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); -void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); -void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); -void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); -void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); -void DrawLargePixel16 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawTile16Add (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); - -void DrawClippedTile16Add (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawTile16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); - -void DrawClippedTile16Add1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); - -void DrawClippedTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawTile16Sub (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); - -void DrawClippedTile16Sub (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawTile16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); - -void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx); - -void DrawClippedTile16FixedSub1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawLargePixel16Add (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawLargePixel16Add1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawLargePixel16Sub (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawLargePixel16Sub1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawHiResClippedTile16 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - -void DrawHiResTile16 (uint32 Tile, uint32 Offset, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); - bool8_32 S9xGraphicsInit () { register uint32 PixelOdd = 1; @@ -317,14 +202,8 @@ bool8_32 S9xGraphicsInit () PixelOdd <<= 2; } - GFX.RealPitch = GFX.Pitch2 = GFX.Pitch; - GFX.ZPitch = GFX.Pitch; - if (Settings.SixteenBit) - GFX.ZPitch >>= 1; - GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1; - GFX.DepthDelta = GFX.SubZBuffer - GFX.ZBuffer; - //GFX.InfoStringTimeout = 0; - //GFX.InfoString = NULL; + GFX.InfoStringTimeout = 0; + GFX.InfoString = NULL; PPU.BG_Forced = 0; IPPU.OBJChanged = TRUE; @@ -573,9 +452,6 @@ void S9xStartScreenRefresh () IPPU.DoubleWidthPixels = FALSE; GFX.Pitch2 = GFX.Pitch = GFX.RealPitch; GFX.PPL = GFX.PPLx2 >> 1; - GFX.ZPitch = GFX.RealPitch; - if (Settings.SixteenBit) - GFX.ZPitch >>= 1; PPU.RecomputeClipWindows = TRUE; GFX.DepthDelta = GFX.SubZBuffer - GFX.ZBuffer; GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1; @@ -964,7 +840,7 @@ void DrawOBJS (bool8_32 OnMain = FALSE, uint8 D = 0) if (W > Width) W = Width; (*DrawClippedTilePtr) (Tile, O, Offset, W, - TileLine, LineCount, &GFX); + TileLine, LineCount); if (W >= Width) continue; @@ -988,12 +864,12 @@ void DrawOBJS (bool8_32 OnMain = FALSE, uint8 D = 0) for (int X = 0; X < Middle; X++, O += 8 * GFX.PixSize, Tile += TileInc) { - (*DrawTilePtr) (Tile, O, TileLine, LineCount, &GFX); + (*DrawTilePtr) (Tile, O, TileLine, LineCount); } if (Offset) { (*DrawClippedTilePtr) (Tile, O, 0, Offset, - TileLine, LineCount, &GFX); + TileLine, LineCount); } } } @@ -1141,13 +1017,13 @@ void DrawBackgroundMosaic (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { (*DrawLargePixelPtr) (Tile + 17 - (Quot & 1), s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } else { (*DrawLargePixelPtr) (Tile + 1 - (Quot & 1), s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } } else @@ -1157,13 +1033,13 @@ void DrawBackgroundMosaic (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { (*DrawLargePixelPtr) (Tile + 17 - (Quot & 1), s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } else { (*DrawLargePixelPtr) (Tile + 1 - (Quot & 1), s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } } } @@ -1177,13 +1053,13 @@ void DrawBackgroundMosaic (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { (*DrawLargePixelPtr) (Tile + 16 + (Quot & 1), s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } else { (*DrawLargePixelPtr) (Tile + (Quot & 1), s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } } else @@ -1193,20 +1069,20 @@ void DrawBackgroundMosaic (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { (*DrawLargePixelPtr) (Tile + 16 + (Quot & 1), s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } else { (*DrawLargePixelPtr) (Tile + (Quot & 1), s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } } } } else (*DrawLargePixelPtr) (Tile, s, HPos & 7, PixWidth, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } } } @@ -1451,14 +1327,14 @@ void DrawBackgroundOffset (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) GFX.Z1 = GFX.Z2 = depths [(Tile & 0x2000) >> 13]; if (BG.TileSize == 8) - (*DrawClippedTilePtr) (Tile, s, Offset, Count, VirtAlign, Lines, &GFX); + (*DrawClippedTilePtr) (Tile, s, Offset, Count, VirtAlign, Lines); else { if (!(Tile & (V_FLIP | H_FLIP))) { // Normal, unflipped (*DrawClippedTilePtr) (Tile + t1 + (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } else if (Tile & H_FLIP) @@ -1467,20 +1343,20 @@ void DrawBackgroundOffset (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { // H & V flip (*DrawClippedTilePtr) (Tile + t2 + 1 - (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } else { // H flip only (*DrawClippedTilePtr) (Tile + t1 + 1 - (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } } else { // V flip only (*DrawClippedTilePtr) (Tile + t2 + (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } } @@ -1636,13 +1512,13 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // Normal, unflipped (*DrawHiResClippedTilePtr) (Tile + (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } else { // H flip (*DrawHiResClippedTilePtr) (Tile + 1 - (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } } else @@ -1651,7 +1527,7 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // Normal, unflipped (*DrawHiResClippedTilePtr) (Tile + t1 + (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } else if (Tile & H_FLIP) @@ -1660,20 +1536,20 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // H & V flip (*DrawHiResClippedTilePtr) (Tile + t2 + 1 - (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } else { // H flip only (*DrawHiResClippedTilePtr) (Tile + t1 + 1 - (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } } else { // V flip only (*DrawHiResClippedTilePtr) (Tile + t2 + (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } } @@ -1700,13 +1576,13 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // Normal, unflipped (*DrawHiResTilePtr) (Tile + (Quot & 1), - s, VirtAlign, Lines, &GFX); + s, VirtAlign, Lines); } else { // H flip (*DrawHiResTilePtr) (Tile + 1 - (Quot & 1), - s, VirtAlign, Lines, &GFX); + s, VirtAlign, Lines); } } else @@ -1715,7 +1591,7 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // Normal, unflipped (*DrawHiResTilePtr) (Tile + t1 + (Quot & 1), - s, VirtAlign, Lines, &GFX); + s, VirtAlign, Lines); } else if (Tile & H_FLIP) @@ -1724,20 +1600,20 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // H & V flip (*DrawHiResTilePtr) (Tile + t2 + 1 - (Quot & 1), - s, VirtAlign, Lines, &GFX); + s, VirtAlign, Lines); } else { // H flip only (*DrawHiResTilePtr) (Tile + t1 + 1 - (Quot & 1), - s, VirtAlign, Lines, &GFX); + s, VirtAlign, Lines); } } else { // V flip only (*DrawHiResTilePtr) (Tile + t2 + (Quot & 1), - s, VirtAlign, Lines, &GFX); + s, VirtAlign, Lines); } } @@ -1760,13 +1636,13 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // Normal, unflipped (*DrawHiResClippedTilePtr) (Tile + (Quot & 1), - s, 0, Count, VirtAlign, Lines, &GFX); + s, 0, Count, VirtAlign, Lines); } else { // H flip (*DrawHiResClippedTilePtr) (Tile + 1 - (Quot & 1), - s, 0, Count, VirtAlign, Lines, &GFX); + s, 0, Count, VirtAlign, Lines); } } else @@ -1775,7 +1651,7 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // Normal, unflipped (*DrawHiResClippedTilePtr) (Tile + t1 + (Quot & 1), - s, 0, Count, VirtAlign, Lines, &GFX); + s, 0, Count, VirtAlign, Lines); } else if (Tile & H_FLIP) @@ -1784,20 +1660,20 @@ void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) { // H & V flip (*DrawHiResClippedTilePtr) (Tile + t2 + 1 - (Quot & 1), - s, 0, Count, VirtAlign, Lines, &GFX); + s, 0, Count, VirtAlign, Lines); } else { // H flip only (*DrawHiResClippedTilePtr) (Tile + t1 + 1 - (Quot & 1), - s, 0, Count, VirtAlign, Lines, &GFX); + s, 0, Count, VirtAlign, Lines); } } else { // V flip only (*DrawHiResClippedTilePtr) (Tile + t2 + (Quot & 1), - s, 0, Count, VirtAlign, Lines, &GFX); + s, 0, Count, VirtAlign, Lines); } } } @@ -1992,7 +1868,7 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) if (BG.TileSize == 8) { (*DrawClippedTilePtr) (Tile, s, Offset, Count, VirtAlign, - Lines, &GFX); + Lines); } else { @@ -2000,7 +1876,7 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { // Normal, unflipped (*DrawClippedTilePtr) (Tile + t1 + (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } else if (Tile & H_FLIP) @@ -2009,20 +1885,20 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { // H & V flip (*DrawClippedTilePtr) (Tile + t2 + 1 - (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } else { // H flip only (*DrawClippedTilePtr) (Tile + t1 + 1 - (Quot & 1), - s, Offset, Count, VirtAlign, Lines, &GFX); + s, Offset, Count, VirtAlign, Lines); } } else { // V flip only (*DrawClippedTilePtr) (Tile + t2 + (Quot & 1), s, - Offset, Count, VirtAlign, Lines, &GFX); + Offset, Count, VirtAlign, Lines); } } @@ -2064,13 +1940,13 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { // Both horzontal & vertical flip (*DrawTilePtr) (Tile + t2 + 1 - (Quot & 1), s, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } else { // Horizontal flip only (*DrawTilePtr) (Tile + t1 + 1 - (Quot & 1), s, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } } else @@ -2080,19 +1956,19 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { // Vertical flip only (*DrawTilePtr) (Tile + t2 + (Quot & 1), s, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } else { // Normal unflipped (*DrawTilePtr) (Tile + t1 + (Quot & 1), s, - VirtAlign, Lines, &GFX); + VirtAlign, Lines); } } } else { - (*DrawTilePtr) (Tile, s, VirtAlign, Lines, &GFX); + (*DrawTilePtr) (Tile, s, VirtAlign, Lines); } if (BG.TileSize == 8) @@ -2122,14 +1998,14 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) if (BG.TileSize == 8) (*DrawClippedTilePtr) (Tile, s, 0, Count, VirtAlign, - Lines, &GFX); + Lines); else { if (!(Tile & (V_FLIP | H_FLIP))) { // Normal, unflipped (*DrawClippedTilePtr) (Tile + t1 + (Quot & 1), s, 0, - Count, VirtAlign, Lines, &GFX); + Count, VirtAlign, Lines); } else if (Tile & H_FLIP) @@ -2139,14 +2015,14 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) // H & V flip (*DrawClippedTilePtr) (Tile + t2 + 1 - (Quot & 1), s, 0, Count, VirtAlign, - Lines, &GFX); + Lines); } else { // H flip only (*DrawClippedTilePtr) (Tile + t1 + 1 - (Quot & 1), s, 0, Count, VirtAlign, - Lines, &GFX); + Lines); } } else @@ -2154,7 +2030,7 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) // V flip only (*DrawClippedTilePtr) (Tile + t2 + (Quot & 1), s, 0, Count, VirtAlign, - Lines, &GFX); + Lines); } } } @@ -3218,10 +3094,6 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) for (register int x = 255; x >= 0; x--, p--, q -= 2) *q = *(q + 1) = *p; } - GFX.Pitch = GFX.Pitch2 = GFX.RealPitch; - GFX.PPL = GFX.Pitch >> 1; - GFX.PPLx2 = GFX.Pitch; - GFX.ZPitch = GFX.PPL; } else #endif diff --git a/gfx.h b/gfx.h index 97f1c1a..279fec8 100644 --- a/gfx.h +++ b/gfx.h @@ -203,13 +203,13 @@ GFX.ZERO [(((C1) | RGB_HI_BITS_MASKx2) - \ ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1] typedef void (*NormalTileRenderer) (uint32 Tile, uint32 Offset, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); + uint32 StartLine, uint32 LineCount); typedef void (*ClippedTileRenderer) (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); + uint32 StartLine, uint32 LineCount); typedef void (*LargePixelRenderer) (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx); + uint32 StartLine, uint32 LineCount); START_EXTERN_C void S9xStartScreenRefresh (); diff --git a/platform/sdlv.cpp b/platform/sdlv.cpp index 03c7c06..0f173b7 100644 --- a/platform/sdlv.cpp +++ b/platform/sdlv.cpp @@ -149,7 +149,7 @@ static void setupVideoSurface() // We get pitch surface values from SDL GFX.RealPitch = GFX.Pitch = screen->pitch; - GFX.ZPitch = realWidth; // The ZBuffer is independent of SDL surface size. + GFX.ZPitch = GFX.Pitch / 2; // gfx & tile.cpp depend on this, unfortunately. GFX.PixSize = screen->format->BitsPerPixel / 8; // Ok, calculate renderArea @@ -171,13 +171,12 @@ static void setupVideoSurface() + (renderArea.x * GFX.PixSize) + (renderArea.y * GFX.Pitch); GFX.SubScreen = (uint8 *) malloc(GFX.Pitch * IMAGE_HEIGHT); - GFX.ZBuffer = (uint8 *) malloc(GFX.Pitch * IMAGE_HEIGHT); - GFX.SubZBuffer = (uint8 *) malloc(GFX.Pitch * IMAGE_HEIGHT); - + GFX.ZBuffer = (uint8 *) malloc(GFX.ZPitch * IMAGE_HEIGHT); + GFX.SubZBuffer = (uint8 *) malloc(GFX.ZPitch * IMAGE_HEIGHT); + GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1; GFX.PPL = GFX.Pitch >> 1; GFX.PPLx2 = GFX.Pitch; - GFX.ZPitch = GFX.Pitch >> 1; // TODO printf("Video: %dx%d (%dx%d output), %hu bits per pixel, %s %s\n", realWidth, realHeight, diff --git a/tile.cpp b/tile.cpp index 22bd06b..f516d44 100644 --- a/tile.cpp +++ b/tile.cpp @@ -50,6 +50,318 @@ #include "3d.h" #endif +#define TILE_PREAMBLE \ + uint8 *pCache; \ +\ + uint32 TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift); \ + if ((Tile & 0x1ff) >= 256) \ + TileAddr += BG.NameSelect; \ +\ + TileAddr &= 0xffff; \ +\ + uint32 TileNumber; \ + pCache = &BG.Buffer[(TileNumber = (TileAddr >> BG.TileShift)) << 6]; \ +\ + if (!BG.Buffered [TileNumber]) \ + BG.Buffered[TileNumber] = ConvertTile (pCache, TileAddr); \ +\ + if (BG.Buffered [TileNumber] == BLANK_TILE) \ + return; \ +\ + register uint32 l; \ + if (BG.DirectColourMode) \ + { \ + if (IPPU.DirectColourMapsNeedRebuild) \ + S9xBuildDirectColourMaps (); \ + GFX.ScreenColors = DirectColourMaps [(Tile >> 10) & BG.PaletteMask]; \ + } \ + else \ + GFX.ScreenColors = &IPPU.ScreenColors [(((Tile >> 10) & BG.PaletteMask) << BG.PaletteShift) + BG.StartPalette]; + +#define RENDER_TILE(NORMAL, FLIPPED, N) \ + if (!(Tile & (V_FLIP | H_FLIP))) \ + { \ + bp = pCache + StartLine; \ + for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ + { \ + if (*(uint32 *) bp) \ + NORMAL (Offset, bp); \ + if (*(uint32 *) (bp + 4)) \ + NORMAL (Offset + N, bp + 4); \ + } \ + } \ + else \ + if (!(Tile & V_FLIP)) \ + { \ + bp = pCache + StartLine; \ + for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ + { \ + if (*(uint32 *) (bp + 4)) \ + FLIPPED (Offset, bp + 4); \ + if (*(uint32 *) bp) \ + FLIPPED (Offset + N, bp); \ + } \ + } \ + else \ + if (Tile & H_FLIP) \ + { \ + bp = pCache + 56 - StartLine; \ + for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ + { \ + if (*(uint32 *) (bp + 4)) \ + FLIPPED (Offset, bp + 4); \ + if (*(uint32 *) bp) \ + FLIPPED (Offset + N, bp); \ + } \ + } \ + else \ + { \ + bp = pCache + 56 - StartLine; \ + for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ + { \ + if (*(uint32 *) bp) \ + NORMAL (Offset, bp); \ + if (*(uint32 *) (bp + 4)) \ + NORMAL (Offset + N, bp + 4); \ + } \ + } + +#define TILE_CLIP_PREAMBLE \ + uint32 dd; \ + uint32 d1; \ + uint32 d2; \ +\ + if (StartPixel < 4) \ + { \ + d1 = HeadMask [StartPixel]; \ + if (StartPixel + Width < 4) \ + d1 &= TailMask [StartPixel + Width]; \ + } \ + else \ + d1 = 0; \ +\ + if (StartPixel + Width > 4) \ + { \ + if (StartPixel > 4) \ + d2 = HeadMask [StartPixel - 4]; \ + else \ + d2 = 0xffffffff; \ +\ + d2 &= TailMask [(StartPixel + Width - 4)]; \ + } \ + else \ + d2 = 0; + + +#define RENDER_CLIPPED_TILE(NORMAL, FLIPPED, N) \ + if (!(Tile & (V_FLIP | H_FLIP))) \ + { \ + bp = pCache + StartLine; \ + for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ + { \ + if ((dd = (*(uint32 *) bp) & d1)) \ + NORMAL (Offset, (uint8 *) &dd); \ + if ((dd = (*(uint32 *) (bp + 4)) & d2)) \ + NORMAL (Offset + N, (uint8 *) &dd); \ + } \ + } \ + else \ + if (!(Tile & V_FLIP)) \ + { \ + bp = pCache + StartLine; \ + SWAP_DWORD (d1); \ + SWAP_DWORD (d2); \ + for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ + { \ + if ((dd = *(uint32 *) (bp + 4) & d1)) \ + FLIPPED (Offset, (uint8 *) &dd); \ + if ((dd = *(uint32 *) bp & d2)) \ + FLIPPED (Offset + N, (uint8 *) &dd); \ + } \ + } \ + else \ + if (Tile & H_FLIP) \ + { \ + bp = pCache + 56 - StartLine; \ + SWAP_DWORD (d1); \ + SWAP_DWORD (d2); \ + for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ + { \ + if ((dd = *(uint32 *) (bp + 4) & d1)) \ + FLIPPED (Offset, (uint8 *) &dd); \ + if ((dd = *(uint32 *) bp & d2)) \ + FLIPPED (Offset + N, (uint8 *) &dd); \ + } \ + } \ + else \ + { \ + bp = pCache + 56 - StartLine; \ + for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ + { \ + if ((dd = (*(uint32 *) bp) & d1)) \ + NORMAL (Offset, (uint8 *) &dd); \ + if ((dd = (*(uint32 *) (bp + 4)) & d2)) \ + NORMAL (Offset + N, (uint8 *) &dd); \ + } \ + } + +#define RENDER_TILE_LARGE(PIXEL, FUNCTION) \ + if (!(Tile & (V_FLIP | H_FLIP))) \ + { \ + if ((pixel = *(pCache + StartLine + StartPixel))) \ + { \ + pixel = PIXEL; \ + for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \ + { \ + for (int z = Pixels - 1; z >= 0; z--) \ + if (GFX.Z1 > Depth [z]) \ + { \ + sp [z] = FUNCTION(sp + z, pixel); \ + Depth [z] = GFX.Z2; \ + }\ + } \ + } \ + } \ + else \ + if (!(Tile & V_FLIP)) \ + { \ + StartPixel = 7 - StartPixel; \ + if ((pixel = *(pCache + StartLine + StartPixel))) \ + { \ + pixel = PIXEL; \ + for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \ + { \ + for (int z = Pixels - 1; z >= 0; z--) \ + if (GFX.Z1 > Depth [z]) \ + { \ + sp [z] = FUNCTION(sp + z, pixel); \ + Depth [z] = GFX.Z2; \ + }\ + } \ + } \ + } \ + else \ + if (Tile & H_FLIP) \ + { \ + StartPixel = 7 - StartPixel; \ + if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \ + { \ + pixel = PIXEL; \ + for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \ + { \ + for (int z = Pixels - 1; z >= 0; z--) \ + if (GFX.Z1 > Depth [z]) \ + { \ + sp [z] = FUNCTION(sp + z, pixel); \ + Depth [z] = GFX.Z2; \ + }\ + } \ + } \ + } \ + else \ + { \ + if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \ + { \ + pixel = PIXEL; \ + for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \ + { \ + for (int z = Pixels - 1; z >= 0; z--) \ + if (GFX.Z1 > Depth [z]) \ + { \ + sp [z] = FUNCTION(sp + z, pixel); \ + Depth [z] = GFX.Z2; \ + }\ + } \ + } \ + } + +#define RENDER_TILEHI(NORMAL, FLIPPED, N) \ + if (!(Tile & (V_FLIP | H_FLIP))) \ + { \ + bp = pCache + StartLine; \ + for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ + { \ + /*if (*(uint32 *) bp)*/if (((uint32)bp[0])|((uint32)bp[2])|((uint32)bp[4])|((uint32)bp[6])) \ + NORMAL (Offset, bp); \ + } \ + } \ + else \ + if (!(Tile & V_FLIP)) \ + { \ + bp = pCache + StartLine; \ + for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ + { \ + /*if (*(uint32 *) (bp + 4))*/if (((uint32)bp[0])|((uint32)bp[2])|((uint32)bp[4])|((uint32)bp[6])) \ + FLIPPED (Offset, bp); \ + } \ + } \ + else \ + if (Tile & H_FLIP) \ + { \ + bp = pCache + 56 - StartLine; \ + for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ + { \ + /*if (*(uint32 *) (bp + 4))*/if (((uint32)bp[0])|((uint32)bp[2])|((uint32)bp[4])|((uint32)bp[6])) \ + FLIPPED (Offset, bp); \ + } \ + } \ + else \ + { \ + bp = pCache + 56 - StartLine; \ + for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ + { \ + /*if (*(uint32 *) bp)*/if (((uint32)bp[0])|((uint32)bp[2])|((uint32)bp[4])|((uint32)bp[6])) \ + NORMAL (Offset, bp); \ + } \ + } + + + +#define RENDER_CLIPPED_TILEHI(NORMAL, FLIPPED, N) \ + d1=(d1&0xFF)|((d1&0xFF0000)>>8)|((d2&0xFF)<<16)|((d2&0xFF0000)<<8);\ + if (!(Tile & (V_FLIP | H_FLIP))) \ + { \ + bp = pCache + StartLine; \ + for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ + { \ + /*if ((dd = (*(uint32 *) bp) & d1))*/if ((dd = (((((uint32)bp[6])<<24)|(((uint32)bp[4])<<16)|(((uint32)bp[2])<<8)|((uint32)bp[0]))&d1))) \ + NORMAL (Offset, (uint8 *) &dd); \ + } \ + } \ + else \ + if (!(Tile & V_FLIP)) \ + { \ + bp = pCache + StartLine; \ + SWAP_DWORD (d1); \ + /*SWAP_DWORD (d2);*/ \ + for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \ + { \ + /*if ((dd = *(uint32 *) (bp + 4) & d1))*/if ((dd = (((((uint32)bp[6])<<24)|(((uint32)bp[4])<<16)|(((uint32)bp[2])<<8)|((uint32)bp[0]))&d1))) \ + FLIPPED (Offset, (uint8 *) &dd); \ + } \ + } \ + else \ + if (Tile & H_FLIP) \ + { \ + bp = pCache + 56 - StartLine; \ + SWAP_DWORD (d1); \ + /*SWAP_DWORD (d2);*/ \ + for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ + { \ + /*if ((dd = *(uint32 *) (bp + 4) & d1))*/if ((dd = (((((uint32)bp[6])<<24)|(((uint32)bp[4])<<16)|(((uint32)bp[2])<<8)|((uint32)bp[0]))&d1))) \ + FLIPPED (Offset, (uint8 *) &dd); \ + } \ + } \ + else \ + { \ + bp = pCache + 56 - StartLine; \ + for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \ + { \ + /*if ((dd = (*(uint32 *) bp) & d1))*/ if ((dd = (((((uint32)bp[6])<<24)|(((uint32)bp[4])<<16)|(((uint32)bp[2])<<8)|((uint32)bp[0]))&d1))) \ + NORMAL (Offset, (uint8 *) &dd); \ + } \ + } + extern uint32 HeadMask [4]; extern uint32 TailMask [5]; @@ -168,17 +480,17 @@ uint8 ConvertTile (uint8 *pCache, uint32 TileAddr) return (non_zero ? TRUE : BLANK_TILE); } -INLINE void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; - uint8 *Screen = gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ - Screen [N] = (uint8) gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -188,17 +500,17 @@ INLINE void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) #undef FN } -INLINE void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; - uint8 *Screen = gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ - Screen [N] = (uint8) gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -248,17 +560,17 @@ inline void WRITE_4PIXELSHI16_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; - uint8 *Screen = gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [0] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [0] && (Pixel = Pixels[N])) \ { \ - Screen [N * 2] = Screen [N * 2 + 1] = (uint8) gfx->ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = gfx->Z2; \ + Screen [N * 2] = Screen [N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ } FN(0) @@ -268,17 +580,17 @@ INLINE void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) #undef FN } -INLINE void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; - uint8 *Screen = gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ { \ - Screen [N * 2] = Screen [N * 2 + 1] = (uint8) gfx->ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = gfx->Z2; \ + Screen [N * 2] = Screen [N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ } FN(0) @@ -288,19 +600,19 @@ INLINE void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels, struct SGFX * #undef FN } -INLINE void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; - uint8 *Screen = gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [gfx->RealPitch + N * 2] = \ - Screen [gfx->RealPitch + N * 2 + 1] = (uint8) gfx->ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [gfx->RealPitch + N * 2] = \ - Depth [gfx->RealPitch + N * 2 + 1] = gfx->Z2; \ + Screen [N * 2] = Screen [N * 2 + 1] = Screen [GFX.RealPitch + N * 2] = \ + Screen [GFX.RealPitch + N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = Depth [GFX.RealPitch + N * 2] = \ + Depth [GFX.RealPitch + N * 2 + 1] = GFX.Z2; \ } FN(0) @@ -310,19 +622,19 @@ INLINE void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) #undef FN } -INLINE void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; - uint8 *Screen = gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [gfx->RealPitch + N * 2] = \ - Screen [gfx->RealPitch + N * 2 + 1] = (uint8) gfx->ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [gfx->RealPitch + N * 2] = \ - Depth [gfx->RealPitch + N * 2 + 1] = gfx->Z2; \ + Screen [N * 2] = Screen [N * 2 + 1] = Screen [GFX.RealPitch + N * 2] = \ + Screen [GFX.RealPitch + N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = Depth [GFX.RealPitch + N * 2] = \ + Depth [GFX.RealPitch + N * 2 + 1] = GFX.Z2; \ } FN(0) @@ -332,8 +644,7 @@ INLINE void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels, struct SGFX #undef FN } -void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) +void DrawTile(uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -342,9 +653,9 @@ void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) } -void DrawClippedTile (uint32 Tile, uint32 Offset, +void DrawClippedTile(uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -353,8 +664,7 @@ void DrawClippedTile (uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) } -void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) +void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -365,7 +675,7 @@ void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTilex2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -375,7 +685,7 @@ void DrawClippedTilex2 (uint32 Tile, uint32 Offset, } void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE @@ -386,7 +696,7 @@ void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -397,29 +707,29 @@ void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, void DrawLargePixel (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE - register uint8 *sp = gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + register uint8 *sp = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; uint8 pixel; #define PLOT_PIXEL(screen, pixel) (pixel) - RENDER_TILE_LARGE (((uint8) gfx->ScreenColors [pixel]), PLOT_PIXEL) + RENDER_TILE_LARGE (((uint8) GFX.ScreenColors [pixel]), PLOT_PIXEL) } -INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -429,17 +739,17 @@ INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -449,17 +759,17 @@ INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels, struct SGFX * #undef FN } -INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ { \ - Screen [N * 2] = Screen [N * 2 + 1] = gfx->ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = gfx->Z2; \ + Screen [N * 2] = Screen [N * 2 + 1] = GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ } FN(0) @@ -469,17 +779,17 @@ INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ { \ - Screen [N * 2] = Screen [N * 2 + 1] = gfx->ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = gfx->Z2; \ + Screen [N * 2] = Screen [N * 2 + 1] = GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ } FN(0) @@ -489,19 +799,19 @@ INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels, struct SGFX #undef FN } -INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [(gfx->RealPitch >> 1) + N * 2] = \ - Screen [(gfx->RealPitch >> 1) + N * 2 + 1] = gfx->ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [(gfx->RealPitch >> 1) + N * 2] = \ - Depth [(gfx->RealPitch >> 1) + N * 2 + 1] = gfx->Z2; \ + Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.RealPitch >> 1) + N * 2] = \ + Screen [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.RealPitch >> 1) + N * 2] = \ + Depth [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.Z2; \ } FN(0) @@ -511,19 +821,19 @@ INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [(gfx->RealPitch >> 1) + N * 2] = \ - Screen [(gfx->RealPitch >> 1) + N * 2 + 1] = gfx->ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [(gfx->RealPitch >> 1) + N * 2] = \ - Depth [(gfx->RealPitch >> 1) + N * 2 + 1] = gfx->Z2; \ + Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.RealPitch >> 1) + N * 2] = \ + Screen [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.RealPitch >> 1) + N * 2] = \ + Depth [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.Z2; \ } FN(0) @@ -534,7 +844,7 @@ INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels, struct SG } void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -544,7 +854,7 @@ void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -554,7 +864,7 @@ void DrawClippedTile16 (uint32 Tile, uint32 Offset, } void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -564,7 +874,7 @@ void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -574,7 +884,7 @@ void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, } void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -584,7 +894,7 @@ void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -595,39 +905,39 @@ void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, void DrawLargePixel16 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE - register uint16 *sp = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->DB + Offset; + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; uint16 pixel; - RENDER_TILE_LARGE (gfx->ScreenColors [pixel], PLOT_PIXEL) + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], PLOT_PIXEL) } -INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ if (SubDepth [N]) \ { \ if (SubDepth [N] != 1) \ - Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \ - Screen [gfx->Delta + N]); \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ else \ - Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ } \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -638,28 +948,28 @@ INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels, struct SGFX * gfx #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ if (SubDepth [N]) \ { \ if (SubDepth [N] != 1) \ - Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \ - Screen [gfx->Delta + N]); \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ else \ - Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ } \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -670,28 +980,28 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels, struct SG #undef FN } -INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ if (SubDepth [N]) \ { \ if (SubDepth [N] != 1) \ - Screen [N] = (uint16) (COLOR_ADD1_2 (gfx->ScreenColors [Pixel], \ - Screen [gfx->Delta + N])); \ + Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N])); \ else \ - Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ } \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -702,28 +1012,28 @@ INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ if (SubDepth [N]) \ { \ if (SubDepth [N] != 1) \ - Screen [N] = (uint16) (COLOR_ADD1_2 (gfx->ScreenColors [Pixel], \ - Screen [gfx->Delta + N])); \ + Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N])); \ else \ - Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ } \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -734,28 +1044,28 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels, struct #undef FN } -INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ if (SubDepth [N]) \ { \ if (SubDepth [N] != 1) \ - Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \ - Screen [gfx->Delta + N]); \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ else \ - Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ } \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -766,28 +1076,28 @@ INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels, struct SGFX * gfx #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ if (SubDepth [N]) \ { \ if (SubDepth [N] != 1) \ - Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \ - Screen [gfx->Delta + N]); \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ else \ - Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ } \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -798,28 +1108,28 @@ INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels, struct SG #undef FN } -INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ if (SubDepth [N]) \ { \ if (SubDepth [N] != 1) \ - Screen [N] = (uint16) COLOR_SUB1_2 (gfx->ScreenColors [Pixel], \ - Screen [gfx->Delta + N]); \ + Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ else \ - Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ } \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -830,28 +1140,28 @@ INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ if (SubDepth [N]) \ { \ if (SubDepth [N] != 1) \ - Screen [N] = (uint16) COLOR_SUB1_2 (gfx->ScreenColors [Pixel], \ - Screen [gfx->Delta + N]); \ + Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ else \ - Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ } \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -864,7 +1174,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels, struct void DrawTile16Add (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -874,7 +1184,7 @@ void DrawTile16Add (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16Add (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -884,7 +1194,7 @@ void DrawClippedTile16Add (uint32 Tile, uint32 Offset, } void DrawTile16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -894,7 +1204,7 @@ void DrawTile16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -904,7 +1214,7 @@ void DrawClippedTile16Add1_2 (uint32 Tile, uint32 Offset, } void DrawTile16Sub (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -914,7 +1224,7 @@ void DrawTile16Sub (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16Sub (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -924,7 +1234,7 @@ void DrawClippedTile16Sub (uint32 Tile, uint32 Offset, } void DrawTile16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -934,7 +1244,7 @@ void DrawTile16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -943,22 +1253,22 @@ void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) } -INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ if (SubDepth [N] == 1) \ - Screen [N] = (uint16) (COLOR_ADD1_2 (gfx->ScreenColors [Pixel], \ - gfx->FixedColour)); \ + Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ + GFX.FixedColour)); \ else \ - Screen [N] = gfx->ScreenColors [Pixel];\ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel];\ + Depth [N] = GFX.Z2; \ } FN(0) @@ -969,22 +1279,22 @@ INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ if (SubDepth [N] == 1) \ - Screen [N] = (uint16) (COLOR_ADD1_2 (gfx->ScreenColors [Pixel], \ - gfx->FixedColour)); \ + Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ + GFX.FixedColour)); \ else \ - Screen [N] = gfx->ScreenColors [Pixel];\ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel];\ + Depth [N] = GFX.Z2; \ } FN(0) @@ -995,22 +1305,22 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels, struc #undef FN } -INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ { \ if (SubDepth [N] == 1) \ - Screen [N] = (uint16) COLOR_SUB1_2 (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -1021,22 +1331,22 @@ INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx) +INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; - uint16 *Screen = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; - uint8 *SubDepth = gfx->SubZBuffer + Offset; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; #define FN(N) \ - if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ { \ if (SubDepth [N] == 1) \ - Screen [N] = (uint16) COLOR_SUB1_2 (gfx->ScreenColors [Pixel], \ - gfx->FixedColour); \ + Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ else \ - Screen [N] = gfx->ScreenColors [Pixel]; \ - Depth [N] = gfx->Z2; \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ } FN(0) @@ -1048,7 +1358,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels, struc } void DrawTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -1058,7 +1368,7 @@ void DrawTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -1069,7 +1379,7 @@ void DrawClippedTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, } void DrawTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -1079,7 +1389,7 @@ void DrawTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -1091,82 +1401,82 @@ void DrawClippedTile16FixedSub1_2 (uint32 Tile, uint32 Offset, void DrawLargePixel16Add (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE - register uint16 *sp = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; register uint16 pixel; #define LARGE_ADD_PIXEL(s, p) \ -(Depth [z + gfx->DepthDelta] ? (Depth [z + gfx->DepthDelta] != 1 ? \ - COLOR_ADD (p, *(s + gfx->Delta)) : \ - COLOR_ADD (p, gfx->FixedColour)) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_ADD (p, *(s + GFX.Delta)) : \ + COLOR_ADD (p, GFX.FixedColour)) \ : p) - RENDER_TILE_LARGE (gfx->ScreenColors [pixel], LARGE_ADD_PIXEL) + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_ADD_PIXEL) } void DrawLargePixel16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE - register uint16 *sp = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; register uint16 pixel; #define LARGE_ADD_PIXEL1_2(s, p) \ -((uint16) (Depth [z + gfx->DepthDelta] ? (Depth [z + gfx->DepthDelta] != 1 ? \ - COLOR_ADD1_2 (p, *(s + gfx->Delta)) : \ - COLOR_ADD (p, gfx->FixedColour)) \ +((uint16) (Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_ADD1_2 (p, *(s + GFX.Delta)) : \ + COLOR_ADD (p, GFX.FixedColour)) \ : p)) - RENDER_TILE_LARGE (gfx->ScreenColors [pixel], LARGE_ADD_PIXEL1_2) + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_ADD_PIXEL1_2) } void DrawLargePixel16Sub (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE - register uint16 *sp = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; register uint16 pixel; #define LARGE_SUB_PIXEL(s, p) \ -(Depth [z + gfx->DepthDelta] ? (Depth [z + gfx->DepthDelta] != 1 ? \ - COLOR_SUB (p, *(s + gfx->Delta)) : \ - COLOR_SUB (p, gfx->FixedColour)) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_SUB (p, *(s + GFX.Delta)) : \ + COLOR_SUB (p, GFX.FixedColour)) \ : p) - RENDER_TILE_LARGE (gfx->ScreenColors [pixel], LARGE_SUB_PIXEL) + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_SUB_PIXEL) } void DrawLargePixel16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE - register uint16 *sp = (uint16 *) gfx->S + Offset; - uint8 *Depth = gfx->ZBuffer + Offset; + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; uint16 pixel; #define LARGE_SUB_PIXEL1_2(s, p) \ -(Depth [z + gfx->DepthDelta] ? (Depth [z + gfx->DepthDelta] != 1 ? \ - COLOR_SUB1_2 (p, *(s + gfx->Delta)) : \ - COLOR_SUB (p, gfx->FixedColour)) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_SUB1_2 (p, *(s + GFX.Delta)) : \ + COLOR_SUB (p, GFX.FixedColour)) \ : p) - RENDER_TILE_LARGE (gfx->ScreenColors [pixel], LARGE_SUB_PIXEL1_2) + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_SUB_PIXEL1_2) } void DrawHiResTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount, struct SGFX * gfx) + uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; @@ -1176,7 +1486,7 @@ void DrawHiResTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawHiResClippedTile16 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount, struct SGFX * gfx) + uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE register uint8 *bp; diff --git a/tile.h b/tile.h index aff3a9d..6ba51f1 100644 --- a/tile.h +++ b/tile.h @@ -41,316 +41,107 @@ #ifndef _TILE_H_ #define _TILE_H_ -#define TILE_PREAMBLE \ - uint8 *pCache; \ -\ - uint32 TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift); \ - if ((Tile & 0x1ff) >= 256) \ - TileAddr += BG.NameSelect; \ -\ - TileAddr &= 0xffff; \ -\ - uint32 TileNumber; \ - pCache = &BG.Buffer[(TileNumber = (TileAddr >> BG.TileShift)) << 6]; \ -\ - if (!BG.Buffered [TileNumber]) \ - BG.Buffered[TileNumber] = ConvertTile (pCache, TileAddr); \ -\ - if (BG.Buffered [TileNumber] == BLANK_TILE) \ - return; \ -\ - register uint32 l; \ - if (BG.DirectColourMode) \ - { \ - if (IPPU.DirectColourMapsNeedRebuild) \ - S9xBuildDirectColourMaps (); \ - gfx->ScreenColors = DirectColourMaps [(Tile >> 10) & BG.PaletteMask]; \ - } \ - else \ - gfx->ScreenColors = &IPPU.ScreenColors [(((Tile >> 10) & BG.PaletteMask) << BG.PaletteShift) + BG.StartPalette]; +void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); +void DrawClippedTile (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); +void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); +void DrawClippedTilex2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); +void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); +void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); +void DrawLargePixel (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount); -#define RENDER_TILE(NORMAL, FLIPPED, N) \ - if (!(Tile & (V_FLIP | H_FLIP))) \ - { \ - bp = pCache + StartLine; \ - for (l = LineCount; l != 0; l--, bp += 8, Offset += gfx->PPL) \ - { \ - if (*(uint32 *) bp) \ - NORMAL (Offset, bp, gfx); \ - if (*(uint32 *) (bp + 4)) \ - NORMAL (Offset + N, bp + 4, gfx); \ - } \ - } \ - else \ - if (!(Tile & V_FLIP)) \ - { \ - bp = pCache + StartLine; \ - for (l = LineCount; l != 0; l--, bp += 8, Offset += gfx->PPL) \ - { \ - if (*(uint32 *) (bp + 4)) \ - FLIPPED (Offset, bp + 4, gfx); \ - if (*(uint32 *) bp) \ - FLIPPED (Offset + N, bp, gfx); \ - } \ - } \ - else \ - if (Tile & H_FLIP) \ - { \ - bp = pCache + 56 - StartLine; \ - for (l = LineCount; l != 0; l--, bp -= 8, Offset += gfx->PPL) \ - { \ - if (*(uint32 *) (bp + 4)) \ - FLIPPED (Offset, bp + 4, gfx); \ - if (*(uint32 *) bp) \ - FLIPPED (Offset + N, bp, gfx); \ - } \ - } \ - else \ - { \ - bp = pCache + 56 - StartLine; \ - for (l = LineCount; l != 0; l--, bp -= 8, Offset += gfx->PPL) \ - { \ - if (*(uint32 *) bp) \ - NORMAL (Offset, bp, gfx); \ - if (*(uint32 *) (bp + 4)) \ - NORMAL (Offset + N, bp + 4, gfx); \ - } \ - } +void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); +void DrawClippedTile16 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); +void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); +void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); +void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); +void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); +void DrawLargePixel16 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount); -#define TILE_CLIP_PREAMBLE \ - uint32 dd; \ - uint32 d1; \ - uint32 d2; \ -\ - if (StartPixel < 4) \ - { \ - d1 = HeadMask [StartPixel]; \ - if (StartPixel + Width < 4) \ - d1 &= TailMask [StartPixel + Width]; \ - } \ - else \ - d1 = 0; \ -\ - if (StartPixel + Width > 4) \ - { \ - if (StartPixel > 4) \ - d2 = HeadMask [StartPixel - 4]; \ - else \ - d2 = 0xffffffff; \ -\ - d2 &= TailMask [(StartPixel + Width - 4)]; \ - } \ - else \ - d2 = 0; +void DrawTile16Add (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); +void DrawClippedTile16Add (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); -#define RENDER_CLIPPED_TILE(NORMAL, FLIPPED, N) \ - if (!(Tile & (V_FLIP | H_FLIP))) \ - { \ - bp = pCache + StartLine; \ - for (l = LineCount; l != 0; l--, bp += 8, Offset += gfx->PPL) \ - { \ - if ((dd = (*(uint32 *) bp) & d1)) \ - NORMAL (Offset, (uint8 *) &dd, gfx); \ - if ((dd = (*(uint32 *) (bp + 4)) & d2)) \ - NORMAL (Offset + N, (uint8 *) &dd, gfx); \ - } \ - } \ - else \ - if (!(Tile & V_FLIP)) \ - { \ - bp = pCache + StartLine; \ - SWAP_DWORD (d1); \ - SWAP_DWORD (d2); \ - for (l = LineCount; l != 0; l--, bp += 8, Offset += gfx->PPL) \ - { \ - if ((dd = *(uint32 *) (bp + 4) & d1)) \ - FLIPPED (Offset, (uint8 *) &dd, gfx); \ - if ((dd = *(uint32 *) bp & d2)) \ - FLIPPED (Offset + N, (uint8 *) &dd, gfx); \ - } \ - } \ - else \ - if (Tile & H_FLIP) \ - { \ - bp = pCache + 56 - StartLine; \ - SWAP_DWORD (d1); \ - SWAP_DWORD (d2); \ - for (l = LineCount; l != 0; l--, bp -= 8, Offset += gfx->PPL) \ - { \ - if ((dd = *(uint32 *) (bp + 4) & d1)) \ - FLIPPED (Offset, (uint8 *) &dd, gfx); \ - if ((dd = *(uint32 *) bp & d2)) \ - FLIPPED (Offset + N, (uint8 *) &dd, gfx); \ - } \ - } \ - else \ - { \ - bp = pCache + 56 - StartLine; \ - for (l = LineCount; l != 0; l--, bp -= 8, Offset += gfx->PPL) \ - { \ - if ((dd = (*(uint32 *) bp) & d1)) \ - NORMAL (Offset, (uint8 *) &dd, gfx); \ - if ((dd = (*(uint32 *) (bp + 4)) & d2)) \ - NORMAL (Offset + N, (uint8 *) &dd, gfx); \ - } \ - } +void DrawTile16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); -#define RENDER_TILE_LARGE(PIXEL, FUNCTION) \ - if (!(Tile & (V_FLIP | H_FLIP))) \ - { \ - if ((pixel = *(pCache + StartLine + StartPixel))) \ - { \ - pixel = PIXEL; \ - for (l = LineCount; l != 0; l--, sp += gfx->PPL, Depth += gfx->PPL) \ - { \ - for (int z = Pixels - 1; z >= 0; z--) \ - if (gfx->Z1 > Depth [z]) \ - { \ - sp [z] = FUNCTION(sp + z, pixel); \ - Depth [z] = gfx->Z2; \ - }\ - } \ - } \ - } \ - else \ - if (!(Tile & V_FLIP)) \ - { \ - StartPixel = 7 - StartPixel; \ - if ((pixel = *(pCache + StartLine + StartPixel))) \ - { \ - pixel = PIXEL; \ - for (l = LineCount; l != 0; l--, sp += gfx->PPL, Depth += gfx->PPL) \ - { \ - for (int z = Pixels - 1; z >= 0; z--) \ - if (gfx->Z1 > Depth [z]) \ - { \ - sp [z] = FUNCTION(sp + z, pixel); \ - Depth [z] = gfx->Z2; \ - }\ - } \ - } \ - } \ - else \ - if (Tile & H_FLIP) \ - { \ - StartPixel = 7 - StartPixel; \ - if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \ - { \ - pixel = PIXEL; \ - for (l = LineCount; l != 0; l--, sp += gfx->PPL, Depth += gfx->PPL) \ - { \ - for (int z = Pixels - 1; z >= 0; z--) \ - if (gfx->Z1 > Depth [z]) \ - { \ - sp [z] = FUNCTION(sp + z, pixel); \ - Depth [z] = gfx->Z2; \ - }\ - } \ - } \ - } \ - else \ - { \ - if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \ - { \ - pixel = PIXEL; \ - for (l = LineCount; l != 0; l--, sp += gfx->PPL, Depth += gfx->PPL) \ - { \ - for (int z = Pixels - 1; z >= 0; z--) \ - if (gfx->Z1 > Depth [z]) \ - { \ - sp [z] = FUNCTION(sp + z, pixel); \ - Depth [z] = gfx->Z2; \ - }\ - } \ - } \ - } - -#define RENDER_TILEHI(NORMAL, FLIPPED, N) \ - if (!(Tile & (V_FLIP | H_FLIP))) \ - { \ - bp = pCache + StartLine; \ - for (l = LineCount; l != 0; l--, bp += 8, Offset += gfx->PPL) \ - { \ - /*if (*(uint32 *) bp)*/if (((uint32)bp[0])|((uint32)bp[2])|((uint32)bp[4])|((uint32)bp[6])) \ - NORMAL (Offset, bp); \ - } \ - } \ - else \ - if (!(Tile & V_FLIP)) \ - { \ - bp = pCache + StartLine; \ - for (l = LineCount; l != 0; l--, bp += 8, Offset += gfx->PPL) \ - { \ - /*if (*(uint32 *) (bp + 4))*/if (((uint32)bp[0])|((uint32)bp[2])|((uint32)bp[4])|((uint32)bp[6])) \ - FLIPPED (Offset, bp); \ - } \ - } \ - else \ - if (Tile & H_FLIP) \ - { \ - bp = pCache + 56 - StartLine; \ - for (l = LineCount; l != 0; l--, bp -= 8, Offset += gfx->PPL) \ - { \ - /*if (*(uint32 *) (bp + 4))*/if (((uint32)bp[0])|((uint32)bp[2])|((uint32)bp[4])|((uint32)bp[6])) \ - FLIPPED (Offset, bp); \ - } \ - } \ - else \ - { \ - bp = pCache + 56 - StartLine; \ - for (l = LineCount; l != 0; l--, bp -= 8, Offset += gfx->PPL) \ - { \ - /*if (*(uint32 *) bp)*/if (((uint32)bp[0])|((uint32)bp[2])|((uint32)bp[4])|((uint32)bp[6])) \ - NORMAL (Offset, bp); \ - } \ - } - - - -#define RENDER_CLIPPED_TILEHI(NORMAL, FLIPPED, N) \ - d1=(d1&0xFF)|((d1&0xFF0000)>>8)|((d2&0xFF)<<16)|((d2&0xFF0000)<<8);\ - if (!(Tile & (V_FLIP | H_FLIP))) \ - { \ - bp = pCache + StartLine; \ - for (l = LineCount; l != 0; l--, bp += 8, Offset += gfx->PPL) \ - { \ - /*if ((dd = (*(uint32 *) bp) & d1))*/if ((dd = (((((uint32)bp[6])<<24)|(((uint32)bp[4])<<16)|(((uint32)bp[2])<<8)|((uint32)bp[0]))&d1))) \ - NORMAL (Offset, (uint8 *) &dd); \ - } \ - } \ - else \ - if (!(Tile & V_FLIP)) \ - { \ - bp = pCache + StartLine; \ - SWAP_DWORD (d1); \ - /*SWAP_DWORD (d2);*/ \ - for (l = LineCount; l != 0; l--, bp += 8, Offset += gfx->PPL) \ - { \ - /*if ((dd = *(uint32 *) (bp + 4) & d1))*/if ((dd = (((((uint32)bp[6])<<24)|(((uint32)bp[4])<<16)|(((uint32)bp[2])<<8)|((uint32)bp[0]))&d1))) \ - FLIPPED (Offset, (uint8 *) &dd); \ - } \ - } \ - else \ - if (Tile & H_FLIP) \ - { \ - bp = pCache + 56 - StartLine; \ - SWAP_DWORD (d1); \ - /*SWAP_DWORD (d2);*/ \ - for (l = LineCount; l != 0; l--, bp -= 8, Offset += gfx->PPL) \ - { \ - /*if ((dd = *(uint32 *) (bp + 4) & d1))*/if ((dd = (((((uint32)bp[6])<<24)|(((uint32)bp[4])<<16)|(((uint32)bp[2])<<8)|((uint32)bp[0]))&d1))) \ - FLIPPED (Offset, (uint8 *) &dd); \ - } \ - } \ - else \ - { \ - bp = pCache + 56 - StartLine; \ - for (l = LineCount; l != 0; l--, bp -= 8, Offset += gfx->PPL) \ - { \ - /*if ((dd = (*(uint32 *) bp) & d1))*/ if ((dd = (((((uint32)bp[6])<<24)|(((uint32)bp[4])<<16)|(((uint32)bp[2])<<8)|((uint32)bp[0]))&d1))) \ - NORMAL (Offset, (uint8 *) &dd); \ - } \ - } +void DrawClippedTile16Add1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); + +void DrawTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); + +void DrawClippedTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); + +void DrawTile16Sub (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); + +void DrawClippedTile16Sub (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); + +void DrawTile16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); + +void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); + +void DrawTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount); + +void DrawClippedTile16FixedSub1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); + +void DrawLargePixel16Add (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount); + +void DrawLargePixel16Add1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount); + +void DrawLargePixel16Sub (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount); + +void DrawLargePixel16Sub1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount); + +void DrawHiResClippedTile16 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount); + +void DrawHiResTile16 (uint32 Tile, uint32 Offset, + uint32 StartLine, uint32 LineCount); #endif -- 1.7.9.5