aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortwinaphex2015-11-05 16:37:11 +0100
committertwinaphex2015-11-05 16:37:11 +0100
commitd68763cd7cb4f7487d760a1dea17ca167d45e182 (patch)
tree74a19723b2a04d6c01f6ce59a0c0572f486ee985
parent3a892c0d1f6aef6b1785740d358d2159945a6110 (diff)
downloadsnesemu-d68763cd7cb4f7487d760a1dea17ca167d45e182.tar.gz
snesemu-d68763cd7cb4f7487d760a1dea17ca167d45e182.tar.bz2
snesemu-d68763cd7cb4f7487d760a1dea17ca167d45e182.zip
Start using stdint types
-rw-r--r--source/apu_blargg.c34
-rw-r--r--source/apu_blargg.h18
-rw-r--r--source/c4.c45
-rw-r--r--source/c4emu.c16
-rw-r--r--source/cpumacro.h16
-rw-r--r--source/dsp1.c20
-rw-r--r--source/dsp1emu.c474
-rw-r--r--source/dsp4emu.c16
-rw-r--r--source/seta010.c40
-rw-r--r--source/soundux.c42
-rw-r--r--source/soundux.h47
-rw-r--r--source/spc700.c4
-rw-r--r--source/spc7110.c58
-rw-r--r--source/spc7110.h2
14 files changed, 413 insertions, 419 deletions
diff --git a/source/apu_blargg.c b/source/apu_blargg.c
index e06f2b6..0a1d025 100644
--- a/source/apu_blargg.c
+++ b/source/apu_blargg.c
@@ -250,7 +250,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
/* Gaussian interpolation */
-static short gauss [512] =
+static int16_t gauss [512] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
@@ -291,7 +291,7 @@ static short gauss [512] =
static INLINE int dsp_interpolate( dsp_voice_t *v )
{
int offset, out, *in;
- short *fwd, *rev;
+ int16_t *fwd, *rev;
/* Make pointers into gaussian based on fractional position between samples */
offset = v->interp_pos >> 4 & 0xFF;
@@ -871,7 +871,7 @@ static INLINE void dsp_echo_26 (void)
static INLINE void dsp_echo_27 (void)
{
int l, r;
- short *out;
+ int16_t *out;
l = dsp_m.t_main_out [0];
ECHO_OUTPUT(r, 1);
@@ -1113,7 +1113,7 @@ loop:
/* Sets destination for output samples. If out is NULL or out_size is 0,
doesn't generate any. */
-static void dsp_set_output( short * out, int size )
+static void dsp_set_output( int16_t * out, int size )
{
if ( !out )
{
@@ -2833,7 +2833,7 @@ static void spc_end_frame( int end_time )
/* Save any extra samples beyond what should be generated */
if ( m.buf_begin )
{
- short *main_end, *dsp_end, *out, *in;
+ int16_t *main_end, *dsp_end, *out, *in;
/* Get end pointers */
main_end = m.buf_end; /* end of data written to buf */
dsp_end = dsp_m.out; /* end of data written to dsp.extra() */
@@ -2865,7 +2865,7 @@ uint8_t * spc_apuram()
static void spc_reset_buffer(void)
{
- short *out;
+ int16_t *out;
/* Start with half extra buffer of silence */
out = m.extra_buf;
while ( out < &m.extra_buf [EXTRA_SIZE_DIV_2] )
@@ -3068,7 +3068,7 @@ static int buffer_size;
static int lag_master = 0;
static int lag = 0;
-static short *landing_buffer = NULL;
+static int16_t *landing_buffer = NULL;
static bool resampler = false;
@@ -3099,7 +3099,7 @@ static int r_left[4], r_right[4];
#define RESAMPLER_MIN(a, b) ((a) < (b) ? (a) : (b))
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
-#define SHORT_CLAMP(n) ((short) CLAMP((n), -32768, 32767))
+#define SHORT_CLAMP(n) ((int16_t) CLAMP((n), -32768, 32767))
static INLINE int32_t hermite (int32_t mu1, int32_t a, int32_t b, int32_t c, int32_t d)
{
@@ -3136,13 +3136,13 @@ static void resampler_time_ratio(double ratio)
resampler_clear();
}
-static void resampler_read(short *data, int num_samples)
+static void resampler_read(int16_t *data, int num_samples)
{
int i_position, o_position, consumed;
- short *internal_buffer;
+ int16_t *internal_buffer;
i_position = rb_start >> 1;
- internal_buffer = (short *)rb_buffer;
+ internal_buffer = (int16_t *)rb_buffer;
o_position = 0;
consumed = 0;
@@ -3207,7 +3207,7 @@ static void resampler_new(int num_samples)
resampler_clear();
}
-static INLINE bool resampler_push(short *src, int num_samples)
+static INLINE bool resampler_push(int16_t *src, int num_samples)
{
int bytes, end, first_write_size;
unsigned char *src_ring;
@@ -3248,7 +3248,7 @@ static INLINE void resampler_resize (int num_samples)
APU
***********************************************************************************/
-bool S9xMixSamples (short *buffer, unsigned sample_count)
+bool S9xMixSamples (int16_t *buffer, unsigned sample_count)
{
if (AVAIL() >= (sample_count + lag))
{
@@ -3275,9 +3275,9 @@ int S9xGetSampleCount (void)
/* Sets destination for output samples */
-static void spc_set_output( short* out, int size )
+static void spc_set_output( int16_t* out, int size )
{
- short *out_end, *in;
+ int16_t *out_end, *in;
out_end = out + size;
m.buf_begin = out;
@@ -3378,11 +3378,11 @@ bool S9xInitSound (int buffer_ms, int lag_ms)
if (landing_buffer)
free(landing_buffer);
- landing_buffer = (short*)malloc(buffer_size * 2);
+ landing_buffer = (int16_t*)malloc(buffer_size * 2);
if (!landing_buffer)
return (false);
- /* The resampler and spc unit use samples (16-bit short) as
+ /* The resampler and spc unit use samples (16-bit int16_t) as
arguments. Use 2x in the resampler for buffer leveling with SoundSync */
if (!resampler)
diff --git a/source/apu_blargg.h b/source/apu_blargg.h
index ebf50b0..adcf731 100644
--- a/source/apu_blargg.h
+++ b/source/apu_blargg.h
@@ -339,10 +339,10 @@ typedef struct
/* non-emulation state */
uint8_t* ram; /* 64K shared RAM between DSP and SMP */
- short* out;
- short* out_end;
- short* out_begin;
- short extra [EXTRA_SIZE];
+ int16_t* out;
+ int16_t* out_end;
+ int16_t* out_begin;
+ int16_t extra [EXTRA_SIZE];
int rom_enabled;
uint8_t *rom, *hi_ram;
@@ -434,10 +434,10 @@ typedef struct
int tempo;
int extra_clocks;
- short* buf_begin;
- short* buf_end;
- short* extra_pos;
- short extra_buf [EXTRA_SIZE];
+ int16_t* buf_begin;
+ int16_t* buf_end;
+ int16_t* extra_pos;
+ int16_t extra_buf [EXTRA_SIZE];
int rom_enabled;
uint8_t rom [ROM_SIZE];
@@ -483,7 +483,7 @@ bool S9xSyncSound (void);
int S9xGetSampleCount (void);
void S9xFinalizeSamples (void);
void S9xClearSamples (void);
-bool S9xMixSamples (short * buffer, unsigned sample_count);
+bool S9xMixSamples (int16_t * buffer, unsigned sample_count);
void S9xSetSamplesAvailableCallback (apu_callback);
#endif // APU_BLARGG_H
diff --git a/source/c4.c b/source/c4.c
index 45cde18..43e561d 100644
--- a/source/c4.c
+++ b/source/c4.c
@@ -91,14 +91,13 @@
#include "c4.h"
#include "memmap.h"
-
-short C4WFXVal;
-short C4WFYVal;
-short C4WFZVal;
-short C4WFX2Val;
-short C4WFY2Val;
-short C4WFDist;
-short C4WFScale;
+int16_t C4WFXVal;
+int16_t C4WFYVal;
+int16_t C4WFZVal;
+int16_t C4WFX2Val;
+int16_t C4WFY2Val;
+int16_t C4WFDist;
+int16_t C4WFScale;
static double tanval;
static double c4x, c4y, c4z;
@@ -126,8 +125,8 @@ void C4TransfWireFrame()
c4y = c4x2 * sin(tanval) + c4y2 * cos(tanval);
// Scale
- C4WFXVal = (short)(c4x * (double)C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
- C4WFYVal = (short)(c4y * (double)C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
+ C4WFXVal = (int16_t)(c4x * (double)C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
+ C4WFYVal = (int16_t)(c4y * (double)C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
}
void C4TransfWireFrame2()
@@ -152,8 +151,8 @@ void C4TransfWireFrame2()
c4y = c4x2 * sin(tanval) + c4y2 * cos(tanval);
// Scale
- C4WFXVal = (short)(c4x * (double)C4WFScale / 0x100);
- C4WFYVal = (short)(c4y * (double)C4WFScale / 0x100);
+ C4WFXVal = (int16_t)(c4x * (double)C4WFScale / 0x100);
+ C4WFYVal = (int16_t)(c4y * (double)C4WFScale / 0x100);
}
void C4CalcWireFrame()
@@ -163,7 +162,7 @@ void C4CalcWireFrame()
if (abs(C4WFXVal) > abs(C4WFYVal))
{
C4WFDist = abs(C4WFXVal) + 1;
- C4WFYVal = (short)(256 * (double) C4WFYVal / abs(C4WFXVal));
+ C4WFYVal = (int16_t)(256 * (double) C4WFYVal / abs(C4WFXVal));
if (C4WFXVal < 0)
C4WFXVal = -256;
else
@@ -174,7 +173,7 @@ void C4CalcWireFrame()
if (C4WFYVal != 0)
{
C4WFDist = abs(C4WFYVal) + 1;
- C4WFXVal = (short)(256 * (double)C4WFXVal / abs(C4WFYVal));
+ C4WFXVal = (int16_t)(256 * (double)C4WFXVal / abs(C4WFYVal));
if (C4WFYVal < 0)
C4WFYVal = -256;
else
@@ -185,11 +184,11 @@ void C4CalcWireFrame()
}
}
-short C41FXVal;
-short C41FYVal;
-short C41FAngleRes;
-short C41FDist;
-short C41FDistVal;
+int16_t C41FXVal;
+int16_t C41FYVal;
+int16_t C41FAngleRes;
+int16_t C41FDist;
+int16_t C41FDistVal;
void C4Op1F()
{
@@ -203,7 +202,7 @@ void C4Op1F()
else
{
tanval = (double) C41FYVal / C41FXVal;
- C41FAngleRes = (short)(atan(tanval) / (3.141592675 * 2) * 512);
+ C41FAngleRes = (int16_t)(atan(tanval) / (3.141592675 * 2) * 512);
if (C41FXVal < 0)
C41FAngleRes += 0x100;
C41FAngleRes &= 0x1FF;
@@ -213,15 +212,15 @@ void C4Op1F()
void C4Op15()
{
tanval = sqrt((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal);
- C41FDist = (short) tanval;
+ C41FDist = (int16_t) tanval;
}
void C4Op0D()
{
tanval = sqrt((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal);
tanval = C41FDistVal / tanval;
- C41FYVal = (short)(C41FYVal * tanval * 0.99);
- C41FXVal = (short)(C41FXVal * tanval * 0.98);
+ C41FYVal = (int16_t)(C41FYVal * tanval * 0.99);
+ C41FXVal = (int16_t)(C41FXVal * tanval * 0.98);
}
#ifdef ZSNES_C4
diff --git a/source/c4emu.c b/source/c4emu.c
index 517df2e..c2412e1 100644
--- a/source/c4emu.c
+++ b/source/c4emu.c
@@ -344,8 +344,8 @@ static void C4DrawLine(int32_t X1, int32_t Y1, int16_t Z1,
int32_t X2, int32_t Y2, int16_t Z2, uint8_t Color)
{
// Transform coordinates
- C4WFXVal = (short)X1;
- C4WFYVal = (short)Y1;
+ C4WFXVal = (int16_t)X1;
+ C4WFYVal = (int16_t)Y1;
C4WFZVal = Z1;
C4WFScale = Memory.C4RAM[0x1f90];
C4WFX2Val = Memory.C4RAM[0x1f86];
@@ -355,18 +355,18 @@ static void C4DrawLine(int32_t X1, int32_t Y1, int16_t Z1,
X1 = (C4WFXVal + 48) << 8;
Y1 = (C4WFYVal + 48) << 8;
- C4WFXVal = (short)X2;
- C4WFYVal = (short)Y2;
+ C4WFXVal = (int16_t)X2;
+ C4WFYVal = (int16_t)Y2;
C4WFZVal = Z2;
C4TransfWireFrame2();
X2 = (C4WFXVal + 48) << 8;
Y2 = (C4WFYVal + 48) << 8;
// get line info
- C4WFXVal = (short)(X1 >> 8);
- C4WFYVal = (short)(Y1 >> 8);
- C4WFX2Val = (short)(X2 >> 8);
- C4WFY2Val = (short)(Y2 >> 8);
+ C4WFXVal = (int16_t)(X1 >> 8);
+ C4WFYVal = (int16_t)(Y1 >> 8);
+ C4WFX2Val = (int16_t)(X2 >> 8);
+ C4WFY2Val = (int16_t)(Y2 >> 8);
C4CalcWireFrame();
X2 = (int16_t)C4WFXVal;
Y2 = (int16_t)C4WFYVal;
diff --git a/source/cpumacro.h b/source/cpumacro.h
index 6975b04..986177f 100644
--- a/source/cpumacro.h
+++ b/source/cpumacro.h
@@ -306,8 +306,8 @@ static void CMP16(long Addr)
static void CMP8(long Addr)
{
- int16_t Int16 = (short) ICPU.Registers.AL -
- (short) S9xGetByte(Addr);
+ int16_t Int16 = (int16_t) ICPU.Registers.AL -
+ (int16_t) S9xGetByte(Addr);
ICPU._Carry = Int16 >= 0;
SetZN8((uint8_t) Int16);
}
@@ -322,8 +322,8 @@ static void CMX16(long Addr)
static void CMX8(long Addr)
{
- int16_t Int16 = (short) ICPU.Registers.XL -
- (short) S9xGetByte(Addr);
+ int16_t Int16 = (int16_t) ICPU.Registers.XL -
+ (int16_t) S9xGetByte(Addr);
ICPU._Carry = Int16 >= 0;
SetZN8((uint8_t) Int16);
}
@@ -338,8 +338,8 @@ static void CMY16(long Addr)
static void CMY8(long Addr)
{
- int16_t Int16 = (short) ICPU.Registers.YL -
- (short) S9xGetByte(Addr);
+ int16_t Int16 = (int16_t) ICPU.Registers.YL -
+ (int16_t) S9xGetByte(Addr);
ICPU._Carry = Int16 >= 0;
SetZN8((uint8_t) Int16);
}
@@ -742,8 +742,8 @@ static void SBC8(long Addr)
}
else
{
- int16_t Int16 = (short) ICPU.Registers.AL - (short) Work8 +
- (short) CheckCarry() - 1;
+ int16_t Int16 = (int16_t) ICPU.Registers.AL - (int16_t) Work8 +
+ (int16_t) CheckCarry() - 1;
ICPU._Carry = Int16 >= 0;
if ((ICPU.Registers.AL ^ Work8) &
diff --git a/source/dsp1.c b/source/dsp1.c
index 12a3327..e917cab 100644
--- a/source/dsp1.c
+++ b/source/dsp1.c
@@ -476,13 +476,13 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
case 0x22:
case 0x12:
case 0x02: // Parameter (Projection)
- Op02FX = (short)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
- Op02FY = (short)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
- Op02FZ = (short)(DSP1.parameters [4] | (DSP1.parameters[5] << 8));
- Op02LFE = (short)(DSP1.parameters [6] | (DSP1.parameters[7] << 8));
- Op02LES = (short)(DSP1.parameters [8] | (DSP1.parameters[9] << 8));
- Op02AAS = (unsigned short)(DSP1.parameters [10] | (DSP1.parameters[11] << 8));
- Op02AZS = (unsigned short)(DSP1.parameters [12] | (DSP1.parameters[13] << 8));
+ Op02FX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
+ Op02FY = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8));
+ Op02FZ = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8));
+ Op02LFE = (int16_t)(DSP1.parameters [6] | (DSP1.parameters[7] << 8));
+ Op02LES = (int16_t)(DSP1.parameters [8] | (DSP1.parameters[9] << 8));
+ Op02AAS = (uint16_t)(DSP1.parameters [10] | (DSP1.parameters[11] << 8));
+ Op02AZS = (uint16_t)(DSP1.parameters [12] | (DSP1.parameters[13] << 8));
DSPOp02();
@@ -501,7 +501,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
case 0x2a: //1a Mirror
case 0x1a: // Raster mode 7 matrix data
case 0x0a:
- Op0AVS = (short)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
+ Op0AVS = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8));
DSPOp0A();
@@ -1479,8 +1479,8 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
int16_t in3a = DSP4_READ_WORD(4);
int16_t out1a, out2a;
- out1a = (short)0xff40;
- out2a = (short)0x00c0;
+ out1a = (int16_t)0xff40;
+ out2a = (int16_t)0x00c0;
DSP4.out_count = 8;
diff --git a/source/dsp1emu.c b/source/dsp1emu.c
index 8bf3617..8840fb5 100644
--- a/source/dsp1emu.c
+++ b/source/dsp1emu.c
@@ -75,7 +75,7 @@ void Stop_Log(void)
#endif
-const unsigned short DSP1ROM[1024] =
+const uint16_t DSP1ROM[1024] =
{
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -236,13 +236,13 @@ double Atan(double x)
* C4 C code *
\***************************************************************************/
-short C4WFXVal;
-short C4WFYVal;
-short C4WFZVal;
-short C4WFX2Val;
-short C4WFY2Val;
-short C4WFDist;
-short C4WFScale;
+int16_t C4WFXVal;
+int16_t C4WFYVal;
+int16_t C4WFZVal;
+int16_t C4WFX2Val;
+int16_t C4WFY2Val;
+int16_t C4WFDist;
+int16_t C4WFScale;
double tanval;
double c4x, c4y, c4z;
double c4x2, c4y2, c4z2;
@@ -269,8 +269,8 @@ void C4TransfWireFrame()
c4y = c4x2 * sin(tanval) + c4y2 * cos(tanval);
// Scale
- C4WFXVal = (short)(c4x * C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
- C4WFYVal = (short)(c4y * C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
+ C4WFXVal = (int16_t)(c4x * C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
+ C4WFYVal = (int16_t)(c4y * C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
}
void C4TransfWireFrame2()
@@ -295,8 +295,8 @@ void C4TransfWireFrame2()
c4y = c4x2 * sin(tanval) + c4y2 * cos(tanval);
// Scale
- C4WFXVal = (short)(c4x * C4WFScale / 0x100);
- C4WFYVal = (short)(c4y * C4WFScale / 0x100);
+ C4WFXVal = (int16_t)(c4x * C4WFScale / 0x100);
+ C4WFYVal = (int16_t)(c4y * C4WFScale / 0x100);
}
void C4CalcWireFrame()
@@ -320,11 +320,11 @@ void C4CalcWireFrame()
else C4WFDist = 0;
}
-short C41FXVal;
-short C41FYVal;
-short C41FAngleRes;
-short C41FDist;
-short C41FDistVal;
+int16_t C41FXVal;
+int16_t C41FYVal;
+int16_t C41FAngleRes;
+int16_t C41FDist;
+int16_t C41FDistVal;
void C4Op1F()
{
@@ -336,7 +336,7 @@ void C4Op1F()
else
{
tanval = ((double)C41FYVal) / ((double)C41FXVal);
- C41FAngleRes = (short)(atan(tanval) / (PI * 2) * 512);
+ C41FAngleRes = (int16_t)(atan(tanval) / (PI * 2) * 512);
C41FAngleRes = C41FAngleRes;
if (C41FXVal < 0) C41FAngleRes += 0x100;
C41FAngleRes &= 0x1FF;
@@ -347,7 +347,7 @@ void C4Op15()
{
tanval = sqrt(((double)C41FYVal) * ((double)C41FYVal) + ((double)C41FXVal) *
((double)C41FXVal));
- C41FDist = (short)tanval;
+ C41FDist = (int16_t)tanval;
}
void C4Op0D()
@@ -355,8 +355,8 @@ void C4Op0D()
tanval = sqrt(((double)C41FYVal) * ((double)C41FYVal) + ((double)C41FXVal) *
((double)C41FXVal));
tanval = (double)C41FDistVal / tanval;
- C41FYVal = (short)(((double)C41FYVal * tanval) * 0.99);
- C41FXVal = (short)(((double)C41FXVal * tanval) * 0.98);
+ C41FYVal = (int16_t)(((double)C41FYVal * tanval) * 0.99);
+ C41FXVal = (int16_t)(((double)C41FXVal * tanval) * 0.98);
}
#endif
@@ -380,9 +380,9 @@ void InitDSP(void)
}
-short Op00Multiplicand;
-short Op00Multiplier;
-short Op00Result;
+int16_t Op00Multiplicand;
+int16_t Op00Multiplier;
+int16_t Op00Result;
void DSPOp00()
{
@@ -394,9 +394,9 @@ void DSPOp00()
#endif
}
-short Op20Multiplicand;
-short Op20Multiplier;
-short Op20Result;
+int16_t Op20Multiplicand;
+int16_t Op20Multiplier;
+int16_t Op20Result;
void DSPOp20()
{
@@ -409,13 +409,13 @@ void DSPOp20()
#endif
}
-signed short Op10Coefficient;
-signed short Op10Exponent;
-signed short Op10CoefficientR;
-signed short Op10ExponentR;
+int16_t Op10Coefficient;
+int16_t Op10Exponent;
+int16_t Op10CoefficientR;
+int16_t Op10ExponentR;
-void DSP1_Inverse(short Coefficient, short Exponent, short* iCoefficient,
- short* iExponent)
+void DSP1_Inverse(int16_t Coefficient, int16_t Exponent, int16_t* iCoefficient,
+ int16_t* iExponent)
{
// Step One: Division by Zero
if (Coefficient == 0x0000)
@@ -425,7 +425,7 @@ void DSP1_Inverse(short Coefficient, short Exponent, short* iCoefficient,
}
else
{
- short Sign = 1;
+ int16_t Sign = 1;
// Step Two: Remove Sign
if (Coefficient < 0)
@@ -453,7 +453,7 @@ void DSP1_Inverse(short Coefficient, short Exponent, short* iCoefficient,
else
{
// Step Five: Initial Guess
- short i = DSP1ROM[((Coefficient - 0x4000) >> 7) + 0x0065];
+ int16_t i = DSP1ROM[((Coefficient - 0x4000) >> 7) + 0x0065];
// Step Six: Iterate "estimated" Newton's Method
i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1;
@@ -475,12 +475,12 @@ void DSPOp10()
#endif
}
-short Op04Angle;
-short Op04Radius;
-short Op04Sin;
-short Op04Cos;
+int16_t Op04Angle;
+int16_t Op04Radius;
+int16_t Op04Sin;
+int16_t Op04Cos;
-const short DSP1_MulTable[256] =
+const int16_t DSP1_MulTable[256] =
{
0x0000, 0x0003, 0x0006, 0x0009, 0x000c, 0x000f, 0x0012, 0x0015,
0x0019, 0x001c, 0x001f, 0x0022, 0x0025, 0x0028, 0x002b, 0x002f,
@@ -516,7 +516,7 @@ const short DSP1_MulTable[256] =
0x030b, 0x030e, 0x0311, 0x0314, 0x0317, 0x031a, 0x031d, 0x0321
};
-const short DSP1_SinTable[256] =
+const int16_t DSP1_SinTable[256] =
{
0x0000, 0x0324, 0x0647, 0x096a, 0x0c8b, 0x0fab, 0x12c8, 0x15e2,
0x18f8, 0x1c0b, 0x1f19, 0x2223, 0x2528, 0x2826, 0x2b1f, 0x2e11,
@@ -552,7 +552,7 @@ const short DSP1_SinTable[256] =
-0x18f8, -0x15e2, -0x12c8, -0x0fab, -0x0c8b, -0x096a, -0x0647, -0x0324
};
-short DSP1_Sin(short Angle)
+int16_t DSP1_Sin(int16_t Angle)
{
if (Angle < 0)
{
@@ -562,10 +562,10 @@ short DSP1_Sin(short Angle)
int S = DSP1_SinTable[Angle >> 8] + (DSP1_MulTable[Angle & 0xff] *
DSP1_SinTable[0x40 + (Angle >> 8)] >> 15);
if (S > 32767) S = 32767;
- return (short) S;
+ return (int16_t) S;
}
-short DSP1_Cos(short Angle)
+int16_t DSP1_Cos(int16_t Angle)
{
if (Angle < 0)
{
@@ -575,13 +575,13 @@ short DSP1_Cos(short Angle)
int S = DSP1_SinTable[0x40 + (Angle >> 8)] - (DSP1_MulTable[Angle & 0xff] *
DSP1_SinTable[Angle >> 8] >> 15);
if (S < -32768) S = -32767;
- return (short) S;
+ return (int16_t) S;
}
-void DSP1_Normalize(short m, short* Coefficient, short* Exponent)
+void DSP1_Normalize(int16_t m, int16_t* Coefficient, int16_t* Exponent)
{
- short i = 0x4000;
- short e = 0;
+ int16_t i = 0x4000;
+ int16_t e = 0;
if (m < 0)
while ((m & i) && i)
@@ -604,12 +604,12 @@ void DSP1_Normalize(short m, short* Coefficient, short* Exponent)
*Exponent -= e;
}
-void DSP1_NormalizeDouble(int Product, short* Coefficient, short* Exponent)
+void DSP1_NormalizeDouble(int Product, int16_t* Coefficient, int16_t* Exponent)
{
- short n = Product & 0x7fff;
- short m = Product >> 15;
- short i = 0x4000;
- short e = 0;
+ int16_t n = Product & 0x7fff;
+ int16_t m = Product >> 15;
+ int16_t i = 0x4000;
+ int16_t e = 0;
if (m < 0)
while ((m & i) && i)
@@ -659,7 +659,7 @@ void DSP1_NormalizeDouble(int Product, short* Coefficient, short* Exponent)
*Exponent = e;
}
-short DSP1_Truncate(short C, short E)
+int16_t DSP1_Truncate(int16_t C, int16_t E)
{
if (E > 0)
{
@@ -679,11 +679,11 @@ void DSPOp04()
Op04Cos = DSP1_Cos(Op04Angle) * Op04Radius >> 15;
}
-short Op0CA;
-short Op0CX1;
-short Op0CY1;
-short Op0CX2;
-short Op0CY2;
+int16_t Op0CA;
+int16_t Op0CX1;
+int16_t Op0CY1;
+int16_t Op0CX2;
+int16_t Op0CY2;
void DSPOp0C()
{
@@ -691,40 +691,40 @@ void DSPOp0C()
Op0CY2 = (Op0CY1 * DSP1_Cos(Op0CA) >> 15) - (Op0CX1 * DSP1_Sin(Op0CA) >> 15);
}
-short CentreX;
-short CentreY;
-short VOffset;
+int16_t CentreX;
+int16_t CentreY;
+int16_t VOffset;
-short VPlane_C;
-short VPlane_E;
+int16_t VPlane_C;
+int16_t VPlane_E;
// Azimuth and Zenith angles
-short SinAas;
-short CosAas;
-short SinAzs;
-short CosAzs;
+int16_t SinAas;
+int16_t CosAas;
+int16_t SinAzs;
+int16_t CosAzs;
// Clipped Zenith angle
-short SinAZS;
-short CosAZS;
-short SecAZS_C1;
-short SecAZS_E1;
-short SecAZS_C2;
-short SecAZS_E2;
-
-const short MaxAZS_Exp[16] =
+int16_t SinAZS;
+int16_t CosAZS;
+int16_t SecAZS_C1;
+int16_t SecAZS_E1;
+int16_t SecAZS_C2;
+int16_t SecAZS_E2;
+
+const int16_t MaxAZS_Exp[16] =
{
0x38b4, 0x38b7, 0x38ba, 0x38be, 0x38c0, 0x38c4, 0x38c7, 0x38ca,
0x38ce, 0x38d0, 0x38d4, 0x38d7, 0x38da, 0x38dd, 0x38e0, 0x38e4
};
-void DSP1_Parameter(short Fx, short Fy, short Fz, short Lfe, short Les,
- short Aas, short Azs, short* Vof, short* Vva, short* Cx, short* Cy)
+void DSP1_Parameter(int16_t Fx, int16_t Fy, int16_t Fz, int16_t Lfe, int16_t Les,
+ int16_t Aas, int16_t Azs, int16_t* Vof, int16_t* Vva, int16_t* Cx, int16_t* Cy)
{
- short CSec, C, E;
+ int16_t CSec, C, E;
// Copy Zenith angle for clipping
- short AZS = Azs;
+ int16_t AZS = Azs;
// Store Sin and Cos of Azimuth and Zenith angles
SinAas = DSP1_Sin(Aas);
@@ -743,7 +743,7 @@ void DSP1_Parameter(short Fx, short Fy, short Fz, short Lfe, short Les,
VPlane_E = E;
// Determine clip boundary and clip Zenith angle if necessary
- short MaxAZS = MaxAZS_Exp[-E];
+ int16_t MaxAZS = MaxAZS_Exp[-E];
if (AZS < 0)
{
@@ -780,7 +780,7 @@ void DSP1_Parameter(short Fx, short Fy, short Fz, short Lfe, short Les,
C = Azs - MaxAZS;
if (C >= 0) C--;
- short Aux = ~(C << 2);
+ int16_t Aux = ~(C << 2);
C = Aux * DSP1ROM[0x0328] >> 15;
C = (C * Aux >> 15) + DSP1ROM[0x0327];
@@ -809,9 +809,9 @@ void DSP1_Parameter(short Fx, short Fy, short Fz, short Lfe, short Les,
DSP1_Inverse(CosAZS, 0, &SecAZS_C2, &SecAZS_E2);
}
-void DSP1_Raster(short Vs, short* An, short* Bn, short* Cn, short* Dn)
+void DSP1_Raster(int16_t Vs, int16_t* An, int16_t* Bn, int16_t* Cn, int16_t* Dn)
{
- short C, E, C1, E1;
+ int16_t C, E, C1, E1;
DSP1_Inverse((Vs * SinAzs >> 15) + VOffset, 7, &C, &E);
E += VPlane_E;
@@ -834,17 +834,17 @@ void DSP1_Raster(short Vs, short* An, short* Bn, short* Cn, short* Dn)
*Dn = C * CosAas >> 15;
}
-short Op02FX;
-short Op02FY;
-short Op02FZ;
-short Op02LFE;
-short Op02LES;
-short Op02AAS;
-short Op02AZS;
-short Op02VOF;
-short Op02VVA;
-short Op02CX;
-short Op02CY;
+int16_t Op02FX;
+int16_t Op02FY;
+int16_t Op02FZ;
+int16_t Op02LFE;
+int16_t Op02LES;
+int16_t Op02AAS;
+int16_t Op02AZS;
+int16_t Op02VOF;
+int16_t Op02VVA;
+int16_t Op02CX;
+int16_t Op02CY;
void DSPOp02()
{
@@ -852,11 +852,11 @@ void DSPOp02()
&Op02VOF, &Op02VVA, &Op02CX, &Op02CY);
}
-short Op0AVS;
-short Op0AA;
-short Op0AB;
-short Op0AC;
-short Op0AD;
+int16_t Op0AVS;
+int16_t Op0AA;
+int16_t Op0AB;
+int16_t Op0AC;
+int16_t Op0AD;
void DSPOp0A()
{
@@ -864,12 +864,12 @@ void DSPOp0A()
Op0AVS++;
}
-short Op06X;
-short Op06Y;
-short Op06Z;
-short Op06H;
-short Op06V;
-unsigned short Op06S;
+int16_t Op06X;
+int16_t Op06Y;
+int16_t Op06Z;
+int16_t Op06H;
+int16_t Op06V;
+uint16_t Op06S;
double ObjPX;
double ObjPY;
@@ -915,8 +915,8 @@ void DSPOp06()
if (ObjPZ2 < 0)
{
double d;
- Op06H = (short)(-ObjPX2 * Op02LES / -(ObjPZ2)); //-ObjPX2*256/-ObjPZ2;
- Op06V = (short)(-ObjPY2 * Op02LES / -(ObjPZ2)); //-ObjPY2*256/-ObjPZ2;
+ Op06H = (int16_t)(-ObjPX2 * Op02LES / -(ObjPZ2)); //-ObjPX2*256/-ObjPZ2;
+ Op06V = (int16_t)(-ObjPY2 * Op02LES / -(ObjPZ2)); //-ObjPY2*256/-ObjPZ2;
d = (double)Op02LES;
d *= 256.0;
d /= (-ObjPZ2);
@@ -924,9 +924,9 @@ void DSPOp06()
d = 65535.0;
else if (d < 0.0)
d = 0.0;
- Op06S = (unsigned short)d;
- //Op06S=(unsigned short)(256*(double)Op02LES/-ObjPZ2);
- //Op06S=(unsigned short)((double)(256.0*((double)Op02LES)/(-ObjPZ2)));
+ Op06S = (uint16_t)d;
+ //Op06S=(uint16_t)(256*(double)Op02LES/-ObjPZ2);
+ //Op06S=(uint16_t)((double)(256.0*((double)Op02LES)/(-ObjPZ2)));
}
else
{
@@ -975,8 +975,8 @@ void DSPOp06()
if (ObjPZ2 < 0)
{
- Op06H = (short)(-ObjPX2 * Op02LES / -(ObjPZ2)); //-ObjPX2*256/-ObjPZ2;
- Op06V = (short)(-ObjPY2 * Op02LES / -(ObjPZ2)); //-ObjPY2*256/-ObjPZ2;
+ Op06H = (int16_t)(-ObjPX2 * Op02LES / -(ObjPZ2)); //-ObjPX2*256/-ObjPZ2;
+ Op06V = (int16_t)(-ObjPY2 * Op02LES / -(ObjPZ2)); //-ObjPY2*256/-ObjPZ2;
double d = (double)Op02LES;
d *= 256.0;
d /= (-ObjPZ2);
@@ -984,8 +984,8 @@ void DSPOp06()
d = 65535.0;
else if (d < 0.0)
d = 0.0;
- Op06S = (unsigned short)d;
- // Op06S=(unsigned short)(256*(double)Op02LES/-ObjPZ2);
+ Op06S = (uint16_t)d;
+ // Op06S=(uint16_t)(256*(double)Op02LES/-ObjPZ2);
}
else
{
@@ -1002,31 +1002,31 @@ void DSPOp06()
#endif
-short matrixC[3][3];
-short matrixB[3][3];
-short matrixA[3][3];
+int16_t matrixC[3][3];
+int16_t matrixB[3][3];
+int16_t matrixA[3][3];
-short Op01m;
-short Op01Zr;
-short Op01Xr;
-short Op01Yr;
-short Op11m;
-short Op11Zr;
-short Op11Xr;
-short Op11Yr;
-short Op21m;
-short Op21Zr;
-short Op21Xr;
-short Op21Yr;
+int16_t Op01m;
+int16_t Op01Zr;
+int16_t Op01Xr;
+int16_t Op01Yr;
+int16_t Op11m;
+int16_t Op11Zr;
+int16_t Op11Xr;
+int16_t Op11Yr;
+int16_t Op21m;
+int16_t Op21Zr;
+int16_t Op21Xr;
+int16_t Op21Yr;
void DSPOp01()
{
- short SinAz = DSP1_Sin(Op01Zr);
- short CosAz = DSP1_Cos(Op01Zr);
- short SinAy = DSP1_Sin(Op01Yr);
- short CosAy = DSP1_Cos(Op01Yr);
- short SinAx = DSP1_Sin(Op01Xr);
- short CosAx = DSP1_Cos(Op01Xr);
+ int16_t SinAz = DSP1_Sin(Op01Zr);
+ int16_t CosAz = DSP1_Cos(Op01Zr);
+ int16_t SinAy = DSP1_Sin(Op01Yr);
+ int16_t CosAy = DSP1_Cos(Op01Yr);
+ int16_t SinAx = DSP1_Sin(Op01Xr);
+ int16_t CosAx = DSP1_Cos(Op01Xr);
Op01m >>= 1;
@@ -1049,12 +1049,12 @@ void DSPOp01()
void DSPOp11()
{
- short SinAz = DSP1_Sin(Op11Zr);
- short CosAz = DSP1_Cos(Op11Zr);
- short SinAy = DSP1_Sin(Op11Yr);
- short CosAy = DSP1_Cos(Op11Yr);
- short SinAx = DSP1_Sin(Op11Xr);
- short CosAx = DSP1_Cos(Op11Xr);
+ int16_t SinAz = DSP1_Sin(Op11Zr);
+ int16_t CosAz = DSP1_Cos(Op11Zr);
+ int16_t SinAy = DSP1_Sin(Op11Yr);
+ int16_t CosAy = DSP1_Cos(Op11Yr);
+ int16_t SinAx = DSP1_Sin(Op11Xr);
+ int16_t CosAx = DSP1_Cos(Op11Xr);
Op11m >>= 1;
@@ -1077,12 +1077,12 @@ void DSPOp11()
void DSPOp21()
{
- short SinAz = DSP1_Sin(Op21Zr);
- short CosAz = DSP1_Cos(Op21Zr);
- short SinAy = DSP1_Sin(Op21Yr);
- short CosAy = DSP1_Cos(Op21Yr);
- short SinAx = DSP1_Sin(Op21Xr);
- short CosAx = DSP1_Cos(Op21Xr);
+ int16_t SinAz = DSP1_Sin(Op21Zr);
+ int16_t CosAz = DSP1_Cos(Op21Zr);
+ int16_t SinAy = DSP1_Sin(Op21Yr);
+ int16_t CosAy = DSP1_Cos(Op21Yr);
+ int16_t SinAx = DSP1_Sin(Op21Xr);
+ int16_t CosAx = DSP1_Cos(Op21Xr);
Op21m >>= 1;
@@ -1103,24 +1103,24 @@ void DSPOp21()
matrixC[2][2] = (Op21m * CosAx >> 15) * CosAy >> 15;
}
-short Op0DX;
-short Op0DY;
-short Op0DZ;
-short Op0DF;
-short Op0DL;
-short Op0DU;
-short Op1DX;
-short Op1DY;
-short Op1DZ;
-short Op1DF;
-short Op1DL;
-short Op1DU;
-short Op2DX;
-short Op2DY;
-short Op2DZ;
-short Op2DF;
-short Op2DL;
-short Op2DU;
+int16_t Op0DX;
+int16_t Op0DY;
+int16_t Op0DZ;
+int16_t Op0DF;
+int16_t Op0DL;
+int16_t Op0DU;
+int16_t Op1DX;
+int16_t Op1DY;
+int16_t Op1DZ;
+int16_t Op1DF;
+int16_t Op1DL;
+int16_t Op1DU;
+int16_t Op2DX;
+int16_t Op2DY;
+int16_t Op2DZ;
+int16_t Op2DF;
+int16_t Op2DL;
+int16_t Op2DU;
void DSPOp0D()
{
@@ -1167,24 +1167,24 @@ void DSPOp2D()
#endif
}
-short Op03F;
-short Op03L;
-short Op03U;
-short Op03X;
-short Op03Y;
-short Op03Z;
-short Op13F;
-short Op13L;
-short Op13U;
-short Op13X;
-short Op13Y;
-short Op13Z;
-short Op23F;
-short Op23L;
-short Op23U;
-short Op23X;
-short Op23Y;
-short Op23Z;
+int16_t Op03F;
+int16_t Op03L;
+int16_t Op03U;
+int16_t Op03X;
+int16_t Op03Y;
+int16_t Op03Z;
+int16_t Op13F;
+int16_t Op13L;
+int16_t Op13U;
+int16_t Op13X;
+int16_t Op13Y;
+int16_t Op13Z;
+int16_t Op23F;
+int16_t Op23L;
+int16_t Op23U;
+int16_t Op23X;
+int16_t Op23Y;
+int16_t Op23Z;
void DSPOp03()
{
@@ -1231,19 +1231,19 @@ void DSPOp23()
#endif
}
-short Op14Zr;
-short Op14Xr;
-short Op14Yr;
-short Op14U;
-short Op14F;
-short Op14L;
-short Op14Zrr;
-short Op14Xrr;
-short Op14Yrr;
+int16_t Op14Zr;
+int16_t Op14Xr;
+int16_t Op14Yr;
+int16_t Op14U;
+int16_t Op14F;
+int16_t Op14L;
+int16_t Op14Zrr;
+int16_t Op14Xrr;
+int16_t Op14Yrr;
void DSPOp14()
{
- short CSec, ESec, CTan, CSin, C, E;
+ int16_t CSec, ESec, CTan, CSin, C, E;
DSP1_Inverse(DSP1_Cos(Op14Xr), 0, &CSec, &ESec);
@@ -1276,9 +1276,9 @@ void DSPOp14()
Op14Yrr = Op14Yr + DSP1_Truncate(C, E) + Op14L;
}
-void DSP1_Target(short H, short V, short* X, short* Y)
+void DSP1_Target(int16_t H, int16_t V, int16_t* X, int16_t* Y)
{
- short C, E, C1, E1;
+ int16_t C, E, C1, E1;
DSP1_Inverse((V * SinAzs >> 15) + VOffset, 8, &C, &E);
E += VPlane_E;
@@ -1305,28 +1305,28 @@ void DSP1_Target(short H, short V, short* X, short* Y)
*Y += C * CosAas >> 15;
}
-short Op0EH;
-short Op0EV;
-short Op0EX;
-short Op0EY;
+int16_t Op0EH;
+int16_t Op0EV;
+int16_t Op0EX;
+int16_t Op0EY;
void DSPOp0E()
{
DSP1_Target(Op0EH, Op0EV, &Op0EX, &Op0EY);
}
-short Op0BX;
-short Op0BY;
-short Op0BZ;
-short Op0BS;
-short Op1BX;
-short Op1BY;
-short Op1BZ;
-short Op1BS;
-short Op2BX;
-short Op2BY;
-short Op2BZ;
-short Op2BS;
+int16_t Op0BX;
+int16_t Op0BY;
+int16_t Op0BZ;
+int16_t Op0BS;
+int16_t Op1BX;
+int16_t Op1BY;
+int16_t Op1BZ;
+int16_t Op1BS;
+int16_t Op2BX;
+int16_t Op2BY;
+int16_t Op2BZ;
+int16_t Op2BS;
void DSPOp0B()
{
@@ -1345,8 +1345,8 @@ void DSPOp1B()
#ifdef DebugDSP1
Log_Message("OP1B X: %d Y: %d Z: %d S: %d", Op1BX, Op1BY, Op1BZ, Op1BS);
- Log_Message(" MX: %d MY: %d MZ: %d Scale: %d", (short)(matrixB[0][0] * 100),
- (short)(matrixB[0][1] * 100), (short)(matrixB[0][2] * 100), (short)(sc2 * 100));
+ Log_Message(" MX: %d MY: %d MZ: %d Scale: %d", (int16_t)(matrixB[0][0] * 100),
+ (int16_t)(matrixB[0][1] * 100), (int16_t)(matrixB[0][2] * 100), (int16_t)(sc2 * 100));
#endif
}
@@ -1360,7 +1360,7 @@ void DSPOp2B()
#endif
}
-short Op08X, Op08Y, Op08Z, Op08Ll, Op08Lh;
+int16_t Op08X, Op08Y, Op08Z, Op08Ll, Op08Lh;
void DSPOp08()
{
@@ -1374,7 +1374,7 @@ void DSPOp08()
#endif
}
-short Op18X, Op18Y, Op18Z, Op18R, Op18D;
+int16_t Op18X, Op18Y, Op18Z, Op18R, Op18D;
void DSPOp18()
{
@@ -1385,7 +1385,7 @@ void DSPOp18()
#endif
}
-short Op38X, Op38Y, Op38Z, Op38R, Op38D;
+int16_t Op38X, Op38Y, Op38Z, Op38R, Op38D;
void DSPOp38()
{
@@ -1397,10 +1397,10 @@ void DSPOp38()
#endif
}
-short Op28X;
-short Op28Y;
-short Op28Z;
-short Op28R;
+int16_t Op28X;
+int16_t Op28Y;
+int16_t Op28Z;
+int16_t Op28R;
void DSPOp28()
{
@@ -1409,14 +1409,14 @@ void DSPOp28()
if (Radius == 0) Op28R = 0;
else
{
- short C, E;
+ int16_t C, E;
DSP1_NormalizeDouble(Radius, &C, &E);
if (E & 1) C = C * 0x4000 >> 15;
- short Pos = C * 0x0040 >> 15;
+ int16_t Pos = C * 0x0040 >> 15;
- short Node1 = DSP1ROM[0x00d5 + Pos];
- short Node2 = DSP1ROM[0x00d6 + Pos];
+ int16_t Node1 = DSP1ROM[0x00d5 + Pos];
+ int16_t Node2 = DSP1ROM[0x00d6 + Pos];
Op28R = ((Node2 - Node1) * (C & 0x1ff) >> 9) + Node1;
Op28R >>= (E >> 1);
@@ -1428,14 +1428,14 @@ void DSPOp28()
#endif
}
-short Op1CX, Op1CY, Op1CZ;
-short Op1CXBR, Op1CYBR, Op1CZBR, Op1CXAR, Op1CYAR, Op1CZAR;
-short Op1CX1;
-short Op1CY1;
-short Op1CZ1;
-short Op1CX2;
-short Op1CY2;
-short Op1CZ2;
+int16_t Op1CX, Op1CY, Op1CZ;
+int16_t Op1CXBR, Op1CYBR, Op1CZBR, Op1CXAR, Op1CYAR, Op1CZAR;
+int16_t Op1CX1;
+int16_t Op1CY1;
+int16_t Op1CZ1;
+int16_t Op1CX2;
+int16_t Op1CY2;
+int16_t Op1CZ2;
void DSPOp1C()
{
@@ -1462,8 +1462,8 @@ void DSPOp1C()
#endif
}
-unsigned short Op0FRamsize;
-unsigned short Op0FPass;
+uint16_t Op0FRamsize;
+uint16_t Op0FPass;
void DSPOp0F()
{
@@ -1474,8 +1474,8 @@ void DSPOp0F()
#endif
}
-short Op2FUnknown;
-short Op2FSize;
+int16_t Op2FUnknown;
+int16_t Op2FSize;
void DSPOp2F()
{
diff --git a/source/dsp4emu.c b/source/dsp4emu.c
index 666656b..bb187c7 100644
--- a/source/dsp4emu.c
+++ b/source/dsp4emu.c
@@ -103,12 +103,12 @@
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
-int DSP4_Multiply(short Multiplicand, short Multiplier)
+int DSP4_Multiply(int16_t Multiplicand, int16_t Multiplier)
{
return Multiplicand * Multiplier;
}
-short DSP4_UnknownOP11(short A, short B, short C, short D)
+int16_t DSP4_UnknownOP11(int16_t A, int16_t B, int16_t C, int16_t D)
{
return ((A * 0x0155 >> 2) & 0xf000) | ((B * 0x0155 >> 6) & 0x0f00) |
((C * 0x0155 >> 10) & 0x00f0) | ((D * 0x0155 >> 14) & 0x000f);
@@ -248,10 +248,10 @@ resume2:
// quadratic regression (rough)
if (project_focaly >= -0x0f)
- py_dy = (short)(project_focaly * project_focaly * -0.20533553
+ py_dy = (int16_t)(project_focaly * project_focaly * -0.20533553
- 1.08330005 * project_focaly - 69.61094639);
else
- py_dy = (short)(project_focaly * project_focaly * -0.000657035759
+ py_dy = (int16_t)(project_focaly * project_focaly * -0.000657035759
- 1.07629051 * project_focaly - 65.69315963);
// approximate # of raster lines
@@ -458,10 +458,10 @@ resume2:
// quadratic regression (rough)
if (project_focaly >= -0x0f)
- py_dy = (short)(project_focaly * project_focaly * -0.20533553
+ py_dy = (int16_t)(project_focaly * project_focaly * -0.20533553
- 1.08330005 * project_focaly - 69.61094639);
else
- py_dy = (short)(project_focaly * project_focaly * -0.000657035759
+ py_dy = (int16_t)(project_focaly * project_focaly * -0.000657035759
- 1.07629051 * project_focaly - 65.69315963);
// approximate # of raster lines
@@ -1043,10 +1043,10 @@ resume2:
// quadratic regression (rough)
if (project_focaly >= -0x0f)
- py_dy = (short)(project_focaly * project_focaly * -0.20533553
+ py_dy = (int16_t)(project_focaly * project_focaly * -0.20533553
- 1.08330005 * project_focaly - 69.61094639);
else
- py_dy = (short)(project_focaly * project_focaly * -0.000657035759
+ py_dy = (int16_t)(project_focaly * project_focaly * -0.000657035759
- 1.07629051 * project_focaly - 65.69315963);
// approximate # of raster lines
diff --git a/source/seta010.c b/source/seta010.c
index 1b92e8d..aa89df2 100644
--- a/source/seta010.c
+++ b/source/seta010.c
@@ -308,18 +308,18 @@ const unsigned char ST010_ArcTan[32][32] =
}
};
-short ST010_Sin(short Theta)
+int16_t ST010_Sin(int16_t Theta)
{
return ST010_SinTable[(Theta >> 8) & 0xff];
}
-short ST010_Cos(short Theta)
+int16_t ST010_Cos(int16_t Theta)
{
return ST010_SinTable[((Theta + 0x4000) >> 8) & 0xff];
}
-void ST010_OP01(short x0, short y0, short* x1, short* y1, short* Quadrant,
- short* Theta)
+void ST010_OP01(int16_t x0, int16_t y0, int16_t* x1, int16_t* y1, int16_t* Quadrant,
+ int16_t* Theta)
{
if ((x0 < 0) && (y0 < 0))
{
@@ -357,24 +357,24 @@ void ST010_OP01(short x0, short y0, short* x1, short* y1, short* Quadrant,
*Theta = (ST010_ArcTan[*y1][*x1] << 8) ^ *Quadrant;
}
-void ST010_Scale(short Multiplier, short X0, short Y0, int* X1, int* Y1)
+void ST010_Scale(int16_t Multiplier, int16_t X0, int16_t Y0, int* X1, int* Y1)
{
*X1 = X0 * Multiplier << 1;
*Y1 = Y0 * Multiplier << 1;
}
-void ST010_Multiply(short Multiplicand, short Multiplier, int* Product)
+void ST010_Multiply(int16_t Multiplicand, int16_t Multiplier, int* Product)
{
*Product = Multiplicand * Multiplier << 1;
}
-void ST010_Rotate(short Theta, short X0, short Y0, short* X1, short* Y1)
+void ST010_Rotate(int16_t Theta, int16_t X0, int16_t Y0, int16_t* X1, int16_t* Y1)
{
*X1 = (Y0 * ST010_Sin(Theta) >> 15) + (X0 * ST010_Cos(Theta) >> 15);
*Y1 = (Y0 * ST010_Cos(Theta) >> 15) - (X0 * ST010_Sin(Theta) >> 15);
}
-void SETA_Distance(short Y0, short X0, short* Distance)
+void SETA_Distance(int16_t Y0, int16_t X0, int16_t* Distance)
{
if (X0 < 0) X0 = -X0;
if (Y0 < 0) Y0 = -Y0;
@@ -444,7 +444,7 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
{
#if defined(FAST_LSB_WORD_ACCESS) && !defined(ANDROID)
/* TODO - FIXME */
- ST010_SortDrivers(*(short*)&Memory.SRAM[0x0024], (uint16_t*)(Memory.SRAM + 0x0040),
+ ST010_SortDrivers(*(int16_t*)&Memory.SRAM[0x0024], (uint16_t*)(Memory.SRAM + 0x0040),
(uint16_t*)(Memory.SRAM + 0x0080));
#else
uint16_t Places[32];
@@ -488,8 +488,8 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
{
#if defined(FAST_LSB_WORD_ACCESS) && !defined(ANDROID)
/* TODO - FIXME */
- ST010_Scale(*(short*)&Memory.SRAM[0x0004], *(short*)&Memory.SRAM[0x0000],
- *(short*)&Memory.SRAM[0x0002],
+ ST010_Scale(*(int16_t*)&Memory.SRAM[0x0004], *(int16_t*)&Memory.SRAM[0x0000],
+ *(int16_t*)&Memory.SRAM[0x0002],
(int*)&Memory.SRAM[0x0010], (int*)&Memory.SRAM[0x0014]);
#else
int x1, y1;
@@ -521,7 +521,7 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
{
#if defined(FAST_LSB_WORD_ACCESS) && !defined(ANDROID)
/* TODO - FIXME */
- ST010_Multiply(*(short*)&Memory.SRAM[0x0000], *(short*)&Memory.SRAM[0x0002],
+ ST010_Multiply(*(int16_t*)&Memory.SRAM[0x0000], *(int16_t*)&Memory.SRAM[0x0002],
(int*)&Memory.SRAM[0x0010]);
#else
int Product;
@@ -598,11 +598,11 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
{
#if defined(FAST_LSB_WORD_ACCESS) && !defined(ANDROID)
/* TODO - FIXME */
- ST010_Rotate(*(short*)&Memory.SRAM[0x0004], *(short*)&Memory.SRAM[0x0000],
- *(short*)&Memory.SRAM[0x0002],
- (short*)&Memory.SRAM[0x0010], (short*)&Memory.SRAM[0x0012]);
+ ST010_Rotate(*(int16_t*)&Memory.SRAM[0x0004], *(int16_t*)&Memory.SRAM[0x0000],
+ *(int16_t*)&Memory.SRAM[0x0002],
+ (int16_t*)&Memory.SRAM[0x0010], (int16_t*)&Memory.SRAM[0x0012]);
#else
- short x1, y1;
+ int16_t x1, y1;
ST010_Rotate(ST010_WORD(0x0004), ST010_WORD(0x0000), ST010_WORD(0x0002), &x1,
&y1);
@@ -628,11 +628,11 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
#if defined(FAST_LSB_WORD_ACCESS) && !defined(ANDROID)
/* TODO - FIXME */
- ST010_OP01(*(short*)&Memory.SRAM[0x0000], *(short*)&Memory.SRAM[0x0002],
- (short*) &Memory.SRAM[0x0000], (short*) &Memory.SRAM[0x0002],
- (short*) &Memory.SRAM[0x0004], (short*) &Memory.SRAM[0x0010]);
+ ST010_OP01(*(int16_t*)&Memory.SRAM[0x0000], *(int16_t*)&Memory.SRAM[0x0002],
+ (int16_t*) &Memory.SRAM[0x0000], (int16_t*) &Memory.SRAM[0x0002],
+ (int16_t*) &Memory.SRAM[0x0004], (int16_t*) &Memory.SRAM[0x0010]);
#else
- short x1, y1, Quadrant, Theta;
+ int16_t x1, y1, Quadrant, Theta;
ST010_OP01(ST010_WORD(0x0000), ST010_WORD(0x0002), &x1, &y1, &Quadrant, &Theta);
diff --git a/source/soundux.c b/source/soundux.c
index 9f85e7a..131f7d2 100644
--- a/source/soundux.c
+++ b/source/soundux.c
@@ -140,7 +140,7 @@ extern int32_t EchoBuffer [SOUND_BUFFER_SIZE];
extern int32_t FilterTaps [8];
static uint8_t FilterTapDefinitionBitfield;
// In the above, bit I is set if FilterTaps[I] is non-zero.
-extern unsigned long Z;
+extern uint32_t Z;
extern int32_t Loop [16];
extern long FilterValues[4][2];
@@ -164,7 +164,7 @@ void DecodeBlockAsm2(int8_t*, int16_t*, int32_t*, int32_t*);
// F is channel's current frequency and M is the 16-bit modulation waveform
// from the previous channel multiplied by the current envelope volume level.
-#define PITCH_MOD(F,M) ((F) * ((((unsigned long) (M)) + 0x800000) >> 16) >> 7)
+#define PITCH_MOD(F,M) ((F) * ((((uint32_t) (M)) + 0x800000) >> 16) >> 7)
//#define PITCH_MOD(F,M) ((F) * ((((M) & 0x7fffff) >> 14) + 1) >> 8)
#define LAST_SAMPLE 0xffffff
@@ -208,7 +208,7 @@ void S9xAPUSetEndX(int ch)
END_OF_FUNCTION(S9xAPUSetEndX)
#endif
-void S9xSetEnvRate(Channel* ch, unsigned long rate, int direction, int target)
+void S9xSetEnvRate(Channel* ch, uint32_t rate, int direction, int target)
{
ch->envx_target = target;
@@ -239,7 +239,7 @@ void S9xSetEnvRate(Channel* ch, unsigned long rate, int direction, int target)
ch->erate = 0;
else
{
- ch->erate = (unsigned long)
+ ch->erate = (uint32_t)
(steps [ch->state] / (rate * so.playback_rate));
}
}
@@ -248,7 +248,7 @@ void S9xSetEnvRate(Channel* ch, unsigned long rate, int direction, int target)
END_OF_FUNCTION(S9xSetEnvRate);
#endif
-void S9xSetEnvelopeRate(int channel, unsigned long rate, int direction,
+void S9xSetEnvelopeRate(int channel, uint32_t rate, int direction,
int target)
{
S9xSetEnvRate(&SoundData.channels [channel], rate, direction, target);
@@ -258,7 +258,7 @@ void S9xSetEnvelopeRate(int channel, unsigned long rate, int direction,
END_OF_FUNCTION(S9xSetEnvelopeRate);
#endif
-void S9xSetSoundVolume(int channel, short volume_left, short volume_right)
+void S9xSetSoundVolume(int channel, int16_t volume_left, int16_t volume_right)
{
Channel* ch = &SoundData.channels[channel];
ch->volume_left = volume_left;
@@ -267,7 +267,7 @@ void S9xSetSoundVolume(int channel, short volume_left, short volume_right)
ch->right_vol_level = (ch->envx * volume_right) / 128;
}
-void S9xSetMasterVolume(short volume_left, short volume_right)
+void S9xSetMasterVolume(int16_t volume_left, int16_t volume_right)
{
if (Settings.DisableMasterVolume || SNESGameFixes.EchoOnlyOutput)
SoundData.master_volume [0] = SoundData.master_volume [1] = 127;
@@ -278,7 +278,7 @@ void S9xSetMasterVolume(short volume_left, short volume_right)
}
}
-void S9xSetEchoVolume(short volume_left, short volume_right)
+void S9xSetEchoVolume(int16_t volume_left, int16_t volume_right)
{
SoundData.echo_volume [0] = volume_left;
SoundData.echo_volume [1] = volume_right;
@@ -520,7 +520,7 @@ void DecodeBlock(Channel* ch)
uint8_t interim_byte = 0;
compressed++;
- signed short* raw = ch->block = ch->decoded;
+ int16_t* raw = ch->block = ch->decoded;
// Seperate out the header parts used for decoding
@@ -581,12 +581,12 @@ void DecodeBlock(Channel* ch)
}
CLIP16(out);
- int16_t result = (signed short)(out << 1);
+ int16_t result = (int16_t)(out << 1);
if (abs(result) > amplitude)
amplitude = abs(result);
interim[interim_byte++] = out;
- prev1 = (signed short)prev0;
- prev0 = (signed short)(out << 1);
+ prev1 = (int16_t)prev0;
+ prev0 = (int16_t)(out << 1);
}
}
ch->previous [0] = prev0;
@@ -710,7 +710,7 @@ void DecodeBlock(Channel* ch)
ch->loop = (filter & 2) != 0;
compressed++;
- signed short* raw = ch->block = ch->decoded;
+ int16_t* raw = ch->block = ch->decoded;
// Seperate out the header parts used for decoding
@@ -769,9 +769,9 @@ void DecodeBlock(Channel* ch)
}
CLIP16(out);
- *raw++ = (signed short)(out << 1);
- prev1 = (signed short)prev0;
- prev0 = (signed short)(out << 1);
+ *raw++ = (int16_t)(out << 1);
+ prev1 = (int16_t)prev0;
+ prev0 = (int16_t)(out << 1);
}
}
ch->previous [0] = prev0;
@@ -795,7 +795,7 @@ static inline void MixStereo(int sample_count)
continue;
int32_t VL, VR;
- unsigned long freq0 = ch->frequency;
+ uint32_t freq0 = ch->frequency;
bool mod = pitch_mod & (1 << J);
@@ -823,7 +823,7 @@ static inline void MixStereo(int sample_count)
uint32_t I;
for (I = 0; I < (uint32_t) sample_count; I += 2)
{
- unsigned long freq = freq0;
+ uint32_t freq = freq0;
if (mod)
freq = PITCH_MOD(freq, wave [I / 2]);
@@ -1125,7 +1125,7 @@ void S9xMixSamples(uint8_t* buffer, int sample_count)
E * SoundData.echo_volume [J & 1]) / VOL_DIV16;
CLIP16(I);
- ((signed short*) buffer)[J] = I;
+ ((int16_t*) buffer)[J] = I;
}
}
else
@@ -1165,7 +1165,7 @@ void S9xMixSamples(uint8_t* buffer, int sample_count)
E * SoundData.echo_volume [J & 1]) / VOL_DIV16;
CLIP16(I);
- ((signed short*) buffer)[J] = I;
+ ((int16_t*) buffer)[J] = I;
}
}
}
@@ -1178,7 +1178,7 @@ void S9xMixSamples(uint8_t* buffer, int sample_count)
SoundData.master_volume [J & 1]) / VOL_DIV16;
CLIP16(I);
- ((signed short*) buffer)[J] = I;
+ ((int16_t*) buffer)[J] = I;
}
}
diff --git a/source/soundux.h b/source/soundux.h
index b5ffe4a..9c499ea 100644
--- a/source/soundux.h
+++ b/source/soundux.h
@@ -148,28 +148,28 @@ typedef struct
{
int state;
int type;
- short volume_left;
- short volume_right;
+ int16_t volume_left;
+ int16_t volume_right;
uint32_t hertz;
uint32_t frequency;
uint32_t count;
bool loop;
int envx;
- short left_vol_level;
- short right_vol_level;
- short envx_target;
- unsigned long int env_error;
- unsigned long erate;
+ int16_t left_vol_level;
+ int16_t right_vol_level;
+ int16_t envx_target;
+ uint32_t env_error;
+ uint32_t erate;
int direction;
- unsigned long attack_rate;
- unsigned long decay_rate;
- unsigned long sustain_rate;
- unsigned long release_rate;
- unsigned long sustain_level;
- signed short sample;
- signed short decoded [16];
- signed short previous16 [2];
- signed short* block;
+ uint32_t attack_rate;
+ uint32_t decay_rate;
+ uint32_t sustain_rate;
+ uint32_t release_rate;
+ uint32_t sustain_level;
+ int16_t sample;
+ int16_t decoded [16];
+ int16_t previous16 [2];
+ int16_t* block;
uint16_t sample_number;
bool last_block;
bool needs_decode;
@@ -178,12 +178,11 @@ typedef struct
int* echo_buf_ptr;
int mode;
int32_t envxx;
- signed short next_sample;
+ int16_t next_sample;
int32_t interpolate;
int32_t previous [2];
// Just incase they are needed in the future, for snapshot compatibility.
uint32_t dummy [8];
- // unsigned short last_valid_header;
} Channel;
typedef struct
@@ -199,8 +198,8 @@ typedef struct
uint32_t dummy [3];
Channel channels [NUM_CHANNELS];
// bool no_filter;
- short master_volume [2]; /* range is -128 .. 127 */
- short echo_volume [2]; /* range is -128 .. 127 */
+ int16_t master_volume [2]; /* range is -128 .. 127 */
+ int16_t echo_volume [2]; /* range is -128 .. 127 */
int noise_hertz;
} SSoundData;
@@ -208,12 +207,12 @@ SSoundData SoundData;
void S9xSetEightBitConsoleSound(bool Enabled);
-void S9xSetSoundVolume(int channel, short volume_left, short volume_right);
+void S9xSetSoundVolume(int channel, int16_t volume_left, int16_t volume_right);
void S9xSetSoundFrequency(int channel, int hertz);
void S9xSetSoundHertz(int channel, int hertz);
void S9xSetSoundType(int channel, int type_of_sound);
-void S9xSetMasterVolume(short master_volume_left, short master_volume_right);
-void S9xSetEchoVolume(short echo_volume_left, short echo_volume_right);
+void S9xSetMasterVolume(int16_t master_volume_left, int16_t master_volume_right);
+void S9xSetEchoVolume(int16_t echo_volume_left, int16_t echo_volume_right);
void S9xSetSoundControl(int sound_switch);
void S9xSetEnvelopeHeight(int channel, int height);
void S9xSetSoundADSR(int channel, int attack, int decay, int sustain,
@@ -229,7 +228,7 @@ void S9xSetEchoDelay(int byte);
void S9xSetEchoWriteEnable(uint8_t byte);
void S9xSetFilterCoefficient(int tap, int value);
void S9xSetFrequencyModulationEnable(uint8_t byte);
-void S9xSetEnvelopeRate(int channel, unsigned long rate, int direction,
+void S9xSetEnvelopeRate(int channel, uint32_t rate, int direction,
int target);
bool S9xSetSoundMode(int channel, int mode);
int S9xGetEnvelopeHeight(int channel);
diff --git a/source/spc700.c b/source/spc700.c
index 4e68ebe..140c832 100644
--- a/source/spc700.c
+++ b/source/spc700.c
@@ -149,7 +149,7 @@ void S9xAPUSetByte(uint8_t, uint32_t address);
// XXX: HalfCarry - BJ fixed?
#define SBC(a,b)\
-int16_t Int16 = (short) (a) - (short) (b) + (short) (APUCheckCarry ()) - 1;\
+int16_t Int16 = (int16_t) (a) - (int16_t) (b) + (int16_t) (APUCheckCarry ()) - 1;\
IAPU._Carry = Int16 >= 0;\
if ((((a) ^ (b)) & 0x80) && (((a) ^ (uint8_t) Int16) & 0x80))\
APUSetOverflow ();\
@@ -177,7 +177,7 @@ if(((a) ^ (b) ^ (uint8_t) Work16) & 0x10)\
APUSetZN8 ((uint8_t) Work16);
#define CMP(a,b)\
-int16_t Int16 = (short) (a) - (short) (b);\
+int16_t Int16 = (int16_t) (a) - (int16_t) (b);\
IAPU._Carry = Int16 >= 0;\
APUSetZN8 ((uint8_t) Int16);
diff --git a/source/spc7110.c b/source/spc7110.c
index 044d1f9..5d2ffd6 100644
--- a/source/spc7110.c
+++ b/source/spc7110.c
@@ -236,7 +236,7 @@ void MovePackData()
Data7110* log = &
(decompack->tableEnts[decompack->idx].location[decompack->last_idx]);
if ((log->used_len + log->used_offset) < (decompack->last_offset +
- (unsigned short)s7r.bank50Internal))
+ (uint16_t)s7r.bank50Internal))
{
log->used_len = s7r.bank50Internal;
log->used_offset = decompack->last_offset;
@@ -336,7 +336,7 @@ void ReadPackData()
Data7110* log = &
(decompack->tableEnts[decompack->idx].location[decompack->last_idx]);
if ((log->used_len + log->used_offset) < (decompack->last_offset +
- (unsigned short)s7r.bank50Internal))
+ (uint16_t)s7r.bank50Internal))
{
log->used_len = s7r.bank50Internal;
log->used_offset = decompack->last_offset;
@@ -461,7 +461,7 @@ void GetPackData()
Data7110* log = &
(decompack->tableEnts[decompack->idx].location[decompack->last_idx]);
if ((log->used_len + log->used_offset) < (decompack->last_offset +
- (unsigned short)s7r.bank50Internal))
+ (uint16_t)s7r.bank50Internal))
{
log->used_len = s7r.bank50Internal;
log->used_offset = decompack->last_offset;
@@ -546,7 +546,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
//the offset registers cannot be incremented due to the offset multiplier.
case 0x4800:
{
- unsigned short count = s7r.reg4809 | (s7r.reg480A << 8);
+ uint16_t count = s7r.reg4809 | (s7r.reg480A << 8);
uint32_t i, j;
j = (s7r.reg4805 | (s7r.reg4806 << 8));
j *= s7r.AlignBy;
@@ -622,7 +622,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
{
if (s7r.reg4818 & 0x08)
{
- signed short r4814;
+ int16_t r4814;
r4814 = (s7r.reg4815 << 8) | s7r.reg4814;
i += r4814;
r4814++;
@@ -631,7 +631,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
}
else
{
- unsigned short r4814;
+ uint16_t r4814;
r4814 = (s7r.reg4815 << 8) | s7r.reg4814;
i += r4814;
if (r4814 != 0xFFFF)
@@ -653,7 +653,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
{
if (s7r.reg4818 & 0x04)
{
- signed short inc;
+ int16_t inc;
inc = (s7r.reg4817 << 8) | s7r.reg4816;
if (!(s7r.reg4818 & 0x10))
@@ -662,7 +662,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
{
if (s7r.reg4818 & 0x08)
{
- signed short r4814;
+ int16_t r4814;
r4814 = (s7r.reg4815 << 8) | s7r.reg4814;
r4814 += inc;
s7r.reg4815 = (r4814 & 0xFF00) >> 8;
@@ -670,7 +670,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
}
else
{
- unsigned short r4814;
+ uint16_t r4814;
r4814 = (s7r.reg4815 << 8) | s7r.reg4814;
r4814 += inc;
s7r.reg4815 = (r4814 & 0xFF00) >> 8;
@@ -690,7 +690,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
{
if (s7r.reg4818 & 0x08)
{
- signed short r4814;
+ int16_t r4814;
r4814 = (s7r.reg4815 << 8) | s7r.reg4814;
r4814 += inc;
s7r.reg4815 = (r4814 & 0xFF00) >> 8;
@@ -698,7 +698,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
}
else
{
- unsigned short r4814;
+ uint16_t r4814;
r4814 = (s7r.reg4815 << 8) | s7r.reg4814;
r4814 += inc;
s7r.reg4815 = (r4814 & 0xFF00) >> 8;
@@ -716,7 +716,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
{
if (s7r.reg4818 & 0x08)
{
- signed short r4814;
+ int16_t r4814;
r4814 = (s7r.reg4815 << 8) | s7r.reg4814;
r4814 += 1;
s7r.reg4815 = (r4814 & 0xFF00) >> 8;
@@ -724,7 +724,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
}
else
{
- unsigned short r4814;
+ uint16_t r4814;
r4814 = (s7r.reg4815 << 8) | s7r.reg4814;
r4814 += 1;
s7r.reg4815 = (r4814 & 0xFF00) >> 8;
@@ -776,8 +776,8 @@ uint8_t S9xGetSPC7110(uint16_t Address)
uint32_t i = ((s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811);
if (s7r.reg4818 & 0x08)
{
- short adj;
- adj = ((short)(s7r.reg4815 << 8)) | s7r.reg4814;
+ int16_t adj;
+ adj = ((int16_t)(s7r.reg4815 << 8)) | s7r.reg4814;
i += adj;
}
else
@@ -799,8 +799,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
{
if (s7r.reg4818 & 0x08)
{
- short adj;
- adj = ((short)(s7r.reg4815 << 8)) | s7r.reg4814;
+ int16_t adj = ((int16_t)(s7r.reg4815 << 8)) | s7r.reg4814;
i += adj;
}
else
@@ -818,8 +817,7 @@ uint8_t S9xGetSPC7110(uint16_t Address)
{
if (s7r.reg4818 & 0x08)
{
- short adj;
- adj = ((short)(s7r.reg4815 << 8)) | s7r.reg4814;
+ int16_t adj = ((int16_t)(s7r.reg4815 << 8)) | s7r.reg4814;
adj += adj;
s7r.reg4815 = (adj & 0xFF00) >> 8;
s7r.reg4814 = adj & 0xFF;
@@ -1087,8 +1085,8 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
uint32_t i = (s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811;
if (s7r.reg4818 & 0x08)
{
- short adj;
- adj = ((short)(s7r.reg4815 << 8)) | s7r.reg4814;
+ int16_t adj;
+ adj = ((int16_t)(s7r.reg4815 << 8)) | s7r.reg4814;
i += adj;
}
else
@@ -1151,8 +1149,8 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
uint32_t i = (s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811;
if (s7r.reg4818 & 0x08)
{
- short adj;
- adj = ((short)(s7r.reg4815 << 8)) | s7r.reg4814;
+ int16_t adj;
+ adj = ((int16_t)(s7r.reg4815 << 8)) | s7r.reg4814;
i += adj;
}
else
@@ -1214,11 +1212,9 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
s7r.reg4825 = data;
if (s7r.reg482E & 0x01)
{
- int mul;
- short m1 = (short)((s7r.reg4824) | (s7r.reg4825 << 8));
- short m2 = (short)((s7r.reg4820) | (s7r.reg4821 << 8));
-
- mul = m1 * m2;
+ int16_t m1 = (int16_t)((s7r.reg4824) | (s7r.reg4825 << 8));
+ int16_t m2 = (int16_t)((s7r.reg4820) | (s7r.reg4821 << 8));
+ int mul = m1 * m2;
s7r.reg4828 = (uint8_t)(mul & 0x000000FF);
s7r.reg4829 = (uint8_t)((mul & 0x0000FF00) >> 8);
s7r.reg482A = (uint8_t)((mul & 0x00FF0000) >> 16);
@@ -1248,14 +1244,14 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address)
if (s7r.reg482E & 0x01)
{
int quotient;
- short remainder;
+ int16_t remainder;
int dividend = (int)(s7r.reg4820 | (s7r.reg4821 << 8) | (s7r.reg4822 << 16) |
(s7r.reg4823 << 24));
- short divisor = (short)(s7r.reg4826 | (s7r.reg4827 << 8));
+ int16_t divisor = (int16_t)(s7r.reg4826 | (s7r.reg4827 << 8));
if (divisor != 0)
{
quotient = (int)(dividend / divisor);
- remainder = (short)(dividend % divisor);
+ remainder = (int16_t)(dividend % divisor);
}
else
{
diff --git a/source/spc7110.h b/source/spc7110.h
index c597096..65a794e 100644
--- a/source/spc7110.h
+++ b/source/spc7110.h
@@ -121,7 +121,7 @@ void SPC7110Grab(char*);
typedef struct SPC7110RTC
{
unsigned char reg[16];
- short index;
+ int16_t index;
uint8_t control;
bool init;
time_t last_used;