Moved ScreenRefresh functions to cpuexec.cpp and turned them

static - moved DirectColourMaps variable to tile.cpp and
turned it static
This commit is contained in:
TwinAphex51224 2011-11-23 14:07:04 +01:00
parent 1f6742f2d5
commit cba59f9b40
6 changed files with 100 additions and 109 deletions

View File

@ -181,9 +181,12 @@
#include "dma.h"
#include "apu/apu.h"
#include "fxemu.h"
#include "controls.h"
#include "cheats.h"
#include "snapshot.h"
//static int counter;
extern struct SLineData LineData[240];
extern struct SLineMatrixData LineMatrixData[240];
void S9xMainLoop (void)
{
@ -331,6 +334,97 @@ static void S9xCheckMissingHTimerHalt (int32 hc_from, int32 range)
}
}
static void S9xEndScreenRefresh (void)
{
FLUSH_REDRAW();
S9xControlEOF();
if (!(GFX.DoInterlace && GFX.InterlaceFrame == 0))
{
//Chrono Trigger mid-frame overscan hack - field to battle transition
if (Settings.ChronoTriggerFrameHack & (IPPU.RenderedScreenHeight == 239))
IPPU.RenderedScreenHeight = 224;
S9xDeinitUpdate(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight);
}
S9xApplyCheats();
}
static void RenderLine (uint8 C)
{
LineData[C].BG[0].VOffset = PPU.BG[0].VOffset + 1;
LineData[C].BG[0].HOffset = PPU.BG[0].HOffset;
LineData[C].BG[1].VOffset = PPU.BG[1].VOffset + 1;
LineData[C].BG[1].HOffset = PPU.BG[1].HOffset;
if (PPU.BGMode == 7)
{
struct SLineMatrixData *p = &LineMatrixData[C];
p->MatrixA = PPU.MatrixA;
p->MatrixB = PPU.MatrixB;
p->MatrixC = PPU.MatrixC;
p->MatrixD = PPU.MatrixD;
p->CentreX = PPU.CentreX;
p->CentreY = PPU.CentreY;
p->M7HOFS = PPU.M7HOFS;
p->M7VOFS = PPU.M7VOFS;
}
else
{
LineData[C].BG[2].VOffset = PPU.BG[2].VOffset + 1;
LineData[C].BG[2].HOffset = PPU.BG[2].HOffset;
LineData[C].BG[3].VOffset = PPU.BG[3].VOffset + 1;
LineData[C].BG[3].HOffset = PPU.BG[3].HOffset;
}
IPPU.CurrentLine = C + 1;
}
static void S9xStartScreenRefresh (void)
{
GFX.InterlaceFrame = !GFX.InterlaceFrame;
if (!GFX.DoInterlace || !GFX.InterlaceFrame)
{
if (GFX.DoInterlace)
GFX.DoInterlace--;
IPPU.MaxBrightness = PPU.Brightness;
IPPU.Interlace = Memory.FillRAM[0x2133] & 1;
IPPU.InterlaceOBJ = Memory.FillRAM[0x2133] & 2;
IPPU.PseudoHires = Memory.FillRAM[0x2133] & 8;
GFX.RealPPL = GFX.Pitch >> 1;
IPPU.RenderedScreenWidth = SNES_WIDTH;
IPPU.RenderedScreenHeight = PPU.ScreenHeight;
IPPU.DoubleWidthPixels = FALSE;
IPPU.DoubleHeightPixels = FALSE;
if ((PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.PseudoHires))
{
IPPU.DoubleWidthPixels = TRUE;
IPPU.RenderedScreenWidth += SNES_WIDTH;
}
GFX.PPL = GFX.RealPPL;
if (IPPU.Interlace)
{
GFX.PPL += GFX.RealPPL;
IPPU.DoubleHeightPixels = TRUE;
IPPU.RenderedScreenHeight += PPU.ScreenHeight;
GFX.DoInterlace++;
}
}
PPU.MosaicStart = 0;
PPU.RecomputeClipWindows = TRUE;
IPPU.PreviousLine = IPPU.CurrentLine = 0;
ZeroMemory(GFX.ZBuffer, GFX.ScreenSize);
ZeroMemory(GFX.SubZBuffer, GFX.ScreenSize);
}
void S9xDoHEventProcessing (void)
{
switch (CPU.WhichEvent)

View File

@ -218,6 +218,8 @@ void S9xDoHEventProcessing (void);
void S9xClearIRQ (uint32);
void S9xSetIRQ (uint32);
void S9xDeinitUpdate (int, int);
#define S9xUnpackStatus() \
ICPU._Zero = (Registers.PL & Zero) == 0; \
ICPU._Negative = (Registers.PL & Negative); \

View File

@ -178,15 +178,11 @@
#include "snes9x.h"
#include "ppu.h"
#include "tile.h"
#include "controls.h"
#include "crosshairs.h"
#include "cheats.h"
//#include "font.h"
#include "display.h"
extern struct SCheatData Cheat;
extern struct SLineData LineData[240];
extern struct SLineMatrixData LineMatrixData[240];
#ifdef REPORT_MODES
static int counter = 0;
@ -289,67 +285,6 @@ void S9xGraphicsDeinit (void)
if (GFX.SubZBuffer) { free(GFX.SubZBuffer); GFX.SubZBuffer = NULL; }
}
void S9xStartScreenRefresh (void)
{
GFX.InterlaceFrame = !GFX.InterlaceFrame;
if (!GFX.DoInterlace || !GFX.InterlaceFrame)
{
if (GFX.DoInterlace)
GFX.DoInterlace--;
IPPU.MaxBrightness = PPU.Brightness;
IPPU.Interlace = Memory.FillRAM[0x2133] & 1;
IPPU.InterlaceOBJ = Memory.FillRAM[0x2133] & 2;
IPPU.PseudoHires = Memory.FillRAM[0x2133] & 8;
GFX.RealPPL = GFX.Pitch >> 1;
IPPU.RenderedScreenWidth = SNES_WIDTH;
IPPU.RenderedScreenHeight = PPU.ScreenHeight;
IPPU.DoubleWidthPixels = FALSE;
IPPU.DoubleHeightPixels = FALSE;
if ((PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.PseudoHires))
{
IPPU.DoubleWidthPixels = TRUE;
IPPU.RenderedScreenWidth += SNES_WIDTH;
}
GFX.PPL = GFX.RealPPL;
if (IPPU.Interlace)
{
GFX.PPL += GFX.RealPPL;
IPPU.DoubleHeightPixels = TRUE;
IPPU.RenderedScreenHeight += PPU.ScreenHeight;
GFX.DoInterlace++;
}
}
PPU.MosaicStart = 0;
PPU.RecomputeClipWindows = TRUE;
IPPU.PreviousLine = IPPU.CurrentLine = 0;
ZeroMemory(GFX.ZBuffer, GFX.ScreenSize);
ZeroMemory(GFX.SubZBuffer, GFX.ScreenSize);
}
void S9xEndScreenRefresh (void)
{
FLUSH_REDRAW();
S9xControlEOF();
if (!(GFX.DoInterlace && GFX.InterlaceFrame == 0))
{
//Chrono Trigger mid-frame overscan hack - field to battle transition
if (Settings.ChronoTriggerFrameHack & (IPPU.RenderedScreenHeight == 239))
IPPU.RenderedScreenHeight = 224;
S9xDeinitUpdate(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight);
}
S9xApplyCheats();
}
static void SetupOBJ (void)
{
int SmallWidth, SmallHeight, LargeWidth, LargeHeight;
@ -572,35 +507,6 @@ static void SetupOBJ (void)
IPPU.OBJChanged = FALSE;
}
void RenderLine (uint8 C)
{
LineData[C].BG[0].VOffset = PPU.BG[0].VOffset + 1;
LineData[C].BG[0].HOffset = PPU.BG[0].HOffset;
LineData[C].BG[1].VOffset = PPU.BG[1].VOffset + 1;
LineData[C].BG[1].HOffset = PPU.BG[1].HOffset;
if (PPU.BGMode == 7)
{
struct SLineMatrixData *p = &LineMatrixData[C];
p->MatrixA = PPU.MatrixA;
p->MatrixB = PPU.MatrixB;
p->MatrixC = PPU.MatrixC;
p->MatrixD = PPU.MatrixD;
p->CentreX = PPU.CentreX;
p->CentreY = PPU.CentreY;
p->M7HOFS = PPU.M7HOFS;
p->M7VOFS = PPU.M7VOFS;
}
else
{
LineData[C].BG[2].VOffset = PPU.BG[2].VOffset + 1;
LineData[C].BG[2].HOffset = PPU.BG[2].HOffset;
LineData[C].BG[3].VOffset = PPU.BG[3].VOffset + 1;
LineData[C].BG[3].HOffset = PPU.BG[3].HOffset;
}
IPPU.CurrentLine = C + 1;
}
static void DrawOBJS (int D)
{
@ -1139,7 +1045,6 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff)
int PixWidth = IPPU.DoubleWidthPixels ? 2 : 1;
bool8 HiresInterlace = IPPU.Interlace && IPPU.DoubleWidthPixels;
//void (*DrawTile) (uint32, uint32, uint32, uint32);
void (*DrawClippedTile) (uint32, uint32, uint32, uint32, uint32, uint32);
for (int clip = 0; clip < GFX.Clip[bg].Count; clip++)
@ -1147,15 +1052,9 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff)
GFX.ClipColors = !(GFX.Clip[bg].DrawMode[clip] & 1);
if (BG.EnableMath && (GFX.Clip[bg].DrawMode[clip] & 2))
{
//DrawTile = GFX.DrawTileMath;
DrawClippedTile = GFX.DrawClippedTileMath;
}
else
{
//DrawTile = GFX.DrawTileNomath;
DrawClippedTile = GFX.DrawClippedTileNomath;
}
for (uint32 Y = GFX.StartY; Y <= GFX.EndY; Y++)
{

View File

@ -282,7 +282,6 @@ struct SLineMatrixData
short M7VOFS;
};
extern uint16 DirectColourMaps[8][256];
extern uint8 mul_brightness[16][32];
extern struct SBG BG;
extern struct SGFX GFX;
@ -306,14 +305,10 @@ extern struct SGFX GFX;
GFX.ZERO[(((C1) | RGB_HI_BITS_MASKx2) - \
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
void S9xStartScreenRefresh (void);
void S9xEndScreenRefresh (void);
void S9xUpdateScreen (void);
void RenderLine (uint8);
// external port interface which must be implemented or initialised for each port
bool8 S9xGraphicsInit (void);
void S9xGraphicsDeinit (void);
void S9xDeinitUpdate (int, int);
#endif

View File

@ -223,7 +223,6 @@ CMemory Memory;
uint8 OpenBus = 0;
uint8 *HDMAMemPointers[8];
uint16 DirectColourMaps[8][256];
#if defined(ZSNES_FX) || defined(ZSNES_C4)
uint8 *ROM = NULL;

View File

@ -210,6 +210,9 @@ static inline uint16 COLOR_SUB (uint16 C1, uint16 C2)
return (v);
}
static uint16 DirectColourMaps[8][256];
static uint16 BlackColourMap[256] = {0};
static void S9xBuildDirectColourMaps (void)
{
IPPU.XB = mul_brightness[PPU.Brightness];
@ -221,7 +224,6 @@ static void S9xBuildDirectColourMaps (void)
IPPU.DirectColourMapsNeedRebuild = FALSE;
}
static uint16 BlackColourMap[256] = {0};
static uint32 pixbit[8][16];
static uint8 hrbit_odd[256];
static uint8 hrbit_even[256];