mirror of
https://github.com/libretro/snes9x2005.git
synced 2024-11-27 02:20:24 +00:00
Merge pull request #92 from jSTE0/microopt
This commit is contained in:
commit
abd072aa37
@ -352,7 +352,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
|
||||
Op11m = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
|
||||
Op11Zr = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
|
||||
Op11Yr = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8));
|
||||
Op11Xr = (int16_t)(DSP1.parameters [7] | (DSP1.parameters[7] << 8));
|
||||
Op11Xr = (int16_t)(DSP1.parameters [6] | (DSP1.parameters[7] << 8));
|
||||
DSPOp11();
|
||||
break;
|
||||
case 0x25:
|
||||
|
@ -187,11 +187,19 @@ void DSP1_Inverse(int16_t Coefficient, int16_t Exponent, int16_t* iCoefficient,
|
||||
}
|
||||
|
||||
/* Step Three: Normalize */
|
||||
#ifdef __GNUC__
|
||||
{
|
||||
const int shift = __builtin_clz(Coefficient) - (8 * sizeof(int) - 15);
|
||||
Coefficient <<= shift;
|
||||
Exponent -= shift;
|
||||
}
|
||||
#else
|
||||
while (Coefficient < 0x4000)
|
||||
{
|
||||
Coefficient <<= 1;
|
||||
Exponent--;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Step Four: Special Case */
|
||||
if (Coefficient == 0x4000)
|
||||
@ -336,9 +344,18 @@ int16_t DSP1_Cos(int16_t Angle)
|
||||
|
||||
void DSP1_Normalize(int16_t m, int16_t* Coefficient, int16_t* Exponent)
|
||||
{
|
||||
int16_t i = 0x4000;
|
||||
int16_t e = 0;
|
||||
|
||||
#ifdef __GNUC__
|
||||
int16_t n = m < 0 ? ~m : m;
|
||||
|
||||
if (n == 0)
|
||||
e = 15;
|
||||
else
|
||||
e = __builtin_clz(n) - (8 * sizeof(int) - 15);
|
||||
#else
|
||||
int16_t i = 0x4000;
|
||||
|
||||
if (m < 0)
|
||||
{
|
||||
while ((m & i) && i)
|
||||
@ -355,6 +372,7 @@ void DSP1_Normalize(int16_t m, int16_t* Coefficient, int16_t* Exponent)
|
||||
e++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (e > 0)
|
||||
*Coefficient = m * DSP1ROM[0x21 + e] << 1;
|
||||
@ -368,9 +386,18 @@ void DSP1_NormalizeDouble(int32_t Product, int16_t* Coefficient, int16_t* Expone
|
||||
{
|
||||
int16_t n = Product & 0x7fff;
|
||||
int16_t m = Product >> 15;
|
||||
int16_t i = 0x4000;
|
||||
int16_t e = 0;
|
||||
|
||||
#ifdef __GNUC__
|
||||
int16_t t = m < 0 ? ~m : m;
|
||||
|
||||
if (t == 0)
|
||||
e = 15;
|
||||
else
|
||||
e = __builtin_clz(t) - (8 * sizeof(int) - 15);
|
||||
#else
|
||||
int16_t i = 0x4000;
|
||||
|
||||
if (m < 0)
|
||||
{
|
||||
while ((m & i) && i)
|
||||
@ -387,6 +414,7 @@ void DSP1_NormalizeDouble(int32_t Product, int16_t* Coefficient, int16_t* Expone
|
||||
e++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (e > 0)
|
||||
{
|
||||
@ -396,6 +424,14 @@ void DSP1_NormalizeDouble(int32_t Product, int16_t* Coefficient, int16_t* Expone
|
||||
*Coefficient += n * DSP1ROM[0x0040 - e] >> 15;
|
||||
else
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
t = m < 0 ? ~(n | 0x8000) : n;
|
||||
|
||||
if (t == 0)
|
||||
e += 15;
|
||||
else
|
||||
e += __builtin_clz(t) - (8 * sizeof(int) - 15);
|
||||
#else
|
||||
i = 0x4000;
|
||||
|
||||
if (m < 0)
|
||||
@ -414,6 +450,7 @@ void DSP1_NormalizeDouble(int32_t Product, int16_t* Coefficient, int16_t* Expone
|
||||
e++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (e > 15)
|
||||
*Coefficient = n * DSP1ROM[0x0012 + e] << 1;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "fxemu.h"
|
||||
#include "fxinst.h"
|
||||
#include "memmap.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -30,33 +31,27 @@ void fx_updateRamBank(uint8_t Byte)
|
||||
|
||||
static INLINE void fx_readRegisterSpaceForCheck(void)
|
||||
{
|
||||
R15 = GSU.pvRegisters[30];
|
||||
R15 |= ((uint32_t) GSU.pvRegisters[31]) << 8;
|
||||
R15 = (uint32_t) READ_WORD(&GSU.pvRegisters[30]);
|
||||
}
|
||||
|
||||
static void fx_readRegisterSpaceForUse(void)
|
||||
{
|
||||
static uint32_t avHeight[] = { 128, 160, 192, 256 };
|
||||
static uint32_t avMult[] = { 16, 32, 32, 64 };
|
||||
static const uint32_t avHeight[] = { 128, 160, 192, 256 };
|
||||
static const uint32_t avMult[] = { 16, 32, 32, 64 };
|
||||
int32_t i;
|
||||
uint8_t* p = GSU.pvRegisters;
|
||||
|
||||
/* Update R0 - R14 */
|
||||
for (i = 0; i < 15; i++)
|
||||
{
|
||||
GSU.avReg[i] = *p++;
|
||||
GSU.avReg[i] += ((uint32_t)(*p++)) << 8;
|
||||
}
|
||||
for (i = 0; i < 15; i++, p += 2)
|
||||
GSU.avReg[i] = (uint32_t) READ_WORD(p);
|
||||
|
||||
/* Update other registers */
|
||||
p = GSU.pvRegisters;
|
||||
GSU.vStatusReg = (uint32_t) GSU.pvRegisters[GSU_SFR];
|
||||
GSU.vStatusReg |= ((uint32_t) GSU.pvRegisters[GSU_SFR + 1]) << 8;
|
||||
GSU.vStatusReg = (uint32_t) READ_WORD(&GSU.pvRegisters[GSU_SFR]);
|
||||
GSU.vPrgBankReg = (uint32_t) GSU.pvRegisters[GSU_PBR];
|
||||
GSU.vRomBankReg = (uint32_t)p[GSU_ROMBR];
|
||||
GSU.vRamBankReg = ((uint32_t)p[GSU_RAMBR]) & (FX_RAM_BANKS - 1);
|
||||
GSU.vCacheBaseReg = (uint32_t)p[GSU_CBR];
|
||||
GSU.vCacheBaseReg |= ((uint32_t)p[GSU_CBR + 1]) << 8;
|
||||
GSU.vCacheBaseReg = (uint32_t) READ_WORD(&p[GSU_CBR]);
|
||||
|
||||
/* Update status register variables */
|
||||
GSU.vZero = !(GSU.vStatusReg & FLG_Z);
|
||||
@ -146,19 +141,15 @@ void fx_computeScreenPointers(void)
|
||||
|
||||
static INLINE void fx_writeRegisterSpaceAfterCheck(void)
|
||||
{
|
||||
GSU.pvRegisters[30] = (uint8_t) R15;
|
||||
GSU.pvRegisters[31] = (uint8_t) (R15 >> 8);
|
||||
WRITE_WORD(&GSU.pvRegisters[30], R15);
|
||||
}
|
||||
|
||||
static void fx_writeRegisterSpaceAfterUse(void)
|
||||
{
|
||||
int32_t i;
|
||||
uint8_t* p = GSU.pvRegisters;
|
||||
for (i = 0; i < 15; i++)
|
||||
{
|
||||
*p++ = (uint8_t)GSU.avReg[i];
|
||||
*p++ = (uint8_t)(GSU.avReg[i] >> 8);
|
||||
}
|
||||
for (i = 0; i < 15; i++, p += 2)
|
||||
WRITE_WORD(p, GSU.avReg[i]);
|
||||
|
||||
/* Update status register */
|
||||
if (USEX16(GSU.vZero) == 0)
|
||||
@ -179,13 +170,11 @@ static void fx_writeRegisterSpaceAfterUse(void)
|
||||
CF(CY);
|
||||
|
||||
p = GSU.pvRegisters;
|
||||
p[GSU_SFR] = (uint8_t) GSU.vStatusReg;
|
||||
p[GSU_SFR + 1] = (uint8_t) (GSU.vStatusReg >> 8);
|
||||
WRITE_WORD(&p[GSU_SFR], GSU.vStatusReg);
|
||||
p[GSU_PBR] = (uint8_t) GSU.vPrgBankReg;
|
||||
p[GSU_ROMBR] = (uint8_t)GSU.vRomBankReg;
|
||||
p[GSU_RAMBR] = (uint8_t)GSU.vRamBankReg;
|
||||
p[GSU_CBR] = (uint8_t)GSU.vCacheBaseReg;
|
||||
p[GSU_CBR + 1] = (uint8_t)(GSU.vCacheBaseReg >> 8);
|
||||
WRITE_WORD(&p[GSU_CBR], GSU.vCacheBaseReg);
|
||||
}
|
||||
|
||||
/* Reset the FxChip */
|
||||
|
@ -423,7 +423,7 @@ void S9xStartScreenRefresh(void)
|
||||
GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1;
|
||||
}
|
||||
|
||||
if (++IPPU.FrameCount % Memory.ROMFramesPerSecond == 0)
|
||||
if (++IPPU.FrameCount == (uint32_t)Memory.ROMFramesPerSecond)
|
||||
IPPU.FrameCount = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user