More commenting and cleanup and added another BP Function.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2903 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
omegadox
2009-04-06 18:20:28 +00:00
parent 62fed97a34
commit 13ac45db1a
5 changed files with 169 additions and 133 deletions

View File

@ -54,6 +54,7 @@ void RestoreRenderState(const Bypass &bp);
u8 *GetPointer(const u32 &address); u8 *GetPointer(const u32 &address);
bool GetConfig(const int &type); bool GetConfig(const int &type);
void SetSamplerState(const Bypass &bp); void SetSamplerState(const Bypass &bp);
void SetInterlacingMode(const Bypass &bp);
}; };
#endif // _BPFUNCTIONS_H_ #endif // _BPFUNCTIONS_H_

View File

@ -62,7 +62,7 @@
#define BPMEM_COPYFILTER1 0x54 #define BPMEM_COPYFILTER1 0x54
#define BPMEM_CLEARBBOX1 0x55 #define BPMEM_CLEARBBOX1 0x55
#define BPMEM_CLEARBBOX2 0x56 #define BPMEM_CLEARBBOX2 0x56
#define BPMEM_UNKNOWN 0xFF #define BPMEM_UNKNOWN 0x58
#define BPMEM_SCISSOROFFSET 0x59 #define BPMEM_SCISSOROFFSET 0x59
#define BPMEM_LOADTLUT0 0x64 #define BPMEM_LOADTLUT0 0x64
#define BPMEM_LOADTLUT1 0x65 #define BPMEM_LOADTLUT1 0x65

View File

