From 265fd7cb3583f0530662f1926ce6a3b803914a19 Mon Sep 17 00:00:00 2001 From: pagefault <> Date: Mon, 14 Apr 2003 18:39:12 +0000 Subject: [PATCH] Updated and cleaned up code --- zsnes/src/chips/dsp1emu.c | 183 +++++++++++++---------------------- zsnes/src/chips/dsp1proc.asm | 55 +++++++---- zsnes/src/chips/fxemu2.asm | 26 ++--- zsnes/src/chips/fxemu2c.asm | 9 +- zsnes/src/chips/fxtable.asm | 14 ++- zsnes/src/chips/sa1proc.asm | 18 ++-- zsnes/src/chips/sa1regs.asm | 56 +++++++---- zsnes/src/chips/sfxproc.asm | 10 +- 8 files changed, 194 insertions(+), 177 deletions(-) diff --git a/zsnes/src/chips/dsp1emu.c b/zsnes/src/chips/dsp1emu.c index 7177967c..ade1a749 100644 --- a/zsnes/src/chips/dsp1emu.c +++ b/zsnes/src/chips/dsp1emu.c @@ -15,16 +15,16 @@ //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifdef __LINUX__ -#include "../gblhdr.h" -#else + +#ifdef __LINUX__ +#include "../gblhdr.h" +#else #include #include #include #include #include #endif - //#define DebugDSP1 // uncomment some lines to test @@ -71,30 +71,32 @@ void Start_Log (void) LogFile = fopen(LogFileName,"wb"); } -void Stop_Log (void) +void Stop_Log(void) { - if (LogFile) - { - fclose(LogFile); - LogFile = NULL; - } + if(LogFile) + { + fclose(LogFile); + LogFile=NULL; + } } #endif - /***************************************************************************\ * Math tables * \***************************************************************************/ +double *CosTable2; +double *SinTable2; #define INCR 2048 #define Angle(x) (((x)/(65536/INCR)) & (INCR-1)) #define Cos(x) ((double) CosTable2[x]) #define Sin(x) ((double) SinTable2[x]) +// gcc warning fix +#ifdef PI +#undef PI +#endif #define PI 3.14159265358979323846264338327 -double CosTable2[INCR]; -double SinTable2[INCR]; - double Atan(double x) { @@ -229,6 +231,7 @@ void C4Op0D() C41FXVal=(short)(((double)C41FXVal*tanval)*0.98); } + /***************************************************************************\ * DSP1 code * \***************************************************************************/ @@ -238,8 +241,8 @@ void InitDSP(void) { #ifdef __OPT__ unsigned int i; -// CosTable2 = (double *) malloc(INCR*sizeof(double)); -// SinTable2 = (double *) malloc(INCR*sizeof(double)); + CosTable2 = (double *)malloc(INCR*sizeof(double)); + SinTable2 = (double *)malloc(INCR*sizeof(double)); for (i=0; i> 15; + Op00Result=Op00Multiplicand*Op00Multiplier/32768; #ifdef DebugDSP1 Log_Message("OP00 MULT %d*%d/32768=%d",Op00Multiplicand,Op00Multiplier,Op00Result); #endif @@ -274,28 +274,23 @@ float Op10Temp; void DSPOp10() { - // Hard to get bit accurate here but it's very close... - // within 2 lsb's on the coefficient of the DSP1B. Emu is more accurate. - - if (Op10Coefficient == 0) { - Op10CoefficientR = 0x7fff; // DSP1B - Strange but true - Op10ExponentR = 0x002f; - } else { - Op10ExponentR = -Op10Exponent; - Op10Temp = (float)(Op10Coefficient / 32768.0); - Op10Temp = 1/Op10Temp; - if (Op10Temp > 0) - while (Op10Temp >= 1.0) { - Op10Temp = (float)(Op10Temp/2.0); - Op10ExponentR++; - } - else - while (Op10Temp <= -1.0) { - Op10Temp=(float)(Op10Temp/2.0); - Op10ExponentR++; - } - Op10CoefficientR = (short)(Op10Temp*32768); - } + Op10ExponentR=-Op10Exponent; + Op10Temp = Op10Coefficient / 32768.0; + if (Op10Temp == 0) { + Op10CoefficientR = 0; + } else + Op10Temp = 1/Op10Temp; + if (Op10Temp > 0) + while (Op10Temp>=1.0) { + Op10Temp=Op10Temp/2.0; + Op10ExponentR++; + } + else + while (Op10Temp<-1.0) { + Op10Temp=Op10Temp/2.0; + Op10ExponentR++; + } + Op10CoefficientR = Op10Temp*32768; #ifdef DebugDSP1 Log_Message("OP10 INV %d*2^%d = %d*2^%d", Op10Coefficient, Op10Exponent, Op10CoefficientR, Op10ExponentR); #endif @@ -303,7 +298,7 @@ void DSPOp10() short Op04Angle; -short Op04Radius; // This is signed +unsigned short Op04Radius; short Op04Sin; short Op04Cos; @@ -331,8 +326,8 @@ void DSPOp04() angle = Op04Angle*2*PI/65536.0; - Op04Sin = (short)(sin(angle) * Op04Radius); - Op04Cos = (short)(cos(angle) * Op04Radius); + Op04Sin = sin(angle) * Op04Radius; + Op04Cos = cos(angle) * Op04Radius; #ifdef DebugDSP1 Log_Message("OP04 Angle:%d Radius:%d",(Op04Angle/256)&255,Op04Radius); @@ -350,8 +345,8 @@ short Op0CY2; #ifdef __OPT0C__ void DSPOp0C() { - Op0CX2=(short)((Op0CX1*Cos(Angle(Op0CA))+Op0CY1*Sin(Angle(Op0CA)))); - Op0CY2=(short)((Op0CX1*-Sin(Angle(Op0CA))+Op0CY1*Cos(Angle(Op0CA)))); + Op0CX2=(Op0CX1*Cos(Angle(Op0CA))+Op0CY1*Sin(Angle(Op0CA))); + Op0CY2=(Op0CX1*-Sin(Angle(Op0CA))+Op0CY1*Cos(Angle(Op0CA))); #ifdef DebugDSP1 Log_Message("OP0C Angle:%d X:%d Y:%d CX:%d CY:%d",(Op0CA/256)&255,Op0CX1,Op0CY1,Op0CX2,Op0CY2); #endif @@ -359,7 +354,7 @@ void DSPOp0C() #else void DSPOp0C() { - + Op0CX2=(Op0CX1*cos(Op0CA*2*PI/65536.0)+Op0CY1*sin(Op0CA*2*PI/65536.0)); Op0CY2=(Op0CX1*-sin(Op0CA*2*PI/65536.0)+Op0CY1*cos(Op0CA*2*PI/65536.0)); #ifdef DebugDSP1 @@ -505,7 +500,7 @@ void DSPOp02() CenterY = (cos(NAasB)*ViewerZc*CXdistance)+ViewerYc; if (CenterY<-32768) CenterY = -32768; if (CenterY>32767) CenterY=32767; - TValDebug = (short)((NAzsB*65536/6.28)); + TValDebug = (NAzsB*65536/6.28); TValDebug2 = ScrDispl; // if (Op02CY < 0) {Op02CYSup = Op02CY/256; Op02CY = 0;} @@ -718,7 +713,6 @@ double ObjPX2; double ObjPY2; double ObjPZ2; double DivideOp06; -double d; int Temp; int tanval2; @@ -758,16 +752,7 @@ void DSPOp06() { Op06H=(short)(-ObjPX2*Op02LES/-(ObjPZ2)); //-ObjPX2*256/-ObjPZ2; Op06V=(short)(-ObjPY2*Op02LES/-(ObjPZ2)); //-ObjPY2*256/-ObjPZ2; - d=(double)Op02LES; - d*=256.0; - d/=(-ObjPZ2); - if(d>65535.0) - 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=(unsigned short)(256*(double)Op02LES/-ObjPZ2); } else { @@ -818,15 +803,7 @@ void DSPOp06() { Op06H=(short)(-ObjPX2*Op02LES/-(ObjPZ2)); //-ObjPX2*256/-ObjPZ2; Op06V=(short)(-ObjPY2*Op02LES/-(ObjPZ2)); //-ObjPY2*256/-ObjPZ2; - double d=(double)Op02LES; - d*=256.0; - d/=(-ObjPZ2); - if(d>65535.0) - 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)(256*(double)Op02LES/-ObjPZ2); } else { @@ -1314,8 +1291,8 @@ void DSPOp0E() RVPos = Op0EV; RHPos = Op0EH; GetRXYPos(); - Op0EX = (short)(RXRes); - Op0EY = (short)(RYRes); + Op0EX = RXRes; + Op0EY = RYRes; #ifdef DebugDSP1 Log_Message("OP0E COORDINATE H:%d V:%d X:%d Y:%d",Op0EH,Op0EV,Op0EX,Op0EY); @@ -1337,7 +1314,7 @@ short Op2BS; void DSPOp0B() { - Op0BS = (short)((Op0BX*matrixA[0][0]+Op0BY*matrixA2[0][1]+Op0BZ*matrixA2[0][2])); + Op0BS = (Op0BX*matrixA[0][0]+Op0BY*matrixA2[0][1]+Op0BZ*matrixA2[0][2]); #ifdef DebugDSP1 Log_Message("OP0B"); #endif @@ -1345,7 +1322,7 @@ void DSPOp0B() void DSPOp1B() { - Op1BS = (short)((Op1BX*matrixA2[0][0]+Op1BY*matrixA2[0][1]+Op1BZ*matrixA2[0][2])); + Op1BS = (Op1BX*matrixA2[0][0]+Op1BY*matrixA2[0][1]+Op1BZ*matrixA2[0][2]); #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)(matrixA2[0][0]*100),(short)(matrixA2[0][1]*100),(short)(matrixA2[0][2]*100),(short)(sc2*100)); @@ -1355,7 +1332,7 @@ void DSPOp1B() void DSPOp2B() { - Op2BS = (short)((Op2BX*matrixA3[0][0]+Op2BY*matrixA3[0][1]+Op2BZ*matrixA3[0][2])); + Op2BS = (Op2BX*matrixA3[0][0]+Op2BY*matrixA3[0][1]+Op2BZ*matrixA3[0][2]); #ifdef DebugDSP1 Log_Message("OP2B"); #endif @@ -1366,8 +1343,6 @@ long Op08Size; void DSPOp08() { - // This is bit accurate to DSP1B when compiled with VC 6 on a P4 - Op08Size=(Op08X*Op08X+Op08Y*Op08Y+Op08Z*Op08Z)*2; Op08Ll = Op08Size&0xFFFF; Op08Lh = (Op08Size>>16) & 0xFFFF; @@ -1381,12 +1356,12 @@ short Op18X,Op18Y,Op18Z,Op18R,Op18D; void DSPOp18() { - // This is bit accurate to DSP1B when compiled with VC6 on a P4 - - int x,y,z,r; // int32 + double x,y,z,r; x=Op18X; y=Op18Y; z=Op18Z; r=Op18R; r = (x*x+y*y+z*z-r*r); - Op18D=(short) (r >> 15); + 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 @@ -1399,9 +1374,6 @@ short Op28R; void DSPOp28() { - // This works pretty good until r overflows from 0x7fff, then it goes to h*ll. - // Hopefully games don't count on overflow cases matching the DSP - Op28R=(short)sqrt(Op28X*Op28X+Op28Y*Op28Y+Op28Z*Op28Z); #ifdef DebugDSP1 Log_Message("OP28 X:%d Y:%d Z:%d",Op28X,Op28Y,Op28Z); @@ -1409,7 +1381,8 @@ void DSPOp28() #endif } -short Op1CX,Op1CY,Op1CZ; +short Op1CAZ; +unsigned short Op1CX,Op1CY,Op1CZ; short Op1CXBR,Op1CYBR,Op1CZBR,Op1CXAR,Op1CYAR,Op1CZAR; short Op1CX1; short Op1CY1; @@ -1427,17 +1400,17 @@ void DSPOp1C() za = Angle(Op1CZ); // rotate around Z - Op1CX1=(short)((Op1CXBR*Cos(za)+Op1CYBR*Sin(za))); - Op1CY1=(short)((Op1CXBR*-Sin(za)+Op1CYBR*Cos(za))); + Op1CX1=(Op1CXBR*Cos(za)+Op1CYBR*Sin(za)); + Op1CY1=(Op1CXBR*-Sin(za)+Op1CYBR*Cos(za)); Op1CZ1=Op1CZBR; // rotate around Y - Op1CX2=(short)((Op1CX1*Cos(ya)+Op1CZ1*-Sin(ya))); + Op1CX2=(Op1CX1*Cos(ya)+Op1CZ1*-Sin(ya)); Op1CY2=Op1CY1; - Op1CZ2=(short)((Op1CX1*Sin(ya)+Op1CZ1*Cos(ya))); + Op1CZ2=(Op1CX1*Sin(ya)+Op1CZ1*Cos(ya)); // rotate around X Op1CXAR=Op1CX2; - Op1CYAR=(short)((Op1CY2*Cos(xa)+Op1CZ2*Sin(xa))); - Op1CZAR=(short)((Op1CY2*-Sin(xa)+Op1CZ2*Cos(xa))); + Op1CYAR=(Op1CY2*Cos(xa)+Op1CZ2*Sin(xa)); + Op1CZAR=(Op1CY2*-Sin(xa)+Op1CZ2*Cos(xa)); #ifdef DebugDSP1 Log_Message("OP1C Apply Matrix CX:%d CY:%d CZ",Op1CXAR,Op1CYAR,Op1CZAR); @@ -1447,10 +1420,9 @@ void DSPOp1C() void DSPOp1C() { double ya,xa,za; - ya = Op1CX/32768.0*PI; - xa = Op1CY/32768.0*PI; - za = Op1CZ/32768.0*PI; - + ya = Op1CX/65536.0*PI*2; + xa = Op1CY/65536.0*PI*2; + za = Op1CZ/65536.0*PI*2; // rotate around Z Op1CX1=(Op1CXBR*cos(za)+Op1CYBR*sin(za)); Op1CY1=(Op1CXBR*-sin(za)+Op1CYBR*cos(za)); @@ -1470,20 +1442,3 @@ void DSPOp1C() } #endif - -// Op 0F = Test DSP1 RAM -// Returns 0x0000 if RAM checks OK - -unsigned short Op0FRamsize; -unsigned short Op0FPass; - -void DSPOp0F() -{ - // We use our PC's RAM, not DSP1 RAM but we need to pass the RAM check - Op0FPass = 0x0000; - return; - - #ifdef DebugDSP1 - Log_Message("OP0F RAM Test Pass:%d", Op0FPass); - #endif -} diff --git a/zsnes/src/chips/dsp1proc.asm b/zsnes/src/chips/dsp1proc.asm index 57c69e84..b4af729e 100644 --- a/zsnes/src/chips/dsp1proc.asm +++ b/zsnes/src/chips/dsp1proc.asm @@ -22,7 +22,6 @@ EXTSYM DSPOp0A,Op0AA,Op0AB,Op0AC,Op0AD,Op0AVS,DSPOp10 EXTSYM debstop EXTSYM DSPOp00,Op00Multiplicand,Op00Multiplier EXTSYM Op00Result -;EXTSYM DSPOp10,Op10a,Op10b,Op10A,Op10B EXTSYM DSPOp0F,Op0FPass EXTSYM DSPOp04,Op04Angle,Op04Cos,Op04Radius,Op04Sin EXTSYM DSPOp28,Op28R,Op28X,Op28Y,Op28Z @@ -54,9 +53,11 @@ NEWSYM Dsp1ProcAsmStart +SECTION .bss +NEWSYM dsp1ptr, resd 1 +NEWSYM dsp1array, resb 4096 -NEWSYM dsp1ptr, dd 0 -NEWSYM dsp1array, times 4096 db 0 +SECTION .text ;******************************************************* ; DSP1 Read Functions @@ -75,7 +76,6 @@ NEWSYM DSP1Read8b3F mov al,80h ret - NEWSYM DSP1Read16b3F test ecx,8000h jnz .dsp1area @@ -85,7 +85,7 @@ NEWSYM DSP1Read16b3F jae .doC000 cmp byte[DSP1RLeft],0 jne .movestuff - mov ax,0FFFFh + xor ax,ax ret .doC000 mov ax,08000h @@ -145,7 +145,7 @@ NEWSYM DSP1Read16b jae .do7000 cmp byte[DSP1RLeft],0 jne .movestuff - mov ax,0FFFFh + xor ax,ax ret .do7000 mov ax,8000h @@ -305,16 +305,19 @@ NEWSYM DSP1Write16b DSP1WriteProc 0Fh, DSP1_0F ; DSP RAM Check ret -NEWSYM DSP1COp, db 0 -NEWSYM DSP1RLeft, db 0 -NEWSYM DSP1WLeft, db 0 -NEWSYM DSP1CPtrW, db 0 -NEWSYM DSP1CPtrR, db 0 -NEWSYM DSP1VARS, times 16 dw 0 -NEWSYM DSP1RET, times 16 dw 0 -NEWSYM DSPDet, db 0 +SECTION .bss +NEWSYM DSP1COp, resb 1 +NEWSYM DSP1RLeft, resb 1 +NEWSYM DSP1WLeft, resb 1 +NEWSYM DSP1CPtrW, resb 1 +NEWSYM DSP1CPtrR, resb 1 +NEWSYM DSP1VARS, resw 16 +NEWSYM DSP1RET, resw 16 +NEWSYM DSPDet, resb 1 -NEWSYM DSPFuncUsed, times 256 db 0 +NEWSYM DSPFuncUsed, resb 256 + +SECTION .text ;******************************************************* ; DSP1 Conversion Functions @@ -337,6 +340,7 @@ DSP1_00: ; 16-bit multiply EXTSYM Op10Exponent, Op10ExponentR EXTSYM Op10Coefficient, Op10CoefficientR + DSP1_10: ; Inverse push eax mov ax,[DSP1VARS] @@ -371,6 +375,7 @@ DSP1_04: ; Trigonometric mov byte[DSP1RLeft],2 pop eax ret + DSP1_08: ; Vector Size push eax mov ax,[DSP1VARS] @@ -389,6 +394,7 @@ DSP1_08: ; Vector Size mov byte[DSP1RLeft],2 pop eax ret + DSP1_18: ; Vector Size Comparison push eax mov ax,[DSP1VARS] @@ -426,7 +432,6 @@ DSP1_28: ; Vector Absolute Value pop eax ret - DSP1_0C: ; Coordinate Rotation or byte[DSPDet],08h push eax @@ -446,6 +451,7 @@ DSP1_0C: ; Coordinate Rotation mov byte[DSP1RLeft],2 pop eax ret + DSP1_1C: ; 3D Coordinate Rotation push eax mov ax,[DSP1VARS] @@ -473,7 +479,6 @@ DSP1_1C: ; 3D Coordinate Rotation pop eax ret - DSP1_02: ; Vector Size or byte[DSPDet],10h push eax @@ -564,6 +569,7 @@ DSP1_0A: ; Raster Data Calculation via DMA mov byte[DSP1RLeft],4 pop eax ret + DSP1_06: ; Object Projection Calculation or byte[DSPDet],40h push eax @@ -603,6 +609,7 @@ DSP1_06: ; Object Projection Calculation mov [eax+11],bx pop ebx add dword[dsp1ptr],13 + DSP1_0E: ; Coordinate Calculation of a point onscreen push eax mov ax,[DSP1VARS] @@ -619,6 +626,7 @@ DSP1_0E: ; Coordinate Calculation of a point onscreen mov byte[DSP1RLeft],2 pop eax ret + DSP1_01: ; Set Attitude Matrix A push eax mov ax,[DSP1VARS] @@ -634,6 +642,7 @@ DSP1_01: ; Set Attitude Matrix A popad pop eax ret + DSP1_11: ; Set Attitude Matrix B push eax mov ax,[DSP1VARS] @@ -649,6 +658,7 @@ DSP1_11: ; Set Attitude Matrix B popad pop eax ret + DSP1_21: ; Set Attitude Matrix C push eax mov ax,[DSP1VARS] @@ -664,6 +674,7 @@ DSP1_21: ; Set Attitude Matrix C popad pop eax ret + DSP1_0D: ; Convert from global to object coords Matrix A push eax mov ax,[DSP1VARS] @@ -684,6 +695,7 @@ DSP1_0D: ; Convert from global to object coords Matrix A mov byte[DSP1RLeft],3 pop eax ret + DSP1_0F: ; DSP RAM Test push eax mov ax,[DSP1VARS] @@ -695,6 +707,7 @@ DSP1_0F: ; DSP RAM Test mov byte[DSP1RLeft],1 pop eax ret + DSP1_1D: ; Convert from global to object coords Matrix B push eax mov ax,[DSP1VARS] @@ -715,6 +728,7 @@ DSP1_1D: ; Convert from global to object coords Matrix B mov byte[DSP1RLeft],3 pop eax ret + DSP1_2D: ; Convert from global to object coords Matrix C push eax mov ax,[DSP1VARS] @@ -735,6 +749,7 @@ DSP1_2D: ; Convert from global to object coords Matrix C mov byte[DSP1RLeft],3 pop eax ret + DSP1_03: ; Convert from object to global coords Matrix A push eax mov ax,[DSP1VARS] @@ -755,6 +770,7 @@ DSP1_03: ; Convert from object to global coords Matrix A mov byte[DSP1RLeft],3 pop eax ret + DSP1_13: ; Convert from object to global coords Matrix B push eax mov ax,[DSP1VARS] @@ -775,6 +791,7 @@ DSP1_13: ; Convert from object to global coords Matrix B mov byte[DSP1RLeft],3 pop eax ret + DSP1_23: ; Convert from object to global coords Matrix C push eax mov ax,[DSP1VARS] @@ -795,6 +812,7 @@ DSP1_23: ; Convert from object to global coords Matrix C mov byte[DSP1RLeft],3 pop eax ret + DSP1_0B: ; Calculation of inner product Matrix A push eax mov ax,[DSP1VARS] @@ -811,6 +829,7 @@ DSP1_0B: ; Calculation of inner product Matrix A mov byte[DSP1RLeft],1 pop eax ret + DSP1_1B: ; Calculation of inner product Matrix B push eax mov ax,[DSP1VARS] @@ -827,6 +846,7 @@ DSP1_1B: ; Calculation of inner product Matrix B mov byte[DSP1RLeft],1 pop eax ret + DSP1_2B: ; Calculation of inner product Matrix C push eax mov ax,[DSP1VARS] @@ -843,6 +863,7 @@ DSP1_2B: ; Calculation of inner product Matrix C mov byte[DSP1RLeft],1 pop eax ret + DSP1_14: ; 3D angle rotation push eax mov ax,[DSP1VARS] diff --git a/zsnes/src/chips/fxemu2.asm b/zsnes/src/chips/fxemu2.asm index 1079e049..ad35fbc0 100644 --- a/zsnes/src/chips/fxemu2.asm +++ b/zsnes/src/chips/fxemu2.asm @@ -37,10 +37,10 @@ NEWSYM FlushCache ; Copy 512 bytes from pb:eax to SfxCACHERAM ret -SECTION .data -NEWSYM tempsfx, db 0,0,0 +SECTION .bss +NEWSYM tempsfx, resb 3 -ALIGN32 +SECTION .data ;ALIGN=32 ; FxChip emulation by _Demo_ ; Optimised by zsKnight @@ -119,7 +119,6 @@ NEWSYM SfxB, dd 0 ; B flag (1 when with instruction executed) NEWSYM SfxOverflow, dd 0 ; Overflow flag NEWSYM SfxCACHERAM, times 512 db 0 ; 512 bytes of GSU cache memory -SECTION .data num2writesfxreg equ $-SfxR0 ; pharos equ hack *sigh* NEWSYM PHnum2writesfxreg, dd num2writesfxreg @@ -844,10 +843,13 @@ NEWSYM FxOp4C ; PLOT plot pixel with R1,R2 as x,y and the color register inc word [SfxR1] ret -.prevx dw 0 -.prevy dw 0 +SECTION .bss +.prevx resw 1 +.prevy resw 1 -sfxwarning db 0 +sfxwarning resb 1 + +SECTION .text NEWSYM FxOp4CA1 ; RPIX read color of the pixel with R1,R2 as x,y FETCHPIPE @@ -2646,11 +2648,13 @@ NEWSYM FxOpFFA2 ; SM (XX),RN store word in RAM CLRFLAGS ret -ALIGN32 +SECTION .bss ;ALIGN=32 -NEWSYM NumberOfOpcodes, dd 0 ; Number of opcodes to execute -NEWSYM NumberOfOpcodesBU, dd 0 ; Number of opcodes to execute backup value -NEWSYM sfxwarningb, db 0 +NEWSYM NumberOfOpcodes, resd 1 ; Number of opcodes to execute +NEWSYM NumberOfOpcodesBU, resd 1 ; Number of opcodes to execute backup value +NEWSYM sfxwarningb, resb 1 + +SECTION .text NEWSYM MainLoop mov eax,[SfxPBR] diff --git a/zsnes/src/chips/fxemu2c.asm b/zsnes/src/chips/fxemu2c.asm index f10583b2..c4e2d202 100644 --- a/zsnes/src/chips/fxemu2c.asm +++ b/zsnes/src/chips/fxemu2c.asm @@ -39,7 +39,7 @@ NEWSYM FxEmu2CAsmStart - +SECTION .text ;ALIGN=32 ALIGN32 NEWSYM FxOpd00 ; STOP stop GSU execution (and maybe generate an IRQ) ; Verified. @@ -747,8 +747,11 @@ NEWSYM FxOpd4C ; PLOT plot pixel with R1,R2 as x,y and the color register inc word [SfxR1] FXReturn -.prevx dw 0 -.prevy dw 0 +SECTION .bss +.prevx resw 1 +.prevy resw 1 + +SECTION .text NEWSYM FxOpd4CA1 ; RPIX read color of the pixel with R1,R2 as x,y FETCHPIPE diff --git a/zsnes/src/chips/fxtable.asm b/zsnes/src/chips/fxtable.asm index ef1cdd4e..27c55b74 100644 --- a/zsnes/src/chips/fxtable.asm +++ b/zsnes/src/chips/fxtable.asm @@ -199,11 +199,12 @@ NEWSYM FxTableAsmStart - -NEWSYM sfx128lineloc, dd 0 -NEWSYM sfx160lineloc, dd 0 -NEWSYM sfx192lineloc, dd 0 -NEWSYM sfxobjlineloc, dd 0 +SECTION .bss ;ALIGN=32 +NEWSYM sfx128lineloc, resd 1 +NEWSYM sfx160lineloc, resd 1 +NEWSYM sfx192lineloc, resd 1 +NEWSYM sfxobjlineloc, resd 1 +SECTION .text NEWSYM InitFxTables @@ -3222,6 +3223,7 @@ NEWSYM InitFxTables ret ; normal +SECTION .data NEWSYM sfxnametab db 'STOP NOP CACHE LSR ' db 'ROL BRA BLT BGE ' @@ -3544,4 +3546,6 @@ NEWSYM sfxnametab db 'IWT R8 IWT R9 IWT R10 IWT R11 ' db 'IWT R12 IWT R13 IWT R14 IWT R15 ' +SECTION .text + NEWSYM FxTableAsmEnd diff --git a/zsnes/src/chips/sa1proc.asm b/zsnes/src/chips/sa1proc.asm index 0196e54d..ff9a3712 100644 --- a/zsnes/src/chips/sa1proc.asm +++ b/zsnes/src/chips/sa1proc.asm @@ -18,7 +18,7 @@ %include "macros.mac" EXTSYM xa,xx,xy,xd,xdb,xpb,xs,xe,initaddrl,UpdateDPage,wramdata,IRAM,cycpbl,SA1DoIRQ -EXTSYM spcnumread,SA1IRQEn,nextopcodesa1,debugds +EXTSYM spcnumread,spchalted,SA1IRQEn,nextopcodesa1,debugds EXTSYM SNSRegP,SNSRegE,SNSRegPCS,SA1Ptr,SNSPtr,nmiv,irqv,nmiv2,irqv2,snesmap2,SA1tablead EXTSYM SA1xpb,SA1RegP,wramdataa,SA1TimerVal,debuggeron EXTSYM SA1RegE,SA1RegPCS,SA1BWPtr,SNSBWPtr,CurBWPtr,SA1NMIV,SA1IRQV,debstop,tablead @@ -35,14 +35,16 @@ NEWSYM Sa1ProcAsmStart ; *** Disable spc700 if possible *** +SECTION .bss ;ALIGN=32 +NEWSYM SA1Status, resb 1 ; 0 = 65816, 1 = SA1A, 2 = SA1B -NEWSYM SA1Status, db 0 ; 0 = 65816, 1 = SA1A, 2 = SA1B +NEWSYM CurrentExecSA1, resb 1 +NEWSYM CurrentCPU, resb 1 -NEWSYM CurrentExecSA1, db 0 -NEWSYM CurrentCPU, db 0 +;ALIGN32 +NEWSYM prevedi, resd 1 -ALIGN32 -NEWSYM prevedi, dd 0 +SECTION .text %macro SA1Debugb 0 pushad @@ -232,7 +234,9 @@ NEWSYM SA1Swap or byte[SA1DoIRQ],8 jmp .returnirq -NEWSYM SA1xpc, dd 0 +SECTION .bss +NEWSYM SA1xpc, resd 1 +SECTION .text %macro makedl 0 and dl,00111100b diff --git a/zsnes/src/chips/sa1regs.asm b/zsnes/src/chips/sa1regs.asm index 8c70786f..3230f70e 100644 --- a/zsnes/src/chips/sa1regs.asm +++ b/zsnes/src/chips/sa1regs.asm @@ -62,9 +62,8 @@ NEWSYM Sa1RegsAsmStart +SECTION .data ;ALIGN=32 - -ALIGN32 NEWSYM SPCMultA, dd 0 NEWSYM SPCMultB, dd 0 NEWSYM SPCDivEnd, dd 0 @@ -96,6 +95,8 @@ NEWSYM SPC7110TempPosition, dd 0 NEWSYM SPC7110TempLength, dd 0 NEWSYM SPCPrevCompPtr, dd 0 +SECTION .text + RTC2800: push ebx cmp dword[RTCRest],100 @@ -274,7 +275,10 @@ SPC485F: mov al,[SPC7110RTC+0Fh] ret -NEWSYM SPCDecompFin, dd 0 +SECTION .bss +NEWSYM SPCDecompFin, resd 1 + +SECTION .text NEWSYM SPC7110init mov dword[SPCMultA],0 @@ -592,16 +596,19 @@ SPC480C: ; decompression finished status mov byte[SPCDecompFin],0 ret -NEWSYM CurPtrVal, dd 0 -NEWSYM CurCompCounter2, dd 0 -NEWSYM CurPtrLen, dd 0 -NEWSYM CurValUsed, db 0 -NEWSYM PrevDecompPtr, dw 0 -NEWSYM CurDecompPtr, dw 0 -NEWSYM CurDecompSize, dw 0 -NEWSYM DecompArray, times 65536 db 0 -NEWSYM DecompAPtr, dd 0 -lastentry dd 0 +SECTION .bss +NEWSYM CurPtrVal, resd 1 +NEWSYM CurCompCounter2, resd 1 +NEWSYM CurPtrLen, resd 1 +NEWSYM CurValUsed, resb 1 +NEWSYM PrevDecompPtr, resw 1 +NEWSYM CurDecompPtr, resw 1 +NEWSYM CurDecompSize, resw 1 +NEWSYM DecompArray, resb 65536 +NEWSYM DecompAPtr, resd 1 +lastentry resd 1 + +SECTION .text NEWSYM UpdateRTC @@ -1423,11 +1430,14 @@ SPC4841: mov al,byte[SPC7110RTCStat+2] ret +SECTION .data SPCTimerVal db 12h,01h,02h,03h,04h,05h,06h,07h,08h,09h,0,0,0,0,0,0 db 10h,11h,32h,21h,22h,23h,24h,25h,26h,27h,0,0,0,0,0,0 db 28h,29h +SECTION .text + SPC4842: mov al,80h ret @@ -1461,7 +1471,7 @@ SPC4842: ; SA-1 Start ; ---------- -ALIGN32 +SECTION .data ;ALIGN=32 ; IRQ Stuff NEWSYM SA1Mode, dd 0 ; 0 = SNES CPU, 1 = SA1 CPU @@ -1547,6 +1557,8 @@ NEWSYM Sdd1Bank, dd 0 NEWSYM Sdd1Addr, dd 0 NEWSYM Sdd1NewAddr, dd 0 +SECTION .text + %macro SA1QuickF 2 NEWSYM %1 mov [%2],al @@ -2297,8 +2309,11 @@ NEWSYM sa12239w mov [SA1DMACount+1],al ret -NEWSYM sa1dmaptr, dd 0 -NEWSYM sa1dmaptrs, dd 0 +SECTION .bss +NEWSYM sa1dmaptr, resd 1 +NEWSYM sa1dmaptrs, resd 1 + +SECTION .text NEWSYM sa1dmairam mov ebx,[SA1DMADest] @@ -2359,8 +2374,10 @@ executesa1dma: pop edx ret +SECTION .bss +tempblah resb 1 -tempblah db 0 +SECTION .text %macro setbit2b 2 test al,%1 @@ -2553,7 +2570,10 @@ sa1chconv: popad ret -.numrows dd 0 +SECTION .bss +.numrows resd 1 + +SECTION .text NEWSYM initSA1regs setreg 2300h*4,sa12300r diff --git a/zsnes/src/chips/sfxproc.asm b/zsnes/src/chips/sfxproc.asm index 4f0b45f0..a0d1dac2 100644 --- a/zsnes/src/chips/sfxproc.asm +++ b/zsnes/src/chips/sfxproc.asm @@ -190,7 +190,10 @@ NEWSYM cacheregw or byte[cachewarning],2 ret -NEWSYM cachewarning, db 0 +SECTION .bss +NEWSYM cachewarning, resb 1 + +SECTION .text ; SFX Registers @@ -315,7 +318,10 @@ NEWSYM reg3031r .cleared mov al,[SfxSFR+1] ret -.test db 0 +SECTION .bss +.test resb 1 +SECTION .text + NEWSYM reg3032r ; Unused xor al,al ret