summaryrefslogtreecommitdiff
path: root/src/ppu_.cpp
diff options
context:
space:
mode:
authoraliaspider2015-11-05 20:32:38 +0100
committeraliaspider2015-11-05 20:32:38 +0100
commit3849de3fc52f228aa0246564032ee2df3154a9a6 (patch)
tree6a77dcc829d07c22217a84adda72827ca086ebbf /src/ppu_.cpp
parent03e67548bb08bb325f156f9c18fbdb1a58f63c59 (diff)
downloadsnes9x2002-3849de3fc52f228aa0246564032ee2df3154a9a6.tar.gz
snes9x2002-3849de3fc52f228aa0246564032ee2df3154a9a6.tar.bz2
snes9x2002-3849de3fc52f228aa0246564032ee2df3154a9a6.zip
clenups
Diffstat (limited to 'src/ppu_.cpp')
-rw-r--r--src/ppu_.cpp291
1 files changed, 71 insertions, 220 deletions
diff --git a/src/ppu_.cpp b/src/ppu_.cpp
index 1cdfa0b..e91be78 100644
--- a/src/ppu_.cpp
+++ b/src/ppu_.cpp
@@ -47,18 +47,18 @@
#include "dma.h"
#include "gfx.h"
#include "display.h"
-#include "sa1.h"
+#include "sa1.h"
#ifndef _SNESPPC
-//#include "netplay.h"
+//#include "netplay.h"
#endif
#include "sdd1.h"
#include "srtc.h"
-
+
#ifndef ZSNES_FX
#include "fxemu.h"
#include "fxinst.h"
-extern struct FxInit_s SuperFX;
+extern struct FxInit_s SuperFX;
extern struct FxRegs_s GSU;
#else
EXTERN_C void S9xSuperFXWriteReg (uint8, uint32);
@@ -126,9 +126,9 @@ void S9xUpdateHTimer ()
void S9xFixColourBrightness ()
{
- IPPU.XB = mul_brightness [PPU.Brightness];
+ IPPU.XB = mul_brightness [PPU.Brightness];
#ifndef _SNESPPC
- if (Settings.SixteenBit)
+ if (Settings.SixteenBit)
#endif
{
for (int i = 0; i < 256; i++)
@@ -155,7 +155,7 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2100:
// Brightness and screen blank bit
if (Byte != Memory.FillRAM [0x2100])
- {
+ {
FLUSH_REDRAW ();
if (PPU.Brightness != (Byte & 0xF))
{
@@ -177,8 +177,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2101:
// Sprite (OBJ) tile address
if (Byte != Memory.FillRAM [0x2101])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.OBJNameBase = (Byte & 3) << 14;
PPU.OBJNameSelect = ((Byte >> 3) & 3) << 13;
PPU.OBJSizeSelect = (Byte >> 5) & 7;
@@ -224,17 +224,17 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
break;
case 0x2104:
- // Sprite register write
- REGISTER_2104(Byte, &Memory, &IPPU, &PPU);
-
+ // Sprite register write
+ REGISTER_2104(Byte, &Memory, &IPPU, &PPU);
+
break;
case 0x2105:
// Screen mode (0 - 7), background tile sizes and background 3
// priority
if (Byte != Memory.FillRAM [0x2105])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.BG3Priority = (Byte >> 3) & 1;
PPU.BG[0].BGSize = (Byte >> 4) & 1;
PPU.BG[1].BGSize = (Byte >> 5) & 1;
@@ -250,8 +250,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2106:
// Mosaic pixel size and enable
if (Byte != Memory.FillRAM [0x2106])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
#ifdef DEBUGGER
if ((Byte & 0xf0) && (Byte & 0x0f))
missing.mosaic = 1;
@@ -265,8 +265,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
break;
case 0x2107: // [BG0SC]
if (Byte != Memory.FillRAM [0x2107])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.BG[0].SCSize = Byte & 3;
PPU.BG[0].SCBase = (Byte & 0x7c) << 8;
}
@@ -274,8 +274,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2108: // [BG1SC]
if (Byte != Memory.FillRAM [0x2108])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.BG[1].SCSize = Byte & 3;
PPU.BG[1].SCBase = (Byte & 0x7c) << 8;
}
@@ -283,8 +283,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2109: // [BG2SC]
if (Byte != Memory.FillRAM [0x2109])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.BG[2].SCSize = Byte & 3;
PPU.BG[2].SCBase = (Byte & 0x7c) << 8;
}
@@ -292,8 +292,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x210A: // [BG3SC]
if (Byte != Memory.FillRAM [0x210a])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.BG[3].SCSize = Byte & 3;
PPU.BG[3].SCBase = (Byte & 0x7c) << 8;
}
@@ -301,8 +301,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x210B: // [BG01NBA]
if (Byte != Memory.FillRAM [0x210b])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.BG[0].NameBase = (Byte & 7) << 12;
PPU.BG[1].NameBase = ((Byte >> 4) & 7) << 12;
}
@@ -310,8 +310,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x210C: // [BG23NBA]
if (Byte != Memory.FillRAM [0x210c])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.BG[2].NameBase = (Byte & 7) << 12;
PPU.BG[3].NameBase = ((Byte >> 4) & 7) << 12;
}
@@ -424,8 +424,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x211a:
// Mode 7 outside rotation area display mode and flipping
if (Byte != Memory.FillRAM [0x211a])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.Mode7Repeat = Byte >> 6;
PPU.Mode7VFlip = (Byte & 2) >> 1;
PPU.Mode7HFlip = Byte & 1;
@@ -472,8 +472,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2123:
// Window 1 and 2 enable for backgrounds 1 and 2
if (Byte != Memory.FillRAM [0x2123])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.ClipWindow1Enable [0] = !!(Byte & 0x02);
PPU.ClipWindow1Enable [1] = !!(Byte & 0x20);
@@ -499,8 +499,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2124:
// Window 1 and 2 enable for backgrounds 3 and 4
if (Byte != Memory.FillRAM [0x2124])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.ClipWindow1Enable [2] = !!(Byte & 0x02);
PPU.ClipWindow1Enable [3] = !!(Byte & 0x20);
@@ -526,8 +526,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2125:
// Window 1 and 2 enable for objects and colour window
if (Byte != Memory.FillRAM [0x2125])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.ClipWindow1Enable [4] = !!(Byte & 0x02);
PPU.ClipWindow1Enable [5] = !!(Byte & 0x20);
@@ -553,8 +553,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2126:
// Window 1 left position
if (Byte != Memory.FillRAM [0x2126])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.Window1Left = Byte;
PPU.RecomputeClipWindows = TRUE;
@@ -563,8 +563,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2127:
// Window 1 right position
if (Byte != Memory.FillRAM [0x2127])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.Window1Right = Byte;
PPU.RecomputeClipWindows = TRUE;
@@ -573,8 +573,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2128:
// Window 2 left position
if (Byte != Memory.FillRAM [0x2128])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.Window2Left = Byte;
PPU.RecomputeClipWindows = TRUE;
@@ -583,8 +583,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2129:
// Window 2 right position
if (Byte != Memory.FillRAM [0x2129])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.Window2Right = Byte;
PPU.RecomputeClipWindows = TRUE;
@@ -593,8 +593,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x212a:
// Windows 1 & 2 overlap logic for backgrounds 1 - 4
if (Byte != Memory.FillRAM [0x212a])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.ClipWindowOverlapLogic [0] = (Byte & 0x03);
PPU.ClipWindowOverlapLogic [1] = (Byte & 0x0c) >> 2;
@@ -606,8 +606,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x212b:
// Windows 1 & 2 overlap logic for objects and colour window
if (Byte != Memory.FillRAM [0x212b])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.ClipWindowOverlapLogic [4] = Byte & 0x03;
PPU.ClipWindowOverlapLogic [5] = (Byte & 0x0c) >> 2;
@@ -617,8 +617,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x212c:
// Main screen designation (backgrounds 1 - 4 and objects)
if (Byte != Memory.FillRAM [0x212c])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.RecomputeClipWindows = TRUE;
Memory.FillRAM [Address] = Byte;
@@ -628,8 +628,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x212d:
// Sub-screen designation (backgrounds 1 - 4 and objects)
if (Byte != Memory.FillRAM [0x212d])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
#ifdef DEBUGGER
if (Byte & 0x1f)
@@ -643,8 +643,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x212e:
// Window mask designation for main screen ?
if (Byte != Memory.FillRAM [0x212e])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.RecomputeClipWindows = TRUE;
}
@@ -652,8 +652,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x212f:
// Window mask designation for sub-screen ?
if (Byte != Memory.FillRAM [0x212f])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.RecomputeClipWindows = TRUE;
}
@@ -661,8 +661,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2130:
// Fixed colour addition or screen addition
if (Byte != Memory.FillRAM [0x2130])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
PPU.RecomputeClipWindows = TRUE;
#ifdef DEBUGGER
@@ -674,8 +674,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2131:
// Colour addition or subtraction select
if (Byte != Memory.FillRAM[0x2131])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
// Backgrounds 1 - 4, objects and backdrop colour add/sub enable
#ifdef DEBUGGER
@@ -701,8 +701,8 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
break;
case 0x2132:
if (Byte != Memory.FillRAM [0x2132])
- {
- FLUSH_REDRAW ();
+ {
+ FLUSH_REDRAW ();
// Colour data for fixed colour addition/subtraction
if (Byte & 0x80)
@@ -1378,10 +1378,10 @@ void S9xSetCPU (uint8 byte, uint16 Address)
}
else
{
- PPU.VTimerEnabled = FALSE;
+ PPU.VTimerEnabled = FALSE;
#ifndef RC_OPTIMIZED
if (SNESGameFixes.umiharakawaseFix)
- byte &= ~0x20;
+ byte &= ~0x20;
#endif
}
@@ -1404,8 +1404,8 @@ void S9xSetCPU (uint8 byte, uint16 Address)
PPU.HTimerEnabled = FALSE;
PPU.HTimerPosition = Settings.H_Max + 1;
}
-
-#ifndef RC_OPTIMIZED
+
+#ifndef RC_OPTIMIZED
if (!Settings.DaffyDuck)
CLEAR_IRQ_SOURCE (PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE);
@@ -1423,7 +1423,7 @@ void S9xSetCPU (uint8 byte, uint16 Address)
CPU.Flags |= NMI_FLAG;
CPU.NMIActive = TRUE;
CPU.NMICycleCount = CPU.NMITriggerPoint;
- }
+ }
#endif
break;
case 0x4201:
@@ -2395,14 +2395,14 @@ void S9xNextController ()
}
void S9xUpdateJoypads ()
-{
-#ifdef _SNESPPC
- int i = 0;
+{
+#ifdef _SNESPPC
+ int i = 0;
#else
int i;
for (i = 0; i < 5; i++)
-#endif
+#endif
{
IPPU.Joypads [i] = S9xReadJoypad (i);
if (IPPU.Joypads [i] & SNES_LEFT_MASK)
@@ -2472,7 +2472,6 @@ void S9xUpdateJoypads ()
#ifndef ZSNES_FX
void S9xSuperFXExec ()
{
-#if 1
if (Settings.SuperFX)
{
if ((Memory.FillRAM [0x3000 + GSU_SFR] & FLG_G) &&
@@ -2491,154 +2490,6 @@ void S9xSuperFXExec ()
}
}
}
-#else
- uint32 tmp = (Memory.FillRAM[0x3034] << 16) + *(uint16 *) &Memory.FillRAM [0x301e];
-
-#if 0
- if (tmp == 0x018428)
- {
- *(uint16 *) &SRAM [0x0064] = 0xbc00;
- *(uint16 *) &SRAM [0x002c] = 0x8000;
- }
-#endif
- if (tmp == -1)//0x018428) //0x01bfc3) //0x09edaf) //-1) //0x57edaf)
- {
- while (Memory.FillRAM [0x3030] & 0x20)
- {
- int i;
- int32 vError;
- uint8 avReg[0x40];
- char tmp[128];
- uint8 vPipe;
- uint8 vColr;
- uint8 vPor;
-
- FxPipeString (tmp);
- /* Make the string 32 chars long */
- if(strlen(tmp) < 32) { memset(&tmp[strlen(tmp)],' ',32-strlen(tmp)); tmp[32] = 0; }
-
- /* Copy registers (so we can see if any changed) */
- vColr = FxGetColorRegister();
- vPor = FxGetPlotOptionRegister();
- memcpy(avReg,SuperFX.pvRegisters,0x40);
-
- /* Print the pipe string */
- printf(tmp);
-
- /* Execute the instruction in the pipe */
- vPipe = FxPipe();
- vError = FxEmulate(1);
-
- /* Check if any registers changed (and print them if they did) */
- for(i=0; i<16; i++)
- {
- uint32 a = 0;
- uint32 r1 = ((uint32)avReg[i*2]) | (((uint32)avReg[(i*2)+1])<<8);
- uint32 r2 = (uint32)(SuperFX.pvRegisters[i*2]) | (((uint32)SuperFX.pvRegisters[(i*2)+1])<<8);
- if(i==15)
- a = OPCODE_BYTES(vPipe);
- if(((r1+a)&0xffff) != r2)
- printf(" r%d=$%04x",i,r2);
- }
- {
- /* Check SFR */
- uint32 r1 = ((uint32)avReg[0x30]) | (((uint32)avReg[0x31])<<8);
- uint32 r2 = (uint32)(SuperFX.pvRegisters[0x30]) | (((uint32)SuperFX.pvRegisters[0x31])<<8);
- if((r1&(1<<1)) != (r2&(1<<1)))
- printf(" Z=%d",(uint32)(!!(r2&(1<<1))));
- if((r1&(1<<2)) != (r2&(1<<2)))
- printf(" CY=%d",(uint32)(!!(r2&(1<<2))));
- if((r1&(1<<3)) != (r2&(1<<3)))
- printf(" S=%d",(uint32)(!!(r2&(1<<3))));
- if((r1&(1<<4)) != (r2&(1<<4)))
- printf(" OV=%d",(uint32)(!!(r2&(1<<4))));
- if((r1&(1<<5)) != (r2&(1<<5)))
- printf(" G=%d",(uint32)(!!(r2&(1<<5))));
- if((r1&(1<<6)) != (r2&(1<<6)))
- printf(" R=%d",(uint32)(!!(r2&(1<<6))));
- if((r1&(1<<8)) != (r2&(1<<8)))
- printf(" ALT1=%d",(uint32)(!!(r2&(1<<8))));
- if((r1&(1<<9)) != (r2&(1<<9)))
- printf(" ALT2=%d",(uint32)(!!(r2&(1<<9))));
- if((r1&(1<<10)) != (r2&(1<<10)))
- printf(" IL=%d",(uint32)(!!(r2&(1<<10))));
- if((r1&(1<<11)) != (r2&(1<<11)))
- printf(" IH=%d",(uint32)(!!(r2&(1<<11))));
- if((r1&(1<<12)) != (r2&(1<<12)))
- printf(" B=%d",(uint32)(!!(r2&(1<<12))));
- if((r1&(1<<15)) != (r2&(1<<15)))
- printf(" IRQ=%d",(uint32)(!!(r2&(1<<15))));
- }
- {
- /* Check PBR */
- uint32 r1 = ((uint32)avReg[0x34]);
- uint32 r2 = (uint32)(SuperFX.pvRegisters[0x34]);
- if(r1 != r2)
- printf(" PBR=$%02x",r2);
- }
- {
- /* Check ROMBR */
- uint32 r1 = ((uint32)avReg[0x36]);
- uint32 r2 = (uint32)(SuperFX.pvRegisters[0x36]);
- if(r1 != r2)
- printf(" ROMBR=$%02x",r2);
- }
- {
- /* Check RAMBR */
- uint32 r1 = ((uint32)avReg[0x3c]);
- uint32 r2 = (uint32)(SuperFX.pvRegisters[0x3c]);
- if(r1 != r2)
- printf(" RAMBR=$%02x",r2);
- }
- {
- /* Check CBR */
- uint32 r1 = ((uint32)avReg[0x3e]) | (((uint32)avReg[0x3f])<<8);
- uint32 r2 = (uint32)(SuperFX.pvRegisters[0x3e]) | (((uint32)SuperFX.pvRegisters[0x3f])<<8);
- if(r1 != r2)
- printf(" CBR=$%04x",r2);
- }
- {
- /* Check COLR */
- if(vColr != FxGetColorRegister())
- printf(" COLR=$%02x",FxGetColorRegister());
- }
- {
- /* Check POR */
- if(vPor != FxGetPlotOptionRegister())
- printf(" POR=$%02x",FxGetPlotOptionRegister());
- }
- printf ("\n");
- }
- S9xExit ();
- }
- else
- {
- uint32 t = (Memory.FillRAM [0x3034] << 16) +
- (Memory.FillRAM [0x301f] << 8) +
- (Memory.FillRAM [0x301e] << 0);
-printf ("%06x: %d\n", t, FxEmulate (2000000));
-// FxEmulate (2000000);
- }
-#if 0
- if (!(CPU.Flags & TRACE_FLAG))
- {
- static int z = 1;
- if (z == 0)
- {
- extern FILE *trace;
- CPU.Flags |= TRACE_FLAG;
- trace = fopen ("trace.log", "wb");
- }
- else
- z--;
- }
-#endif
- Memory.FillRAM [0x3030] &= ~0x20;
- if (Memory.FillRAM [0x3031] & 0x80)
- {
- S9xSetIRQ (GSU_IRQ_SOURCE);
- }
-#endif
}
#endif