diff --git a/.gitignore b/.gitignore index d4f7f8338d..700122d992 100644 --- a/.gitignore +++ b/.gitignore @@ -97,6 +97,7 @@ asciifont_atlas.zim.png ppge_atlas.zim.png local.properties r.sh +Windows/compileData* # For vim *.swp @@ -124,4 +125,4 @@ debian/ppsspp/ CMakeFiles # Clangd -.cache/ \ No newline at end of file +.cache/ diff --git a/Common/TimeUtil.cpp b/Common/TimeUtil.cpp index 99d3288d99..253dbcb8e3 100644 --- a/Common/TimeUtil.cpp +++ b/Common/TimeUtil.cpp @@ -19,6 +19,8 @@ #endif #include +// TODO: https://github.com/floooh/sokol/blob/9a6237fcdf213e6da48e4f9201f144bcb2dcb46f/sokol_time.h#L229-L248 + static double curtime = 0; #ifdef _WIN32 diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 7a27543ab4..f1be3b94fe 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -80,6 +80,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "DisableRangeCulling", &flags_.DisableRangeCulling); CheckSetting(iniFile, gameID, "MpegAvcWarmUp", &flags_.MpegAvcWarmUp); CheckSetting(iniFile, gameID, "BlueToAlpha", &flags_.BlueToAlpha); + CheckSetting(iniFile, gameID, "CenteredLines", &flags_.CenteredLines); } void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index fd3e76d743..37173adc6d 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -79,6 +79,7 @@ struct CompatFlags { bool DisableRangeCulling; bool MpegAvcWarmUp; bool BlueToAlpha; + bool CenteredLines; }; class IniFile; diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index aed7963268..98b5adc079 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -758,8 +758,8 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, u16 *newInds = inds + vertexCount; u16 *indsOut = newInds; - float dx = 1.0f * gstate_c.vpWidthScale * (1.0f / gstate.getViewportXScale()); - float dy = 1.0f * gstate_c.vpHeightScale * (1.0f / gstate.getViewportYScale()); + float dx = 1.0f * gstate_c.vpWidthScale * (1.0f / fabsf(gstate.getViewportXScale())); + float dy = 1.0f * gstate_c.vpHeightScale * (1.0f / fabsf(gstate.getViewportYScale())); float du = 1.0f / gstate_c.curTextureWidth; float dv = 1.0f / gstate_c.curTextureHeight; @@ -769,57 +769,105 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, } maxIndex = 4 * (vertexCount / 2); - for (int i = 0; i < vertexCount; i += 2) { - const TransformedVertex &transVtx1 = transformed[indsIn[i + 0]]; - const TransformedVertex &transVtx2 = transformed[indsIn[i + 1]]; - const TransformedVertex &transVtxT = transVtx1.y <= transVtx2.y ? transVtx1 : transVtx2; - const TransformedVertex &transVtxB = transVtx1.y <= transVtx2.y ? transVtx2 : transVtx1; - const TransformedVertex &transVtxL = transVtx1.x <= transVtx2.x ? transVtx1 : transVtx2; - const TransformedVertex &transVtxR = transVtx1.x <= transVtx2.x ? transVtx2 : transVtx1; + if (PSP_CoreParameter().compat.flags().CenteredLines) { + // Lines meant to be pretty in 3D like in Echochrome. - // Sort the points so our perpendicular will bias the right direction. - const TransformedVertex &transVtxTL = transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x ? transVtxT : transVtxB; - const TransformedVertex &transVtxBL = transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x ? transVtxB : transVtxT; + // We expand them in both directions for symmetry, so we need to halve the expansion. + dx *= 0.5f; + dy *= 0.5f; - // Okay, let's calculate the perpendicular. - float horizontal = transVtxTL.x - transVtxBL.x; - float vertical = transVtxTL.y - transVtxBL.y; - Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized(); + for (int i = 0; i < vertexCount; i += 2) { + const TransformedVertex &transVtx1 = transformed[indsIn[i + 0]]; + const TransformedVertex &transVtx2 = transformed[indsIn[i + 1]]; - // bottom right - trans[0] = transVtxBL; - trans[0].x += addWidth.x * dx; - trans[0].y += addWidth.y * dy; - trans[0].u += addWidth.x * du; - trans[0].v += addWidth.y * dv; + // Okay, let's calculate the perpendicular. + float horizontal = transVtx2.x - transVtx1.x; + float vertical = transVtx2.y - transVtx1.y; + Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized(); - // top right - trans[1] = transVtxTL; - trans[1].x += addWidth.x * dx; - trans[1].y += addWidth.y * dy; - trans[1].u += addWidth.x * du; - trans[1].v += addWidth.y * dv; + float xoff = addWidth.x * dx; + float yoff = addWidth.y * dy; - // top left - trans[2] = transVtxTL; + // bottom right + trans[0].CopyFromWithOffset(transVtx2, xoff, yoff); + // top right + trans[1].CopyFromWithOffset(transVtx1, xoff, yoff); + // top left + trans[2].CopyFromWithOffset(transVtx1, -xoff, -yoff); + // bottom left + trans[3].CopyFromWithOffset(transVtx2, -xoff, -yoff); - // bottom left - trans[3] = transVtxBL; + // Triangle: BR-TR-TL + indsOut[0] = i * 2 + 0; + indsOut[1] = i * 2 + 1; + indsOut[2] = i * 2 + 2; + // Triangle: BL-BR-TL + indsOut[3] = i * 2 + 3; + indsOut[4] = i * 2 + 0; + indsOut[5] = i * 2 + 2; + trans += 4; + indsOut += 6; - // Triangle: BR-TR-TL - indsOut[0] = i * 2 + 0; - indsOut[1] = i * 2 + 1; - indsOut[2] = i * 2 + 2; - // Triangle: BL-BR-TL - indsOut[3] = i * 2 + 3; - indsOut[4] = i * 2 + 0; - indsOut[5] = i * 2 + 2; - trans += 4; - indsOut += 6; + numTrans += 6; + } + } else { + // Lines meant to be as closely compatible with upscaled 2D drawing as possible. + // We use this as default. - numTrans += 6; + for (int i = 0; i < vertexCount; i += 2) { + const TransformedVertex &transVtx1 = transformed[indsIn[i + 0]]; + const TransformedVertex &transVtx2 = transformed[indsIn[i + 1]]; + + const TransformedVertex &transVtxT = transVtx1.y <= transVtx2.y ? transVtx1 : transVtx2; + const TransformedVertex &transVtxB = transVtx1.y <= transVtx2.y ? transVtx2 : transVtx1; + const TransformedVertex &transVtxL = transVtx1.x <= transVtx2.x ? transVtx1 : transVtx2; + const TransformedVertex &transVtxR = transVtx1.x <= transVtx2.x ? transVtx2 : transVtx1; + + // Sort the points so our perpendicular will bias the right direction. + const TransformedVertex &transVtxTL = (transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x) ? transVtxT : transVtxB; + const TransformedVertex &transVtxBL = (transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x) ? transVtxB : transVtxT; + + // Okay, let's calculate the perpendicular. + float horizontal = transVtxTL.x - transVtxBL.x; + float vertical = transVtxTL.y - transVtxBL.y; + Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized(); + + // bottom right + trans[0] = transVtxBL; + trans[0].x += addWidth.x * dx; + trans[0].y += addWidth.y * dy; + trans[0].u += addWidth.x * du; + trans[0].v += addWidth.y * dv; + + // top right + trans[1] = transVtxTL; + trans[1].x += addWidth.x * dx; + trans[1].y += addWidth.y * dy; + trans[1].u += addWidth.x * du; + trans[1].v += addWidth.y * dv; + + // top left + trans[2] = transVtxTL; + + // bottom left + trans[3] = transVtxBL; + + // Triangle: BR-TR-TL + indsOut[0] = i * 2 + 0; + indsOut[1] = i * 2 + 1; + indsOut[2] = i * 2 + 2; + // Triangle: BL-BR-TL + indsOut[3] = i * 2 + 3; + indsOut[4] = i * 2 + 0; + indsOut[5] = i * 2 + 2; + trans += 4; + indsOut += 6; + + numTrans += 6; + } } + inds = newInds; } diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 880aceab25..623842853c 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -57,6 +57,13 @@ struct TransformedVertex { u8 color1[4]; // prelit u32 color1_32; }; + + + void CopyFromWithOffset(const TransformedVertex &other, float xoff, float yoff) { + this->x = other.x + xoff; + this->y = other.y + yoff; + memcpy(&this->z, &other.z, sizeof(*this) - sizeof(float) * 2); + } }; class GPUCommon : public GPUInterface, public GPUDebugInterface { diff --git a/GPU/Math3D.cpp b/GPU/Math3D.cpp index 83d31f1d33..7da413829f 100644 --- a/GPU/Math3D.cpp +++ b/GPU/Math3D.cpp @@ -23,6 +23,7 @@ namespace Math3D { template<> float Vec2::Length() const { + // Doubt this is worth it for a vec2 :/ #if defined(_M_SSE) float ret; __m128 xy = _mm_loadu_ps(&x); diff --git a/assets/compat.ini b/assets/compat.ini index fc17e3e9b1..7266ee4074 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1110,3 +1110,12 @@ ULUS10107 = true ULJM05101 = true ULES00724 = true ULJM05320 = true + +[CenteredLines] +# Echochrome looks better with these. Related: #15556 +UCES01011 = true +UCAS40197 = true +NPEG00006 = true +NPUG80135 = true + +UCES diff --git a/build.gradle b/build.gradle index 1f50b57b8d..bfad5c1419 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.3' + classpath 'com.android.tools.build:gradle:7.2.1' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 47be57e213..0b74ce0881 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,6 +3,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip android.useAndroidX=true android.enableJetifier=true