aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-05-21 17:56:49 -0400
committer浅倉麗子2020-05-21 17:56:49 -0400
commitc12a5d2e701987aee31c50ef6d597989df7dda20 (patch)
tree8a61708ffbc9281d8a2c3f2152f84a94e105bbf6
parentKeep bilinear filter when scaling is not applied (diff)
downloadsharpscale-c12a5d2e701987aee31c50ef6d597989df7dda20.tar.gz
Show OSD in scaling test with resolution info
-rw-r--r--scaling-test/CMakeLists.txt24
-rw-r--r--scaling-test/main.c25
2 files changed, 48 insertions, 1 deletions
diff --git a/scaling-test/CMakeLists.txt b/scaling-test/CMakeLists.txt
index 39cca67..debfb02 100644
--- a/scaling-test/CMakeLists.txt
+++ b/scaling-test/CMakeLists.txt
@@ -29,19 +29,40 @@ project(sharpscale_scaling_test LANGUAGES C)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -O3 -std=c99")
+set(FONT_FILE "unifont.bdf.gz")
+set(SFN_FILE "font.sfn")
+
+file(DOWNLOAD
+ "https://ftp.gnu.org/gnu/unifont/unifont-13.0.02/unifont-13.0.02.bdf.gz"
+ "${FONT_FILE}"
+ EXPECTED_HASH SHA256=ee02036aec9350dc35ebaaa205c43f9f9ad14efc56d63c12b177ac4fd424e94f
+)
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${SFN_FILE}"
+ COMMAND bit2sfn
+ -r "Basic Latin" "${FONT_FILE}"
+ -r "Latin-1 Supplement" "${FONT_FILE}"
+ -r 0x6D45 0x6D46 "${FONT_FILE}"
+ -r 0x5009 0x500A "${FONT_FILE}"
+ -r 0x9E97 0x9E98 "${FONT_FILE}"
+ -r 0x5B50 0x5B51 "${FONT_FILE}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${SFN_FILE}"
+)
+
set(ELF "${PROJECT_NAME}.elf")
set(SELF "${PROJECT_NAME}.self")
set(VPK "${PROJECT_NAME}.vpk")
set(TITLE_NAME "Sharpscale Scaling Test")
set(TITLE_ID "AKRK00004")
-set(TITLE_VER "01.04")
+set(TITLE_VER "01.05")
add_executable("${ELF}"
main.c
)
target_link_libraries("${ELF}"
+ fnblit
SceCtrl_stub
SceDisplay_stub
SceLibKernel_stub
@@ -55,4 +76,5 @@ dolce_create_vpk("${VPK}" "${TITLE_ID}" "${SELF}"
VERSION "${TITLE_VER}"
NAME "${TITLE_NAME}"
FILE icon0.png sce_sys/icon0.png
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/${SFN_FILE}" "${SFN_FILE}"
)
diff --git a/scaling-test/main.c b/scaling-test/main.c
index df8ddd1..de6bc93 100644
--- a/scaling-test/main.c
+++ b/scaling-test/main.c
@@ -15,12 +15,17 @@ 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 <stdlib.h>
#include <string.h>
#include <psp2/ctrl.h>
#include <psp2/display.h>
+#include <psp2/io/fcntl.h>
#include <psp2/kernel/clib.h>
#include <psp2/kernel/processmgr.h>
#include <psp2/kernel/sysmem.h>
+#include <fnblit.h>
+
+#define SFN_FILE_BUF_LEN 0x100000
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
@@ -92,6 +97,20 @@ static void render(int *fb_base, int width, int pitch, int height) {
}
int main() {
+ void *sfn_file = malloc(SFN_FILE_BUF_LEN);
+ if (!sfn_file) { goto done; }
+
+ SceUID sfn_file_fd = sceIoOpen("app0:font.sfn", SCE_O_RDONLY, 0);
+ if (sfn_file_fd < 0) { goto done; }
+
+ int bytes_read = sceIoRead(sfn_file_fd, sfn_file, SFN_FILE_BUF_LEN);
+ sceIoClose(sfn_file_fd);
+ if (bytes_read < 0 || bytes_read == SFN_FILE_BUF_LEN) { goto done; }
+
+ fnblit_set_font(sfn_file);
+ fnblit_set_fg(WHITE);
+ fnblit_set_bg(BLACK);
+
SceUID mem_id = sceKernelAllocMemBlock(
"ScalingTestMemblock",
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
@@ -110,6 +129,12 @@ int main() {
pitch = ALIGN(width, 64);
height = fb_res[idx].h;
render(fb_base, width, pitch, height);
+
+ fnblit_set_fb(fb_base, pitch, width, height);
+ fnblit_printf(10, 10, "%dx%d", width, height);
+ fnblit_printf(10, height - 42, "Sharpscale Scaling Test");
+ fnblit_printf(10, height - 26, "Copyright 2020 浅倉麗子");
+
sceClibPrintf("Selected resolution %dx%d\n", width, height);
}