diff options
author | 浅倉麗子 | 2020-04-23 21:04:20 -0400 |
---|---|---|
committer | 浅倉麗子 | 2020-04-23 21:04:20 -0400 |
commit | d6890455ec870b506cd6f0dad0a3d245d3f3a70f (patch) | |
tree | 152002b869d356be074b5e22a3cc06ed5f9d7108 | |
parent | Add fitted scaling mode (diff) | |
download | sharpscale-1.2.0.tar.gz |
Add configuration appv1.2.0
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | README.md | 26 | ||||
-rw-r--r-- | config-app/CMakeLists.txt | 43 | ||||
-rw-r--r-- | config-app/icon0.png | bin | 0 -> 2725 bytes | |||
-rw-r--r-- | config-app/main.c | 149 |
5 files changed, 209 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c5a970c..4d6f428 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,3 +59,5 @@ dolce_create_stubs("${PROJECT_NAME}-stubs" KERNEL LIB Sharpscale_stub ) + +add_subdirectory(config-app) @@ -47,17 +47,7 @@ ur0:tai/sharpscale.skprx ## Configuration -Configuration is provided by a text file at `ur0:/data/sharpscale/config.txt` containing two numbers separated by a space. - -1. Scaling mode - - `0` original - - `1` integer - - `2` real -2. Bilinear filtering - - `0` off - - `1` on - -For example, to use integer mode and turn off bilinear filtering, write `1 0` in the text file. +Use the provided configuration app to change settings instantly without needing to close the foreground application or needing to reboot. ## Scaling test @@ -65,6 +55,20 @@ The scaling test program shows horizontal and vertical lines 1 pixel wide altern **Warning:** Do not use when HDMI is set to interlaced mode. +## Building + +Use [DolceSDK](https://forum.devchroma.nl/index.php/topic,129.0.html) and [libvita2d_sys](https://github.com/GrapheneCt/libvita2d_sys) to build. The following modifications to libvita2d_sys are required to reduce memory usage: + +``` +DEFAULT_TEMP_POOL_SIZE 128 KiB +PARAMETER_BUFFER_SIZE 256 KiB +VDM_RING_BUFFER_SIZE 32 KiB +VERTEX_RING_BUFFER_SIZE 128 KiB +FRAGMENT_RING_BUFFER_SIZE 64 KiB + +Remove the stencil buffer +``` + ## Credits - Bounty backers: [ScHlAuChii, eleriaqueen, mansjg, TG](https://www.bountysource.com/issues/78540965-native-resolution-output-for-pstv) diff --git a/config-app/CMakeLists.txt b/config-app/CMakeLists.txt new file mode 100644 index 0000000..9e07e26 --- /dev/null +++ b/config-app/CMakeLists.txt @@ -0,0 +1,43 @@ +project(sharpscale_config LANGUAGES C) + +add_custom_command(OUTPUT boot_param.bin + COMMAND dolce-make-bootparam app_memsize 0x1800 boot_param.bin +) + +set(ELF "${PROJECT_NAME}.elf") +set(SELF "${PROJECT_NAME}.self") + +add_executable("${ELF}" + main.c +) + +target_include_directories("${ELF}" + PRIVATE "${CMAKE_SOURCE_DIR}" +) + +target_link_libraries("${ELF}" + vita2d_sys + m + Sharpscale_stub + SceAppMgr_stub + SceCtrl_stub + SceDisplay_stub + SceGxm_stub + SceLibKernel_stub + ScePgf_stub + SceSysmodule_stub +) + +dolce_create_self("${SELF}" + "${ELF}" + UNSAFE + BOOT_PARAM ${CMAKE_CURRENT_BINARY_DIR}/boot_param.bin +) + +dolce_create_vpk(${PROJECT_NAME}.vpk + AKRK00005 + "${SELF}" + NAME "Sharpscale Config" + VERSION 01.00 + FILE icon0.png sce_sys/icon0.png +) diff --git a/config-app/icon0.png b/config-app/icon0.png Binary files differnew file mode 100644 index 0000000..0bfbb17 --- /dev/null +++ b/config-app/icon0.png diff --git a/config-app/main.c b/config-app/main.c new file mode 100644 index 0000000..7ca8a27 --- /dev/null +++ b/config-app/main.c @@ -0,0 +1,149 @@ +/* +Sharpscale +Copyright (C) 2020 浅倉麗子 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 3 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + +#include <psp2/ctrl.h> +#include <psp2/kernel/clib.h> +#include <psp2/kernel/sysmem.h> +#include <vita2d_sys.h> +#include "sharpscale.h" + +// do not need newlib heap +int _newlib_heap_size_user = 4 * 1024; +#define CLIB_HEAP_SIZE 256 * 1024 + +#define BG_COLOUR 0xFFDFDFDF +#define TEXT_BLACK 0xFF202020 +#define TEXT_BLUE 0xFFFF8000 +#define TEXT_YELLOW 0xFF009090 + +static int text_blue(int a) { + return a ? TEXT_BLUE : TEXT_BLACK; +} + +static int text_yellow(int a) { + return a ? TEXT_YELLOW : TEXT_BLACK; +} + +int main(int argc, char **argv) { (void)argc; (void)argv; + SceUID memid = sceKernelAllocMemBlock( + "SharpscaleConfigMemBlock", + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + CLIB_HEAP_SIZE, + NULL); + void *membase; + sceKernelGetMemBlockBase(memid, &membase); + + vita2d_clib_pass_mspace(sceClibMspaceCreate(membase, CLIB_HEAP_SIZE)); + vita2d_init(); + vita2d_set_vblank_wait(0); + vita2d_set_clear_color(BG_COLOUR); + + vita2d_pgf *pgf; + pgf = vita2d_load_default_pgf(); + + void draw_text(int x, int y, int colour, char *txt) { + vita2d_pgf_draw_text(pgf, x, y, colour, 1.0, txt); + } + + void draw_text_right(int x, int y, int colour, char *txt) { + int width = vita2d_pgf_text_width(pgf, 1.0, txt); + draw_text(960 - width - x, y, colour, txt); + } + + void draw_text_centre(int y, int colour, char *txt) { + int width = vita2d_pgf_text_width(pgf, 1.0, txt); + draw_text((960 - width) / 2, y, colour, txt); + } + + int ui_row = 0; + SceCtrlData last_ctrl = {0}; + SharpscaleConfig config = {0}; + SharpscaleGetConfig(&config); + + for (;;) { + + SceCtrlData ctrl; + if (sceCtrlReadBufferPositive(0, &ctrl, 1) == 1) { + int btns = ~last_ctrl.buttons & ctrl.buttons; + + if (btns & SCE_CTRL_UP) { + ui_row = (ui_row - 1 + 3) % 3; + + } else if (btns & SCE_CTRL_DOWN) { + ui_row = (ui_row + 1) % 3; + + } else if ((btns & SCE_CTRL_LEFT) || (btns & SCE_CTRL_RIGHT)) { + int inc = (btns & SCE_CTRL_LEFT) ? -1 : 1; + + if (ui_row == 0) { + config.mode = (config.mode + inc + 4) % 4; + } else if (ui_row == 1) { + config.psone_mode = (config.psone_mode + inc + 3) % 3; + } else if (ui_row == 2) { + config.bilinear = !config.bilinear; + } + + SharpscaleSetConfig(&config); + } + last_ctrl = ctrl; + } + + vita2d_start_drawing(); + vita2d_clear_screen(); + + int line_height = 35; + int x_pos = 50; + int y_pos = line_height * 2; + + draw_text(x_pos, y_pos, TEXT_BLACK, "Sharpscale Configuration Menu"); + draw_text_right(x_pos, y_pos, TEXT_BLACK, "© 2020 浅倉麗子"); + + vita2d_draw_line(50.0f, line_height * 2.75f, 910.0f, line_height * 2.75f, TEXT_BLACK); + + x_pos = 50; + y_pos = line_height * 4; + draw_text(x_pos, y_pos, text_yellow(ui_row == 0), "Scaling mode"); + draw_text(x_pos += 300, y_pos, text_blue(config.mode == SHARPSCALE_MODE_ORIGINAL), "Original"); + draw_text(x_pos += 100, y_pos, text_blue(config.mode == SHARPSCALE_MODE_INTEGER), "Integer"); + draw_text(x_pos += 100, y_pos, text_blue(config.mode == SHARPSCALE_MODE_REAL), "Real"); + draw_text(x_pos += 100, y_pos, text_blue(config.mode == SHARPSCALE_MODE_FITTED), "Fitted"); + + x_pos = 50; + y_pos = line_height * 5; + draw_text(x_pos, y_pos, text_yellow(ui_row == 1), "PS1 aspect ratio mode"); + draw_text(x_pos += 300, y_pos, text_blue(config.psone_mode == SHARPSCALE_PSONE_MODE_PIXEL), "Pixel"); + draw_text(x_pos += 100, y_pos, text_blue(config.psone_mode == SHARPSCALE_PSONE_MODE_4_3), "4:3"); + draw_text(x_pos += 100, y_pos, text_blue(config.psone_mode == SHARPSCALE_PSONE_MODE_16_9), "16:9"); + + x_pos = 50; + y_pos = line_height * 6; + draw_text(x_pos, y_pos, text_yellow(ui_row == 2), "Bilinear filtering"); + draw_text(x_pos += 300, y_pos, text_blue(config.bilinear), "On"); + draw_text(x_pos += 100, y_pos, text_blue(!config.bilinear), "Off"); + + y_pos = line_height * 13; + draw_text_centre(y_pos, TEXT_BLACK, "CBPS Productions"); + y_pos = line_height * 14; + draw_text_centre(y_pos, TEXT_BLACK, "forum.devchroma.nl"); + + vita2d_end_drawing(); + vita2d_wait_rendering_done(); + vita2d_end_shfb(); + } + + return 0; +} |