void glDisable(GLenum type){ switch(type) { case GL_DEPTH_TEST: depthtestenabled = GX_FALSE; break; case GL_LIGHTING: GX_SetNumChans(1); //keep this at one all time? GX_SetNumTevStages(1); if (tex2denabled){ GX_SetNumTexGens(1); //multitexturing so set to 1 for now GX_SetTevOp(GX_TEVSTAGE0,GX_REPLACE); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); } else { GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); GX_SetChanCtrl(GX_COLOR0A0,GX_DISABLE,GX_SRC_REG,GX_SRC_VTX,GX_LIGHTNULL,GX_DF_NONE,GX_AF_NONE); } break; case GL_TEXTURE_2D: tex2denabled = false; GX_SetNumTexGens(0); //texturing is of so no textures GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0); GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); break; case GL_LIGHT0: gxlightenabled[0]=false; break; case GL_LIGHT1: gxlightenabled[1]=false; break; case GL_LIGHT2: gxlightenabled[2]=false; break; case GL_LIGHT3: gxlightenabled[3]=false; break; case GL_LIGHT4: gxlightenabled[4]=false; break; case GL_LIGHT5: gxlightenabled[5]=false; break; case GL_LIGHT6: gxlightenabled[6]=false; break; case GL_LIGHT7: gxlightenabled[7]=false; break; case GL_CULL_FACE: gxcullfaceanabled=false; break; }; }
/**************************************************************************** * Restore GX to 2D mode drawing ***************************************************************************/ void ReSetup_GX(void) { // channel control GX_SetNumChans(1); GX_SetChanCtrl(GX_COLOR0A0,GX_DISABLE,GX_SRC_REG,GX_SRC_VTX,GX_LIGHTNULL,GX_DF_NONE,GX_AF_NONE); // texture gen. GX_SetNumTexGens(1); GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); // texture environment GX_SetNumTevStages(1); GX_SetNumIndStages(0); GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_SetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0); GX_SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_1_4); GX_SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_1); GX_SetTevDirect(GX_TEVSTAGE0); // swap table GX_SetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); GX_SetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_RED, GX_CH_RED, GX_CH_ALPHA); GX_SetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_GREEN, GX_CH_GREEN, GX_CH_GREEN, GX_CH_ALPHA); GX_SetTevSwapModeTable(GX_TEV_SWAP3, GX_CH_BLUE, GX_CH_BLUE, GX_CH_BLUE, GX_CH_ALPHA); // alpha compare and blend mode GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET); }
void drawInit() { Mtx44 GXprojection2D; Mtx GXmodelView2D; // Reset various parameters from gfx plugin GX_SetCoPlanar(GX_DISABLE); GX_SetClipMode(GX_CLIP_ENABLE); // GX_SetScissor(0,0,vmode->fbWidth,vmode->efbHeight); GX_SetAlphaCompare(GX_ALWAYS,0,GX_AOP_AND,GX_ALWAYS,0); guMtxIdentity(GXmodelView2D); GX_LoadTexMtxImm(GXmodelView2D,GX_TEXMTX0,GX_MTX2x4); GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0); guOrtho(GXprojection2D, 0, 479, 0, 639, 0, 700); GX_LoadProjectionMtx(GXprojection2D, GX_ORTHOGRAPHIC); // GX_SetViewport (0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); GX_SetZMode(GX_DISABLE,GX_ALWAYS,GX_TRUE); GX_ClearVtxDesc(); GX_SetVtxDesc(GX_VA_PTNMTXIDX, GX_PNMTX0); GX_SetVtxDesc(GX_VA_TEX0MTXIDX, GX_TEXMTX0); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); //set vertex attribute formats here GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); //enable textures GX_SetNumChans (1); GX_SetNumTexGens (1); GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GX_SetNumTevStages (1); GX_SetTevOrder (GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); //set blend mode GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); //Fix src alpha GX_SetColorUpdate(GX_ENABLE); // GX_SetAlphaUpdate(GX_ENABLE); // GX_SetDstAlpha(GX_DISABLE, 0xFF); //set cull mode GX_SetCullMode (GX_CULL_NONE); }
void glEnable(GLenum type){ u8 gxlightmask = 0x00000000; u8 gxlightmaskspec = 0x00000000; int lightcounter = 0; int countlights =0; switch(type) { case GL_DEPTH_TEST: depthtestenabled = GX_TRUE; break; case GL_LIGHTING: //getting opengl lights to work on gx // //xg has only one light color (a diffuse one) //opengl lights have the following colors: diffuse, ambient and specular //also opengl has a global ambient color independend of a individual light //gx has 2 material colors: diffuse (mat) and ambient (can also be considered part of light?) //opengl material have the followning colors: diffuse, ambient, specular and emission //so we (may) have problem (or call it a challenge) //now how does opengl calculate light with all these colors //vertex color = material emission // + global ambient scaled by material ambient // + ambient, diffuse, specular contributions from light(s), properly attinuated // //let us take these apart. // //material emission is like a constant color. So we can just add this in a tev stage. The only problem is how to add a color to a specific stage?) // //global ambient scaled by material ambient //this is global ambient * material ambient so we can feed that result to an tev stage. // //Now comes the hard part as each color is used in the light calulation. And we only have once color in gx. //Maybe we are lucky as each colors term is added to each other and only then used in light calculation //So we might get away with just adding the 3 colors upfront and feed that as color to the light source //But first let see how these terms are calculated. // //Ambient Term = light ambient * material ambient = GXChanAmbColor ? //Diffuse Term = surface * (light diffuse * material diffuse) light diffues = light color | material diffuse = GXChanMatColor (let gx handle this) //Specular Term = normal.shininess * (light specular * material specular) (let gx handle this, but add lspec*mspec to GXChanMatColor) // //now we could use 3 light to emulate 1 opengl light but that would not be helpfull //so maybe there is an other way also gx material misses color components // //gx has max to channels //each can be setup differently so we can have on chanel for normal diffuse //and the other for specular. But we only have on light color so unless the specular color equals light color this it not usefull) //maybe some experiments with GXChanMatColor help with that? So light color to none and all color CHANMatColor? // //also we have multiple tev stages. //as we have used 2 channels we have to use 3 stages //stage 1 = emissive + global ambient scaled by material as constant color (maybe 2 stages?) //stage 2 = ambient + diffuse //stage 3 = specular // //So this might do the trick in theory. Now on to practice... //<h0lyRS> did you try setting specular to channel GX_COLOR1A1, and diffuse to GX_COLOR0A0, so you can blend them anyway you want? //this could add an extra color? //one way is adding the specular light, other way is multiplying //Setup lightmask with enabled lights (thanks h0lyRS) for (lightcounter =0; lightcounter < 4; lightcounter++){ if(gxlightenabled[lightcounter]){ //when light is enabled gxlightmask |= (GX_LIGHT0 << lightcounter); gxlightmaskspec |= (GX_LIGHT0 << (lightcounter+4) ); //countlights++; } }; // gxlightmask |= (GX_LIGHT0 << 0); // gxlightmaskspec |= (GX_LIGHT0 << 1); //Setup light system/channels GX_SetNumChans(2); //dependend on if there is a specular color/effect needed //channel 1 (ambient + diffuse) GX_SetChanCtrl(GX_COLOR0A0,GX_TRUE,GX_SRC_REG,GX_SRC_REG,gxlightmask,GX_DF_CLAMP,GX_AF_SPOT); //channel 2 (specular) GX_SetChanCtrl(GX_COLOR1A1,GX_ENABLE,GX_SRC_REG,GX_SRC_REG,gxlightmaskspec,GX_DF_CLAMP,GX_AF_SPEC); //Setup TEV-shader //Setup the number of tev stages needed int numtevstages = 0; if (tex2denabled){ numtevstages = 5; } else { numtevstages = 4; } GX_SetNumTevStages(numtevstages); //each extra color takes another stage? //stage 1 (global ambient light) //color GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); //shagkur method GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); //alpha GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); //shagkur method GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); //tevorder GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0); //only use color //end stage 1 //stage 2 (global ambient light) //color GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C1); //shagkur method GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); //alpha GX_SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_APREV, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A1); //shagkur method GX_SetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); //tevorder GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0); //only use color //end stage 2 //stage 3 (ambient and diffuse light from material and lights) //color GX_SetTevColorIn(GX_TEVSTAGE2, GX_CC_CPREV, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC); GX_SetTevColorOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); //alpha GX_SetTevAlphaIn(GX_TEVSTAGE2, GX_CA_APREV, GX_CA_ZERO, GX_CA_ZERO, GX_CC_RASA); GX_SetTevAlphaOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); //tevorder GX_SetTevOrder(GX_TEVSTAGE2, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0); //only use color // end stage 3 //stage 4 (specular light) // color - blend GX_SetTevColorOp(GX_TEVSTAGE3, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); //GX_SetTevColorIn(GX_TEVSTAGE3, GX_CC_CPREV, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC); // GX_SetTevColorIn(GX_TEVSTAGE3,GX_CC_ZERO,GX_CC_RASC,GX_CC_CPREV,GX_CC_ZERO); GX_SetTevColorIn(GX_TEVSTAGE3,GX_CC_ZERO,GX_CC_RASC,GX_CC_ONE,GX_CC_CPREV); // alpha - nop GX_SetTevAlphaOp(GX_TEVSTAGE3, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); //GX_SetTevAlphaIn(GX_TEVSTAGE3, GX_CA_APREV, GX_CA_ZERO, GX_CA_ZERO, GX_CA_RASA); //shagkur method GX_SetTevAlphaIn(GX_TEVSTAGE3,GX_CA_ZERO,GX_CA_RASA,GX_CA_APREV,GX_CA_ZERO); GX_SetTevOrder(GX_TEVSTAGE3, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1); // end stage 4 if (tex2denabled){ // stage 5 (textures) GX_SetTevOrder(GX_TEVSTAGE4, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); //use texture GX_SetTevOp(GX_TEVSTAGE4, GX_MODULATE); //blend with previous stage // end stage 5 } break; case GL_TEXTURE_2D: tex2denabled = true; GX_SetNumTexGens(1); //multitexturing so set to 1 for now GX_SetTevOp(GX_TEVSTAGE0,GX_REPLACE); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); break; case GL_LIGHT0: gxlightenabled[0]=true; break; case GL_LIGHT1: gxlightenabled[1]=true; break; case GL_LIGHT2: gxlightenabled[2]=true; break; case GL_LIGHT3: gxlightenabled[3]=true; break; case GL_LIGHT4: gxlightenabled[4]=true; break; case GL_LIGHT5: gxlightenabled[5]=true; break; case GL_LIGHT6: gxlightenabled[6]=true; break; case GL_LIGHT7: gxlightenabled[7]=true; break; case GL_CULL_FACE: gxcullfaceanabled=true; break; }; }
void Textbox::SetupGX(const BannerResources& resources) const { GX_ClearVtxDesc(); GX_InvVtxCache(); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); // channel control GX_SetNumChans(1); GX_SetChanCtrl(GX_COLOR0A0,GX_DISABLE,GX_SRC_REG,GX_SRC_VTX,GX_LIGHTNULL,GX_DF_NONE,GX_AF_NONE); // texture gen. GX_SetNumTexGens(1); GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); // texture environment GX_SetNumTevStages(1); GX_SetNumIndStages(0); GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_SetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0); GX_SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_1_4); GX_SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_1); GX_SetTevDirect(GX_TEVSTAGE0); // swap table GX_SetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); GX_SetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_RED, GX_CH_RED, GX_CH_ALPHA); GX_SetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_GREEN, GX_CH_GREEN, GX_CH_GREEN, GX_CH_ALPHA); GX_SetTevSwapModeTable(GX_TEV_SWAP3, GX_CH_BLUE, GX_CH_BLUE, GX_CH_BLUE, GX_CH_ALPHA); // alpha compare and blend mode GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET); if(header->material_index < resources.materials.size()) { const Material::Header *matHead = resources.materials[header->material_index]->GetHeader(); if(!matHead) return; //GX_SetFog(0, 0.0f, 0.0f, 0.0f, 0.0f, (GXColor){0xff, 0xff, 0xff, 0xff}); GX_SetTevSwapModeTable(0, 0, 1, 2, 3); //GX_SetZTexture(0, 0x11, 0); GX_SetNumChans(1 ); GX_SetChanCtrl(4, 0, 0, 1, 0, 0, 2); GX_SetChanCtrl(5, 0, 0, 0, 0, 0, 2); GX_SetNumTexGens(1); GX_SetTexCoordGen2(0, 1, 4, 0x3c, 0, 0x7D); GX_SetNumIndStages(0); GX_SetBlendMode(1, 4, 5, 0xf); GX_SetNumTevStages(2); GX_SetTevDirect(0); GX_SetTevDirect(1); GX_SetTevSwapMode(0, 0, 0); GX_SetTevSwapMode(1, 0, 0); GX_SetTevOrder(0, 0, 0, 0xff); for( int i = 0; i < 2; i++ ) { // Devkitppc_r27 internal compiler error //GX_SetTevColor(i + 1, (GXColor){ LIMIT(matHead->color_regs[i].r, 0, 0xFF), // LIMIT(matHead->color_regs[i].g, 0, 0xFF), // LIMIT(matHead->color_regs[i].b, 0, 0xFF), // LIMIT(matHead->color_regs[i].a, 0, 0xFF) }); u8 r = (u8) LIMIT(matHead->color_regs[i].r, 0, 0xFF); u8 g = (u8) LIMIT(matHead->color_regs[i].g, 0, 0xFF); u8 b = (u8) LIMIT(matHead->color_regs[i].b, 0, 0xFF); u8 a = (u8) LIMIT(matHead->color_regs[i].a, 0, 0xFF); GX_SetTevColor((u8) (i + 1), (GXColor){r,g,b,a}); } GX_SetTevColorIn(0, 2, 4, 8, 0xf); GX_SetTevAlphaIn(0, 1, 2, 4, 7); GX_SetTevColorOp(0, 0, 0, 0, 1, 0); GX_SetTevAlphaOp(0, 0, 0, 0, 1, 0); GX_SetTevOrder(1, 0xff, 0xff, 4); GX_SetTevColorIn(1, 0xf, 0, 0xa, 0xf); GX_SetTevAlphaIn(1, 7, 0, 5, 7); GX_SetTevColorOp(1, 0, 0, 0, 1, 0); GX_SetTevAlphaOp(1, 0, 0, 0, 1, 0); } }
inline void Material::ApplyTevStages(bool modulate_colors) const { u32 tev_stages_cnt = 0; if(flags->tev_stages) { // tev stages for(u32 i = 0; i < flags->tev_stages; ++i) { const TevStage &ts = tev_stages[i]; GX_SetTevOrder(i, ts.texcoord, ts.tex_map | (ts.lowBit << 8), ts.color ); GX_SetTevSwapMode(i, ts.ras_sel, ts.tex_sel); GX_SetTevColorIn(i, ts.color_in.a, ts.color_in.b, ts.color_in.c, ts.color_in.d); GX_SetTevColorOp(i, ts.color_in.tevop, ts.color_in.tevbias, ts.color_in.tevscale, ts.color_in.clamp, ts.color_in.tevregid ); GX_SetTevKColorSel(i, ts.color_in.sel ); GX_SetTevAlphaIn(i, ts.alpha_in.a, ts.alpha_in.b, ts.alpha_in.c, ts.alpha_in.d); GX_SetTevAlphaOp(i, ts.alpha_in.tevop, ts.alpha_in.tevbias, ts.alpha_in.tevscale, ts.alpha_in.clamp, ts.alpha_in.tevregid ); GX_SetTevKAlphaSel(i, ts.alpha_in.sel ); GX_SetTevIndirect(i, ts.ind.indtexid, ts.ind.format, ts.ind.bias, ts.ind.mtxid, ts.ind.wrap_s, ts.ind.wrap_t, ts.ind.addprev, ts.ind.utclod, ts.ind.a); tev_stages_cnt++; } } else { if(flags->texture_map == 0) { // 1st stage GX_SetTevOrder(GX_TEVSTAGE0, 0xFF, 0xFF, 4); GX_SetTevColorIn(GX_TEVSTAGE0, 0xF, 4, 0xA, 0xF); GX_SetTevAlphaIn(GX_TEVSTAGE0, 0x7, 2, 0x5, 0x7); tev_stages_cnt++; } else if(flags->texture_map == 1) { // 1st stage GX_SetTevOrder(GX_TEVSTAGE0, 0, 0, 0xFF); GX_SetTevColorIn(GX_TEVSTAGE0, 2, 4, 8, 0xF); GX_SetTevAlphaIn(GX_TEVSTAGE0, 1, 2, 4, 7); tev_stages_cnt++; // 2nd stage if(modulate_colors) { GX_SetTevOrder(GX_TEVSTAGE0 + tev_stages_cnt, 0xFF, 0xFF, 4); GX_SetTevColorIn(GX_TEVSTAGE0 + tev_stages_cnt, 0xF, 0, 0xA, 0xF); GX_SetTevAlphaIn(GX_TEVSTAGE0 + tev_stages_cnt, 7, 0, 5, 7); tev_stages_cnt++; } } else if(flags->texture_map == 2) { // 1st stage GX_SetTevOrder(GX_TEVSTAGE0, 0, 0, 0xFF); GX_SetTevColorIn(GX_TEVSTAGE0, 0xF, 0xF, 0xF, 8); GX_SetTevAlphaIn(GX_TEVSTAGE0, 7, 7, 7, 4); tev_stages_cnt++; // 2nd stage GX_SetTevOrder(GX_TEVSTAGE0 + tev_stages_cnt, 1, 1, 0xFF); GX_SetTevColorIn(GX_TEVSTAGE0 + tev_stages_cnt, 8, 0, 0xE, 0xF); GX_SetTevAlphaIn(GX_TEVSTAGE0 + tev_stages_cnt, 4, 0, 6, 7); GX_SetTevKColorSel(GX_TEVSTAGE0 + tev_stages_cnt, 0x1f); GX_SetTevKAlphaSel(GX_TEVSTAGE0 + tev_stages_cnt, 0x1f); tev_stages_cnt++; // 3rd stage if(modulate_colors) { GX_SetTevOrder(GX_TEVSTAGE0 + tev_stages_cnt, 0xFF, 0xFF, 4); GX_SetTevColorIn(GX_TEVSTAGE0 + tev_stages_cnt, 0xF, 0, 0xA, 0xF); GX_SetTevAlphaIn(GX_TEVSTAGE0 + tev_stages_cnt, 7, 0, 5, 7); tev_stages_cnt++; } } else { u32 TevKDefault[] = { 0x1F, 0x1B, 0x17, 0x13, 0x1E, 0x1A, 0x16, 0x12 }; for(int i = 0; i < flags->texture_map; i++) { GX_SetTevOrder(i, i, i, 0xff ); GX_SetTevColorIn(i, 0xf, 8, 0xe, i ? 0xf : 0 ); GX_SetTevAlphaIn(i, 7, 4, 6, i ? 7 : 0 ); GX_SetTevKColorSel(i, TevKDefault[i] ); GX_SetTevKAlphaSel(i, TevKDefault[i] ); tev_stages_cnt++; } GX_SetTevOrder(GX_TEVSTAGE0 + tev_stages_cnt, 0xff, 0xff, 0xff ); GX_SetTevColorIn(GX_TEVSTAGE0 + tev_stages_cnt, 2, 4, 0, 0xf ); GX_SetTevAlphaIn(GX_TEVSTAGE0 + tev_stages_cnt, 1, 2, 0, 7 ); tev_stages_cnt++; if(modulate_colors) { GX_SetTevOrder(GX_TEVSTAGE0 + tev_stages_cnt, 0xFF, 0xFF, 4); GX_SetTevColorIn(GX_TEVSTAGE0 + tev_stages_cnt, 0xF, 0, 0xA, 0xF); GX_SetTevAlphaIn(GX_TEVSTAGE0 + tev_stages_cnt, 7, 0, 5, 7); tev_stages_cnt++; } } for(u32 i = 0; i < tev_stages_cnt; i++) { GX_SetTevColorOp(GX_TEVSTAGE0 + i, 0, 0, 0, 1, 0); GX_SetTevAlphaOp(GX_TEVSTAGE0 + i, 0, 0, 0, 1, 0); GX_SetTevDirect(GX_TEVSTAGE0 + i); GX_SetTevSwapMode(GX_TEVSTAGE0 + i, 0, 0); } } // enable correct number of tev stages GX_SetNumTevStages(tev_stages_cnt); }