match JFramework

This commit is contained in:
SwareJonge
2025-06-16 22:11:30 +02:00
parent 5b865cb165
commit b791f26f44
16 changed files with 1262 additions and 14 deletions
+164
View File
@@ -0,0 +1,164 @@
#ifndef _JSYSTEM_JFW_JFWDISPLAY_H
#define _JSYSTEM_JFW_JFWDISPLAY_H
#include <dolphin/gx.h>
#include <dolphin/mtx.h>
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JUtility/JUTDirectPrint.h"
#include "JSystem/JUtility/JUTFader.h"
#include "JSystem/JUtility/JUTProcBar.h"
#include "JSystem/JUtility/JUTVideo.h"
#include "JSystem/JUtility/JUTXfb.h"
#include "JSystem/JUtility/TColor.h"
#include "types.h"
typedef void (*JFWDisplayUnkFunc)(void);
extern GC_Mtx e_mtx;
class JFWAlarm : public OSAlarm { // everything here seems to be auto inlined or unused
public:
// Contructor and Destructor are both present in map but unused, not sure if it belongs here
JFWAlarm() {}
~JFWAlarm() {}
void createAlarm() { OSCreateAlarm(this); }
void cancelAlarm() { OSCancelAlarm(this); }
OSThread *getThread() const { return mThread; }
void setThread(OSThread *thread) { mThread = thread; }
static JSUList<JFWAlarm> sList;//
public:
/* 0x28 */ OSThread *mThread;
};
class JFWDisplay
{
public:
enum EDrawDone
{
/* 0x0 */ UNK_METHOD_0 = 0,
/* 0x1 */ UNK_METHOD_1 = 1
};
static JFWDisplay *createManager(const _GXRenderModeObj *, JKRHeap *, JUTXfb::EXfbNumber, bool); // 0x80015bfc
void waitBlanking(int); // 0x8001684c
void threadSleep(s64); // 0x800169fc
void clearEfb_init(); // 0x80016ab8
void clearEfb(); // 0x80016b2c
void clearEfb(_GXColor); // 0x80016b58
void clearEfb(int, int, int, int, _GXColor); // 0x80016b9c
void calcCombinationRatio(); // 0x80016f0c
void ctor_subroutine(const GXRenderModeObj *, bool);
JFWDisplay(const GXRenderModeObj *, JKRHeap *, JUTXfb::EXfbNumber, bool);
static void destroyManager();
void prepareCopyDisp();
void drawendXfb_single();
void exchangeXfb_double();
void exchangeXfb_triple();
void copyXfb_triple();
void preGX();
void endGX();
void* changeToSingleXfb(int);
void* changeToDoubleXfb();
// UNUSED
JFWDisplay(void *, bool);
JFWDisplay(void *, void *, bool);
JFWDisplay(void *, void *, void *, bool);
void createManager(const _GXRenderModeObj *, void *, bool);
void createManager(const _GXRenderModeObj *, void *, void *, bool);
void createManager(const _GXRenderModeObj *, void *, void *, void *, bool);
void deleteToSingleXfb(int);
void deleteToSingleXfb(void *);
void addToDoubleXfb(void *, bool);
void addToDoubleXfb(JKRHeap *);
void clearAllXfb();
s32 frameToTick(float);
static void setForOSResetSystem();
// Virtual functions
virtual void beginRender(); // 0x80015e0c
virtual void endRender(); // 0x8001633c
virtual void endFrame(); // 0x8001669c
virtual ~JFWDisplay(); // 0x80015b80
static JFWDisplay *getManager() { return sManager; }
int getEfbHeight() const {
return JUTVideo::getManager()->getEfbHeight();
}
int getEfbWidth() const {
return JUTVideo::getManager()->getFbWidth();
}
JUTFader *getFader() const { return mFader; }
void setFader(JUTFader * fader) { mFader = fader; }
bool startFadeOut(int duration) {
if (mFader != nullptr) {
return mFader->startFadeOut(duration);
}
return true;
}
bool startFadeIn(int duration) {
if (mFader != nullptr) {
return mFader->startFadeIn(duration);
}
return true;
}
void setTickRate(u32 rate) {
mTickRate = rate;
mFrameRate = 0;
}
JUtility::TColor getClearColor() const {
return mClearColor;
}
void setClearColor(u8 r, u8 g, u8 b, u8 a) {
mClearColor.set(r, g, b, a);
}
void setClearColor(JUtility::TColor color)
{
mClearColor = color;
}
void setFBAlpha(bool enable) {
mEnableAlpha = enable;
}
bool getFBAlpha()
{
return mEnableAlpha;
}
static JFWDisplay *sManager; // 0x80415718
private:
JUTFader *mFader; // 04
const GXRenderModeObj *mRMode; // 08
JUtility::TColor mClearColor; // 0c
u32 mZClear; // 10
JUTXfb *mXfb; // 14
u16 mGamma; // 18
EDrawDone mDrawDoneMethod; // 1c
u16 mFrameRate; // 20
u32 mTickRate; // 24
bool mEnableAlpha; // 28
u16 mClamp; // 2a
f32 mCombinationRatio; // 2c
u32 mStartTick; // 30, tick of when the frame starts rendering
u32 mFrameTime; // 34, time it took to render a frame/amount of ticks beginRender took
u32 mVideoFrameTime; // 38, time between mStartTick and the last Video Tick
s16 mDrawingXfbNo; // 3c
bool mIsSingleXfb; // 3e
};
#endif
+70
View File
@@ -0,0 +1,70 @@
#ifndef _JSYSTEM_JFW_JFWSYSTEM_H
#define _JSYSTEM_JFW_JFWSYSTEM_H
#include <dolphin/gx.h>
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JKernel/JKRThread.h"
#include "JSystem/JUtility/JUTAssertion.h"
#include "JSystem/JUtility/JUTConsole.h"
#include "JSystem/JUtility/JUTDbPrint.h"
#include "JSystem/JUtility/JUTFont.h"
#include "types.h"
// Maybe these are namespaces?
struct JFWSystem
{
struct CSetUpParam
{
static int maxStdHeaps;
static u32 sysHeapSize;
static u32 fifoBufSize;
static u32 aramAudioBufSize;
static u32 aramGraphBufSize;
static s32 streamPriority;
static s32 decompPriority;
static s32 aPiecePriority;
static const ResFONT *systemFontRes;
static const _GXRenderModeObj *renderMode;
static u32 exConsoleBufferSize;
};
static void firstInit();
static void init();
static JKRHeap *rootHeap;
static JKRHeap *systemHeap;
static JKRThread *mainThread;
static JUTDbPrint *debugPrint;
static JUTFont *systemFont;
static JUTConsoleManager *systemConsoleManager;
static JUTConsole *systemConsole;
static bool sInitCalled;
// No idea how they formatted this lol
static void setMaxStdHeap(int stdHeaps) {
JUT_ASSERT(sInitCalled == 0);
CSetUpParam::maxStdHeaps = stdHeaps; }
static void setSysHeapSize(u32 heapSize) {
JUT_ASSERT(sInitCalled == 0);
CSetUpParam::sysHeapSize = heapSize; }
static void setFifoBufSize(u32 bufSize) {
JUT_ASSERT(sInitCalled == 0);
CSetUpParam::fifoBufSize = bufSize; }
// Inlines for Aram
static void setAramAudioBufSize(u32 bufSize) {
JUT_ASSERT(sInitCalled == 0);
CSetUpParam::aramAudioBufSize = bufSize; }
static void setAramGraphBufSize(u32 bufSize) {
JUT_ASSERT(sInitCalled == 0);
CSetUpParam::aramGraphBufSize = bufSize; }
// probably some more inlines for other variables, not used by MKDD
static void setRenderMode(const _GXRenderModeObj * rmode) {
#line 80
JUT_ASSERT(sInitCalled == 0);
CSetUpParam::renderMode = rmode; }
};
#endif
+1
View File
@@ -1,6 +1,7 @@
#ifndef _JSYSTEM_JGEOMETRY_H
#define _JSYSTEM_JGEOMETRY_H
#include <dolphin/mtx.h>
#include "types.h"
#ifdef __cplusplus
+1 -1
View File
@@ -3,6 +3,6 @@
#include "JSystem/JKernel/JKRAram.h"
#include "JSystem/JMacro.h"
//#include "JSystem/JUtility/JUTException.h"
#include "JSystem/JUtility/JUTException.h"
#endif
+48
View File
@@ -2,6 +2,54 @@
#define _JSYSTEM_JUT_JUTDBPRINT_H
#ifdef __cplusplus
#include "JSystem/JUtility/TColor.h"
#include "JSystem/JUtility/JUTFont.h"
#include "JSystem/JKernel/JKRHeap.h"
struct JUTDbPrintList
{
JUTDbPrintList *mNext; // _00
s16 mX; // _04
s16 mY; // _06
s16 mDuration; // _08
s16 mLen; // _0A
u8 mStr; // _0C
};
struct JUTDbPrint
{
JUTDbPrint(JUTFont *, JKRHeap *); // unused/inlined
~JUTDbPrint(); // unused/inlined
JUTFont *changeFont(JUTFont *);
void flush();
void flush(int, int, int, int);
void drawString(int, int, int, const u8 *);
// Unused/inlined:
void enter(int, int, int, const char *, int);
void print(int, int, const char *, ...);
void print(int, int, int, const char *, ...);
void reset();
void setVisible(bool visible) { mVisible = visible; }
JUTFont *getFont() const { return mFont; }
JUTDbPrintList *getList() const { return mList; }
static JUTDbPrint *start(JUTFont *, JKRHeap *);
static JUTDbPrint *getManager() { return sDebugPrint; }
static JUTDbPrint *sDebugPrint;
JUTDbPrintList *mList; // _00
JUTFont *mFont; // _04
JUtility::TColor mColor; // _08
bool mVisible; // _0C
JKRHeap *mHeap; // _10
};
extern "C" {
#endif
+1 -1
View File
@@ -40,7 +40,7 @@ private:
void *mFramebuffer; // _00
u16 mFbWidth; // _04
u16 mFbHeight; // _06
u16 mStride; // _08, aligned width?
u16 mStride; // _08
size_t mFbSize; // _0C
u8 _10[0x4]; // _10 - unknown
u16 *mFrameMemory; // _14
+149
View File
@@ -0,0 +1,149 @@
#ifndef _JSYSTEM_JUT_JUTEXCEPTION_H
#define _JSYSTEM_JUT_JUTEXCEPTION_H
#include <dolphin/os.h>
#include "JSystem/JKernel/JKRThread.h"
#include "JSystem/JSupport/JSUList.h"
#include "JSystem/JUtility/JUTGamePad.h"
#include "JSystem/JUtility/JUTXfb.h"
#include "types.h"
struct JUTConsole;
struct JUTDirectPrint;
typedef void (*JUTErrorHandler)(s32 error, OSContext *context, u32 dsisr, u32 dar);
enum ExPrintFlags
{
EXPRINTFLAG_GPR = 0x1,
EXPRINTFLAG_GPRMap = 0x2,
EXPRINTFLAG_SRR0Map = 0x4,
EXPRINTFLAG_Float = 0x8,
EXPRINTFLAG_Stack = 0x10,
EXPRINTFLAG_All = 0x1F,
};
/**
* @size{0xA4}
*/
struct JUTException : public JKRThread
{
enum EInfoPage
{
INFOPAGE_GPR = 1,
INFOPAGE_Float = 2,
INFOPAGE_Stack = 3,
INFOPAGE_GPRMap = 4,
INFOPAGE_SRR0Map = 5,
};
// size: 0x14
struct JUTExMapFile
{
inline JUTExMapFile(const char *fileName)
: mLink(this)
{
mFileName = (char *)fileName;
}
char *mFileName; // _00
JSULink<JUTExMapFile> mLink; // _04
};
/** @fabricated */
struct ExCallbackObject
{
JUTErrorHandler mErrorHandler; // _00
s32 mError; // _04
OSContext *mContext; // _08
u32 _0C; // _0C
u32 _10; // _10
};
JUTException(JUTDirectPrint *); // unused/inlined
virtual ~JUTException(){}; // _08 (weak)
virtual void *run(); // _0C
void showFloat(OSContext *);
void showStack(OSContext *);
void showMainInfo(u16, OSContext *, u32, u32);
bool showMapInfo_subroutine(u32, bool);
void showGPRMap(OSContext *);
void printDebugInfo(JUTException::EInfoPage, u16, OSContext *, u32, u32);
bool readPad(u32 *, u32 *);
void printContext(u16, OSContext *, u32, u32);
void createFB();
static void waitTime(long);
static JUTErrorHandler setPreUserCallback(JUTErrorHandler);
static void appendMapFile(const char *);
static bool queryMapAddress(char *, u32, long, u32 *, u32 *, char *, u32, bool, bool);
static bool queryMapAddress_single(char *, u32, long, u32 *, u32 *, char *, u32, bool, bool);
static JUTException *create(JUTDirectPrint *);
static void createConsole(void *buffer, u32 bufferSize);
static void panic_f(const char *file, int line, const char *msg, ...);
static void errorHandler(u16, OSContext *, u32, u32);
static void setFPException(u32);
static bool searchPartialModule(u32, u32 *, u32 *, u32 *, u32 *);
// unused/inlined:
static void panic_f_va(const char *, int, const char *, va_list);
static JUTErrorHandler setPostUserCallback(JUTErrorHandler);
// Inline
static void panic(const char *file, int line, const char *msg) {
panic_f(file, line, "%s", msg);
}
void showFloatSub(int, f32);
void showGPR(OSContext *);
void showSRR0Map(OSContext *);
bool isEnablePad() const;
u32 getFpscr();
void setFpscr(u32);
void enableFpuException();
void disableFpuException();
JUTExternalFB *getFrameMemory() const { return mFrameMemory; }
void setTraceSuppress(u32 supress) { mTraceSuppress = supress; }
void setGamePad(JUTGamePad *gamePad)
{
mGamePad = gamePad;
mPadPort = JUTGamePad::Port_Invalid;
}
static JUTException *getManager() { return sErrorManager; }
static JUTConsole *getConsole() { return sConsole; }
static JUTConsole *sConsole;
static void *sConsoleBuffer;
static size_t sConsoleBufferSize;
static JUTException *sErrorManager;
static OSMessageQueue sMessageQueue;
static void *sMessageBuffer[1];
static JUTErrorHandler sPreUserCallback;
static JUTErrorHandler sPostUserCallback;
static u32 msr;
static u32 fpscr;
static const char *sCpuExpName[32];
static JSUList<JUTExMapFile> sMapFileList;
// _00 = VTBL
// _00-_7C = JKRThread
JUTExternalFB *mFrameMemory; // _7C
JUTDirectPrint *mDirectPrint; // _80
JUTGamePad *mGamePad; // _84
JUTGamePad::EPadPort mPadPort; // _88
int mPrintWaitTime0; // _8C
int mPrintWaitTime1; // _90
u32 mTraceSuppress; // _94
u32 _98; // _98
u32 mPrintFlags; // _9C, see ExPrintFlags enum
u32 mStackPointer; // _A0
};
#endif
+49
View File
@@ -0,0 +1,49 @@
#ifndef _JUTFADER_H
#define _JUTFADER_H
#include "JSystem/JGeometry.h"
#include "JSystem/JUtility/TColor.h"
#include "JSystem/JUtility/JUTVideo.h"
#include "types.h"
struct JUTFader
{
enum EStatus
{
Status_Out = 0,
Status_In = 1,
Status_FadingIn = 2,
Status_FadingOut = 3
};
JUTFader(int, int, int, int, JUtility::TColor);
virtual ~JUTFader() {} // _08 (weak)
virtual bool startFadeIn(int duration); // _0C
virtual bool startFadeOut(int duration); // _10
virtual void draw(); // _14
void control();
// unused/inlined:
void start(int);
void setStatus(EStatus, int);
void setResetState(bool reset) { mResetting = reset; }
EStatus getStatus() const { return mStatus; }
void setColor(JUtility::TColor color) { mColor.set(color.r, color.g, color.b, mColor.a); }
// _00 VTBL
EStatus mStatus; // _04 - current status
u16 mTicksTarget; // _08 - ticks (calls to control()) to run a fade in/out for
u16 mTicksRun; // _0A - ticks the current fade has run
bool mResetting; // _0C - probably exclusive to mkdd, holds true when starting the fadeout for reset, sets back to false when fading in
u8 _0D[3]; // padding
JUtility::TColor mColor; // _10 - color of fade
JGeometry::TBox2f mViewBox; // _14 - ortho box to render within
int mEStatus; // _24 - ???
EStatus _28; // _28 - ???
};
#endif
+43
View File
@@ -0,0 +1,43 @@
#ifndef _JSYSTEM_JUT_JUTGRAPHFIFO_H
#define _JSYSTEM_JUT_JUTGRAPHFIFO_H
#include "types.h"
#include <dolphin/gx.h>
struct JUTGraphFifo
{
JUTGraphFifo(u32);
virtual ~JUTGraphFifo(); // _08
void becomeCurrent();
void setBreakPt();
void getGpStatus()
{
GXGetGPStatus((GXBool*)&mGpStatus[0], (GXBool*)&mGpStatus[1], (GXBool*)&mGpStatus[2], (GXBool*)&mGpStatus[3],
(GXBool*)&mGpStatus[4]);
}
bool isGPActive()
{
getGpStatus();
return mGpStatus[2] == false;
}
void save() { GXSaveCPUFifo(this->mFifo); }
static JUTGraphFifo *sCurrentFifo;
static GXBool mGpStatus[5];
static bool sInitiated;
// _00 = VTBL
GXFifoObj* mFifo; // _04
void* mBase; // _08
u32 mSize; // _0C
u8 _10[0xC]; // _10
};
inline void JUTCreateFifo(u32 bufSize) { new JUTGraphFifo(bufSize); }
#endif
+8 -11
View File
@@ -8,46 +8,43 @@
#include "dolphin/vi.h"
#ifdef __cplusplus
/**
* @size{0x58}
*/
typedef u8 (*Pattern)[2];
struct JUTVideo
{
JUTVideo(const _GXRenderModeObj *);
JUTVideo(const GXRenderModeObj*);
virtual ~JUTVideo(); // _08
static JUTVideo *createManager(const _GXRenderModeObj *);
static JUTVideo *createManager(const GXRenderModeObj*);
static void destroyManager();
static void preRetraceProc(unsigned long);
static void postRetraceProc(unsigned long);
static void drawDoneCallback();
u16 getEfbHeight() const { return mRenderModeObj->efbHeight; }
u16 getFbWidth() const { return mRenderModeObj->fbWidth; }
u32 getEfbHeight() const { return mRenderModeObj->efbHeight; }
u32 getXfbHeight() const { return mRenderModeObj->xfbHeight; }
u32 getFbWidth() const { return (u16)mRenderModeObj->fbWidth; } // cast required for callDirectDraw
void getBounds(u16& width, u16& height) const {
width = getFbWidth();
height = getEfbHeight();
}
_GXRenderModeObj *getRenderMode() const { return mRenderModeObj; }
u16 getXfbHeight() const { return mRenderModeObj->xfbHeight; }
GXRenderModeObj *getRenderMode() const { return mRenderModeObj; }
u32 isAntiAliasing() const { return mRenderModeObj->aa; }
Pattern getSamplePattern() const { return mRenderModeObj->sample_pattern; }
u8 *getVFilter() const { return mRenderModeObj->vfilter; }
OSMessageQueue *getMessageQueue() { return &mMessageQueue; };
static void drawDoneStart();
static void dummyNoDrawWait();
void setRenderMode(const _GXRenderModeObj *);
void setRenderMode(const GXRenderModeObj*);
void waitRetraceIfNeed(); // blr, global
VIRetraceCallback setPostRetraceCallback(VIRetraceCallback);
// Unused/inlined:
void getDrawWait();
VIRetraceCallback setPreRetraceCallback(VIRetraceCallback);
void getPixelAspect(const _GXRenderModeObj *);
void getPixelAspect(const GXRenderModeObj*);
void getPixelAspect() const;
// Static inline gets
+84
View File
@@ -0,0 +1,84 @@
#ifndef _JSYSTEM_JUT_JUTXFB_H
#define _JSYSTEM_JUT_JUTXFB_H
#include <dolphin/gx.h>
#include <JSystem/JKernel/JKRHeap.h>
#include "types.h"
struct JUTExternalFB
{
JUTExternalFB(GXRenderModeObj *, GXGamma, void *, u32);
GXRenderModeObj *mRenderModeObj; // _00
u32 mSize; // _04
u8 _08[4]; // _08
u16 _0C; // _0C
u16 mGamma; // _0E, treat as GXGamma
bool _10; // _10
};
class JUTXfb
{
public:
enum EXfbNumber
{
Unset = 0,
SingleBuffer = 1,
DoubleBuffer = 2,
TripleBuffer = 3
};
void clearIndex();
void common_init(int);
JUTXfb(const GXRenderModeObj*, JKRHeap*, JUTXfb::EXfbNumber);
~JUTXfb();
void delXfb(int);
static JUTXfb *createManager(const GXRenderModeObj* rmode, JKRHeap*, JUTXfb::EXfbNumber);
static void destroyManager();
void initiate(u16, u16, JKRHeap*, JUTXfb::EXfbNumber);
u32 accumeXfbSize();
int getBufferNum() const { return mBufferNum; }
int getDrawnXfbIndex() const { return mDrawnXfbIndex; }
s16 getDrawingXfbIndex() const { return mDrawingXfbIndex; }
s16 getDisplayingXfbIndex() const { return mDisplayingXfbIndex; }
int getSDrawingFlag() const { return mSDrawingFlag; }
void *getXfb(int index) const {
return mBuffer[index];
}
void *getDrawnXfb() const {
return (mDrawnXfbIndex >= 0) ? mBuffer[mDrawnXfbIndex] : nullptr;
}
void *getDrawingXfb() const {
return (mDrawingXfbIndex >= 0) ? mBuffer[mDrawingXfbIndex] : nullptr;
}
void *getDisplayingXfb() const {
return (mDisplayingXfbIndex >= 0) ? mBuffer[mDisplayingXfbIndex] : nullptr;
}
void setBufferNum(int num) { mBufferNum = num; }
void setDisplayingXfbIndex(s16 index) { mDisplayingXfbIndex = index; }
void setSDrawingFlag(s32 flag) { mSDrawingFlag = flag; }
void setDrawnXfbIndex(s16 index) { mDrawnXfbIndex = index; }
void setDrawingXfbIndex(s16 index) { mDrawingXfbIndex = index; }
static JUTXfb *getManager() { return sManager; }
private:
static JUTXfb *sManager;
private:
void *mBuffer[3]; // 00
bool mXfbAllocated[3]; // 0c
int mBufferNum; // 10
s16 mDrawingXfbIndex; // 14
s16 mDrawnXfbIndex; // 16
s16 mDisplayingXfbIndex; // 18
s32 mSDrawingFlag; // 1a
};
#endif