PS1: Implement more accurate thread sleeping

This commit is contained in:
UnknownShadow200 2025-01-16 20:01:11 +11:00
parent 591e31bea6
commit df49656b25
2 changed files with 7 additions and 3 deletions

View file

@ -24,7 +24,7 @@ enum gp1_cmd_type {
GP1_CMD_DMA_MODE = 0x04000000,
};
enum gp1_dma_mode {
enum gp1_cmd_dma_mode {
GP1_DMA_NONE = 0,
GP1_DMA_CPU_TO_GP0 = 2,
};

View file

@ -160,8 +160,12 @@ cc_result File_Length(cc_file file, cc_uint32* len) {
*--------------------------------------------------------Threading--------------------------------------------------------*
*#########################################################################################################################*/
void Thread_Sleep(cc_uint32 milliseconds) {
// TODO sleep a bit
VSync(0);
// Simulate sleep with a busy loop
cc_uint64 delay = (cc_uint64)milliseconds * F_CPU / (8 * 1000);
cc_uint32 delay_ = (cc_uint32)delay;
for (cc_uint32 i = 0; i < delay_; i++) { __asm__ volatile(""); }
ChangeClearPAD(0);
}
void Thread_Run(void** handle, Thread_StartFunc func, int stackSize, const char* name) {