diff --git a/libctru/include/3ds/gpu/gpu.h b/libctru/include/3ds/gpu/gpu.h index 8370721..b58cf89 100644 --- a/libctru/include/3ds/gpu/gpu.h +++ b/libctru/include/3ds/gpu/gpu.h @@ -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, @@ -184,6 +187,7 @@ typedef enum{ GPU_TEXTURE1 = 0x04, GPU_TEXTURE2 = 0x05, GPU_TEXTURE3 = 0x06, + GPU_PREVIOUS_BUFFER = 0x0D, GPU_CONSTANT = 0x0E, GPU_PREVIOUS = 0x0F, }GPU_TEVSRC; @@ -262,6 +266,8 @@ void GPU_SetDepthTestAndWriteMask(bool enable, GPU_TESTFUNC function, GPU_WRITEM void GPU_SetStencilTest(bool enable, GPU_TESTFUNC function, u8 ref, u8 mask, u8 replace); 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, @@ -281,7 +287,7 @@ void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 para /** * @param borderColor The color used for the border when using the @ref GPU_CLAMP_TO_BORDER wrap mode */ - void GPU_SetTextureBorderColor(GPU_TEXUNIT unit,u32 borderColor); +void GPU_SetTextureBorderColor(GPU_TEXUNIT unit,u32 borderColor); void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor); void GPU_DrawArray(GPU_Primitive_t primitive, u32 n); diff --git a/libctru/include/3ds/gpu/registers.h b/libctru/include/3ds/gpu/registers.h index b08fa2b..aebc4af 100644 --- a/libctru/include/3ds/gpu/registers.h +++ b/libctru/include/3ds/gpu/registers.h @@ -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 diff --git a/libctru/source/gpu/gpu.c b/libctru/source/gpu/gpu.c index 49d5809..b50717c 100644 --- a/libctru/source/gpu/gpu.c +++ b/libctru/source/gpu/gpu.c @@ -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)