⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsp1emu.c

📁 linux下的任天堂模拟器代码。供大家参考。
💻 C
📖 第 1 页 / 共 3 页
字号:
	matrixA[0][1] = -((Op01m * SinAz >> 15) * CosAy >> 15);	matrixA[0][2] = Op01m * SinAy >> 15;	matrixA[1][0] = ((Op01m * SinAz >> 15) * CosAx >> 15) + (((Op01m * CosAz >> 15) * SinAx >> 15) * SinAy >> 15);	matrixA[1][1] = ((Op01m * CosAz >> 15) * CosAx >> 15) - (((Op01m * SinAz >> 15) * SinAx >> 15) * SinAy >> 15);	matrixA[1][2] = -((Op01m * SinAx >> 15) * CosAy >> 15);	matrixA[2][0] = ((Op01m * SinAz >> 15) * SinAx >> 15) - (((Op01m * CosAz >> 15) * CosAx >> 15) * SinAy >> 15);	matrixA[2][1] = ((Op01m * CosAz >> 15) * SinAx >> 15) + (((Op01m * SinAz >> 15) * CosAx >> 15) * SinAy >> 15);	matrixA[2][2] = (Op01m * CosAx >> 15) * CosAy >> 15;}void DSPOp11(){	short SinAz = DSP1_Sin(Op11Zr);	short CosAz = DSP1_Cos(Op11Zr);	short SinAy = DSP1_Sin(Op11Yr);	short CosAy = DSP1_Cos(Op11Yr);	short SinAx = DSP1_Sin(Op11Xr);	short CosAx = DSP1_Cos(Op11Xr);	Op11m >>= 1;	matrixB[0][0] = (Op11m * CosAz >> 15) * CosAy >> 15;	matrixB[0][1] = -((Op11m * SinAz >> 15) * CosAy >> 15);	matrixB[0][2] = Op11m * SinAy >> 15;	matrixB[1][0] = ((Op11m * SinAz >> 15) * CosAx >> 15) + (((Op11m * CosAz >> 15) * SinAx >> 15) * SinAy >> 15);	matrixB[1][1] = ((Op11m * CosAz >> 15) * CosAx >> 15) - (((Op11m * SinAz >> 15) * SinAx >> 15) * SinAy >> 15);	matrixB[1][2] = -((Op11m * SinAx >> 15) * CosAy >> 15);	matrixB[2][0] = ((Op11m * SinAz >> 15) * SinAx >> 15) - (((Op11m * CosAz >> 15) * CosAx >> 15) * SinAy >> 15);	matrixB[2][1] = ((Op11m * CosAz >> 15) * SinAx >> 15) + (((Op11m * SinAz >> 15) * CosAx >> 15) * SinAy >> 15);	matrixB[2][2] = (Op11m * CosAx >> 15) * CosAy >> 15;}void DSPOp21(){	short SinAz = DSP1_Sin(Op21Zr);	short CosAz = DSP1_Cos(Op21Zr);	short SinAy = DSP1_Sin(Op21Yr);	short CosAy = DSP1_Cos(Op21Yr);	short SinAx = DSP1_Sin(Op21Xr);	short CosAx = DSP1_Cos(Op21Xr);	Op21m >>= 1;	matrixC[0][0] = (Op21m * CosAz >> 15) * CosAy >> 15;	matrixC[0][1] = -((Op21m * SinAz >> 15) * CosAy >> 15);	matrixC[0][2] = Op21m * SinAy >> 15;	matrixC[1][0] = ((Op21m * SinAz >> 15) * CosAx >> 15) + (((Op21m * CosAz >> 15) * SinAx >> 15) * SinAy >> 15);	matrixC[1][1] = ((Op21m * CosAz >> 15) * CosAx >> 15) - (((Op21m * SinAz >> 15) * SinAx >> 15) * SinAy >> 15);	matrixC[1][2] = -((Op21m * SinAx >> 15) * CosAy >> 15);	matrixC[2][0] = ((Op21m * SinAz >> 15) * SinAx >> 15) - (((Op21m * CosAz >> 15) * CosAx >> 15) * SinAy >> 15);	matrixC[2][1] = ((Op21m * CosAz >> 15) * SinAx >> 15) + (((Op21m * SinAz >> 15) * CosAx >> 15) * SinAy >> 15);	matrixC[2][2] = (Op21m * CosAx >> 15) * CosAy >> 15;}short Op0DX;short Op0DY;short Op0DZ;short Op0DF;short Op0DL;short Op0DU;short Op1DX;short Op1DY;short Op1DZ;short Op1DF;short Op1DL;short Op1DU;short Op2DX;short Op2DY;short Op2DZ;short Op2DF;short Op2DL;short Op2DU;void DSPOp0D(){    Op0DF = (Op0DX * matrixA[0][0] >> 15) + (Op0DY * matrixA[0][1] >> 15) + (Op0DZ * matrixA[0][2] >> 15);	Op0DL = (Op0DX * matrixA[1][0] >> 15) + (Op0DY * matrixA[1][1] >> 15) + (Op0DZ * matrixA[1][2] >> 15);	Op0DU = (Op0DX * matrixA[2][0] >> 15) + (Op0DY * matrixA[2][1] >> 15) + (Op0DZ * matrixA[2][2] >> 15);	#ifdef DebugDSP1		Log_Message("OP0D X: %d Y: %d Z: %d / F: %d L: %d U: %d",Op0DX,Op0DY,Op0DZ,Op0DF,Op0DL,Op0DU);	#endif}void DSPOp1D(){	Op1DF = (Op1DX * matrixB[0][0] >> 15) + (Op1DY * matrixB[0][1] >> 15) + (Op1DZ * matrixB[0][2] >> 15);	Op1DL = (Op1DX * matrixB[1][0] >> 15) + (Op1DY * matrixB[1][1] >> 15) + (Op1DZ * matrixB[1][2] >> 15);	Op1DU = (Op1DX * matrixB[2][0] >> 15) + (Op1DY * matrixB[2][1] >> 15) + (Op1DZ * matrixB[2][2] >> 15);	#ifdef DebugDSP1		Log_Message("OP1D X: %d Y: %d Z: %d / F: %d L: %d U: %d",Op1DX,Op1DY,Op1DZ,Op1DF,Op1DL,Op1DU);	#endif}void DSPOp2D(){	Op2DF = (Op2DX * matrixC[0][0] >> 15) + (Op2DY * matrixC[0][1] >> 15) + (Op2DZ * matrixC[0][2] >> 15);	Op2DL = (Op2DX * matrixC[1][0] >> 15) + (Op2DY * matrixC[1][1] >> 15) + (Op2DZ * matrixC[1][2] >> 15);	Op2DU = (Op2DX * matrixC[2][0] >> 15) + (Op2DY * matrixC[2][1] >> 15) + (Op2DZ * matrixC[2][2] >> 15);	#ifdef DebugDSP1		Log_Message("OP2D X: %d Y: %d Z: %d / F: %d L: %d U: %d",Op2DX,Op2DY,Op2DZ,Op2DF,Op2DL,Op2DU);	#endif}short Op03F;short Op03L;short Op03U;short Op03X;short Op03Y;short Op03Z;short Op13F;short Op13L;short Op13U;short Op13X;short Op13Y;short Op13Z;short Op23F;short Op23L;short Op23U;short Op23X;short Op23Y;short Op23Z;void DSPOp03(){	Op03X = (Op03F * matrixA[0][0] >> 15) + (Op03L * matrixA[1][0] >> 15) + (Op03U * matrixA[2][0] >> 15);	Op03Y = (Op03F * matrixA[0][1] >> 15) + (Op03L * matrixA[1][1] >> 15) + (Op03U * matrixA[2][1] >> 15);	Op03Z = (Op03F * matrixA[0][2] >> 15) + (Op03L * matrixA[1][2] >> 15) + (Op03U * matrixA[2][2] >> 15);	#ifdef DebugDSP1		Log_Message("OP03 F: %d L: %d U: %d / X: %d Y: %d Z: %d",Op03F,Op03L,Op03U,Op03X,Op03Y,Op03Z);	#endif}void DSPOp13(){	Op13X = (Op13F * matrixB[0][0] >> 15) + (Op13L * matrixB[1][0] >> 15) + (Op13U * matrixB[2][0] >> 15);	Op13Y = (Op13F * matrixB[0][1] >> 15) + (Op13L * matrixB[1][1] >> 15) + (Op13U * matrixB[2][1] >> 15);	Op13Z = (Op13F * matrixB[0][2] >> 15) + (Op13L * matrixB[1][2] >> 15) + (Op13U * matrixB[2][2] >> 15);	#ifdef DebugDSP1		Log_Message("OP13 F: %d L: %d U: %d / X: %d Y: %d Z: %d",Op13F,Op13L,Op13U,Op13X,Op13Y,Op13Z);	#endif}void DSPOp23(){	Op23X = (Op23F * matrixC[0][0] >> 15) + (Op23L * matrixC[1][0] >> 15) + (Op23U * matrixC[2][0] >> 15);	Op23Y = (Op23F * matrixC[0][1] >> 15) + (Op23L * matrixC[1][1] >> 15) + (Op23U * matrixC[2][1] >> 15);	Op23Z = (Op23F * matrixC[0][2] >> 15) + (Op23L * matrixC[1][2] >> 15) + (Op23U * matrixC[2][2] >> 15);	#ifdef DebugDSP1		Log_Message("OP23 F: %d L: %d U: %d / X: %d Y: %d Z: %d",Op23F,Op23L,Op23U,Op23X,Op23Y,Op23Z);	#endif}short Op14Zr;short Op14Xr;short Op14Yr;short Op14U;short Op14F;short Op14L;short Op14Zrr;short Op14Xrr;short Op14Yrr;void DSPOp14(){	short CSec, ESec, CTan, CSin, C, E;	DSP1_Inverse(DSP1_Cos(Op14Xr), 0, &CSec, &ESec);	// Rotation Around Z	DSP1_NormalizeDouble(Op14U * DSP1_Cos(Op14Yr) - Op14F * DSP1_Sin(Op14Yr), &C, &E);	E = ESec - E;	DSP1_Normalize(C * CSec >> 15, &C, &E);	Op14Zrr = Op14Zr + DSP1_Truncate(C, E);	// Rotation Around X	Op14Xrr = Op14Xr + (Op14U * DSP1_Sin(Op14Yr) >> 15) + (Op14F * DSP1_Cos(Op14Yr) >> 15);	// Rotation Around Y	DSP1_NormalizeDouble(Op14U * DSP1_Cos(Op14Yr) + Op14F * DSP1_Sin(Op14Yr), &C, &E);	E = ESec - E;	DSP1_Normalize(DSP1_Sin(Op14Xr), &CSin, &E);	CTan = CSec * CSin >> 15;	DSP1_Normalize(-(C * CTan >> 15), &C, &E);	Op14Yrr = Op14Yr + DSP1_Truncate(C, E) + Op14L;}void DSP1_Target(short H, short V, short *X, short *Y){	short C, E, C1, E1;	DSP1_Inverse((V * SinAzs >> 15) + VOffset, 8, &C, &E);	E += VPlane_E;	C1 = C * VPlane_C >> 15;	E1 = E + SecAZS_E1;	H <<= 8;	DSP1_Normalize(C1, &C, &E);	C = DSP1_Truncate(C, E) * H >> 15;	*X = CentreX + (C * CosAas >> 15);	*Y = CentreY - (C * SinAas >> 15);	V <<= 8;	DSP1_Normalize(C1 * SecAZS_C1 >> 15, &C, &E1);	C = DSP1_Truncate(C, E1) * V >> 15;	*X += C * -SinAas >> 15;	*Y += C * CosAas >> 15;}short Op0EH;short Op0EV;short Op0EX;short Op0EY;void DSPOp0E(){	DSP1_Target(Op0EH, Op0EV, &Op0EX, &Op0EY);}short Op0BX;short Op0BY;short Op0BZ;short Op0BS;short Op1BX;short Op1BY;short Op1BZ;short Op1BS;short Op2BX;short Op2BY;short Op2BZ;short Op2BS;void DSPOp0B(){    Op0BS = (Op0BX * matrixA[0][0] + Op0BY * matrixA[0][1] + Op0BZ * matrixA[0][2]) >> 15;	#ifdef DebugDSP1		Log_Message("OP0B");	#endif}void DSPOp1B(){    Op1BS = (Op1BX * matrixB[0][0] + Op1BY * matrixB[0][1] + Op1BZ * matrixB[0][2]) >> 15;	#ifdef DebugDSP1		Log_Message("OP1B X: %d Y: %d Z: %d S: %d",Op1BX,Op1BY,Op1BZ,Op1BS);		Log_Message("     MX: %d MY: %d MZ: %d Scale: %d",(short)(matrixB[0][0]*100),(short)(matrixB[0][1]*100),(short)(matrixB[0][2]*100),(short)(sc2*100));	#endif}void DSPOp2B(){    Op2BS = (Op2BX * matrixC[0][0] + Op2BY * matrixC[0][1] + Op2BZ * matrixC[0][2]) >> 15;	#ifdef DebugDSP1		Log_Message("OP2B");	#endif}short Op08X,Op08Y,Op08Z,Op08Ll,Op08Lh;void DSPOp08(){	int Op08Size = (Op08X * Op08X + Op08Y * Op08Y + Op08Z * Op08Z) << 1;	Op08Ll = Op08Size & 0xffff;	Op08Lh = (Op08Size >> 16) & 0xffff;	#ifdef DebugDSP1		Log_Message("OP08 %d,%d,%d",Op08X,Op08Y,Op08Z);		Log_Message("OP08 ((Op08X^2)+(Op08Y^2)+(Op08X^2))=%x",Op08Size );	#endif}short Op18X,Op18Y,Op18Z,Op18R,Op18D;void DSPOp18(){   Op18D = (Op18X * Op18X + Op18Y * Op18Y + Op18Z * Op18Z - Op18R * Op18R) >> 15;   #ifdef DebugDSP1      Log_Message("Op18 X: %d Y: %d Z: %d R: %D DIFF %d",Op18X,Op18Y,Op38Z,Op18D);   #endif}short Op38X,Op38Y,Op38Z,Op38R,Op38D;void DSPOp38(){   Op38D = (Op38X * Op38X + Op38Y * Op38Y + Op38Z * Op38Z - Op38R * Op38R) >> 15;   Op38D++;   #ifdef DebugDSP1      Log_Message("OP38 X: %d Y: %d Z: %d R: %D DIFF %d",Op38X,Op38Y,Op38Z,Op38D);   #endif}short Op28X;short Op28Y;short Op28Z;short Op28R;void DSPOp28(){	int Radius = Op28X * Op28X + Op28Y * Op28Y + Op28Z * Op28Z;	if (Radius == 0) Op28R = 0;	else	{		short C, E, Pos, Node1, Node2;		DSP1_NormalizeDouble(Radius, &C, &E);		if (E & 1) C = C * 0x4000 >> 15;		Pos = C * 0x0040 >> 15;		Node1 = DSP1ROM[0x00d5 + Pos];		Node2 = DSP1ROM[0x00d6 + Pos];		Op28R = ((Node2 - Node1) * (C & 0x1ff) >> 9) + Node1;		Op28R >>= (E >> 1);	}   #ifdef DebugDSP1      Log_Message("OP28 X:%d Y:%d Z:%d",Op28X,Op28Y,Op28Z);      Log_Message("OP28 Vector Length %d",Op28R);   #endif}short Op1CX,Op1CY,Op1CZ;short Op1CXBR,Op1CYBR,Op1CZBR,Op1CXAR,Op1CYAR,Op1CZAR;short Op1CX1;short Op1CY1;short Op1CZ1;short Op1CX2;short Op1CY2;short Op1CZ2;void DSPOp1C(){	// Rotate Around Op1CZ1	Op1CX1 = (Op1CYBR * DSP1_Sin(Op1CZ) >> 15) + (Op1CXBR * DSP1_Cos(Op1CZ) >> 15);	Op1CY1 = (Op1CYBR * DSP1_Cos(Op1CZ) >> 15) - (Op1CXBR * DSP1_Sin(Op1CZ) >> 15);	Op1CXBR = Op1CX1; Op1CYBR = Op1CY1;	// Rotate Around Op1CY1	Op1CZ1 = (Op1CXBR * DSP1_Sin(Op1CY) >> 15) + (Op1CZBR * DSP1_Cos(Op1CY) >> 15);	Op1CX1 = (Op1CXBR * DSP1_Cos(Op1CY) >> 15) - (Op1CZBR * DSP1_Sin(Op1CY) >> 15);	Op1CXAR = Op1CX1; Op1CZBR = Op1CZ1;	// Rotate Around Op1CX1	Op1CY1 = (Op1CZBR * DSP1_Sin(Op1CX) >> 15) + (Op1CYBR * DSP1_Cos(Op1CX) >> 15);	Op1CZ1 = (Op1CZBR * DSP1_Cos(Op1CX) >> 15) - (Op1CYBR * DSP1_Sin(Op1CX) >> 15);	Op1CYAR = Op1CY1; Op1CZAR = Op1CZ1;	#ifdef DebugDSP1		Log_Message("OP1C Apply Matrix CX:%d CY:%d CZ",Op1CXAR,Op1CYAR,Op1CZAR);	#endif}unsigned short Op0FRamsize;unsigned short Op0FPass;void DSPOp0F(){   Op0FPass = 0x0000;   #ifdef DebugDSP1      Log_Message("OP0F RAM Test Pass:%d", Op0FPass);   #endif}short Op2FUnknown;short Op2FSize;void DSPOp2F(){	Op2FSize=0x100;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -