First release of ZSNES sources
This commit is contained in:
953
zsnes/src/chips/dsp1emu.c
Normal file
953
zsnes/src/chips/dsp1emu.c
Normal file
@@ -0,0 +1,953 @@
|
||||
//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
|
||||
//
|
||||
//This program is free software; you can redistribute it and/or
|
||||
//modify it under the terms of the GNU General Public License
|
||||
//as published by the Free Software Foundation; either
|
||||
//version 2 of the License, or (at your option) any later
|
||||
//version.
|
||||
//
|
||||
//This program is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with this program; if not, write to the Free Software
|
||||
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <math.h>
|
||||
|
||||
#define DebugDSP1
|
||||
|
||||
// uncomment some lines to test
|
||||
//#define printinfo
|
||||
//#define debug02
|
||||
//#define debug0A
|
||||
//#define debug06
|
||||
|
||||
|
||||
#ifdef DebugDSP1
|
||||
|
||||
FILE * LogFile = NULL;
|
||||
|
||||
void Log_Message (char *Message, ...)
|
||||
{
|
||||
char Msg[400];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap,Message);
|
||||
vsprintf(Msg,Message,ap );
|
||||
va_end(ap);
|
||||
|
||||
strcat(Msg,"\r\n\0");
|
||||
fwrite(Msg,strlen(Msg),1,LogFile);
|
||||
}
|
||||
|
||||
void Start_Log (void)
|
||||
{
|
||||
char LogFileName[255];
|
||||
char *p;
|
||||
|
||||
strcpy(LogFileName,"dsp1emu.log\0");
|
||||
|
||||
LogFile = fopen(LogFileName,"wb");
|
||||
}
|
||||
|
||||
void Stop_Log (void)
|
||||
{
|
||||
if (LogFile)
|
||||
{
|
||||
fclose(LogFile);
|
||||
LogFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************\
|
||||
* Math tables *
|
||||
\***************************************************************************/
|
||||
|
||||
int CosTable2[256]={65536,65516,65457,65358,65220,65043,64826,64571,64276,63943,63571,63161,62713,62227,61704,61144,60546,59912,59243,58537,57796,
|
||||
57020,56210,55367,54489,53579,52637,51663,50658,49622,48556,47461,46338,45187,44008,42803,41572,
|
||||
40316,39036,37732,36406,35057,33688,32298,30889,29461,28015,26553,25074,23581,22073,20552,19018,17473,15918,14353,12779,11198,9610,8016,6417,4814,
|
||||
3209,1601,-6,-1615,-3222,-4828,-6430,-8029,-9623,-11211,-12792,-14366,-15931,-17486,-19031,-20565,-22086,-23593,-25087,-26565,-28028,-29473,
|
||||
-30901,-32310,-33700,-35069,-36417,-37743,-39047,-40327,-41583,-42813,-44018,-45197,-46348,-47471,-48565,
|
||||
-49631,-50666,-51671,-52645,-53587,-54497,-55374,-56217,-57027,-57802,-58543,-59248,-59918,-60551,-61148,
|
||||
-61709,-62232,-62717,-63165,-63575,-63946,-64279,-64573,-64828,-65044,-65221,-65359,-65457,-65516,-65535,
|
||||
-65515,-65456,-65357,-65219,-65041,-64824,-64568,-64273,-63940,-63568,-63158,-62709,-62223,-61699,-61139,
|
||||
-60541,-59907,-59237,-58531,-57790,-57014,-56203,-55359,-54482,-53571,-52629,-51654,-50649,-49613,-48547,
|
||||
-47452,-46328,-45177,-43998,-42793,-41562,-40306,-39025,-37721,-36395,-35046,-33676,-32286,-30877,-29449,
|
||||
-28003,-26540,-25062,-23568,-22060,-20539,-19005,-17460,-15905,-14340,-12766,-11184,-9596,-8002,-6403,
|
||||
-4801,-3195,-1588,20,1628,3236,4841,6444,8043,9636,11224,12806,14379,15944,17500,19044,20578,22099,
|
||||
23606,25099,26578,28040,29485,30913,32322,33711,35080,36428,37754,39058,40338,41593,42824,44028,
|
||||
45206,46357,47480,48575,49640,50675,51680,52653,53595,54504,55381,56224,57034,57809,58549,59254,
|
||||
59923,60557,61153,61713,62236,62721,63168,63578,63949,64281,64575,64830,65046,65223,65360,65458,65516};
|
||||
|
||||
int SinTable2[256]={0,1608,3215,4821,6424,8022,9616,11204,12786,14359,15924,17480,19025,20558,22079,
|
||||
23587,25081,26559,28021,29467,30895,32304,33694,35063,36411,37738,39041,40322,41577,42808,44013,
|
||||
45192,46343,47466,48561,49626,50662,51667,52641,53583,54493,55370,56214,57024,57799,58540,59245,
|
||||
59915,60549,61146,61706,62229,62715,63163,63573,63944,64277,64572,64827,65043,65221,65358,65457,
|
||||
65516,65535,65516,65456,65357,65219,65042,64825,64569,64275,63941,63570,63159,62711,62225,61702,
|
||||
61141,60544,59910,59240,58534,57793,57017,56207,55363,54486,53575,52633,51659,50653,49617,48552,
|
||||
47457,46333,45182,44003,42798,41567,40311,39031,37727,36400,35052,33682,32292,30883,29455,28009,
|
||||
26547,25068,23574,22067,20545,19012,17467,15911,14346,12772,11191,9603,8009,6410,4807,3202,1594,
|
||||
-13,-1622,-3229,-4834,-6437,-8036,-9630,-11218,-12799,-14373,-15938,-17493,-19038,-20571,-22092,
|
||||
-23600,-25093,-26571,-28034,-29479,-30907,-32316,-33705,-35075,-36423,-37749,-39052,-40332,-41588,-42818,-44023,-45201,-46352,-47476,-48570,-49635,-50671,-51675,-52649,-53591,-54501,-55377,-56221,-57030,-57806,-58546,-59251,-59921,-60554,-61151,-61711,
|
||||
-62234,-62719,-63167,-63576,-63947,-64280,-64574,-64829,-65045,-65222,-65359,-65458,-65516,-65535,
|
||||
-65515,-65456,-65356,-65218,-65040,-64823,-64567,-64272,-63938,-63566,-63156,-62707,-62221,-61697,
|
||||
-61136,-60538,-59904,-59234,-58528,-57786,-57010,-56200,-55356,-54478,-53567,-52625,-51650,-50645,
|
||||
-49609,-48543,-47447,-46324,-45172,-43993,-42788,-41556,-40300,-39020,-37716,-36389,-35040,-33670,
|
||||
-32280,-30871,-29443,-27997,-26534,-25056,-23562,-22054,-20532,-18999,-17454,-15898,-14333,-12759,
|
||||
-11178,-9589,-7995,-6397,-4794,-3188,-1581};
|
||||
|
||||
|
||||
|
||||
/***************************************************************************\
|
||||
* C4 C code *
|
||||
\***************************************************************************/
|
||||
|
||||
|
||||
short C4WFXVal;
|
||||
short C4WFYVal;
|
||||
short C4WFZVal;
|
||||
short C4WFX2Val;
|
||||
short C4WFY2Val;
|
||||
short C4WFDist;
|
||||
short C4WFScale;
|
||||
double tanval;
|
||||
double c4x,c4y,c4z;
|
||||
double c4x2,c4y2,c4z2;
|
||||
|
||||
C4TransfWireFrame()
|
||||
{
|
||||
c4x=(double)C4WFXVal;
|
||||
c4y=(double)C4WFYVal;
|
||||
c4z=(double)C4WFZVal-0x95;
|
||||
|
||||
// Rotate X
|
||||
tanval=-(double)C4WFX2Val*3.14159265*2/128;
|
||||
c4y2=c4y*cos(tanval)-c4z*sin(tanval);
|
||||
c4z2=c4y*sin(tanval)+c4z*cos(tanval);
|
||||
|
||||
// Rotate Y
|
||||
tanval=-(double)C4WFY2Val*3.14159265*2/128;
|
||||
c4x2=c4x*cos(tanval)+c4z2*sin(tanval);
|
||||
c4z=c4x*-sin(tanval)+c4z2*cos(tanval);
|
||||
|
||||
// Rotate Z
|
||||
tanval=-(double)C4WFDist*3.14159265*2/128;
|
||||
c4x=c4x2*cos(tanval)-c4y2*sin(tanval);
|
||||
c4y=c4x2*sin(tanval)+c4y2*cos(tanval);
|
||||
|
||||
// Scale
|
||||
C4WFXVal=c4x*(double)C4WFScale/(0x90*(c4z+0x95))*0x95;
|
||||
C4WFYVal=c4y*(double)C4WFScale/(0x90*(c4z+0x95))*0x95;
|
||||
}
|
||||
|
||||
C4TransfWireFrame2()
|
||||
{
|
||||
c4x=(double)C4WFXVal;
|
||||
c4y=(double)C4WFYVal;
|
||||
c4z=(double)C4WFZVal;
|
||||
|
||||
// Rotate X
|
||||
tanval=-(double)C4WFX2Val*3.14159265*2/128;
|
||||
c4y2=c4y*cos(tanval)-c4z*sin(tanval);
|
||||
c4z2=c4y*sin(tanval)+c4z*cos(tanval);
|
||||
|
||||
// Rotate Y
|
||||
tanval=-(double)C4WFY2Val*3.14159265*2/128;
|
||||
c4x2=c4x*cos(tanval)+c4z2*sin(tanval);
|
||||
c4z=c4x*-sin(tanval)+c4z2*cos(tanval);
|
||||
|
||||
// Rotate Z
|
||||
tanval=-(double)C4WFDist*3.14159265*2/128;
|
||||
c4x=c4x2*cos(tanval)-c4y2*sin(tanval);
|
||||
c4y=c4x2*sin(tanval)+c4y2*cos(tanval);
|
||||
|
||||
// Scale
|
||||
C4WFXVal=c4x*(double)C4WFScale/0x100;
|
||||
C4WFYVal=c4y*(double)C4WFScale/0x100;
|
||||
}
|
||||
|
||||
C4CalcWireFrame()
|
||||
{
|
||||
C4WFXVal=C4WFX2Val-C4WFXVal;
|
||||
C4WFYVal=C4WFY2Val-C4WFYVal;
|
||||
if (abs(C4WFXVal)>abs(C4WFYVal)){
|
||||
C4WFDist=abs(C4WFXVal)+1;
|
||||
C4WFYVal=256*(double)C4WFYVal/abs((double)C4WFXVal);
|
||||
if (C4WFXVal<0) C4WFXVal=-256;
|
||||
else C4WFXVal=256;
|
||||
}
|
||||
else
|
||||
if (C4WFYVal!=0) {
|
||||
C4WFDist=abs(C4WFYVal)+1;
|
||||
C4WFXVal=256*(double)C4WFXVal/abs((double)C4WFYVal);
|
||||
if (C4WFYVal<0) C4WFYVal=-256;
|
||||
else C4WFYVal=256;
|
||||
}
|
||||
else C4WFDist=0;
|
||||
}
|
||||
|
||||
short C41FXVal;
|
||||
short C41FYVal;
|
||||
short C41FAngleRes;
|
||||
short C41FDist;
|
||||
short C41FDistVal;
|
||||
|
||||
C4Op1F()
|
||||
{
|
||||
if (C41FXVal == 0) {
|
||||
if (C41FYVal>0) C41FAngleRes=0x80;
|
||||
else C41FAngleRes=0x180;
|
||||
}
|
||||
else {
|
||||
tanval = ((double)C41FYVal)/((double)C41FXVal);
|
||||
C41FAngleRes=atan(tanval)/(3.141592675*2)*512;
|
||||
C41FAngleRes=C41FAngleRes;
|
||||
if (C41FXVal<0) C41FAngleRes+=0x100;
|
||||
C41FAngleRes&=0x1FF;
|
||||
}
|
||||
}
|
||||
|
||||
C4Op15()
|
||||
{
|
||||
tanval=sqrt(((double)C41FYVal)*((double)C41FYVal)+((double)C41FXVal)*
|
||||
((double)C41FXVal));
|
||||
C41FDist=tanval;
|
||||
}
|
||||
|
||||
C4Op0D()
|
||||
{
|
||||
tanval=sqrt(((double)C41FYVal)*((double)C41FYVal)+((double)C41FXVal)*
|
||||
((double)C41FXVal));
|
||||
tanval=(double)C41FDistVal/tanval;
|
||||
C41FYVal=((double)C41FYVal*tanval)*0.99;
|
||||
C41FXVal=((double)C41FXVal*tanval)*0.98;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************\
|
||||
* DSP1 code *
|
||||
\***************************************************************************/
|
||||
|
||||
|
||||
void InitDSP(void)
|
||||
{
|
||||
#ifdef DebugDSP1
|
||||
Start_Log();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
short Op00Multiplicand;
|
||||
short Op00Multiplier;
|
||||
short Op00Result;
|
||||
|
||||
DSPOp00()
|
||||
{
|
||||
Op00Result=Op00Multiplicand*Op00Multiplier/32768;
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP00 MULT %d*%d/32768=%d",Op00Multiplicand,Op00Multiplier,Op00Result);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
short Op10Coefficient;
|
||||
short Op10Exponent;
|
||||
short Op10CoefficientR;
|
||||
short Op10ExponentR;
|
||||
|
||||
// To fix...
|
||||
|
||||
DSPOp10()
|
||||
{
|
||||
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP10 NOT IMPLEMENTED");
|
||||
#endif
|
||||
|
||||
Op10ExponentR=-Op10Exponent;
|
||||
Op10CoefficientR=1/Op10Coefficient;
|
||||
}
|
||||
|
||||
|
||||
short Op04Angle;
|
||||
unsigned short Op04Radius;
|
||||
short Op04Sin;
|
||||
short Op04Cos;
|
||||
|
||||
DSPOp04()
|
||||
{
|
||||
Op04Sin=SinTable2[(Op04Angle/256)&255]*Op04Radius/65536;
|
||||
Op04Cos=CosTable2[(Op04Angle/256)&255]*Op04Radius/65536;
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP04 Angle:%d Radius:%d",(Op04Angle/256)&255,Op04Radius);
|
||||
Log_Message("OP04 SIN:%d COS:%d",Op04Sin,Op04Cos);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
short Op08X;
|
||||
short Op08Y;
|
||||
short Op08Z;
|
||||
int Op08Size;
|
||||
|
||||
DSPOp08Radius()
|
||||
{
|
||||
Op08Size=(Op08X*Op08X+Op08Y*Op08Y+Op08Z*Op08Z)*2;
|
||||
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP08 %d,%d,%d",Op08X,Op08Y,Op08Z);
|
||||
Log_Message("OP08 ((Op08X^2)+(Op08Y^2)+(Op08X^2))*2=%d",Op08Size );
|
||||
#endif
|
||||
}
|
||||
|
||||
short Op18X;
|
||||
short Op18Y;
|
||||
short Op18Z;
|
||||
short Op18R;
|
||||
short Op18Difference;
|
||||
|
||||
DSPOp18()
|
||||
{
|
||||
Op18Difference=((Op18X*Op18X+Op18Y*Op18Y+Op18Z*Op18Z-Op18R*Op18R)*2)/65536;
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP18 DIFF %d",Op18Difference);
|
||||
#endif
|
||||
}
|
||||
|
||||
short Op28X;
|
||||
short Op28Y;
|
||||
short Op28Z;
|
||||
short Op28R;
|
||||
|
||||
DSPOp28()
|
||||
{
|
||||
Op28R=sqrt(abs(Op28X*Op28X+Op28Y*Op28Y+Op28Z*Op28Z));
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP28 X:%d Y:%d Z:%d",Op18X,Op18Y,Op18Z);
|
||||
Log_Message("OP28 Vector Length %d",Op18R);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned short Op0CA;
|
||||
short Op0CX1;
|
||||
short Op0CY1;
|
||||
short Op0CX2;
|
||||
short Op0CY2;
|
||||
|
||||
DSPOp0C()
|
||||
{
|
||||
Op0CX2=(Op0CX1*CosTable2[(Op0CA/256)&255]+Op0CY1*SinTable2[(Op0CA/256)&255])/65536;
|
||||
Op0CY2=(Op0CX1*-SinTable2[(Op0CA/256)&255]+Op0CY1*CosTable2[(Op0CA/256)&255])/65536;
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP0C Angle:%d X:%d Y:%d CX:%d CY:%d",(Op0CA/256)&255,Op0CX1,Op0CY1,Op0CX2,Op0CY2);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned short Op1CAZ;
|
||||
unsigned short Op1CAX;
|
||||
unsigned short Op1CAY;
|
||||
short Op1CX;
|
||||
short Op1CY;
|
||||
short Op1CZ;
|
||||
short Op1CX1;
|
||||
short Op1CY1;
|
||||
short Op1CZ1;
|
||||
short Op1CX2;
|
||||
short Op1CY2;
|
||||
short Op1CZ2;
|
||||
short Op1CX3;
|
||||
short Op1CY3;
|
||||
short Op1CZ3;
|
||||
|
||||
DSPOp1C()
|
||||
{
|
||||
// rotate around Y
|
||||
Op1CX1=(Op1CX*CosTable2[(Op1CAY/256)&255]+Op1CZ*SinTable2[(Op1CAY/256)&255])/65536;
|
||||
Op1CY1=Op1CY;
|
||||
Op1CZ1=(Op1CX*-SinTable2[(Op1CAY/256)&255]+Op1CZ*CosTable2[(Op1CAY/256)&255])/65536;
|
||||
// rotate around X
|
||||
Op1CX2=Op1CX1;
|
||||
Op1CY2=(Op1CY1*CosTable2[(Op1CAX/256)&255]+Op1CZ1*-SinTable2[(Op1CAX/256)&255])/65536;
|
||||
Op1CZ2=(Op1CY1*SinTable2[(Op1CAX/256)&255]+Op1CZ1*CosTable2[(Op1CAX/256)&255])/65536;
|
||||
// rotate around Z
|
||||
Op1CX3=(Op1CX2*CosTable2[(Op1CAZ/256)&255]+Op1CY2*-SinTable2[(Op1CAZ/256)&255])/65536;
|
||||
Op1CY3=(Op1CX2*SinTable2[(Op1CAZ/256)&255]+Op1CY2*CosTable2[(Op1CAZ/256)&255])/65536;
|
||||
Op1CZ3=Op1CZ2;
|
||||
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP1C Apply Matrix CX:%d CY:%d CZ",Op1CX3,Op1CY3,Op1CZ3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
short Op02FX;
|
||||
short Op02FY;
|
||||
short Op02FZ;
|
||||
short Op02LFE;
|
||||
short Op02LES;
|
||||
unsigned short Op02AAS;
|
||||
unsigned short Op02AZS;
|
||||
unsigned short Op02VOF;
|
||||
unsigned short Op02VVA;
|
||||
|
||||
short Op02CX;
|
||||
short Op02CY;
|
||||
double Op02CXF;
|
||||
double Op02CYF;
|
||||
double ViewerX0;
|
||||
double ViewerY0;
|
||||
double ViewerZ0;
|
||||
double ViewerX1;
|
||||
double ViewerY1;
|
||||
double ViewerZ1;
|
||||
double ViewerX;
|
||||
double ViewerY;
|
||||
double ViewerZ;
|
||||
int ViewerAX;
|
||||
int ViewerAY;
|
||||
int ViewerAZ;
|
||||
double NumberOfSlope;
|
||||
double ScreenX;
|
||||
double ScreenY;
|
||||
double ScreenZ;
|
||||
double TopLeftScreenX;
|
||||
double TopLeftScreenY;
|
||||
double TopLeftScreenZ;
|
||||
double BottomRightScreenX;
|
||||
double BottomRightScreenY;
|
||||
double BottomRightScreenZ;
|
||||
double Ready;
|
||||
double RasterLX;
|
||||
double RasterLY;
|
||||
double RasterLZ;
|
||||
double ScreenLX1;
|
||||
double ScreenLY1;
|
||||
double ScreenLZ1;
|
||||
|
||||
DSPOp02()
|
||||
{
|
||||
ViewerZ1=-cos(Op02AZS*6.2832/65536.0);
|
||||
ViewerX1=sin(Op02AZS*6.2832/65536.0)*sin(Op02AAS*6.2832/65536.0);
|
||||
ViewerY1=sin(Op02AZS*6.2832/65536.0)*cos(-Op02AAS*6.2832/65536.0);
|
||||
|
||||
#ifdef debug02
|
||||
printf("\nViewerX1 : %f ViewerY1 : %f ViewerZ1 : %f\n",ViewerX1,ViewerY1,
|
||||
ViewerZ1);
|
||||
getch();
|
||||
#endif
|
||||
ViewerX=Op02FX-ViewerX1*Op02LFE;
|
||||
ViewerY=Op02FY-ViewerY1*Op02LFE;
|
||||
ViewerZ=Op02FZ-ViewerZ1*Op02LFE;
|
||||
|
||||
ScreenX=Op02FX+ViewerX1*(Op02LES-Op02LFE);
|
||||
ScreenY=Op02FY+ViewerY1*(Op02LES-Op02LFE);
|
||||
ScreenZ=Op02FZ+ViewerZ1*(Op02LES-Op02LFE);
|
||||
|
||||
#ifdef debug02
|
||||
printf("ViewerX : %f ViewerY : %f ViewerZ : %f\n",ViewerX,ViewerY,ViewerZ);
|
||||
printf("Op02FX : %d Op02FY : %d Op02FZ : %d\n",Op02FX,Op02FY,Op02FZ);
|
||||
printf("ScreenX : %f ScreenY : %f ScreenZ : %f\n",ScreenX,ScreenY,ScreenZ);
|
||||
getch();
|
||||
#endif
|
||||
if (ViewerZ1==0)ViewerZ1++;
|
||||
NumberOfSlope=ViewerZ/-ViewerZ1;
|
||||
|
||||
Op02CX=ViewerX+ViewerX1*NumberOfSlope;
|
||||
Op02CY=ViewerY+ViewerY1*NumberOfSlope;
|
||||
|
||||
Op02CXF=ViewerX+ViewerX1*NumberOfSlope;
|
||||
Op02CYF=ViewerY+ViewerY1*NumberOfSlope;
|
||||
|
||||
Op02VOF=0x0000;
|
||||
if(Op02LFE==0x2200)Op02VVA=0xFECD;
|
||||
else Op02VVA=0xFFB2;
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP02 FX:%d FY:%d FZ:%d LFE:%d LES:%d",Op02FX,Op02FY,Op02FZ,Op02LFE,Op02LES);
|
||||
Log_Message(" AAS:%d AZS:%d VOF:%d VVA:%d",Op02AAS,Op02AZS,Op02VOF,Op02VVA);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
short Op0AVS;
|
||||
short Op0AA;
|
||||
short Op0AB;
|
||||
short Op0AC;
|
||||
short Op0AD;
|
||||
|
||||
double RasterRX;
|
||||
double RasterRY;
|
||||
double RasterRZ;
|
||||
double RasterLSlopeX;
|
||||
double RasterLSlopeY;
|
||||
double RasterLSlopeZ;
|
||||
double RasterRSlopeX;
|
||||
double RasterRSlopeY;
|
||||
double RasterRSlopeZ;
|
||||
double GroundLX;
|
||||
double GroundLY;
|
||||
double GroundRX;
|
||||
double GroundRY;
|
||||
double Distance;
|
||||
|
||||
DSPOp0A()
|
||||
{
|
||||
if(Op0AVS==0)Op0AVS++;
|
||||
|
||||
ScreenLZ1=-cos((Op02AZS-16384.0)*6.2832/65536.0); // -16384.0
|
||||
ScreenLX1=sin((Op02AZS-16384.0)*6.2832/65536.0)*-sin(Op02AAS*6.2832/65536.0);
|
||||
ScreenLY1=-sin((Op02AZS-16384.0)*6.2832/65536.0)*-cos(-Op02AAS*6.2832/65536.0);
|
||||
|
||||
RasterRX=RasterLX=ScreenX+(Op0AVS)*ScreenLX1;
|
||||
RasterRY=RasterLY=ScreenY+(Op0AVS)*ScreenLY1;
|
||||
RasterRZ=RasterLZ=ScreenZ+(Op0AVS)*ScreenLZ1;
|
||||
|
||||
ScreenLX1=sin((Op02AAS+16384.0)*6.2832/65536);
|
||||
ScreenLY1=cos(-(Op02AAS+16384.0)*6.2832/65536);
|
||||
|
||||
RasterLX=RasterLX-128*ScreenLX1;
|
||||
RasterLY=RasterLY-128*ScreenLY1;
|
||||
|
||||
RasterRX=RasterRX+128*ScreenLX1;
|
||||
RasterRY=RasterRY+128*ScreenLY1;
|
||||
|
||||
Distance=Op02LFE;
|
||||
if(Distance==0)Distance=1;
|
||||
|
||||
RasterLSlopeX=(RasterLX-ViewerX)/Distance;
|
||||
RasterLSlopeY=(RasterLY-ViewerY)/Distance;
|
||||
RasterLSlopeZ=(RasterLZ-ViewerZ)/Distance;
|
||||
|
||||
RasterRSlopeX=(RasterRX-ViewerX)/Distance;
|
||||
RasterRSlopeY=(RasterRY-ViewerY)/Distance;
|
||||
RasterRSlopeZ=(RasterRZ-ViewerZ)/Distance;
|
||||
|
||||
if(RasterLSlopeZ==0) RasterLSlopeZ++; // divide by 0
|
||||
|
||||
NumberOfSlope=ViewerZ/-RasterLSlopeZ;
|
||||
|
||||
GroundLX=ViewerX+RasterLSlopeX*NumberOfSlope;
|
||||
GroundLY=ViewerY+RasterLSlopeY*NumberOfSlope;
|
||||
|
||||
if(RasterRSlopeZ==0) RasterRSlopeZ++; // divide by 0
|
||||
|
||||
NumberOfSlope=ViewerZ/-RasterRSlopeZ;
|
||||
|
||||
GroundRX=ViewerX+RasterRSlopeX*NumberOfSlope;
|
||||
GroundRY=ViewerY+RasterRSlopeY*NumberOfSlope;
|
||||
|
||||
|
||||
if(Op02LES==0)Op02LES=1;
|
||||
|
||||
Op0AA=(GroundRX-GroundLX);
|
||||
Op0AB=(GroundRY-GroundLY); //0x300/Op02LES*2;
|
||||
|
||||
if(Op0AVS!=0)
|
||||
{
|
||||
Op0AC=(((Op02CXF)-((GroundRX+GroundLX)/2)))/Op0AVS;
|
||||
Op0AD=(((Op02CYF)-((GroundRY+GroundLY)/2)))/Op0AVS*256;
|
||||
}
|
||||
else
|
||||
{
|
||||
Op0AC=0;
|
||||
Op0AD=0;
|
||||
}
|
||||
Op0AVS+=1;
|
||||
}
|
||||
|
||||
short Op06X;
|
||||
short Op06Y;
|
||||
short Op06Z;
|
||||
short Op06H;
|
||||
short Op06V;
|
||||
unsigned short Op06S;
|
||||
|
||||
double ObjPX;
|
||||
double ObjPY;
|
||||
double ObjPZ;
|
||||
double ObjPX1;
|
||||
double ObjPY1;
|
||||
double ObjPZ1;
|
||||
double ObjPX2;
|
||||
double ObjPY2;
|
||||
double ObjPZ2;
|
||||
double DivideOp06;
|
||||
int Temp;
|
||||
|
||||
DSPOp06()
|
||||
{
|
||||
|
||||
ObjPX=Op06X-Op02CXF;
|
||||
ObjPY=Op06Y-Op02CYF;
|
||||
ObjPZ=Op06Z;
|
||||
|
||||
// rotate around Z
|
||||
ObjPX1=(ObjPX*cos((-Op02AAS+32768)/65536.0*6.2832)+ObjPY*-sin((-Op02AAS+32768)/65536.0*6.2832));
|
||||
ObjPY1=(ObjPX*sin((-Op02AAS+32768)/65536.0*6.2832)+ObjPY*cos((-Op02AAS+32768)/65536.0*6.2832));
|
||||
ObjPZ1=ObjPZ;
|
||||
|
||||
// rotate around X
|
||||
ObjPX2=ObjPX1;
|
||||
ObjPY2=(ObjPY1*cos((-Op02AZS)/65536.0*6.2832)+ObjPZ1*-sin((-Op02AZS)/65536.0*6.2832));
|
||||
ObjPZ2=(ObjPY1*sin((-Op02AZS)/65536.0*6.2832)+ObjPZ1*cos((-Op02AZS)/65536.0*6.2832));
|
||||
|
||||
#ifdef debug06
|
||||
printf("ObjPX2: %f ObjPY2: %f ObjPZ2: %f\n",ObjPX2,ObjPY2,ObjPZ2);
|
||||
#endif
|
||||
|
||||
ObjPZ2=ObjPZ2-Op02LFE;
|
||||
|
||||
if (ObjPZ2<0)
|
||||
{
|
||||
Op06H=-ObjPX2*Op02LES/-(ObjPZ2); //-ObjPX2*256/-ObjPZ2;
|
||||
Op06V=-ObjPY2*Op02LES/-(ObjPZ2); //-ObjPY2*256/-ObjPZ2;
|
||||
Op06S=256*Op02LES/-ObjPZ2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Op06H=0;
|
||||
Op06V=14*16;
|
||||
}
|
||||
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP06 X:%d Y:%d Z:%d",Op06X,Op06Y,Op06Z);
|
||||
Log_Message("OP06 H:%d V:%d S:%d",Op06H,Op06V,Op06S);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
double matrix[4][4];
|
||||
double smat[4][4];
|
||||
double tmat[4][4];
|
||||
double xmat[4][4];
|
||||
double ymat[4][4];
|
||||
double zmat[4][4];
|
||||
double matrix0[4][4];
|
||||
double matrix1[4][4];
|
||||
double matrix2[4][4];
|
||||
double matrixI0[4][4];
|
||||
double matrixI1[4][4];
|
||||
double matrixI2[4][4];
|
||||
|
||||
void InitMatrix()
|
||||
{
|
||||
matrix[0][0]=1; matrix[0][1]=0; matrix[0][2]=0; matrix[0][3]=0;
|
||||
matrix[1][0]=0; matrix[1][1]=1; matrix[1][2]=0; matrix[1][3]=0;
|
||||
matrix[2][0]=0; matrix[2][1]=0; matrix[2][2]=1; matrix[2][3]=0;
|
||||
matrix[3][0]=0; matrix[3][1]=0; matrix[3][2]=0; matrix[3][3]=1;
|
||||
}
|
||||
|
||||
|
||||
void MultMatrix(double result[4][4],double mat1[4][4],double mat2[4][4])
|
||||
{
|
||||
result[0][0]=0;
|
||||
result[0][0]+=(mat1[0][0]*mat2[0][0]+mat1[0][1]*mat2[1][0]+mat1[0][2]*mat2[2][0]+mat1[0][3]*mat2[3][0]);
|
||||
result[0][1]=0;
|
||||
result[0][1]+=(mat1[0][0]*mat2[0][1]+mat1[0][1]*mat2[1][1]+mat1[0][2]*mat2[2][1]+mat1[0][3]*mat2[3][1]);
|
||||
result[0][2]=0;
|
||||
result[0][2]+=(mat1[0][0]*mat2[0][2]+mat1[0][1]*mat2[1][2]+mat1[0][2]*mat2[2][2]+mat1[0][3]*mat2[3][2]);
|
||||
result[0][3]=0;
|
||||
result[0][3]+=(mat1[0][0]*mat2[0][3]+mat1[0][1]*mat2[1][3]+mat1[0][2]*mat2[2][3]+mat1[0][3]*mat2[3][3]);
|
||||
|
||||
result[1][0]=0;
|
||||
result[1][0]+=(mat1[1][0]*mat2[0][0]+mat1[1][1]*mat2[1][0]+mat1[1][2]*mat2[2][0]+mat1[1][3]*mat2[3][0]);
|
||||
result[1][1]=0;
|
||||
result[1][1]+=(mat1[1][0]*mat2[0][1]+mat1[1][1]*mat2[1][1]+mat1[1][2]*mat2[2][1]+mat1[1][3]*mat2[3][1]);
|
||||
result[1][2]=0;
|
||||
result[1][2]+=(mat1[1][0]*mat2[0][2]+mat1[1][1]*mat2[1][2]+mat1[1][2]*mat2[2][2]+mat1[1][3]*mat2[3][2]);
|
||||
result[1][3]=0;
|
||||
result[1][3]+=(mat1[1][0]*mat2[0][3]+mat1[1][1]*mat2[1][3]+mat1[1][2]*mat2[2][3]+mat1[1][3]*mat2[3][3]);
|
||||
|
||||
result[2][0]=0;
|
||||
result[2][0]+=(mat1[2][0]*mat2[0][0]+mat1[2][1]*mat2[1][0]+mat1[2][2]*mat2[2][0]+mat1[2][3]*mat2[3][0]);
|
||||
result[2][1]=0;
|
||||
result[2][1]+=(mat1[2][0]*mat2[0][1]+mat1[2][1]*mat2[1][1]+mat1[2][2]*mat2[2][1]+mat1[2][3]*mat2[3][1]);
|
||||
result[2][2]=0;
|
||||
result[2][2]+=(mat1[2][0]*mat2[0][2]+mat1[2][1]*mat2[1][2]+mat1[2][2]*mat2[2][2]+mat1[2][3]*mat2[3][2]);
|
||||
result[2][3]=0;
|
||||
result[2][3]+=(mat1[2][0]*mat2[0][3]+mat1[2][1]*mat2[1][3]+mat1[2][2]*mat2[2][3]+mat1[2][3]*mat2[3][3]);
|
||||
|
||||
result[3][0]=0;
|
||||
result[3][0]+=(mat1[3][0]*mat2[0][0]+mat1[3][1]*mat2[1][0]+mat1[3][2]*mat2[2][0]+mat1[3][3]*mat2[3][0]);
|
||||
result[3][1]=0;
|
||||
result[3][1]+=(mat1[3][0]*mat2[0][1]+mat1[3][1]*mat2[1][1]+mat1[3][2]*mat2[2][1]+mat1[3][3]*mat2[3][1]);
|
||||
result[3][2]=0;
|
||||
result[3][2]+=(mat1[3][0]*mat2[0][2]+mat1[3][1]*mat2[1][2]+mat1[3][2]*mat2[2][2]+mat1[3][3]*mat2[3][2]);
|
||||
result[3][3]=0;
|
||||
result[3][3]+=(mat1[3][0]*mat2[0][3]+mat1[3][1]*mat2[1][3]+mat1[3][2]*mat2[2][3]+mat1[3][3]*mat2[3][3]);
|
||||
}
|
||||
|
||||
void CopyMatrix(double dest[4][4],double source[4][4])
|
||||
{
|
||||
dest[0][0]=source[0][0];
|
||||
dest[0][1]=source[0][1];
|
||||
dest[0][2]=source[0][2];
|
||||
dest[0][3]=source[0][3];
|
||||
dest[1][0]=source[1][0];
|
||||
dest[1][1]=source[1][1];
|
||||
dest[1][2]=source[1][2];
|
||||
dest[1][3]=source[1][3];
|
||||
dest[2][0]=source[2][0];
|
||||
dest[2][1]=source[2][1];
|
||||
dest[2][2]=source[2][2];
|
||||
dest[2][3]=source[2][3];
|
||||
dest[3][0]=source[3][0];
|
||||
dest[3][1]=source[3][1];
|
||||
dest[3][2]=source[3][2];
|
||||
dest[3][3]=source[3][3];
|
||||
}
|
||||
|
||||
void scale(double sf)
|
||||
{
|
||||
double mat[4][4];
|
||||
smat[0][0]=sf; smat[0][1]=0; smat[0][2]=0; smat[0][3]=0;
|
||||
smat[1][0]=0; smat[1][1]=sf; smat[1][2]=0; smat[1][3]=0;
|
||||
smat[2][0]=0; smat[2][1]=0; smat[2][2]=sf; smat[2][3]=0;
|
||||
smat[3][0]=0; smat[3][1]=0; smat[3][2]=0; smat[3][3]=1;
|
||||
MultMatrix(mat,smat,matrix);
|
||||
CopyMatrix(matrix,mat);
|
||||
}
|
||||
|
||||
void translate(double xt,double yt,double zt)
|
||||
{
|
||||
double mat[4][4];
|
||||
tmat[0][0]=1; tmat[0][1]=0; tmat[0][2]=0; tmat[0][3]=0;
|
||||
tmat[1][0]=0; tmat[1][1]=1; tmat[1][2]=0; tmat[1][3]=0;
|
||||
tmat[2][0]=0; tmat[2][1]=0; tmat[2][2]=1; tmat[2][3]=0;
|
||||
tmat[3][0]=xt; tmat[3][1]=yt; tmat[3][2]=zt; tmat[3][3]=1;
|
||||
MultMatrix(mat,matrix,tmat);
|
||||
CopyMatrix(matrix,mat);
|
||||
}
|
||||
|
||||
void rotate(double ax,double ay,double az)
|
||||
{
|
||||
double mat1[4][4];
|
||||
double mat2[4][4];
|
||||
xmat[0][0]=1; xmat[0][1]=0; xmat[0][2]=0; xmat[0][3]=0;
|
||||
xmat[1][0]=0; xmat[1][1]=cos(ax); xmat[1][2]=sin(ax); xmat[1][3]=0;
|
||||
xmat[2][0]=0; xmat[2][1]=-(sin(ax)); xmat[2][2]=cos(ax); xmat[2][3]=0;
|
||||
xmat[3][0]=0; xmat[3][1]=0; xmat[3][2]=0; xmat[3][3]=1;
|
||||
MultMatrix(mat1,xmat,matrix);
|
||||
ymat[0][0]=cos(ay); ymat[0][1]=0; ymat[0][2]=-(sin(ay)); ymat[0][3]=0;
|
||||
ymat[1][0]=0; ymat[1][1]=1; ymat[1][2]=0; ymat[1][3]=0;
|
||||
ymat[2][0]=sin(ay); ymat[2][1]=0; ymat[2][2]=cos(ay); ymat[2][3]=0;
|
||||
ymat[3][0]=0; ymat[3][1]=0; ymat[3][2]=0; ymat[3][3]=1;
|
||||
MultMatrix(mat2,ymat,mat1);
|
||||
zmat[0][0]=cos(az); zmat[0][1]=sin(az); zmat[0][2]=0; zmat[0][3]=0;
|
||||
zmat[1][0]=-(sin(az)); zmat[1][1]=cos(az); zmat[1][2]=0; zmat[1][3]=0;
|
||||
zmat[2][0]=0; zmat[2][1]=0; zmat[2][2]=1; zmat[2][3]=0;
|
||||
zmat[3][0]=0; zmat[3][1]=0; zmat[3][2]=0; zmat[3][3]=1;
|
||||
MultMatrix(matrix,zmat,mat2);
|
||||
}
|
||||
|
||||
short Op01m;
|
||||
short Op01Zr;
|
||||
short Op01Xr;
|
||||
short Op01Yr;
|
||||
|
||||
DSPOp01()
|
||||
{
|
||||
InitMatrix();
|
||||
rotate(Op01Xr/65536.0*6.2832,Op01Yr/65536.0*6.2832,Op01Zr/65536.0*6.2832);
|
||||
CopyMatrix(matrix0,matrix);
|
||||
InitMatrix();
|
||||
rotate(0,0,Op01Zr/65536.0*6.2832);
|
||||
rotate(Op01Xr/65536.0*6.2832,0,0);
|
||||
rotate(0,Op01Yr/65536.0*6.2832,0);
|
||||
CopyMatrix(matrixI0,matrix);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP01");
|
||||
#endif
|
||||
}
|
||||
|
||||
DSPOp11()
|
||||
{
|
||||
InitMatrix();
|
||||
rotate(Op01Xr/65536.0*6.2832,Op01Yr/65536.0*6.2832,Op01Zr/65536.0*6.2832);
|
||||
CopyMatrix(matrix1,matrix);
|
||||
InitMatrix();
|
||||
rotate(0,0,Op01Zr/65536.0*6.2832);
|
||||
rotate(Op01Xr/65536.0*6.2832,0,0);
|
||||
rotate(0,Op01Yr/65536.0*6.2832,0);
|
||||
CopyMatrix(matrixI1,matrix);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP11");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
DSPOp21()
|
||||
{
|
||||
InitMatrix();
|
||||
rotate(Op01Xr/65536.0*6.2832,Op01Yr/65536.0*6.2832,Op01Zr/65536.0*6.2832);
|
||||
CopyMatrix(matrix2,matrix);
|
||||
InitMatrix();
|
||||
rotate(0,0,Op01Zr/65536.0*6.2832);
|
||||
rotate(Op01Xr/65536.0*6.2832,0,0);
|
||||
rotate(0,Op01Yr/65536.0*6.2832,0);
|
||||
CopyMatrix(matrixI2,matrix);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP21");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
short Op0DX;
|
||||
short Op0DY;
|
||||
short Op0DZ;
|
||||
short Op0DF;
|
||||
short Op0DL;
|
||||
short Op0DU;
|
||||
|
||||
DSPOp0D()
|
||||
{
|
||||
Op0DF=(double)(Op0DX*matrixI0[0][0]+Op0DY*matrixI0[1][0]+Op0DZ*matrixI0[2][0]+matrixI0[3][0]);
|
||||
Op0DL=(double)(Op0DX*matrixI0[0][1]+Op0DY*matrixI0[1][1]+Op0DZ*matrixI0[2][1]+matrixI0[3][1]);
|
||||
Op0DU=(double)(Op0DX*matrixI0[0][2]+Op0DY*matrixI0[1][2]+Op0DZ*matrixI0[2][2]+matrixI0[3][2]);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP0D");
|
||||
#endif
|
||||
}
|
||||
|
||||
DSPOp1D()
|
||||
{
|
||||
Op0DF=(double)(Op0DX*matrixI1[0][0]+Op0DY*matrixI1[1][0]+Op0DZ*matrixI1[2][0]+matrixI1[3][0]);
|
||||
Op0DL=(double)(Op0DX*matrixI1[0][1]+Op0DY*matrixI1[1][1]+Op0DZ*matrixI1[2][1]+matrixI1[3][1]);
|
||||
Op0DU=(double)(Op0DX*matrixI1[0][2]+Op0DY*matrixI1[1][2]+Op0DZ*matrixI1[2][2]+matrixI1[3][2]);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP1D");
|
||||
#endif
|
||||
}
|
||||
|
||||
DSPOp2D()
|
||||
{
|
||||
Op0DF=(double)(Op0DX*matrixI2[0][0]+Op0DY*matrixI2[1][0]+Op0DZ*matrixI2[2][0]+matrixI2[3][0]);
|
||||
Op0DL=(double)(Op0DX*matrixI2[0][1]+Op0DY*matrixI2[1][1]+Op0DZ*matrixI2[2][1]+matrixI2[3][1]);
|
||||
Op0DU=(double)(Op0DX*matrixI2[0][2]+Op0DY*matrixI2[1][2]+Op0DZ*matrixI2[2][2]+matrixI2[3][2]);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP2D");
|
||||
#endif
|
||||
}
|
||||
|
||||
short Op03F;
|
||||
short Op03L;
|
||||
short Op03U;
|
||||
short Op03X;
|
||||
short Op03Y;
|
||||
short Op03Z;
|
||||
|
||||
DSPOp03()
|
||||
{
|
||||
Op03X=(double)(Op03F*matrix0[0][0]+Op03L*matrix0[1][0]+Op03U*matrix0[2][0]+matrix0[3][0]);
|
||||
Op03Y=(double)(Op03F*matrix0[0][1]+Op03L*matrix0[1][1]+Op03U*matrix0[2][1]+matrix0[3][1]);
|
||||
Op03Z=(double)(Op03F*matrix0[0][2]+Op03L*matrix0[1][2]+Op03U*matrix0[2][2]+matrix0[3][2]);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP03");
|
||||
#endif
|
||||
}
|
||||
|
||||
DSPOp13()
|
||||
{
|
||||
Op03X=(double)(Op03F*matrix1[0][0]+Op03L*matrix1[1][0]+Op03U*matrix1[2][0]+matrix1[3][0]);
|
||||
Op03Y=(double)(Op03F*matrix1[0][1]+Op03L*matrix1[1][1]+Op03U*matrix1[2][1]+matrix1[3][1]);
|
||||
Op03Z=(double)(Op03F*matrix1[0][2]+Op03L*matrix1[1][2]+Op03U*matrix1[2][2]+matrix1[3][2]);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP13");
|
||||
#endif
|
||||
}
|
||||
|
||||
DSPOp23()
|
||||
{
|
||||
Op03X=(double)(Op03F*matrix2[0][0]+Op03L*matrix2[1][0]+Op03U*matrix2[2][0]+matrix2[3][0]);
|
||||
Op03Y=(double)(Op03F*matrix2[0][1]+Op03L*matrix2[1][1]+Op03U*matrix2[2][1]+matrix2[3][1]);
|
||||
Op03Z=(double)(Op03F*matrix2[0][2]+Op03L*matrix2[1][2]+Op03U*matrix2[2][2]+matrix2[3][2]);
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP23");
|
||||
#endif
|
||||
}
|
||||
|
||||
short Op14Zr;
|
||||
short Op14Xr;
|
||||
short Op14Yr;
|
||||
short Op14U;
|
||||
short Op14F;
|
||||
short Op14L;
|
||||
short Op14Zrr;
|
||||
short Op14Xrr;
|
||||
short Op14Yrr;
|
||||
|
||||
double Op14Temp;
|
||||
DSPOp14()
|
||||
{
|
||||
Op14Temp=(Op14Zr*6.2832/65536.0)+(1/cos(Op14Xr*6.2832/65536.0))*((Op14U*6.2832/65536.0)*cos(Op14Yr*6.2832/65536.0)-(Op14F*6.2832/65536.0)*sin(Op14Yr*6.2832/65536.0));
|
||||
Op14Zrr=Op14Temp*65536.0/6.2832;
|
||||
Op14Temp=(Op14Xr*6.2832/65536.0)+((Op14U*6.2832/65536.0)*sin(Op14Yr*6.2832/65536.0)+(Op14F*6.2832/65536.0)*cos(Op14Yr*6.2832/65536.0));
|
||||
Op14Xrr=Op14Temp*65536.0/6.2832;
|
||||
Op14Temp=(Op14Yr*6.2832/65536.0)-tan(Op14Xr*6.2832/65536.0)*((Op14U*6.2832/65536.0)*cos(Op14Yr*6.2832/65536.0)+(Op14F*6.2832/65536.0)*sin(Op14Yr*6.2832/65536.0))+(Op14L*6.2832/65536.0);
|
||||
Op14Yrr=Op14Temp*65536.0/6.2832;
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP14 X:%d Y%d Z:%D U:%d F:%d L:%d",Op14Xr,Op14Yr,Op14Zr,Op14U,Op14F,Op14L);
|
||||
Log_Message("OP14 X:%d Y%d Z:%D",Op14Xrr,Op14Yrr,Op14Zrr);
|
||||
#endif
|
||||
}
|
||||
|
||||
short Op0EH;
|
||||
short Op0EV;
|
||||
short Op0EX;
|
||||
short Op0EY;
|
||||
DSPOp0E()
|
||||
{
|
||||
|
||||
// screen Directions UP
|
||||
ScreenLZ1=-cos((Op02AZS-16384.0)*6.2832/65536.0); // -16384.0
|
||||
ScreenLX1=sin((Op02AZS-16384.0)*6.2832/65536.0)*-sin(Op02AAS*6.2832/65536.0);
|
||||
ScreenLY1=-sin((Op02AZS-16384.0)*6.2832/65536.0)*-cos(-Op02AAS*6.2832/65536.0);
|
||||
|
||||
RasterLX=ScreenX+(Op0EV)*ScreenLX1;
|
||||
RasterLY=ScreenY+(Op0EV)*ScreenLY1;
|
||||
RasterLZ=ScreenZ+(Op0EV)*ScreenLZ1;
|
||||
|
||||
// screen direction right
|
||||
ScreenLX1=sin((Op02AAS+16384.0)*6.2832/65536);
|
||||
ScreenLY1=cos(-(Op02AAS+16384.0)*6.2832/65536);
|
||||
|
||||
RasterLX=RasterLX+Op0EH*ScreenLX1;
|
||||
RasterLY=RasterLY+Op0EH*ScreenLY1;
|
||||
|
||||
Distance=Op02LFE;
|
||||
|
||||
if(Distance==0)Distance=1;
|
||||
|
||||
RasterLSlopeX=(RasterLX-ViewerX)/Distance;
|
||||
RasterLSlopeY=(RasterLY-ViewerY)/Distance;
|
||||
RasterLSlopeZ=(RasterLZ-ViewerZ)/Distance;
|
||||
|
||||
if(RasterLSlopeZ==0)RasterLSlopeZ++;
|
||||
|
||||
NumberOfSlope=ViewerZ/-RasterLSlopeZ;
|
||||
|
||||
GroundLX=ViewerX+RasterLSlopeX*NumberOfSlope;
|
||||
GroundLY=ViewerY+RasterLSlopeY*NumberOfSlope;
|
||||
|
||||
Op0EX=GroundLX;
|
||||
Op0EY=GroundLY;
|
||||
|
||||
#ifdef DebugDSP1
|
||||
Log_Message("OP0E COORDINATE H:%d V:%d",Op0EH,Op0EV);
|
||||
Log_Message(" X:%d Y:%d",Op0EX,Op0EY);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
639
zsnes/src/chips/dsp1proc.asm
Normal file
639
zsnes/src/chips/dsp1proc.asm
Normal file
@@ -0,0 +1,639 @@
|
||||
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;as published by the Free Software Foundation; either
|
||||
;version 2 of the License, or (at your option) any later
|
||||
;version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License
|
||||
;along with this program; if not, write to the Free Software
|
||||
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM regaccessbankr8,regaccessbankr16,regaccessbankw8,regaccessbankw16
|
||||
EXTSYM DSPOp0A,Op0AA,Op0AB,Op0AC,Op0AD,Op0AVS
|
||||
EXTSYM debstop
|
||||
EXTSYM DSPOp00,Op00Multiplicand,Op00Multiplier
|
||||
EXTSYM Op00Result
|
||||
;EXTSYM DSPOp10,Op10a,Op10b,Op10A,Op10B
|
||||
EXTSYM DSPOp04,Op04Angle,Op04Cos,Op04Radius,Op04Sin
|
||||
EXTSYM DSPOp28,Op28R,Op28X,Op28Y,Op28Z
|
||||
EXTSYM DSPOp0C,Op0CA,Op0CX1,Op0CX2,Op0CY1,Op0CY2
|
||||
EXTSYM DSPOp02,Op02AAS,Op02AZS,Op02CX,Op02CY,Op02FX,Op02FY
|
||||
EXTSYM Op02FZ,Op02LES,Op02LFE,Op02VOF,Op02VVA
|
||||
EXTSYM DSPOp06,Op06X,Op06Y,Op06Z,Op06H,Op06V,Op06S
|
||||
EXTSYM DSPOp0E,Op0EH,Op0EV,Op0EX,Op0EY
|
||||
EXTSYM Op01m, Op01Zr, Op01Xr, Op01Yr, DSPOp01
|
||||
EXTSYM Op0DX, Op0DY, Op0DZ, Op0DF, Op0DL, Op0DU, DSPOp0D
|
||||
EXTSYM Op03X, Op03Y, Op03Z, Op03F, Op03L, Op03U, DSPOp03
|
||||
EXTSYM Op14Zr, Op14Xr, Op14Yr, Op14U, Op14F, Op14L
|
||||
EXTSYM Op14Zrr,Op14Xrr,Op14Yrr, DSPOp14
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NEWSYM dsp1ptr, dd 0
|
||||
NEWSYM dsp1array, times 4096 db 0
|
||||
|
||||
;*******************************************************
|
||||
; DSP1 Read Functions
|
||||
;*******************************************************
|
||||
|
||||
NEWSYM DSP1Read8b3F
|
||||
test ecx,8000h
|
||||
jnz .dsp1area
|
||||
jmp regaccessbankr8
|
||||
.dsp1area
|
||||
cmp ecx,0C000h
|
||||
jae .doC000
|
||||
mov al,080h
|
||||
ret
|
||||
.doC000
|
||||
mov al,80h
|
||||
ret
|
||||
|
||||
|
||||
NEWSYM DSP1Read16b3F
|
||||
test ecx,8000h
|
||||
jnz .dsp1area
|
||||
jmp regaccessbankr16
|
||||
.dsp1area
|
||||
cmp ecx,0C000h
|
||||
jae .doC000
|
||||
cmp byte[DSP1RLeft],0
|
||||
jne .movestuff
|
||||
mov ax,08000h
|
||||
ret
|
||||
.doC000
|
||||
mov ax,08000h
|
||||
ret
|
||||
.movestuff
|
||||
push ebx
|
||||
xor ebx,ebx
|
||||
mov bl,[DSP1CPtrR]
|
||||
mov ax,[DSP1RET+ebx*2]
|
||||
pop ebx
|
||||
inc byte[DSP1CPtrR]
|
||||
dec byte[DSP1RLeft]
|
||||
jz .nomore
|
||||
.goback
|
||||
ret
|
||||
.nomore
|
||||
cmp byte[DSP1COp],0Ah
|
||||
jne .goback
|
||||
push eax
|
||||
pushad
|
||||
call DSPOp0A
|
||||
popad
|
||||
mov ax,[Op0AA]
|
||||
mov [DSP1RET],ax
|
||||
mov ax,[Op0AB]
|
||||
mov [DSP1RET+2],ax
|
||||
mov ax,[Op0AC]
|
||||
mov [DSP1RET+4],ax
|
||||
mov ax,[Op0AD]
|
||||
mov [DSP1RET+6],ax
|
||||
mov byte[DSP1RLeft],4
|
||||
mov byte[DSP1CPtrR],0
|
||||
pop eax
|
||||
ret
|
||||
|
||||
NEWSYM DSP1Read8b
|
||||
; mov byte[debstop],1
|
||||
cmp ecx,7000h
|
||||
jae .do7000
|
||||
xor al,al
|
||||
ret
|
||||
.do7000
|
||||
mov al,80h
|
||||
test ecx,1
|
||||
jz .no1
|
||||
mov al,80h
|
||||
.no1
|
||||
ret
|
||||
|
||||
NEWSYM DSP1Read16b
|
||||
; mov byte[debstop],1
|
||||
cmp ecx,7000h
|
||||
jae .do7000
|
||||
cmp byte[DSP1RLeft],0
|
||||
jne .movestuff
|
||||
mov ax,0FFFFh
|
||||
ret
|
||||
.do7000
|
||||
mov ax,8000h
|
||||
test ecx,01h
|
||||
jz .norev
|
||||
mov ax,0080h
|
||||
.norev
|
||||
ret
|
||||
.movestuff
|
||||
push ebx
|
||||
xor ebx,ebx
|
||||
mov bl,[DSP1CPtrR]
|
||||
mov ax,[DSP1RET+ebx*2]
|
||||
pop ebx
|
||||
inc byte[DSP1CPtrR]
|
||||
dec byte[DSP1RLeft]
|
||||
jz .nomore
|
||||
.goback
|
||||
ret
|
||||
.nomore
|
||||
cmp byte[DSP1COp],0Ah
|
||||
jne .goback
|
||||
push eax
|
||||
pushad
|
||||
call DSPOp0A
|
||||
popad
|
||||
mov ax,[Op0AA]
|
||||
mov [DSP1RET],ax
|
||||
mov ax,[Op0AB]
|
||||
mov [DSP1RET+2],ax
|
||||
mov ax,[Op0AC]
|
||||
mov [DSP1RET+4],ax
|
||||
mov ax,[Op0AD]
|
||||
mov [DSP1RET+6],ax
|
||||
mov byte[DSP1RLeft],4
|
||||
mov byte[DSP1CPtrR],0
|
||||
pop eax
|
||||
ret
|
||||
|
||||
%macro DSP1WriteInit 2
|
||||
cmp al,%1
|
||||
jne %%no
|
||||
mov byte[DSP1WLeft],%2
|
||||
%%no
|
||||
%endmacro
|
||||
|
||||
NEWSYM DSP1Write8b3F
|
||||
test ecx,8000h
|
||||
jnz .dsp1area
|
||||
jmp regaccessbankw8
|
||||
.dsp1area
|
||||
call DSP1Write8b
|
||||
ret
|
||||
|
||||
NEWSYM DSP1Write16b3F
|
||||
test ecx,8000h
|
||||
jnz .dsp1area
|
||||
jmp regaccessbankw16
|
||||
.dsp1area
|
||||
call DSP1Write16b
|
||||
ret
|
||||
|
||||
NEWSYM DSP1Write8b
|
||||
push ebx
|
||||
xor ebx,ebx
|
||||
mov bl,al
|
||||
mov byte[DSPFuncUsed+ebx],1
|
||||
pop ebx
|
||||
mov byte[DSP1COp],al
|
||||
mov byte[DSP1CPtrW],0
|
||||
DSP1WriteInit 00h, 2 ; 16-bit multiply
|
||||
DSP1WriteInit 10h, 2 ; Inverse
|
||||
DSP1WriteInit 04h, 2 ; Trigonometric
|
||||
DSP1WriteInit 08h, 3 ; Vector Size
|
||||
DSP1WriteInit 18h, 4 ; Vector Size Comparison
|
||||
DSP1WriteInit 28h, 3 ; Vector Absolute Value
|
||||
DSP1WriteInit 0Ch, 3 ; Coordinate Rotation
|
||||
DSP1WriteInit 1Ch, 4 ; 3D Coordinate Rotation
|
||||
DSP1WriteInit 02h, 7 ; Vector Size
|
||||
DSP1WriteInit 0Ah, 1 ; Raster Data Calculation via DMA
|
||||
DSP1WriteInit 1Ah, 1 ; Raster Data Calculation w/o DMA
|
||||
DSP1WriteInit 06h, 3 ; Object Projection Calculation
|
||||
DSP1WriteInit 0Eh, 2 ; Coordinate Calculation of a point onscreen
|
||||
DSP1WriteInit 01h, 4 ; Set Attitude Matrix A
|
||||
DSP1WriteInit 11h, 4 ; Set Attitude Matrix B
|
||||
DSP1WriteInit 21h, 4 ; Set Attitude Matrix C
|
||||
DSP1WriteInit 0Dh, 3 ; Convert from global to object coords Matrix A
|
||||
DSP1WriteInit 1Dh, 3 ; Convert from global to object coords Matrix B
|
||||
DSP1WriteInit 2Dh, 3 ; Convert from global to object coords Matrix C
|
||||
DSP1WriteInit 03h, 3 ; Convert from object to global coords Matrix A
|
||||
DSP1WriteInit 13h, 3 ; Convert from object to global coords Matrix B
|
||||
DSP1WriteInit 23h, 3 ; Convert from object to global coords Matrix C
|
||||
DSP1WriteInit 0Bh, 3 ; Calculation of inner product Matrix A
|
||||
DSP1WriteInit 1Bh, 3 ; Calculation of inner product Matrix B
|
||||
DSP1WriteInit 2Bh, 3 ; Calculation of inner product Matrix C
|
||||
DSP1WriteInit 14h, 6 ; 3D angle rotation
|
||||
ret
|
||||
|
||||
%macro DSP1WriteProc 2
|
||||
cmp byte[DSP1COp],%1
|
||||
jne %%no
|
||||
pushad
|
||||
call %2
|
||||
popad
|
||||
%%no
|
||||
%endmacro
|
||||
|
||||
NEWSYM DSP1Write16b
|
||||
; mov byte[debstop],1
|
||||
cmp byte[DSP1WLeft],0
|
||||
jne .yesleft
|
||||
ret
|
||||
.yesleft
|
||||
push ebx
|
||||
xor ebx,ebx
|
||||
mov bl,[DSP1CPtrW]
|
||||
mov [DSP1VARS+ebx*2],ax
|
||||
pop ebx
|
||||
inc byte[DSP1CPtrW]
|
||||
dec byte[DSP1WLeft]
|
||||
jz .ProcessDSP1
|
||||
ret
|
||||
.ProcessDSP1
|
||||
mov byte[DSP1CPtrR],0
|
||||
mov byte[DSP1RLeft],0
|
||||
DSP1WriteProc 00h, DSP1_00 ; 16-bit multiply
|
||||
DSP1WriteProc 10h, DSP1_10 ; Inverse
|
||||
DSP1WriteProc 04h, DSP1_04 ; Trigonometric
|
||||
DSP1WriteProc 08h, DSP1_08 ; Vector Size
|
||||
DSP1WriteProc 18h, DSP1_18 ; Vector Size Comparison
|
||||
DSP1WriteProc 28h, DSP1_28 ; Vector Absolute Value
|
||||
DSP1WriteProc 0Ch, DSP1_0C ; Coordinate Rotation
|
||||
DSP1WriteProc 1Ch, DSP1_1C ; 3D Coordinate Rotation
|
||||
DSP1WriteProc 02h, DSP1_02 ; Vector Size
|
||||
DSP1WriteProc 0Ah, DSP1_0A ; Raster Data Calculation via DMA
|
||||
DSP1WriteProc 1Ah, DSP1_0A ; Raster Data Calculation w/o DMA
|
||||
DSP1WriteProc 06h, DSP1_06 ; Object Projection Calculation
|
||||
DSP1WriteProc 0Eh, DSP1_0E ; Coordinate Calculation of a point onscreen
|
||||
DSP1WriteProc 01h, DSP1_01 ; Set Attitude Matrix A
|
||||
DSP1WriteProc 11h, DSP1_11 ; Set Attitude Matrix B
|
||||
DSP1WriteProc 21h, DSP1_21 ; Set Attitude Matrix C
|
||||
DSP1WriteProc 0Dh, DSP1_0D ; Convert from global to object coords Matrix A
|
||||
DSP1WriteProc 1Dh, DSP1_1D ; Convert from global to object coords Matrix B
|
||||
DSP1WriteProc 2Dh, DSP1_2D ; Convert from global to object coords Matrix C
|
||||
DSP1WriteProc 03h, DSP1_03 ; Convert from object to global coords Matrix A
|
||||
DSP1WriteProc 13h, DSP1_13 ; Convert from object to global coords Matrix B
|
||||
DSP1WriteProc 23h, DSP1_23 ; Convert from object to global coords Matrix C
|
||||
DSP1WriteProc 0Bh, DSP1_0B ; Calculation of inner product Matrix A
|
||||
DSP1WriteProc 1Bh, DSP1_1B ; Calculation of inner product Matrix B
|
||||
DSP1WriteProc 2Bh, DSP1_2B ; Calculation of inner product Matrix C
|
||||
DSP1WriteProc 14h, DSP1_14 ; 3D angle rotation
|
||||
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
|
||||
|
||||
NEWSYM DSPFuncUsed, times 256 db 0
|
||||
|
||||
;*******************************************************
|
||||
; DSP1 Conversion Functions
|
||||
;*******************************************************
|
||||
DSP1_00: ; 16-bit multiply
|
||||
or byte[DSPDet],01h
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op00Multiplicand],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op00Multiplier],ax
|
||||
pushad
|
||||
call DSPOp00
|
||||
popad
|
||||
mov ax,[Op00Result]
|
||||
mov [DSP1RET],ax
|
||||
mov byte[DSP1RLeft],1
|
||||
pop eax
|
||||
ret
|
||||
DSP1_10: ; Inverse
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
; mov [Op10a],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
; mov [Op10b],ax
|
||||
pushad
|
||||
; call DSPOp10
|
||||
popad
|
||||
; mov ax,[Op10A]
|
||||
mov [DSP1RET],ax
|
||||
; mov ax,[Op10B]
|
||||
mov [DSP1RET+2],ax
|
||||
mov byte[DSP1RLeft],2
|
||||
pop eax
|
||||
ret
|
||||
|
||||
DSP1_04: ; Trigonometric
|
||||
or byte[DSPDet],02h
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op04Angle],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op04Radius],ax
|
||||
pushad
|
||||
call DSPOp04
|
||||
popad
|
||||
mov ax,[Op04Sin]
|
||||
mov [DSP1RET],ax
|
||||
mov ax,[Op04Cos]
|
||||
mov [DSP1RET+2],ax
|
||||
mov byte[DSP1RLeft],2
|
||||
pop eax
|
||||
ret
|
||||
DSP1_08: ; Vector Size
|
||||
ret
|
||||
DSP1_18: ; Vector Size Comparison
|
||||
ret
|
||||
|
||||
DSP1_28: ; Vector Absolute Value
|
||||
or byte[DSPDet],04h
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op28X],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op28Y],ax
|
||||
mov ax,[DSP1VARS+4]
|
||||
mov [Op28Z],ax
|
||||
pushad
|
||||
call DSPOp28
|
||||
popad
|
||||
mov ax,[Op28R]
|
||||
mov [DSP1RET],ax
|
||||
mov byte[DSP1RLeft],1
|
||||
pop eax
|
||||
ret
|
||||
|
||||
|
||||
DSP1_0C: ; Coordinate Rotation
|
||||
or byte[DSPDet],08h
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op0CA],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op0CX1],ax
|
||||
mov ax,[DSP1VARS+4]
|
||||
mov [Op0CY1],ax
|
||||
pushad
|
||||
call DSPOp0C
|
||||
popad
|
||||
mov ax,[Op0CX2]
|
||||
mov [DSP1RET],ax
|
||||
mov ax,[Op0CY2]
|
||||
mov [DSP1RET+2],ax
|
||||
mov byte[DSP1RLeft],2
|
||||
pop eax
|
||||
ret
|
||||
DSP1_1C: ; 3D Coordinate Rotation
|
||||
ret
|
||||
|
||||
|
||||
DSP1_02: ; Vector Size
|
||||
or byte[DSPDet],10h
|
||||
push eax
|
||||
;Op02FX dw 0
|
||||
;Op02FY dw 0
|
||||
;Op02FZ dw 0
|
||||
;Op02LFE dw 0
|
||||
;Op02LES dw 0
|
||||
;Op02AAS dw 0
|
||||
;Op02AZS dw 0
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op02FX],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op02FY],ax
|
||||
mov ax,[DSP1VARS+4]
|
||||
mov [Op02FZ],ax
|
||||
mov ax,[DSP1VARS+6]
|
||||
mov [Op02LFE],ax
|
||||
mov ax,[DSP1VARS+8]
|
||||
mov [Op02LES],ax
|
||||
mov ax,[DSP1VARS+10]
|
||||
mov [Op02AAS],ax
|
||||
mov ax,[DSP1VARS+12]
|
||||
mov [Op02AZS],ax
|
||||
pushad
|
||||
call DSPOp02
|
||||
popad
|
||||
;Op02VOF dw 0
|
||||
;Op02VVA dw 0
|
||||
;Op02CX dw 0
|
||||
;Op02CY dw 0
|
||||
mov ax,[Op02VOF]
|
||||
mov [DSP1RET],ax
|
||||
mov ax,[Op02VVA]
|
||||
mov [DSP1RET+2],ax
|
||||
mov ax,[Op02CX]
|
||||
mov [DSP1RET+4],ax
|
||||
mov ax,[Op02CY]
|
||||
mov [DSP1RET+6],ax
|
||||
mov byte[DSP1RLeft],4
|
||||
pop eax
|
||||
ret
|
||||
mov eax,dsp1array
|
||||
add eax,[dsp1ptr]
|
||||
push ebx
|
||||
mov byte[eax],02h
|
||||
mov bx,[Op02FX]
|
||||
mov [eax+1],bx
|
||||
mov bx,[Op02FY]
|
||||
mov [eax+3],bx
|
||||
mov bx,[Op02FZ]
|
||||
mov [eax+5],bx
|
||||
mov bx,[Op02LFE]
|
||||
mov [eax+7],bx
|
||||
mov bx,[Op02LES]
|
||||
mov [eax+9],bx
|
||||
mov bx,[Op02AAS]
|
||||
mov [eax+11],bx
|
||||
mov bx,[Op02AZS]
|
||||
mov [eax+13],bx
|
||||
mov bx,[Op02VOF]
|
||||
mov [eax+15],bx
|
||||
mov bx,[Op02VVA]
|
||||
mov [eax+17],bx
|
||||
mov bx,[Op02CX]
|
||||
mov [eax+19],bx
|
||||
mov bx,[Op02CY]
|
||||
mov [eax+21],bx
|
||||
pop ebx
|
||||
add dword[dsp1ptr],23
|
||||
DSP1_0A: ; Raster Data Calculation via DMA
|
||||
mov byte[DSP1COp],0Ah
|
||||
or byte[DSPDet],20h
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op0AVS],ax
|
||||
pushad
|
||||
call DSPOp0A
|
||||
popad
|
||||
mov ax,[Op0AA]
|
||||
mov [DSP1RET],ax
|
||||
mov ax,[Op0AB]
|
||||
mov [DSP1RET+2],ax
|
||||
mov ax,[Op0AC]
|
||||
mov [DSP1RET+4],ax
|
||||
mov ax,[Op0AD]
|
||||
mov [DSP1RET+6],ax
|
||||
mov byte[DSP1RLeft],4
|
||||
pop eax
|
||||
ret
|
||||
DSP1_06: ; Object Projection Calculation
|
||||
or byte[DSPDet],40h
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op06X],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op06Y],ax
|
||||
mov ax,[DSP1VARS+4]
|
||||
mov [Op06Z],ax
|
||||
pushad
|
||||
call DSPOp06
|
||||
popad
|
||||
mov ax,[Op06H]
|
||||
mov word[DSP1RET],ax
|
||||
mov ax,[Op06V]
|
||||
mov word[DSP1RET+2],ax
|
||||
mov ax,[Op06S]
|
||||
mov word[DSP1RET+4],ax
|
||||
mov byte[DSP1RLeft],3
|
||||
pop eax
|
||||
ret
|
||||
mov eax,dsp1array
|
||||
add eax,[dsp1ptr]
|
||||
push ebx
|
||||
mov byte[eax],06h
|
||||
mov bx,[Op06X]
|
||||
mov [eax+1],bx
|
||||
mov bx,[Op06Y]
|
||||
mov [eax+3],bx
|
||||
mov bx,[Op06Z]
|
||||
mov [eax+5],bx
|
||||
mov bx,[Op06H]
|
||||
mov [eax+7],bx
|
||||
mov bx,[Op06V]
|
||||
mov [eax+9],bx
|
||||
mov bx,[Op06S]
|
||||
mov [eax+11],bx
|
||||
pop ebx
|
||||
add dword[dsp1ptr],13
|
||||
DSP1_0E: ; Coordinate Calculation of a point onscreen
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op0EH],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op0EV],ax
|
||||
pushad
|
||||
call DSPOp0E
|
||||
popad
|
||||
mov ax,[Op0EX]
|
||||
mov word[DSP1RET],ax
|
||||
mov ax,[Op0EY]
|
||||
mov word[DSP1RET+2],ax
|
||||
mov byte[DSP1RLeft],2
|
||||
pop eax
|
||||
ret
|
||||
DSP1_01: ; Set Attitude Matrix A
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op01m],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op01Zr],ax
|
||||
mov ax,[DSP1VARS+4]
|
||||
mov [Op01Xr],ax
|
||||
mov ax,[DSP1VARS+6]
|
||||
mov [Op01Yr],ax
|
||||
pushad
|
||||
call DSPOp01
|
||||
popad
|
||||
pop eax
|
||||
ret
|
||||
DSP1_11: ; Set Attitude Matrix B
|
||||
ret
|
||||
DSP1_21: ; Set Attitude Matrix C
|
||||
ret
|
||||
DSP1_0D: ; Convert from global to object coords Matrix A
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op0DX],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op0DY],ax
|
||||
mov ax,[DSP1VARS+4]
|
||||
mov [Op0DZ],ax
|
||||
pushad
|
||||
call DSPOp0D
|
||||
popad
|
||||
mov ax,[Op0DF]
|
||||
mov word[DSP1RET],ax
|
||||
mov ax,[Op0DL]
|
||||
mov word[DSP1RET+2],ax
|
||||
mov ax,[Op0DU]
|
||||
mov word[DSP1RET+4],ax
|
||||
mov byte[DSP1RLeft],3
|
||||
pop eax
|
||||
ret
|
||||
DSP1_1D: ; Convert from global to object coords Matrix B
|
||||
ret
|
||||
DSP1_2D: ; Convert from global to object coords Matrix C
|
||||
ret
|
||||
DSP1_03: ; Convert from object to global coords Matrix A
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op03F],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op03L],ax
|
||||
mov ax,[DSP1VARS+4]
|
||||
mov [Op03U],ax
|
||||
pushad
|
||||
call DSPOp03
|
||||
popad
|
||||
mov ax,[Op03X]
|
||||
mov word[DSP1RET],ax
|
||||
mov ax,[Op03Y]
|
||||
mov word[DSP1RET+2],ax
|
||||
mov ax,[Op03Z]
|
||||
mov word[DSP1RET+4],ax
|
||||
mov byte[DSP1RLeft],3
|
||||
pop eax
|
||||
ret
|
||||
DSP1_13: ; Convert from object to global coords Matrix B
|
||||
ret
|
||||
DSP1_23: ; Convert from object to global coords Matrix C
|
||||
ret
|
||||
DSP1_0B: ; Calculation of inner product Matrix A
|
||||
ret
|
||||
DSP1_1B: ; Calculation of inner product Matrix B
|
||||
ret
|
||||
DSP1_2B: ; Calculation of inner product Matrix C
|
||||
ret
|
||||
DSP1_14: ; 3D angle rotation
|
||||
push eax
|
||||
mov ax,[DSP1VARS]
|
||||
mov [Op14Zr],ax
|
||||
mov ax,[DSP1VARS+2]
|
||||
mov [Op14Xr],ax
|
||||
mov ax,[DSP1VARS+4]
|
||||
mov [Op14Yr],ax
|
||||
mov ax,[DSP1VARS+6]
|
||||
mov [Op14U],ax
|
||||
mov ax,[DSP1VARS+8]
|
||||
mov [Op14F],ax
|
||||
mov ax,[DSP1VARS+10]
|
||||
mov [Op14L],ax
|
||||
pushad
|
||||
call DSPOp14
|
||||
popad
|
||||
mov ax,[Op14Zrr]
|
||||
mov word[DSP1RET],ax
|
||||
mov ax,[Op14Xrr]
|
||||
mov word[DSP1RET+2],ax
|
||||
mov ax,[Op14Yrr]
|
||||
mov word[DSP1RET+4],ax
|
||||
mov byte[DSP1RLeft],3
|
||||
pop eax
|
||||
ret
|
||||
|
||||
2683
zsnes/src/chips/fxemu2.asm
Normal file
2683
zsnes/src/chips/fxemu2.asm
Normal file
File diff suppressed because it is too large
Load Diff
835
zsnes/src/chips/fxemu2.mac
Normal file
835
zsnes/src/chips/fxemu2.mac
Normal file
@@ -0,0 +1,835 @@
|
||||
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;as published by the Free Software Foundation; either
|
||||
;version 2 of the License, or (at your option) any later
|
||||
;version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License
|
||||
;along with this program; if not, write to the Free Software
|
||||
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%macro FETCHPIPE 0
|
||||
; mov edx,[SfxPBR]
|
||||
; mov edx,[SfxMemTable+edx*4]
|
||||
; mov edx,[SfxCPB]
|
||||
; mov edx,[SfxR15]
|
||||
mov cl,[ebp]
|
||||
%endmacro
|
||||
|
||||
%macro UpdateR14 0
|
||||
; mov edx,[SfxROMBR]
|
||||
; mov edx,[SfxMemTable+edx*4]
|
||||
mov eax,[SfxCROM]
|
||||
; and dword[SfxR14],0FFFFh
|
||||
add eax,[SfxR14]
|
||||
mov [SfxRomBuffer],eax
|
||||
%endmacro
|
||||
|
||||
%macro UpdateR15 0
|
||||
mov ebp,[SfxCPB]
|
||||
add ebp,[SfxR15]
|
||||
%endmacro
|
||||
|
||||
%macro CLRFLAGS 0
|
||||
;and dword [SfxSFR],0FFFFh-0100h-0200h-1000h ; Clear ALT1,ALT2 and B Flags
|
||||
; xor ch,ch
|
||||
; mov dword [SfxB],0 ; Clear B Flag
|
||||
; mov esi,SfxR0
|
||||
; mov edi,SfxR0
|
||||
%endmacro
|
||||
|
||||
%macro TORN 1 ; V
|
||||
FETCHPIPE
|
||||
mov edi, SfxR0+%1*4
|
||||
inc ebp ; Increase program counter
|
||||
call [FxTable+ecx*4]
|
||||
mov edi,SfxR0
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro WITH 1 ; Verified.
|
||||
FETCHPIPE
|
||||
mov esi,SfxR0+%1*4
|
||||
mov edi,SfxR0+%1*4
|
||||
mov dword [SfxB],1
|
||||
inc ebp ; Increase program counter
|
||||
call [FxTablec+ecx*4]
|
||||
mov esi,SfxR0
|
||||
mov edi,SfxR0
|
||||
mov dword [SfxB],0 ; Clear B Flag
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro STWRN 1 ; V
|
||||
mov eax,[SfxR0+%1*4] ; Read register
|
||||
mov ebx,[SfxRAMMem]
|
||||
mov dword [SfxLastRamAdr],eax ; Save last ram address
|
||||
add dword [SfxLastRamAdr],ebx ; Save last ram address
|
||||
mov edx,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
mov [ebx+eax],dl ; Store Word
|
||||
xor eax,1
|
||||
inc ebp ; Increase program counter
|
||||
mov [ebx+eax],dh ; Store Word
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro STBRN 1 ; V
|
||||
mov eax,[SfxR0+%1*4] ; Read register
|
||||
FETCHPIPE
|
||||
add eax,[SfxRAMMem]
|
||||
mov dword [SfxLastRamAdr],eax ; Save last ram address
|
||||
mov ebx,[esi] ; Read Source
|
||||
mov byte [eax],bl ; Store Byte
|
||||
CLRFLAGS
|
||||
inc ebp ; Increase program counter
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro LDWRN 1 ; V
|
||||
mov eax,[SfxR0+%1*4] ; Read register
|
||||
mov ebx,[SfxRAMMem]
|
||||
mov dword [SfxLastRamAdr],eax ; Save last ram address
|
||||
FETCHPIPE
|
||||
mov dl,[ebx+eax] ; Store Word
|
||||
add dword [SfxLastRamAdr],ebx ; Save last ram address
|
||||
xor eax,1
|
||||
and edx,0FFFFh
|
||||
inc ebp ; Increase program counter
|
||||
mov dh,[ebx+eax] ; Store Word
|
||||
mov [edi],edx ; Read Source
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro LDBRN 1 ; V
|
||||
mov eax,[SfxR0+%1*4] ; Read register
|
||||
FETCHPIPE
|
||||
add eax,[SfxRAMMem]
|
||||
xor ebx,ebx
|
||||
mov dword [SfxLastRamAdr],eax ; Save last ram address
|
||||
mov bl,[eax] ; Read Byte
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],ebx ; Store Result
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
; test byte[SfxPOR],01h
|
||||
; jnz .nozerocheck
|
||||
; test byte[SfxPOR],02h
|
||||
; jz .nodither
|
||||
|
||||
; **** Can pre-calculate [SfxSCBR] << 10 + [sfxramdata]
|
||||
; Pre-calculate fxbit values from color register
|
||||
|
||||
%macro drawpix4b 0
|
||||
and [eax],edx
|
||||
and [eax+16],edx
|
||||
xor edx,0FFFFFFFFh
|
||||
mov ebx,[fxbit01pcal]
|
||||
and ebx,edx
|
||||
or [eax], ebx
|
||||
and edx,[fxbit23pcal]
|
||||
or [eax+16], edx
|
||||
%endmacro
|
||||
|
||||
%macro drawpix4bd 0
|
||||
and [eax],edx
|
||||
and [eax+16],edx
|
||||
xor edx,0FFFFFFFFh
|
||||
mov ebx,[fxbit45pcal]
|
||||
and ebx,edx
|
||||
or [eax], ebx
|
||||
and edx,[fxbit67pcal]
|
||||
or [eax+16], edx
|
||||
%endmacro
|
||||
|
||||
%macro drawpix2b 0
|
||||
and [eax],edx
|
||||
xor edx,0FFFFFFFFh
|
||||
and edx,[fxbit01pcal]
|
||||
or [eax], edx
|
||||
%endmacro
|
||||
|
||||
%macro drawpix2bd 0
|
||||
and [eax],edx
|
||||
xor edx,0FFFFFFFFh
|
||||
and edx,[fxbit45pcal]
|
||||
or [eax], edx
|
||||
%endmacro
|
||||
|
||||
%macro drawpix8b 0
|
||||
and [eax],edx
|
||||
and [eax+16],edx
|
||||
and [eax+32],edx
|
||||
and [eax+48],edx
|
||||
xor edx,0FFFFFFFFh
|
||||
mov ebx,[fxbit01pcal]
|
||||
and ebx,edx
|
||||
or [eax], ebx
|
||||
mov ebx,[fxbit23pcal]
|
||||
and ebx,edx
|
||||
or [eax+16], ebx
|
||||
mov ebx,[fxbit45pcal]
|
||||
and ebx,edx
|
||||
or [eax+32], ebx
|
||||
and edx,[fxbit67pcal]
|
||||
or [eax+48], edx
|
||||
%endmacro
|
||||
|
||||
%macro drawpix8bd 0
|
||||
and [eax],edx
|
||||
and [eax+16],edx
|
||||
and [eax+32],edx
|
||||
and [eax+48],edx
|
||||
xor edx,0FFFFFFFFh
|
||||
mov ebx,[fxbit45pcal]
|
||||
and ebx,edx
|
||||
or [eax], ebx
|
||||
mov ebx,[fxbit67pcal]
|
||||
and ebx,edx
|
||||
or [eax+16], ebx
|
||||
mov ebx,[fxbit01pcal]
|
||||
and ebx,edx
|
||||
or [eax+32], ebx
|
||||
and edx,[fxbit23pcal]
|
||||
or [eax+48], edx
|
||||
%endmacro
|
||||
|
||||
%macro plotb 5
|
||||
shl eax,%3
|
||||
and ebx,07h
|
||||
add ebx,ebx
|
||||
add eax,ebx
|
||||
add eax,[SCBRrel]
|
||||
mov bl,[SfxR1]
|
||||
mov edx,[fxxand+ebx*4]
|
||||
%2
|
||||
%endmacro
|
||||
|
||||
%macro plotbz 5
|
||||
shl eax,%3
|
||||
and ebx,07h
|
||||
add ebx,ebx
|
||||
add eax,ebx
|
||||
add eax,[SCBRrel]
|
||||
mov bl,[SfxR1]
|
||||
mov edx,[fxxand+ebx*4]
|
||||
test byte[SfxCOLR],%5
|
||||
jz .nodraw
|
||||
%2
|
||||
%endmacro
|
||||
|
||||
%macro plotbd 5
|
||||
shl eax,%3
|
||||
and ebx,07h
|
||||
add ebx,ebx
|
||||
add eax,ebx
|
||||
add eax,[SCBRrel]
|
||||
mov bl,[SfxR1]
|
||||
mov edx,[fxxand+ebx*4]
|
||||
mov bl,[SfxR1]
|
||||
xor bl,[SfxR2]
|
||||
test bl,01h
|
||||
jz near .nodither4b
|
||||
%4
|
||||
inc word [SfxR1]
|
||||
%1
|
||||
.nodither4b
|
||||
%2
|
||||
%endmacro
|
||||
|
||||
%macro plotbzd 5
|
||||
shl eax,%3
|
||||
and ebx,07h
|
||||
add ebx,ebx
|
||||
add eax,ebx
|
||||
add eax,[SCBRrel]
|
||||
mov bl,[SfxR1]
|
||||
mov edx,[fxxand+ebx*4]
|
||||
test byte[SfxCOLR],%5
|
||||
jz near .nodraw
|
||||
mov bl,[SfxR1]
|
||||
xor bl,[SfxR2]
|
||||
test bl,01h
|
||||
jz .nodither4b
|
||||
%4
|
||||
inc word [SfxR1]
|
||||
%1
|
||||
.nodither4b
|
||||
%2
|
||||
%endmacro
|
||||
|
||||
%macro plotlines4b 1
|
||||
mov ebx,[SfxR2]
|
||||
FETCHPIPE
|
||||
mov bh,[SfxR1]
|
||||
mov eax,[sfxclineloc]
|
||||
inc ebp
|
||||
mov eax,[eax+ebx*4]
|
||||
cmp eax,0FFFFFFFFh
|
||||
je near .nodraw
|
||||
%1 ret, drawpix4b, 5, drawpix4bd, 0Fh
|
||||
.nodraw
|
||||
inc word [SfxR1]
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro plotlines4bb 1
|
||||
mov ebx,[SfxR2]
|
||||
FETCHPIPE
|
||||
mov bh,[SfxR1]
|
||||
mov eax,[sfxclineloc]
|
||||
inc ebp
|
||||
mov eax,[eax+ebx*4]
|
||||
cmp eax,0FFFFFFFFh
|
||||
je near .nodraw
|
||||
%1 FXReturn, drawpix4b, 5, drawpix4bd, 0Fh
|
||||
.nodraw
|
||||
inc word [SfxR1]
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro plotlines2b 1
|
||||
mov ebx,[SfxR2]
|
||||
FETCHPIPE
|
||||
mov bh,[SfxR1]
|
||||
mov eax,[sfxclineloc]
|
||||
inc ebp
|
||||
mov eax,[eax+ebx*4]
|
||||
cmp eax,0FFFFFFFFh
|
||||
je near .nodraw
|
||||
%1 ret, drawpix2b, 4, drawpix2bd, 03h
|
||||
.nodraw
|
||||
inc word [SfxR1]
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro plotlines2bb 1
|
||||
mov ebx,[SfxR2]
|
||||
FETCHPIPE
|
||||
mov bh,[SfxR1]
|
||||
mov eax,[sfxclineloc]
|
||||
inc ebp
|
||||
mov eax,[eax+ebx*4]
|
||||
cmp eax,0FFFFFFFFh
|
||||
je near .nodraw
|
||||
%1 FXReturn, drawpix2b, 4, drawpix2bd, 03h
|
||||
.nodraw
|
||||
inc word [SfxR1]
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro plotlines8b 1
|
||||
mov ebx,[SfxR2]
|
||||
FETCHPIPE
|
||||
mov bh,[SfxR1]
|
||||
mov eax,[sfxclineloc]
|
||||
inc ebp
|
||||
mov eax,[eax+ebx*4]
|
||||
cmp eax,0FFFFFFFFh
|
||||
je near .nodraw
|
||||
%1 ret, drawpix8b, 6, drawpix8bd, 0FFh
|
||||
.nodraw
|
||||
inc word [SfxR1]
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro plotlines8bb 1
|
||||
mov ebx,[SfxR2]
|
||||
FETCHPIPE
|
||||
mov bh,[SfxR1]
|
||||
mov eax,[sfxclineloc]
|
||||
inc ebp
|
||||
mov eax,[eax+ebx*4]
|
||||
cmp eax,0FFFFFFFFh
|
||||
je near .nodraw
|
||||
%1 FXReturn, drawpix8b, 6, drawpix8bd, 0FFh
|
||||
.nodraw
|
||||
inc word [SfxR1]
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro plotlines8bl 1
|
||||
mov ebx,[SfxR2]
|
||||
FETCHPIPE
|
||||
mov bh,[SfxR1]
|
||||
mov eax,[sfxclineloc]
|
||||
inc ebp
|
||||
mov eax,[eax+ebx*4]
|
||||
cmp eax,0FFFFFFFFh
|
||||
je near .nodraw
|
||||
%1 ret, drawpix8b, 6, drawpix8bd, 0Fh
|
||||
.nodraw
|
||||
inc word [SfxR1]
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro plotlines8bbl 1
|
||||
mov ebx,[SfxR2]
|
||||
FETCHPIPE
|
||||
mov bh,[SfxR1]
|
||||
mov eax,[sfxclineloc]
|
||||
inc ebp
|
||||
mov eax,[eax+ebx*4]
|
||||
cmp eax,0FFFFFFFFh
|
||||
je near .nodraw
|
||||
%1 FXReturn, drawpix8b, 6, drawpix8bd, 0Fh
|
||||
.nodraw
|
||||
inc word [SfxR1]
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ADDRN 1 ; V
|
||||
mov eax, [esi] ; Read Source
|
||||
mov ebx, [SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
add ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
mov [SfxSignZero],eax
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro ADCRN 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax, [esi] ; Read Source
|
||||
mov ebx, [SfxR0+%1*4]
|
||||
shr byte[SfxCarry],1
|
||||
adc ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
mov [SfxSignZero],eax
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro ADIRN 1 ; V
|
||||
mov eax, [esi] ; Read Source
|
||||
FETCHPIPE
|
||||
add ax,%1
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
mov [SfxSignZero],eax
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro ADCIRN 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax, [esi] ; Read Source
|
||||
shr byte[SfxCarry],1
|
||||
adc ax,%1
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
mov [SfxSignZero],eax
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro SUBRN 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
sub ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
xor byte[SfxCarry],1
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro SBCRN 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4]
|
||||
cmp byte[SfxCarry],1
|
||||
sbb ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
xor byte[SfxCarry],1
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro SUBIRN 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
sub ax,%1
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
xor byte[SfxCarry],1
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro CMPRN 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
sub ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
xor byte[SfxCarry],1
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
inc ebp ; Increase program counter
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro ANDRN 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4] ; Read RN
|
||||
FETCHPIPE
|
||||
and eax,ebx
|
||||
inc ebp
|
||||
mov dword [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro BICRN 1 ; V
|
||||
mov ebx,[SfxR0+%1*4] ; Read RN
|
||||
mov eax,[esi] ; Read Source
|
||||
xor ebx,0FFFFh
|
||||
FETCHPIPE
|
||||
and eax,ebx
|
||||
inc ebp
|
||||
mov dword [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro ANDIRN 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
and eax,%1
|
||||
inc ebp
|
||||
mov dword [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro BICIRN 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
and eax,%1
|
||||
inc ebp
|
||||
mov dword [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro MULTRN 1 ; V
|
||||
mov al,byte [esi] ; Read Source
|
||||
mov bl,byte [SfxR0+%1*4] ; Read RN
|
||||
FETCHPIPE
|
||||
imul bl
|
||||
inc ebp
|
||||
and eax,0FFFFh
|
||||
mov [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro UMULTRN 1 ; V
|
||||
mov al,byte [esi] ; Read Source
|
||||
mov bl,byte [SfxR0+%1*4] ; Read RN
|
||||
FETCHPIPE
|
||||
mul bl
|
||||
inc ebp
|
||||
and eax,0FFFFh
|
||||
mov [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro MULTIRN 1 ; V
|
||||
mov al,byte [esi] ; Read Source
|
||||
mov bl,%1 ; Read RN
|
||||
FETCHPIPE
|
||||
imul bl
|
||||
inc ebp
|
||||
and eax,0FFFFh
|
||||
mov [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro UMULTIRN 1 ; V
|
||||
mov al,byte [esi] ; Read Source
|
||||
mov bl,%1 ; Read RN
|
||||
FETCHPIPE
|
||||
mul bl
|
||||
inc ebp
|
||||
and eax,0FFFFh
|
||||
mov [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro LINK 1 ; Verified.
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
add eax,%1
|
||||
FETCHPIPE
|
||||
mov word [SfxR11],ax
|
||||
CLRFLAGS
|
||||
inc ebp
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro JMPRN 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4] ; Read RN
|
||||
mov ebp,[SfxCPB]
|
||||
add ebp,eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro LJMPRN 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4]
|
||||
and eax,07Fh
|
||||
mov byte[SfxPBR],al
|
||||
; mov byte[fxtrace+eax],1
|
||||
mov eax,[SfxMemTable+eax*4]
|
||||
mov [SfxCPB],eax
|
||||
mov ebp,eax
|
||||
add ebp,[esi] ; Read RN
|
||||
mov dword [SfxCacheActive],0
|
||||
push ecx
|
||||
call FxOp02
|
||||
pop ecx
|
||||
dec ebp
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro IBTRN 1 ; V
|
||||
movsx eax,byte[ebp]
|
||||
mov cl,[ebp+1]
|
||||
add ebp,2
|
||||
mov [SfxR0+%1*4],ax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro LMSRN 1 ; Verified.
|
||||
xor eax,eax
|
||||
mov al,[ebp]
|
||||
add eax,eax
|
||||
inc ebp
|
||||
add eax,[SfxRAMMem]
|
||||
mov cl,[ebp]
|
||||
mov dword [SfxLastRamAdr],eax
|
||||
mov ebx,[eax] ; Read word from ram
|
||||
inc ebp
|
||||
mov [SfxR0+%1*4],bx ; Write data
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro SMSRN 1 ; Verified.
|
||||
xor eax,eax
|
||||
mov al,[ebp]
|
||||
inc ebp
|
||||
add eax,eax
|
||||
mov cl,[ebp]
|
||||
add eax,[SfxRAMMem]
|
||||
mov ebx,[SfxR0+%1*4] ; Read data
|
||||
mov dword [SfxLastRamAdr],eax
|
||||
inc ebp
|
||||
mov [eax],bx ; Write word to ram
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro FROMRN 1 ; V
|
||||
FETCHPIPE
|
||||
mov esi,SfxR0+%1*4
|
||||
inc ebp ; Increase program counter
|
||||
call [FxTable+ecx*4]
|
||||
mov esi,SfxR0
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro ORRN 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4] ; Read
|
||||
FETCHPIPE
|
||||
or eax,ebx
|
||||
inc ebp
|
||||
mov [edi],eax ; Write DREG
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro XORRN 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4] ; Read
|
||||
FETCHPIPE
|
||||
xor eax,ebx
|
||||
inc ebp
|
||||
mov [edi],eax ; Write DREG
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro ORI 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
or eax,%1
|
||||
inc ebp
|
||||
mov [edi],eax ; Write DREG
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro XORI 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
xor eax,%1
|
||||
inc ebp
|
||||
mov [edi],eax ; Write DREG
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro INCRN 1 ; Verified
|
||||
inc word[SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4] ; Read Source
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
inc ebp
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro DECRN 1 ; Verified
|
||||
dec word[SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4] ; Read Source
|
||||
mov [SfxR0+%1*4],eax
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
inc ebp
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro IWTRN 1 ; aka LEA ; Verified.
|
||||
mov eax,[ebp]
|
||||
mov cl,[ebp+2]
|
||||
and eax,0FFFFh
|
||||
add ebp,3
|
||||
mov [SfxR0+%1*4],eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro LMRN 1 ; Verified!
|
||||
xor eax,eax
|
||||
mov cl,[ebp+2]
|
||||
mov ax,[ebp]
|
||||
mov ebx,[SfxRAMMem]
|
||||
mov [SfxLastRamAdr],eax
|
||||
add [SfxLastRamAdr],ebx
|
||||
mov dl,[eax+ebx]
|
||||
xor eax,1
|
||||
add ebp,3
|
||||
mov dh,[eax+ebx]
|
||||
mov word [SfxR0+%1*4],dx ; Store Word
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro SMRN 1 ; Verified
|
||||
mov ebx,[SfxR0+%1*4]
|
||||
mov eax,[ebp]
|
||||
mov cl,[ebp+2]
|
||||
and eax,0FFFFh
|
||||
mov dx,bx
|
||||
mov ebx,[SfxRAMMem]
|
||||
mov [SfxLastRamAdr],eax
|
||||
add [SfxLastRamAdr],ebx
|
||||
mov [eax+ebx],dl
|
||||
xor eax,1
|
||||
add ebp,3
|
||||
mov [eax+ebx],dh
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro PackEsiEdi 0
|
||||
mov eax,[SfxSREG]
|
||||
shl eax,2
|
||||
add eax,SfxR0
|
||||
mov esi,eax
|
||||
mov eax,[SfxDREG]
|
||||
shl eax,2
|
||||
add eax,SfxR0
|
||||
mov edi,eax
|
||||
mov eax,[SfxRAMBR]
|
||||
shl eax,16
|
||||
add eax,[sfxramdata]
|
||||
mov dword [SfxRAMMem],eax
|
||||
%endmacro
|
||||
|
||||
%macro UnPackEsiEdi 0
|
||||
mov eax,esi
|
||||
sub eax,SfxR0
|
||||
shr eax,2
|
||||
mov [SfxSREG],eax
|
||||
mov eax,edi
|
||||
sub eax,SfxR0
|
||||
shr eax,2
|
||||
mov [SfxDREG],eax
|
||||
%endmacro
|
||||
|
||||
614
zsnes/src/chips/fxemu2b.asm
Normal file
614
zsnes/src/chips/fxemu2b.asm
Normal file
@@ -0,0 +1,614 @@
|
||||
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;as published by the Free Software Foundation; either
|
||||
;version 2 of the License, or (at your option) any later
|
||||
;version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License
|
||||
;along with this program; if not, write to the Free Software
|
||||
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM FxTable,FxTableb,FxTablec,SfxB,SfxCPB,SfxCROM,SfxCarry,SfxOverflow
|
||||
EXTSYM SfxR0,SfxR14,SfxR15,SfxRomBuffer,SfxSignZero,withr15sk
|
||||
|
||||
%include "chips/fxemu2.mac"
|
||||
%include "chips/fxemu2b.mac"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NEWSYM FxOpb05 ; BRA branch always ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
mov cl,[ebp+1]
|
||||
inc ebp
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb06 ; BGE branch on greater or equals ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
mov ebx,[SfxSignZero]
|
||||
shr ebx,15
|
||||
inc ebp
|
||||
xor bl,[SfxOverflow]
|
||||
mov cl,[ebp]
|
||||
test bl,01h
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb07 ; BLT branch on lesss than ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
mov ebx,[SfxSignZero]
|
||||
shr ebx,15
|
||||
inc ebp
|
||||
xor bl,[SfxOverflow]
|
||||
mov cl,[ebp]
|
||||
test bl,01h
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb08 ; BNE branch on not equal ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test dword[SfxSignZero],0FFFFh
|
||||
mov cl,[ebp]
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb09 ; BEQ branch on equal (z=1) ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test dword[SfxSignZero],0FFFFh
|
||||
mov cl,[ebp]
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb0A ; BPL branch on plus ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test dword[SfxSignZero],088000h
|
||||
mov cl,[ebp]
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb0B ; BMI branch on minus ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test dword[SfxSignZero],088000h
|
||||
mov cl,[ebp]
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb0C ; BCC branch on carry clear ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test byte[SfxCarry],01h
|
||||
mov cl,[ebp]
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb0D ; BCS branch on carry set ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test byte[SfxCarry],01h
|
||||
mov cl,[ebp]
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb0E ; BVC branch on overflow clear ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test byte[SfxOverflow],01h
|
||||
mov cl,[ebp]
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb0F ; BVS branch on overflow set ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test byte[SfxOverflow],01h
|
||||
mov cl,[ebp]
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTableb+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb10 ; TO RN set register n as destination register
|
||||
TORNb 0
|
||||
NEWSYM FxOpb11 ; TO RN set register n as destination register
|
||||
TORNb 1
|
||||
NEWSYM FxOpb12 ; TO RN set register n as destination register
|
||||
TORNb 2
|
||||
NEWSYM FxOpb13 ; TO RN set register n as destination register
|
||||
TORNb 3
|
||||
NEWSYM FxOpb14 ; TO RN set register n as destination register
|
||||
TORNb 4
|
||||
NEWSYM FxOpb15 ; TO RN set register n as destination register
|
||||
TORNb 5
|
||||
NEWSYM FxOpb16 ; TO RN set register n as destination register
|
||||
TORNb 6
|
||||
NEWSYM FxOpb17 ; TO RN set register n as destination register
|
||||
TORNb 7
|
||||
NEWSYM FxOpb18 ; TO RN set register n as destination register
|
||||
TORNb 8
|
||||
NEWSYM FxOpb19 ; TO RN set register n as destination register
|
||||
TORNb 9
|
||||
NEWSYM FxOpb1A ; TO RN set register n as destination register
|
||||
TORNb 10
|
||||
NEWSYM FxOpb1B ; TO RN set register n as destination register
|
||||
TORNb 11
|
||||
NEWSYM FxOpb1C ; TO RN set register n as destination register
|
||||
TORNb 12
|
||||
NEWSYM FxOpb1D ; TO RN set register n as destination register
|
||||
TORNb 13
|
||||
NEWSYM FxOpb1E ; TO RN set register n as destination register
|
||||
FETCHPIPE
|
||||
test dword [SfxB],1
|
||||
jnz .VersionB
|
||||
mov edi,SfxR0+14*4
|
||||
inc ebp
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
mov dword[withr15sk],1
|
||||
mov [SfxR15],eax
|
||||
call [FxTableb+ecx*4]
|
||||
mov edi,SfxR0
|
||||
UpdateR14
|
||||
ret
|
||||
.VersionB
|
||||
mov eax,[esi] ; Read Source
|
||||
mov dword[withr15sk],1
|
||||
mov [SfxR0+14*4],eax ; Write
|
||||
CLRFLAGS
|
||||
UpdateR14
|
||||
inc ebp ; Increase program counter
|
||||
ret
|
||||
NEWSYM FxOpb1F ; TO RN set register n as destination register
|
||||
FETCHPIPE
|
||||
test dword [SfxB],1
|
||||
jnz .VersionB
|
||||
mov edi,SfxR0+15*4
|
||||
inc ebp
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
mov [SfxR15],eax
|
||||
call [FxTableb+ecx*4]
|
||||
mov ebp,[SfxCPB]
|
||||
mov dword[withr15sk],1
|
||||
add ebp,[SfxR15]
|
||||
mov edi,SfxR0
|
||||
ret
|
||||
.VersionB
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebp,[SfxCPB]
|
||||
mov dword[withr15sk],1
|
||||
add ebp,eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb3D ; ALT1 set alt1 mode ; Verified.
|
||||
FETCHPIPE
|
||||
mov dword [SfxB],0
|
||||
or ch,01h
|
||||
inc ebp
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
mov [SfxR15],eax
|
||||
call [FxTableb+ecx*4]
|
||||
xor ch,ch
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb3E ; ALT2 set alt1 mode ; Verified.
|
||||
FETCHPIPE
|
||||
mov dword [SfxB],0
|
||||
or ch,02h
|
||||
inc ebp
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
mov [SfxR15],eax
|
||||
call [FxTable+ecx*4]
|
||||
xor ch,ch
|
||||
ret
|
||||
|
||||
NEWSYM FxOpb3F ; ALT3 set alt3 mode ; Verified.
|
||||
FETCHPIPE
|
||||
mov dword [SfxB],0
|
||||
or ch,03h
|
||||
inc ebp
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
mov [SfxR15],eax
|
||||
call [FxTable+ecx*4]
|
||||
xor ch,ch
|
||||
ret
|
||||
|
||||
NEWSYM FxOpbB0 ; FROM rn set source register
|
||||
FROMRNb 0
|
||||
NEWSYM FxOpbB1 ; FROM rn set source register
|
||||
FROMRNb 1
|
||||
NEWSYM FxOpbB2 ; FROM rn set source register
|
||||
FROMRNb 2
|
||||
NEWSYM FxOpbB3 ; FROM rn set source register
|
||||
FROMRNb 3
|
||||
NEWSYM FxOpbB4 ; FROM rn set source register
|
||||
FROMRNb 4
|
||||
NEWSYM FxOpbB5 ; FROM rn set source register
|
||||
FROMRNb 5
|
||||
NEWSYM FxOpbB6 ; FROM rn set source register
|
||||
FROMRNb 6
|
||||
NEWSYM FxOpbB7 ; FROM rn set source register
|
||||
FROMRNb 7
|
||||
NEWSYM FxOpbB8 ; FROM rn set source register
|
||||
FROMRNb 8
|
||||
NEWSYM FxOpbB9 ; FROM rn set source register
|
||||
FROMRNb 9
|
||||
NEWSYM FxOpbBA ; FROM rn set source register
|
||||
FROMRNb 10
|
||||
NEWSYM FxOpbBB ; FROM rn set source register
|
||||
FROMRNb 11
|
||||
NEWSYM FxOpbBC ; FROM rn set source register
|
||||
FROMRNb 12
|
||||
NEWSYM FxOpbBD ; FROM rn set source register
|
||||
FROMRNb 13
|
||||
NEWSYM FxOpbBE ; FROM rn set source register
|
||||
FROMRNb 14
|
||||
NEWSYM FxOpbBF ; FROM rn set source register
|
||||
test dword [SfxB],1
|
||||
jnz .VersionB
|
||||
mov esi,SfxR0+15*4
|
||||
inc ebp ; Increase program counter
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
mov [SfxR15],eax
|
||||
call [FxTableb+ecx*4]
|
||||
mov esi,SfxR0
|
||||
ret
|
||||
.VersionB
|
||||
FETCHPIPE
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
inc ebp
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
shr al,7
|
||||
mov byte[SfxOverflow],al
|
||||
CLRFLAGS
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc05 ; BRA branch always ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
mov cl,[ebp+1]
|
||||
inc ebp
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc06 ; BGE branch on greater or equals ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
mov ebx,[SfxSignZero]
|
||||
shr ebx,15
|
||||
inc ebp
|
||||
xor bl,[SfxOverflow]
|
||||
mov cl,[ebp]
|
||||
test bl,01h
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc07 ; BLT branch on lesss than ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
mov ebx,[SfxSignZero]
|
||||
shr ebx,15
|
||||
inc ebp
|
||||
xor bl,[SfxOverflow]
|
||||
mov cl,[ebp]
|
||||
test bl,01h
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc08 ; BNE branch on not equal ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test dword[SfxSignZero],0FFFFh
|
||||
mov cl,[ebp]
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc09 ; BEQ branch on equal (z=1) ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test dword[SfxSignZero],0FFFFh
|
||||
mov cl,[ebp]
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc0A ; BPL branch on plus ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test dword[SfxSignZero],088000h
|
||||
mov cl,[ebp]
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc0B ; BMI branch on minus ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test dword[SfxSignZero],088000h
|
||||
mov cl,[ebp]
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc0C ; BCC branch on carry clear ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test byte[SfxCarry],01h
|
||||
mov cl,[ebp]
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc0D ; BCS branch on carry set ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test byte[SfxCarry],01h
|
||||
mov cl,[ebp]
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc0E ; BVC branch on overflow clear ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test byte[SfxOverflow],01h
|
||||
mov cl,[ebp]
|
||||
jnz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc0F ; BVS branch on overflow set ; Verified.
|
||||
movsx eax,byte[ebp]
|
||||
inc ebp
|
||||
test byte[SfxOverflow],01h
|
||||
mov cl,[ebp]
|
||||
jz .nojump
|
||||
add ebp,eax
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
.nojump
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc10 ; TO RN set register n as destination register
|
||||
TORNc 0
|
||||
NEWSYM FxOpc11 ; TO RN set register n as destination register
|
||||
TORNc 1
|
||||
NEWSYM FxOpc12 ; TO RN set register n as destination register
|
||||
TORNc 2
|
||||
NEWSYM FxOpc13 ; TO RN set register n as destination register
|
||||
TORNc 3
|
||||
NEWSYM FxOpc14 ; TO RN set register n as destination register
|
||||
TORNc 4
|
||||
NEWSYM FxOpc15 ; TO RN set register n as destination register
|
||||
TORNc 5
|
||||
NEWSYM FxOpc16 ; TO RN set register n as destination register
|
||||
TORNc 6
|
||||
NEWSYM FxOpc17 ; TO RN set register n as destination register
|
||||
TORNc 7
|
||||
NEWSYM FxOpc18 ; TO RN set register n as destination register
|
||||
TORNc 8
|
||||
NEWSYM FxOpc19 ; TO RN set register n as destination register
|
||||
TORNc 9
|
||||
NEWSYM FxOpc1A ; TO RN set register n as destination register
|
||||
TORNc 10
|
||||
NEWSYM FxOpc1B ; TO RN set register n as destination register
|
||||
TORNc 11
|
||||
NEWSYM FxOpc1C ; TO RN set register n as destination register
|
||||
TORNc 12
|
||||
NEWSYM FxOpc1D ; TO RN set register n as destination register
|
||||
TORNc 13
|
||||
NEWSYM FxOpc1E ; TO RN set register n as destination register
|
||||
FETCHPIPE
|
||||
mov eax,[esi] ; Read Source
|
||||
mov [SfxR0+14*4],eax ; Write
|
||||
CLRFLAGS
|
||||
UpdateR14
|
||||
inc ebp ; Increase program counter
|
||||
ret
|
||||
NEWSYM FxOpc1F ; TO RN set register n as destination register
|
||||
FETCHPIPE
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebp,[SfxCPB]
|
||||
mov [SfxR15],eax
|
||||
add ebp,eax
|
||||
CLRFLAGS
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc3D ; ALT1 set alt1 mode ; Verified.
|
||||
FETCHPIPE
|
||||
mov dword [SfxB],0
|
||||
or ch,01h
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
xor ch,ch
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc3E ; ALT2 set alt1 mode ; Verified.
|
||||
FETCHPIPE
|
||||
mov dword [SfxB],0
|
||||
or ch,02h
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
xor ch,ch
|
||||
ret
|
||||
|
||||
NEWSYM FxOpc3F ; ALT3 set alt3 mode ; Verified.
|
||||
FETCHPIPE
|
||||
mov dword [SfxB],0
|
||||
or ch,03h
|
||||
inc ebp
|
||||
call [FxTablec+ecx*4]
|
||||
xor ch,ch
|
||||
ret
|
||||
|
||||
NEWSYM FxOpcB0 ; FROM rn set source register
|
||||
FROMRNc 0
|
||||
NEWSYM FxOpcB1 ; FROM rn set source register
|
||||
FROMRNc 1
|
||||
NEWSYM FxOpcB2 ; FROM rn set source register
|
||||
FROMRNc 2
|
||||
NEWSYM FxOpcB3 ; FROM rn set source register
|
||||
FROMRNc 3
|
||||
NEWSYM FxOpcB4 ; FROM rn set source register
|
||||
FROMRNc 4
|
||||
NEWSYM FxOpcB5 ; FROM rn set source register
|
||||
FROMRNc 5
|
||||
NEWSYM FxOpcB6 ; FROM rn set source register
|
||||
FROMRNc 6
|
||||
NEWSYM FxOpcB7 ; FROM rn set source register
|
||||
FROMRNc 7
|
||||
NEWSYM FxOpcB8 ; FROM rn set source register
|
||||
FROMRNc 8
|
||||
NEWSYM FxOpcB9 ; FROM rn set source register
|
||||
FROMRNc 9
|
||||
NEWSYM FxOpcBA ; FROM rn set source register
|
||||
FROMRNc 10
|
||||
NEWSYM FxOpcBB ; FROM rn set source register
|
||||
FROMRNc 11
|
||||
NEWSYM FxOpcBC ; FROM rn set source register
|
||||
FROMRNc 12
|
||||
NEWSYM FxOpcBD ; FROM rn set source register
|
||||
FROMRNc 13
|
||||
NEWSYM FxOpcBE ; FROM rn set source register
|
||||
FROMRNc 14
|
||||
NEWSYM FxOpcBF ; FROM rn set source register
|
||||
FETCHPIPE
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
inc ebp
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
shr al,7
|
||||
mov byte[SfxOverflow],al
|
||||
CLRFLAGS
|
||||
ret
|
||||
|
||||
89
zsnes/src/chips/fxemu2b.mac
Normal file
89
zsnes/src/chips/fxemu2b.mac
Normal file
@@ -0,0 +1,89 @@
|
||||
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;as published by the Free Software Foundation; either
|
||||
;version 2 of the License, or (at your option) any later
|
||||
;version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License
|
||||
;along with this program; if not, write to the Free Software
|
||||
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%macro TORNb 1 ; V
|
||||
FETCHPIPE
|
||||
test dword [SfxB],1
|
||||
jnz .VersionB
|
||||
mov edi, SfxR0+%1*4
|
||||
inc ebp ; Increase program counter
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
mov dword[withr15sk],1
|
||||
mov [SfxR15],eax
|
||||
call [FxTableb+ecx*4]
|
||||
mov edi,SfxR0
|
||||
ret
|
||||
.VersionB
|
||||
mov eax,[esi] ; Read Source
|
||||
mov dword[withr15sk],1
|
||||
inc ebp ; Increase program counter
|
||||
mov [SfxR0+%1*4],eax ; Write
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro FROMRNb 1 ; V
|
||||
FETCHPIPE
|
||||
test dword [SfxB],1
|
||||
jnz .VersionB
|
||||
mov esi,SfxR0+%1*4
|
||||
inc ebp ; Increase program counter
|
||||
call [FxTable+ecx*4]
|
||||
mov esi,SfxR0
|
||||
ret
|
||||
.VersionB
|
||||
mov eax,[SfxR0+%1*4] ; Read
|
||||
inc ebp
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
shr al,7
|
||||
mov byte[SfxOverflow],al
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%macro TORNc 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax,[esi] ; Read Source
|
||||
inc ebp ; Increase program counter
|
||||
mov [SfxR0+%1*4],eax ; Write
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
|
||||
%macro FROMRNc 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4] ; Read
|
||||
inc ebp
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
shr al,7
|
||||
mov byte[SfxOverflow],al
|
||||
CLRFLAGS
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
2551
zsnes/src/chips/fxemu2c.asm
Normal file
2551
zsnes/src/chips/fxemu2c.asm
Normal file
File diff suppressed because it is too large
Load Diff
529
zsnes/src/chips/fxemu2c.mac
Normal file
529
zsnes/src/chips/fxemu2c.mac
Normal file
@@ -0,0 +1,529 @@
|
||||
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;as published by the Free Software Foundation; either
|
||||
;version 2 of the License, or (at your option) any later
|
||||
;version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License
|
||||
;along with this program; if not, write to the Free Software
|
||||
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%macro FXReturn 0
|
||||
dec dword [NumberOfOpcodes]
|
||||
jmp [FxTabled+ecx*4]
|
||||
ALIGN32
|
||||
%endmacro
|
||||
|
||||
%macro FXReturn2 0
|
||||
dec dword [NumberOfOpcodes]
|
||||
js %%endloop
|
||||
jmp [FxTabled+ecx*4]
|
||||
%%endloop
|
||||
jmp FXEndLoop
|
||||
; jmp [FxTabled+ecx*4]
|
||||
ALIGN32
|
||||
%endmacro
|
||||
|
||||
%macro TORNd 1 ; V
|
||||
FETCHPIPE
|
||||
mov edi, SfxR0+%1*4
|
||||
inc ebp ; Increase program counter
|
||||
call [FxTable+ecx*4]
|
||||
mov edi,SfxR0
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro WITHc 1 ; Verified.
|
||||
FETCHPIPE
|
||||
mov esi,SfxR0+%1*4
|
||||
mov edi,SfxR0+%1*4
|
||||
mov dword [SfxB],1
|
||||
inc ebp ; Increase program counter
|
||||
call [FxTablec+ecx*4]
|
||||
mov esi,SfxR0
|
||||
mov edi,SfxR0
|
||||
mov dword [SfxB],0 ; Clear B Flag
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro STWRNc 1 ; V
|
||||
mov eax,[SfxR0+%1*4] ; Read register
|
||||
mov ebx,[SfxRAMMem]
|
||||
mov dword [SfxLastRamAdr],eax ; Save last ram address
|
||||
add dword [SfxLastRamAdr],ebx ; Save last ram address
|
||||
mov edx,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
mov [ebx+eax],dl ; Store Word
|
||||
xor eax,1
|
||||
inc ebp ; Increase program counter
|
||||
mov [ebx+eax],dh ; Store Word
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro STBRNc 1 ; V
|
||||
mov eax,[SfxR0+%1*4] ; Read register
|
||||
FETCHPIPE
|
||||
add eax,[SfxRAMMem]
|
||||
mov dword [SfxLastRamAdr],eax ; Save last ram address
|
||||
mov ebx,[esi] ; Read Source
|
||||
mov byte [eax],bl ; Store Byte
|
||||
CLRFLAGS
|
||||
inc ebp ; Increase program counter
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro LDWRNc 1 ; V
|
||||
mov eax,[SfxR0+%1*4] ; Read register
|
||||
mov ebx,[SfxRAMMem]
|
||||
mov dword [SfxLastRamAdr],eax ; Save last ram address
|
||||
FETCHPIPE
|
||||
mov dl,[ebx+eax] ; Store Word
|
||||
add dword [SfxLastRamAdr],ebx ; Save last ram address
|
||||
xor eax,1
|
||||
and edx,0FFFFh
|
||||
inc ebp ; Increase program counter
|
||||
mov dh,[ebx+eax] ; Store Word
|
||||
mov [edi],edx ; Read Source
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro LDBRNc 1 ; V
|
||||
mov eax,[SfxR0+%1*4] ; Read register
|
||||
FETCHPIPE
|
||||
add eax,[SfxRAMMem]
|
||||
xor ebx,ebx
|
||||
mov dword [SfxLastRamAdr],eax ; Save last ram address
|
||||
mov bl,[eax] ; Read Byte
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],ebx ; Store Result
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ADDRNc 1 ; V
|
||||
mov eax, [esi] ; Read Source
|
||||
mov ebx, [SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
add ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
mov [SfxSignZero],eax
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ADCRNc 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax, [esi] ; Read Source
|
||||
mov ebx, [SfxR0+%1*4]
|
||||
shr byte[SfxCarry],1
|
||||
adc ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
mov [SfxSignZero],eax
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ADIRNc 1 ; V
|
||||
mov eax, [esi] ; Read Source
|
||||
FETCHPIPE
|
||||
add ax,%1
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
mov [SfxSignZero],eax
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ADCIRNc 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax, [esi] ; Read Source
|
||||
shr byte[SfxCarry],1
|
||||
adc ax,%1
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
mov [SfxSignZero],eax
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro SUBRNc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
sub ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
xor byte[SfxCarry],1
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro SBCRNc 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4]
|
||||
cmp byte[SfxCarry],1
|
||||
sbb ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
xor byte[SfxCarry],1
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro SUBIRNc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
sub ax,%1
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
xor byte[SfxCarry],1
|
||||
inc ebp ; Increase program counter
|
||||
mov [edi],eax ; Write Destination
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro CMPRNc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
sub ax,bx
|
||||
seto byte[SfxOverflow]
|
||||
setc byte[SfxCarry]
|
||||
xor byte[SfxCarry],1
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
inc ebp ; Increase program counter
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ANDRNc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4] ; Read RN
|
||||
FETCHPIPE
|
||||
and eax,ebx
|
||||
inc ebp
|
||||
mov dword [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro BICRNc 1 ; V
|
||||
mov ebx,[SfxR0+%1*4] ; Read RN
|
||||
mov eax,[esi] ; Read Source
|
||||
xor ebx,0FFFFh
|
||||
FETCHPIPE
|
||||
and eax,ebx
|
||||
inc ebp
|
||||
mov dword [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ANDIRNc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
and eax,%1
|
||||
inc ebp
|
||||
mov dword [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro BICIRNc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
and eax,%1
|
||||
inc ebp
|
||||
mov dword [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro MULTRNc 1 ; V
|
||||
mov al,byte [esi] ; Read Source
|
||||
mov bl,byte [SfxR0+%1*4] ; Read RN
|
||||
FETCHPIPE
|
||||
imul bl
|
||||
inc ebp
|
||||
and eax,0FFFFh
|
||||
mov [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro UMULTRNc 1 ; V
|
||||
mov al,byte [esi] ; Read Source
|
||||
mov bl,byte [SfxR0+%1*4] ; Read RN
|
||||
FETCHPIPE
|
||||
mul bl
|
||||
inc ebp
|
||||
and eax,0FFFFh
|
||||
mov [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro MULTIRNc 1 ; V
|
||||
mov al,byte [esi] ; Read Source
|
||||
mov bl,%1 ; Read RN
|
||||
FETCHPIPE
|
||||
imul bl
|
||||
inc ebp
|
||||
and eax,0FFFFh
|
||||
mov [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro UMULTIRNc 1 ; V
|
||||
mov al,byte [esi] ; Read Source
|
||||
mov bl,%1 ; Read RN
|
||||
FETCHPIPE
|
||||
mul bl
|
||||
inc ebp
|
||||
and eax,0FFFFh
|
||||
mov [SfxSignZero],eax
|
||||
mov [edi],eax ; Write Destination
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro LINKc 1 ; Verified.
|
||||
mov eax,ebp
|
||||
sub eax,[SfxCPB]
|
||||
add eax,%1
|
||||
FETCHPIPE
|
||||
mov word [SfxR11],ax
|
||||
CLRFLAGS
|
||||
inc ebp
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro JMPRNc 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4] ; Read RN
|
||||
mov ebp,[SfxCPB]
|
||||
add ebp,eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro LJMPRNc 1 ; V
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4]
|
||||
and eax,07Fh
|
||||
mov byte[SfxPBR],al
|
||||
; mov byte[fxtrace+eax],1
|
||||
mov eax,[SfxMemTable+eax*4]
|
||||
mov [SfxCPB],eax
|
||||
mov ebp,eax
|
||||
add ebp,[esi] ; Read RN
|
||||
mov dword [SfxCacheActive],0
|
||||
push ecx
|
||||
call FxOp02
|
||||
pop ecx
|
||||
dec ebp
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro IBTRNc 1 ; V
|
||||
movsx eax,byte[ebp]
|
||||
mov cl,[ebp+1]
|
||||
add ebp,2
|
||||
mov [SfxR0+%1*4],ax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro LMSRNc 1 ; Verified.
|
||||
xor eax,eax
|
||||
mov al,[ebp]
|
||||
add eax,eax
|
||||
inc ebp
|
||||
add eax,[SfxRAMMem]
|
||||
mov cl,[ebp]
|
||||
mov dword [SfxLastRamAdr],eax
|
||||
mov ebx,[eax] ; Read word from ram
|
||||
inc ebp
|
||||
mov [SfxR0+%1*4],bx ; Write data
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro SMSRNc 1 ; Verified.
|
||||
xor eax,eax
|
||||
mov al,[ebp]
|
||||
inc ebp
|
||||
add eax,eax
|
||||
mov cl,[ebp]
|
||||
add eax,[SfxRAMMem]
|
||||
mov ebx,[SfxR0+%1*4] ; Read data
|
||||
mov dword [SfxLastRamAdr],eax
|
||||
inc ebp
|
||||
mov [eax],bx ; Write word to ram
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro FROMRNd 1 ; V
|
||||
FETCHPIPE
|
||||
mov esi,SfxR0+%1*4
|
||||
inc ebp ; Increase program counter
|
||||
call [FxTable+ecx*4]
|
||||
mov esi,SfxR0
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ORRNc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4] ; Read
|
||||
FETCHPIPE
|
||||
or eax,ebx
|
||||
inc ebp
|
||||
mov [edi],eax ; Write DREG
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro XORRNc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
mov ebx,[SfxR0+%1*4] ; Read
|
||||
FETCHPIPE
|
||||
xor eax,ebx
|
||||
inc ebp
|
||||
mov [edi],eax ; Write DREG
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro ORIc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
or eax,%1
|
||||
inc ebp
|
||||
mov [edi],eax ; Write DREG
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro XORIc 1 ; V
|
||||
mov eax,[esi] ; Read Source
|
||||
FETCHPIPE
|
||||
xor eax,%1
|
||||
inc ebp
|
||||
mov [edi],eax ; Write DREG
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro INCRNc 1 ; Verified
|
||||
inc word[SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4] ; Read Source
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
inc ebp
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro DECRNc 1 ; Verified
|
||||
dec word[SfxR0+%1*4]
|
||||
FETCHPIPE
|
||||
mov eax,[SfxR0+%1*4] ; Read Source
|
||||
mov [SfxR0+%1*4],eax
|
||||
mov [SfxSignZero],eax
|
||||
CLRFLAGS
|
||||
inc ebp
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro IWTRNc 1 ; aka LEA ; Verified.
|
||||
mov eax,[ebp]
|
||||
mov cl,[ebp+2]
|
||||
and eax,0FFFFh
|
||||
add ebp,3
|
||||
mov [SfxR0+%1*4],eax
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro LMRNc 1 ; Verified!
|
||||
xor eax,eax
|
||||
mov cl,[ebp+2]
|
||||
mov ax,[ebp]
|
||||
mov ebx,[SfxRAMMem]
|
||||
mov [SfxLastRamAdr],eax
|
||||
add [SfxLastRamAdr],ebx
|
||||
mov dl,[eax+ebx]
|
||||
xor eax,1
|
||||
add ebp,3
|
||||
mov dh,[eax+ebx]
|
||||
mov word [SfxR0+%1*4],dx ; Store Word
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
%macro SMRNc 1 ; Verified
|
||||
mov ebx,[SfxR0+%1*4]
|
||||
mov eax,[ebp]
|
||||
mov cl,[ebp+2]
|
||||
and eax,0FFFFh
|
||||
mov dx,bx
|
||||
mov ebx,[SfxRAMMem]
|
||||
mov [SfxLastRamAdr],eax
|
||||
add [SfxLastRamAdr],ebx
|
||||
mov [eax+ebx],dl
|
||||
xor eax,1
|
||||
add ebp,3
|
||||
mov [eax+ebx],dh
|
||||
CLRFLAGS
|
||||
FXReturn
|
||||
%endmacro
|
||||
|
||||
3546
zsnes/src/chips/fxtable.asm
Normal file
3546
zsnes/src/chips/fxtable.asm
Normal file
File diff suppressed because it is too large
Load Diff
365
zsnes/src/chips/sa1proc.asm
Normal file
365
zsnes/src/chips/sa1proc.asm
Normal file
@@ -0,0 +1,365 @@
|
||||
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;as published by the Free Software Foundation; either
|
||||
;version 2 of the License, or (at your option) any later
|
||||
;version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License
|
||||
;along with this program; if not, write to the Free Software
|
||||
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM xa,xx,xy,xd,xdb,xpb,xs,xe,initaddrl,UpdateDPage,wramdata,IRAM,cycpbl,SA1DoIRQ
|
||||
EXTSYM spcnumread,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
|
||||
EXTSYM membank0w8,romdata,SA1LBound,SA1UBound,SA1SH,SA1SHb
|
||||
EXTSYM stackor,stackand,snesmmap,SA1xs,SA1IRQExec
|
||||
EXTSYM SA1Message,Sflagnz,Sflagc,Sflago
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; In exec loop, jump to execloop if SA1Status != 0
|
||||
; *** Disable spc700 if possible ***
|
||||
|
||||
|
||||
|
||||
NEWSYM SA1Status, db 0 ; 0 = 65816, 1 = SA1A, 2 = SA1B
|
||||
|
||||
NEWSYM CurrentExecSA1, db 0
|
||||
NEWSYM CurrentCPU, db 0
|
||||
|
||||
ALIGN32
|
||||
NEWSYM prevedi, dd 0
|
||||
|
||||
%macro SA1Debugb 0
|
||||
pushad
|
||||
sub esi,[initaddrl]
|
||||
mov [SA1xpc],esi
|
||||
call nextopcodesa1
|
||||
popad
|
||||
mov bl,[esi]
|
||||
xor dh,dh
|
||||
inc esi
|
||||
call dword near [edi+ebx*4]
|
||||
dec esi
|
||||
%endmacro
|
||||
|
||||
%macro SA1Debug 0
|
||||
; debug version
|
||||
test byte[debugds],01h
|
||||
jz near .nodebug
|
||||
cmp byte[debuggeron],0
|
||||
je near .nodebug
|
||||
SA1Debugb
|
||||
SA1Debugb
|
||||
SA1Debugb
|
||||
SA1Debugb
|
||||
SA1Debugb
|
||||
SA1Debugb
|
||||
SA1Debugb
|
||||
SA1Debugb
|
||||
jmp .debug
|
||||
.nodebug
|
||||
%endmacro
|
||||
|
||||
|
||||
NEWSYM SA1Swap
|
||||
mov ecx,[SA1BWPtr]
|
||||
mov eax,[SA1Ptr] ; small speed hack
|
||||
test byte[SA1DoIRQ],1
|
||||
jnz near .sa1exec3
|
||||
cmp byte[IRAM],0
|
||||
jne .sa1exec2
|
||||
cmp dword[eax],0FCF000A5h
|
||||
je near .nosa1exec
|
||||
cmp dword[eax-2],0FCF000A5h
|
||||
je near .nosa1exec
|
||||
.sa1exec2
|
||||
cmp byte[SA1SHb],1
|
||||
je near .nosa1execb
|
||||
|
||||
cmp word[ecx+72A4h],0
|
||||
jnz .sa1exec
|
||||
cmp dword[eax],0F072A4ADh
|
||||
je near .nosa1execb
|
||||
.sa1exec
|
||||
cmp byte[IRAM+72h],0
|
||||
jne .sa1exec3
|
||||
cmp dword[eax],0F03072ADh
|
||||
je near .nosa1execb
|
||||
.sa1exec3
|
||||
.yesdebugr
|
||||
xor ecx,ecx
|
||||
; store all snes 65816 stuff
|
||||
mov [SNSRegP],dl
|
||||
mov eax,[initaddrl]
|
||||
mov [prevedi],edi
|
||||
mov [SNSRegPCS],eax
|
||||
mov [SNSPtr],esi
|
||||
; restore all sa1 65816 stuff
|
||||
mov dl,[SA1RegP]
|
||||
mov eax,[SA1RegPCS]
|
||||
mov [initaddrl],eax
|
||||
mov eax,[SA1BWPtr]
|
||||
mov [CurBWPtr],eax
|
||||
mov esi,[SA1Ptr]
|
||||
mov dword[snesmap2],IRAM
|
||||
mov dword[wramdata],IRAM
|
||||
; Check if IRQ is executed on SA-1
|
||||
xor eax,eax
|
||||
mov al,dl
|
||||
add dh,25
|
||||
mov edi,[SA1tablead+eax*4]
|
||||
mov byte[SA1Status],1
|
||||
test dword[SA1DoIRQ],0FF000003h
|
||||
jnz near .switchirq
|
||||
.returnirq
|
||||
|
||||
; SA1Debug
|
||||
|
||||
cmp byte[SA1SH],1
|
||||
je near .speedhack
|
||||
|
||||
; non debug version
|
||||
mov bl,[esi]
|
||||
inc esi
|
||||
call dword near [edi+ebx*4]
|
||||
dec esi
|
||||
.debug
|
||||
|
||||
; store all sa1 65816 stuff
|
||||
mov [SA1RegP],dl
|
||||
mov eax,[initaddrl]
|
||||
mov [SA1RegPCS],eax
|
||||
mov [SA1Ptr],esi
|
||||
; restore all snes 65816 stuff
|
||||
mov dl,[SNSRegP]
|
||||
mov eax,[SNSRegPCS]
|
||||
mov [initaddrl],eax
|
||||
mov eax,[SNSBWPtr]
|
||||
mov [CurBWPtr],eax
|
||||
mov dword[wramdata],wramdataa
|
||||
mov esi,[SNSPtr]
|
||||
mov eax,[wramdata]
|
||||
mov dword[snesmap2],eax
|
||||
mov edi,[prevedi]
|
||||
xor eax,eax
|
||||
add dh,11
|
||||
inc byte[CurrentExecSA1]
|
||||
mov byte[SA1Status],0
|
||||
add dword[SA1TimerVal],23
|
||||
ret
|
||||
|
||||
.speedhack
|
||||
add dh,100
|
||||
|
||||
mov bl,[esi]
|
||||
inc esi
|
||||
call dword near [edi+ebx*4]
|
||||
dec esi
|
||||
; store all sa1 65816 stuff
|
||||
mov [SA1RegP],dl
|
||||
mov eax,[initaddrl]
|
||||
mov [SA1RegPCS],eax
|
||||
mov [SA1Ptr],esi
|
||||
; restore all snes 65816 stuff
|
||||
mov dl,[SNSRegP]
|
||||
mov eax,[SNSRegPCS]
|
||||
mov [initaddrl],eax
|
||||
mov eax,[SNSBWPtr]
|
||||
mov [CurBWPtr],eax
|
||||
mov dword[wramdata],wramdataa
|
||||
mov esi,[SNSPtr]
|
||||
mov eax,[wramdata]
|
||||
mov dword[snesmap2],eax
|
||||
mov edi,[prevedi]
|
||||
xor eax,eax
|
||||
add byte[CurrentExecSA1],4
|
||||
mov byte[SA1Status],0
|
||||
add dword[SA1TimerVal],23
|
||||
; xor dh,dh
|
||||
mov dh,18
|
||||
cmp esi,dword[SA1LBound]
|
||||
jb .stoph
|
||||
cmp esi,dword[SA1UBound]
|
||||
ja .stoph
|
||||
ret
|
||||
.stoph
|
||||
mov byte[SA1SH],0
|
||||
ret
|
||||
.nosa1execb
|
||||
xor ecx,ecx
|
||||
add dh,15
|
||||
add byte[CurrentExecSA1],2
|
||||
mov byte[SA1Status],0
|
||||
ret
|
||||
.nosa1exec
|
||||
xor ecx,ecx
|
||||
add dh,22
|
||||
add byte[CurrentExecSA1],2
|
||||
mov byte[SA1Status],0
|
||||
ret
|
||||
.switchirq
|
||||
test dword[SA1DoIRQ],3
|
||||
jz .notirq
|
||||
test dword[SA1DoIRQ],1
|
||||
jz .nmi
|
||||
and byte[SA1DoIRQ],0FEh
|
||||
call SA1switchtovirq
|
||||
jmp .returnirq
|
||||
.nmi
|
||||
and byte[SA1DoIRQ],0FDh
|
||||
call SA1switchtonmi
|
||||
jmp .returnirq
|
||||
.notirq
|
||||
dec byte[SA1DoIRQ+3]
|
||||
jz .hack
|
||||
jmp .returnirq
|
||||
.hack
|
||||
or byte[SA1DoIRQ],8
|
||||
jmp .returnirq
|
||||
|
||||
NEWSYM SA1xpc, dd 0
|
||||
|
||||
%macro makedl 0
|
||||
and dl,00111100b
|
||||
test dword[Sflagnz],18000h
|
||||
jz %%noneg
|
||||
or dl,80h
|
||||
%%noneg
|
||||
test dword[Sflagnz],0FFFFh
|
||||
jnz %%nozero
|
||||
or dl,02h
|
||||
%%nozero
|
||||
test dword[Sflagc],0FFh
|
||||
jz %%nocarry
|
||||
or dl,01h
|
||||
%%nocarry
|
||||
test dword[Sflago],0FFh
|
||||
jz %%nov
|
||||
or dl,40h
|
||||
%%nov
|
||||
%endmacro
|
||||
|
||||
NEWSYM SA1switchtonmi
|
||||
mov al,byte[SA1Message]
|
||||
mov byte[SA1Message+2],al
|
||||
mov byte[SA1IRQExec+2],1
|
||||
mov ebx,esi
|
||||
sub ebx,[initaddrl]
|
||||
mov [SA1xpc],bx
|
||||
|
||||
xor ecx,ecx
|
||||
mov cx,[SA1xs]
|
||||
mov al,[SA1xpb]
|
||||
call membank0w8
|
||||
|
||||
dec cx
|
||||
and cx,word[stackand]
|
||||
or cx,word[stackor]
|
||||
mov al,[SA1xpc+1]
|
||||
call membank0w8
|
||||
|
||||
dec cx
|
||||
and cx,word[stackand]
|
||||
or cx,word[stackor]
|
||||
mov al,[SA1xpc]
|
||||
call membank0w8
|
||||
|
||||
dec cx
|
||||
and cx,word[stackand]
|
||||
or cx,word[stackor]
|
||||
makedl
|
||||
mov al,dl
|
||||
call membank0w8
|
||||
|
||||
dec cx
|
||||
and cx,word[stackand]
|
||||
or cx,word[stackor]
|
||||
mov [SA1xs],cx
|
||||
|
||||
xor ebx,ebx
|
||||
mov [SA1xpb],bl
|
||||
xor eax,eax
|
||||
mov ax,[SA1NMIV]
|
||||
and dl,11110011b
|
||||
or dl,00000100b
|
||||
test ax,8000h
|
||||
jz .loweraddr
|
||||
mov esi,[snesmmap+ebx*4]
|
||||
mov [initaddrl],esi
|
||||
add esi,eax
|
||||
ret
|
||||
.loweraddr
|
||||
mov esi,[snesmap2+ebx*4]
|
||||
mov [initaddrl],esi
|
||||
add esi,eax
|
||||
ret
|
||||
|
||||
NEWSYM SA1switchtovirq
|
||||
mov al,byte[SA1Message]
|
||||
mov byte[SA1Message+2],al
|
||||
mov byte[SA1IRQExec+1],1
|
||||
mov ebx,esi
|
||||
sub ebx,[initaddrl]
|
||||
mov [SA1xpc],bx
|
||||
|
||||
xor ecx,ecx
|
||||
mov cx,[SA1xs]
|
||||
mov al,[SA1xpb]
|
||||
call membank0w8
|
||||
|
||||
dec cx
|
||||
and cx,word[stackand]
|
||||
or cx,word[stackor]
|
||||
mov al,[SA1xpc+1]
|
||||
call membank0w8
|
||||
|
||||
dec cx
|
||||
and cx,word[stackand]
|
||||
or cx,word[stackor]
|
||||
mov al,[SA1xpc]
|
||||
call membank0w8
|
||||
|
||||
dec cx
|
||||
and cx,word[stackand]
|
||||
or cx,word[stackor]
|
||||
makedl
|
||||
mov al,dl
|
||||
call membank0w8
|
||||
|
||||
dec cx
|
||||
and cx,word[stackand]
|
||||
or cx,word[stackor]
|
||||
mov [SA1xs],cx
|
||||
xor ebx,ebx
|
||||
mov [SA1xpb],bl
|
||||
xor eax,eax
|
||||
mov ax,[SA1IRQV]
|
||||
and dl,11110011b
|
||||
or dl,00000100b
|
||||
test ax,8000h
|
||||
jz .loweraddr
|
||||
mov esi,[snesmmap+ebx*4]
|
||||
mov [initaddrl],esi
|
||||
add esi,eax
|
||||
ret
|
||||
.loweraddr
|
||||
mov esi,[snesmap2+ebx*4]
|
||||
mov [initaddrl],esi
|
||||
add esi,eax
|
||||
ret
|
||||
|
||||
2577
zsnes/src/chips/sa1regs.asm
Normal file
2577
zsnes/src/chips/sa1regs.asm
Normal file
File diff suppressed because it is too large
Load Diff
670
zsnes/src/chips/sfxproc.asm
Normal file
670
zsnes/src/chips/sfxproc.asm
Normal file
@@ -0,0 +1,670 @@
|
||||
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;as published by the Free Software Foundation; either
|
||||
;version 2 of the License, or (at your option) any later
|
||||
;version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License
|
||||
;along with this program; if not, write to the Free Software
|
||||
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM NumberOfOpcodes,SfxB,SfxBRAMR,SfxCBR,SfxCFGR,SfxCLSR,SfxCPB,SfxCROM
|
||||
EXTSYM SfxCarry,SfxMemTable,SfxOverflow,SfxPBR,SfxPIPE,SfxR0,SfxR1,SfxR10
|
||||
EXTSYM SfxR11,SfxR12,SfxR13,SfxR14,SfxR15,SfxR2,SfxR3,SfxR4,SfxR5,SfxR6
|
||||
EXTSYM SfxR7,SfxR8,SfxR9,SfxRAMBR,SfxRAMMem,SfxROMBR,SfxSCBR,SfxSCMR,SfxSFR
|
||||
EXTSYM SfxSignZero,SfxnRamBanks,StartSFX,regptr,regptw,sfxramdata,ChangeOps
|
||||
EXTSYM SfxPOR,sfxclineloc,UpdatePORSCMR,UpdateCLSR,UpdateSCBRCOLR,SfxAC
|
||||
EXTSYM sfx128lineloc,sfx160lineloc,sfx192lineloc,sfxobjlineloc,SFXProc
|
||||
|
||||
%include "cpu\regs.mac"
|
||||
%include "cpu\regsw.mac"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%macro AssembleSFXFlags 0
|
||||
and word[SfxSFR],8F60h
|
||||
test byte[SfxCarry],1
|
||||
jz .nosfxcarry
|
||||
or word[SfxSFR],04h
|
||||
.nosfxcarry
|
||||
cmp word[SfxSignZero],0
|
||||
jne .nozero
|
||||
or word[SfxSFR],02h
|
||||
.nozero
|
||||
test word[SfxSignZero],8000h
|
||||
jz .noneg
|
||||
or word[SfxSFR],08h
|
||||
.noneg
|
||||
cmp byte[SfxOverflow],0
|
||||
je .noof
|
||||
or word[SfxSFR],10h
|
||||
.noof
|
||||
cmp byte[SfxB],0
|
||||
je .bzero
|
||||
or word[SfxSFR],1000h
|
||||
.bzero
|
||||
%endmacro
|
||||
|
||||
|
||||
NEWSYM initsfxregsr
|
||||
setreg 3000h*4,reg3000r
|
||||
setreg 3001h*4,reg3001r
|
||||
setreg 3002h*4,reg3002r
|
||||
setreg 3003h*4,reg3003r
|
||||
setreg 3004h*4,reg3004r
|
||||
setreg 3005h*4,reg3005r
|
||||
setreg 3006h*4,reg3006r
|
||||
setreg 3007h*4,reg3007r
|
||||
setreg 3008h*4,reg3008r
|
||||
setreg 3009h*4,reg3009r
|
||||
setreg 300Ah*4,reg300Ar
|
||||
setreg 300Bh*4,reg300Br
|
||||
setreg 300Ch*4,reg300Cr
|
||||
setreg 300Dh*4,reg300Dr
|
||||
setreg 300Eh*4,reg300Er
|
||||
setreg 300Fh*4,reg300Fr
|
||||
setreg 3010h*4,reg3010r
|
||||
setreg 3011h*4,reg3011r
|
||||
setreg 3012h*4,reg3012r
|
||||
setreg 3013h*4,reg3013r
|
||||
setreg 3014h*4,reg3014r
|
||||
setreg 3015h*4,reg3015r
|
||||
setreg 3016h*4,reg3016r
|
||||
setreg 3017h*4,reg3017r
|
||||
setreg 3018h*4,reg3018r
|
||||
setreg 3019h*4,reg3019r
|
||||
setreg 301Ah*4,reg301Ar
|
||||
setreg 301Bh*4,reg301Br
|
||||
setreg 301Ch*4,reg301Cr
|
||||
setreg 301Dh*4,reg301Dr
|
||||
setreg 301Eh*4,reg301Er
|
||||
setreg 301Fh*4,reg301Fr
|
||||
setreg 3030h*4,reg3030r
|
||||
setreg 3031h*4,reg3031r
|
||||
setreg 3032h*4,reg3032r
|
||||
setreg 3033h*4,reg3033r
|
||||
setreg 3034h*4,reg3034r
|
||||
setreg 3035h*4,reg3035r
|
||||
setreg 3036h*4,reg3036r
|
||||
setreg 3037h*4,reg3037r
|
||||
setreg 3038h*4,reg3038r
|
||||
setreg 3039h*4,reg3039r
|
||||
setreg 303Ah*4,reg303Ar
|
||||
setreg 303Bh*4,reg303Br
|
||||
setreg 303Ch*4,reg303Cr
|
||||
setreg 303Dh*4,reg303Dr
|
||||
setreg 303Eh*4,reg303Er
|
||||
setreg 303Fh*4,reg303Fr
|
||||
; set 3100-31FF to cacheregr
|
||||
mov edi,3100h*4
|
||||
add edi,[regptr]
|
||||
mov eax,cacheregr
|
||||
mov ecx,200h
|
||||
.loop
|
||||
mov [edi],eax
|
||||
add edi,4
|
||||
dec ecx
|
||||
jnz .loop
|
||||
ret
|
||||
|
||||
NEWSYM initsfxregsw
|
||||
setregw 3000h*4,reg3000w
|
||||
setregw 3001h*4,reg3001w
|
||||
setregw 3002h*4,reg3002w
|
||||
setregw 3003h*4,reg3003w
|
||||
setregw 3004h*4,reg3004w
|
||||
setregw 3005h*4,reg3005w
|
||||
setregw 3006h*4,reg3006w
|
||||
setregw 3007h*4,reg3007w
|
||||
setregw 3008h*4,reg3008w
|
||||
setregw 3009h*4,reg3009w
|
||||
setregw 300Ah*4,reg300Aw
|
||||
setregw 300Bh*4,reg300Bw
|
||||
setregw 300Ch*4,reg300Cw
|
||||
setregw 300Dh*4,reg300Dw
|
||||
setregw 300Eh*4,reg300Ew
|
||||
setregw 300Fh*4,reg300Fw
|
||||
setregw 3010h*4,reg3010w
|
||||
setregw 3011h*4,reg3011w
|
||||
setregw 3012h*4,reg3012w
|
||||
setregw 3013h*4,reg3013w
|
||||
setregw 3014h*4,reg3014w
|
||||
setregw 3015h*4,reg3015w
|
||||
setregw 3016h*4,reg3016w
|
||||
setregw 3017h*4,reg3017w
|
||||
setregw 3018h*4,reg3018w
|
||||
setregw 3019h*4,reg3019w
|
||||
setregw 301Ah*4,reg301Aw
|
||||
setregw 301Bh*4,reg301Bw
|
||||
setregw 301Ch*4,reg301Cw
|
||||
setregw 301Dh*4,reg301Dw
|
||||
setregw 301Eh*4,reg301Ew
|
||||
setregw 301Fh*4,reg301Fw
|
||||
setregw 3030h*4,reg3030w
|
||||
setregw 3031h*4,reg3031w
|
||||
setregw 3032h*4,reg3032w
|
||||
setregw 3033h*4,reg3033w
|
||||
setregw 3034h*4,reg3034w
|
||||
setregw 3035h*4,reg3035w
|
||||
setregw 3036h*4,reg3036w
|
||||
setregw 3037h*4,reg3037w
|
||||
setregw 3038h*4,reg3038w
|
||||
setregw 3039h*4,reg3039w
|
||||
setregw 303Ah*4,reg303Aw
|
||||
setregw 303Bh*4,reg303Bw
|
||||
setregw 303Ch*4,reg303Cw
|
||||
setregw 303Dh*4,reg303Dw
|
||||
setregw 303Eh*4,reg303Ew
|
||||
setregw 303Fh*4,reg303Fw
|
||||
; set 3100-31FF to cacheregw
|
||||
mov edi,3100h*4
|
||||
add edi,[regptw]
|
||||
mov eax,cacheregw
|
||||
mov ecx,200h
|
||||
.loop
|
||||
mov [edi],eax
|
||||
add edi,4
|
||||
dec ecx
|
||||
jnz .loop
|
||||
ret
|
||||
|
||||
NEWSYM cacheregr
|
||||
or byte[cachewarning],1
|
||||
ret
|
||||
|
||||
NEWSYM cacheregw
|
||||
or byte[cachewarning],2
|
||||
ret
|
||||
|
||||
NEWSYM cachewarning, db 0
|
||||
|
||||
; SFX Registers
|
||||
|
||||
NEWSYM reg3000r
|
||||
mov al,[SfxR0]
|
||||
ret
|
||||
NEWSYM reg3001r
|
||||
mov al,[SfxR0+1]
|
||||
ret
|
||||
NEWSYM reg3002r
|
||||
mov al,[SfxR1]
|
||||
ret
|
||||
NEWSYM reg3003r
|
||||
mov al,[SfxR1+1]
|
||||
ret
|
||||
NEWSYM reg3004r
|
||||
mov al,[SfxR2]
|
||||
ret
|
||||
NEWSYM reg3005r
|
||||
mov al,[SfxR2+1]
|
||||
ret
|
||||
NEWSYM reg3006r
|
||||
mov al,[SfxR3]
|
||||
ret
|
||||
NEWSYM reg3007r
|
||||
mov al,[SfxR3+1]
|
||||
ret
|
||||
NEWSYM reg3008r
|
||||
mov al,[SfxR4]
|
||||
ret
|
||||
NEWSYM reg3009r
|
||||
mov al,[SfxR4+1]
|
||||
ret
|
||||
NEWSYM reg300Ar
|
||||
mov al,[SfxR5]
|
||||
ret
|
||||
NEWSYM reg300Br
|
||||
mov al,[SfxR5+1]
|
||||
ret
|
||||
NEWSYM reg300Cr
|
||||
mov al,[SfxR6]
|
||||
ret
|
||||
NEWSYM reg300Dr
|
||||
mov al,[SfxR6+1]
|
||||
ret
|
||||
NEWSYM reg300Er
|
||||
mov al,[SfxR7]
|
||||
ret
|
||||
NEWSYM reg300Fr
|
||||
mov al,[SfxR7+1]
|
||||
ret
|
||||
NEWSYM reg3010r
|
||||
mov al,[SfxR8]
|
||||
ret
|
||||
NEWSYM reg3011r
|
||||
mov al,[SfxR8+1]
|
||||
ret
|
||||
NEWSYM reg3012r
|
||||
mov al,[SfxR9]
|
||||
ret
|
||||
NEWSYM reg3013r
|
||||
mov al,[SfxR9+1]
|
||||
ret
|
||||
NEWSYM reg3014r
|
||||
mov al,[SfxR10]
|
||||
ret
|
||||
NEWSYM reg3015r
|
||||
mov al,[SfxR10+1]
|
||||
ret
|
||||
NEWSYM reg3016r
|
||||
mov al,[SfxR11]
|
||||
ret
|
||||
NEWSYM reg3017r
|
||||
mov al,[SfxR11+1]
|
||||
ret
|
||||
NEWSYM reg3018r
|
||||
mov al,[SfxR12]
|
||||
ret
|
||||
NEWSYM reg3019r
|
||||
mov al,[SfxR12+1]
|
||||
ret
|
||||
NEWSYM reg301Ar
|
||||
mov al,[SfxR13]
|
||||
ret
|
||||
NEWSYM reg301Br
|
||||
mov al,[SfxR13+1]
|
||||
ret
|
||||
NEWSYM reg301Cr
|
||||
mov al,[SfxR14]
|
||||
ret
|
||||
NEWSYM reg301Dr
|
||||
mov al,[SfxR14+1]
|
||||
ret
|
||||
NEWSYM reg301Er
|
||||
mov al,[SfxR15]
|
||||
ret
|
||||
NEWSYM reg301Fr
|
||||
mov al,[SfxR15+1]
|
||||
ret
|
||||
|
||||
; Other SFX stuff
|
||||
|
||||
NEWSYM reg3030r
|
||||
AssembleSFXFlags
|
||||
mov al,[SfxSFR]
|
||||
ret
|
||||
NEWSYM reg3031r
|
||||
cmp byte[SfxAC],1
|
||||
je .alwaysclear
|
||||
cmp dword[ChangeOps],-350*240
|
||||
jl .noclear
|
||||
.alwaysclear
|
||||
and byte[SfxSFR+1],07fh ; clear IRQ flag
|
||||
jmp .cleared
|
||||
.noclear
|
||||
cmp dword[ChangeOps],-350*240*4
|
||||
jge .clear
|
||||
mov dword[ChangeOps],-350*240*4
|
||||
jmp .cleared
|
||||
.clear
|
||||
add dword[ChangeOps],350*240
|
||||
.cleared
|
||||
mov al,[SfxSFR+1]
|
||||
ret
|
||||
.test db 0
|
||||
NEWSYM reg3032r ; Unused
|
||||
xor al,al
|
||||
ret
|
||||
NEWSYM reg3033r ; BRAMR Backup Ram Read only on/off (bits 1-15 unused)
|
||||
mov al,[SfxBRAMR]
|
||||
ret
|
||||
NEWSYM reg3034r ; PBR (Program Bank)
|
||||
mov al,[SfxPBR]
|
||||
ret
|
||||
NEWSYM reg3035r ; Unused
|
||||
xor al,al
|
||||
ret
|
||||
NEWSYM reg3036r ; ROMBR (Gamepak Rom Bank Register)
|
||||
mov al,[SfxROMBR]
|
||||
ret
|
||||
NEWSYM reg3037r ; CFGR (Control Flags Register)
|
||||
mov al,[SfxCFGR]
|
||||
ret
|
||||
NEWSYM reg3038r ; SCBR (Screen Bank Register)
|
||||
mov al,[SfxSCBR]
|
||||
ret
|
||||
NEWSYM reg3039r ; CLSR (Clock Speed Register)
|
||||
mov al,[SfxCLSR]
|
||||
ret
|
||||
NEWSYM reg303Ar ; SCMR (Screen Mode Register)
|
||||
mov al,[SfxSCMR]
|
||||
test byte[SfxPOR],10h
|
||||
jnz .objmode
|
||||
mov al,[SfxSCMR]
|
||||
and al,00100100b ; 4 + 32
|
||||
cmp al,4
|
||||
je .lines160
|
||||
cmp al,32
|
||||
je .lines192
|
||||
cmp al,36
|
||||
je .objmode
|
||||
mov eax,[sfx128lineloc]
|
||||
jmp .donelines
|
||||
.lines160
|
||||
mov eax,[sfx160lineloc]
|
||||
jmp .donelines
|
||||
.lines192
|
||||
mov eax,[sfx192lineloc]
|
||||
jmp .donelines
|
||||
.objmode
|
||||
mov eax,[sfxobjlineloc]
|
||||
.donelines
|
||||
mov [sfxclineloc],eax
|
||||
ret
|
||||
NEWSYM reg303Br ; VCR (Version Code Register)
|
||||
mov al,20h
|
||||
ret
|
||||
NEWSYM reg303Cr ; RAMBR (Ram bank register)
|
||||
mov al,[SfxRAMBR]
|
||||
ret
|
||||
NEWSYM reg303Dr ; Unused
|
||||
xor al,al
|
||||
ret
|
||||
NEWSYM reg303Er ; CBR (Cache Base Register), lower byte
|
||||
mov al,[SfxCBR]
|
||||
ret
|
||||
NEWSYM reg303Fr ; CBR (Cache Base Register), upper byte
|
||||
mov al,[SfxCBR+1]
|
||||
ret
|
||||
|
||||
; SFX Write Registers
|
||||
|
||||
NEWSYM reg3000w
|
||||
mov [SfxR0],al
|
||||
ret
|
||||
NEWSYM reg3001w
|
||||
mov [SfxR0+1],al
|
||||
ret
|
||||
NEWSYM reg3002w
|
||||
mov [SfxR1],al
|
||||
ret
|
||||
NEWSYM reg3003w
|
||||
mov [SfxR1+1],al
|
||||
ret
|
||||
NEWSYM reg3004w
|
||||
mov [SfxR2],al
|
||||
ret
|
||||
NEWSYM reg3005w
|
||||
mov [SfxR2+1],al
|
||||
ret
|
||||
NEWSYM reg3006w
|
||||
mov [SfxR3],al
|
||||
ret
|
||||
NEWSYM reg3007w
|
||||
mov [SfxR3+1],al
|
||||
ret
|
||||
NEWSYM reg3008w
|
||||
mov [SfxR4],al
|
||||
ret
|
||||
NEWSYM reg3009w
|
||||
mov [SfxR4+1],al
|
||||
ret
|
||||
NEWSYM reg300Aw
|
||||
mov [SfxR5],al
|
||||
ret
|
||||
NEWSYM reg300Bw
|
||||
mov [SfxR5+1],al
|
||||
ret
|
||||
NEWSYM reg300Cw
|
||||
mov [SfxR6],al
|
||||
ret
|
||||
NEWSYM reg300Dw
|
||||
mov [SfxR6+1],al
|
||||
ret
|
||||
NEWSYM reg300Ew
|
||||
mov [SfxR7],al
|
||||
ret
|
||||
NEWSYM reg300Fw
|
||||
mov [SfxR7+1],al
|
||||
ret
|
||||
NEWSYM reg3010w
|
||||
mov [SfxR8],al
|
||||
ret
|
||||
NEWSYM reg3011w
|
||||
mov [SfxR8+1],al
|
||||
ret
|
||||
NEWSYM reg3012w
|
||||
mov [SfxR9],al
|
||||
ret
|
||||
NEWSYM reg3013w
|
||||
mov [SfxR9+1],al
|
||||
ret
|
||||
NEWSYM reg3014w
|
||||
mov [SfxR10],al
|
||||
ret
|
||||
NEWSYM reg3015w
|
||||
mov [SfxR10+1],al
|
||||
ret
|
||||
NEWSYM reg3016w
|
||||
mov [SfxR11],al
|
||||
ret
|
||||
NEWSYM reg3017w
|
||||
mov [SfxR11+1],al
|
||||
ret
|
||||
NEWSYM reg3018w
|
||||
mov [SfxR12],al
|
||||
ret
|
||||
NEWSYM reg3019w
|
||||
mov [SfxR12+1],al
|
||||
ret
|
||||
NEWSYM reg301Aw
|
||||
mov [SfxR13],al
|
||||
ret
|
||||
NEWSYM reg301Bw
|
||||
mov [SfxR13+1],al
|
||||
ret
|
||||
NEWSYM reg301Cw
|
||||
mov [SfxR14],al
|
||||
ret
|
||||
NEWSYM reg301Dw
|
||||
mov [SfxR14+1],al
|
||||
ret
|
||||
NEWSYM reg301Ew
|
||||
mov [SfxR15],al
|
||||
ret
|
||||
NEWSYM reg301Fw
|
||||
mov [SfxR15+1],al
|
||||
; start execution
|
||||
push edx
|
||||
mov edx,[SfxPBR]
|
||||
mov edx,[SfxMemTable+edx*4]
|
||||
add edx,[SfxR15]
|
||||
mov dl,[edx]
|
||||
mov [SfxPIPE],dl
|
||||
pop edx
|
||||
inc word[SfxR15]
|
||||
or byte[SfxSFR],20h
|
||||
or dword [SfxSFR],08000h ; Set IRQ Flag
|
||||
mov dword[SFXProc],1
|
||||
; call StartSFXret
|
||||
ret
|
||||
|
||||
; Other SFX stuff
|
||||
|
||||
NEWSYM reg3030w
|
||||
mov [SfxSFR],al
|
||||
; mov dh,10
|
||||
; Disassemble Flags
|
||||
test al,20h
|
||||
jz .noexec
|
||||
pushad
|
||||
mov dword [NumberOfOpcodes],100
|
||||
call StartSFX
|
||||
popad
|
||||
.noexec
|
||||
ret
|
||||
NEWSYM reg3031w
|
||||
mov [SfxSFR+1],al
|
||||
ret
|
||||
NEWSYM reg3032w ; Unused
|
||||
ret
|
||||
NEWSYM reg3033w ; BRAMR Backup Ram Read only on/off (bits 1-15 unused)
|
||||
and al,0FEh
|
||||
mov [SfxBRAMR],al
|
||||
ret
|
||||
NEWSYM reg3034w ; PBR (Program Bank)
|
||||
mov [SfxPBR],al
|
||||
xor ebx,ebx
|
||||
mov bl,al
|
||||
mov ebx,[SfxMemTable+ebx*4]
|
||||
mov [SfxCPB],ebx
|
||||
ret
|
||||
NEWSYM reg3035w ; Unused
|
||||
ret
|
||||
NEWSYM reg3036w ; ROMBR (Gamepak Rom Bank Register)
|
||||
mov [SfxROMBR],al
|
||||
xor ebx,ebx
|
||||
mov bl,al
|
||||
mov ebx,[SfxMemTable+ebx*4]
|
||||
mov [SfxCROM],ebx
|
||||
ret
|
||||
NEWSYM reg3037w ; CFGR (Control Flags Register)
|
||||
mov [SfxCFGR],al
|
||||
ret
|
||||
NEWSYM reg3038w ; SCBR (Screen Bank Register)
|
||||
mov [SfxSCBR],al
|
||||
call UpdateSCBRCOLR
|
||||
ret
|
||||
NEWSYM reg3039w ; CLSR (Clock Speed Register)
|
||||
and al,0FEh
|
||||
mov [SfxCLSR],al
|
||||
call UpdateCLSR
|
||||
ret
|
||||
NEWSYM reg303Aw ; SCMR (Screen Mode Register)
|
||||
mov [SfxSCMR],al
|
||||
call UpdatePORSCMR
|
||||
ret
|
||||
NEWSYM reg303Bw ; VCR (Version Code Register)
|
||||
ret
|
||||
NEWSYM reg303Cw ; RAMBR (Ram bank register)
|
||||
mov bl,[SfxnRamBanks]
|
||||
dec bl
|
||||
and al,bl
|
||||
mov ebx,[SfxnRamBanks]
|
||||
dec ebx
|
||||
and eax,ebx
|
||||
mov [SfxRAMBR],eax
|
||||
xor ebx,ebx
|
||||
mov bl,al
|
||||
shl ebx,16
|
||||
add ebx,[sfxramdata]
|
||||
mov dword [SfxRAMMem],ebx
|
||||
ret
|
||||
NEWSYM reg303Dw ; Unused
|
||||
ret
|
||||
NEWSYM reg303Ew ; CBR (Cache Base Register), lower byte
|
||||
mov [SfxCBR],al
|
||||
ret
|
||||
NEWSYM reg303Fw ; CBR (Cache Base Register), upper byte
|
||||
mov [SfxCBR+1],al
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankr8
|
||||
mov ebx,[sfxramdata]
|
||||
mov al,[ebx+ecx]
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankw8
|
||||
mov ebx,[sfxramdata]
|
||||
mov [ebx+ecx],al
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankr16
|
||||
mov ebx,[sfxramdata]
|
||||
mov ax,[ebx+ecx]
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankw16
|
||||
mov ebx,[sfxramdata]
|
||||
mov [ebx+ecx],ax
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankr8b
|
||||
mov ebx,[sfxramdata]
|
||||
mov al,[ebx+ecx+65536]
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankw8b
|
||||
mov ebx,[sfxramdata]
|
||||
mov [ebx+ecx+65536],al
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankr16b
|
||||
mov ebx,[sfxramdata]
|
||||
mov ax,[ebx+ecx+65536]
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankw16b
|
||||
mov ebx,[sfxramdata]
|
||||
mov [ebx+ecx+65536],ax
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankr8c
|
||||
mov ebx,[sfxramdata]
|
||||
mov al,[ebx+ecx+65536*2]
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankw8c
|
||||
mov ebx,[sfxramdata]
|
||||
mov [ebx+ecx+65536*2],al
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankr16c
|
||||
mov ebx,[sfxramdata]
|
||||
mov ax,[ebx+ecx+65536*2]
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankw16c
|
||||
mov ebx,[sfxramdata]
|
||||
mov [ebx+ecx+65536*2],ax
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankr8d
|
||||
mov ebx,[sfxramdata]
|
||||
mov al,[ebx+ecx+65536*3]
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankw8d
|
||||
mov ebx,[sfxramdata]
|
||||
mov [ebx+ecx+65536*3],al
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankr16d
|
||||
mov ebx,[sfxramdata]
|
||||
mov ax,[ebx+ecx+65536*3]
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
NEWSYM sfxaccessbankw16d
|
||||
mov ebx,[sfxramdata]
|
||||
mov [ebx+ecx+65536*3],ax
|
||||
xor ebx,ebx
|
||||
ret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user