Merge pull request #735 from jSTE0/microopt

Microoptimisations from jSTE0
This commit is contained in:
bearoso 2022-02-21 17:47:02 -06:00 committed by GitHub
commit 29d319ad78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 198 additions and 227 deletions

388
dsp1.cpp
View File

@ -316,11 +316,17 @@ static void DSP1_Inverse (int16 Coefficient, int16 Exponent, int16 *iCoefficient
} }
// Step Three: Normalize // Step Three: Normalize
#ifdef __GNUC__
const int shift = __builtin_clz(Coefficient) - (8 * sizeof(int) - 15);
Coefficient <<= shift;
Exponent -= shift;
#else
while (Coefficient < 0x4000) while (Coefficient < 0x4000)
{ {
Coefficient <<= 1; Coefficient <<= 1;
Exponent--; Exponent--;
} }
#endif
// Step Four: Special Case // Step Four: Special Case
if (Coefficient == 0x4000) if (Coefficient == 0x4000)
@ -398,9 +404,18 @@ static int16 DSP1_Cos (int16 Angle)
static void DSP1_Normalize (int16 m, int16 *Coefficient, int16 *Exponent) static void DSP1_Normalize (int16 m, int16 *Coefficient, int16 *Exponent)
{ {
int16 i = 0x4000;
int16 e = 0; int16 e = 0;
#ifdef __GNUC__
int16 n = m < 0 ? ~m : m;
if (n == 0)
e = 15;
else
e = __builtin_clz(n) - (8 * sizeof(int) - 15);
#else
int16 i = 0x4000;
if (m < 0) if (m < 0)
{ {
while ((m & i) && i) while ((m & i) && i)
@ -417,6 +432,7 @@ static void DSP1_Normalize (int16 m, int16 *Coefficient, int16 *Exponent)
e++; e++;
} }
} }
#endif
if (e > 0) if (e > 0)
*Coefficient = m * DSP1ROM[0x21 + e] << 1; *Coefficient = m * DSP1ROM[0x21 + e] << 1;
@ -430,9 +446,18 @@ static void DSP1_NormalizeDouble (int32 Product, int16 *Coefficient, int16 *Expo
{ {
int16 n = Product & 0x7fff; int16 n = Product & 0x7fff;
int16 m = Product >> 15; int16 m = Product >> 15;
int16 i = 0x4000;
int16 e = 0; int16 e = 0;
#ifdef __GNUC__
int16 t = m < 0 ? ~m : m;
if (t == 0)
e = 15;
else
e = __builtin_clz(t) - (8 * sizeof(int) - 15);
#else
int16 i = 0x4000;
if (m < 0) if (m < 0)
{ {
while ((m & i) && i) while ((m & i) && i)
@ -449,6 +474,7 @@ static void DSP1_NormalizeDouble (int32 Product, int16 *Coefficient, int16 *Expo
e++; e++;
} }
} }
#endif
if (e > 0) if (e > 0)
{ {
@ -458,6 +484,14 @@ static void DSP1_NormalizeDouble (int32 Product, int16 *Coefficient, int16 *Expo
*Coefficient += n * DSP1ROM[0x0040 - e] >> 15; *Coefficient += n * DSP1ROM[0x0040 - e] >> 15;
else 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; i = 0x4000;
if (m < 0) if (m < 0)
@ -476,6 +510,7 @@ static void DSP1_NormalizeDouble (int32 Product, int16 *Coefficient, int16 *Expo
e++; e++;
} }
} }
#endif
if (e > 15) if (e > 15)
*Coefficient = n * DSP1ROM[0x0012 + e] << 1; *Coefficient = n * DSP1ROM[0x0012 + e] << 1;
@ -522,7 +557,7 @@ static void DSP1_Op0C (void)
static void DSP1_Parameter (int16 Fx, int16 Fy, int16 Fz, int16 Lfe, int16 Les, int16 Aas, int16 Azs, int16 *Vof, int16 *Vva, int16 *Cx, int16 *Cy) static void DSP1_Parameter (int16 Fx, int16 Fy, int16 Fz, int16 Lfe, int16 Les, int16 Aas, int16 Azs, int16 *Vof, int16 *Vva, int16 *Cx, int16 *Cy)
{ {
const int16 MaxAZS_Exp[16] = static const int16 MaxAZS_Exp[16] =
{ {
0x38b4, 0x38b7, 0x38ba, 0x38be, 0x38c0, 0x38c4, 0x38c7, 0x38ca, 0x38b4, 0x38b7, 0x38ba, 0x38be, 0x38c0, 0x38c4, 0x38c7, 0x38ca,
0x38ce, 0x38d0, 0x38d4, 0x38d7, 0x38da, 0x38dd, 0x38e0, 0x38e4 0x38ce, 0x38d0, 0x38d4, 0x38d7, 0x38da, 0x38dd, 0x38e0, 0x38e4
@ -1231,187 +1266,163 @@ void DSP1SetByte (uint8 byte, uint16 address)
break; break;
case 0x00: // Multiple case 0x00: // Multiple
DSP1.Op00Multiplicand = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op00Multiplicand = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op00Multiplier = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op00Multiplier = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1_Op00(); DSP1_Op00();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = DSP1.Op00Result & 0xFF; WRITE_WORD(&DSP1.output[0], DSP1.Op00Result);
DSP1.output[1] = (DSP1.Op00Result >> 8) & 0xFF;
break; break;
case 0x20: // Multiple case 0x20: // Multiple
DSP1.Op20Multiplicand = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op20Multiplicand = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op20Multiplier = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op20Multiplier = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1_Op20(); DSP1_Op20();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = DSP1.Op20Result & 0xFF; WRITE_WORD(&DSP1.output[0], DSP1.Op20Result);
DSP1.output[1] = (DSP1.Op20Result >> 8) & 0xFF;
break; break;
case 0x30: case 0x30:
case 0x10: // Inverse case 0x10: // Inverse
DSP1.Op10Coefficient = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op10Coefficient = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op10Exponent = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op10Exponent = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1_Op10(); DSP1_Op10();
DSP1.out_count = 4; DSP1.out_count = 4;
DSP1.output[0] = (uint8) ( ((int16) DSP1.Op10CoefficientR) & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op10CoefficientR);
DSP1.output[1] = (uint8) ((((int16) DSP1.Op10CoefficientR) >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op10ExponentR);
DSP1.output[2] = (uint8) ( ((int16) DSP1.Op10ExponentR ) & 0xFF);
DSP1.output[3] = (uint8) ((((int16) DSP1.Op10ExponentR ) >> 8) & 0xFF);
break; break;
case 0x24: case 0x24:
case 0x04: // Sin and Cos of angle case 0x04: // Sin and Cos of angle
DSP1.Op04Angle = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op04Angle = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op04Radius = (uint16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op04Radius = (uint16) READ_WORD(&DSP1.parameters[2]);
DSP1_Op04(); DSP1_Op04();
DSP1.out_count = 4; DSP1.out_count = 4;
DSP1.output[0] = (uint8) (DSP1.Op04Sin & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op04Sin);
DSP1.output[1] = (uint8) ((DSP1.Op04Sin >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op04Cos);
DSP1.output[2] = (uint8) (DSP1.Op04Cos & 0xFF);
DSP1.output[3] = (uint8) ((DSP1.Op04Cos >> 8) & 0xFF);
break; break;
case 0x08: // Radius case 0x08: // Radius
DSP1.Op08X = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op08X = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op08Y = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op08Y = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op08Z = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op08Z = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op08(); DSP1_Op08();
DSP1.out_count = 4; DSP1.out_count = 4;
DSP1.output[0] = (uint8) ( ((int16) DSP1.Op08Ll) & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op08Ll);
DSP1.output[1] = (uint8) ((((int16) DSP1.Op08Ll) >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op08Lh);
DSP1.output[2] = (uint8) ( ((int16) DSP1.Op08Lh) & 0xFF);
DSP1.output[3] = (uint8) ((((int16) DSP1.Op08Lh) >> 8) & 0xFF);
break; break;
case 0x18: // Range case 0x18: // Range
DSP1.Op18X = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op18X = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op18Y = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op18Y = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op18Z = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op18Z = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1.Op18R = (int16) (DSP1.parameters[6] | (DSP1.parameters[7] << 8)); DSP1.Op18R = (int16) READ_WORD(&DSP1.parameters[6]);
DSP1_Op18(); DSP1_Op18();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = (uint8) (DSP1.Op18D & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op18D);
DSP1.output[1] = (uint8) ((DSP1.Op18D >> 8) & 0xFF);
break; break;
case 0x38: // Range case 0x38: // Range
DSP1.Op38X = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op38X = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op38Y = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op38Y = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op38Z = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op38Z = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1.Op38R = (int16) (DSP1.parameters[6] | (DSP1.parameters[7] << 8)); DSP1.Op38R = (int16) READ_WORD(&DSP1.parameters[6]);
DSP1_Op38(); DSP1_Op38();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = (uint8) (DSP1.Op38D & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op38D);
DSP1.output[1] = (uint8) ((DSP1.Op38D >> 8) & 0xFF);
break; break;
case 0x28: // Distance (vector length) case 0x28: // Distance (vector length)
DSP1.Op28X = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op28X = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op28Y = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op28Y = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op28Z = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op28Z = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op28(); DSP1_Op28();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = (uint8) (DSP1.Op28R & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op28R);
DSP1.output[1] = (uint8) ((DSP1.Op28R >> 8) & 0xFF);
break; break;
case 0x2c: case 0x2c:
case 0x0c: // Rotate (2D rotate) case 0x0c: // Rotate (2D rotate)
DSP1.Op0CA = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op0CA = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op0CX1 = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op0CX1 = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op0CY1 = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op0CY1 = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op0C(); DSP1_Op0C();
DSP1.out_count = 4; DSP1.out_count = 4;
DSP1.output[0] = (uint8) (DSP1.Op0CX2 & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op0CX2);
DSP1.output[1] = (uint8) ((DSP1.Op0CX2 >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op0CY2);
DSP1.output[2] = (uint8) (DSP1.Op0CY2 & 0xFF);
DSP1.output[3] = (uint8) ((DSP1.Op0CY2 >> 8) & 0xFF);
break; break;
case 0x3c: case 0x3c:
case 0x1c: // Polar (3D rotate) case 0x1c: // Polar (3D rotate)
DSP1.Op1CZ = (DSP1.parameters[ 0] | (DSP1.parameters[ 1] << 8)); DSP1.Op1CZ = READ_WORD(&DSP1.parameters[ 0]);
//MK: reversed X and Y on neviksti and John's advice. //MK: reversed X and Y on neviksti and John's advice.
DSP1.Op1CY = (DSP1.parameters[ 2] | (DSP1.parameters[ 3] << 8)); DSP1.Op1CY = READ_WORD(&DSP1.parameters[ 2]);
DSP1.Op1CX = (DSP1.parameters[ 4] | (DSP1.parameters[ 5] << 8)); DSP1.Op1CX = READ_WORD(&DSP1.parameters[ 4]);
DSP1.Op1CXBR = (DSP1.parameters[ 6] | (DSP1.parameters[ 7] << 8)); DSP1.Op1CXBR = READ_WORD(&DSP1.parameters[ 6]);
DSP1.Op1CYBR = (DSP1.parameters[ 8] | (DSP1.parameters[ 9] << 8)); DSP1.Op1CYBR = READ_WORD(&DSP1.parameters[ 8]);
DSP1.Op1CZBR = (DSP1.parameters[10] | (DSP1.parameters[11] << 8)); DSP1.Op1CZBR = READ_WORD(&DSP1.parameters[10]);
DSP1_Op1C(); DSP1_Op1C();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output[0] = (uint8) (DSP1.Op1CXAR & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op1CXAR);
DSP1.output[1] = (uint8) ((DSP1.Op1CXAR >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op1CYAR);
DSP1.output[2] = (uint8) (DSP1.Op1CYAR & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op1CZAR);
DSP1.output[3] = (uint8) ((DSP1.Op1CYAR >> 8) & 0xFF);
DSP1.output[4] = (uint8) (DSP1.Op1CZAR & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op1CZAR >> 8) & 0xFF);
break; break;
case 0x32: case 0x32:
case 0x22: case 0x22:
case 0x12: case 0x12:
case 0x02: // Parameter (Projection) case 0x02: // Parameter (Projection)
DSP1.Op02FX = (int16) (DSP1.parameters[ 0] | (DSP1.parameters[ 1] << 8)); DSP1.Op02FX = (int16) READ_WORD(&DSP1.parameters[ 0]);
DSP1.Op02FY = (int16) (DSP1.parameters[ 2] | (DSP1.parameters[ 3] << 8)); DSP1.Op02FY = (int16) READ_WORD(&DSP1.parameters[ 2]);
DSP1.Op02FZ = (int16) (DSP1.parameters[ 4] | (DSP1.parameters[ 5] << 8)); DSP1.Op02FZ = (int16) READ_WORD(&DSP1.parameters[ 4]);
DSP1.Op02LFE = (int16) (DSP1.parameters[ 6] | (DSP1.parameters[ 7] << 8)); DSP1.Op02LFE = (int16) READ_WORD(&DSP1.parameters[ 6]);
DSP1.Op02LES = (int16) (DSP1.parameters[ 8] | (DSP1.parameters[ 9] << 8)); DSP1.Op02LES = (int16) READ_WORD(&DSP1.parameters[ 8]);
DSP1.Op02AAS = (uint16) (DSP1.parameters[10] | (DSP1.parameters[11] << 8)); DSP1.Op02AAS = (uint16) READ_WORD(&DSP1.parameters[10]);
DSP1.Op02AZS = (uint16) (DSP1.parameters[12] | (DSP1.parameters[13] << 8)); DSP1.Op02AZS = (uint16) READ_WORD(&DSP1.parameters[12]);
DSP1_Op02(); DSP1_Op02();
DSP1.out_count = 8; DSP1.out_count = 8;
DSP1.output[0] = (uint8) (DSP1.Op02VOF & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op02VOF);
DSP1.output[1] = (uint8) ((DSP1.Op02VOF >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op02VVA);
DSP1.output[2] = (uint8) (DSP1.Op02VVA & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op02CX);
DSP1.output[3] = (uint8) ((DSP1.Op02VVA >> 8) & 0xFF); WRITE_WORD(&DSP1.output[6], DSP1.Op02CY);
DSP1.output[4] = (uint8) (DSP1.Op02CX & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op02CX >> 8) & 0xFF);
DSP1.output[6] = (uint8) (DSP1.Op02CY & 0xFF);
DSP1.output[7] = (uint8) ((DSP1.Op02CY >> 8) & 0xFF);
break; break;
case 0x3a: case 0x3a:
case 0x2a: case 0x2a:
case 0x1a: // Raster mode 7 matrix data case 0x1a: // Raster mode 7 matrix data
case 0x0a: case 0x0a:
DSP1.Op0AVS = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op0AVS = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1_Op0A(); DSP1_Op0A();
DSP1.out_count = 8; DSP1.out_count = 8;
DSP1.output[0] = (uint8) (DSP1.Op0AA & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op0AA);
DSP1.output[1] = (uint8) ((DSP1.Op0AA >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op0AB);
DSP1.output[2] = (uint8) (DSP1.Op0AB & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op0AC);
DSP1.output[3] = (uint8) ((DSP1.Op0AB >> 8) & 0xFF); WRITE_WORD(&DSP1.output[6], DSP1.Op0AD);
DSP1.output[4] = (uint8) (DSP1.Op0AC & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op0AC >> 8) & 0xFF);
DSP1.output[6] = (uint8) (DSP1.Op0AD & 0xFF);
DSP1.output[7] = (uint8) ((DSP1.Op0AD >> 8) & 0xFF);
DSP1.in_index = 0; DSP1.in_index = 0;
break; break;
@ -1419,35 +1430,30 @@ void DSP1SetByte (uint8 byte, uint16 address)
case 0x26: case 0x26:
case 0x36: case 0x36:
case 0x06: // Project object case 0x06: // Project object
DSP1.Op06X = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op06X = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op06Y = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op06Y = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op06Z = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op06Z = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op06(); DSP1_Op06();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output[0] = (uint8) (DSP1.Op06H & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op06H);
DSP1.output[1] = (uint8) ((DSP1.Op06H >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op06V);
DSP1.output[2] = (uint8) (DSP1.Op06V & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op06M);
DSP1.output[3] = (uint8) ((DSP1.Op06V >> 8) & 0xFF);
DSP1.output[4] = (uint8) (DSP1.Op06M & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op06M >> 8) & 0xFF);
break; break;
case 0x1e: case 0x1e:
case 0x2e: case 0x2e:
case 0x3e: case 0x3e:
case 0x0e: // Target case 0x0e: // Target
DSP1.Op0EH = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op0EH = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op0EV = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op0EV = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1_Op0E(); DSP1_Op0E();
DSP1.out_count = 4; DSP1.out_count = 4;
DSP1.output[0] = (uint8) (DSP1.Op0EX & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op0EX);
DSP1.output[1] = (uint8) ((DSP1.Op0EX >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op0EY);
DSP1.output[2] = (uint8) (DSP1.Op0EY & 0xFF);
DSP1.output[3] = (uint8) ((DSP1.Op0EY >> 8) & 0xFF);
break; break;
// Extra commands used by Pilot Wings // Extra commands used by Pilot Wings
@ -1455,30 +1461,30 @@ void DSP1SetByte (uint8 byte, uint16 address)
case 0x35: case 0x35:
case 0x31: case 0x31:
case 0x01: // Set attitude matrix A case 0x01: // Set attitude matrix A
DSP1.Op01m = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op01m = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op01Zr = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op01Zr = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op01Yr = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op01Yr = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1.Op01Xr = (int16) (DSP1.parameters[6] | (DSP1.parameters[7] << 8)); DSP1.Op01Xr = (int16) READ_WORD(&DSP1.parameters[6]);
DSP1_Op01(); DSP1_Op01();
break; break;
case 0x15: case 0x15:
case 0x11: // Set attitude matrix B case 0x11: // Set attitude matrix B
DSP1.Op11m = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op11m = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op11Zr = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op11Zr = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op11Yr = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op11Yr = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1.Op11Xr = (int16) (DSP1.parameters[7] | (DSP1.parameters[7] << 8)); DSP1.Op11Xr = (int16) READ_WORD(&DSP1.parameters[6]);
DSP1_Op11(); DSP1_Op11();
break; break;
case 0x25: case 0x25:
case 0x21: // Set attitude matrix C case 0x21: // Set attitude matrix C
DSP1.Op21m = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op21m = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op21Zr = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op21Zr = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op21Yr = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op21Yr = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1.Op21Xr = (int16) (DSP1.parameters[6] | (DSP1.parameters[7] << 8)); DSP1.Op21Xr = (int16) READ_WORD(&DSP1.parameters[6]);
DSP1_Op21(); DSP1_Op21();
break; break;
@ -1487,182 +1493,156 @@ void DSP1SetByte (uint8 byte, uint16 address)
case 0x39: case 0x39:
case 0x3d: case 0x3d:
case 0x0d: // Objective matrix A case 0x0d: // Objective matrix A
DSP1.Op0DX = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op0DX = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op0DY = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op0DY = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op0DZ = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op0DZ = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op0D(); DSP1_Op0D();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output [0] = (uint8) (DSP1.Op0DF & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op0DF);
DSP1.output [1] = (uint8) ((DSP1.Op0DF >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op0DL);
DSP1.output [2] = (uint8) (DSP1.Op0DL & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op0DU);
DSP1.output [3] = (uint8) ((DSP1.Op0DL >> 8) & 0xFF);
DSP1.output [4] = (uint8) (DSP1.Op0DU & 0xFF);
DSP1.output [5] = (uint8) ((DSP1.Op0DU >> 8) & 0xFF);
break; break;
case 0x19: case 0x19:
case 0x1d: // Objective matrix B case 0x1d: // Objective matrix B
DSP1.Op1DX = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op1DX = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op1DY = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op1DY = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op1DZ = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op1DZ = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op1D(); DSP1_Op1D();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output[0] = (uint8) (DSP1.Op1DF & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op1DF);
DSP1.output[1] = (uint8) ((DSP1.Op1DF >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op1DL);
DSP1.output[2] = (uint8) (DSP1.Op1DL & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op1DU);
DSP1.output[3] = (uint8) ((DSP1.Op1DL >> 8) & 0xFF);
DSP1.output[4] = (uint8) (DSP1.Op1DU & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op1DU >> 8) & 0xFF);
break; break;
case 0x29: case 0x29:
case 0x2d: // Objective matrix C case 0x2d: // Objective matrix C
DSP1.Op2DX = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op2DX = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op2DY = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op2DY = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op2DZ = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op2DZ = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op2D(); DSP1_Op2D();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output[0] = (uint8) (DSP1.Op2DF & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op2DF);
DSP1.output[1] = (uint8) ((DSP1.Op2DF >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op2DL);
DSP1.output[2] = (uint8) (DSP1.Op2DL & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op2DU);
DSP1.output[3] = (uint8) ((DSP1.Op2DL >> 8) & 0xFF);
DSP1.output[4] = (uint8) (DSP1.Op2DU & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op2DU >> 8) & 0xFF);
break; break;
case 0x33: case 0x33:
case 0x03: // Subjective matrix A case 0x03: // Subjective matrix A
DSP1.Op03F = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op03F = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op03L = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op03L = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op03U = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op03U = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op03(); DSP1_Op03();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output[0] = (uint8) (DSP1.Op03X & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op03X);
DSP1.output[1] = (uint8) ((DSP1.Op03X >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op03Y);
DSP1.output[2] = (uint8) (DSP1.Op03Y & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op03Z);
DSP1.output[3] = (uint8) ((DSP1.Op03Y >> 8) & 0xFF);
DSP1.output[4] = (uint8) (DSP1.Op03Z & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op03Z >> 8) & 0xFF);
break; break;
case 0x13: // Subjective matrix B case 0x13: // Subjective matrix B
DSP1.Op13F = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op13F = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op13L = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op13L = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op13U = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op13U = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op13(); DSP1_Op13();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output[0] = (uint8) (DSP1.Op13X & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op13X);
DSP1.output[1] = (uint8) ((DSP1.Op13X >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op13Y);
DSP1.output[2] = (uint8) (DSP1.Op13Y & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op13Z);
DSP1.output[3] = (uint8) ((DSP1.Op13Y >> 8) & 0xFF);
DSP1.output[4] = (uint8) (DSP1.Op13Z & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op13Z >> 8) & 0xFF);
break; break;
case 0x23: // Subjective matrix C case 0x23: // Subjective matrix C
DSP1.Op23F = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op23F = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op23L = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op23L = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op23U = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op23U = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op23(); DSP1_Op23();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output[0] = (uint8) (DSP1.Op23X & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op23X);
DSP1.output[1] = (uint8) ((DSP1.Op23X >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op23Y);
DSP1.output[2] = (uint8) (DSP1.Op23Y & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op23Z);
DSP1.output[3] = (uint8) ((DSP1.Op23Y >> 8) & 0xFF);
DSP1.output[4] = (uint8) (DSP1.Op23Z & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op23Z >> 8) & 0xFF);
break; break;
case 0x3b: case 0x3b:
case 0x0b: case 0x0b:
DSP1.Op0BX = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op0BX = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op0BY = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op0BY = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op0BZ = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op0BZ = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op0B(); DSP1_Op0B();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = (uint8) (DSP1.Op0BS & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op0BS);
DSP1.output[1] = (uint8) ((DSP1.Op0BS >> 8) & 0xFF);
break; break;
case 0x1b: case 0x1b:
DSP1.Op1BX = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op1BX = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op1BY = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op1BY = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op1BZ = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op1BZ = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op1B(); DSP1_Op1B();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = (uint8) (DSP1.Op1BS & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op1BS);
DSP1.output[1] = (uint8) ((DSP1.Op1BS >> 8) & 0xFF);
break; break;
case 0x2b: case 0x2b:
DSP1.Op2BX = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op2BX = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1.Op2BY = (int16) (DSP1.parameters[2] | (DSP1.parameters[3] << 8)); DSP1.Op2BY = (int16) READ_WORD(&DSP1.parameters[2]);
DSP1.Op2BZ = (int16) (DSP1.parameters[4] | (DSP1.parameters[5] << 8)); DSP1.Op2BZ = (int16) READ_WORD(&DSP1.parameters[4]);
DSP1_Op2B(); DSP1_Op2B();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = (uint8) (DSP1.Op2BS & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op2BS);
DSP1.output[1] = (uint8) ((DSP1.Op2BS >> 8) & 0xFF);
break; break;
case 0x34: case 0x34:
case 0x14: case 0x14:
DSP1.Op14Zr = (int16) (DSP1.parameters[ 0] | (DSP1.parameters[ 1] << 8)); DSP1.Op14Zr = (int16) READ_WORD(&DSP1.parameters[ 0]);
DSP1.Op14Xr = (int16) (DSP1.parameters[ 2] | (DSP1.parameters[ 3] << 8)); DSP1.Op14Xr = (int16) READ_WORD(&DSP1.parameters[ 2]);
DSP1.Op14Yr = (int16) (DSP1.parameters[ 4] | (DSP1.parameters[ 5] << 8)); DSP1.Op14Yr = (int16) READ_WORD(&DSP1.parameters[ 4]);
DSP1.Op14U = (int16) (DSP1.parameters[ 6] | (DSP1.parameters[ 7] << 8)); DSP1.Op14U = (int16) READ_WORD(&DSP1.parameters[ 6]);
DSP1.Op14F = (int16) (DSP1.parameters[ 8] | (DSP1.parameters[ 9] << 8)); DSP1.Op14F = (int16) READ_WORD(&DSP1.parameters[ 8]);
DSP1.Op14L = (int16) (DSP1.parameters[10] | (DSP1.parameters[11] << 8)); DSP1.Op14L = (int16) READ_WORD(&DSP1.parameters[10]);
DSP1_Op14(); DSP1_Op14();
DSP1.out_count = 6; DSP1.out_count = 6;
DSP1.output[0] = (uint8) (DSP1.Op14Zrr & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op14Zrr);
DSP1.output[1] = (uint8) ((DSP1.Op14Zrr >> 8) & 0xFF); WRITE_WORD(&DSP1.output[2], DSP1.Op14Xrr);
DSP1.output[2] = (uint8) (DSP1.Op14Xrr & 0xFF); WRITE_WORD(&DSP1.output[4], DSP1.Op14Yrr);
DSP1.output[3] = (uint8) ((DSP1.Op14Xrr >> 8) & 0xFF);
DSP1.output[4] = (uint8) (DSP1.Op14Yrr & 0xFF);
DSP1.output[5] = (uint8) ((DSP1.Op14Yrr >> 8) & 0xFF);
break; break;
case 0x27: case 0x27:
case 0x2F: case 0x2F:
DSP1.Op2FUnknown = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op2FUnknown = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1_Op2F(); DSP1_Op2F();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = (uint8) (DSP1.Op2FSize & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op2FSize);
DSP1.output[1] = (uint8) ((DSP1.Op2FSize >> 8) & 0xFF);
break; break;
case 0x07: case 0x07:
case 0x0F: case 0x0F:
DSP1.Op0FRamsize = (int16) (DSP1.parameters[0] | (DSP1.parameters[1] << 8)); DSP1.Op0FRamsize = (int16) READ_WORD(&DSP1.parameters[0]);
DSP1_Op0F(); DSP1_Op0F();
DSP1.out_count = 2; DSP1.out_count = 2;
DSP1.output[0] = (uint8) (DSP1.Op0FPass & 0xFF); WRITE_WORD(&DSP1.output[0], DSP1.Op0FPass);
DSP1.output[1] = (uint8) ((DSP1.Op0FPass >> 8) & 0xFF);
break; break;
default: default:

View File

@ -929,12 +929,12 @@ static void DSP3_OP1E_D (int16 move, int16 *lo, int16 *hi)
static void DSP3_OP1E_D1 (int16 move, int16 *lo, int16 *hi) static void DSP3_OP1E_D1 (int16 move, int16 *lo, int16 *hi)
{ {
const uint16 HiAdd[] = static const uint16 HiAdd[] =
{ {
0x00, 0xFF, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0xFF, 0x00 0x00, 0xFF, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x01, 0x00, 0xFF, 0x00
}; };
const uint16 LoAdd[] = static const uint16 LoAdd[] =
{ {
0x00, 0x00, 0x01, 0x01, 0x00, 0xFF, 0xFF, 0x00 0x00, 0x00, 0x01, 0x01, 0x00, 0xFF, 0xFF, 0x00
}; };

View File

@ -90,7 +90,7 @@ static int32 DSP4_READ_DWORD (void)
static int16 DSP4_Inverse (int16 value) static int16 DSP4_Inverse (int16 value)
{ {
// Attention: This lookup table is not verified // Attention: This lookup table is not verified
const uint16 div_lut[64] = static const uint16 div_lut[64] =
{ {
0x0000, 0x8000, 0x4000, 0x2aaa, 0x2000, 0x1999, 0x1555, 0x1249, 0x0000, 0x8000, 0x4000, 0x2aaa, 0x2000, 0x1999, 0x1555, 0x1249,
0x1000, 0x0e38, 0x0ccc, 0x0ba2, 0x0aaa, 0x09d8, 0x0924, 0x0888, 0x1000, 0x0e38, 0x0ccc, 0x0ba2, 0x0aaa, 0x09d8, 0x0924, 0x0888,
@ -1080,7 +1080,7 @@ static void DSP4_OP09 (void)
static void DSP4_OP0A (int16 n2, int16 *o1, int16 *o2, int16 *o3, int16 *o4) static void DSP4_OP0A (int16 n2, int16 *o1, int16 *o2, int16 *o3, int16 *o4)
{ {
const uint16 OP0A_Values[16] = static const uint16 OP0A_Values[16] =
{ {
0x0000, 0x0030, 0x0060, 0x0090, 0x00c0, 0x00f0, 0x0120, 0x0150, 0x0000, 0x0030, 0x0060, 0x0090, 0x00c0, 0x00f0, 0x0120, 0x0150,
0xfe80, 0xfeb0, 0xfee0, 0xff10, 0xff40, 0xff70, 0xffa0, 0xffd0 0xfe80, 0xfeb0, 0xfee0, 0xff10, 0xff40, 0xff70, 0xffa0, 0xffd0

View File

@ -218,8 +218,8 @@ static void FxReset (struct FxInfo_s *psFxInfo)
static void fx_readRegisterSpace (void) static void fx_readRegisterSpace (void)
{ {
static uint32 avHeight[] = { 128, 160, 192, 256 }; static const uint32 avHeight[] = { 128, 160, 192, 256 };
static uint32 avMult[] = { 16, 32, 32, 64 }; static const uint32 avMult[] = { 16, 32, 32, 64 };
uint8 *p; uint8 *p;
int n; int n;
@ -228,16 +228,12 @@ static void fx_readRegisterSpace (void)
// Update R0-R15 // Update R0-R15
p = GSU.pvRegisters; p = GSU.pvRegisters;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++, p += 2)
{ GSU.avReg[i] = (uint32) READ_WORD(p);
GSU.avReg[i] = *p++;
GSU.avReg[i] += ((uint32) (*p++)) << 8;
}
// Update other registers // Update other registers
p = GSU.pvRegisters; p = GSU.pvRegisters;
GSU.vStatusReg = (uint32) p[GSU_SFR]; GSU.vStatusReg = (uint32) READ_WORD(&p[GSU_SFR]);
GSU.vStatusReg |= ((uint32) p[GSU_SFR + 1]) << 8;
GSU.vPrgBankReg = (uint32) p[GSU_PBR]; GSU.vPrgBankReg = (uint32) p[GSU_PBR];
GSU.vRomBankReg = (uint32) p[GSU_ROMBR]; GSU.vRomBankReg = (uint32) p[GSU_ROMBR];
GSU.vRamBankReg = ((uint32) p[GSU_RAMBR]) & (FX_RAM_BANKS - 1); GSU.vRamBankReg = ((uint32) p[GSU_RAMBR]) & (FX_RAM_BANKS - 1);
@ -291,11 +287,8 @@ static void fx_writeRegisterSpace (void)
uint8 *p; uint8 *p;
p = GSU.pvRegisters; p = GSU.pvRegisters;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++, p += 2)
{ WRITE_WORD(p, GSU.avReg[i]);
*p++ = (uint8) GSU.avReg[i];
*p++ = (uint8) (GSU.avReg[i] >> 8);
}
// Update status register // Update status register
if (USEX16(GSU.vZero) == 0) if (USEX16(GSU.vZero) == 0)
@ -319,13 +312,11 @@ static void fx_writeRegisterSpace (void)
CF(CY); CF(CY);
p = GSU.pvRegisters; p = GSU.pvRegisters;
p[GSU_SFR] = (uint8) GSU.vStatusReg; WRITE_WORD(&p[GSU_SFR], GSU.vStatusReg);
p[GSU_SFR + 1] = (uint8) (GSU.vStatusReg >> 8);
p[GSU_PBR] = (uint8) GSU.vPrgBankReg; p[GSU_PBR] = (uint8) GSU.vPrgBankReg;
p[GSU_ROMBR] = (uint8) GSU.vRomBankReg; p[GSU_ROMBR] = (uint8) GSU.vRomBankReg;
p[GSU_RAMBR] = (uint8) GSU.vRamBankReg; p[GSU_RAMBR] = (uint8) GSU.vRamBankReg;
p[GSU_CBR] = (uint8) GSU.vCacheBaseReg; WRITE_WORD(&p[GSU_CBR], GSU.vCacheBaseReg);
p[GSU_CBR + 1] = (uint8) (GSU.vCacheBaseReg >> 8);
//fx_restoreCache(); //fx_restoreCache();
} }

View File

@ -191,7 +191,7 @@ void S9xStartScreenRefresh (void)
memset(GFX.SubZBuffer, 0, GFX.ScreenSize); memset(GFX.SubZBuffer, 0, GFX.ScreenSize);
} }
if (++IPPU.FrameCount % Memory.ROMFramesPerSecond == 0) if (++IPPU.FrameCount == (uint32)Memory.ROMFramesPerSecond)
{ {
IPPU.DisplayedRenderedFrameCount = IPPU.RenderedFramesCount; IPPU.DisplayedRenderedFrameCount = IPPU.RenderedFramesCount;
IPPU.RenderedFramesCount = 0; IPPU.RenderedFramesCount = 0;