aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-10-15 17:13:18 +0200
committerBad Diode <bd@badd10de.dev>2022-10-15 17:13:18 +0200
commit0d0e489b6621bf8d998d3aa6e4b02c457c9feefb (patch)
treed3407aa7ebe71a669c14fd09f09cb1f86d5ea1f9 /src
parentd822337f5920c1b639695ebfcf0eb9e49fd5e01a (diff)
downloaduxn64-0d0e489b6621bf8d998d3aa6e4b02c457c9feefb.tar.gz
uxn64-0d0e489b6621bf8d998d3aa6e4b02c457c9feefb.zip
Cleanup task list code
Diffstat (limited to 'src')
-rw-r--r--src/main.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/src/main.c b/src/main.c
index 57a0965..045f65d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,36 +66,20 @@ main_proc(void *arg) {
66 // 10. Video signal is produced. 66 // 10. Video signal is produced.
67 67
68 // Main loop. 68 // Main loop.
69 size_t i = 0; 69 int i = 0;
70 int increment = 4;
71 int direction = increment;
70 while (true) { 72 while (true) {
71 i += 2; 73 if (i >= 255 - increment) {
72 74 direction = -increment;
73 // Task list. 75 } else if (i <= 0) {
74 OSTask tlist = (OSTask){ 76 direction = +increment;
75 { 77 }
76 M_GFXTASK, // task type 78 i += direction;
77 OS_TASK_DP_WAIT, // task flags
78 NULL, // boot ucode pointer (fill in later)
79 0, // boot ucode size (fill in later)
80 NULL, // task ucode pointer (fill in later)
81 SP_UCODE_SIZE, // task ucode size
82 NULL, // task ucode data pointer (fill in later)
83 SP_UCODE_DATA_SIZE, // task ucode data size
84 &dram_stack[0], // task dram stack pointer
85 SP_DRAM_STACK_SIZE8, // task dram stack size
86 NULL, // FIFO buffer start.
87 NULL, // FIFO buffer end.
88 NULL, // task data pointer (fill in later)
89 0, // task data size (fill in later)
90 NULL, // task yield buffer ptr (not used here)
91 0 // task yield buffer size (not used here)
92 },
93 };
94 79
95 // Graphics command list. 80 // Graphics command list.
96 Gfx glist[2048]; 81 // TODO: Check out of bounds when adding elements to the list.
97 82 Gfx glist[2048];
98 OSTask *tlistp = &tlist;
99 Gfx *glistp = glist; 83 Gfx *glistp = glist;
100 84
101 // Tell RCP where each segment is. 85 // Tell RCP where each segment is.
@@ -114,16 +98,24 @@ main_proc(void *arg) {
114 gDPFullSync(glistp++); 98 gDPFullSync(glistp++);
115 gSPEndDisplayList(glistp++); 99 gSPEndDisplayList(glistp++);
116 100
117 // Build graphics task: 101 // Start up the RSP task list.
118 tlistp->t.ucode_boot = (u64 *) rspbootTextStart; 102 OSTask tlist = (OSTask){
119 tlistp->t.ucode_boot_size = (u32)rspbootTextEnd - (u32)rspbootTextStart; 103 {
120 tlistp->t.ucode = (u64 *) gspF3DEX2_fifoTextStart; 104 .type = M_GFXTASK,
121 tlistp->t.ucode_data = (u64 *) gspF3DEX2_fifoDataStart; 105 .flags = OS_TASK_DP_WAIT,
122 tlistp->t.data_ptr = (u64 *) glist; 106 .ucode_boot = (u64*) rspbootTextStart,
123 tlistp->t.data_size = (u32)((glistp - glist) * sizeof(Gfx)); 107 .ucode_boot_size = (u32)rspbootTextEnd - (u32)rspbootTextStart,
124 108 .ucode = (u64*)gspF3DEX2_xbusTextStart,
125 // Start up the RSP task. 109 .ucode_size = SP_UCODE_SIZE,
126 osSpTaskStart(tlistp); 110 .ucode_data = (u64*)gspF3DEX2_xbusDataStart,
111 .ucode_data_size = SP_UCODE_DATA_SIZE,
112 .data_ptr = (u64*) glist,
113 .data_size = (u32)((glistp - glist) * sizeof(Gfx)),
114 .dram_stack = dram_stack,
115 .dram_stack_size = SP_DRAM_STACK_SIZE8,
116 },
117 };
118 osSpTaskStart(&tlist);
127 119
128 // Wait for RDP completion. 120 // Wait for RDP completion.
129 osRecvMesg(&rdp_msg_queue, NULL, OS_MESG_BLOCK); 121 osRecvMesg(&rdp_msg_queue, NULL, OS_MESG_BLOCK);