mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-16 04:44:44 +00:00
More documentation for sched.c (#1219)
* More documentation for sched.c * VI retrace -> vertical retrace, attempt to clarify comment in viconfig * Further review changes, fix inconsistent capitalization of PreNMI (PRENMI -> PreNMI) * Fix typo Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Change TaskSwapBuffer, change comment on OS_SC_DRAM_DLIST to unimplemented * Rename SchedContext/gSchedContext to Scheduler/gScheduler * Comments fixes Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Format Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
parent
ee5ac838b6
commit
1738b19d63
20 changed files with 449 additions and 268 deletions
|
@ -19,7 +19,7 @@ void cleararena(void);
|
|||
void bootproc(void);
|
||||
void Main_ThreadEntry(void* arg);
|
||||
void Idle_ThreadEntry(void* arg);
|
||||
void ViConfig_UpdateVi(u32 mode);
|
||||
void ViConfig_UpdateVi(u32 black);
|
||||
void ViConfig_UpdateBlack(void);
|
||||
s32 DmaMgr_CompareName(const char* name1, const char* name2);
|
||||
s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size);
|
||||
|
@ -977,7 +977,7 @@ void MapMark_Draw(PlayState* play);
|
|||
void PreNmiBuff_Init(PreNmiBuff* this);
|
||||
void PreNmiBuff_SetReset(PreNmiBuff* this);
|
||||
u32 PreNmiBuff_IsResetting(PreNmiBuff* this);
|
||||
void MsgEvent_SendNullTask(void);
|
||||
void Sched_FlushTaskQueue(void);
|
||||
f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b);
|
||||
f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b);
|
||||
f32 OLib_ClampMinDist(f32 val, f32 min);
|
||||
|
@ -1563,10 +1563,10 @@ void THA_Dt(TwoHeadArena* tha);
|
|||
void func_800C3C20(void);
|
||||
void func_800C3C80(AudioMgr* audioMgr);
|
||||
void AudioMgr_HandleRetrace(AudioMgr* audioMgr);
|
||||
void AudioMgr_HandlePRENMI(AudioMgr* audioMgr);
|
||||
void AudioMgr_HandlePreNMI(AudioMgr* audioMgr);
|
||||
void AudioMgr_ThreadEntry(void* arg0);
|
||||
void AudioMgr_Unlock(AudioMgr* audioMgr);
|
||||
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr);
|
||||
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, Scheduler* sched, IrqMgr* irqMgr);
|
||||
void TitleSetup_InitImpl(GameState* gameState);
|
||||
void TitleSetup_Destroy(GameState* gameState);
|
||||
void TitleSetup_Init(GameState* gameState);
|
||||
|
@ -1630,24 +1630,6 @@ void PadMgr_HandlePreNMI(PadMgr* padmgr);
|
|||
// fault.c (actual bug in game), and the compiler notices and won't compile it
|
||||
// void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 mode);
|
||||
void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack);
|
||||
void Sched_SwapFrameBuffer(CfbInfo* cfbInfo);
|
||||
void func_800C84E4(SchedContext* sc, CfbInfo* cfbInfo);
|
||||
void Sched_HandleReset(SchedContext* sc);
|
||||
void Sched_HandleStart(SchedContext* sc);
|
||||
void Sched_QueueTask(SchedContext* sc, OSScTask* task);
|
||||
void Sched_Yield(SchedContext* sc);
|
||||
OSScTask* func_800C89D4(SchedContext* sc, OSScTask* task);
|
||||
s32 Sched_Schedule(SchedContext* sc, OSScTask** sp, OSScTask** dp, s32 state);
|
||||
void func_800C8BC4(SchedContext* sc, OSScTask* task);
|
||||
u32 Sched_IsComplete(SchedContext* sc, OSScTask* task);
|
||||
void Sched_RunTask(SchedContext* sc, OSScTask* spTask, OSScTask* dpTask);
|
||||
void Sched_HandleEntry(SchedContext* sc);
|
||||
void Sched_HandleRetrace(SchedContext* sc);
|
||||
void Sched_HandleRSPDone(SchedContext* sc);
|
||||
void Sched_HandleRDPDone(SchedContext* sc);
|
||||
void Sched_SendEntryMsg(SchedContext* sc);
|
||||
void Sched_ThreadEntry(void* arg);
|
||||
void Sched_Init(SchedContext* sc, void* stack, OSPri priority, UNK_TYPE arg3, UNK_TYPE arg4, IrqMgr* irqMgr);
|
||||
void SpeedMeter_InitImpl(SpeedMeter* this, u32 arg1, u32 y);
|
||||
void SpeedMeter_Init(SpeedMeter* this);
|
||||
void SpeedMeter_Destroy(SpeedMeter* this);
|
||||
|
@ -2261,7 +2243,7 @@ void guMtxF2L(MtxF* m1, Mtx* m2);
|
|||
// ? __ll_to_f(?);
|
||||
// ? __ull_to_d(?);
|
||||
// ? __ull_to_f(?);
|
||||
u32* osViGetCurrentFramebuffer(void);
|
||||
void* osViGetCurrentFramebuffer(void);
|
||||
s32 __osSpSetPc(void* pc);
|
||||
f32 absf(f32);
|
||||
void* __osMemset(void* dest, s32 val, size_t len);
|
||||
|
|
70
include/sched.h
Normal file
70
include/sched.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
#ifndef SCHED_H
|
||||
#define SCHED_H
|
||||
|
||||
#include "ultra64.h"
|
||||
#include "irqmgr.h"
|
||||
|
||||
#define OS_SC_NEEDS_RDP 0x0001 // Task uses the RDP
|
||||
#define OS_SC_NEEDS_RSP 0x0002 // Task uses the RSP
|
||||
#define OS_SC_DRAM_DLIST 0x0004 // Unimplemented
|
||||
#define OS_SC_PARALLEL_TASK 0x0010 // Unimplemented
|
||||
#define OS_SC_LAST_TASK 0x0020 // Unimplemented
|
||||
#define OS_SC_SWAPBUFFER 0x0040 // Swap framebuffer when done
|
||||
|
||||
#define OS_SC_DP OS_SC_NEEDS_RDP // Task is using the RDP
|
||||
#define OS_SC_SP OS_SC_NEEDS_RSP // Task is using the RSP
|
||||
#define OS_SC_YIELD 0x0010 // Task has been asked to yield
|
||||
#define OS_SC_YIELDED 0x0020 // Task has yielded
|
||||
|
||||
#define OS_SC_RCP_MASK (OS_SC_NEEDS_RDP | OS_SC_NEEDS_RSP)
|
||||
#define OS_SC_TYPE_MASK (OS_SC_NEEDS_RDP | OS_SC_NEEDS_RSP | OS_SC_DRAM_DLIST)
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u16* framebuffer; // current framebuffer
|
||||
/* 0x04 */ u16* swapBuffer; // framebuffer to swap to
|
||||
/* 0x08 */ OSViMode* viMode;
|
||||
/* 0x0C */ u32 viFeatures;
|
||||
/* 0x10 */ u8 unk_10; // set to 0, never read
|
||||
/* 0x11 */ s8 updateRate; // how many VIs should elapse before next swap
|
||||
/* 0x12 */ s8 updateTimer; // counts down (in VIs) from updateRate to 0, swaps the framebuffer at 0
|
||||
/* 0x14 */ f32 xScale;
|
||||
/* 0x18 */ f32 yScale;
|
||||
} CfbInfo; // size = 0x1C
|
||||
|
||||
typedef struct OSScTask {
|
||||
/* 0x00 */ struct OSScTask* next;
|
||||
/* 0x04 */ u32 state;
|
||||
/* 0x08 */ u32 flags;
|
||||
/* 0x0C */ CfbInfo* framebuffer; // The original libultra OSScTask had void* here, it would point directly to a framebuffer
|
||||
/* 0x10 */ OSTask list;
|
||||
/* 0x50 */ OSMesgQueue* msgQueue; // Notification queue, will receive a message when the task completes
|
||||
/* 0x54 */ OSMesg msg;
|
||||
/* 0x58 */ OSTime startTime; // These last two fields are a guess based on the original libultra OSScTask and padding in other structures, they are unused.
|
||||
/* 0x60 */ OSTime totalTime;
|
||||
} OSScTask; // size = 0x68
|
||||
|
||||
typedef struct {
|
||||
/* 0x0000 */ OSMesgQueue interruptQueue;
|
||||
/* 0x0018 */ OSMesg interruptMsgBuf[8];
|
||||
/* 0x0038 */ OSMesgQueue cmdQueue; // queue for receiving OSScTask pointers
|
||||
/* 0x0050 */ OSMesg cmdMsgBuf[8];
|
||||
/* 0x0070 */ OSThread thread;
|
||||
/* 0x0220 */ OSScTask* audioListHead;
|
||||
/* 0x0224 */ OSScTask* gfxListHead;
|
||||
/* 0x0228 */ OSScTask* audioListTail;
|
||||
/* 0x022C */ OSScTask* gfxListTail;
|
||||
/* 0x0230 */ OSScTask* curRSPTask; // task currently using the RSP
|
||||
/* 0x0234 */ OSScTask* curRDPTask; // task currently using the RDP
|
||||
/* 0x0238 */ s32 retraceCount;
|
||||
/* 0x023C */ s32 doAudio;
|
||||
/* 0x0240 */ CfbInfo* curBuf; // current framebuffer (taken from buffer 1)
|
||||
/* 0x0244 */ CfbInfo* pendingSwapBuf1; // buffer 1 (next buffer)
|
||||
/* 0x0220 */ CfbInfo* pendingSwapBuf2; // buffer 2 (always NULL)
|
||||
/* 0x0220 */ s32 isFirstSwap;
|
||||
/* 0x0250 */ IrqMgrClient irqClient;
|
||||
} Scheduler; // size = 0x258
|
||||
|
||||
void Sched_Notify(Scheduler* sc);
|
||||
void Sched_Init(Scheduler* sc, void* stack, OSPri priority, UNK_TYPE arg3, UNK_TYPE arg4, IrqMgr* irqMgr);
|
||||
|
||||
#endif
|
|
@ -15,7 +15,7 @@ extern u8 osAppNMIBuffer[0x40];
|
|||
extern s8 D_80009430;
|
||||
extern u32 gDmaMgrVerbose;
|
||||
extern u32 gDmaMgrDmaBuffSize;
|
||||
extern vu8 gViConfigUseDefault;
|
||||
extern vu8 gViConfigBlack;
|
||||
extern u8 gViConfigAdditionalScanLines;
|
||||
extern u32 gViConfigFeatures;
|
||||
extern f32 gViConfigXScale;
|
||||
|
@ -184,7 +184,7 @@ extern PauseMapMarksData* gLoadedPauseMarkDataTable;
|
|||
extern s32 gTrnsnUnkState;
|
||||
extern Color_RGBA8_u32 D_801614B0;
|
||||
extern PreNmiBuff* gAppNmiBufferPtr;
|
||||
extern SchedContext gSchedContext;
|
||||
extern Scheduler gScheduler;
|
||||
extern PadMgr gPadMgr;
|
||||
extern u32 gSegments[NUM_SEGMENTS];
|
||||
extern volatile OSTime D_8016A520;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "irqmgr.h"
|
||||
#include "padmgr.h"
|
||||
#include "fault.h"
|
||||
#include "sched.h"
|
||||
|
||||
#define SCREEN_WIDTH 320
|
||||
#define SCREEN_HEIGHT 240
|
||||
|
@ -116,30 +117,6 @@ typedef struct {
|
|||
/* 0x000C */ Gfx* d;
|
||||
} TwoHeadGfxArena; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u16* fb1;
|
||||
/* 0x04 */ u16* swapBuffer;
|
||||
/* 0x08 */ OSViMode* viMode;
|
||||
/* 0x0C */ u32 features;
|
||||
/* 0x10 */ u8 unk_10;
|
||||
/* 0x11 */ s8 updateRate;
|
||||
/* 0x12 */ s8 updateRate2;
|
||||
/* 0x13 */ u8 unk_13;
|
||||
/* 0x14 */ f32 xScale;
|
||||
/* 0x18 */ f32 yScale;
|
||||
} CfbInfo; // size = 0x1C
|
||||
|
||||
typedef struct OSScTask {
|
||||
/* 0x00 */ struct OSScTask* next;
|
||||
/* 0x04 */ u32 state;
|
||||
/* 0x08 */ u32 flags;
|
||||
/* 0x0C */ CfbInfo* framebuffer;
|
||||
/* 0x10 */ OSTask list;
|
||||
/* 0x50 */ OSMesgQueue* msgQueue;
|
||||
/* 0x54 */ OSMesg msg;
|
||||
/* 0x58 */ char unk_58[0x10];
|
||||
} OSScTask; // size = 0x68
|
||||
|
||||
typedef struct GraphicsContext {
|
||||
/* 0x0000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0"
|
||||
/* 0x0004 */ Gfx* polyXluBuffer; // Pointer to "Zelda 1"
|
||||
|
@ -150,7 +127,6 @@ typedef struct GraphicsContext {
|
|||
/* 0x0038 */ OSMesg msgBuff[0x08];
|
||||
/* 0x0058 */ OSMesgQueue* schedMsgQueue;
|
||||
/* 0x005C */ OSMesgQueue queue;
|
||||
/* 0x0074 */ char unk_074[0x04];
|
||||
/* 0x0078 */ OSScTask task;
|
||||
/* 0x00E0 */ char unk_0E0[0xD0];
|
||||
/* 0x01B0 */ Gfx* workBuffer;
|
||||
|
@ -1580,63 +1556,18 @@ typedef struct {
|
|||
/* 0x10 */ u32 data[1];
|
||||
} Yaz0Header; // size = 0x10 ("data" is not part of the header)
|
||||
|
||||
// == Previously sched.h
|
||||
|
||||
#define OS_SC_NEEDS_RDP 0x0001
|
||||
#define OS_SC_NEEDS_RSP 0x0002
|
||||
#define OS_SC_DRAM_DLIST 0x0004
|
||||
#define OS_SC_PARALLEL_TASK 0x0010
|
||||
#define OS_SC_LAST_TASK 0x0020
|
||||
#define OS_SC_SWAPBUFFER 0x0040
|
||||
|
||||
#define OS_SC_RCP_MASK 0x0003
|
||||
#define OS_SC_TYPE_MASK 0x0007
|
||||
|
||||
typedef struct {
|
||||
/* 0x0000 */ u16* curBuffer;
|
||||
/* 0x0004 */ u16* nextBuffer;
|
||||
} FrameBufferSwap;
|
||||
|
||||
typedef struct {
|
||||
/* 0x0000 */ OSMesgQueue interruptQueue;
|
||||
/* 0x0018 */ OSMesg interruptMsgBuf[8];
|
||||
/* 0x0038 */ OSMesgQueue cmdQueue;
|
||||
/* 0x0050 */ OSMesg cmdMsgBuf[8];
|
||||
/* 0x0070 */ OSThread thread;
|
||||
/* 0x0220 */ OSScTask* audioListHead;
|
||||
/* 0x0224 */ OSScTask* gfxListHead;
|
||||
/* 0x0228 */ OSScTask* audioListTail;
|
||||
/* 0x022C */ OSScTask* gfxListTail;
|
||||
/* 0x0230 */ OSScTask* curRSPTask;
|
||||
/* 0x0234 */ OSScTask* curRDPTask;
|
||||
/* 0x0238 */ s32 retraceCnt;
|
||||
/* 0x023C */ s32 doAudio;
|
||||
/* 0x0240 */ CfbInfo* curBuf;
|
||||
/* 0x0244 */ CfbInfo* pendingSwapBuf1;
|
||||
/* 0x0220 */ CfbInfo* pendingSwapBuf2;
|
||||
/* 0x0220 */ UNK_TYPE4 unk_24C;
|
||||
/* 0x0250 */ IrqMgrClient irqClient;
|
||||
} SchedContext; // size = 0x258
|
||||
|
||||
// ========================
|
||||
|
||||
#define OS_SC_DP 0x0001
|
||||
#define OS_SC_SP 0x0002
|
||||
#define OS_SC_YIELD 0x0010
|
||||
#define OS_SC_YIELDED 0x0020
|
||||
|
||||
typedef struct {
|
||||
/* 0x0000 */ IrqMgr* irqMgr;
|
||||
/* 0x0004 */ SchedContext* sched;
|
||||
/* 0x0008 */ OSScTask audioTask;
|
||||
/* 0x0070 */ AudioTask* rspTask;
|
||||
/* 0x0074 */ OSMesgQueue interruptQueue;
|
||||
/* 0x008C */ OSMesg interruptMsgBuf[8];
|
||||
/* 0x00AC */ OSMesgQueue taskQueue;
|
||||
/* 0x00C4 */ OSMesg taskMsgBuf[1];
|
||||
/* 0x00C8 */ OSMesgQueue lockQueue;
|
||||
/* 0x00E0 */ OSMesg lockMsgBuf[1];
|
||||
/* 0x00E8 */ OSThread thread;
|
||||
/* 0x0000 */ IrqMgr* irqMgr;
|
||||
/* 0x0004 */ Scheduler* sched;
|
||||
/* 0x0008 */ OSScTask audioTask;
|
||||
/* 0x0070 */ AudioTask* rspTask;
|
||||
/* 0x0074 */ OSMesgQueue interruptQueue;
|
||||
/* 0x008C */ OSMesg interruptMsgBuf[8];
|
||||
/* 0x00AC */ OSMesgQueue taskQueue;
|
||||
/* 0x00C4 */ OSMesg taskMsgBuf[1];
|
||||
/* 0x00C8 */ OSMesgQueue lockQueue;
|
||||
/* 0x00E0 */ OSMesg lockMsgBuf[1];
|
||||
/* 0x00E8 */ OSThread thread;
|
||||
} AudioMgr; // size = 0x298
|
||||
|
||||
struct ArenaNode;
|
||||
|
@ -1823,7 +1754,6 @@ typedef struct {
|
|||
/* 0x14 */ u8* dhtPtr[4];
|
||||
/* 0x24 */ void* imageData;
|
||||
/* 0x28 */ u32 mode; // 0 if Y V0 is 1 and 2 if Y V0 is 2
|
||||
/* 0x2C */ char unk_2C[4];
|
||||
/* 0x30 */ OSScTask scTask;
|
||||
/* 0x98 */ OSMesgQueue mq;
|
||||
/* 0xB0 */ OSMesg msg;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue