summaryrefslogtreecommitdiff
path: root/src/libultra_boot_O2/vimgr.c
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2021-12-01 00:08:57 +0000
committerGitHub <noreply@github.com>2021-11-30 19:08:57 -0500
commitf1d183d6feac23275306bfa2dee939d123702765 (patch)
treec20585c17dea94561f7c4cfcff572e39bc033a3e /src/libultra_boot_O2/vimgr.c
parenteabc91881761a82856cca3fab9a4749c60ea1fe7 (diff)
libultra files and directories restructure (#1038)
* Restructure files, begin header restructure * Format * us2dex * Fix parallel spelling Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> * Use OS_K0_TO_PHYSICAL in place of VIRTUAL_TO_PHYSICAL in osAiSetNextBuffer * Uppercase hex, exception vector address defines * Interrupt flags 1 Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Interrupt flags 2 Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Diffstat (limited to 'src/libultra_boot_O2/vimgr.c')
-rw-r--r--src/libultra_boot_O2/vimgr.c106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/libultra_boot_O2/vimgr.c b/src/libultra_boot_O2/vimgr.c
deleted file mode 100644
index 5be0ba2e3..000000000
--- a/src/libultra_boot_O2/vimgr.c
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "global.h"
-#include "ultra64/internal.h"
-
-OSThread viThread;
-u8 viThreadStack[0x1000];
-OSMesgQueue viEventQueue;
-OSMesg viEventBuf[6];
-OSIoMesg viRetraceMsg;
-OSIoMesg viCounterMsg;
-OSMgrArgs __osViDevMgr = { 0 };
-u32 __additional_scanline = 0;
-
-void viMgrMain(void*);
-
-void osCreateViManager(OSPri pri) {
- u32 prevInt;
- OSPri newPri;
- OSPri currentPri;
-
- if (!__osViDevMgr.initialized) {
- __osTimerServicesInit();
- __additional_scanline = 0;
- osCreateMesgQueue(&viEventQueue, viEventBuf, 5);
- viRetraceMsg.hdr.type = 13;
- viRetraceMsg.hdr.pri = 0;
- viRetraceMsg.hdr.retQueue = NULL;
- viCounterMsg.hdr.type = 14;
- viCounterMsg.hdr.pri = 0;
- viCounterMsg.hdr.retQueue = NULL;
- osSetEventMesg(OS_EVENT_VI, &viEventQueue, &viRetraceMsg);
- osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg);
- newPri = -1;
- currentPri = osGetThreadPri(NULL);
- if (currentPri < pri) {
- newPri = currentPri;
- osSetThreadPri(NULL, pri);
- }
-
- prevInt = __osDisableInt();
- __osViDevMgr.initialized = true;
- __osViDevMgr.mgrThread = &viThread;
- __osViDevMgr.cmdQueue = &viEventQueue;
- __osViDevMgr.eventQueue = &viEventQueue;
- __osViDevMgr.acccessQueue = NULL;
- __osViDevMgr.piDmaCallback = NULL;
- __osViDevMgr.epiDmaCallback = NULL;
-
- osCreateThread(&viThread, 0, &viMgrMain, &__osViDevMgr, viThreadStack + sizeof(viThreadStack), pri);
- __osViInit();
- osStartThread(&viThread);
- __osRestoreInt(prevInt);
- if (newPri != -1) {
- osSetThreadPri(NULL, newPri);
- }
- }
-}
-
-void viMgrMain(void* vargs) {
- OSMgrArgs* args;
- static u16 viRetrace;
- u32 addTime;
- OSIoMesg* mesg = NULL;
- u32 temp = 0; // always 0
-
- viRetrace = __osViGetCurrentContext()->retraceCount;
- if (viRetrace == 0) {
- viRetrace = 1;
- }
-
- args = (OSMgrArgs*)vargs;
-
- while (true) {
- osRecvMesg(args->eventQueue, (OSMesg)&mesg, OS_MESG_BLOCK);
- switch (mesg->hdr.type) {
- case 13:
- __osViSwapContext();
- viRetrace--;
- if (!viRetrace) {
- OSViContext* ctx = __osViGetCurrentContext();
- if (ctx->mq) {
- osSendMesg(ctx->mq, ctx->msg, OS_MESG_NOBLOCK);
- }
- viRetrace = ctx->retraceCount;
- }
-
- __osViIntrCount++;
-
- // block optimized out since temp is always 0,
- // but it changes register allocation and ordering for __osCurrentTime
- if (temp != 0) {
- addTime = osGetCount();
- __osCurrentTime = addTime;
- temp = 0;
- }
-
- addTime = __osBaseCounter;
- __osBaseCounter = osGetCount();
- addTime = __osBaseCounter - addTime;
- __osCurrentTime = __osCurrentTime + addTime;
- break;
- case 14:
- __osTimerInterrupt();
- break;
- }
- }
-}