From 8e777322e4a5723474e70330338f036c79f07cb6 Mon Sep 17 00:00:00 2001 From: Jaby Date: Fri, 14 Jun 2024 19:29:28 +0200 Subject: [PATCH] Support Callback --- include/PSX/System/syscalls.hpp | 8 ++++++++ src/Library/src/CD/cd.cpp | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/PSX/System/syscalls.hpp b/include/PSX/System/syscalls.hpp index 9e606d3f..dbacbd7f 100644 --- a/include/PSX/System/syscalls.hpp +++ b/include/PSX/System/syscalls.hpp @@ -155,6 +155,14 @@ namespace JabyEngine { return __syscall_function_cast(Table_B, ThreadHandle(*)(void(*)(), uint32_t*, uint32_t*))(thread_func, stack_ptr, gp); } + // No return?????? + static __always_inline void ChangeThread(ThreadHandle handle) { + register uint32_t FuncID asm("t1") = 0x10; + __asm__ volatile("" : "=r"(FuncID) : "r"(FuncID)); + + __syscall_function_cast(Table_B, void(*)(ThreadHandle))(handle); + } + static __always_inline void InitPad(uint8_t *portA, uint32_t portASize, uint8_t *portB, uint32_t portBSize) { register uint32_t FuncID asm("t1") = 0x12; __asm__ volatile("" : "=r"(FuncID) : "r"(FuncID)); diff --git a/src/Library/src/CD/cd.cpp b/src/Library/src/CD/cd.cpp index 9dfc2847..da421793 100644 --- a/src/Library/src/CD/cd.cpp +++ b/src/Library/src/CD/cd.cpp @@ -155,8 +155,10 @@ namespace JabyEngine { } void data_ready_handler(uint32_t data) { - printf("Data: %i\n", data); - MainThread::restore(); + while(true) { + printf("Data: %i\n", data); + SysCall::ChangeThread(0xFF000000); + } } }