diff --git a/CHANGES b/CHANGES index fdabf6914..eb5f81cb4 100644 --- a/CHANGES +++ b/CHANGES @@ -60,6 +60,7 @@ Misc: - Qt: Enable -b for Boot BIOS menu option (fixes mgba.io/i/2074) - Qt: Add tile range selection to tile viewer (closes mgba.io/i/2455) - Windows: Attach to console if present + - Vita: Add bilinear filtering option (closes mgba.io/i/344) 0.9.3: (2021-12-17) Emulation fixes: diff --git a/src/platform/psp2/main.c b/src/platform/psp2/main.c index 2be4dafee..7ad4db343 100644 --- a/src/platform/psp2/main.c +++ b/src/platform/psp2/main.c @@ -171,6 +171,17 @@ int main() { }, .nStates = 4 }, + { + .title = "Screen filtering", + .data = GUI_V_S("filtering"), + .submenu = 0, + .state = 0, + .validStates = (const char*[]) { + "None", + "Bilinear", + }, + .nStates = 2 + }, { .title = "Camera", .data = GUI_V_S("camera"), diff --git a/src/platform/psp2/psp2-context.c b/src/platform/psp2/psp2-context.c index 05e7a2593..82f0c6029 100644 --- a/src/platform/psp2/psp2-context.c +++ b/src/platform/psp2/psp2-context.c @@ -56,6 +56,7 @@ static vita2d_texture* screenshot; static Thread audioThread; static bool interframeBlending = false; static bool sgbCrop = false; +static bool blurry = false; static struct mSceRotationSource { struct mRotationSource d; @@ -368,10 +369,8 @@ void mPSP2Setup(struct mGUIRunner* runner) { if (mCoreConfigGetUIntValue(&runner->config, "camera", &mode)) { camera.cam = mode; } - int fakeBool; - if (mCoreConfigGetIntValue(&runner->config, "sgb.borderCrop", &fakeBool)) { - sgbCrop = fakeBool; - } + mCoreConfigGetBoolValue(&runner->config, "sgb.borderCrop", &sgbCrop); + mCoreConfigGetBoolValue(&runner->config, "filtering", &blurry); } void mPSP2LoadROM(struct mGUIRunner* runner) { @@ -400,10 +399,7 @@ void mPSP2LoadROM(struct mGUIRunner* runner) { break; } - int fakeBool; - if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) { - interframeBlending = fakeBool; - } + mCoreConfigGetBoolValue(&runner->config, "interframeBlending", &interframeBlending); // Backcompat: Old versions of mGBA use an older binding system that has different mappings for L/R if (!sceKernelIsPSVitaTV()) { @@ -479,14 +475,9 @@ void mPSP2Unpaused(struct mGUIRunner* runner) { } } - int fakeBool; - if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) { - interframeBlending = fakeBool; - } - - if (mCoreConfigGetIntValue(&runner->config, "sgb.borderCrop", &fakeBool)) { - sgbCrop = fakeBool; - } + mCoreConfigGetBoolValue(&runner->config, "interframeBlending", &interframeBlending); + mCoreConfigGetBoolValue(&runner->config, "sgb.borderCrop", &sgbCrop); + mCoreConfigGetBoolValue(&runner->config, "filtering", &blurry); } void mPSP2Teardown(struct mGUIRunner* runner) { @@ -577,6 +568,21 @@ void _drawTex(vita2d_texture* t, unsigned width, unsigned height, bool faded, bo scaley = 544.0f / height; break; } + vita2d_texture_set_filters(t, SCE_GXM_TEXTURE_FILTER_LINEAR, + blurry ? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT); + if (blurry) { + // Needed to avoid bleed from off-screen portion of texture + unsigned i; + uint32_t* texpixels = vita2d_texture_get_datap(t); + if (width < 256) { + for (i = 0; i < height; ++i) { + texpixels[i * 256 + width] = texpixels[i * 256 + width - 1]; + } + } + if (height < vita2d_texture_get_height(t)) { + memcpy(&texpixels[height * 256], &texpixels[(height - 1) * 256], 1024); + } + } vita2d_draw_texture_tint_part_scale(t, (960.0f - w) / 2.0f, (544.0f - h) / 2.0f, 0, 0, width, height,