aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-04-09 11:37:53 -0400
committer浅倉麗子2020-04-09 11:37:53 -0400
commit90e8f485acd64657855920a5c6679b98d0cf6802 (patch)
treef9481b6b8d7c2eb0398c8b3d596e547d9857b2bd
parentEnable "display area settings" in original mode (diff)
downloadsharpscale-90e8f485acd64657855920a5c6679b98d0cf6802.tar.gz
Centre framebuffer when cropping
-rw-r--r--main.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/main.c b/main.c
index 967aabe..1f02a57 100644
--- a/main.c
+++ b/main.c
@@ -148,27 +148,30 @@ static int sceIftuSetInputFrameBuffer_hook(int plane, SceIftuPlaneState *state,
int head_w = head_data[cur_head_idx].head_w;
int head_h = head_data[cur_head_idx].head_h;
+ int scale = 0;
+
if (ss_config.mode == SHARPSCALE_MODE_INTEGER) {
- int scale = MIN(4, MIN(head_w / fb_w, head_h / (fb_h - 16)));
+ scale = MIN(4, MIN(head_w / fb_w, head_h / (fb_h - 16)));
+ } else if (ss_config.mode == SHARPSCALE_MODE_REAL) {
+ scale = (fb_w <= head_w && (fb_h - 16) <= head_h) ? 1 : 0;
+ }
- if (scale > 0) {
- state->src_w = 0x10000 / scale;
- state->src_h = 0x10000 / scale;
+ if (scale > 0) {
+ state->src_w = 0x10000 / scale;
+ state->src_h = 0x10000 / scale;
- state->dst_x = (head_w - fb_w * scale) / 2;
- state->dst_y = (fb_h * scale <= head_h)
- ? (head_h - fb_h * scale) / 2
- : 0;
- }
- } else if (ss_config.mode == SHARPSCALE_MODE_REAL) {
- if (fb_w <= head_w && (fb_h - 16) <= head_h) {
- state->src_w = 0x10000;
- state->src_h = 0x10000;
-
- state->dst_x = (head_w - fb_w) / 2;
- state->dst_y = (fb_h <= head_h)
- ? (head_h - fb_h) / 2
- : 0;
+ fb_w *= scale;
+ fb_h *= scale;
+
+ state->src_x = 0;
+ state->dst_x = (head_w - fb_w) / 2;
+
+ if (fb_h <= head_h) {
+ state->src_y = 0;
+ state->dst_y = (head_h - fb_h) / 2;
+ } else {
+ state->src_y = MIN(0x400 - 1, (fb_h - head_h) * 0x100 / (2 * scale));
+ state->dst_y = 0;
}
}