aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-07-08 17:39:17 -0400
committer浅倉麗子2020-07-08 17:39:17 -0400
commit631a23bd4df8b92d4ce7925fba0b6c233dfe2c55 (patch)
tree28924bc0311ea967e31c7e4efeda4b35adf488ef
parentInitial commit (diff)
downloadlcd-colour-crunch-631a23bd4df8b92d4ce7925fba0b6c233dfe2c55.tar.gz
Add message after setting colour space
-rw-r--r--CMakeLists.txt30
-rw-r--r--main.c35
2 files changed, 64 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d76d0c2..387c271 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,16 +27,42 @@ include("$ENV{DOLCESDK}/share/dolce.cmake" REQUIRED)
project(LCDColourCrunch LANGUAGES C)
+# Build font
+set(FONT_BASE "terminus-font-4.48")
+set(FONT_FILE "ter-u28b.bdf")
+set(SFN_FILE "font.sfn")
+set(SFN_OBJ "${SFN_FILE}.o")
+
+file(DOWNLOAD
+ "https://sourceforge.net/projects/terminus-font/files/${FONT_BASE}/${FONT_BASE}.tar.gz/download"
+ "${FONT_BASE}.tar.gz"
+ EXPECTED_HASH SHA256=34799c8dd5cec7db8016b4a615820dfb43b395575afbb24fc17ee19c869c94af
+)
+
+add_custom_command(OUTPUT "${SFN_FILE}"
+ DEPENDS "${FONT_BASE}.tar.gz"
+ COMMAND tar xzf "${FONT_BASE}.tar.gz" --strip-components=1 "${FONT_BASE}/${FONT_FILE}"
+ COMMAND bit2sfn
+ -r "Basic Latin" "${FONT_FILE}"
+ "${SFN_FILE}"
+)
+
+add_custom_command(OUTPUT "${SFN_OBJ}"
+ DEPENDS "${SFN_FILE}"
+ COMMAND ${CMAKE_LINKER} -r -b binary -o "${SFN_OBJ}" "${SFN_FILE}"
+)
+
set(ELF "${PROJECT_NAME}.elf")
set(SELF "${PROJECT_NAME}.self")
set(VPK "${PROJECT_NAME}.vpk")
set(TITLE_NAME "LCD Colour Crunch")
set(TITLE_ID "AKRK00006")
-set(TITLE_VER "01.00")
+set(TITLE_VER "01.01")
add_executable("${ELF}"
main.c
+ "${SFN_OBJ}"
)
target_compile_options("${ELF}"
@@ -46,7 +72,9 @@ target_compile_options("${ELF}"
)
target_link_libraries("${ELF}"
+ fnblit
SceAVConfig_stub
+ SceDisplay_stub
SceRegistryMgr_stub
)
diff --git a/main.c b/main.c
index f8c5aeb..b4dd927 100644
--- a/main.c
+++ b/main.c
@@ -16,7 +16,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <psp2/avconfig.h>
+#include <psp2/display.h>
+#include <psp2/kernel/clib.h>
+#include <psp2/kernel/sysmem.h>
+#include <psp2/kernel/threadmgr.h>
#include <psp2/registrymgr.h>
+#include "fnblit.h"
+
+extern char _binary_font_sfn_start[];
int _newlib_heap_size_user = 4 * 1024;
@@ -26,5 +33,33 @@ int main(int argc, char **argv) { (void)argc; (void)argv;
sceRegMgrGetKeyInt("/CONFIG/DISPLAY/", "color_space_mode", &v);
sceAVConfigSetDisplayColorSpaceMode(!v);
sceRegMgrSetKeyInt("/CONFIG/DISPLAY/", "color_space_mode", !v);
+
+ SceUID mem_id = sceKernelAllocMemBlock(
+ "FramebufferMem",
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ SCE_KERNEL_2MiB,
+ NULL);
+ if (mem_id < 0) { goto done; }
+ void *fb_base;
+ sceKernelGetMemBlockBase(mem_id, &fb_base);
+ sceClibMemset(fb_base, 0x00, SCE_KERNEL_2MiB);
+
+ fnblit_set_font(_binary_font_sfn_start);
+ fnblit_set_fg(0xFFFFFFFF);
+ fnblit_set_bg(0x00000000);
+ fnblit_set_fb(fb_base, 960, 960, 544);
+ fnblit_printf(10, 10, "LCD colour space set to %s mode", !v ? "OLED emulation" : "original");
+ SceDisplayFrameBuf fb = {
+ sizeof(fb),
+ fb_base,
+ 960,
+ SCE_DISPLAY_PIXELFORMAT_A8B8G8R8,
+ 960,
+ 544,
+ };
+ sceDisplaySetFrameBuf(&fb, SCE_DISPLAY_SETBUF_NEXTFRAME);
+ sceKernelDelayThread(1 * 1000 * 1000);
+
+done:
return 0;
}