Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/include/PR/sptask.h
7858 views
1
#ifndef _ULTRA64_SPTASK_H_
2
#define _ULTRA64_SPTASK_H_
3
4
/* Task Types */
5
#define M_GFXTASK 1
6
#define M_AUDTASK 2
7
#define M_VIDTASK 3
8
#define M_HVQTASK 6
9
#define M_HVQMTASK 7
10
11
#if (defined(F3DEX_GBI) || defined(F3DLP_GBI) || defined(F3DEX_GBI_2))
12
#define OS_YIELD_DATA_SIZE 0xc00
13
#else
14
#define OS_YIELD_DATA_SIZE 0x900
15
#endif
16
#define OS_YIELD_AUDIO_SIZE 0x400
17
18
/* Flags */
19
#define M_TASK_FLAG0 1
20
#define M_TASK_FLAG1 2
21
#ifdef VERSION_SH
22
#define M_TASK_FLAG2 4
23
#endif
24
25
/* SpStatus */
26
#define SPSTATUS_CLEAR_HALT 0x00000001
27
#define SPSTATUS_SET_HALT 0x00000002
28
#define SPSTATUS_CLEAR_BROKE 0x00000004
29
#define SPSTATUS_CLEAR_INTR 0x00000008
30
#define SPSTATUS_SET_INTR 0x00000010
31
#define SPSTATUS_CLEAR_SSTEP 0x00000020
32
#define SPSTATUS_SET_SSTEP 0x00000040
33
#define SPSTATUS_CLEAR_INTR_ON_BREAK 0x00000080
34
#define SPSTATUS_SET_INTR_ON_BREAK 0x00000100
35
#define SPSTATUS_CLEAR_SIGNAL0 0x00000200
36
#define SPSTATUS_SET_SIGNAL0 0x00000400
37
#define SPSTATUS_CLEAR_SIGNAL1 0x00000800
38
#define SPSTATUS_SET_SIGNAL1 0x00001000
39
#define SPSTATUS_CLEAR_SIGNAL2 0x00002000
40
#define SPSTATUS_SET_SIGNAL2 0x00004000
41
#define SPSTATUS_CLEAR_SIGNAL3 0x00008000
42
#define SPSTATUS_SET_SIGNAL3 0x00010000
43
#define SPSTATUS_CLEAR_SIGNAL4 0x00020000
44
#define SPSTATUS_SET_SIGNAL4 0x00040000
45
#define SPSTATUS_CLEAR_SIGNAL5 0x00080000
46
#define SPSTATUS_SET_SIGNAL5 0x00100000
47
#define SPSTATUS_CLEAR_SIGNAL6 0x00200000
48
#define SPSTATUS_SET_SIGNAL6 0x00800000
49
#define SPSTATUS_CLEAR_SIGNAL7 0x01000000
50
#define SPSTATUS_SET_SIGNAL7 0x02000000
51
52
#define SPSTATUS_HALT 0x0001
53
#define SPSTATUS_BROKE 0x0002
54
#define SPSTATUS_DMA_BUSY 0x0004
55
#define SPSTATUS_DMA_FULL 0x0008
56
#define SPSTATUS_IO_FULL 0x0010
57
#define SPSTATUS_SINGLE_STEP 0x0020
58
#define SPSTATUS_INTERRUPT_ON_BREAK 0x0040
59
#define SPSTATUS_SIGNAL0_SET 0x0080
60
#define SPSTATUS_SIGNAL1_SET 0x0100
61
#define SPSTATUS_SIGNAL2_SET 0x0200
62
#define SPSTATUS_SIGNAL3_SET 0x0400
63
#define SPSTATUS_SIGNAL4_SET 0x0800
64
#define SPSTATUS_SIGNAL5_SET 0x1000
65
#define SPSTATUS_SIGNAL6_SET 0x2000
66
#define SPSTATUS_SIGNAL7_SET 0x4000
67
68
/* Types */
69
/* Types */
70
71
typedef struct
72
{
73
/*0x00*/ u32 type;
74
/*0x04*/ u32 flags;
75
76
/*0x08*/ u64 *ucode_boot;
77
/*0x0C*/ u32 ucode_boot_size;
78
79
/*0x10*/ u64 *ucode;
80
/*0x14*/ u32 ucode_size;
81
82
/*0x18*/ u64 *ucode_data;
83
/*0x1C*/ u32 ucode_data_size;
84
85
/*0x20*/ u64 *dram_stack;
86
/*0x24*/ u32 dram_stack_size;
87
88
/*0x28*/ u64 *output_buff;
89
/*0x2C*/ u64 *output_buff_size;
90
91
/*0x30*/ u64 *data_ptr;
92
/*0x34*/ u32 data_size;
93
94
/*0x38*/ u64 *yield_data_ptr;
95
/*0x3C*/ u32 yield_data_size;
96
} OSTask_t; // size = 0x40
97
98
typedef union {
99
OSTask_t t;
100
long long int force_structure_alignment;
101
} OSTask;
102
103
typedef u32 OSYieldResult;
104
105
/* Functions */
106
107
#define osSpTaskStart(p) \
108
osSpTaskLoad(p); \
109
osSpTaskStartGo(p);
110
111
void osSpTaskLoad(OSTask *task);
112
void osSpTaskStartGo(OSTask *task);
113
void osSpTaskYield(void);
114
OSYieldResult osSpTaskYielded(OSTask *task);
115
116
#endif
117
118