Skip to content

Commit

Permalink
Several adjustments to some gfx microcodes.
Browse files Browse the repository at this point in the history
Thanks to Salvy.
  • Loading branch information
Rinnegatamante committed Jul 3, 2020
1 parent 6c1104f commit fb063c9
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 475 deletions.
68 changes: 35 additions & 33 deletions Source/HLEGraphics/Microcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Debug/DBGConsole.h"
#include "Utility/AuxFunc.h"

#include "OSHLE/ultra_gbi.h"

// Limit cache ucode entries to 6
// In theory we should never reach this max
#define MAX_UCODE_CACHE_ENTRIES 6
Expand Down Expand Up @@ -153,8 +155,8 @@ static const MicrocodeData gMicrocodeData[] =
{ GBI_LL, GBI_1, 2, 0xdd560323, false, "GBI_LL" }, // Toukon Road - Brave Spirits
{ GBI_BETA, GBI_0, 5, 0x64cc729d, true, "GBI_BETA" }, // Wave Race 64 (v.1.1)
{ GBI_1, GBI_1, 2, 0x9fb58257, true, "GBI_MK (F3DEX)"}, // Mario Kart 64
{ GBI_0, GBI_0, 10, 0xf4c3491b, true, "GBI_SM (F3DEX)"}, // Super Mario 64
{ GBI_0, GBI_0, 10, 0xe908848d, true, "GBI_CU (F3DEX)"}, // Cruise'n USA
{ GBI_0, GBI_0, 10, 0xf4c3491b, true, "GBI_SM (F3D) "}, // Super Mario 64
{ GBI_0, GBI_0, 10, 0xe908848d, true, "GBI_CU (F3D) "}, // Cruise'n USA
};

UcodeInfo GBIMicrocode_SetCache(u32 index, u32 code_base, u32 data_base, u32 ucode_stride, u32 ucode_version, const MicroCodeInstruction * ucode_function)
Expand Down Expand Up @@ -296,7 +298,7 @@ UcodeInfo GBIMicrocode_DetectVersion( u32 code_base, u32 code_size, u32 data_bas
default:
{
ucode_stride = 10;
sprintf(cur_ucode, "F3D [Hash: 0x%08x]", code_hash);
sprintf(cur_ucode, "GBI_0 (F3D) [Hash: 0x%08x]", code_hash);
}
break;
}
Expand All @@ -306,9 +308,9 @@ UcodeInfo GBIMicrocode_DetectVersion( u32 code_base, u32 code_size, u32 data_bas
if (is_custom_ucode) {
GBIMicrocode_SetCustomArray(ucode_version, ucode_offset);
if (ucode_beta_persp) {
SetCommand(0xb2, DLParser_GBI1_RDPHalf_1);
SetCommand(0xb3, DLParser_GBI1_RDPHalf_2);
SetCommand(0xb4, DLParser_GBI0_PerspNorm_Beta);
SetCommand(G_GBI1_RDPHALF_CONT, DLParser_GBI1_RDPHalf_1);
SetCommand(G_GBI1_RDPHALF_2, DLParser_GBI1_RDPHalf_2);
SetCommand(G_GBI1_RDPHALF_1, DLParser_GBI0_PerspNorm_Beta);
}
return GBIMicrocode_SetCache(i, code_base, data_base, ucode_stride, ucode_version, gCustomInstruction);
}
Expand All @@ -333,38 +335,38 @@ static void GBIMicrocode_SetCustomArray( u32 ucode_version, u32 ucode_offset )
switch( ucode_version )
{
case GBI_GE:
SetCommand( 0xb4, DLParser_RDPHalf1_GoldenEye);
SetCommand( 0xbd, DLParser_GBI1_MoveWord);
SetCommand( G_GBI1_RDPHALF_1, DLParser_RDPHalf1_GoldenEye);
SetCommand( G_GBI1_POPMTX, DLParser_GBI1_MoveWord);
break;
case GBI_BETA:
SetCommand( 0x04, DLParser_GBI0_Vtx_Beta);
SetCommand( 0xbf, DLParser_GBI0_Tri1_Beta);
SetCommand( 0xb1, DLParser_GBI0_Tri2_Beta);
SetCommand( 0xb5, DLParser_GBI0_Line3D_Beta);
SetCommand( G_GBI1_VTX, DLParser_GBI0_Vtx_Beta);
SetCommand( G_GBI1_TRI1, DLParser_GBI0_Tri1_Beta);
SetCommand( G_GBI1_TRI2, DLParser_GBI0_Tri2_Beta);
SetCommand( G_GBI1_LINE3D, DLParser_GBI0_Line3D_Beta);
break;
case GBI_LL:
SetCommand( 0x80, DLParser_Last_Legion_0x80);
SetCommand( 0x00, DLParser_Last_Legion_0x00);
SetCommand( 0xe4, DLParser_TexRect_Last_Legion);
SetCommand( G_GBI1_SPNOOP, DLParser_Last_Legion_0x00);
SetCommand( G_RDP_TEXRECT, DLParser_TexRect_Last_Legion);
break;
case GBI_PD:
SetCommand( 0x04, DLParser_Vtx_PD);
SetCommand( 0x07, DLParser_Set_Vtx_CI_PD);
SetCommand( 0xb4, DLParser_RDPHalf1_GoldenEye);
SetCommand( G_GBI1_VTX, DLParser_Vtx_PD);
SetCommand( G_GBI1_RESERVED2, DLParser_Set_Vtx_CI_PD);
SetCommand( G_GBI1_RDPHALF_1, DLParser_RDPHalf1_GoldenEye);
break;
case GBI_DKR:
SetCommand( 0x01, DLParser_Mtx_DKR);
SetCommand( 0x04, DLParser_GBI0_Vtx_DKR);
SetCommand( 0x05, DLParser_DMA_Tri_DKR);
SetCommand( 0x07, DLParser_DLInMem);
SetCommand( 0xbc, DLParser_MoveWord_DKR);
SetCommand( 0xbf, DLParser_Set_Addr_DKR);
SetCommand( 0xbb, DLParser_GBI1_Texture_DKR);
SetCommand( G_GBI1_MTX, DLParser_Mtx_DKR);
SetCommand( G_GBI1_VTX, DLParser_GBI0_Vtx_DKR);
SetCommand( G_GBI1_RESERVED1, DLParser_DMA_Tri_DKR);
SetCommand( G_GBI1_RESERVED2, DLParser_DLInMem);
SetCommand( G_GBI1_MOVEWORD, DLParser_MoveWord_DKR);
SetCommand( G_GBI1_TRI1, DLParser_Set_Addr_DKR);
SetCommand( G_GBI1_TEXTURE, DLParser_GBI1_Texture_DKR);
break;
case GBI_CONKER:
SetCommand( 0x01, DLParser_Vtx_Conker);
SetCommand( 0x05, DLParser_Tri1_Conker);
SetCommand( 0x06, DLParser_Tri2_Conker);
SetCommand( G_GBI2_VTX, DLParser_Vtx_Conker);
SetCommand( G_GBI2_TRI1, DLParser_Tri1_Conker);
SetCommand( G_GBI2_TRI2, DLParser_Tri2_Conker);
SetCommand( 0x10, DLParser_Tri4_Conker);
SetCommand( 0x11, DLParser_Tri4_Conker);
SetCommand( 0x12, DLParser_Tri4_Conker);
Expand All @@ -381,16 +383,16 @@ static void GBIMicrocode_SetCustomArray( u32 ucode_version, u32 ucode_offset )
SetCommand( 0x1d, DLParser_Tri4_Conker);
SetCommand( 0x1e, DLParser_Tri4_Conker);
SetCommand( 0x1f, DLParser_Tri4_Conker);
SetCommand( 0xdb, DLParser_MoveWord_Conker);
SetCommand( 0xdc, DLParser_MoveMem_Conker);
SetCommand( G_GBI2_MOVEWORD, DLParser_MoveWord_Conker);
SetCommand( G_GBI2_MOVEMEM, DLParser_MoveMem_Conker);
break;
case GBI_ACCLAIM:
SetCommand( 0xdc, DLParser_MoveMem_Acclaim);
SetCommand( G_GBI2_MOVEMEM, DLParser_MoveMem_Acclaim);
break;
case GBI_AM:
SetCommand( 0x01, DLParser_GBI2_Vtx_AM);
SetCommand( 0xd7, DLParser_GBI2_Texture_AM);
SetCommand( 0xdb, DLParser_GBI2_MoveWord_AM);
SetCommand( G_GBI2_VTX, DLParser_GBI2_Vtx_AM);
SetCommand( G_GBI2_TEXTURE, DLParser_GBI2_Texture_AM);
SetCommand( G_GBI2_MOVEWORD, DLParser_GBI2_MoveWord_AM);
break;
default:
break;
Expand Down
4 changes: 2 additions & 2 deletions Source/HLEGraphics/uCodes/Ucode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ const MicroCodeInstruction gNormalInstruction[MAX_UCODE_TABLE][256] =
DLParser_Nothing, DLParser_Nothing, DLParser_Nothing, DLParser_Nothing,
//b0
DLParser_Nothing,DLParser_GBI0_Tri4, DLParser_GBI1_RDPHalf_Cont, DLParser_GBI1_RDPHalf_2,
DLParser_GBI1_RDPHalf_1, DLParser_GBI1_Line3D, DLParser_GBI1_GeometryMode, DLParser_GBI1_GeometryMode,
DLParser_GBI1_RDPHalf_1, DLParser_GBI0_Line3D, DLParser_GBI1_GeometryMode, DLParser_GBI1_GeometryMode,
DLParser_GBI1_EndDL, DLParser_GBI1_SetOtherModeL, DLParser_GBI1_SetOtherModeH, DLParser_GBI1_Texture,
DLParser_GBI1_MoveWord, DLParser_GBI1_PopMtx, DLParser_GBI1_CullDL, DLParser_GBI1_Tri1,
DLParser_GBI1_MoveWord, DLParser_GBI1_PopMtx, DLParser_GBI0_CullDL, DLParser_GBI0_Tri1,

//c0
DLParser_GBI1_Noop, DLParser_Nothing, DLParser_Nothing, DLParser_Nothing,
Expand Down
9 changes: 6 additions & 3 deletions Source/HLEGraphics/uCodes/Ucode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ void DLParser_GBI1_Tri2_T( MicroCodeCommand command );
template< u32 VertexStride >
void DLParser_GBI1_Line3D_T( MicroCodeCommand command );

UcodeFunc( DLParser_GBI0_Vtx );
UcodeFunc( DLParser_GBI0_CullDL );
UcodeFunc( DLParser_GBI0_Tri1 );
UcodeFunc( DLParser_GBI0_Line3D );
UcodeFunc( DLParser_GBI0_Tri4 );

UcodeFunc( DLParser_GBI1_CullDL );
UcodeFunc( DLParser_GBI1_DL );
UcodeFunc( DLParser_GBI1_BranchZ );
Expand All @@ -52,7 +58,6 @@ UcodeFunc( DLParser_GBI2_SetOtherModeH );
UcodeFunc( DLParser_GBI1_Texture );
UcodeFunc( DLParser_GBI2_Texture );

UcodeFunc( DLParser_GBI0_Vtx );
UcodeFunc( DLParser_GBI1_Vtx );
UcodeFunc( DLParser_GBI2_Vtx );
UcodeFunc( DLParser_GBI1_ModifyVtx );
Expand All @@ -61,8 +66,6 @@ UcodeFunc( DLParser_GBI1_Mtx );
UcodeFunc( DLParser_GBI2_Mtx );
UcodeFunc( DLParser_GBI1_PopMtx );

UcodeFunc( DLParser_GBI0_Tri4 );

UcodeFunc( DLParser_GBI2_Quad );
UcodeFunc( DLParser_GBI2_Line3D );
UcodeFunc( DLParser_GBI2_Tri1 );
Expand Down
95 changes: 22 additions & 73 deletions Source/HLEGraphics/uCodes/Ucode_Conker.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,15 @@ void DLParser_Vtx_Conker( MicroCodeCommand command )
{
if( g_CI.Format != G_IM_FMT_RGBA || (gRDPOtherMode.L == CONKER_SHADOW) )
{
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" Skipping Conker TnL (Vtx -> Off-Screen/Shadow)");
#endif
return;
}

u32 address = RDPSegAddr(command.inst.cmd1);
u32 len = ((command.inst.cmd0 >> 1 )& 0x7F) ;
u32 n = ((command.inst.cmd0 >> 12)& 0xFF);
u32 v0 = len - n;
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" Address[0x%08x] Len[%d] v0[%d] Num[%d]", address, len, v0, n);
#endif

gRenderer->SetNewVertexInfoConker( address, v0, n );

#ifdef DAEDALUS_DEBUG_DISPLAYLIST
gNumVertices += n;
DLParser_DumpVtxInfo( address, v0, n );
#endif

}

