aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-04-08 14:00:40 -0400
committer浅倉麗子2020-04-08 14:00:40 -0400
commitadbfc38c5d497e37de7a75b76885f85d28141b49 (patch)
treef1c3b84d156ebb44307fd522cd7b74379bfef298
parentAdd readme (diff)
downloadsharpscale-adbfc38c5d497e37de7a75b76885f85d28141b49.tar.gz
Limit Iftu scaling to 4x
Fixes a bug where PS1 games with very small framebuffers may attempt to scale more than 4x in integer mode, which produces a black screen.
-rw-r--r--main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/main.c b/main.c
index 57dbc97..72f9cda 100644
--- a/main.c
+++ b/main.c
@@ -37,6 +37,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
if ((x) < 0) { goto fail; }\
} while (0)
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+
__attribute__ ((__format__ (__printf__, 1, 2)))
static void LOG(const char *fmt, ...) {
(void)fmt;
@@ -147,9 +149,7 @@ static int sceIftuSetInputFrameBuffer_hook(int plane, SceIftuPlaneState *state,
int head_h = head_data[cur_head_idx].head_h;
if (ss_config.mode == SHARPSCALE_MODE_INTEGER) {
- int scale_w = head_w / fb_w;
- int scale_h = head_h / (fb_h - 16);
- int scale = (scale_w < scale_h) ? scale_w : scale_h;
+ int scale = MIN(4, MIN(head_w / fb_w, head_h / (fb_h - 16)));
if (scale > 0) {
state->src_w = 0x10000 / scale;