aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/gfx.cpp83
-rw-r--r--source/tile.cpp26
-rw-r--r--source/tile.h43
3 files changed, 94 insertions, 58 deletions
diff --git a/source/gfx.cpp b/source/gfx.cpp
index 47fd826..f6a6217 100644
--- a/source/gfx.cpp
+++ b/source/gfx.cpp
@@ -191,6 +191,9 @@ void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset,
void DrawLargePixel (uint32 Tile, uint32 Offset,
uint32 StartPixel, uint32 Pixels,
uint32 StartLine, uint32 LineCount);
+void DrawLargePixelHalfWidth (uint32 Tile, uint32 Offset,
+ uint32 StartPixel, uint32 Pixels,
+ uint32 StartLine, uint32 LineCount);
#endif
void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine,
@@ -216,6 +219,9 @@ void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset,
void DrawLargePixel16 (uint32 Tile, uint32 Offset,
uint32 StartPixel, uint32 Pixels,
uint32 StartLine, uint32 LineCount);
+void DrawLargePixel16HalfWidth (uint32 Tile, uint32 Offset,
+ uint32 StartPixel, uint32 Pixels,
+ uint32 StartLine, uint32 LineCount);
void DrawTile16Add (uint32 Tile, uint32 Offset, uint32 StartLine,
uint32 LineCount);
@@ -892,7 +898,7 @@ inline void SelectTileRenderer (bool8 normal)
{
DrawTilePtr = DrawTile16HalfWidth;
DrawClippedTilePtr = DrawClippedTile16HalfWidth;
- DrawLargePixelPtr = DrawLargePixel16;
+ DrawLargePixelPtr = DrawLargePixel16HalfWidth;
}
else
{
@@ -1302,71 +1308,31 @@ if(Settings.BGLayering) {
#endif
}
}
-#if 0
- else if (!Settings.SupportHiRes)
+ else // if (!Settings.SupportHiRes)
{
- if (PPU.BGMode == 5)
+ if (PPU.BGMode == 5 || PPU.BGMode == 6)
{
// Bah, OnMain is never used except to determine if calling
// SelectTileRenderer is necessary. So let's hack it to false here
// to stop SelectTileRenderer from being called when it causes
// problems.
OnMain = FALSE;
- GFX.PixSize = 1; // half width - maybe? [Neb]
- if (IPPU.HalfWidthPixels)
- {
-#ifndef FOREVER_16_BIT
- if (Settings.SixteenBit)
- {
-#endif
- DrawTilePtr = DrawTile16HalfWidth;
- DrawClippedTilePtr = DrawClippedTile16HalfWidth;
-#ifndef FOREVER_16_BIT
- }
- else
- {
- DrawTilePtr = DrawTileHalfWidth;
- DrawClippedTilePtr = DrawClippedTileHalfWidth;
- }
-#endif
- }
- else
- {
+ }
#ifndef FOREVER_16_BIT
- if (Settings.SixteenBit)
- {
+ if (Settings.SixteenBit)
+ {
#endif
- DrawTilePtr = DrawTile16;
- DrawClippedTilePtr = DrawClippedTile16;
+ DrawTilePtr = DrawTile16;
+ DrawClippedTilePtr = DrawClippedTile16;
#ifndef FOREVER_16_BIT
- }
- else
- {
- DrawTilePtr = DrawTile;
- DrawClippedTilePtr = DrawClippedTile;
- }
-#endif
- }
}
else
{
-#ifndef FOREVER_16_BIT
- if (Settings.SixteenBit)
- {
-#endif
- DrawTilePtr = DrawTile16;
- DrawClippedTilePtr = DrawClippedTile16;
-#ifndef FOREVER_16_BIT
- }
- else
- {
- DrawTilePtr = DrawTile;
- DrawClippedTilePtr = DrawClippedTile;
- }
-#endif
+ DrawTilePtr = DrawTile;
+ DrawClippedTilePtr = DrawClippedTile;
}
+#endif
}
-#endif // 0
GFX.Z1 = D + 2;
for(uint32 Y=GFX.StartY, Offset=Y*GFX.PPL; Y<=GFX.EndY; Y++, Offset+=GFX.PPL){
@@ -1580,7 +1546,7 @@ static void DrawBackgroundMosaic (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2)
}
uint32 s = Y * GFX.PPL + Left * GFX.PixSize;
for (uint32 x = Left; x < Right; x += PixWidth,
- s += PixWidth * GFX.PixSize,
+ s += (IPPU.HalfWidthPixels ? PixWidth >> 1 : PixWidth) * GFX.PixSize,
HPos += PixWidth, PixWidth = (PPU.Mosaic << m5))
{
uint32 Quot = (HPos & OffsetMask) >> 3;
@@ -1980,7 +1946,7 @@ static void DrawBackgroundOffset (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2)
if (Count > MaxCount)
Count = MaxCount;
- s -= Offset * GFX.PixSize;
+ s -= (IPPU.HalfWidthPixels ? Offset >> 1 : Offset) * GFX.PixSize;
Tile = READ_2BYTES(t);
GFX.Z1 = GFX.Z2 = depths [(Tile & 0x2000) >> 13];
@@ -2020,7 +1986,7 @@ static void DrawBackgroundOffset (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2)
Left += Count;
TotalCount += Count;
- s += (Offset + Count) * GFX.PixSize;
+ s += (IPPU.HalfWidthPixels ? (Offset + Count) >> 1 : (Offset + Count)) * GFX.PixSize;
MaxCount = 8;
}
}
@@ -2156,7 +2122,7 @@ static void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8
continue;
}
- uint32 s = Left * GFX.PixSize + Y * GFX.PPL;
+ uint32 s = (IPPU.HalfWidthPixels ? Left >> 1 : Left) * GFX.PixSize + Y * GFX.PPL;
uint32 HPos = (HOffset + Left * GFX.PixSize) & 0x3ff;
uint32 Quot = HPos >> 3;
@@ -2176,7 +2142,7 @@ static void DrawBackgroundMode5 (uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8
Count = 8 - Offset;
if (Count > Width)
Count = Width;
- s -= Offset >> 1;
+ s -= (IPPU.HalfWidthPixels ? Offset >> 1 : Offset);
Tile = READ_2BYTES (t);
GFX.Z1 = GFX.Z2 = depths [(Tile & 0x2000) >> 13];
@@ -2605,14 +2571,14 @@ static void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2)
t = b1;
}
Quot++;
- s += 8 * GFX.PixSize;
+ s += (IPPU.HalfWidthPixels ? 4 : 8) * GFX.PixSize;
}
// Middle, unclipped tiles
Count = Width - Count;
int Middle = Count >> 3;
Count &= 7;
- for (int C = Middle; C > 0; s += 8 * GFX.PixSize, Quot++, C--)
+ for (int C = Middle; C > 0; s += (IPPU.HalfWidthPixels ? 4 : 8) * GFX.PixSize, Quot++, C--)
{
Tile = READ_2BYTES(t);
GFX.Z1 = GFX.Z2 = depths [(Tile & 0x2000) >> 13];
@@ -3748,6 +3714,7 @@ void S9xUpdateScreen ()
}
#endif
IPPU.DoubleWidthPixels = TRUE;
+ IPPU.HalfWidthPixels = FALSE;
}
// BJ: And we have to change the height if Interlace gets set,
// too.
diff --git a/source/tile.cpp b/source/tile.cpp
index 4fb9de0..e18182d 100644
--- a/source/tile.cpp
+++ b/source/tile.cpp
@@ -441,6 +441,19 @@ void DrawLargePixel (uint32 Tile, uint32 Offset,
RENDER_TILE_LARGE (((uint8) ScreenColors [pixel]), PLOT_PIXEL)
}
+
+void DrawLargePixelHalfWidth (uint32 Tile, uint32 Offset,
+ uint32 StartPixel, uint32 Pixels,
+ uint32 StartLine, uint32 LineCount)
+{
+ TILE_PREAMBLE
+
+ register uint8 *sp = GFX.S + Offset;
+ uint8 *Depth = GFX.DB + Offset;
+ uint8 pixel;
+
+ RENDER_TILE_LARGE_HALFWIDTH (((uint8) ScreenColors [pixel]), PLOT_PIXEL)
+}
#endif
static void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels, uint16 *ScreenColors)
@@ -727,6 +740,19 @@ void DrawLargePixel16 (uint32 Tile, uint32 Offset,
RENDER_TILE_LARGE (ScreenColors [pixel], PLOT_PIXEL)
}
+void DrawLargePixel16HalfWidth (uint32 Tile, uint32 Offset,
+ uint32 StartPixel, uint32 Pixels,
+ uint32 StartLine, uint32 LineCount)
+{
+ TILE_PREAMBLE
+
+ register uint16 *sp = (uint16 *) GFX.S + Offset;
+ uint8 *Depth = GFX.DB + Offset;
+ uint16 pixel;
+
+ RENDER_TILE_LARGE_HALFWIDTH (ScreenColors [pixel], PLOT_PIXEL)
+}
+
static void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels, uint16 *ScreenColors)
{
uint8 Pixel;
diff --git a/source/tile.h b/source/tile.h
index c43e7af..73f2860 100644
--- a/source/tile.h
+++ b/source/tile.h
@@ -288,5 +288,48 @@
default: \
break; \
}
+
+#define RENDER_TILE_LARGE_HALFWIDTH(PIXEL, FUNCTION) \
+ switch (Tile & (V_FLIP | H_FLIP)) \
+ { \
+ case H_FLIP: \
+ StartPixel = 7 - StartPixel; \
+ /* fallthrough for no-flip case - above was a horizontal flip */ \
+ case 0: \
+ if ((pixel = *(pCache + StartLine + StartPixel))) \
+ { \
+ pixel = PIXEL; \
+ for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
+ { \
+ for (int z = Pixels - 2; z >= 0; z -= 2) \
+ if (GFX.Z1 > Depth [z]) \
+ { \
+ sp [z >> 1] = FUNCTION(sp + z, pixel); \
+ Depth [z >> 1] = GFX.Z2; \
+ }\
+ } \
+ } \
+ break; \
+ case H_FLIP | V_FLIP: \
+ StartPixel = 7 - StartPixel; \
+ /* fallthrough for V_FLIP-only case - above was a horizontal flip */ \
+ case V_FLIP: \
+ if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \
+ { \
+ pixel = PIXEL; \
+ for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
+ { \
+ for (int z = Pixels - 2; z >= 0; z -= 2) \
+ if (GFX.Z1 > Depth [z]) \
+ { \
+ sp [z >> 1] = FUNCTION(sp + z, pixel); \
+ Depth [z >> 1] = GFX.Z2; \
+ }\
+ } \
+ } \
+ break; \
+ default: \
+ break; \
+ }
#endif