Files
oot/src/libultra_boot_O1/osCreateThread.c
T
Random 174af7384d libultra cleanup (#215)
* cleanup libultra

* fixes

- use quotes instead of <> for includes
- add macros for zelda specific thread priorities
- fix Makefile
- properly format the remaining pfs structs

* fix button macros + add CHECK_BTN_ANY/CHECK_BTN_ALL

* remove ULTRA_ABS

* fix includes

* update z_player.c/z_lib.c + run format.sh

* merge upstream/master

* fix include in En_Goroiwa

* fix includes
2020-10-03 11:22:44 -04:00

34 lines
1012 B
C

#include "global.h"
OSThread* __osThreadTail[2] = { NULL, (OSThread*)-1 };
OSThread* __osRunQueue = __osThreadTail;
OSThread* __osActiveQueue = __osThreadTail;
OSThread* __osRunningThread = NULL;
OSThread* __osFaultedThread = NULL;
void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri pri) {
register u32 s0;
u32 t8;
thread->id = id;
thread->priority = pri;
thread->next = (struct OSThread_s*)NULL;
thread->queue = (struct OSThread_s**)NULL;
thread->context.pc = (u32)entry;
thread->context.a0 = (u64)arg;
thread->context.sp = (u64)sp - 16;
thread->context.ra = (u64)__osCleanupThread;
t8 = 0x3FFF01;
thread->context.sr = (t8 & 0xFF01) | 2;
thread->context.rcp = (t8 & 0x3F0000) >> 16;
thread->context.fpcsr = 0x01000800;
thread->fp = 0;
thread->state = 1;
thread->flags = 0;
s0 = __osDisableInt();
thread->tlnext = __osActiveQueue;
__osActiveQueue = thread;
__osRestoreInt(s0);
}