diff --git a/zsnes/src/chips/dsp1emu.c b/zsnes/src/chips/dsp1emu.c index f17a7a46..5653ee8b 100644 --- a/zsnes/src/chips/dsp1emu.c +++ b/zsnes/src/chips/dsp1emu.c @@ -233,7 +233,7 @@ void C4Op0D() void InitDSP(void) { #ifdef __OPT__ - unsigned short i; + unsigned int i; CosTable2 = malloc(INCR*sizeof(double)); SinTable2 = malloc(INCR*sizeof(double)); for (i=0; i32767) CenterX=32767; - Op02CX = (short)CenterX; CenterY = (cos(NAasB)*ViewerZc*CXdistance)+ViewerYc; if (CenterY<-32768) CenterY = -32768; if (CenterY>32767) CenterY=32767; - Op02CY = (short)CenterY; TValDebug = (NAzsB*65536/6.28); TValDebug2 = ScrDispl; @@ -1344,7 +1351,10 @@ void DSPOp18() { double x,y,z,r; x=Op18X; y=Op18Y; z=Op18Z; r=Op18R; - Op18D=(short)(x*x+y*y+z*z-r*r); + r = (x*x+y*y+z*z-r*r); + if (r>32767) r=32767; + if (r<-32768) r=-32768; + Op18D=(short)r; #ifdef DebugDSP1 Log_Message("OP18 X: %d Y: %d Z: %d R: %D DIFF %d",Op18X,Op18Y,Op18Z,Op18D); #endif