Merge pull request #154 from Subv/tev_buffer_color

GPU: Added code to manipulate the combiner buffer.
This commit is contained in:
fincs 2015-08-22 21:20:37 +02:00
commit 6f9edd9bbe
3 changed files with 14 additions and 3 deletions

View File

@ -33,6 +33,9 @@ void GPUCMD_Finalize();
#define GPU_TEXTURE_WRAP_S(v) (((v)&0x3)<<12) //takes a GPU_TEXTURE_WRAP_PARAM
#define GPU_TEXTURE_WRAP_T(v) (((v)&0x3)<<8) //takes a GPU_TEXTURE_WRAP_PARAM
// Combiner buffer write config
#define GPU_TEV_BUFFER_WRITE_CONFIG(stage0, stage1, stage2, stage3) (stage0 | (stage1 << 1) | (stage2 << 2) | (stage3 << 3))
typedef enum
{
GPU_NEAREST = 0x0,
@ -188,6 +191,7 @@ typedef enum{
GPU_TEXTURE1 = 0x04,
GPU_TEXTURE2 = 0x05,
GPU_TEXTURE3 = 0x06,
GPU_PREVIOUS_BUFFER = 0x0D,
GPU_CONSTANT = 0x0E,
GPU_PREVIOUS = 0x0F,
}GPU_TEVSRC;
@ -266,6 +270,8 @@ void GPU_SetDepthTestAndWriteMask(bool enable, GPU_TESTFUNC function, GPU_WRITEM
void GPU_SetStencilTest(bool enable, GPU_TESTFUNC function, u8 ref, u8 input_mask, u8 write_mask);
void GPU_SetStencilOp(GPU_STENCILOP sfail, GPU_STENCILOP dfail, GPU_STENCILOP pass);
void GPU_SetFaceCulling(GPU_CULLMODE mode);
// Only the first four tev stages can write to the combiner buffer, use GPU_TEV_BUFFER_WRITE_CONFIG to build the parameters
void GPU_SetCombinerBufferWrite(u8 rgb_config, u8 alpha_config);
// these two can't be used together
void GPU_SetAlphaBlending(GPU_BLENDEQUATION colorEquation, GPU_BLENDEQUATION alphaEquation,

View File

@ -224,7 +224,7 @@
#define GPUREG_00DD 0x00DD
#define GPUREG_00DE 0x00DE
#define GPUREG_00DF 0x00DF
#define GPUREG_00E0 0x00E0
#define GPUREG_TEXENV_BUFFER_CONFIG 0x00E0
#define GPUREG_00E1 0x00E1
#define GPUREG_00E2 0x00E2
#define GPUREG_00E3 0x00E3
@ -253,7 +253,7 @@
#define GPUREG_TEXENV5_CONFIG2 0x00FA
#define GPUREG_TEXENV5_CONFIG3 0x00FB
#define GPUREG_TEXENV5_CONFIG4 0x00FC
#define GPUREG_00FD 0x00FD
#define GPUREG_TEXENV_BUFFER_COLOR 0x00FD
#define GPUREG_00FE 0x00FE
#define GPUREG_00FF 0x00FF
#define GPUREG_COLOROUTPUT_CONFIG 0x0100

View File

@ -463,6 +463,11 @@ void GPU_SetFaceCulling(GPU_CULLMODE mode)
GPUCMD_AddWrite(GPUREG_FACECULLING_CONFIG, mode&0x3);
}
void GPU_SetCombinerBufferWrite(u8 rgb_config, u8 alpha_config)
{
GPUCMD_AddMaskedWrite(GPUREG_TEXENV_BUFFER_CONFIG, 0x2, (rgb_config << 8) | (alpha_config << 12));
}
const u8 GPU_TEVID[]={0xC0,0xC8,0xD0,0xD8,0xF0,0xF8};
void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor)