static void set_lighting(void) { /* create light */ z64_gbi_lights_t *gbi_lights = gDisplayListAlloc(&z64_ctxt.gfx->poly_opa.d, sizeof(z64_gbi_lights_t)); gbi_lights->numlights = 0; Ambient *a = &gbi_lights->lites.a; a->l.col[0] = a->l.colc[0] = z64_game.lighting.ambient[0]; a->l.col[1] = a->l.colc[1] = z64_game.lighting.ambient[1]; a->l.col[2] = a->l.colc[2] = z64_game.lighting.ambient[2]; /* fill light */ for (z64_light_node_t *light_node = z64_game.lighting.light_list; light_node; light_node = light_node->next) { z64_light_handler_t handler = z64_light_handlers[light_node->light->type]; handler(gbi_lights, &light_node->light->lightn, NULL); } /* set light */ gSPNumLights(z64_ctxt.gfx->poly_opa.p++, gbi_lights->numlights); gSPNumLights(z64_ctxt.gfx->poly_xlu.p++, gbi_lights->numlights); for (int i = 0; i < gbi_lights->numlights; ++i) { gSPLight(z64_ctxt.gfx->poly_opa.p++, &gbi_lights->lites.l[i], i + 1); gSPLight(z64_ctxt.gfx->poly_xlu.p++, &gbi_lights->lites.l[i], i + 1); } gSPLight(z64_ctxt.gfx->poly_opa.p++, &gbi_lights->lites.a, gbi_lights->numlights + 1); gSPLight(z64_ctxt.gfx->poly_xlu.p++, &gbi_lights->lites.a, gbi_lights->numlights + 1); }
void F3DEX2_MoveMem( u32 w0, u32 w1 ) { switch (_SHIFTR( w0, 0, 8 )) { case F3DEX2_MV_VIEWPORT: gSPViewport( w1 ); break; case G_MV_MATRIX: gSPForceMatrix( w1 ); // force matrix takes two commands RSP.PC[RSP.PCi] += 8; break; case G_MV_LIGHT: u32 offset = _SHIFTR( w0, 8, 8 ) << 3; if (offset >= 48) { gSPLight( w1, (offset - 24) / 24); } /* else { // Do lookat stuff }*/ break; } }
void F3D_MoveMem( u32 w0, u32 w1 ) { #ifdef __TRIBUFFER_OPT gSPFlushTriangles(); #endif switch (_SHIFTR( w0, 16, 8 )) { case F3D_MV_VIEWPORT://G_MV_VIEWPORT: gSPViewport( w1 ); break; case G_MV_MATRIX_1: gSPForceMatrix( w1 ); // force matrix takes four commands RSP.PC[RSP.PCi] += 24; break; case G_MV_L0: gSPLight( w1, LIGHT_1 ); break; case G_MV_L1: gSPLight( w1, LIGHT_2 ); break; case G_MV_L2: gSPLight( w1, LIGHT_3 ); break; case G_MV_L3: gSPLight( w1, LIGHT_4 ); break; case G_MV_L4: gSPLight( w1, LIGHT_5 ); break; case G_MV_L5: gSPLight( w1, LIGHT_6 ); break; case G_MV_L6: gSPLight( w1, LIGHT_7 ); break; case G_MV_L7: gSPLight( w1, LIGHT_8 ); break; case G_MV_LOOKATX: break; case G_MV_LOOKATY: break; } }
void F3D_MoveMem( u32 w0, u32 w1 ) { switch (_SHIFTR( w0, 16, 8 )) { case F3D_MV_VIEWPORT://G_MV_VIEWPORT: gSPViewport( w1 ); break; case G_MV_MATRIX_1: gSPForceMatrix( w1 ); // force matrix takes four commands __RSP.PC[__RSP.PCi] += 24; break; case G_MV_L0: gSPLight( w1, LIGHT_1 ); break; case G_MV_L1: gSPLight( w1, LIGHT_2 ); break; case G_MV_L2: gSPLight( w1, LIGHT_3 ); break; case G_MV_L3: gSPLight( w1, LIGHT_4 ); break; case G_MV_L4: gSPLight( w1, LIGHT_5 ); break; case G_MV_L5: gSPLight( w1, LIGHT_6 ); break; case G_MV_L6: gSPLight( w1, LIGHT_7 ); break; case G_MV_L7: gSPLight( w1, LIGHT_8 ); break; case G_MV_LOOKATX: gSPLookAt(w1, 0); break; case G_MV_LOOKATY: gSPLookAt(w1, 1); break; } }
void F3DCBFD_MoveMem( u32 w0, u32 w1 ) { u32 offset = _SHIFTR( w0, 8, 8 ) << 3; switch (_SHIFTR( w0, 0, 8 )) { case F3DCBFD_MV_NORMAL: gSPSetVertexColorBase( w1 ); break; case G_MV_LIGHT: if (offset >= 96) { gSPLight( w1, (offset - 48) / 48 ); } break; default: F3DEX2_MoveMem( w0, w1 ); break; } }