aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-04-28 13:50:48 -0400
committer浅倉麗子2020-04-28 13:50:48 -0400
commita3a3936364182140082fa0b8df9a5232c9e6064c (patch)
tree4c41ed30ab3c0fc3fbfeb334fe0170cfbc9132cd
parentAdd UNHOOK function (diff)
downloadsharpscale-a3a3936364182140082fa0b8df9a5232c9e6064c.tar.gz
Add "Enable Full HD" featurev1.3.0
Allow the PSTV to use HD framebuffer sizes: 1280x720 1440x1080 1920x1080
-rw-r--r--README.md5
-rw-r--r--config-app/CMakeLists.txt2
-rw-r--r--config-app/main.c12
-rw-r--r--config.c6
-rw-r--r--main.c69
-rw-r--r--sharpscale.h1
-rw-r--r--sharpscale_internal.h8
7 files changed, 94 insertions, 9 deletions
diff --git a/README.md b/README.md
index 17653ec..31355af 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,11 @@ Scaling and PS1 aspect ratio will not apply when
- On: system default
- Off: nearest neighbour
+#### Enable Full HD
+
+- On: allow framebuffers of sizes 1280x720, 1440x1080, and 1920x1080 to be submitted to the kernel
+- Off: system default
+
## Installation
Install under `*KERNEL` of your taiHEN config.
diff --git a/config-app/CMakeLists.txt b/config-app/CMakeLists.txt
index 9e07e26..a85d114 100644
--- a/config-app/CMakeLists.txt
+++ b/config-app/CMakeLists.txt
@@ -38,6 +38,6 @@ dolce_create_vpk(${PROJECT_NAME}.vpk
AKRK00005
"${SELF}"
NAME "Sharpscale Config"
- VERSION 01.00
+ VERSION 01.01
FILE icon0.png sce_sys/icon0.png
)
diff --git a/config-app/main.c b/config-app/main.c
index 7ca8a27..93e5311 100644
--- a/config-app/main.c
+++ b/config-app/main.c
@@ -81,10 +81,10 @@ int main(int argc, char **argv) { (void)argc; (void)argv;
int btns = ~last_ctrl.buttons & ctrl.buttons;
if (btns & SCE_CTRL_UP) {
- ui_row = (ui_row - 1 + 3) % 3;
+ ui_row = (ui_row - 1 + 4) % 4;
} else if (btns & SCE_CTRL_DOWN) {
- ui_row = (ui_row + 1) % 3;
+ ui_row = (ui_row + 1) % 4;
} else if ((btns & SCE_CTRL_LEFT) || (btns & SCE_CTRL_RIGHT)) {
int inc = (btns & SCE_CTRL_LEFT) ? -1 : 1;
@@ -95,6 +95,8 @@ int main(int argc, char **argv) { (void)argc; (void)argv;
config.psone_mode = (config.psone_mode + inc + 3) % 3;
} else if (ui_row == 2) {
config.bilinear = !config.bilinear;
+ } else if (ui_row == 3) {
+ config.full_hd = !config.full_hd;
}
SharpscaleSetConfig(&config);
@@ -135,6 +137,12 @@ int main(int argc, char **argv) { (void)argc; (void)argv;
draw_text(x_pos += 300, y_pos, text_blue(config.bilinear), "On");
draw_text(x_pos += 100, y_pos, text_blue(!config.bilinear), "Off");
+ x_pos = 50;
+ y_pos = line_height * 7;
+ draw_text(x_pos, y_pos, text_yellow(ui_row == 3), "Enable Full HD");
+ draw_text(x_pos += 300, y_pos, text_blue(config.full_hd), "On");
+ draw_text(x_pos += 100, y_pos, text_blue(!config.full_hd), "Off");
+
y_pos = line_height * 13;
draw_text_centre(y_pos, TEXT_BLACK, "CBPS Productions");
y_pos = line_height * 14;
diff --git a/config.c b/config.c
index 9ac78af..599c050 100644
--- a/config.c
+++ b/config.c
@@ -20,6 +20,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <psp2kern/io/stat.h>
#include <psp2kern/kernel/sysmem.h>
#include "config.h"
+#include "sharpscale_internal.h"
#define BASE_PATH "ur0:/data"
#define SS_BASE_PATH BASE_PATH"/sharpscale"
@@ -30,13 +31,15 @@ SharpscaleConfig ss_config;
static bool is_config_valid(SharpscaleConfig *config) {
return config->mode < SHARPSCALE_MODE_INVALID
&& config->psone_mode < SHARPSCALE_PSONE_MODE_INVALID
- && (config->bilinear == true || config->bilinear == false);
+ && (config->bilinear == true || config->bilinear == false)
+ && (config->full_hd == true || config->full_hd == false);
}
int reset_config(SharpscaleConfig *config) {
config->mode = SHARPSCALE_MODE_INTEGER;
config->psone_mode = SHARPSCALE_PSONE_MODE_4_3;
config->bilinear = false;
+ config->full_hd = false;
return 0;
}
@@ -87,6 +90,7 @@ int SharpscaleSetConfig(SharpscaleConfig *config) {
int ret = ksceKernelMemcpyUserToKernel(&kconfig, (uintptr_t)config, sizeof(kconfig));
if (ret < 0) { goto fail; }
if (!is_config_valid(&kconfig)) { goto fail; }
+ if (set_full_hd(kconfig.full_hd) < 0) { goto fail; }
memcpy(&ss_config, &kconfig, sizeof(ss_config));
return write_config(&ss_config);
diff --git a/main.c b/main.c
index 6f589ed..23ca501 100644
--- a/main.c
+++ b/main.c
@@ -32,8 +32,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <psp2kern/lowio/iftu.h>
#include <psp2kern/sblacmgr.h>
#include <taihen.h>
-#include "scedisplay.h"
#include "config.h"
+#include "scedisplay.h"
+#include "sharpscale_internal.h"
#define GLZ(x) do {\
if ((x) < 0) { goto fail; }\
@@ -66,10 +67,19 @@ static void LOG(const char *fmt, ...) {
#endif
}
+#define N_INJECT 5
+static SceUID inject_id[N_INJECT];
+
#define N_HOOK 3
static SceUID hook_id[N_HOOK];
static tai_hook_ref_t hook_ref[N_HOOK];
+static SceUID INJECT_DATA(int idx, int mod, int seg, int ofs, void *data, int size) {
+ inject_id[idx] = taiInjectDataForKernel(KERNEL_PID, mod, seg, ofs, data, size);
+ LOG("Injected %d UID %08X\n", idx, inject_id[idx]);
+ return inject_id[idx];
+}
+
static SceUID hook_import(int idx, char *mod, int libnid, int funcnid, void *func) {
hook_id[idx] = taiHookFunctionImportForKernel(KERNEL_PID, hook_ref+idx, mod, libnid, funcnid, func);
LOG("Hooked %d UID %08X\n", idx, hook_id[idx]);
@@ -86,6 +96,16 @@ static SceUID hook_offset(int idx, int mod, int ofs, void *func) {
#define HOOK_OFFSET(idx, mod, ofs, func)\
hook_offset(idx, mod, ofs, func##_hook)
+static int UNINJECT(int idx) {
+ int ret = 0;
+ if (inject_id[idx] >= 0) {
+ ret = taiInjectReleaseForKernel(inject_id[idx]);
+ LOG("Uninjected %d UID %08X\n", idx, inject_id[idx]);
+ inject_id[idx] = -1;
+ }
+ return ret;
+}
+
static int UNHOOK(int idx) {
int ret = 0;
if (hook_id[idx] >= 0) {
@@ -103,6 +123,8 @@ extern int module_get_offset(SceUID pid, SceUID modid, int segidx, size_t offset
extern SharpscaleConfig ss_config;
+static int scedisplay_uid = -1;
+
// SceDisplay_8100B000
static SceDisplayHead *head_data = 0;
@@ -210,12 +232,46 @@ done:
return TAI_CONTINUE(int, hook_ref[2], plane, state, bilinear, sync_mode);
}
+int set_full_hd(bool enable) {
+ static int enabled = 0;
+ int ret = 0;
+
+ if (enable) {
+ if (!enabled) {
+ // authority ID check
+ char movw_r0_0[] = "\x40\xf2\x00\x00";
+ GLZ(ret = INJECT_DATA(0, scedisplay_uid, 0, 0x40A6, movw_r0_0, 4));
+ GLZ(ret = INJECT_DATA(1, scedisplay_uid, 0, 0x434E, movw_r0_0, 4));
+ GLZ(ret = INJECT_DATA(2, scedisplay_uid, 0, 0x46D2, movw_r0_0, 4));
+ GLZ(ret = INJECT_DATA(3, scedisplay_uid, 0, 0x47FC, movw_r0_0, 4));
+
+ // framebuffer flags check
+ char cmpw_r3_r3[] = "\xb3\xeb\x03\x0f";
+ GLZ(ret = INJECT_DATA(4, scedisplay_uid, 0, 0x4812, cmpw_r3_r3, 4));
+
+ enabled = 1;
+ ret = 0;
+ }
+ goto done;
+ } else if (!enabled) {
+ goto done;
+ }
+
+fail:
+ for (int i = 0; i < 5; i++) { UNINJECT(i); }
+ enabled = 0;
+done:
+ return ret;
+}
+
static void startup(void) {
+ memset(inject_id, 0xFF, sizeof(inject_id));
memset(hook_id, 0xFF, sizeof(hook_id));
memset(hook_ref, 0xFF, sizeof(hook_ref));
}
static void cleanup(void) {
+ for (int i = 0; i < N_INJECT; i++) { UNINJECT(i); }
for (int i = 0; i < N_HOOK; i++) { UNHOOK(i); }
}
@@ -230,14 +286,17 @@ int module_start(SceSize argc, const void *argv) { (void)argc; (void)argv;
tai_module_info_t minfo;
minfo.size = sizeof(minfo);
GLZ(taiGetModuleInfoForKernel(KERNEL_PID, "SceDisplay", &minfo));
+ scedisplay_uid = minfo.modid;
- GLZ(GET_OFFSET(minfo.modid, 1, 0x000, &head_data));
- GLZ(GET_OFFSET(minfo.modid, 1, 0x1D4, &primary_head_idx));
+ GLZ(GET_OFFSET(scedisplay_uid, 1, 0x000, &head_data));
+ GLZ(GET_OFFSET(scedisplay_uid, 1, 0x1D4, &primary_head_idx));
- GLZ(HOOK_OFFSET(0, minfo.modid, 0x2CC, prepare_set_fb));
- GLZ(HOOK_OFFSET(1, minfo.modid, 0x004, prepare_fb_compat));
+ GLZ(HOOK_OFFSET(0, scedisplay_uid, 0x2CC, prepare_set_fb));
+ GLZ(HOOK_OFFSET(1, scedisplay_uid, 0x004, prepare_fb_compat));
GLZ(HOOK_IMPORT(2, "SceDisplay", 0xCAFCFE50, 0x7CE0C4DA, sceIftuSetInputFrameBuffer));
+ GLZ(set_full_hd(ss_config.full_hd));
+
return SCE_KERNEL_START_SUCCESS;
fail:
diff --git a/sharpscale.h b/sharpscale.h
index e538f28..49da549 100644
--- a/sharpscale.h
+++ b/sharpscale.h
@@ -22,6 +22,7 @@ typedef struct SharpscaleConfig {
SharpscaleMode mode;
SharpscalePSOneMode psone_mode;
bool bilinear;
+ bool full_hd;
} SharpscaleConfig;
int SharpscaleGetConfig(SharpscaleConfig *config);
diff --git a/sharpscale_internal.h b/sharpscale_internal.h
new file mode 100644
index 0000000..cc56b51
--- /dev/null
+++ b/sharpscale_internal.h
@@ -0,0 +1,8 @@
+#ifndef SHARPSCALE_INTERNAL_H
+#define SHARPSCALE_INTERNAL_H
+
+#include <stdbool.h>
+
+int set_full_hd(bool enable);
+
+#endif