2021-10-03 21:04:03 +00:00
|
|
|
#ifndef _SYSTEM_H
|
|
|
|
#define _SYSTEM_H
|
|
|
|
|
2021-11-02 03:35:18 +00:00
|
|
|
#include "DvdThreadCommand.h"
|
2022-08-06 05:33:13 +00:00
|
|
|
#include "Dolphin/gx.h"
|
2022-08-09 10:23:11 +00:00
|
|
|
#include "SysTimers.h"
|
2023-01-26 01:54:54 +00:00
|
|
|
#include "JSystem/JKernel/JKRHeap.h"
|
2022-11-03 00:33:18 +00:00
|
|
|
#include "node.h"
|
2022-12-29 23:04:33 +00:00
|
|
|
#include "BitFlag.h"
|
2021-10-03 21:04:03 +00:00
|
|
|
|
2021-12-06 00:22:31 +00:00
|
|
|
struct Graphics;
|
|
|
|
struct OSContext;
|
2022-08-06 05:33:13 +00:00
|
|
|
struct _GXRenderModeObj;
|
2022-12-29 23:04:33 +00:00
|
|
|
struct HeapStatus;
|
2021-12-06 00:22:31 +00:00
|
|
|
|
2021-10-04 17:51:29 +00:00
|
|
|
void Pikmin2DefaultMemoryErrorRoutine(void*, u32, s32);
|
|
|
|
void kando_panic_f(bool, const char*, s32, const char*, ...);
|
2022-01-12 03:31:11 +00:00
|
|
|
extern void preUserCallback(unsigned short, OSContext*, unsigned long, unsigned long);
|
2021-10-04 11:51:11 +00:00
|
|
|
|
2022-12-29 23:04:33 +00:00
|
|
|
// const char* cMapFileName = "/pikmin2UP.map";
|
2021-10-19 10:18:55 +00:00
|
|
|
|
2022-12-29 23:04:33 +00:00
|
|
|
//_GXRenderModeObj* renderMode;
|
|
|
|
|
|
|
|
struct HeapInfo : public Node, public JKRDisposer {
|
2022-11-03 00:33:18 +00:00
|
|
|
virtual ~HeapInfo(); // _20 (weak)
|
|
|
|
|
|
|
|
void search(HeapInfo*);
|
2022-12-29 23:04:33 +00:00
|
|
|
|
2023-10-11 09:09:20 +00:00
|
|
|
void dump(int, bool);
|
|
|
|
void getTotalUsedSize();
|
|
|
|
void dumpNode(int);
|
|
|
|
void search(char*, bool);
|
|
|
|
void isInvalidUsedSize();
|
|
|
|
void isValidUsedSize();
|
|
|
|
void getUsedSize(bool);
|
|
|
|
|
2022-12-29 23:04:33 +00:00
|
|
|
// _00-_24 = Node
|
|
|
|
// _20 = VTBL (Node)
|
|
|
|
// _24-_3C = JKRDisposer
|
|
|
|
u32 _3C; // _3C, unknown
|
|
|
|
int _40; // _40
|
|
|
|
u32 _44; // _44, unknown
|
|
|
|
HeapStatus* _48; // _48
|
|
|
|
HeapStatus* _4C; // _4C
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HeapStatus {
|
|
|
|
HeapStatus();
|
|
|
|
|
2023-10-11 09:09:20 +00:00
|
|
|
void start(char*, JKRHeap*);
|
|
|
|
void end(char*);
|
|
|
|
void setCurrentHeapInfoParent();
|
|
|
|
void searchHeapInfo(char*);
|
|
|
|
void searchHeapInfo(HeapInfo*);
|
|
|
|
void dump(bool);
|
|
|
|
void dumpNode();
|
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
HeapInfo mHeapInfo; // _00
|
|
|
|
u8 _50; // _50, unknown
|
2022-11-03 00:33:18 +00:00
|
|
|
};
|
|
|
|
|
2021-10-19 10:18:55 +00:00
|
|
|
namespace Game {
|
2021-12-06 00:22:31 +00:00
|
|
|
namespace CommonSaveData {
|
2022-01-04 13:51:21 +00:00
|
|
|
struct Mgr;
|
2023-03-16 01:58:40 +00:00
|
|
|
} // namespace CommonSaveData
|
|
|
|
|
|
|
|
namespace MemoryCard {
|
|
|
|
struct Mgr;
|
|
|
|
}
|
2021-10-19 10:18:55 +00:00
|
|
|
} // namespace Game
|
|
|
|
|
2023-10-25 15:48:28 +00:00
|
|
|
#define SINGLE_FRAME_LENGTH (1.0f / 60.0f) // 0.016666668f
|
|
|
|
|
2023-02-09 06:47:52 +00:00
|
|
|
struct System : public OSMutex {
|
2023-10-24 01:53:45 +00:00
|
|
|
enum ERenderMode { NTSC_Standard = 0, NTSC_Progressive, PAL_Standard, PAL_60Hz };
|
2022-12-29 23:04:33 +00:00
|
|
|
|
2022-01-12 03:31:11 +00:00
|
|
|
enum LanguageID { LANG_ENGLISH = 0, LANG_FRENCH, LANG_GERMAN, LANG_HOL_UNUSED, LANG_ITALIAN, LANG_JAPANESE, LANG_SPANISH };
|
2021-10-19 10:18:55 +00:00
|
|
|
struct FragmentationChecker {
|
|
|
|
FragmentationChecker(char*, bool);
|
|
|
|
~FragmentationChecker();
|
2022-12-29 23:04:33 +00:00
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
u32 mSize; // _00
|
|
|
|
char* mName; // _04
|
2022-12-29 23:04:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// unused struct?
|
|
|
|
struct GXVerifyArg {
|
|
|
|
GXVerifyArg();
|
|
|
|
|
|
|
|
u32 _00; // _00
|
|
|
|
u8 _04; // _04
|
2021-10-19 10:18:55 +00:00
|
|
|
};
|
|
|
|
|
2021-10-11 02:05:19 +00:00
|
|
|
System();
|
|
|
|
~System();
|
2021-10-19 10:18:55 +00:00
|
|
|
|
2022-08-06 05:33:13 +00:00
|
|
|
static _GXRenderModeObj* getRenderModeObj();
|
2022-12-29 23:04:33 +00:00
|
|
|
static int assert_fragmentation(char*);
|
2021-10-19 10:18:55 +00:00
|
|
|
static void loadSoundResource();
|
2021-10-11 02:05:19 +00:00
|
|
|
static void initialize();
|
2021-10-19 10:18:55 +00:00
|
|
|
|
2022-12-29 23:04:33 +00:00
|
|
|
void createSoundSystem();
|
2021-10-19 10:18:55 +00:00
|
|
|
void enableCPULockDetector(int);
|
|
|
|
int disableCPULockDetector();
|
|
|
|
void construct();
|
|
|
|
void constructWithDvdAccessFirst();
|
|
|
|
void constructWithDvdAccessSecond();
|
2023-10-25 15:48:28 +00:00
|
|
|
void createRomFont(struct JKRHeap* heap);
|
2021-10-19 10:18:55 +00:00
|
|
|
void destroyRomFont();
|
|
|
|
void loadResourceFirst();
|
|
|
|
void loadResourceSecond();
|
2021-10-11 02:05:19 +00:00
|
|
|
int run();
|
2023-01-16 20:23:01 +00:00
|
|
|
f32 getTime();
|
2021-10-19 10:18:55 +00:00
|
|
|
void clearOptionBlockSaveFlag();
|
|
|
|
void setOptionBlockSaveFlag();
|
|
|
|
Game::CommonSaveData::Mgr* getPlayCommonData();
|
2023-10-25 15:48:28 +00:00
|
|
|
void dvdLoadUseCallBack(struct DvdThreadCommand* cmd, struct IDelegate* delegate);
|
2021-10-19 10:18:55 +00:00
|
|
|
void deleteThreads();
|
2023-10-25 15:48:28 +00:00
|
|
|
struct JFWDisplay* setCurrentDisplay(struct JFWDisplay* currentDisplay);
|
|
|
|
struct JFWDisplay* clearCurrentDisplay(struct JFWDisplay* display);
|
2021-12-15 18:49:16 +00:00
|
|
|
bool beginFrame();
|
2021-10-19 10:18:55 +00:00
|
|
|
void endFrame();
|
|
|
|
void beginRender();
|
|
|
|
void endRender();
|
2022-12-29 23:04:33 +00:00
|
|
|
static ERenderMode setRenderMode(ERenderMode);
|
2021-10-19 10:18:55 +00:00
|
|
|
void changeRenderMode(ERenderMode);
|
2021-12-06 00:22:31 +00:00
|
|
|
// Possibilities: HeapStatus*, bool, ???
|
2021-10-19 10:18:55 +00:00
|
|
|
u32 heapStatusStart(char*, JKRHeap*);
|
|
|
|
void heapStatusEnd(char*);
|
|
|
|
void heapStatusDump(bool);
|
|
|
|
void heapStatusIndividual();
|
|
|
|
void heapStatusNormal();
|
|
|
|
void resetOn(bool);
|
|
|
|
void resetPermissionOn();
|
|
|
|
bool isResetActive();
|
|
|
|
void activeGP();
|
|
|
|
void inactiveGP();
|
|
|
|
bool isDvdErrorOccured();
|
|
|
|
void initCurrentHeapMutex();
|
|
|
|
void startChangeCurrentHeap(JKRHeap*);
|
|
|
|
void endChangeCurrentHeap();
|
|
|
|
void addGenNode(struct CNode*);
|
|
|
|
void initGenNode();
|
|
|
|
void refreshGenNode();
|
|
|
|
void setFrameRate(int);
|
|
|
|
bool dvdLoadSyncNoBlock(struct DvdThreadCommand*);
|
|
|
|
int dvdLoadSyncAllNoBlock();
|
2021-10-03 21:04:03 +00:00
|
|
|
|
2022-12-29 23:04:33 +00:00
|
|
|
// unused/inline
|
|
|
|
void setGXVerifyLevel(System::GXVerifyArg&);
|
|
|
|
void clearGXVerifyLevel();
|
|
|
|
void checkOptionBlockSaveFlag();
|
|
|
|
void dvdLoadArchive(DvdThreadCommand*, char*, JKRHeap*);
|
|
|
|
void dvdLoadArchiveTemporary(DvdThreadCommand*, char*, JKRHeap*);
|
|
|
|
void dvdLoadFile(DvdThreadCommand*, char*, JKRHeap*);
|
|
|
|
void dvdLoadSync(DvdThreadCommand*, DvdThread::ESyncBlockFlag);
|
|
|
|
void dvdLoadSyncAll(DvdThread::ESyncBlockFlag);
|
|
|
|
void heapStatusDumpNode();
|
|
|
|
void resetOff();
|
|
|
|
void forceFinishSection();
|
|
|
|
|
2023-02-16 03:25:00 +00:00
|
|
|
// idk why this exists alongside getPlayCommonData() but that one's global.
|
|
|
|
// this one needs to be weak/inlined.
|
|
|
|
inline Game::CommonSaveData::Mgr* getCommonDataMgr() { return mPlayData; }
|
|
|
|
|
2022-12-29 23:04:33 +00:00
|
|
|
static ERenderMode mRenderMode;
|
|
|
|
static GXVerifyArg sVerifyArg;
|
|
|
|
|
2023-02-01 12:57:48 +00:00
|
|
|
inline f32 getFrameLength() const { return mDeltaTime; }
|
2023-10-16 02:13:47 +00:00
|
|
|
inline f32 getFrameRate(f32 mod) const { return getFrameLength() / mod; }
|
2023-02-01 12:57:48 +00:00
|
|
|
|
2023-02-09 06:47:52 +00:00
|
|
|
// _00-_18 = OSMutex
|
2023-03-16 01:58:40 +00:00
|
|
|
JKRHeap* mBackupHeap; // _18
|
|
|
|
u32 mCpuRetraceCount; // _1C
|
|
|
|
u32 mCpuLockCount; // _20
|
|
|
|
Graphics* mGfx; // _24
|
|
|
|
SysTimers* mTimers; // _28
|
|
|
|
u32 _2C; // _2C
|
|
|
|
u32 _30; // _30
|
|
|
|
u32 _34; // _34
|
|
|
|
JKRHeap* mSysHeap; // _38
|
|
|
|
struct GameFlow* mGameFlow; // _3C
|
|
|
|
struct DvdThread* mDvdThread; // _40
|
|
|
|
struct ResetManager* mResetMgr; // _44
|
|
|
|
struct DvdStatus* mDvdStatus; // _48
|
|
|
|
struct JFWDisplay* mDisplay; // _4C
|
|
|
|
HeapStatus* mHeapStatus; // _50
|
|
|
|
f32 mDeltaTime; // _54
|
|
|
|
struct JKRTask* mTask; // _58
|
|
|
|
Game::MemoryCard::Mgr* mCardMgr; // _5C
|
|
|
|
Game::CommonSaveData::Mgr* mPlayData; // _60
|
|
|
|
f32 mFpsFactor; // _64
|
|
|
|
DvdThreadCommand mThreadCommand; // _68
|
|
|
|
LanguageID mRegion; // _D4
|
2023-07-24 06:26:21 +00:00
|
|
|
BitFlag<u32> mFlags; // _D8 (1 = loadResident)
|
2023-03-16 01:58:40 +00:00
|
|
|
struct JUTRomFont* mRomFont; // _DC
|
2021-10-03 21:04:03 +00:00
|
|
|
};
|
|
|
|
|
2021-12-23 15:14:01 +00:00
|
|
|
extern System* sys;
|
2021-11-01 02:25:00 +00:00
|
|
|
|
2021-10-14 19:43:06 +00:00
|
|
|
#endif
|