[headers] Move padmgr, scheduler, irqmgr symbols to respective headers; add segmented_address.h (#1681)

* [headers] Move padmgr, scheduler symbols to respective headers

* fix revealed header problems

* Fix bss

* review

* bss

* segmented_address.h

---------

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
This commit is contained in:
Dragorn421 2024-09-08 00:47:22 +02:00 committed by GitHub
parent e982c44721
commit 2e2b2e2c7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 55 additions and 40 deletions

View File

@ -7,7 +7,7 @@
#include "scheduler.h"
#include "z64audio.h"
typedef struct {
typedef struct AudioMgr {
/* 0x000 */ IrqMgr* irqMgr;
/* 0x004 */ Scheduler* sched;
/* 0x008 */ OSScTask audioTask;

View File

@ -2,9 +2,7 @@
#define IDLE_H
#include "ultra64.h"
#include "irqmgr.h"
extern IrqMgr gIrqMgr;
extern OSMesgQueue gPiMgrCmdQueue;
extern OSViMode gViConfigMode;
extern u8 gViConfigModeType;

View File

@ -15,7 +15,7 @@ typedef struct IrqMgrClient {
/* 0x4 */ OSMesgQueue* queue;
} IrqMgrClient; // size = 0x8
typedef struct {
typedef struct IrqMgr {
/* 0x000 */ OSScMsg retraceMsg;
/* 0x020 */ OSScMsg prenmiMsg;
/* 0x040 */ OSScMsg nmiMsg;
@ -29,6 +29,8 @@ typedef struct {
/* 0x278 */ OSTime retraceTime;
} IrqMgr; // size = 0x280
extern IrqMgr gIrqMgr;
extern vs32 gIrqMgrResetStatus;
extern volatile OSTime sIrqMgrResetTime;
extern volatile OSTime gIrqMgrRetraceTime;

View File

@ -3,22 +3,12 @@
#include "ultra64.h"
#include "stdint.h"
#include "scheduler.h"
#include "padmgr.h"
extern s32 gScreenWidth;
extern s32 gScreenHeight;
extern size_t gSystemHeapSize;
extern uintptr_t gSegments[NUM_SEGMENTS];
extern Scheduler gScheduler;
extern OSThread gGraphThread;
extern PadMgr gPadMgr;
void Main(void* arg);
#define SEGMENTED_TO_K0(addr) (void*)((gSegments[SEGMENT_NUMBER(addr)] + K0BASE) + SEGMENT_OFFSET(addr))
#endif

View File

@ -23,7 +23,7 @@ typedef enum {
/* 2 */ CONT_PAK_OTHER
} ControllerPakType;
typedef struct {
typedef struct PadMgr {
/* 0x000 */ u8 validCtrlrsMask;
/* 0x004 */ void (*rumbleRetraceCallback)(void*);
/* 0x008 */ void* rumbleRetraceArg;
@ -88,4 +88,6 @@ void PadMgr_RumbleSetSingle(s32 port, s32 enable);
void PadMgr_RumbleSet(u8 enable[MAXCONTROLLERS]);
s32 PadMgr_ControllerHasRumblePak(s32 port);
extern PadMgr gPadMgr;
#endif

View File

@ -28,7 +28,7 @@ typedef struct {
/* 0x18 */ f32 yScale;
} CfbInfo; // size = 0x1C
typedef struct {
typedef struct Scheduler {
/* 0x000 */ OSMesgQueue interruptQueue;
/* 0x018 */ OSMesg interruptMsgBuf[64];
/* 0x118 */ OSMesgQueue cmdQueue;
@ -58,4 +58,6 @@ void Sched_SendGfxCancelMsg(Scheduler* sched);
void Sched_Init(Scheduler* sched, void* stack, OSPri pri, u8 viModeType, UNK_TYPE arg4, IrqMgr* irqMgr);
extern Scheduler gScheduler;
#endif

View File

@ -0,0 +1,12 @@
#ifndef SEGMENTED_ADDRESS_H
#define SEGMENTED_ADDRESS_H
#include "ultra64.h"
#include "stdint.h"
extern uintptr_t gSegments[NUM_SEGMENTS];
#define SEGMENTED_TO_K0(addr) (void*)((gSegments[SEGMENT_NUMBER(addr)] + K0BASE) + SEGMENT_OFFSET(addr))
#endif

View File

@ -23,6 +23,7 @@
#include "padutils.h"
#include "regs.h"
#include "scheduler.h"
#include "segmented_address.h"
#include "sequence.h"
#include "seqcmd.h"
#include "sfx.h"

View File

@ -1,6 +1,8 @@
#ifndef Z64PLAYER_H
#define Z64PLAYER_H
#include "stdbool.h"
#include "alignment.h"
#include "PR/os.h"
#include "z64actor.h"

View File

@ -1,6 +1,8 @@
#include "prevent_bss_reordering.h"
#include "stdbool.h"
#include "buffers.h"
#include "irqmgr.h"
#include "main.h"
#include "segment_symbols.h"
#include "stack.h"
@ -10,7 +12,7 @@
#include "z64thread.h"
// Variables are put before most headers as a hacky way to bypass bss reordering
IrqMgr gIrqMgr;
struct IrqMgr gIrqMgr;
STACK(sIrqMgrStack, 0x500);
StackEntry sIrqMgrStackInfo;
OSThread sMainThread;
@ -22,6 +24,7 @@ OSViMode gViConfigMode;
u8 gViConfigModeType;
#include "idle.h"
#include "irqmgr.h"
u8 D_80096B20 = 1;
vu8 gViConfigUseBlack = true;

View File

@ -1,19 +1,13 @@
#include "audiomgr.h"
#include "fault.h"
#include "idle.h"
#include "irqmgr.h"
#include "padmgr.h"
#include "scheduler.h"
#include "CIC6105.h"
#include "prevent_bss_reordering.h"
#include "ultra64.h"
#include "stack.h"
#include "stackcheck.h"
// Variables are put before most headers as a hacky way to bypass bss reordering
OSMesgQueue sSerialEventQueue;
OSMesg sSerialMsgBuf[1];
u32 gSegments[NUM_SEGMENTS];
Scheduler gScheduler;
IrqMgrClient sIrqClient;
struct Scheduler gScheduler;
struct IrqMgrClient sIrqClient;
OSMesgQueue sIrqMgrMsgQueue;
OSMesg sIrqMgrMsgBuf[60];
OSThread gGraphThread;
@ -21,17 +15,28 @@ STACK(sGraphStack, 0x1800);
STACK(sSchedStack, 0x600);
STACK(sAudioStack, 0x800);
STACK(sPadMgrStack, 0x500);
StackEntry sGraphStackInfo;
StackEntry sSchedStackInfo;
StackEntry sAudioStackInfo;
StackEntry sPadMgrStackInfo;
AudioMgr sAudioMgr;
struct StackEntry sGraphStackInfo;
struct StackEntry sSchedStackInfo;
struct StackEntry sAudioStackInfo;
struct StackEntry sPadMgrStackInfo;
struct AudioMgr sAudioMgr;
static s32 sBssPad;
PadMgr gPadMgr;
struct PadMgr gPadMgr;
#include "main.h"
#include "audiomgr.h"
#include "buffers.h"
#include "global.h"
#include "CIC6105.h"
#include "fault.h"
#include "idle.h"
#include "irqmgr.h"
#include "padmgr.h"
#include "regs.h"
#include "segment_symbols.h"
#include "stack.h"
#include "stackcheck.h"
#include "scheduler.h"
#include "sys_initial_check.h"
#include "system_heap.h"
#include "z64nmi_buff.h"

View File

@ -38,7 +38,7 @@
#include "fault.h"
#include "macros.h"
#include "main.h"
#include "scheduler.h"
#include "z64math.h"
#include "z64voice.h"

View File

@ -3,7 +3,6 @@
#include "libc64/malloc.h"
#include "gfx.h"
#include "main.h"
#include "regs.h"
#include "sys_cfb.h"
#include "z64game.h"

View File

@ -1,7 +1,7 @@
#include "z64jpeg.h"
#include "stdbool.h"
#include "main.h"
#include "scheduler.h"
#include "sys_ucode.h"
#include "macros.h"

View File

@ -3,7 +3,7 @@
#include "libc64/qrand.h"
#include "main.h"
#include "segmented_address.h"
#include "sfx.h"
#include "z64game.h"

View File

@ -1,7 +1,6 @@
#include "scheduler.h"
#include "macros.h"
#include "main.h"
/**
* Blocks the current thread until all queued scheduler tasks have completed.