//*****************************************************************************
Expand All @@ -69,9 +57,6 @@ void DLParser_Tri1_Conker( MicroCodeCommand command )
{
do
{
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" Tri1 (Culled -> Off-Screen/Shadow)");
#endif
command.inst.cmd0 = *pCmdBase++;
command.inst.cmd1 = *pCmdBase++;
pc += 8;
Expand Down Expand Up @@ -120,9 +105,6 @@ void DLParser_Tri2_Conker( MicroCodeCommand command )
{
do
{
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" Tri2 (Culled -> Off-Screen/Shadow)");
#endif
command.inst.cmd0 = *pCmdBase++;
command.inst.cmd1 = *pCmdBase++;
pc += 8;
Expand Down Expand Up @@ -176,9 +158,6 @@ void DLParser_Tri4_Conker( MicroCodeCommand command )
{
do
{
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" Tri4 (Culled -> Off-Screen)");
#endif
command.inst.cmd0 = *(u32 *)(g_pu8RamBase + pc+0);
command.inst.cmd1 = *(u32 *)(g_pu8RamBase + pc+4);
pc += 8;
Expand Down Expand Up @@ -261,9 +240,6 @@ void DLParser_MoveMem_Conker( MicroCodeCommand command )
u32 light_idx = (offset2 / 48);
if (light_idx < 2)
{
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" G_MV_LOOKAT" );
#endif
return;
}

Expand All @@ -276,9 +252,6 @@ void DLParser_MoveMem_Conker( MicroCodeCommand command )
}
break;
default:
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" GBI2 MoveMem Type: Unknown");
#endif
break;
}
}
Expand All @@ -288,7 +261,6 @@ void DLParser_MoveMem_Conker( MicroCodeCommand command )
//*****************************************************************************
void DLParser_MoveWord_Conker( MicroCodeCommand command )
{
#if 1
u8 index = (u8)(( command.inst.cmd0 >> 16) & 0xFF);
switch (index)
{
Expand All @@ -314,58 +286,35 @@ void DLParser_MoveWord_Conker( MicroCodeCommand command )
break;

case 0x10: // moveword coord mod
{
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" G_MoveWord_Conker: coord mod");
#endif
if ( (command.inst.cmd0 & 8) == 0 )
{
u32 idx = (command.inst.cmd0 >> 1) & 3;
u32 pos = command.inst.cmd0 & 0x30;

switch(pos)
if ( (command.inst.cmd0 & 8) == 0 )
{
case 0:
gRenderer->SetCoordMod( 0+idx, (s16)(command.inst.cmd1 >> 16) );
gRenderer->SetCoordMod( 1+idx, (s16)(command.inst.cmd1 & 0xFFFF) );
break;
case 0x10:
gRenderer->SetCoordMod( 4+idx, (command.inst.cmd1 >> 16) / 65536.0f );
gRenderer->SetCoordMod( 5+idx, (command.inst.cmd1 & 0xFFFF) / 65536.0f );
gRenderer->SetCoordMod( 12+idx, gRenderer->GetCoordMod(0+idx) + gRenderer->GetCoordMod(4+idx) );
gRenderer->SetCoordMod( 13+idx, gRenderer->GetCoordMod(1+idx) + gRenderer->GetCoordMod(5+idx) );
break;
case 0x20:
gRenderer->SetCoordMod( 8+idx, (s16)(command.inst.cmd1 >> 16) );
gRenderer->SetCoordMod( 9+idx, (s16)(command.inst.cmd1 & 0xFFFF) );
break;
u32 idx = (command.inst.cmd0 >> 1) & 3;
u32 pos = command.inst.cmd0 & 0x30;

switch(pos)
{
case 0:
gRenderer->SetCoordMod( 0+idx, (s16)(command.inst.cmd1 >> 16) );
gRenderer->SetCoordMod( 1+idx, (s16)(command.inst.cmd1 & 0xFFFF) );
break;
case 0x10:
gRenderer->SetCoordMod( 4+idx, (command.inst.cmd1 >> 16) / 65536.0f );
gRenderer->SetCoordMod( 5+idx, (command.inst.cmd1 & 0xFFFF) / 65536.0f );
gRenderer->SetCoordMod( 12+idx, gRenderer->GetCoordMod(0+idx) + gRenderer->GetCoordMod(4+idx) );
gRenderer->SetCoordMod( 13+idx, gRenderer->GetCoordMod(1+idx) + gRenderer->GetCoordMod(5+idx) );
break;
case 0x20:
gRenderer->SetCoordMod( 8+idx, (s16)(command.inst.cmd1 >> 16) );
gRenderer->SetCoordMod( 9+idx, (s16)(command.inst.cmd1 & 0xFFFF) );
break;
}
}
}
}
break;
break;
default:
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" G_MoveWord_Conker: Unknown");
#endif
break;
}

#else
u32 type = (command.inst.cmd0 >> 16) & 0xFF;

if( type != G_MW_NUMLIGHT )
{
DLParser_GBI2_MoveWord( command );
}
else
{
u32 num_lights = command.inst.cmd1 / 48;
#ifdef DAEDALUS_DEBUG_DISPLAYLIST
DL_PF(" G_MW_NUMLIGHT: %d", num_lights);
#endif
gRenderer->SetNumLights(num_lights);
}
#endif
}


Expand Down
Loading

0 comments on commit fb063c9

Please sign in to comment.