2 Copyright (C) 2002 Rice1964
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 void RSP_GBI2_Vtx(Gfx *gfx)
25 uint32 addr = RSPSegmentAddr((gfx->gbi2vtx.addr));
26 int vend = gfx->gbi2vtx.vend/2;
27 int n = gfx->gbi2vtx.n;
30 LOG_UCODE(" Vtx: Address 0x%08x, vEnd: %d, v0: %d, Num: %d", addr, vend, v0, n);
34 DebuggerAppendMsg("Warning, attempting to load into invalid vertex positions, v0=%d, n=%d", v0, n);
38 if ((addr + (n*16)) > g_dwRamSize)
40 DebuggerAppendMsg("ProcessVertexData: Address out of range (0x%08x)", addr);
44 ProcessVertexData(addr, v0, n);
45 status.dwNumVertices += n;
46 DisplayVertexInfo(addr, v0, n);
50 void RSP_GBI2_EndDL(Gfx *gfx)
52 SP_Timing(RSP_GBI1_EndDL);
57 void RSP_GBI2_CullDL(Gfx *gfx)
59 SP_Timing(RSP_GBI1_CullDL);
62 if( !debuggerEnableCullFace )
64 return; //Disable Culling
67 if( g_curRomInfo.bDisableCulling )
69 return; //Disable Culling
72 uint32 dwVFirst = (((gfx->words.w0)) & 0xfff) / gRSP.vertexMult;
73 uint32 dwVLast = (((gfx->words.w1)) & 0xfff) / gRSP.vertexMult;
75 LOG_UCODE(" Culling using verts %d to %d", dwVFirst, dwVLast);
81 if( dwVLast < dwVFirst ) return;
82 if( !gRSP.bRejectVtx ) return;
84 for (uint32 i = dwVFirst; i <= dwVLast; i++)
86 //if (g_dwVtxFlags[i] == 0)
87 if (g_clipFlag[i] == 0)
89 LOG_UCODE(" Vertex %d is visible, returning", i);
94 status.dwNumDListsCulled++;
96 LOG_UCODE(" No vertices were visible, culling");
101 void RSP_GBI2_MoveWord(Gfx *gfx)
103 SP_Timing(RSP_GBI1_MoveWord);
105 switch (gfx->gbi2moveword.type)
107 case RSP_MOVE_WORD_MATRIX:
108 RSP_RDP_InsertMatrix(gfx);
110 case RSP_MOVE_WORD_NUMLIGHT:
112 uint32 dwNumLights = gfx->gbi2moveword.value/24;
113 gRSP.ambientLightIndex = dwNumLights;
114 SetNumLights(dwNumLights);
118 case RSP_MOVE_WORD_CLIP:
120 switch (gfx->gbi2moveword.offset)
122 case RSP_MV_WORD_OFFSET_CLIP_RNX:
123 case RSP_MV_WORD_OFFSET_CLIP_RNY:
124 case RSP_MV_WORD_OFFSET_CLIP_RPX:
125 case RSP_MV_WORD_OFFSET_CLIP_RPY:
126 CRender::g_pRender->SetClipRatio(gfx->gbi2moveword.offset, gfx->gbi2moveword.value);
128 LOG_UCODE(" RSP_MOVE_WORD_CLIP ? : 0x%08x", gfx->words.w1);
134 case RSP_MOVE_WORD_SEGMENT:
136 uint32 dwSeg = gfx->gbi2moveword.offset / 4;
137 uint32 dwAddr = gfx->gbi2moveword.value & 0x00FFFFFF; // Hack - convert to physical
139 LOG_UCODE(" RSP_MOVE_WORD_SEGMENT Segment[%d] = 0x%08x", dwSeg, dwAddr);
140 if( dwAddr > g_dwRamSize )
142 gRSP.segments[dwSeg] = dwAddr;
145 DebuggerAppendMsg("warning: Segment %d addr is %8X", dwSeg, dwAddr);
150 gRSP.segments[dwSeg] = dwAddr;
154 case RSP_MOVE_WORD_FOG:
156 uint16 wMult = (uint16)((gfx->gbi2moveword.value >> 16) & 0xFFFF);
157 uint16 wOff = (uint16)((gfx->gbi2moveword.value ) & 0xFFFF);
159 float fMult = (float)(short)wMult;
160 float fOff = (float)(short)wOff;
162 float rng = 128000.0f / fMult;
163 float fMin = 500.0f - (fOff*rng/256.0f);
164 float fMax = rng + fMin;
166 FOG_DUMP(TRACE4("Set Fog: Min=%f, Max=%f, Mul=%f, Off=%f", fMin, fMax, fMult, fOff));
167 //if( fMult <= 0 || fMin > fMax || fMax < 0 || fMin > 1000 )
168 if( fMult <= 0 || fMax < 0 )
177 SetFogMinMax(fMin, fMax, fMult, fOff);
178 FOG_DUMP(TRACE3("Set Fog: Min=%f, Max=%f, Data=0x%08X", fMin, fMax, gfx->gbi2moveword.value));
181 case RSP_MOVE_WORD_LIGHTCOL:
183 uint32 dwLight = gfx->gbi2moveword.offset / 0x18;
184 uint32 dwField = (gfx->gbi2moveword.offset & 0x7);
189 if (dwLight == gRSP.ambientLightIndex)
191 SetAmbientLight( (gfx->gbi2moveword.value>>8) );
195 SetLightCol(dwLight, gfx->gbi2moveword.value);
203 DebuggerAppendMsg("RSP_MOVE_WORD_LIGHTCOL with unknown offset 0x%08x", dwField);
211 case RSP_MOVE_WORD_PERSPNORM:
212 LOG_UCODE(" RSP_MOVE_WORD_PERSPNORM 0x%04x", (short)gfx->words.w1);
215 case RSP_MOVE_WORD_POINTS:
216 LOG_UCODE(" 2nd cmd of Force Matrix");
221 LOG_UCODE(" Ignored!!");
228 void RSP_GBI2_Tri1(Gfx *gfx)
230 if( gfx->words.w0 == 0x05000017 && gfx->gbi2tri1.flag == 0x80 )
232 // The ObjLoadTxtr / Tlut cmd for Evangelion.v64
233 RSP_S2DEX_SPObjLoadTxtr(gfx);
234 DebuggerAppendMsg("Fix me, SPObjLoadTxtr as RSP_GBI2_Tri2");
238 status.primitiveType = PRIM_TRI1;
239 bool bTrisAdded = false;
240 bool bTexturesAreEnabled = CRender::g_pRender->IsTextureEnabled();
242 // While the next command pair is Tri1, add vertices
243 uint32 dwPC = gDlistStack[gDlistStackPointer].pc;
244 //uint32 * pCmdBase = (uint32 *)(g_pRDRAMu8 + dwPC);
248 uint32 dwV2 = gfx->gbi2tri1.v2/gRSP.vertexMult;
249 uint32 dwV1 = gfx->gbi2tri1.v1/gRSP.vertexMult;
250 uint32 dwV0 = gfx->gbi2tri1.v0/gRSP.vertexMult;
252 if (IsTriangleVisible(dwV0, dwV1, dwV2))
254 DEBUG_DUMP_VERTEXES("ZeldaTri1", dwV0, dwV1, dwV2);
255 LOG_UCODE(" ZeldaTri1: 0x%08x 0x%08x %d,%d,%d", gfx->words.w0, gfx->words.w1, dwV0, dwV1, dwV2);
258 if( bTexturesAreEnabled )
261 InitVertexTextureConstants();
264 CRender::g_pRender->SetCombinerAndBlender();
267 PrepareTriangle(dwV0, dwV1, dwV2);
274 } while (!(pauseAtNext && eventToPause==NEXT_TRIANGLE) && gfx->words.cmd == (uint8)RSP_ZELDATRI1);
276 } while( gfx->words.cmd == (uint8)RSP_ZELDATRI1);
279 gDlistStack[gDlistStackPointer].pc = dwPC-8;
283 CRender::g_pRender->DrawTriangles();
286 DEBUG_TRIANGLE(TRACE0("Pause at GBI2 TRI1"));
290 void RSP_GBI2_Tri2(Gfx *gfx)
292 if( gfx->words.w0 == 0x0600002f && gfx->gbi2tri2.flag == 0x80 )
294 // The ObjTxSprite cmd for Evangelion.v64
295 RSP_S2DEX_SPObjLoadTxSprite(gfx);
296 DebuggerAppendMsg("Fix me, SPObjLoadTxSprite as RSP_GBI2_Tri2");
300 status.primitiveType = PRIM_TRI2;
301 BOOL bTrisAdded = FALSE;
303 // While the next command pair is Tri2, add vertices
304 uint32 dwPC = gDlistStack[gDlistStackPointer].pc;
305 bool bTexturesAreEnabled = CRender::g_pRender->IsTextureEnabled();
308 uint32 dwV2 = gfx->gbi2tri2.v2;
309 uint32 dwV1 = gfx->gbi2tri2.v1;
310 uint32 dwV0 = gfx->gbi2tri2.v0;
312 uint32 dwV5 = gfx->gbi2tri2.v5;
313 uint32 dwV4 = gfx->gbi2tri2.v4;
314 uint32 dwV3 = gfx->gbi2tri2.v3;
316 LOG_UCODE(" ZeldaTri2: 0x%08x 0x%08x", gfx->words.w0, gfx->words.w1);
317 LOG_UCODE(" V0: %d, V1: %d, V2: %d", dwV0, dwV1, dwV2);
318 LOG_UCODE(" V3: %d, V4: %d, V5: %d", dwV3, dwV4, dwV5);
321 if (IsTriangleVisible(dwV0, dwV1, dwV2))
323 DEBUG_DUMP_VERTEXES("ZeldaTri2 1/2", dwV0, dwV1, dwV2);
326 if( bTexturesAreEnabled )
329 InitVertexTextureConstants();
332 CRender::g_pRender->SetCombinerAndBlender();
336 PrepareTriangle(dwV0, dwV1, dwV2);
340 if (IsTriangleVisible(dwV3, dwV4, dwV5))
342 DEBUG_DUMP_VERTEXES("ZeldaTri2 2/2", dwV3, dwV4, dwV5);
345 if( bTexturesAreEnabled )
348 InitVertexTextureConstants();
351 CRender::g_pRender->SetCombinerAndBlender();
355 PrepareTriangle(dwV3, dwV4, dwV5);
362 } while (!(pauseAtNext && eventToPause==NEXT_TRIANGLE) && gfx->words.cmd == (uint8)RSP_ZELDATRI2);
364 } while ( gfx->words.cmd == (uint8)RSP_ZELDATRI2 );//&& status.dwNumTrisRendered < 50);
368 gDlistStack[gDlistStackPointer].pc = dwPC-8;
372 CRender::g_pRender->DrawTriangles();
375 DEBUG_TRIANGLE(TRACE0("Pause at GBI2 TRI2"));
379 void RSP_GBI2_Line3D(Gfx *gfx)
381 if( gfx->words.w0 == 0x0700002f && (gfx->words.w1>>24) == 0x80 )
383 // The ObjTxSprite cmd for Evangelion.v64
384 RSP_S2DEX_SPObjLoadTxRect(gfx);
388 status.primitiveType = PRIM_TRI3;
390 uint32 dwPC = gDlistStack[gDlistStackPointer].pc;
392 BOOL bTrisAdded = FALSE;
395 uint32 dwV0 = gfx->gbi2line3d.v0/gRSP.vertexMult;
396 uint32 dwV1 = gfx->gbi2line3d.v1/gRSP.vertexMult;
397 uint32 dwV2 = gfx->gbi2line3d.v2/gRSP.vertexMult;
399 uint32 dwV3 = gfx->gbi2line3d.v3/gRSP.vertexMult;
400 uint32 dwV4 = gfx->gbi2line3d.v4/gRSP.vertexMult;
401 uint32 dwV5 = gfx->gbi2line3d.v5/gRSP.vertexMult;
403 LOG_UCODE(" ZeldaTri3: 0x%08x 0x%08x", gfx->words.w0, gfx->words.w1);
404 LOG_UCODE(" V0: %d, V1: %d, V2: %d", dwV0, dwV1, dwV2);
405 LOG_UCODE(" V3: %d, V4: %d, V5: %d", dwV3, dwV4, dwV5);
408 if (IsTriangleVisible(dwV0, dwV1, dwV2))
410 DEBUG_DUMP_VERTEXES("ZeldaTri3 1/2", dwV0, dwV1, dwV2);
411 if (!bTrisAdded && CRender::g_pRender->IsTextureEnabled())
414 InitVertexTextureConstants();
419 CRender::g_pRender->SetCombinerAndBlender();
423 PrepareTriangle(dwV0, dwV1, dwV2);
427 if (IsTriangleVisible(dwV3, dwV4, dwV5))
429 DEBUG_DUMP_VERTEXES("ZeldaTri3 2/2", dwV3, dwV4, dwV5);
430 if (!bTrisAdded && CRender::g_pRender->IsTextureEnabled())
433 InitVertexTextureConstants();
438 CRender::g_pRender->SetCombinerAndBlender();
442 PrepareTriangle(dwV3, dwV4, dwV5);
449 } while (!(pauseAtNext && eventToPause==NEXT_TRIANGLE) && gfx->words.cmd == (uint8)RSP_LINE3D);
451 } while ( gfx->words.cmd == (uint8)RSP_LINE3D);
454 gDlistStack[gDlistStackPointer].pc = dwPC-8;
459 CRender::g_pRender->DrawTriangles();
462 DEBUG_TRIANGLE(TRACE0("Pause at GBI2 Line3D"));
466 void RSP_GBI2_Texture(Gfx *gfx)
468 SP_Timing(RSP_GBI1_Texture);
470 float fTextureScaleS = (float)(gfx->texture.scaleS) / (65536.0f * 32.0f);
471 float fTextureScaleT = (float)(gfx->texture.scaleT) / (65536.0f * 32.0f);
473 if( (((gfx->words.w1)>>16)&0xFFFF) == 0xFFFF )
475 fTextureScaleS = 1/32.0f;
477 else if( (((gfx->words.w1)>>16)&0xFFFF) == 0x8000 )
479 fTextureScaleS = 1/64.0f;
481 if( (((gfx->words.w1) )&0xFFFF) == 0xFFFF )
483 fTextureScaleT = 1/32.0f;
485 else if( (((gfx->words.w1) )&0xFFFF) == 0x8000 )
487 fTextureScaleT = 1/64.0f;
490 CRender::g_pRender->SetTextureEnableAndScale(gfx->texture.tile, gfx->texture.enable_gbi2, fTextureScaleS, fTextureScaleT);
493 if( g_curRomInfo.bTextureScaleHack )
495 // Hack, need to verify, refer to N64 programming manual
496 // that if scale = 0.5 (1/64), vtx s,t are also doubled
498 if( ((word1>>16)&0xFFFF) == 0x8000 )
500 fTextureScaleS = 1/128.0f;
501 if( ((word1)&0xFFFF) == 0xFFFF )
503 fTextureScaleT = 1/64.0f;
507 if( ((word1 )&0xFFFF) == 0x8000 )
509 fTextureScaleT = 1/128.0f;
510 if( ((word1>>16)&0xFFFF) == 0xFFFF )
512 fTextureScaleS = 1/64.0f;
518 CRender::g_pRender->SetTextureEnableAndScale(gfx->texture.tile, gfx->texture.enable_gbi2, fTextureScaleS, fTextureScaleT);
522 DebuggerAppendMsg("SetTexture: Level: %d Tile: %d %s\n", gfx->texture.level, gfx->texture.tile, gfx->texture.enable_gbi2 ? "enabled":"disabled");
523 DebuggerAppendMsg(" ScaleS: %f, ScaleT: %f\n", fTextureScaleS*32.0f, fTextureScaleT*32.0f);
526 DEBUGGER_PAUSE_COUNT_N(NEXT_SET_TEXTURE);
528 LOG_UCODE(" Level: %d Tile: %d %s", gfx->texture.level, gfx->texture.tile, gfx->texture.enable_gbi2 ? "enabled":"disabled");
529 LOG_UCODE(" ScaleS: %f, ScaleT: %f", fTextureScaleS*32.0f, fTextureScaleT*32.0f);
534 void RSP_GBI2_PopMtx(Gfx *gfx)
536 SP_Timing(RSP_GBI1_PopMtx);
538 uint8 nCommand = (uint8)(gfx->words.w0 & 0xFF);
540 LOG_UCODE(" PopMtx: 0x%02x (%s)",
542 (nCommand & RSP_ZELDA_MTX_PROJECTION) ? "Projection" : "ModelView");
545 /* if (nCommand & RSP_ZELDA_MTX_PROJECTION)
547 CRender::g_pRender->PopProjection();
551 CRender::g_pRender->PopWorldView();
554 if( pauseAtNext && eventToPause == NEXT_MATRIX_CMD )
557 debuggerPause = true;
558 TRACE0("Pause after Pop GBI2_PopMtx:");
562 if( pauseAtNext && logMatrix )
564 TRACE0("Pause after Pop GBI2_PopMtx:");
572 #define RSP_ZELDA_ZBUFFER 0x00000001 // Guess
573 #define RSP_ZELDA_CULL_BACK 0x00000200
574 #define RSP_ZELDA_CULL_FRONT 0x00000400
575 #define RSP_ZELDA_FOG 0x00010000
576 #define RSP_ZELDA_LIGHTING 0x00020000
577 #define RSP_ZELDA_TEXTURE_GEN 0x00040000
578 #define RSP_ZELDA_TEXTURE_GEN_LINEAR 0x00080000
579 #define RSP_ZELDA_SHADING_SMOOTH 0x00200000
581 void RSP_GBI2_GeometryMode(Gfx *gfx)
583 SP_Timing(RSP_GBI2_GeometryMode);
585 uint32 dwAnd = ((gfx->words.w0)) & 0x00FFFFFF;
586 uint32 dwOr = ((gfx->words.w1)) & 0x00FFFFFF;
589 LOG_UCODE(" 0x%08x 0x%08x =(x & 0x%08x) | 0x%08x", gfx->words.w0, gfx->words.w1, dwAnd, dwOr);
591 if ((~dwAnd) & RSP_ZELDA_ZBUFFER) LOG_UCODE(" Disabling ZBuffer");
592 //if ((~dwAnd) & RSP_ZELDA_TEXTURE_ENABLE) LOG_UCODE(" Disabling Texture");
593 //if ((~dwAnd) & RSP_ZELDA_SHADE) LOG_UCODE(" Disabling Shade");
594 if ((~dwAnd) & RSP_ZELDA_SHADING_SMOOTH) LOG_UCODE(" Disabling Flat Shading");
595 if ((~dwAnd) & RSP_ZELDA_CULL_FRONT) LOG_UCODE(" Disabling Front Culling");
596 if ((~dwAnd) & RSP_ZELDA_CULL_BACK) LOG_UCODE(" Disabling Back Culling");
597 if ((~dwAnd) & RSP_ZELDA_FOG) LOG_UCODE(" Disabling Fog");
598 if ((~dwAnd) & RSP_ZELDA_LIGHTING) LOG_UCODE(" Disabling Lighting");
599 if ((~dwAnd) & RSP_ZELDA_TEXTURE_GEN) LOG_UCODE(" Disabling Texture Gen");
600 if ((~dwAnd) & RSP_ZELDA_TEXTURE_GEN_LINEAR) LOG_UCODE(" Disabling Texture Gen Linear");
601 // if ((~dwAnd) & RSP_ZELDA_LOD) LOG_UCODE(" Disabling LOD (no impl)");
603 if (dwOr & RSP_ZELDA_ZBUFFER) LOG_UCODE(" Enabling ZBuffer");
604 //if (dwOr & RSP_ZELDA_TEXTURE_ENABLE) LOG_UCODE(" Enabling Texture");
605 //if (dwOr & RSP_ZELDA_SHADE) LOG_UCODE(" Enabling Shade");
606 if (dwOr & RSP_ZELDA_SHADING_SMOOTH) LOG_UCODE(" Enabling Flat Shading");
607 if (dwOr & RSP_ZELDA_CULL_FRONT) LOG_UCODE(" Enabling Front Culling");
608 if (dwOr & RSP_ZELDA_CULL_BACK) LOG_UCODE(" Enabling Back Culling");
609 if (dwOr & RSP_ZELDA_FOG) LOG_UCODE(" Enabling Fog");
610 if (dwOr & RSP_ZELDA_LIGHTING) LOG_UCODE(" Enabling Lighting");
611 if (dwOr & RSP_ZELDA_TEXTURE_GEN) LOG_UCODE(" Enabling Texture Gen");
612 if (dwOr & RSP_ZELDA_TEXTURE_GEN_LINEAR) LOG_UCODE(" Enabling Texture Gen Linear");
613 ///if (dwOr & RSP_ZELDA_LOD) LOG_UCODE(" Enabling LOD (no impl)");
616 gRDP.geometryMode &= dwAnd;
617 gRDP.geometryMode |= dwOr;
620 bool bCullFront = (gRDP.geometryMode & RSP_ZELDA_CULL_FRONT) ? true : false;
621 bool bCullBack = (gRDP.geometryMode & RSP_ZELDA_CULL_BACK) ? true : false;
623 //BOOL bShade = (gRDP.geometryMode & G_SHADE) ? TRUE : FALSE;
624 //BOOL bFlatShade = (gRDP.geometryMode & RSP_ZELDA_SHADING_SMOOTH) ? TRUE : FALSE;
625 BOOL bFlatShade = (gRDP.geometryMode & RSP_ZELDA_TEXTURE_GEN_LINEAR) ? TRUE : FALSE;
626 if( options.enableHackForGames == HACK_FOR_TIGER_HONEY_HUNT )
629 bool bFog = (gRDP.geometryMode & RSP_ZELDA_FOG) ? true : false;
630 bool bTextureGen = (gRDP.geometryMode & RSP_ZELDA_TEXTURE_GEN) ? true : false;
632 bool bLighting = (gRDP.geometryMode & RSP_ZELDA_LIGHTING) ? true : false;
633 BOOL bZBuffer = (gRDP.geometryMode & RSP_ZELDA_ZBUFFER) ? TRUE : FALSE;
635 CRender::g_pRender->SetCullMode(bCullFront, bCullBack);
637 //if (bFlatShade||!bShade) CRender::g_pRender->SetShadeMode( SHADE_FLAT );
638 if (bFlatShade) CRender::g_pRender->SetShadeMode( SHADE_FLAT );
639 else CRender::g_pRender->SetShadeMode( SHADE_SMOOTH );
641 SetTextureGen(bTextureGen);
643 SetLighting( bLighting );
644 CRender::g_pRender->ZBufferEnable( bZBuffer );
645 CRender::g_pRender->SetFogEnable( bFog );
650 extern uint32 dwConkerVtxZAddr;
652 void RSP_GBI2_Mtx(Gfx *gfx)
654 SP_Timing(RSP_GBI0_Mtx);
655 dwConkerVtxZAddr = 0; // For Conker BFD
657 uint32 addr = RSPSegmentAddr((gfx->gbi2matrix.addr));
659 if( gfx->gbi2matrix.param == 0 && gfx->gbi2matrix.len == 0 )
661 DLParser_Bomberman2TextRect(gfx);
665 LOG_UCODE(" Mtx: %s %s %s Length %d Address 0x%08x",
666 gfx->gbi2matrix.projection ? "Projection" : "ModelView",
667 gfx->gbi2matrix.load ? "Load" : "Mul",
668 gfx->gbi2matrix.nopush==0 ? "Push" : "No Push",
669 gfx->gbi2matrix.len, addr);
671 if (addr + 64 > g_dwRamSize)
673 DebuggerAppendMsg("ZeldaMtx: Address invalid (0x%08x)", addr);
679 if (gfx->gbi2matrix.projection)
681 // So far only Extreme-G seems to Push/Pop projection matrices
682 CRender::g_pRender->SetProjection(matToLoad, gfx->gbi2matrix.nopush==0, gfx->gbi2matrix.load);
686 CRender::g_pRender->SetWorldView(matToLoad, gfx->gbi2matrix.nopush==0, gfx->gbi2matrix.load);
688 if( options.enableHackForGames == HACK_FOR_SOUTH_PARK_RALLY )
691 if( dlistMtxCount == 2 )
693 CRender::g_pRender->ClearZBuffer(1.0f);
699 const char *loadstr = gfx->gbi2matrix.load?"Load":"Mul";
700 const char *pushstr = gfx->gbi2matrix.nopush==0?"Push":"Nopush";
701 int projlevel = CRender::g_pRender->GetProjectMatrixLevel();
702 int worldlevel = CRender::g_pRender->GetWorldViewMatrixLevel();
703 if( pauseAtNext && eventToPause == NEXT_MATRIX_CMD )
706 debuggerPause = true;
707 if (gfx->gbi2matrix.projection)
709 DebuggerAppendMsg("Pause after %s and %s Matrix: Projection, level=%d\n", loadstr, pushstr, projlevel );
713 DebuggerAppendMsg("Pause after %s and %s Matrix: WorldView level=%d\n", loadstr, pushstr, worldlevel);
718 if( pauseAtNext && logMatrix )
720 if (gfx->gbi2matrix.projection)
722 DebuggerAppendMsg("Matrix: %s and %s Projection level=%d\n", loadstr, pushstr, projlevel);
726 DebuggerAppendMsg("Matrix: %s and %s WorldView\n level=%d", loadstr, pushstr, worldlevel);
733 void RSP_GBI2_MoveMem(Gfx *gfx)
735 SP_Timing(RSP_GBI1_MoveMem);
737 uint32 addr = RSPSegmentAddr((gfx->words.w1));
738 uint32 type = ((gfx->words.w0) ) & 0xFE;
740 //uint32 dwLen = ((gfx->words.w0) >> 16) & 0xFF;
741 //uint32 dwOffset = ((gfx->words.w0) >> 8) & 0xFFFF;
745 case RSP_GBI2_MV_MEM__VIEWPORT:
747 RSP_MoveMemViewport(addr);
750 case RSP_GBI2_MV_MEM__LIGHT:
752 uint32 dwOffset2 = ((gfx->words.w0) >> 5) & 0x3FFF;
757 s8 * pcBase = g_pRDRAMs8 + addr;
758 LOG_UCODE(" RSP_GBI1_MV_MEM_LOOKATX %f %f %f",
759 (float)pcBase[8 ^ 0x3],
760 (float)pcBase[9 ^ 0x3],
761 (float)pcBase[10 ^ 0x3]);
767 s8 * pcBase = g_pRDRAMs8 + addr;
768 LOG_UCODE(" RSP_GBI1_MV_MEM_LOOKATY %f %f %f",
769 (float)pcBase[8 ^ 0x3],
770 (float)pcBase[9 ^ 0x3],
771 (float)pcBase[10 ^ 0x3]);
774 default: //0x30/48/60
776 uint32 dwLight = (dwOffset2 - 0x30)/0x18;
777 LOG_UCODE(" Light %d:", dwLight);
778 RSP_MoveMemLight(dwLight, addr);
785 case RSP_GBI2_MV_MEM__MATRIX:
786 LOG_UCODE("Force Matrix: addr=%08X", addr);
787 RSP_GFX_Force_Matrix(addr);
789 case RSP_GBI2_MV_MEM_O_L0:
790 case RSP_GBI2_MV_MEM_O_L1:
791 case RSP_GBI2_MV_MEM_O_L2:
792 case RSP_GBI2_MV_MEM_O_L3:
793 case RSP_GBI2_MV_MEM_O_L4:
794 case RSP_GBI2_MV_MEM_O_L5:
795 case RSP_GBI2_MV_MEM_O_L6:
796 case RSP_GBI2_MV_MEM_O_L7:
797 LOG_UCODE("Zelda Move Light");
798 RDP_NOIMPL_WARN("Zelda Move Light");
801 case RSP_GBI2_MV_MEM__POINT:
802 LOG_UCODE("Zelda Move Point");
803 void RDP_NOIMPL_WARN(const char* op);
804 RDP_NOIMPL_WARN("Zelda Move Point");
807 case RSP_GBI2_MV_MEM_O_LOOKATX:
808 if( (gfx->words.w0) == 0xDC170000 && ((gfx->words.w1)&0xFF000000) == 0x80000000 )
810 // Ucode for Evangelion.v64, the ObjMatrix cmd
811 RSP_S2DEX_OBJ_MOVEMEM(gfx);
814 case RSP_GBI2_MV_MEM_O_LOOKATY:
815 RSP_RDP_NOIMPL("Not implemented ZeldaMoveMem LOOKATY, Cmd0=0x%08X, Cmd1=0x%08X", gfx->words.w0, gfx->words.w1);
818 if( (gfx->words.w0) == 0xDC070002 && ((gfx->words.w1)&0xFF000000) == 0x80000000 )
820 RSP_S2DEX_OBJ_MOVEMEM(gfx);
824 LOG_UCODE("ZeldaMoveMem Type: Unknown");
825 RSP_RDP_NOIMPL("Unknown ZeldaMoveMem Type, type=0x%X, Addr=%08X", type, addr);
832 void RSP_GBI2_DL(Gfx *gfx)
834 SP_Timing(RSP_GBI0_DL);
836 uint32 dwPush = ((gfx->words.w0) >> 16) & 0xFF;
837 uint32 dwAddr = RSPSegmentAddr((gfx->words.w1));
839 if( dwAddr > g_dwRamSize )
841 RSP_RDP_NOIMPL("Error: DL addr = %08X out of range, PC=%08X", dwAddr, gDlistStack[gDlistStackPointer].pc );
842 dwAddr &= (g_dwRamSize-1);
843 DebuggerPauseCountN( NEXT_DLIST );
846 LOG_UCODE(" DL: Push:0x%02x Addr: 0x%08x", dwPush, dwAddr);
851 LOG_UCODE(" Pushing ZeldaDisplayList 0x%08x", dwAddr);
852 gDlistStackPointer++;
853 gDlistStack[gDlistStackPointer].pc = dwAddr;
854 gDlistStack[gDlistStackPointer].countdown = MAX_DL_COUNT;
857 case RSP_DLIST_NOPUSH:
858 LOG_UCODE(" Jumping to ZeldaDisplayList 0x%08x", dwAddr);
859 if( gDlistStack[gDlistStackPointer].pc == dwAddr+8 ) //Is this a loop
861 //Hack for Gauntlet Legends
862 gDlistStack[gDlistStackPointer].pc = dwAddr+8;
865 gDlistStack[gDlistStackPointer].pc = dwAddr;
866 gDlistStack[gDlistStackPointer].countdown = MAX_DL_COUNT;
871 LOG_UCODE("\\/ \\/ \\/ \\/ \\/ \\/ \\/ \\/ \\/ \\/ \\/ \\/ \\/ \\/ \\/");
872 LOG_UCODE("#############################################");
876 void RSP_GBI2_SetOtherModeL(Gfx *gfx)
878 SP_Timing(RSP_GBI1_SetOtherModeL);
880 uint32 dwShift = ((gfx->words.w0)>>8)&0xFF;
881 uint32 dwLength= ((gfx->words.w0) )&0xFF;
882 uint32 dwData = (gfx->words.w1);
884 // Mask is constructed slightly differently
885 uint32 dwMask = (uint32)((s32)(0x80000000)>>dwLength)>>dwShift;
888 uint32 modeL = gRDP.otherModeL;
889 modeL = (modeL&(~dwMask)) | dwData;
892 tempgfx.words.w0 = gRDP.otherModeH;
893 tempgfx.words.w1 = modeL;
894 DLParser_RDPSetOtherMode(&tempgfx );
898 void RSP_GBI2_SetOtherModeH(Gfx *gfx)
900 SP_Timing(RSP_GBI1_SetOtherModeH);
902 uint32 dwLength= (((gfx->words.w0))&0xFF)+1;
903 uint32 dwShift = 32 - (((gfx->words.w0)>>8)&0xFF) - dwLength;
904 uint32 dwData = (gfx->words.w1);
906 uint32 dwMask2 = ((1<<dwLength)-1)<<dwShift;
907 uint32 dwModeH = gRDP.otherModeH;
908 dwModeH = (dwModeH&(~dwMask2)) | dwData;
911 tempgfx.words.w0 = dwModeH;
912 tempgfx.words.w1 = gRDP.otherModeL;
913 DLParser_RDPSetOtherMode(&tempgfx );
917 void RSP_GBI2_SubModule(Gfx *gfx)
919 SP_Timing(RSP_GBI2_SubModule);
921 RSP_RDP_NOIMPL("RDP: RSP_GBI2_SubModule (0x%08x 0x%08x)", (gfx->words.w0), (gfx->words.w1));