From 17d6ca5329184f78ddaeff66548635ed207fd57e Mon Sep 17 00:00:00 2001 From: Jaby Date: Wed, 13 Dec 2023 19:46:34 -0500 Subject: [PATCH] Load a BIOS font --- include/PSX/System/syscalls.hpp | 15 +++++++++++---- src/Library/src/BootLoader/start_boot.cpp | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/PSX/System/syscalls.hpp b/include/PSX/System/syscalls.hpp index f3b76916..00234cdd 100644 --- a/include/PSX/System/syscalls.hpp +++ b/include/PSX/System/syscalls.hpp @@ -148,18 +148,25 @@ namespace JabyEngine { return __syscall_function_cast(Table_B, uint32_t(*)(uint32_t))(event); } - static __always_inline int TestEvent(uint32_t event) { + static __always_inline int32_t TestEvent(uint32_t event) { register uint32_t FuncID asm("t1") = 0x0B; __asm__ volatile("" : "=r"(FuncID) : "r"(FuncID)); - return __syscall_function_cast(Table_B, int (*)(uint32_t))(event); + return __syscall_function_cast(Table_B, int32_t (*)(uint32_t))(event); } - static __always_inline int EnableEvent(uint32_t event) { + static __always_inline int32_t EnableEvent(uint32_t event) { register uint32_t FuncID asm("t1") = 0x0C; __asm__ volatile("" : "=r"(FuncID) : "r"(FuncID)); - return __syscall_function_cast(Table_B, int (*)(uint32_t))(event); + return __syscall_function_cast(Table_B, int32_t (*)(uint32_t))(event); + } + + static __always_inline const uint16_t* Krom2RawAdd(uint16_t sjis_code) { + register uint32_t FuncID asm("t1") = 0x51; + + __asm__ volatile("" : "=r"(FuncID) : "r"(FuncID)); + return __syscall_function_cast(Table_B, const uint16_t* (*)(uint16_t))(sjis_code); } void printf(const char* txt, ...); diff --git a/src/Library/src/BootLoader/start_boot.cpp b/src/Library/src/BootLoader/start_boot.cpp index 2fd13df2..798815e0 100644 --- a/src/Library/src/BootLoader/start_boot.cpp +++ b/src/Library/src/BootLoader/start_boot.cpp @@ -3,6 +3,8 @@ #include #include +#include + extern "C" uint32_t __heap_start; extern "C" uint32_t __bss_start; extern "C" uint32_t __bss_end; @@ -42,6 +44,24 @@ namespace JabyEngine { } } } + + static void test_bios_font() { + static constexpr uint16_t SJIS = 0x83B5; + + const auto* font = SysCall::Krom2RawAdd(SJIS); + const auto*const font_end = font + 16; + printf("Loading SJIS from @0x%p\n", font); + + for(; font < font_end; font++) { + const auto cur_char = __builtin_bswap16(*font); + for(uint16_t shift = 1 << 15; shift; shift = shift >> 1) { + printf(cur_char & shift ? "#" : " "); + } + + printf("\n"); + } + } + void start() { static constexpr auto DebugX = 0; static constexpr auto DebugY = 0; @@ -50,6 +70,7 @@ namespace JabyEngine { __debug_boot_print_at(GPU::Color24::White(), DebugX, DebugY, DebugScale, "Starting Planschbecken\n"); printf("Heap starts @0x%p\n", &__heap_start); printf("BSS from 0x%p to 0x%p (%u)\n", &__bss_start, &__bss_end, __bss_len); + test_bios_font(); __debug_boot_print_at(GPU::Color24::Green(), DebugX, DebugY, DebugScale, "PLANSCHI from 0x%p to 0x%p\n", &__planschi_start, &__planschi_end); boot::Start::setup();