forked from Ports/perfect_dark
port: implement NVG/IRG color modulation using the grayscale command
still missing the funky overlays
This commit is contained in:
1 parent
143d2a107a
commit
a85a18774f
5 files changed
+56
-1
No files matched your search
@@ -2398,6 +2398,9 @@ static void gfx_run_dl(Gfx* cmd) {
|
||||
rdp.textures_changed[0] = false;
|
||||
rdp.textures_changed[1] = false;
|
||||
break;
|
||||
case G_SETGRAYSCALE_EXT:
|
||||
rdp.grayscale = cmd->words.w1;
|
||||
break;
|
||||
case G_LOADBLOCK:
|
||||
gfx_dp_load_block(C1(24, 3), C0(12, 12), C0(0, 12), C1(12, 12), C1(0, 12));
|
||||
break;
|
||||
@@ -2426,6 +2429,9 @@ static void gfx_run_dl(Gfx* cmd) {
|
||||
case G_SETFILLCOLOR:
|
||||
gfx_dp_set_fill_color(cmd->words.w1);
|
||||
break;
|
||||
case G_SETINTENSITY_EXT:
|
||||
gfx_dp_set_grayscale_color(C1(24, 8), C1(16, 8), C1(8, 8), C1(0, 8));
|
||||
break;
|
||||
case G_SETCOMBINE:
|
||||
gfx_dp_set_combine_mode(color_comb(C0(20, 4), C1(28, 4), C0(15, 5), C1(15, 3)),
|
||||
alpha_comb(C0(12, 3), C1(12, 3), C0(9, 3), C1(9, 3)),
|
||||
|
||||
@@ -1185,6 +1185,9 @@ Gfx *lvRender(Gfx *gdl)
|
||||
}
|
||||
|
||||
gdl = viRenderViewportEdges(gdl);
|
||||
#ifndef PLATFORM_N64
|
||||
gdl = playerSetVisionMode(gdl);
|
||||
#endif
|
||||
gdl = skyRender(gdl);
|
||||
bgTick();
|
||||
lightsTick();
|
||||
@@ -1306,6 +1309,7 @@ Gfx *lvRender(Gfx *gdl)
|
||||
}
|
||||
|
||||
propsTestForPickup();
|
||||
|
||||
gdl = bgRender(gdl);
|
||||
chr0f028498(var80075d68 == 15 || g_AnimHostEnabled);
|
||||
gdl = propsRenderBeams(gdl);
|
||||
|
||||
@@ -4484,6 +4484,28 @@ Gfx *playerRenderShield(Gfx *gdl)
|
||||
return gdl;
|
||||
}
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
Gfx *playerSetVisionMode(Gfx *gdl)
|
||||
{
|
||||
if (g_Vars.currentplayer) {
|
||||
if (g_Vars.currentplayer->isdead == false
|
||||
&& g_InCutscene == 0
|
||||
&& (!g_Vars.currentplayer->eyespy || (g_Vars.currentplayer->eyespy && !g_Vars.currentplayer->eyespy->active))
|
||||
&& ((g_Vars.currentplayer->devicesactive & ~g_Vars.currentplayer->devicesinhibit) & DEVICE_NIGHTVISION)) {
|
||||
gDPGrayscaleEXT(gdl++, G_ON);
|
||||
gDPSetGrayscaleColorEXT(gdl++, 0x00, 0xFF, 0x00, 0xFF);
|
||||
} else if (g_Vars.currentplayer->isdead == false
|
||||
&& g_InCutscene == 0
|
||||
&& (!g_Vars.currentplayer->eyespy || (g_Vars.currentplayer->eyespy && !g_Vars.currentplayer->eyespy->active))
|
||||
&& ((g_Vars.currentplayer->devicesactive & ~g_Vars.currentplayer->devicesinhibit) & DEVICE_IRSCANNER)) {
|
||||
gDPGrayscaleEXT(gdl++, G_ON);
|
||||
gDPSetGrayscaleColorEXT(gdl++, 0xFF, 0x00, 0x00, 0xFF);
|
||||
}
|
||||
}
|
||||
return gdl;
|
||||
}
|
||||
#endif
|
||||
|
||||
Gfx *playerRenderHud(Gfx *gdl)
|
||||
{
|
||||
if (g_Vars.currentplayer->cameramode == CAMERAMODE_THIRDPERSON) {
|
||||
@@ -4547,12 +4569,20 @@ Gfx *playerRenderHud(Gfx *gdl)
|
||||
&& ((g_Vars.currentplayer->devicesactive & ~g_Vars.currentplayer->devicesinhibit) & DEVICE_NIGHTVISION)) {
|
||||
gdl = bviewDrawNvLens(gdl);
|
||||
gdl = bviewDrawNvBinoculars(gdl);
|
||||
#ifndef PLATFORM_N64
|
||||
// turn off "greenscale"
|
||||
gDPGrayscaleEXT(gdl++, G_OFF);
|
||||
#endif
|
||||
} else if (g_Vars.currentplayer->isdead == false
|
||||
&& g_InCutscene == 0
|
||||
&& (!g_Vars.currentplayer->eyespy || (g_Vars.currentplayer->eyespy && !g_Vars.currentplayer->eyespy->active))
|
||||
&& ((g_Vars.currentplayer->devicesactive & ~g_Vars.currentplayer->devicesinhibit) & DEVICE_IRSCANNER)) {
|
||||
gdl = bviewDrawIrLens(gdl);
|
||||
gdl = bviewDrawIrBinoculars(gdl);
|
||||
#ifndef PLATFORM_N64
|
||||
// turn off "redscale"
|
||||
gDPGrayscaleEXT(gdl++, G_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (g_Vars.currentplayer->eyesshutfrac > 0) {
|
||||
|
||||
@@ -106,5 +106,8 @@ void playerSetCamPropertiesWithRoom(struct coord *pos, struct coord *up, struct
|
||||
void playerSetCamPropertiesWithoutRoom(struct coord *pos, struct coord *up, struct coord *look, s32 room);
|
||||
void playerSetCamProperties(struct coord *pos, struct coord *up, struct coord *look, s32 room);
|
||||
void playerClearMemCamRoom(void);
|
||||
#ifndef PLATFORM_N64
|
||||
Gfx *playerSetVisionMode(Gfx *gdl);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+13
-1
@@ -185,9 +185,11 @@
|
||||
/* Extended RDP commands */
|
||||
|
||||
#define G_SETFB_EXT 0x21
|
||||
#define G_COPYFB_EXT 0x41
|
||||
#define G_SETTIMG_FB_EXT 0x23
|
||||
#define G_INVALTEXCACHE_EXT 0x34
|
||||
#define G_SETGRAYSCALE_EXT 0x39
|
||||
#define G_SETINTENSITY_EXT 0x40
|
||||
#define G_COPYFB_EXT 0x41
|
||||
|
||||
/* Extended RDP command macros */
|
||||
|
||||
@@ -214,6 +216,16 @@
|
||||
_g->words.w1 = (uintptr_t)(addr); \
|
||||
}
|
||||
|
||||
#define gDPGrayscaleEXT(pkt, state) \
|
||||
{ \
|
||||
Gfx* _g = (Gfx*)(pkt); \
|
||||
\
|
||||
_g->words.w0 = _SHIFTL(G_SETGRAYSCALE_EXT, 24, 8); \
|
||||
_g->words.w1 = state; \
|
||||
}
|
||||
|
||||
#define gDPSetGrayscaleColorEXT(pkt, r, g, b, lerp) DPRGBColor(pkt, G_SETINTENSITY_EXT, r, g, b, lerp)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user