BPMemory: Use the new BitField class in two selected structures.

This commit is contained in:
Tony Wasserka 2014-03-10 16:15:40 +01:00
parent 948c0a54f1
commit 77a7bab5ae
5 changed files with 47 additions and 48 deletions

View File

@ -160,11 +160,11 @@ void SWBPWritten(int address, int newvalue)
case BPMEM_TEV_REGISTER_L+6: // Reg 4
{
int regNum = (address >> 1 ) & 0x3;
ColReg& reg = bpmem.tevregs[regNum].low;
bool konst = reg.type;
TevReg& reg = bpmem.tevregs[regNum];
bool konst = reg.type_ra;
Rasterizer::SetTevReg(regNum, Tev::ALP_C, konst, reg.b); // A
Rasterizer::SetTevReg(regNum, Tev::RED_C, konst, reg.a); // R
Rasterizer::SetTevReg(regNum, Tev::ALP_C, konst, reg.alpha);
Rasterizer::SetTevReg(regNum, Tev::RED_C, konst, reg.red);
break;
}
@ -175,11 +175,11 @@ void SWBPWritten(int address, int newvalue)
case BPMEM_TEV_REGISTER_H+6: // Reg 4
{
int regNum = (address >> 1 ) & 0x3;
ColReg& reg = bpmem.tevregs[regNum].high;
bool konst = reg.type;
TevReg& reg = bpmem.tevregs[regNum];
bool konst = reg.type_bg;
Rasterizer::SetTevReg(regNum, Tev::GRN_C, konst, reg.b); // G
Rasterizer::SetTevReg(regNum, Tev::BLU_C, konst, reg.a); // B
Rasterizer::SetTevReg(regNum, Tev::GRN_C, konst, reg.green);
Rasterizer::SetTevReg(regNum, Tev::BLU_C, konst, reg.blue);
break;
}

View File

@ -158,7 +158,7 @@ void GetBPRegInfo(const u8* data, char* name, size_t name_size, char* desc, size
no_yes[copy.half_scale],
no_yes[copy.scale_invert],
no_yes[copy.clear],
copy.frame_to_field,
(u32)copy.frame_to_field,
no_yes[copy.copy_to_xfb],
no_yes[copy.intensity_fmt],
no_yes[copy.auto_conv]);

View File

@ -4,6 +4,7 @@
#pragma once
#include "Common/BitField.h"
#include "Common/Common.h"
#pragma pack(4)
@ -828,22 +829,25 @@ struct TCoordInfo
};
union ColReg
union TevReg
{
u32 hex;
struct
{
s32 a : 11;
u32 : 1;
s32 b : 11;
u32 type : 1;
};
};
u64 hex;
struct TevReg
{
ColReg low;
ColReg high;
// Access to individual registers
BitField< 0, 32,u64> low;
BitField<32, 32,u64> high;
// Low register
BitField< 0,11,s64> red;
BitField<12,11,s64> alpha;
BitField<23, 1,u64> type_ra;
// High register
BitField<32,11,s64> blue;
BitField<44,11,s64> green;
BitField<55, 1,u64> type_bg;
};
union TevKSel
@ -920,21 +924,20 @@ union AlphaTest
union UPE_Copy
{
u32 Hex;
struct
{
u32 clamp0 : 1; // if set clamp top
u32 clamp1 : 1; // if set clamp bottom
u32 yuv : 1; // if set, color conversion from RGB to YUV
u32 target_pixel_format : 4; // realformat is (fmt/2)+((fmt&1)*8).... for some reason the msb is the lsb (pattern: cycling right shift)
u32 gamma : 2; // gamma correction.. 0 = 1.0 ; 1 = 1.7 ; 2 = 2.2 ; 3 is reserved
u32 half_scale : 1; // "mipmap" filter... 0 = no filter (scale 1:1) ; 1 = box filter (scale 2:1)
u32 scale_invert : 1; // if set vertical scaling is on
u32 clear : 1;
u32 frame_to_field : 2; // 0 progressive ; 1 is reserved ; 2 = interlaced (even lines) ; 3 = interlaced 1 (odd lines)
u32 copy_to_xfb : 1;
u32 intensity_fmt : 1; // if set, is an intensity format (I4,I8,IA4,IA8)
u32 auto_conv : 1; // if 0 automatic color conversion by texture format and pixel type
};
BitField< 0,1,u32> clamp0; // if set clamp top
BitField< 1,1,u32> clamp1; // if set clamp bottom
BitField< 2,1,u32> yuv; // if set, color conversion from RGB to YUV
BitField< 3,4,u32> target_pixel_format; // realformat is (fmt/2)+((fmt&1)*8).... for some reason the msb is the lsb (pattern: cycling right shift)
BitField< 7,2,u32> gamma; // gamma correction.. 0 = 1.0 ; 1 = 1.7 ; 2 = 2.2 ; 3 is reserved
BitField< 9,1,u32> half_scale; // "mipmap" filter... 0 = no filter (scale 1:1) ; 1 = box filter (scale 2:1)
BitField<10,1,u32> scale_invert; // if set vertical scaling is on
BitField<11,1,u32> clear;
BitField<12,2,u32> frame_to_field; // 0 progressive ; 1 is reserved ; 2 = interlaced (even lines) ; 3 = interlaced 1 (odd lines)
BitField<14,1,u32> copy_to_xfb;
BitField<15,1,u32> intensity_fmt; // if set, is an intensity format (I4,I8,IA4,IA8)
BitField<16,1,u32> auto_conv; // if 0 automatic color conversion by texture format and pixel type
u32 tp_realFormat() {
return target_pixel_format / 2 + (target_pixel_format & 1) * 8;
}

View File

@ -560,9 +560,9 @@ void BPWritten(const BPCmd& bp)
// don't compare with changes!
int num = (bp.address >> 1) & 0x3;
if ((bp.address & 1) == 0)
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].low.type, num);
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].type_ra, num);
else
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num);
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].type_bg, num);
}
break;

View File

@ -148,17 +148,13 @@ void PixelShaderManager::SetConstants()
}
}
// This one is high in profiles (0.5%).
// TODO: Move conversion out, only store the raw color value
// and update it when the shader constant is set, only.
// TODO: Conversion should be checked in the context of tev_fixes..
void PixelShaderManager::SetColorChanged(int type, int num)
{
int4* c = type ? constants.kcolors : constants.colors;
c[num][0] = bpmem.tevregs[num].low.a;
c[num][3] = bpmem.tevregs[num].low.b;
c[num][2] = bpmem.tevregs[num].high.a;
c[num][1] = bpmem.tevregs[num].high.b;
c[num][0] = bpmem.tevregs[num].red;
c[num][3] = bpmem.tevregs[num].alpha;
c[num][2] = bpmem.tevregs[num].blue;
c[num][1] = bpmem.tevregs[num].green;
dirty = true;
PRIM_LOG("pixel %scolor%d: %d %d %d %d\n", type?"k":"", num, c[num][0], c[num][1], c[num][2], c[num][3]);