@ -37,7 +37,7 @@ void BPInit()
} }
// ---------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------
// Write to the Bypass Memory // Write to the Bypass Memory (Bypass Raster State Registers)
/* ------------------ /* ------------------
Called: Called:
At the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg At the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg
@ -63,12 +63,14 @@ void BPWritten(const Bypass& bp)
switch (bp.address) switch (bp.address)
{ {
case BPMEM_GENMODE: // Set the Generation Mode case BPMEM_GENMODE: // Set the Generation Mode
{
PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, culmode=%d, ind=%d, zfeeze=%d", PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, culmode=%d, ind=%d, zfeeze=%d",
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans, bpmem.genMode.numtexgens, bpmem.genMode.numcolchans,
bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode, bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode,
bpmem.genMode.numindstages, bpmem.genMode.zfreeze); bpmem.genMode.numindstages, bpmem.genMode.zfreeze);
SetGenerationMode(bp); SetGenerationMode(bp);
break; break;
}
case BPMEM_IND_MTXA: // Index Matrix Changed case BPMEM_IND_MTXA: // Index Matrix Changed
case BPMEM_IND_MTXB: case BPMEM_IND_MTXB:
case BPMEM_IND_MTXC: case BPMEM_IND_MTXC:
@ -98,6 +100,7 @@ void BPWritten(const Bypass& bp)
SetDepthMode(bp); SetDepthMode(bp);
break; break;
case BPMEM_BLENDMODE: // Blending Control case BPMEM_BLENDMODE: // Blending Control
{
if (bp.changes & 0xFFFF) if (bp.changes & 0xFFFF)
{ {
PRIM_LOG("blendmode: en=%d, open=%d, colupd=%d, alphaupd=%d, dst=%d, src=%d, sub=%d, mode=%d", PRIM_LOG("blendmode: en=%d, open=%d, colupd=%d, alphaupd=%d, dst=%d, src=%d, sub=%d, mode=%d",
@ -131,12 +134,15 @@ void BPWritten(const Bypass& bp)
} }
} }
break; break;
}
case BPMEM_CONSTANTALPHA: // Set Destination Alpha case BPMEM_CONSTANTALPHA: // Set Destination Alpha
{
PRIM_LOG("constalpha: alp=%d, en=%d", bpmem.dstalpha.alpha, bpmem.dstalpha.enable); PRIM_LOG("constalpha: alp=%d, en=%d", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
SETSTAT(stats.dstAlphaEnable, bpmem.dstalpha.enable); SETSTAT(stats.dstAlphaEnable, bpmem.dstalpha.enable);
SETSTAT_UINT(stats.dstAlpha, bpmem.dstalpha.alpha); SETSTAT_UINT(stats.dstAlpha, bpmem.dstalpha.alpha);
PixelShaderManager::SetDestAlpha(bpmem.dstalpha); PixelShaderManager::SetDestAlpha(bpmem.dstalpha);
break; break;
}
case BPMEM_SETDRAWDONE: // This is called when the game is done drawing (eg: like in DX: Begin(); Draw(); End();) case BPMEM_SETDRAWDONE: // This is called when the game is done drawing (eg: like in DX: Begin(); Draw(); End();)
switch (bp.newvalue & 0xFF) switch (bp.newvalue & 0xFF)
{ {
@ -186,9 +192,8 @@ void BPWritten(const Bypass& bp)
}; };
UPE_Copy PE_copy; UPE_Copy PE_copy;
PE_copy.Hex = bpmem.triggerEFBCopy; PE_copy.Hex = bpmem.triggerEFBCopy;
// ----------------------------------------------------------
// Check to where we should copy the image data from the EFB. // Check if we are to copy from the EFB or draw to the XFB
// ----------------------------------------------------------
if (PE_copy.copy_to_xfb == 0) if (PE_copy.copy_to_xfb == 0)
{ {
if (GetConfig(CONFIG_SHOWEFBREGIONS)) if (GetConfig(CONFIG_SHOWEFBREGIONS))
@ -211,9 +216,7 @@ void BPWritten(const Bypass& bp)
(u32)ceil(xfbLines)); (u32)ceil(xfbLines));
} }
// ----------------------------------------------------------------------------------
// Clear the picture after it's done and submitted, to prepare for the next picture // Clear the picture after it's done and submitted, to prepare for the next picture
// ----------------------------------------------------------------------------------
if (PE_copy.clear) if (PE_copy.clear)
ClearScreen(bp, multirc); ClearScreen(bp, multirc);
@ -221,7 +224,7 @@ void BPWritten(const Bypass& bp)
break; break;
} }
case BPMEM_LOADTLUT0: // Load the Texture Look Up Table case BPMEM_LOADTLUT0: // Load a Texture Look Up Table
case BPMEM_LOADTLUT1: case BPMEM_LOADTLUT1:
{ {
DVSTARTSUBPROFILE("LoadBPReg:GXLoadTlut"); DVSTARTSUBPROFILE("LoadBPReg:GXLoadTlut");
@ -244,8 +247,8 @@ void BPWritten(const Bypass& bp)
// TODO(ector) : kill all textures that use this palette // TODO(ector) : kill all textures that use this palette
// Not sure if it's a good idea, though. For now, we hash texture palettes // Not sure if it's a good idea, though. For now, we hash texture palettes
}
break; break;
}
case BPMEM_FOGRANGE: // Fog Settings Control case BPMEM_FOGRANGE: // Fog Settings Control
case BPMEM_FOGPARAM0: case BPMEM_FOGPARAM0:
case BPMEM_FOGBMAGNITUDE: case BPMEM_FOGBMAGNITUDE:
@ -277,22 +280,21 @@ void BPWritten(const Bypass& bp)
#endif #endif
break; break;
} }
case BPMEM_DISPLAYCOPYFILER: // Display Filtering Control, ignore this
case BPMEM_DISPLAYCOPYFILER: // Display Filtering Control
case BPMEM_DISPLAYCOPYFILER+1: case BPMEM_DISPLAYCOPYFILER+1:
case BPMEM_DISPLAYCOPYFILER+2: case BPMEM_DISPLAYCOPYFILER+2:
case BPMEM_DISPLAYCOPYFILER+3: case BPMEM_DISPLAYCOPYFILER+3:
case BPMEM_COPYFILTER0: case BPMEM_COPYFILTER0:
case BPMEM_COPYFILTER1: case BPMEM_COPYFILTER1:
break; break;
case BPMEM_SU_COUNTER: // Counters case BPMEM_FIELDMASK: // Interlacing Control
case BPMEM_RAS_COUNTER:
break;
case BPMEM_FIELDMASK: // Field Control
case BPMEM_FIELDMODE: case BPMEM_FIELDMODE:
SetInterlacingMode(bp);
break; break;
case BPMEM_CLOCK0: // Debugging info case BPMEM_CLOCK0: // Debugging/Profiling info, we don't care about them
case BPMEM_CLOCK1: case BPMEM_CLOCK1:
case BPMEM_SU_COUNTER:
case BPMEM_RAS_COUNTER:
case BPMEM_SETGPMETRIC: case BPMEM_SETGPMETRIC:
break; break;
case BPMEM_EFB_TL: // EFB Source Rect. Top, Left case BPMEM_EFB_TL: // EFB Source Rect. Top, Left
@ -306,11 +308,11 @@ void BPWritten(const Bypass& bp)
case BPMEM_CLEARBBOX1: // let's hope not many games use bboxes.. case BPMEM_CLEARBBOX1: // let's hope not many games use bboxes..
case BPMEM_CLEARBBOX2: // TODO(ector): add something that watches bboxes case BPMEM_CLEARBBOX2: // TODO(ector): add something that watches bboxes
break; break;
case BPMEM_IREF:
case BPMEM_PE_CONTROL: // Pixel Engine Control (GXSetZCompLoc, GXPixModeSync) case BPMEM_PE_CONTROL: // Pixel Engine Control (GXSetZCompLoc, GXPixModeSync)
case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow
case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel
case BPMEM_COPYYSCALE: // Display Copy Y Scale case BPMEM_COPYYSCALE: // Display Copy Y Scale
case BPMEM_IREF: // Something to do with Tev ordering
break; break;
case BPMEM_TEV_KSEL: // Texture Environment Swap Mode Table 0 case BPMEM_TEV_KSEL: // Texture Environment Swap Mode Table 0
case BPMEM_TEV_KSEL+1:// Texture Environment Swap Mode Table 1 case BPMEM_TEV_KSEL+1:// Texture Environment Swap Mode Table 1
@ -325,6 +327,7 @@ void BPWritten(const Bypass& bp)
case BPMEM_IND_IMASK: case BPMEM_IND_IMASK:
break; break;
case BPMEM_UNKNOWN: // This is always set to 0xF at boot of any game, so this sounds like a useless reg case BPMEM_UNKNOWN: // This is always set to 0xF at boot of any game, so this sounds like a useless reg
break;
// ------------------------------------------------ // ------------------------------------------------
// On Default, we try to look for other things // On Default, we try to look for other things
@ -333,7 +336,10 @@ void BPWritten(const Bypass& bp)
default: default:
switch (bp.address & 0xFC) // Texture sampler filter switch (bp.address & 0xFC) // Texture sampler filter
{ {
case BPMEM_TREF: // Texture Environment Order // -------------------------
// Texture Environment Order
// -------------------------
case BPMEM_TREF:
case BPMEM_TREF+1: case BPMEM_TREF+1:
case BPMEM_TREF+2: case BPMEM_TREF+2:
case BPMEM_TREF+3: case BPMEM_TREF+3:
@ -342,10 +348,11 @@ void BPWritten(const Bypass& bp)
case BPMEM_TREF+6: case BPMEM_TREF+6:
case BPMEM_TREF+7: case BPMEM_TREF+7:
break; break;
// ------------------------------------- // ---------------------------------------------
// This could be Level Of Detail control for Wrap // Mipmapping control of the polygon's wrapping
case BPMEM_SU_SSIZE: // Texture Wrap Size U? // ---------------------------------------------
case BPMEM_SU_TSIZE: // Texture Wrap Size V? case BPMEM_SU_SSIZE: // U
case BPMEM_SU_TSIZE: // V
case BPMEM_SU_SSIZE+2: case BPMEM_SU_SSIZE+2:
case BPMEM_SU_TSIZE+2: case BPMEM_SU_TSIZE+2:
case BPMEM_SU_SSIZE+4: case BPMEM_SU_SSIZE+4:
@ -361,6 +368,9 @@ void BPWritten(const Bypass& bp)
case BPMEM_SU_SSIZE+14: case BPMEM_SU_SSIZE+14:
case BPMEM_SU_TSIZE+14: case BPMEM_SU_TSIZE+14:
break; break;
// ------------------------
// Mipmapping mode control
// ------------------------
case BPMEM_TX_SETMODE0: // 0x90 for Linear, Index 0 case BPMEM_TX_SETMODE0: // 0x90 for Linear, Index 0
case BPMEM_TX_SETMODE0+1: case BPMEM_TX_SETMODE0+1:
case BPMEM_TX_SETMODE0+2: case BPMEM_TX_SETMODE0+2:
@ -379,6 +389,9 @@ void BPWritten(const Bypass& bp)
case BPMEM_TX_SETMODE1_4+3: case BPMEM_TX_SETMODE1_4+3:
SetSamplerState(bp); SetSamplerState(bp);
break; break;
// --------------------------------------------
// Mipmapping control of the polygon's texture
// --------------------------------------------
case BPMEM_TX_SETIMAGE0: case BPMEM_TX_SETIMAGE0:
case BPMEM_TX_SETIMAGE0+1: case BPMEM_TX_SETIMAGE0+1:
case BPMEM_TX_SETIMAGE0+2: case BPMEM_TX_SETIMAGE0+2:
@ -403,7 +416,7 @@ void BPWritten(const Bypass& bp)
case BPMEM_TX_SETIMAGE2_4+1: case BPMEM_TX_SETIMAGE2_4+1:
case BPMEM_TX_SETIMAGE2_4+2: case BPMEM_TX_SETIMAGE2_4+2:
case BPMEM_TX_SETIMAGE2_4+3: case BPMEM_TX_SETIMAGE2_4+3:
case BPMEM_TX_SETIMAGE3: // Texture Pointer case BPMEM_TX_SETIMAGE3:
case BPMEM_TX_SETIMAGE3+1: case BPMEM_TX_SETIMAGE3+1:
case BPMEM_TX_SETIMAGE3+2: case BPMEM_TX_SETIMAGE3+2:
case BPMEM_TX_SETIMAGE3+3: case BPMEM_TX_SETIMAGE3+3:
@ -412,6 +425,9 @@ void BPWritten(const Bypass& bp)
case BPMEM_TX_SETIMAGE3_4+2: case BPMEM_TX_SETIMAGE3_4+2:
case BPMEM_TX_SETIMAGE3_4+3: case BPMEM_TX_SETIMAGE3_4+3:
break; break;
// -------------------------------
// Mipmapping control of the TLUT
// -------------------------------
case BPMEM_TX_SETTLUT: case BPMEM_TX_SETTLUT:
case BPMEM_TX_SETTLUT+1: case BPMEM_TX_SETTLUT+1:
case BPMEM_TX_SETTLUT+2: case BPMEM_TX_SETTLUT+2:
@ -421,6 +437,9 @@ void BPWritten(const Bypass& bp)
case BPMEM_TX_SETLUT_4+2: case BPMEM_TX_SETLUT_4+2:
case BPMEM_TX_SETLUT_4+3: case BPMEM_TX_SETLUT_4+3:
break; break;
// ---------------------------------------------------
// Set the TEV Color
// ---------------------------------------------------
case BPMEM_TEV_REGISTER_L: // Reg 1 case BPMEM_TEV_REGISTER_L: // Reg 1
case BPMEM_TEV_REGISTER_H: case BPMEM_TEV_REGISTER_H:
case BPMEM_TEV_REGISTER_L+2: // Reg 2 case BPMEM_TEV_REGISTER_L+2: // Reg 2
@ -429,6 +448,7 @@ void BPWritten(const Bypass& bp)
case BPMEM_TEV_REGISTER_H+4: case BPMEM_TEV_REGISTER_H+4:
case BPMEM_TEV_REGISTER_L+6: // Reg 4 case BPMEM_TEV_REGISTER_L+6: // Reg 4
case BPMEM_TEV_REGISTER_H+6: case BPMEM_TEV_REGISTER_H+6:
{
if (bp.address & 1) if (bp.address & 1)
{ {
// don't compare with changes! // don't compare with changes!
@ -436,6 +456,7 @@ void BPWritten(const Bypass& bp)
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num); PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num);
} }
break; break;
}
// ------------------------------------------------ // ------------------------------------------------
// On Default, we try to look for other things // On Default, we try to look for other things
// before we give up and say its an unknown opcode // before we give up and say its an unknown opcode
@ -444,6 +465,9 @@ void BPWritten(const Bypass& bp)
default: default:
switch (bp.address & 0xF0) switch (bp.address & 0xF0)
{ {
// --------------
// Indirect Tev
// --------------
case BPMEM_IND_CMD: case BPMEM_IND_CMD:
case BPMEM_IND_CMD+1: case BPMEM_IND_CMD+1:
case BPMEM_IND_CMD+2: case BPMEM_IND_CMD+2:
@ -461,6 +485,9 @@ void BPWritten(const Bypass& bp)
case BPMEM_IND_CMD+14: case BPMEM_IND_CMD+14:
case BPMEM_IND_CMD+15: case BPMEM_IND_CMD+15:
break; break;
// --------------------------------------------------
// Set Color/Alpha of a Tev
// --------------------------------------------------
case BPMEM_TEV_COLOR_ENV: // Texture Environment 1 case BPMEM_TEV_COLOR_ENV: // Texture Environment 1
case BPMEM_TEV_ALPHA_ENV: case BPMEM_TEV_ALPHA_ENV:
case BPMEM_TEV_COLOR_ENV+2: // Texture Environment 2 case BPMEM_TEV_COLOR_ENV+2: // Texture Environment 2

View File

@ -329,4 +329,8 @@ void SetSamplerState(const Bypass &bp)
//sprintf(temp,"lod %f",tm0.lod_bias/4.0f); //sprintf(temp,"lod %f",tm0.lod_bias/4.0f);
//g_VideoInitialize.pLog(temp); //g_VideoInitialize.pLog(temp);
} }
void SetInterlacingMode(const Bypass &bp)
{
// TODO
}
}; };

View File

@ -252,4 +252,8 @@ void SetSamplerState(const Bypass &bp)
{ {
// TODO // TODO
} }
void SetInterlacingMode(const Bypass &bp)
{
// TODO
}
}; };