Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Actor_DrawLensActors(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** invisibleActors) {
- Actor** invisibleActor;
- GraphicsContext* gfxCtx;
- s32 i;
- gfxCtx = globalCtx->state.gfxCtx;
- OPEN_DISPS(gfxCtx, "../z_actor.c", 6197);
- gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ START", 0); // "Magic lens START"
- gDPPipeSync(POLY_XLU_DISP++);
- if (globalCtx->roomCtx.curRoom.showInvisActors == 0) {
- // Update both the color frame buffer and the z-buffer
- gDPSetOtherMode(POLY_XLU_DISP++,
- G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
- G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
- G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | G_RM_CLD_SURF | G_RM_CLD_SURF2);
- gDPSetCombineMode(POLY_XLU_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
- gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 0, 255);
- // the z-buffer will later only allow drawing inside the lens circle
- } else {
- // Update the z-buffer but leave the frame buffer untouched
- gDPSetOtherMode(POLY_XLU_DISP++,
- G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
- G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
- G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL |
- GBL_c1(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA) |
- GBL_c2(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA));
- // inverts the mask image, which initially is 0 inner and 74 outer,
- // by setting the combiner to draw 74 - image instead of the image
- gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0,
- PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0);
- gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 74, 74, 74, 74);
- // the z-buffer will later only allow drawing outside the lens circle
- }
- // Since `G_ZS_PRIM` is used in the other mode set above (in both branches), the depth value will be 0 as set here
- // for further drawing. 0 is the closest depth value, meaning that for a pixel corresponding to such a depth value
- // the z-buffer will consider any geometry drawn to that pixel to be behind something and the pixel will stay
- // unchanged.
- gDPSetPrimDepth(POLY_XLU_DISP++, 0, 0);
- // 0 is effectively put into the z-buffer by `Actor_DrawLensOverlay` where the mask is not fully transparent
- // (alpha not 0), which can be inner or outer the lens circle depending on the branch just above.
- Actor_DrawLensOverlay(gfxCtx);
- // "Magic lens invisible Actor display START"
- gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないActor表示 START", numInvisibleActors);
- invisibleActor = &invisibleActors[0];
- for (i = 0; i < numInvisibleActors; i++) {
- // "Magic lens invisible Actor display"
- gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないActor表示", i);
- Actor_Draw(globalCtx, *(invisibleActor++));
- }
- // "Magic lens invisible Actor display END"
- gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないActor表示 END", numInvisibleActors);
- if (globalCtx->roomCtx.curRoom.showInvisActors != 0) {
- // visually draw the lens mask to the framebuffer and not just the z-buffer,
- // the same way the `showInvisActors == 0` branch above does
- gDPNoOpString(POLY_OPA_DISP++, "青い眼鏡(外側)", 0); // "Blue spectacles (exterior)"
- gDPPipeSync(POLY_XLU_DISP++);
- gDPSetOtherMode(POLY_XLU_DISP++,
- G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
- G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
- G_AC_THRESHOLD | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2);
- gDPSetCombineMode(POLY_XLU_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
- gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 0, 255);
- Actor_DrawLensOverlay(gfxCtx);
- gDPNoOpString(POLY_OPA_DISP++, "青い眼鏡(外側)", 1); // "Blue spectacles (exterior)"
- }
- gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ END", 0); // "Magic lens END"
- CLOSE_DISPS(gfxCtx, "../z_actor.c", 6284);
- }
Add Comment
Please, Sign In to add comment