aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-06-13 22:16:19 -0400
committer浅倉麗子2020-06-13 22:16:19 -0400
commite567f72ff8ef6005a73548faf53318e9c491d5cb (patch)
tree6d5af422a489a9a92a54d1ec2645104a8e48360b
parentUpdate readme (diff)
downloadp4goldenhd-e567f72ff8ef6005a73548faf53318e9c491d5cb.tar.gz
Refactor compile-time options
-rw-r--r--CMakeLists.txt7
-rw-r--r--README.md5
-rw-r--r--main.c39
3 files changed, 31 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0618870..4e3fdab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,11 +75,10 @@ if(LOG_PRINTF)
target_compile_definitions("${ELF}" PRIVATE LOG_PRINTF)
endif()
-if(FB_FHD)
- target_compile_definitions("${ELF}" PRIVATE FB_FHD)
- message("Framebuffer set to 1920x1080")
+if(PATCH_MODE)
+ target_compile_definitions("${ELF}" PRIVATE PATCH_MODE=${PATCH_MODE})
else()
- message("Framebuffer set to 1280x720")
+ target_compile_definitions("${ELF}" PRIVATE PATCH_MODE=0)
endif()
target_link_options("${ELF}"
diff --git a/README.md b/README.md
index c62e349..f95852e 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,10 @@ Dependencies:
- [Terminus font](http://terminus-font.sourceforge.net)
- [taiHEN](https://git.shotatoshounenwachigau.moe/vita/taihen)
-To build for 1920x1080 mode, pass `-DFB_FHD=1` when invoking `cmake`.
+Define `PATCH_MODE` when building:
+
+- `0` 1280x720
+- `1` 1920x1080
## Contributing
diff --git a/main.c b/main.c
index 2040874..aa41cb2 100644
--- a/main.c
+++ b/main.c
@@ -36,14 +36,21 @@ extern int font_sfn_len;
#define P4G_MOD_NAME "XRD654_libgmq_MASTER_INSTA"
#define P4G_JP_NID 0x8C503A79
-#ifdef FB_FHD
+#define MODE_720 0
+#define MODE_1080 1
+
+#if PATCH_MODE == MODE_720
+ #pragma message "Compiling 1280x720"
+ #define FB_PITCH 1280
+ #define FB_WIDTH 1280
+ #define FB_HEIGHT 720
+#elif PATCH_MODE == MODE_1080
+ #pragma message "Compiling 1920x1080"
#define FB_PITCH 1920
#define FB_WIDTH 1920
#define FB_HEIGHT 1080
#else
- #define FB_PITCH 1280
- #define FB_WIDTH 1280
- #define FB_HEIGHT 720
+ #pragma GCC error "Invalid PATCH_MODE"
#endif
#define GLZ(x) do {\
@@ -170,7 +177,7 @@ static int sceGxmSetUniformDataF_hook(
uniformBuffer, parameter, componentOffset, componentCount, sourceData);
}
-#ifdef FB_FHD
+#if PATCH_MODE == MODE_1080
static SceUID sceKernelAllocMemBlock_hook(char *name, int type, int size, void *opt) {
// Non-JP versions allocate memory differently when decoding pre-rendered videos.
@@ -202,7 +209,7 @@ static int sceAvcdecDeleteDecoder_hook(void *ctrl) {
return TAI_NEXT(sceAvcdecDeleteDecoder_hook, hook_ref[4], ctrl);
}
-#endif // ifdef FB_FHD
+#endif
static void startup(void) {
sceClibMemset(inject_id, 0xFF, sizeof(inject_id));
@@ -280,16 +287,12 @@ int module_start(SceSize argc, const void *argv) { (void)argc; (void)argv;
p4g_info->height = (float)FB_HEIGHT;
p4g_info->pitch = FB_PITCH;
- // setup fnblit
- fnblit_set_font(font_sfn);
- fnblit_set_fg(0xFFFFFFFF);
- fnblit_set_bg(0x00000000);
-
- // hooks
- GLZ(HOOK_IMPORT(0, P4G_MOD_NAME, 0x4FAACD11, 0x7A410B64, sceDisplaySetFrameBuf));
+ // fix scaling
GLZ(HOOK_IMPORT(1, P4G_MOD_NAME, 0xF76B66BD, 0x65DD0C84, sceGxmSetUniformDataF));
-#ifdef FB_FHD
+ // memory management
+
+#if PATCH_MODE == MODE_1080
// disable set default number of backbuffers
GLZ(INJECT_DATA(6, p4g_modid, 0, ofs_instr + 0x0C, nop_nop, 4));
p4g_info->n_back_buffers = 2;
@@ -297,7 +300,6 @@ int module_start(SceSize argc, const void *argv) { (void)argc; (void)argv;
// do not create unused buffer and render target
GLZ(INJECT_DATA(7, p4g_modid, 0, ofs_instr + 0xCE, nop_nop, 4));
- // hooks
if (minfo.module_nid == P4G_JP_NID) {
GLZ(HOOK_IMPORT(3, P4G_MOD_NAME, 0x163C3727, 0xE82BB69B, sceAvcdecCreateDecoder));
GLZ(HOOK_IMPORT(4, P4G_MOD_NAME, 0x163C3727, 0x8A0E359E, sceAvcdecDeleteDecoder));
@@ -306,6 +308,13 @@ int module_start(SceSize argc, const void *argv) { (void)argc; (void)argv;
}
#endif
+ // on-screen display
+
+ fnblit_set_font(font_sfn);
+ fnblit_set_fg(0xFFFFFFFF);
+ fnblit_set_bg(0x00000000);
+ GLZ(HOOK_IMPORT(0, P4G_MOD_NAME, 0x4FAACD11, 0x7A410B64, sceDisplaySetFrameBuf));
+
return SCE_KERNEL_START_SUCCESS;
fail: