aboutsummaryrefslogtreecommitdiff
path: root/source/fxemu.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/fxemu.c')
-rw-r--r--source/fxemu.c181
1 files changed, 7 insertions, 174 deletions
diff --git a/source/fxemu.c b/source/fxemu.c
index ffb82be..c16ee58 100644
--- a/source/fxemu.c
+++ b/source/fxemu.c
@@ -13,133 +13,21 @@ uint32_t(**fx_ppfFunctionTable)(uint32_t) = 0;
void (**fx_ppfPlotTable)() = 0;
void (**fx_ppfOpcodeTable)() = 0;
-#if 0
-void fx_setCache()
-{
- uint32_t c;
- GSU.bCacheActive = true;
- GSU.pvRegisters[0x3e] &= 0xf0;
- c = (uint32_t)GSU.pvRegisters[0x3e];
- c |= ((uint32_t)GSU.pvRegisters[0x3f]) << 8;
- if (c == GSU.vCacheBaseReg)
- return;
- GSU.vCacheBaseReg = c;
- GSU.vCacheFlags = 0;
- if (c < (0x10000 - 512))
- {
- uint8_t const* t = &ROM(c);
- memcpy(GSU.pvCache, t, 512);
- }
- else
- {
- uint8_t const* t1;
- uint8_t const* t2;
- uint32_t i = 0x10000 - c;
- t1 = &ROM(c);
- t2 = &ROM(0);
- memcpy(GSU.pvCache, t1, i);
- memcpy(&GSU.pvCache[i], t2, 512 - i);
- }
-}
-#endif
-
void FxCacheWriteAccess(uint16_t vAddress)
{
-#if 0
- if (!GSU.bCacheActive)
- {
- uint8_t v = GSU.pvCache[GSU.pvCache[vAddress & 0x1ff];
- fx_setCache();
- GSU.pvCache[GSU.pvCache[vAddress & 0x1ff] = v;
- }
-#endif
- if ((vAddress & 0x00f) == 0x00f)
- GSU.vCacheFlags |= 1 << ((vAddress & 0x1f0) >> 4);
+ if ((vAddress & 0x00f) == 0x00f)
+ GSU.vCacheFlags |= 1 << ((vAddress & 0x1f0) >> 4);
}
- void FxFlushCache()
+void FxFlushCache()
{
GSU.vCacheFlags = 0;
GSU.vCacheBaseReg = 0;
GSU.bCacheActive = false;
- // GSU.vPipe = 0x1;
-}
-
-static void fx_backupCache()
-{
-#if 0
- uint32_t i;
- uint32_t v = GSU.vCacheFlags;
- uint32_t c = USEX16(GSU.vCacheBaseReg);
- if (v)
- for (i = 0; i < 32; i++)
- {
- if (v & 1)
- {
- if (c < (0x10000 - 16))
- {
- uint8_t* t = &GSU.pvPrgBank[c];
- memcpy(&GSU.avCacheBackup[i << 4], t, 16);
- memcpy(t, &GSU.pvCache[i << 4], 16);
- }
- else
- {
- uint8_t* t1;
- uint8_t* t2;
- uint32_t a = 0x10000 - c;
- t1 = &GSU.pvPrgBank[c];
- t2 = &GSU.pvPrgBank[0];
- memcpy(&GSU.avCacheBackup[i << 4], t1, a);
- memcpy(t1, &GSU.pvCache[i << 4], a);
- memcpy(&GSU.avCacheBackup[(i << 4) + a], t2, 16 - a);
- memcpy(t2, &GSU.pvCache[(i << 4) + a], 16 - a);
- }
- }
- c = USEX16(c + 16);
- v >>= 1;
- }
-#endif
-}
-
-static void fx_restoreCache()
-{
-#if 0
- uint32_t i;
- uint32_t v = GSU.vCacheFlags;
- uint32_t c = USEX16(GSU.vCacheBaseReg);
- if (v)
- for (i = 0; i < 32; i++)
- {
- if (v & 1)
- {
- if (c < (0x10000 - 16))
- {
- uint8_t* t = &GSU.pvPrgBank[c];
- memcpy(t, &GSU.avCacheBackup[i << 4], 16);
- memcpy(&GSU.pvCache[i << 4], t, 16);
- }
- else
- {
- uint8_t* t1;
- uint8_t* t2;
- uint32_t a = 0x10000 - c;
- t1 = &GSU.pvPrgBank[c];
- t2 = &GSU.pvPrgBank[0];
- memcpy(t1, &GSU.avCacheBackup[i << 4], a);
- memcpy(&GSU.pvCache[i << 4], t1, a);
- memcpy(t2, &GSU.avCacheBackup[(i << 4) + a], 16 - a);
- memcpy(&GSU.pvCache[(i << 4) + a], t2, 16 - a);
- }
- }
- c = USEX16(c + 16);
- v >>= 1;
- }
-#endif
}
void fx_flushCache()
{
- fx_restoreCache();
GSU.vCacheFlags = 0;
GSU.bCacheActive = false;
}
@@ -197,10 +85,6 @@ static void fx_readRegisterSpace()
i |= ((int)(!!(p[GSU_SCMR] & 0x20))) << 1;
GSU.vScreenHeight = GSU.vScreenRealHeight = avHeight[i];
GSU.vMode = p[GSU_SCMR] & 0x03;
-#if 0
- if (GSU.vMode == 2)
- error illegal color depth GSU.vMode;
-#endif
if (i == 3)
GSU.vScreenSize = (256 / 8) * (256 / 8) * 32;
else
@@ -210,14 +94,9 @@ static void fx_readRegisterSpace()
/* OBJ Mode (for drawing into sprites) */
GSU.vScreenHeight = 256;
}
-#if 0
- if (GSU.pvScreenBase + GSU.vScreenSize > GSU.pvRam + (GSU.nRamBanks * 65536))
- error illegal address for screen base register
-#else
if (GSU.pvScreenBase + GSU.vScreenSize > GSU.pvRam + (GSU.nRamBanks * 65536))
GSU.pvScreenBase = GSU.pvRam + (GSU.nRamBanks * 65536) - GSU.vScreenSize;
-#endif
- GSU.pfPlot = fx_apfPlotTable[GSU.vMode];
+ GSU.pfPlot = fx_apfPlotTable[GSU.vMode];
GSU.pfRpix = fx_apfPlotTable[GSU.vMode + 5];
fx_ppfOpcodeTable[0x04c] = GSU.pfPlot;
@@ -226,8 +105,6 @@ static void fx_readRegisterSpace()
fx_ppfOpcodeTable[0x34c] = GSU.pfRpix;
fx_computeScreenPointers();
-
- fx_backupCache();
}
void fx_dirtySCBR()
@@ -395,8 +272,6 @@ static void fx_writeRegisterSpace()
p[GSU_RAMBR] = (uint8_t)GSU.vRamBankReg;
p[GSU_CBR] = (uint8_t)GSU.vCacheBaseReg;
p[GSU_CBR + 1] = (uint8_t)(GSU.vCacheBaseReg >> 8);
-
- fx_restoreCache();
}
/* Reset the FxChip */
@@ -405,30 +280,15 @@ void FxReset(struct FxInit_s* psFxInfo)
int i;
static uint32_t(**appfFunction[])(uint32_t) =
{
- &fx_apfFunctionTable[0],
-#if 0
- &fx_a_apfFunctionTable[0],
- &fx_r_apfFunctionTable[0],
- &fx_ar_apfFunctionTable[0],
-#endif
+ &fx_apfFunctionTable[0]
};
static void (**appfPlot[])() =
{
- &fx_apfPlotTable[0],
-#if 0
- &fx_a_apfPlotTable[0],
- &fx_r_apfPlotTable[0],
- &fx_ar_apfPlotTable[0],
-#endif
+ &fx_apfPlotTable[0]
};
static void (**appfOpcode[])() =
{
- &fx_apfOpcodeTable[0],
-#if 0
- &fx_a_apfOpcodeTable[0],
- &fx_r_apfOpcodeTable[0],
- &fx_ar_apfOpcodeTable[0],
-#endif
+ &fx_apfOpcodeTable[0]
};
/* Get function pointers for the current emulation mode */
@@ -536,22 +396,12 @@ int FxEmulate(uint32_t nInstructions)
{
CF(G);
fx_writeRegisterSpace();
-#if 0
- GSU.vIllegalAddress = (GSU.vPrgBankReg << 24) | R15;
- return FX_ERROR_ILLEGAL_ADDRESS;
-#else
return 0;
-#endif
}
/* Execute GSU session */
CF(IRQ);
- /*
- if (GSU.bBreakPoint)
- vCount = fx_ppfFunctionTable[FX_FUNCTION_RUN_TO_BREAKPOINT](nInstructions);
- else
- */
vCount = fx_ppfFunctionTable[FX_FUNCTION_RUN](nInstructions);
/* Store GSU registers */
@@ -564,18 +414,6 @@ int FxEmulate(uint32_t nInstructions)
return vCount;
}
-/* Breakpoints */
-/*
-void FxBreakPointSet(uint32_t vAddress)
-{
- GSU.bBreakPoint = true;
- GSU.vBreakPoint = USEX16(vAddress);
-}
-void FxBreakPointClear()
-{
- GSU.bBreakPoint = false;
-}*/
-
/* Step by step execution */
int FxStepOver(uint32_t nInstructions)
{
@@ -586,12 +424,7 @@ int FxStepOver(uint32_t nInstructions)
if (!fx_checkStartAddress())
{
CF(G);
-#if 0
- GSU.vIllegalAddress = (GSU.vPrgBankReg << 24) | R15;
- return FX_ERROR_ILLEGAL_ADDRESS;
-#else
return 0;
-#endif
}
if (PIPE >= 0xf0)