diff options
author | neonloop | 2021-03-11 16:29:10 +0000 |
---|---|---|
committer | neonloop | 2021-03-11 16:29:10 +0000 |
commit | c057cb5ed6ffed8a9b88158a9e0e77608b46813f (patch) | |
tree | a6548a3a63ffb1bb08d841d3e31fdc10a0d1c042 | |
parent | cf10b4323da80ea564b6b5a07b48faf375471af9 (diff) | |
download | snesemu-c057cb5ed6ffed8a9b88158a9e0e77608b46813f.tar.gz snesemu-c057cb5ed6ffed8a9b88158a9e0e77608b46813f.tar.bz2 snesemu-c057cb5ed6ffed8a9b88158a9e0e77608b46813f.zip |
Adds NO_HIRES to scale hires mode to low-res screens
-rw-r--r-- | source/gfx.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/source/gfx.c b/source/gfx.c index 3508011..0cf0ac8 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -220,8 +220,13 @@ bool S9xInitGFX(void) DrawTilePtr = DrawTile16; DrawClippedTilePtr = DrawClippedTile16; DrawLargePixelPtr = DrawLargePixel16; +#ifdef NO_HIRES + DrawHiResTilePtr = DrawTile16HalfWidth; + DrawHiResClippedTilePtr = DrawClippedTile16HalfWidth; +#else DrawHiResTilePtr = DrawTile16; DrawHiResClippedTilePtr = DrawClippedTile16; +#endif GFX.PPL = GFX.Pitch >> 1; GFX.PPLx2 = GFX.Pitch; S9xFixColourBrightness(); @@ -292,6 +297,16 @@ void S9xStartScreenRefresh(void) if (PPU.BGMode == 5 || PPU.BGMode == 6) IPPU.Interlace = (Memory.FillRAM[0x2133] & 1); +#ifdef NO_HIRES + if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace) + { + IPPU.RenderedScreenWidth = 256; + IPPU.DoubleWidthPixels = false; + // Secret of Mana displays menus with mode 5. + // Make them readable. + IPPU.HalfWidthPixels = true; + } +#else if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace) { IPPU.RenderedScreenWidth = 512; @@ -315,6 +330,7 @@ void S9xStartScreenRefresh(void) GFX.PPLx2 = GFX.PPL << 1; } } +#endif else { IPPU.RenderedScreenWidth = 256; @@ -755,6 +771,18 @@ static void DrawOBJS(bool OnMain, uint8_t D) } } +#ifdef NO_HIRES + 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; + } + DrawTilePtr = DrawTile16; + DrawClippedTilePtr = DrawClippedTile16; +#else if (PPU.BGMode == 5 || PPU.BGMode == 6) { /* Bah, OnMain is never used except to determine if calling @@ -779,6 +807,7 @@ static void DrawOBJS(bool OnMain, uint8_t D) DrawTilePtr = DrawTile16; DrawClippedTilePtr = DrawClippedTile16; } +#endif GFX.Z1 = D + 2; @@ -1651,6 +1680,9 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2) case 5: case 6: /* XXX: is also offset per tile. */ +#ifdef NO_HIRES + SelectTileRenderer(true /* normal */); +#endif DrawBackgroundMode5(bg, Z1, Z2); return; } @@ -2668,6 +2700,26 @@ void S9xUpdateScreen(void) starty = GFX.StartY; endy = GFX.EndY; +#ifdef NO_HIRES + if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace) + { + if (!IPPU.HalfWidthPixels) + { + // The game has switched from lo-res to hi-res mode part way down + // the screen. Hi-res pixels must now be drawn at half width. + IPPU.HalfWidthPixels = true; + } + } + else + { + if (IPPU.HalfWidthPixels) + { + // The game has switched from hi-res to lo-res mode part way down + // the screen. Lo-res pixels must now be drawn at FULL width. + IPPU.HalfWidthPixels = false; + } + } +#else if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace || IPPU.DoubleHeightPixels) { if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace) @@ -2725,6 +2777,7 @@ void S9xUpdateScreen(void) } } } +#endif black = BLACK | (BLACK << 16); @@ -3132,6 +3185,7 @@ void S9xUpdateScreen(void) } } +#ifndef NO_HIRES if (PPU.BGMode != 5 && PPU.BGMode != 6 && IPPU.DoubleWidthPixels) { /* Mixture of background modes used on screen - scale width @@ -3150,5 +3204,6 @@ void S9xUpdateScreen(void) /* Double the height of the pixels just drawn */ FIX_INTERLACE(GFX.Screen, false, GFX.ZBuffer); +#endif IPPU.PreviousLine = IPPU.CurrentLine; } |