port: implement fisheye

This commit is contained in:
fgsfds committed 2023-10-16 22:38:44 +02:00
1 parent b78a5ee064
commit 79f8a35c33
9 files changed
+51 -15

No files matched your search

+36
View File
@@ -563,6 +563,24 @@ f32 bview0f142d74(s32 arg0, f32 arg1, f32 arg2, f32 arg3)
return result;
}
#ifndef PLATFORM_N64
static inline Gfx *bviewDrawFisheyeLine(Gfx *gdl, s32 viewleft, s32 viewwidth, s32 y, f32 scale)
{
const f32 orighalfw = viewwidth * 0.5f;
const f32 xcenter = viewleft + orighalfw;
const f32 halfw = orighalfw * scale;
const s32 left = xcenter - halfw;
const s32 right = xcenter + halfw;
gSPImageRectangleEXT(gdl++,
left << 2, y << 2, viewleft, y,
right << 2, (y + 1) << 2, viewleft + viewwidth, y + 1,
0, videoGetNativeWidth(), videoGetNativeHeight());
return gdl;
}
#endif
/**
* Draw the fisheye curved effect when using an eyespy.
*
@@ -677,6 +695,12 @@ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 sta
gdl = bviewPrepareStaticRgba16(gdl, colour, alpha);
#ifndef PLATFORM_N64
// make a copy of the current back buffer contents that we will be using as a texture
gDPCopyFramebufferEXT(gdl++, g_PrevFrameFb, 0, 0, 0, G_ON);
gDPSetFramebufferTextureEXT(gdl++, 0, 0, 0, g_PrevFrameFb);
#endif
if (starting) {
for (i = viewtop; i < viewtop + viewheight; i++) {
if (i % 2) {
@@ -684,7 +708,11 @@ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 sta
gDPSetEnvColorViaWord(gdl++, (colour & 0xffffff00) | (spec & 0xff));
tmp = bview0f142d74(s2, f26, halfheight, sqhalfheight) * startupfrac;
#ifdef PLATFORM_N64
gdl = bviewCopyPixels(gdl, fb, i, 5, i, tmp, viewleft, viewwidth);
#else
gdl = bviewDrawFisheyeLine(gdl, viewleft, viewwidth, i, tmp);
#endif
}
}
@@ -710,13 +738,21 @@ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 sta
}
tmp = bview0f142d74(s2, f26, halfheight, sqhalfheight) * f22;
#ifdef PLATFORM_N64
gdl = bviewCopyPixels(gdl, fb, i, 5, i, tmp, viewleft, viewwidth);
#else
gdl = bviewDrawFisheyeLine(gdl, viewleft, viewwidth, i, tmp);
#endif
if (hit == EYESPYHIT_DAMAGE) {
gDPSetEnvColorViaWord(gdl++, 0xddaaaa99);
tmp = bview0f142d74(s2, f26, halfheight, sqhalfheight) * 1.03f;
#ifdef PLATFORM_N64
gdl = bviewCopyPixels(gdl, fb, i, 5, i, tmp, viewleft, viewwidth);
#else
gdl = bviewDrawFisheyeLine(gdl, viewleft, viewwidth, i, tmp);
#endif
}
s2 += s3;
+1 -1
View File
@@ -6426,7 +6426,7 @@ Gfx *chrRenderCloak(Gfx *gdl, struct prop *chrprop, struct prop *thisprop)
gDPPipeSync(gdl++);
gSPTextureRectangle(gdl++, 0, 0, 60, 60, G_TX_RENDERTILE, 0, 0, 4096, 1024);
#else
gDPCopyFramebufferEXT(gdl++, var8009ccc0[index], 0, uls, ult);
gDPCopyFramebufferEXT(gdl++, var8009ccc0[index], 0, uls, ult, G_ON);
gDPSetTile(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b,
((((lrs - uls + 1) * G_IM_SIZ_16b_BYTES)+7)>>3), 0, 0, 0,
G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD,
+3 -2
View File
@@ -213,12 +213,13 @@
#define gDPSetFramebufferTextureEXT(pkt, f, s, w, i) \
gSetImage(pkt, G_SETTIMG_FB_EXT, f, s, w, i)
#define gDPCopyFramebufferEXT(pkt, dst, src, uls, ult) \
#define gDPCopyFramebufferEXT(pkt, dst, src, uls, ult, back) \
{ \
Gfx *_g = (Gfx *)(pkt); \
\
_g->words.w0 = _SHIFTL(G_COPYFB_EXT, 24, 8) \
| _SHIFTL(dst, 12, 12) | _SHIFTL(src, 0, 12); \
| _SHIFTL(dst, 11, 11) | _SHIFTL(src, 0, 11) | \
_SHIFTL(back, 22, 1); \
_g->words.w1 = _SHIFTL(uls, 16, 16) | _SHIFTL(ult, 0, 16); \
}