Super Mario 64s source code (from a leak on 4chan so be careful)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.8 KiB

5 years ago
  1. #ifndef _ULTRA64_THREAD_H_
  2. #define _ULTRA64_THREAD_H_
  3. /* Recommended priorities for system threads */
  4. #define OS_PRIORITY_MAX 255
  5. #define OS_PRIORITY_VIMGR 254
  6. #define OS_PRIORITY_RMON 250
  7. #define OS_PRIORITY_RMONSPIN 200
  8. #define OS_PRIORITY_PIMGR 150
  9. #define OS_PRIORITY_SIMGR 140
  10. #define OS_PRIORITY_APPMAX 127
  11. #define OS_PRIORITY_IDLE 0
  12. #define OS_STATE_STOPPED 1
  13. #define OS_STATE_RUNNABLE 2
  14. #define OS_STATE_RUNNING 4
  15. #define OS_STATE_WAITING 8
  16. /* Types */
  17. typedef s32 OSPri;
  18. typedef s32 OSId;
  19. typedef union
  20. {
  21. struct {f32 f_odd; f32 f_even;} f;
  22. } __OSfp;
  23. typedef struct
  24. {
  25. /* registers */
  26. /*0x20*/ u64 at, v0, v1, a0, a1, a2, a3;
  27. /*0x58*/ u64 t0, t1, t2, t3, t4, t5, t6, t7;
  28. /*0x98*/ u64 s0, s1, s2, s3, s4, s5, s6, s7;
  29. /*0xD8*/ u64 t8, t9, gp, sp, s8, ra;
  30. /*0x108*/ u64 lo, hi;
  31. /*0x118*/ u32 sr, pc, cause, badvaddr, rcp;
  32. /*0x12C*/ u32 fpcsr;
  33. __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14;
  34. __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30;
  35. } __OSThreadContext;
  36. typedef struct
  37. {
  38. u32 flag;
  39. u32 count;
  40. u64 time;
  41. } __OSThreadprofile_s;
  42. typedef struct OSThread_s
  43. {
  44. /*0x00*/ struct OSThread_s *next;
  45. /*0x04*/ OSPri priority;
  46. /*0x08*/ struct OSThread_s **queue;
  47. /*0x0C*/ struct OSThread_s *tlnext;
  48. /*0x10*/ u16 state;
  49. /*0x12*/ u16 flags;
  50. /*0x14*/ OSId id;
  51. /*0x18*/ int fp;
  52. /*0x1C*/ __OSThreadprofile_s *thprof;
  53. /*0x20*/ __OSThreadContext context;
  54. } OSThread;
  55. /* Functions */
  56. void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *),
  57. void *arg, void *sp, OSPri pri);
  58. OSId osGetThreadId(OSThread *thread);
  59. OSPri osGetThreadPri(OSThread *thread);
  60. void osSetThreadPri(OSThread *thread, OSPri pri);
  61. void osStartThread(OSThread *thread);
  62. void osStopThread(OSThread *thread);
  63. #endif