summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakaRikka <38417346+TakaRikka@users.noreply.github.com>2022-01-09 17:33:14 -0800
committerTakaRikka <38417346+TakaRikka@users.noreply.github.com>2022-01-09 17:33:14 -0800
commit37146dfed130ad271f552fc1bbfff4dde7958d53 (patch)
tree26a14703979221daf1a642c9f3726cf7a93dd992
parent035a24092ee91139ab60d41fb5f8b4fb35053281 (diff)
JFramework mostly ok
-rw-r--r--include/JSystem/JFramework/JFWDisplay.h53
-rw-r--r--include/JSystem/JFramework/JFWSystem.h28
-rw-r--r--include/JSystem/JUtility/JUTConsole.h18
-rw-r--r--include/JSystem/JUtility/JUTProcBar.h85
-rw-r--r--include/JSystem/JUtility/JUTVideo.h22
-rw-r--r--include/JSystem/JUtility/JUTXfb.h6
-rw-r--r--include/dolphin/gx/GX.h88
-rw-r--r--include/dolphin/os/OS.h21
-rw-r--r--libs/JSystem/JFramework/JFWDisplay.cpp921
-rw-r--r--libs/JSystem/JFramework/JFWSystem.cpp167
-rw-r--r--libs/JSystem/JParticle/JPAResource.cpp2
-rw-r--r--libs/JSystem/JUtility/JUTException.cpp2
-rw-r--r--libs/JSystem/JUtility/JUTProcBar.cpp40
-rw-r--r--libs/JSystem/JUtility/JUTVideo.cpp3
-rw-r--r--src/m_Do/m_Do_graphic.cpp4
-rw-r--r--src/m_Do/m_Do_machine.cpp3
-rw-r--r--src/m_Do/m_Do_main.cpp4
17 files changed, 881 insertions, 586 deletions
diff --git a/include/JSystem/JFramework/JFWDisplay.h b/include/JSystem/JFramework/JFWDisplay.h
index b7fd742e16..ec61c69e86 100644
--- a/include/JSystem/JFramework/JFWDisplay.h
+++ b/include/JSystem/JFramework/JFWDisplay.h
@@ -2,21 +2,45 @@
#define JFWDISPLAY_H
#include "JSystem/JKernel/JKRHeap.h"
+#include "JSystem/JUtility/JUTDirectPrint.h"
#include "JSystem/JUtility/JUTFader.h"
+#include "JSystem/JUtility/JUTProcBar.h"
#include "JSystem/JUtility/JUTXfb.h"
#include "JSystem/JUtility/TColor.h"
#include "dolphin/gx/GX.h"
#include "dolphin/types.h"
+typedef void (*UnkFunc)(void);
+
+class JFWAlarm : public OSAlarm {
+public:
+ JFWAlarm() : mLink(this) {}
+ ~JFWAlarm() {}
+ void createAlarm() { OSCreateAlarm(this); }
+ void cancelAlarm() { OSCancelAlarm(this); }
+ void removeLink() { sList.remove(&mLink); }
+ void appendLink() { sList.append(&mLink); }
+ OSThread* getThread() const { return mThread; }
+ void setThread(OSThread* thread) { mThread = thread; }
+
+ static JSUList<JFWAlarm> sList;
+
+public:
+ /* 0x28 */ OSThread* mThread;
+ /* 0x2C */ JSULink<JFWAlarm> mLink;
+};
+
class JFWDisplay {
public:
enum EDrawDone {
+ /* 0x0 */ UNK_METHOD_0 = 0,
/* 0x1 */ UNK_METHOD_1 = 1
};
/* 80272040 */ void ctor_subroutine(bool);
/* 802720F8 */ JFWDisplay(JKRHeap*, JUTXfb::EXfbNumber, bool);
- /* 802721DC */ void createManager(_GXRenderModeObj const*, JKRHeap*, JUTXfb::EXfbNumber, bool);
+ /* 802721DC */ static JFWDisplay* createManager(_GXRenderModeObj const*, JKRHeap*,
+ JUTXfb::EXfbNumber, bool);
/* 802722B8 */ void prepareCopyDisp();
/* 802723AC */ void drawendXfb_single();
/* 802723F4 */ void exchangeXfb_double();
@@ -58,23 +82,34 @@ public:
private:
/* 0x04 */ JUTFader* mFader;
/* 0x08 */ JUtility::TColor mClearColor;
- /* 0x0C */ u32 field_0xc;
+ /* 0x0C */ u32 mZClear;
/* 0x10 */ JUTXfb* mXfbManager;
- /* 0x14 */ u16 field_0x14;
+ /* 0x14 */ u16 mGamma;
/* 0x18 */ EDrawDone mDrawDoneMethod;
/* 0x1C */ u16 mFrameRate;
/* 0x20 */ u32 mTickRate;
- /* 0x24 */ bool field_0x24;
+ /* 0x24 */ bool mEnableAlpha;
+ /* 0x26 */ u16 mClamp;
/* 0x28 */ f32 mCombinationRatio;
/* 0x2C */ u32 field_0x2c;
- /* 0x30 */ int field_0x30;
- /* 0x34 */ int field_0x34;
+ /* 0x30 */ u32 field_0x30;
+ /* 0x34 */ u32 field_0x34;
/* 0x38 */ int field_0x38;
/* 0x3C */ int field_0x3c;
- /* 0x40 */ u8 field_0x40;
- /* 0x44 */ int field_0x44;
- /* 0x48 */ u16 field_0x48;
+ /* 0x40 */ bool field_0x40;
+ /* 0x44 */ UnkFunc field_0x44;
+ /* 0x48 */ s16 field_0x48;
/* 0x4A */ u8 field_0x4a;
};
+inline void JUTChangeFrameBuffer(void* buffer, u16 height, u16 width) {
+ JUTDirectPrint::getManager()->changeFrameBuffer(buffer, width, height);
+}
+
+static void JFWDrawDoneAlarm();
+static void JFWThreadAlarmHandler(OSAlarm*, OSContext*);
+static void JFWGXAbortAlarmHandler(OSAlarm*, OSContext*);
+static void waitForTick(u32, u16);
+static void diagnoseGpHang();
+
#endif /* JFWDISPLAY_H */
diff --git a/include/JSystem/JFramework/JFWSystem.h b/include/JSystem/JFramework/JFWSystem.h
index a618ea68f6..b8af555edf 100644
--- a/include/JSystem/JFramework/JFWSystem.h
+++ b/include/JSystem/JFramework/JFWSystem.h
@@ -1,12 +1,16 @@
#ifndef JFWSYSTEM_H
#define JFWSYSTEM_H
+#include "JSystem/JKernel/JKRExpHeap.h"
+#include "JSystem/JKernel/JKRThread.h"
#include "JSystem/JUtility/JUTConsole.h"
+#include "JSystem/JUtility/JUTDbPrint.h"
+#include "JSystem/JUtility/JUTResFont.h"
#include "dolphin/types.h"
struct JFWSystem {
struct CSetUpParam {
- static u32 maxStdHeaps;
+ static s32 maxStdHeaps;
static u32 sysHeapSize;
static u32 fifoBufSize;
static u32 aramAudioBufSize;
@@ -14,22 +18,22 @@ struct JFWSystem {
static u32 streamPriority;
static u32 decompPriority;
static u32 aPiecePriority;
- static void* systemFontRes;
- static void* renderMode;
- static u32 exConsoleBufferSize[1 + 1 /* padding */];
+ static ResFONT* systemFontRes;
+ static GXRenderModeObj* renderMode;
+ static u32 exConsoleBufferSize;
};
- /* 80271CD0 */ void firstInit();
- /* 80271D18 */ void init();
+ /* 80271CD0 */ static void firstInit();
+ /* 80271D18 */ static void init();
static JUTConsole* getSystemConsole() { return systemConsole; }
- static u8 rootHeap[4];
- static u8 systemHeap[4];
- static u8 mainThread[4];
- static u8 debugPrint[4];
- static u8 systemFont[4];
- static u8 systemConsoleManager[4];
+ static JKRExpHeap* rootHeap;
+ static JKRExpHeap* systemHeap;
+ static JKRThread* mainThread;
+ static JUTDbPrint* debugPrint;
+ static JUTResFont* systemFont;
+ static JUTConsoleManager* systemConsoleManager;
static JUTConsole* systemConsole;
};
diff --git a/include/JSystem/JUtility/JUTConsole.h b/include/JSystem/JUtility/JUTConsole.h
index 274e8de7e7..9377bf25fe 100644
--- a/include/JSystem/JUtility/JUTConsole.h
+++ b/include/JSystem/JUtility/JUTConsole.h
@@ -14,6 +14,12 @@ public:
UNK_TYPE2 = 2,
};
+ enum OutputFlag {
+ /* 0x0 */ OUTPUT_NONE,
+ /* 0x1 */ OUTPUT_OSREPORT,
+ /* 0x2 */ OUTPUT_CONSOLE
+ };
+
/* 802E73E4 */ static JUTConsole* create(unsigned int, void*, u32);
/* 802E7354 */ static JUTConsole* create(unsigned int, unsigned int, JKRHeap*);
/* 802E746C */ JUTConsole(unsigned int, unsigned int, bool);
@@ -46,6 +52,11 @@ public:
}
}
+ void setFont(JUTFont* p_font) {
+ mFont = p_font;
+ setFontSize(p_font->getWidth(), p_font->getHeight());
+ }
+
u32 getOutput() const { return mOutput; }
int getPositionY() const { return mPositionY; }
int getPositionX() const { return mPositionX; }
@@ -115,10 +126,13 @@ private:
/* 0x10 */ JUTConsole* mDirectConsole;
}; // Size: 0x14
-void JUTConsole_print_f_va_(JUTConsole*, const char*, va_list);
+extern "C" {
void JUTSetReportConsole(JUTConsole*);
-JUTConsole* JUTGetReportConsole();
void JUTSetWarningConsole(JUTConsole*);
+};
+
+void JUTConsole_print_f_va_(JUTConsole*, const char*, va_list);
+JUTConsole* JUTGetReportConsole();
JUTConsole* JUTGetWarningConsole();
void JUTReportConsole_f_va(const char*, va_list);
void JUTReportConsole_f(const char*, ...);
diff --git a/include/JSystem/JUtility/JUTProcBar.h b/include/JSystem/JUtility/JUTProcBar.h
index 1243be8ee6..79e3b3538d 100644
--- a/include/JSystem/JUtility/JUTProcBar.h
+++ b/include/JSystem/JUtility/JUTProcBar.h
@@ -1,6 +1,91 @@
#ifndef JUTPROCBAR_H
#define JUTPROCBAR_H
+#include "JSystem/JKernel/JKRHeap.h"
+#include "JSystem/JUtility/TColor.h"
#include "dolphin/types.h"
+class JUTProcBar {
+public:
+ class CTime {
+ public:
+ /* 802E7340 */ CTime();
+
+ void start(u8 param_0, u8 param_1, u8 param_2) {
+ field_0x10 = param_0;
+ field_0x11 = param_1;
+ field_0x12 = param_2;
+ mTick = OSGetTick();
+ }
+
+ void end() {
+ field_0x4 = ((OSGetTick() - mTick) * 8) / ((*(u32*)0x800000F8 >> 2) / 125000);
+ if (field_0x4 == 0) {
+ field_0x4 = 1;
+ }
+ }
+
+ /* 0x00 */ u32 mTick;
+ /* 0x04 */ u32 field_0x4;
+ /* 0x08 */ u32 field_0x8;
+ /* 0x0C */ u32 field_0xc;
+ /* 0x10 */ u8 field_0x10;
+ /* 0x11 */ u8 field_0x11;
+ /* 0x12 */ u8 field_0x12;
+ };
+
+ class CParamSet {
+ public:
+ /* 0x00 */ int mBarWidth;
+ /* 0x04 */ int mPosX;
+ /* 0x08 */ int mPosY;
+ /* 0x0C */ int mWidth;
+ /* 0x10 */ int mUserPosition;
+ };
+
+ /* 802E5888 */ JUTProcBar();
+ /* 802E599C */ ~JUTProcBar();
+ /* 802E59E0 */ static void create();
+ /* 802E5A28 */ static void destroy();
+ /* 802E5A60 */ static void clear();
+ /* 802E5B30 */ void bar_subroutine(int, int, int, int, int, int, int, JUtility::TColor,
+ JUtility::TColor);
+ /* 802E5CC4 */ void adjustMeterLength(u32, f32*, f32, f32, int*);
+ /* 802E5E08 */ void draw();
+ /* 802E5E3C */ void drawProcessBar();
+ /* 802E6FA0 */ void drawHeapBar();
+
+ void cpuStart() { mCpu.start(255, 129, 30); }
+ void cpuEnd() { mCpu.end(); }
+ void gpWaitStart() { mGpWait.start(255, 129, 30); }
+ void gpWaitEnd() { mGpWait.end(); }
+ void gpStart() { mGp.start(255, 129, 30); }
+ void gpEnd() { mGp.end(); }
+ void wholeLoopStart() { mWholeLoop.start(255, 129, 30); }
+ void wholeLoopEnd() { mWholeLoop.end(); }
+ void idleStart() { mIdle.start(255, 129, 30); }
+ void idleEnd() { mIdle.end(); }
+ void setCostFrame(int frame) { mCostFrame = frame; }
+
+ static JUTProcBar* getManager() { return sManager; }
+
+ static JUTProcBar* sManager;
+
+private:
+ /* 0x000 */ CTime mIdle;
+ /* 0x014 */ CTime mGp;
+ /* 0x028 */ CTime mCpu;
+ /* 0x03C */ CTime mGpWait;
+ /* 0x050 */ CTime mWholeLoop;
+ /* 0x064 */ CTime field_0x64[8];
+ /* 0x104 */ int mCostFrame;
+ /* 0x108 */ int field_0x108;
+ /* 0x10C */ bool mVisible;
+ /* 0x110 */ int field_0x110;
+ /* 0x114 */ CParamSet field_0x114;
+ /* 0x128 */ int field_0x128;
+ /* 0x12C */ JKRHeap* mWatchHeap;
+ /* 0x130 */ bool mHeapBarVisible;
+};
+
#endif /* JUTPROCBAR_H */
diff --git a/include/JSystem/JUtility/JUTVideo.h b/include/JSystem/JUtility/JUTVideo.h
index 537ee1dcf6..319a8f2c7c 100644
--- a/include/JSystem/JUtility/JUTVideo.h
+++ b/include/JSystem/JUtility/JUTVideo.h
@@ -6,6 +6,8 @@
#include "dolphin/types.h"
#include "dolphin/vi/vi.h"
+typedef u8 (*Pattern)[2];
+
class JUTVideo {
public:
typedef void (*Callback)(u32);
@@ -16,8 +18,8 @@ public:
// TODO: return types not confirmed
/* 802E4C54 */ static JUTVideo* createManager(GXRenderModeObj const*);
/* 802E4CAC */ static void destroyManager();
- /* 802E5088 */ void drawDoneStart();
- /* 802E50B0 */ void dummyNoDrawWait();
+ /* 802E5088 */ static void drawDoneStart();
+ /* 802E50B0 */ static void dummyNoDrawWait();
/* 802E5198 */ void setRenderMode(GXRenderModeObj const*);
/* 802E5210 */ void waitRetraceIfNeed();
@@ -25,10 +27,22 @@ public:
/* 802E5144 */ static void postRetraceProc(u32);
/* 802E50BC */ static void drawDoneCallback();
- u32 getFbWidth() const { return mRenderObj->fb_width; }
- u32 getEfbHeight() const { return mRenderObj->efb_height; }
+ u16 getFbWidth() const { return mRenderObj->fb_width; }
+ u16 getEfbHeight() const { return mRenderObj->efb_height; }
+ void getBounds(u16& width, u16& height) const {
+ width = (u16)getFbWidth();
+ height = (u16)getEfbHeight();
+ }
+ u16 getXfbHeight() const { return mRenderObj->xfb_height; }
+ u32 isAntiAliasing() const { return mRenderObj->antialiasing; }
+ Pattern getSamplePattern() const { return mRenderObj->sample_pattern; }
+ u8* getVFilter() const { return mRenderObj->vfilter; }
+ OSMessageQueue* getMessageQueue() { return &mMessageQueue; }
static JUTVideo* getManager() { return sManager; }
+ static OSTick getVideoInterval() { return sVideoInterval; }
+ static OSTick getVideoLastTick() { return sVideoLastTick; }
+
GXRenderModeObj* getRenderMode() const { return mRenderObj; }
private:
diff --git a/include/JSystem/JUtility/JUTXfb.h b/include/JSystem/JUtility/JUTXfb.h
index 240fb27a08..5d3933cc71 100644
--- a/include/JSystem/JUtility/JUTXfb.h
+++ b/include/JSystem/JUtility/JUTXfb.h
@@ -25,7 +25,7 @@ public:
s32 getBufferNum() const { return mBufferNum; }
s16 getDrawnXfbIndex() const { return mDrawnXfbIndex; }
- s16 getDrawningXfbIndex() const { return mDrawingXfbIndex; }
+ s16 getDrawingXfbIndex() const { return mDrawingXfbIndex; }
s16 getDisplayingXfbIndex() const { return mDisplayingXfbIndex; }
s32 getSDrawingFlag() const { return mSDrawingFlag; }
@@ -35,7 +35,7 @@ public:
return NULL;
}
- void* getDrawningXfb() const {
+ void* getDrawingXfb() const {
if (mDrawingXfbIndex >= 0)
return mBuffer[mDrawingXfbIndex];
return NULL;
@@ -49,6 +49,8 @@ public:
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; }
diff --git a/include/dolphin/gx/GX.h b/include/dolphin/gx/GX.h
index 157ddaaebb..f1eca18856 100644
--- a/include/dolphin/gx/GX.h
+++ b/include/dolphin/gx/GX.h
@@ -40,7 +40,7 @@ typedef struct _GXRenderModeObj {
u16 vi_height;
s32 xfb_mode;
u8 field_rendering;
- u8 antialiasing;
+ bool antialiasing;
u8 sample_pattern[12][2];
u8 vfilter[7];
} GXRenderModeObj;
@@ -74,6 +74,21 @@ typedef struct _GXFogAdjTable {
/* 0x0 */ u16 r[10];
} GXFogAdjTable;
+typedef struct _GXFifoObj {
+ /* 0x00 */ void* base;
+ /* 0x04 */ u32 end;
+ /* 0x08 */ u32 size;
+ /* 0x0C */ u32 high_wtrmark;
+ /* 0x10 */ u32 low_wtrmark;
+ /* 0x14 */ void* read_ptr;
+ /* 0x18 */ void* write_ptr;
+ /* 0x1C */ void* rw_dst;
+ /* 0x20 */ u8 fifo_wrap;
+ /* 0x21 */ bool cpu_fifo_ready;
+ /* 0x22 */ bool gp_fifo_ready;
+ /* 0x23 */ u8 field_0x23[93];
+} GXFifoObj; // Size: 0x80
+
typedef enum _GXPrimitive {
/* 0x80 */ GX_QUADS = 0x80,
/* 0x90 */ GX_TRIANGLES = 0x90,
@@ -416,9 +431,15 @@ typedef enum _GXTexFmt {
/* 0x8 */ GX_TF_CI8,
/* 0x9 */ GX_TF_CI14,
/* 0xE */ GX_TF_CMPR = 14,
-
/* 0x10 */ _GX_TF_ZTF = 0x10,
- /* 0x20 */ _GX_TF_CTF = 0x20
+ /* 0x11 */ GX_TF_Z8 = (0x1 | _GX_TF_ZTF),
+ /* 0x13 */ GX_TF_Z16 = (0x3 | _GX_TF_ZTF),
+ /* 0x16 */ GX_TF_Z24X8 = (0x6 | _GX_TF_ZTF),
+ /* 0x20 */ _GX_TF_CTF = 0x20,
+ /* 0x30 */ GX_CTF_Z4 = (0x0 | _GX_TF_ZTF | _GX_TF_CTF),
+ /* 0x39 */ GX_CTF_Z8M = (0x9 | _GX_TF_ZTF | _GX_TF_CTF),
+ /* 0x3A */ GX_CTF_Z8L = (0xA | _GX_TF_ZTF | _GX_TF_CTF),
+ /* 0x3C */ GX_CTF_Z16L = (0xC | _GX_TF_ZTF | _GX_TF_CTF),
} GXTexFmt;
typedef enum _GXGamma {
@@ -470,16 +491,6 @@ typedef enum _GXTexFmt8 {
/* 0x2C */ GX_CTF_GB8 = (0xC | _GX_TF_CTF),
} GXTexFmt8;
-typedef enum _GXZTexFmt {
- /* 0x11 */ GX_TF_Z8 = (0x1 | _GX_TF_ZTF),
- /* 0x13 */ GX_TF_Z16 = (0x3 | _GX_TF_ZTF),
- /* 0x16 */ GX_TF_Z24X8 = (0x6 | _GX_TF_ZTF),
- /* 0x30 */ GX_CTF_Z4 = (0x0 | _GX_TF_ZTF | _GX_TF_CTF),
- /* 0x39 */ GX_CTF_Z8M = (0x9 | _GX_TF_ZTF | _GX_TF_CTF),
- /* 0x3A */ GX_CTF_Z8L = (0xA | _GX_TF_ZTF | _GX_TF_CTF),
- /* 0x3C */ GX_CTF_Z16L = (0xC | _GX_TF_ZTF | _GX_TF_CTF),
-} GXZTexFmt;
-
typedef enum _GXTexWrapMode {
/* 0x0 */ GX_CLAMP,
/* 0x1 */ GX_REPEAT,
@@ -816,6 +827,30 @@ typedef struct _GXVtxDescList {
GXAttrType type;
} GXVtxDescList;
+typedef enum _GXFBClamp {
+ /* 0x0 */ GX_CLAMP_NONE,
+ /* 0x1 */ GX_CLAMP_TOP,
+ /* 0x2 */ GX_CLAMP_BOTTOM,
+} GXFBClamp;
+
+typedef enum _GXPixelFmt {
+ /* 0x0 */ GX_PF_RGB8_Z24,
+ /* 0x1 */ GX_PF_RGBA6_Z24,
+ /* 0x2 */ GX_PF_RGB565_Z16,
+ /* 0x3 */ GX_PF_Z24,
+ /* 0x4 */ GX_PF_Y8,
+ /* 0x5 */ GX_PF_U8,
+ /* 0x6 */ GX_PF_V8,
+ /* 0x7 */ GX_PF_YUV420,
+} GXPixelFmt;
+
+typedef enum _GXZFmt16 {
+ /* 0x0 */ GX_ZC_LINEAR,
+ /* 0x1 */ GX_ZC_NEAR,
+ /* 0x2 */ GX_ZC_MID,
+ /* 0x3 */ GX_ZC_FAR,
+} GXZFmt16;
+
extern "C" {
f32 GXGetYScaleFactor(u16 efb_height, u16 xfb_height);
u16 GXGetNumXfbLines(u32 efb_height, f32 y_scale);
@@ -852,6 +887,14 @@ void GXSetDrawDoneCallback(GXDrawDoneCallback);
void GXDrawDone(void);
void GXAbortFrame(void);
void GXFlush(void);
+void GXSetCopyClear(GXColor, u32);
+void GXSetDispCopySrc(u16, u16, u16, u16);
+void GXSetDispCopyDst(u16, u16);
+u32 GXSetDispCopyYScale(f32);
+void GXSetCopyClamp(GXFBClamp);
+void GXSetDispCopyGamma(GXGamma);
+void GXCopyDisp(void*, GXBool);
+void GXSetPixelFmt(GXPixelFmt, GXZFmt16);
struct OSThread;
OSThread* GXSetCurrentGXThread(void);
@@ -898,7 +941,7 @@ void GXSetTexCopySrc(u16, u16, u16, u16);
void GXSetViewport(f32, f32, f32, f32, f32, f32);
void GXSetZCompLoc(GXBool);
void GXSetZMode(GXBool, GXCompare, GXBool);
-void GXSetZTexture(GXZTexOp, GXZTexFmt, u32);
+void GXSetZTexture(GXZTexOp, GXTexFmt, u32);
void GXSetPointSize(u8, GXTexOffset);
void GXSetLineWidth(u8, GXTexOffset);
void GXSetTevDirect(GXTevStageID);
@@ -909,6 +952,13 @@ void GXSetIndTexMtx(GXIndTexMtxID, Mtx23, s8);
void GXSetIndTexCoordScale(GXIndTexStageID, GXIndTexScale, GXIndTexScale);
void GXSetIndTexOrder(GXIndTexStageID, GXTexCoordID, GXTexMapID);
void GXEnableTexOffsets(GXTexCoordID, GXBool, GXBool);
+void GXSetDstAlpha(GXBool, u8);
+u32 GXGetFifoSize(GXFifoObj*);
+void* GXGetFifoBase(GXFifoObj*);
+GXFifoObj* GXInit(void*, u32);
+GXFifoObj* GXGetCPUFifo(void);
+void GXGetGPStatus(GXBool*, GXBool*, GXBool*, GXBool*, GXBool*);
+void GXReadXfRasMetric(u32*, u32*, u32*, u32*);
#define GFX_FIFO(T) (*(volatile T*)0xCC008000)
@@ -927,6 +977,16 @@ inline void GXTexCoord2f32(f32 s, f32 t) {
GFX_FIFO(f32) = t;
}
+inline void GXTexCoord2u8(u8 s, u8 t) {
+ GFX_FIFO(u8) = s;
+ GFX_FIFO(u8) = t;
+}
+
+inline void GXPosition2u16(u16 x, u16 y) {
+ GFX_FIFO(u16) = x;
+ GFX_FIFO(u16) = y;
+}
+
inline void GXEnd() {}
};
diff --git a/include/dolphin/os/OS.h b/include/dolphin/os/OS.h
index 7c94ec7bf0..b30dbbdf3a 100644
--- a/include/dolphin/os/OS.h
+++ b/include/dolphin/os/OS.h
@@ -131,6 +131,23 @@ struct OSThread {
void* data[2];
};
+struct OSAlarm;
+struct OSAlarmLink {
+ /* 0x0 */ OSAlarm* prev;
+ /* 0x4 */ OSAlarm* next;
+};
+
+typedef void (*OSAlarmHandler)(OSAlarm*, OSContext*);
+
+struct OSAlarm {
+ /* 0x00 */ OSAlarmHandler handler;
+ /* 0x04 */ u32 tag;
+ /* 0x08 */ OSTime fire_time;
+ /* 0x10 */ OSAlarmLink link;
+ /* 0x18 */ OSTime period_time;
+ /* 0x20 */ OSTime start_time;
+}; // Size: 0x28
+
extern "C" {
s32 OSEnableScheduler(void);
s32 OSDisableScheduler(void);
@@ -205,6 +222,10 @@ void LCDisable(void);
void OSReportInit__Fv(void); // needed for inline asm
u8* OSGetStackPointer(void);
+
+void OSCreateAlarm(OSAlarm*);
+void OSCancelAlarm(OSAlarm*);
+void OSSetAlarm(OSAlarm*, OSTime, OSAlarmHandler);
}; // extern "C"
void OSSwitchFiberEx(u32, u32, u32, u32, u32, u32);
diff --git a/libs/JSystem/JFramework/JFWDisplay.cpp b/libs/JSystem/JFramework/JFWDisplay.cpp
index d3b04a2376..149572c943 100644
--- a/libs/JSystem/JFramework/JFWDisplay.cpp
+++ b/libs/JSystem/JFramework/JFWDisplay.cpp
@@ -4,58 +4,15 @@
//
#include "JSystem/JFramework/JFWDisplay.h"
+#include "JSystem/J2DGraph/J2DOrthoGraph.h"
+#include "JSystem/JUtility/JUTAssert.h"
+#include "JSystem/JUtility/JUTConsole.h"
+#include "JSystem/JUtility/JUTDbPrint.h"
#include "dol2asm.h"
#include "dolphin/mtx/mtx44.h"
#include "dolphin/types.h"
//
-// Types:
-//
-
-struct OSAlarm {};
-
-struct JUTProcBar {
- /* 802E59E0 */ void create();
- /* 802E5A28 */ void destroy();
- /* 802E5A60 */ void clear();
- /* 802E5E08 */ void draw();
-
- static u8 sManager[4];
-};
-
-struct JUTDirectPrint {
- /* 802E456C */ void changeFrameBuffer(void*, u16, u16);
-
- static u8 sDirectPrint[4 + 4 /* padding */];
-};
-
-struct JUTDbPrint {
- /* 802E02A4 */ void flush();
-
- static u8 sDebugPrint[4 + 4 /* padding */];
-};
-
-struct JUTConsoleManager {
- /* 802E8384 */ void draw() const;
-
- static u8 sManager[4];
-};
-
-struct JUTAssertion {
- /* 802E499C */ void flushMessage();
- /* 802E4A54 */ void flushMessage_dbPrint();
-};
-
-struct JFWAlarm {
- static u8 sList[12];
-};
-
-struct J2DOrthoGraph {
- /* 802E96D0 */ J2DOrthoGraph(f32, f32, f32, f32, f32, f32);
- /* 802E97B4 */ void setPort();
-};
-
-//
// Forward References:
//
@@ -122,33 +79,14 @@ extern "C" void draw__10JUTProcBarFv();
extern "C" void draw__17JUTConsoleManagerCFv();
extern "C" void __ct__13J2DOrthoGraphFffffff();
extern "C" void setPort__13J2DOrthoGraphFv();
-extern "C" void OSCreateAlarm();
-extern "C" void OSSetAlarm();
-extern "C" void OSCancelAlarm();
extern "C" void VIFlush();
-extern "C" void GXInit();
-extern "C" void GXGetGPStatus();
-extern "C" void GXGetFifoBase();
-extern "C" void GXGetFifoSize();
-extern "C" void GXGetCPUFifo();
extern "C" void GXClearVtxDesc();
extern "C" void GXInvalidateVtxCache();
-extern "C" void GXFlush();
extern "C" void GXAbortFrame();
extern "C" void GXSetDrawDone();
extern "C" void GXDrawDone();
extern "C" void GXPixModeSync();
-extern "C" void GXSetDispCopySrc();
-extern "C" void GXSetDispCopyDst();
-extern "C" void GXSetCopyClamp();
-extern "C" void GXSetDispCopyYScale();
-extern "C" void GXSetCopyClear();
-extern "C" void GXSetDispCopyGamma();
-extern "C" void GXCopyDisp();
extern "C" void GXInvalidateTexAll();
-extern "C" void GXSetPixelFmt();
-extern "C" void GXSetDstAlpha();
-extern "C" void GXReadXfRasMetric();
extern "C" void __register_global_object();
extern "C" void _savegpr_24();
extern "C" void _savegpr_28();
@@ -172,136 +110,64 @@ extern "C" u8 sManager__17JUTConsoleManager[4];
// Declarations:
//
-/* ############################################################################################## */
-/* 80455250-80455254 003850 0004+00 4/4 0/0 0/0 .sdata2 @2198 */
-SECTION_SDATA2 static u8 lit_2198[4] = {
- 0x00,
- 0x00,
- 0x00,
- 0x00,
-};
-
/* 80272040-802720F8 26C980 00B8+00 1/1 0/0 0/0 .text ctor_subroutine__10JFWDisplayFb */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::ctor_subroutine(bool param_0) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/ctor_subroutine__10JFWDisplayFb.s"
+void JFWDisplay::ctor_subroutine(bool enableAlpha) {
+ mEnableAlpha = enableAlpha;
+ mClamp = GX_CLAMP_TOP | GX_CLAMP_BOTTOM;
+ mClearColor.set(0, 0, 0, 0);
+ mZClear = 0xFFFFFF;
+ mGamma = 0;
+ mFader = NULL;
+ mFrameRate = 1;
+ mTickRate = 0;
+ mCombinationRatio = 0.0f;
+ field_0x30 = 0;
+ field_0x2c = OSGetTick();
+ field_0x34 = 0;
+ field_0x48 = 0;
+ field_0x4a = 0;
+ mDrawDoneMethod = UNK_METHOD_0;
+ clearEfb_init();
+ JUTProcBar::create();
+ JUTProcBar::clear();
+ field_0x38 = 1;
+ field_0x3c = 0;
+ field_0x40 = 0;
+ field_0x44 = 0;
}
-#pragma pop
/* ############################################################################################## */
/* 803C4020-803C4060 021140 0030+10 1/1 0/0 0/0 .data e_mtx */
-SECTION_DATA static u8 e_mtx[48 + 16 /* padding */] ALIGN_DECL(32) = {
- 0x3F,
- 0x80,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x3F,
- 0x80,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x3F,
- 0x80,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- /* padding */
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
+SECTION_DATA static Mtx e_mtx ALIGN_DECL(32) = {
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 1.0f, 0.0f},
};
/* 803C4060-803C40A0 021180 0040+00 1/1 0/0 0/0 .data clear_z_TX */
-SECTION_DATA static u8 clear_z_TX[64] = {
+SECTION_DATA static u8 clear_z_TX[64] ALIGN_DECL(32) = {
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};
-/* 803C40A0-803C40C0 0211C0 0018+08 2/2 0/0 0/0 .data __vt__10JFWDisplay */
-SECTION_DATA extern void* __vt__10JFWDisplay[6 + 2 /* padding */] = {
- (void*)NULL /* RTTI */,
- (void*)NULL,
- (void*)beginRender__10JFWDisplayFv,
- (void*)endRender__10JFWDisplayFv,
- (void*)endFrame__10JFWDisplayFv,
- (void*)__dt__10JFWDisplayFv,
- /* padding */
- NULL,
- NULL,
-};
-
/* 802720F8-80272160 26CA38 0068+00 1/1 0/0 0/0 .text
* __ct__10JFWDisplayFP7JKRHeapQ26JUTXfb10EXfbNumberb */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm JFWDisplay::JFWDisplay(JKRHeap* param_0, JUTXfb::EXfbNumber param_1, bool param_2) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/__ct__10JFWDisplayFP7JKRHeapQ26JUTXfb10EXfbNumberb.s"
+JFWDisplay::JFWDisplay(JKRHeap* p_heap, JUTXfb::EXfbNumber xfb_num, bool enableAlpha) {
+ ctor_subroutine(enableAlpha);
+ mXfbManager = JUTXfb::createManager(p_heap, xfb_num);
}
-#pragma pop
/* 80272160-802721DC 26CAA0 007C+00 1/0 0/0 0/0 .text __dt__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm JFWDisplay::~JFWDisplay() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/__dt__10JFWDisplayFv.s"
+JFWDisplay::~JFWDisplay() {
+ if (JUTVideo::getManager() != NULL) {
+ waitBlanking(2);
+ }
+ JUTProcBar::destroy();
+ JUTXfb::destroyManager();
+ mXfbManager = NULL;
}
-#pragma pop
/* ############################################################################################## */
/* 804511C0-804511C4 0006C0 0004+00 2/2 40/40 1/1 .sbss sManager__10JFWDisplay */
@@ -309,178 +175,362 @@ JFWDisplay* JFWDisplay::sManager;
/* 802721DC-80272260 26CB1C 0084+00 0/0 1/1 0/0 .text
* createManager__10JFWDisplayFPC16_GXRenderModeObjP7JKRHeapQ26JUTXfb10EXfbNumberb */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::createManager(_GXRenderModeObj const* param_0, JKRHeap* param_1,
- JUTXfb::EXfbNumber param_2, bool param_3) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/createManager__10JFWDisplayFPC16_GXRenderModeObjP7JKRHeapQ26JUTXfb10EXfbNumberb.s"
+JFWDisplay* JFWDisplay::createManager(_GXRenderModeObj const* p_rObj, JKRHeap* p_heap,
+ JUTXfb::EXfbNumber xfb_num, bool enableAlpha) {
+ if (p_rObj != NULL) {
+ JUTVideo::getManager()->setRenderMode(p_rObj);
+ }
+
+ if (sManager == NULL) {
+ sManager = new JFWDisplay(p_heap, xfb_num, enableAlpha);
+ }
+
+ return sManager;
}
-#pragma pop
/* 80272260-802722B8 26CBA0 0058+00 2/2 0/0 0/0 .text callDirectDraw__Fv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-static asm void callDirectDraw() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/callDirectDraw__Fv.s"
+static void callDirectDraw() {
+ JUTChangeFrameBuffer(JUTXfb::getManager()->getDrawingXfb(),
+ JUTVideo::getManager()->getEfbHeight(),
+ JUTVideo::getManager()->getFbWidth());
+ JUTAssertion::flushMessage();
}
-#pragma pop
/* 802722B8-802723AC 26CBF8 00F4+00 3/3 0/0 0/0 .text prepareCopyDisp__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::prepareCopyDisp() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/prepareCopyDisp__10JFWDisplayFv.s"
+void JFWDisplay::prepareCopyDisp() {
+ u16 width = JUTVideo::getManager()->getFbWidth();
+ u16 height = JUTVideo::getManager()->getEfbHeight();
+ f32 y_scaleF = GXGetYScaleFactor(height, JUTVideo::getManager()->getXfbHeight());
+ u16 line_num = GXGetNumXfbLines(height, y_scaleF);
+
+ GXSetCopyClear(mClearColor, mZClear);
+ GXSetDispCopySrc(0, 0, width, height);
+ GXSetDispCopyDst(width, line_num);
+ GXSetDispCopyYScale(y_scaleF);
+ VIFlush();
+ GXSetCopyFilter((GXBool)JUTVideo::getManager()->isAntiAliasing(),
+ JUTVideo::getManager()->getSamplePattern(), GX_ENABLE,
+ JUTVideo::getManager()->getVFilter());
+ GXSetCopyClamp((GXFBClamp)mClamp);
+ GXSetDispCopyGamma((GXGamma)mGamma);
+ GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE);
+ if (mEnableAlpha) {
+ GXSetAlphaUpdate(GX_ENABLE);
+ }
}
-#pragma pop
/* 802723AC-802723F4 26CCEC 0048+00 1/1 0/0 0/0 .text drawendXfb_single__10JFWDisplayFv
*/
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::drawendXfb_single() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/drawendXfb_single__10JFWDisplayFv.s"
+void JFWDisplay::drawendXfb_single() {
+ JUTXfb* manager = JUTXfb::getManager();
+ if (manager->getDrawingXfbIndex() >= 0) {
+ prepareCopyDisp();
+ JFWDrawDoneAlarm();
+ GXFlush();
+ manager->setDrawnXfbIndex(manager->getDrawingXfbIndex());
+ }
}
-#pragma pop
/* 802723F4-802724FC 26CD34 0108+00 1/1 0/0 0/0 .text exchangeXfb_double__10JFWDisplayFv
*/
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::exchangeXfb_double() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/exchangeXfb_double__10JFWDisplayFv.s"
+void JFWDisplay::exchangeXfb_double() {
+ JUTXfb* xfbMng = JUTXfb::getManager();
+
+ if (xfbMng->getDrawnXfbIndex() == xfbMng->getDisplayingXfbIndex()) {
+ if (xfbMng->getDrawingXfbIndex() >= 0) {
+ if (field_0x44 != NULL) {
+ field_0x44();
+ }
+
+ prepareCopyDisp();
+ GXCopyDisp(xfbMng->getDrawingXfb(), GX_TRUE);
+ if (mDrawDoneMethod == UNK_METHOD_0) {
+ xfbMng->setDrawnXfbIndex(xfbMng->getDrawingXfbIndex());
+ GXDrawDone();
+ JUTVideo::dummyNoDrawWait();
+ } else {
+ JUTVideo::drawDoneStart();
+ }
+
+ if (mDrawDoneMethod == UNK_METHOD_0) {
+ callDirectDraw();
+ }
+ }
+ s16 cur_xfb_index = xfbMng->getDrawingXfbIndex();
+ xfbMng->setDrawnXfbIndex(cur_xfb_index);
+ xfbMng->setDrawingXfbIndex(cur_xfb_index >= 0 ? cur_xfb_index ^ 1 : 0);
+ } else {
+ clearEfb(mClearColor);
+ if (xfbMng->getDrawingXfbIndex() < 0) {
+ xfbMng->setDrawingXfbIndex(0);
+ }
+ }
}
-#pragma pop
/* 802724FC-80272574 26CE3C 0078+00 1/1 0/0 0/0 .text exchangeXfb_triple__10JFWDisplayFv
*/
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::exchangeXfb_triple() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/exchangeXfb_triple__10JFWDisplayFv.s"
+void JFWDisplay::exchangeXfb_triple() {
+ JUTXfb* xfbMng = JUTXfb::getManager();
+
+ if (xfbMng->getDrawingXfbIndex() >= 0) {
+ callDirectDraw();
+ }
+
+ xfbMng->setDrawnXfbIndex(xfbMng->getDrawingXfbIndex());
+
+ s16 drawing_idx = xfbMng->getDrawingXfbIndex() + 1;
+ do {
+ if (drawing_idx >= 3 || drawing_idx < 0) {
+ drawing_idx = 0;
+ }
+ } while (drawing_idx == xfbMng->getDisplayingXfbIndex());
+ xfbMng->setDrawingXfbIndex(drawing_idx);
}
-#pragma pop
/* 80272574-802725F8 26CEB4 0084+00 1/1 0/0 0/0 .text copyXfb_triple__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::copyXfb_triple() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/copyXfb_triple__10JFWDisplayFv.s"
+void JFWDisplay::copyXfb_triple() {
+ JUTXfb* xfbMng = JUTXfb::getManager();
+
+ if (xfbMng->getDrawingXfbIndex() >= 0) {
+ if (field_0x44 != NULL) {
+ field_0x44();
+ }
+ prepareCopyDisp();
+ GXCopyDisp(xfbMng->getDrawingXfb(), GX_TRUE);
+ GXPixModeSync();
+ }
}
-#pragma pop
/* 802725F8-8027268C 26CF38 0094+00 1/1 0/0 0/0 .text preGX__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::preGX() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/preGX__10JFWDisplayFv.s"
+void JFWDisplay::preGX() {
+ GXInvalidateTexAll();
+ GXInvalidateVtxCache();
+
+ if (JUTVideo::getManager()->isAntiAliasing()) {
+ GXSetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
+ GXSetDither(GX_ENABLE);
+ } else {
+ if (mEnableAlpha) {
+ GXSetPixelFmt(GX_PF_RGBA6_Z24, GX_ZC_LINEAR);
+ GXSetDither(GX_ENABLE);
+ } else {
+ GXSetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
+ GXSetDither(GX_DISABLE);
+ }
+ }
}
-#pragma pop
-
-/* ############################################################################################## */
-/* 80455254-80455258 003854 0004+00 1/1 0/0 0/0 .sdata2 @2497 */
-SECTION_SDATA2 static f32 lit_2497 = -1.0f;
-
-/* 80455258-80455260 003858 0004+04 3/3 0/0 0/0 .sdata2 @2498 */
-SECTION_SDATA2 static f32 lit_2498[1 + 1 /* padding */] = {
- 1.0f,
- /* padding */
- 0.0f,
-};
-
-/* 80455260-80455268 003860 0008+00 4/4 0/0 0/0 .sdata2 @2500 */
-SECTION_SDATA2 static f64 lit_2500 = 4503599627370496.0 /* cast u32 to float */;
/* 8027268C-80272798 26CFCC 010C+00 1/1 0/0 0/0 .text endGX__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::endGX() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/endGX__10JFWDisplayFv.s"
+void JFWDisplay::endGX() {
+ f32 width = JUTVideo::getManager()->getFbWidth();
+ f32 height = JUTVideo::getManager()->getEfbHeight();
+
+ J2DOrthoGraph ortho(0.0f, 0.0f, width, height, -1.0f, 1.0f);
+
+ if (mFader != NULL) {
+ ortho.setPort();
+ mFader->control();
+ }
+ ortho.setPort();
+ JUTDbPrint::getManager()->flush();
+
+ if (JUTConsoleManager::getManager() != NULL) {
+ ortho.setPort();
+ JUTConsoleManager::getManager()->draw();
+ }
+
+ ortho.setPort();
+ JUTProcBar::getManager()->draw();
+
+ if (mDrawDoneMethod != UNK_METHOD_0 || JUTXfb::getManager()->getBufferNum() == 1) {
+ JUTAssertion::flushMessage_dbPrint();
+ }
+ GXFlush();
}
-#pragma pop
/* 80272798-80272A04 26D0D8 026C+00 1/0 0/0 0/0 .text beginRender__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-// asm void JFWDisplay::beginRender() {
-extern "C" asm void beginRender__10JFWDisplayFv() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/beginRender__10JFWDisplayFv.s"
+void JFWDisplay::beginRender() {
+ if (field_0x40) {
+ JUTProcBar::getManager()->wholeLoopEnd();
+ }
+
+ if (field_0x40) {
+ JUTProcBar::getManager()->wholeLoopStart();
+ JUTProcBar::getManager()->idleStart();
+ }
+
+ waitForTick(mTickRate, mFrameRate);
+ JUTVideo::getManager()->waitRetraceIfNeed();
+
+ OSTick tick = OSGetTick();
+ field_0x30 = tick - field_0x2c;
+ field_0x2c = tick;
+ field_0x34 = field_0x2c - JUTVideo::getVideoLastTick();
+
+ if (field_0x40) {
+ JUTProcBar::getManager()->idleEnd();
+ }
+
+ if (field_0x40) {
+ JUTProcBar::getManager()->gpStart();
+
+ JUTXfb* xfbMng = JUTXfb::getManager();
+ switch (xfbMng->getBufferNum()) {
+ case 1:
+ if (xfbMng->getSDrawingFlag() != 2) {
+ xfbMng->setSDrawingFlag(1);
+ clearEfb(mClearColor);
+ } else {
+ xfbMng->setSDrawingFlag(1);
+ }
+ xfbMng->setDrawingXfbIndex(field_0x48);
+ break;
+ case 2:
+ exchangeXfb_double();
+ break;
+ case 3:
+ exchangeXfb_triple();
+ break;
+ default:
+ break;
+ }
+ }
+
+ field_0x3c++;
+ field_0x40 = field_0x3c >= field_0x38;
+
+ if (field_0x40) {
+ field_0x3c = 0;
+ }
+
+ if (field_0x40) {
+ clearEfb();
+ preGX();
+ }
}
-#pragma pop
/* 80272A04-80272AB0 26D344 00AC+00 1/0 0/0 0/0 .text endRender__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::endRender() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/endRender__10JFWDisplayFv.s"
+void JFWDisplay::endRender() {
+ endGX();
+
+ if (field_0x40) {
+ switch (JUTXfb::getManager()->getBufferNum()) {
+ case 1:
+ drawendXfb_single();
+ case 2:
+ break;
+ case 3:
+ copyXfb_triple();
+ default:
+ break;
+ }
+ }
+
+ JUTProcBar::getManager()->cpuStart();
+ calcCombinationRatio();
}
-#pragma pop
/* ############################################################################################## */
/* 804511C4-804511C8 0006C4 0004+00 1/1 0/0 0/0 .sbss prevFrame$2597 */
-static u8 prevFrame[4];
+static u32 prevFrame;
/* 804511C8-804511D0 0006C8 0008+00 1/1 0/0 0/0 .sbss None */
-static u8 data_804511C8[8];
+static s8 data_804511C8;
/* 80272AB0-80272C60 26D3F0 01B0+00 1/0 0/0 0/0 .text endFrame__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::endFrame() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/endFrame__10JFWDisplayFv.s"
+void JFWDisplay::endFrame() {
+ JUTProcBar::getManager()->cpuEnd();
+
+ if (field_0x40) {
+ JUTProcBar::getManager()->gpWaitStart();
+ switch (JUTXfb::getManager()->getBufferNum()) {
+ case 1:
+ break;
+ case 2:
+ JFWDrawDoneAlarm();
+ GXFlush();
+ break;
+ case 3:
+ JFWDrawDoneAlarm();
+ GXFlush();
+ break;
+ default:
+ break;
+ }
+
+ JUTProcBar::getManager()->gpWaitEnd();
+ JUTProcBar::getManager()->gpEnd();
+ }
+
+ if (field_0x40) {
+ if (data_804511C8 == 0) {
+ prevFrame = VIGetRetraceCount();
+ data_804511C8 = 1;
+ }
+ u32 retrace_cnt = VIGetRetraceCount();
+ JUTProcBar::getManager()->setCostFrame(retrace_cnt - prevFrame);
+ prevFrame = retrace_cnt;
+ }
}
-#pragma pop
/* 80272C60-80272CB0 26D5A0 0050+00 1/1 1/1 0/0 .text waitBlanking__10JFWDisplayFi */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::waitBlanking(int param_0) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/waitBlanking__10JFWDisplayFi.s"
+void JFWDisplay::waitBlanking(int param_0) {
+ while (param_0-- > 0) {
+ waitForTick(mTickRate, mFrameRate);
+ }
}
-#pragma pop
/* ############################################################################################## */
/* 804511D0-804511D4 0006D0 0004+00 1/1 0/0 0/0 .sbss nextTick$2642 */
-static u8 nextTick[4];
+static u8 nextTick[4] ALIGN_DECL(8);
/* 804511D4-804511D8 0006D4 0004+00 1/1 0/0 0/0 .sbss None */
static u8 data_804511D4[4];
/* 804511D8-804511DC 0006D8 0004+00 1/1 0/0 0/0 .sbss None */
-static u8 data_804511D8[4];
+static s8 data_804511D8;
/* 804511DC-804511E0 0006DC 0004+00 1/1 0/0 0/0 .sbss nextCount$2650 */
-static u8 nextCount[4];
+static u32 nextCount;
/* 804511E0-804511E8 0006E0 0008+00 1/1 0/0 0/0 .sbss None */
-static u8 data_804511E0[8];
+static s8 data_804511E0;
/* 80272CB0-80272DD0 26D5F0 0120+00 2/2 0/0 0/0 .text waitForTick__FUlUs */
+#ifdef NONMATCHING
+static void waitForTick(u32 param_0, u16 param_1) {
+ if (param_0 != 0) {
+ if (!data_804511D8) {
+ nextTick = OSGetTime();
+ data_804511D8 = true;
+ }
+
+ while (OSGetTime() < nextTick) {
+ JFWDisplay::getManager()->threadSleep(nextTick - param_0);
+ }
+ nextTick += param_0;
+ } else {
+ if (!data_804511E0) {
+ nextCount = VIGetRetraceCount();
+ data_804511E0 = true;
+ }
+
+ int uvar4 = 1;
+ if (param_1 != 0) {
+ uvar4 = param_1;
+ }
+
+ OSMessage msg;
+ do {
+ if (!OSReceiveMessage(JUTVideo::getManager()->getMessageQueue(), &msg,
+ OS_MESSAGE_BLOCKING)) {
+ msg = NULL;
+ }
+ } while ((int)msg - nextCount > 0);
+ nextCount = (int)msg + uvar4;
+ }
+}
+#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -489,166 +539,211 @@ static asm void waitForTick(u32 param_0, u16 param_1) {
#include "asm/JSystem/JFramework/JFWDisplay/waitForTick__FUlUs.s"
}
#pragma pop
-
-/* ############################################################################################## */
-/* 80430FD8-80430FE4 05DCF8 000C+00 1/1 0/0 0/0 .bss @2184 */
-static u8 lit_2184[12];
+#endif
/* 80430FE4-80430FF0 05DD04 000C+00 4/4 0/0 0/0 .bss sList__8JFWAlarm */
-u8 JFWAlarm::sList[12];
+JSUList<JFWAlarm> JFWAlarm::sList(false);
/* 80272DD0-80272E10 26D710 0040+00 1/1 0/0 0/0 .text JFWThreadAlarmHandler__FP7OSAlarmP9OSContext
*/
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-static asm void JFWThreadAlarmHandler(OSAlarm* param_0, OSContext* param_1) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/JFWThreadAlarmHandler__FP7OSAlarmP9OSContext.s"
+static void JFWThreadAlarmHandler(OSAlarm* p_alarm, OSContext* p_ctx) {
+ JFWAlarm* alarm = static_cast<JFWAlarm*>(p_alarm);
+ alarm->removeLink();
+ OSResumeThread(alarm->getThread());
}
-#pragma pop
/* 80272E10-80272EB8 26D750 00A8+00 1/1 0/0 0/0 .text threadSleep__10JFWDisplayFx */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::threadSleep(s64 param_0) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/threadSleep__10JFWDisplayFx.s"
+void JFWDisplay::threadSleep(s64 time) {
+ JFWAlarm alarm;
+ alarm.createAlarm();
+ alarm.setThread(OSGetCurrentThread());
+ s32 status = OSDisableInterrupts();
+ alarm.appendLink();
+
+ OSSetAlarm(&alarm, time, JFWThreadAlarmHandler);
+ OSSuspendThread(alarm.getThread());
+ OSRestoreInterrupts(status);
}
-#pragma pop
/* ############################################################################################## */
/* 80430FF0-80431010 05DD10 0020+00 2/2 0/0 0/0 .bss clear_z_tobj */
-static u8 clear_z_tobj[32];
+static GXTexObj clear_z_tobj;
/* 80272EB8-80272F2C 26D7F8 0074+00 1/1 0/0 0/0 .text clearEfb_init__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::clearEfb_init() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/clearEfb_init__10JFWDisplayFv.s"
+void JFWDisplay::clearEfb_init() {
+ GXInitTexObj(&clear_z_tobj, &clear_z_TX, 4, 4, GX_TF_Z24X8, GX_REPEAT, GX_REPEAT, GX_FALSE);
+ GXInitTexObjLOD(&clear_z_tobj, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, GX_FALSE, GX_FALSE,
+ GX_ANISO_1);
}
-#pragma pop
/* 80272F2C-80272F58 26D86C 002C+00 1/1 0/0 0/0 .text clearEfb__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::clearEfb() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/clearEfb__10JFWDisplayFv.s"
+void JFWDisplay::clearEfb() {
+ clearEfb(mClearColor);
}
-#pragma pop
/* 80272F58-80272F9C 26D898 0044+00 3/3 0/0 0/0 .text clearEfb__10JFWDisplayF8_GXColor */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::clearEfb(_GXColor param_0) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/clearEfb__10JFWDisplayF8_GXColor.s"
+void JFWDisplay::clearEfb(GXColor color) {
+ int width = JUTVideo::getManager()->getFbWidth();
+ int height = JUTVideo::getManager()->getEfbHeight();
+
+ clearEfb(0, 0, width, height, color);
}
-#pragma pop
/* 80272F9C-8027331C 26D8DC 0380+00 1/1 0/0 0/0 .text clearEfb__10JFWDisplayFiiii8_GXColor */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::clearEfb(int param_0, int param_1, int param_2, int param_3,
- _GXColor param_4) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/clearEfb__10JFWDisplayFiiii8_GXColor.s"
+void JFWDisplay::clearEfb(int param_0, int param_1, int param_2, int param_3, GXColor color) {
+ u16 width;
+ u16 height;
+ Mtx44 mtx;
+
+ JUTVideo::getManager()->getBounds(width, height);
+
+ C_MTXOrtho(mtx, 0.0f, height, 0.0f, width, 0.0f, 1.0f);
+ GXSetProjection(mtx, GX_ORTHOGRAPHIC);
+ GXSetViewport(0.0f, 0.0f, width, height, 0.0f, 1.0f);
+ GXSetScissor(0, 0, width, height);
+
+ GXLoadPosMtxImm(e_mtx, GX_PNMTX0);
+ GXSetCurrentMtx(0);
+ GXClearVtxDesc();
+ GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
+ GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
+ GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_RGBX8, 0);
+ GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGB565, 0);
+ GXSetNumChans(0);
+ GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE,
+ GX_AF_NONE);
+ GXSetChanCtrl(GX_COLOR1A1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE,
+ GX_AF_NONE);
+ GXSetNumTexGens(1);
+ GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_DISABLE, 125);
+ GXLoadTexObj(&clear_z_tobj, GX_TEXMAP0);
+ GXSetNumTevStages(1);
+ GXSetTevColor(GX_TEVREG0, color);
+ GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
+ GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0);
+ GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV);
+ GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0);
+ GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV);
+ GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0);
+ GXSetZTexture(GX_ZT_REPLACE, GX_TF_Z24X8, 0);
+ GXSetZCompLoc(GX_DISABLE);
+ GXSetBlendMode(GX_BM_NONE, GX_BL_ZERO, GX_BL_ZERO, GX_LO_NOOP);
+
+ if (mEnableAlpha) {
+ GXSetAlphaUpdate(GX_ENABLE);
+ GXSetDstAlpha(GX_ENABLE, color.a);
+ }
+ GXSetZMode(GX_ENABLE, GX_ALWAYS, GX_ENABLE);
+ GXSetCullMode(GX_CULL_BACK);
+
+ GXBegin(GX_QUADS, GX_VTXFMT0, 4);
+ GXPosition2u16(param_0, param_1);
+ GXTexCoord2u8(0, 0);
+
+ GXPosition2u16(param_0 + param_2, param_1);
+ GXTexCoord2u8(1, 0);
+
+ GXPosition2u16(param_0 + param_2, param_1 + param_3);
+ GXTexCoord2u8(1, 1);
+
+ GXPosition2u16(param_0, param_1 + param_3);
+ GXTexCoord2u8(0, 1);
+
+ GXSetZTexture(GX_ZT_DISABLE, GX_TF_Z24X8, 0);
+ GXSetZCompLoc(GX_ENABLE);
+ if (mEnableAlpha) {
+ GXSetDstAlpha(GX_DISABLE, color.a);
+ }
}
-#pragma pop
-
-/* ############################################################################################## */
-/* 80455268-80455270 003868 0008+00 1/1 0/0 0/0 .sdata2 @2933 */
-SECTION_SDATA2 static f64 lit_2933 = 4503601774854144.0 /* cast s32 to float */;
/* 8027331C-802733A8 26DC5C 008C+00 1/1 0/0 0/0 .text calcCombinationRatio__10JFWDisplayFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWDisplay::calcCombinationRatio() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/calcCombinationRatio__10JFWDisplayFv.s"
+void JFWDisplay::calcCombinationRatio() {
+ u32 vidInterval = JUTVideo::getVideoInterval();
+ s32 unk30 = field_0x30 * 2;
+
+ s32 i = vidInterval;
+ for (; i < unk30; i += vidInterval) {
+ }
+
+ s32 tmp = (i - unk30) - field_0x34;
+ if (tmp < 0) {
+ tmp += vidInterval;
+ }
+ mCombinationRatio = (f32)tmp / (f32)field_0x30;
+ if (mCombinationRatio > 1.0f) {
+ mCombinationRatio = 1.0f;
+ }
}
-#pragma pop
-
-/* ############################################################################################## */
-/* 80455270-80455278 003870 0008+00 1/1 0/0 0/0 .sdata2 @2964 */
-SECTION_SDATA2 static f64 lit_2964 = 0.5;
/* 802733A8-80273484 26DCE8 00DC+00 2/2 0/0 0/0 .text JFWDrawDoneAlarm__Fv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-static asm void JFWDrawDoneAlarm() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/JFWDrawDoneAlarm__Fv.s"
+static void JFWDrawDoneAlarm() {
+ JFWAlarm alarm;
+ s32 status = OSDisableInterrupts();
+ alarm.createAlarm();
+ alarm.appendLink();
+ OSSetAlarm(&alarm, 0.5 * (*(u32*)0x800000F8 >> 2), JFWGXAbortAlarmHandler);
+ GXDrawDone();
+ alarm.cancelAlarm();
+ alarm.removeLink();
+ OSRestoreInterrupts(status);
}
-#pragma pop
/* 80273484-802734FC 26DDC4 0078+00 1/1 0/0 0/0 .text
* JFWGXAbortAlarmHandler__FP7OSAlarmP9OSContext */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-static asm void JFWGXAbortAlarmHandler(OSAlarm* param_0, OSContext* param_1) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/JFWGXAbortAlarmHandler__FP7OSAlarmP9OSContext.s"
+static void JFWGXAbortAlarmHandler(OSAlarm* param_0, OSContext* param_1) {
+ diagnoseGpHang();
+ GXAbortFrame();
+ GFX_FIFO(u8) = 0x61;
+ GFX_FIFO(u32) = 0x5800000F;
+
+ GXFifoObj* fifo = GXGetCPUFifo();
+ if (fifo != NULL) {
+ void* base = GXGetFifoBase(fifo);
+ u32 size = GXGetFifoSize(fifo);
+ GXInit(base, size);
+ }
+ GXSetDrawDone();
}
-#pragma pop
-
-/* ############################################################################################## */
-/* 8039A878-8039A878 026ED8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
-#pragma push
-#pragma force_active on
-SECTION_DEAD static char const* const stringBase_8039A878 = "GP status %d%d%d%d%d%d --> ";
-SECTION_DEAD static char const* const stringBase_8039A894 = "GP hang due to XF stall bug.\n";
-SECTION_DEAD static char const* const stringBase_8039A8B2 =
- "GP hang due to unterminated primitive.\n";
-SECTION_DEAD static char const* const stringBase_8039A8DA = "GP hang due to illegal instruction.\n";
-SECTION_DEAD static char const* const stringBase_8039A8FF =
- "GP appears to be not hung (waiting for input).\n";
-SECTION_DEAD static char const* const stringBase_8039A92F = "GP is in unknown state.\n";
-#pragma pop
/* 802734FC-802736DC 26DE3C 01E0+00 1/1 0/0 0/0 .text diagnoseGpHang__Fv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-static asm void diagnoseGpHang() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/diagnoseGpHang__Fv.s"
-}
-#pragma pop
-
-/* 802736DC-80273724 26E01C 0048+00 0/0 1/0 0/0 .text __sinit_JFWDisplay_cpp */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void __sinit_JFWDisplay_cpp() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/__sinit_JFWDisplay_cpp.s"
-}
-#pragma pop
-
-#pragma push
-#pragma force_active on
-REGISTER_CTORS(0x802736DC, __sinit_JFWDisplay_cpp);
-#pragma pop
-
-/* 80273724-80273778 26E064 0054+00 1/1 0/0 0/0 .text __dt__18JSUList<8JFWAlarm>Fv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-extern "C" asm void func_80273724(void* _this) {
- nofralloc
-#include "asm/JSystem/JFramework/JFWDisplay/func_80273724.s"
+static void diagnoseGpHang() {
+ u32 sp28;
+ u32 sp24;
+ u32 sp20;
+ u32 sp1C;
+ u32 sp18;
+ u32 sp14;
+ u32 sp10;
+ u32 spC;
+ bool readIdle;
+ bool commandIdle;
+ bool sp8;
+
+ GXReadXfRasMetric(&sp24, &sp28, &sp1C, &sp20);
+ GXReadXfRasMetric(&sp14, &sp18, &spC, &sp10);
+
+ u32 temp_r31 = sp28 == sp18;
+ u32 temp_r30 = sp24 == sp14;
+ u32 temp_r0 = sp20 != sp10;
+ u32 temp_r0_2 = sp1C != spC;
+
+ GXGetGPStatus((GXBool*)&sp8, (GXBool*)&sp8, (GXBool*)&readIdle, (GXBool*)&commandIdle,
+ (GXBool*)&sp8);
+
+ OSReport("GP status %d%d%d%d%d%d --> ", readIdle, commandIdle, temp_r31, temp_r30, temp_r0,
+ temp_r0_2);
+
+ if (!temp_r30 && temp_r0) {
+ OSReport("GP hang due to XF stall bug.\n");
+ } else if (!temp_r31 && temp_r30 && temp_r0) {
+ OSReport("GP hang due to unterminated primitive.\n");
+ } else if (!commandIdle && temp_r31 && temp_r30 && temp_r0) {
+ OSReport("GP hang due to illegal instruction.\n");
+ } else if (readIdle && commandIdle && temp_r31 && temp_r30 && temp_r0 && temp_r0_2) {
+ OSReport("GP appears to be not hung (waiting for input).\n");
+ } else {
+ OSReport("GP is in unknown state.\n");
+ }
}
-#pragma pop
/* 8039A878-8039A878 026ED8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
diff --git a/libs/JSystem/JFramework/JFWSystem.cpp b/libs/JSystem/JFramework/JFWSystem.cpp
index 3339bf57df..4405ffbf36 100644
--- a/libs/JSystem/JFramework/JFWSystem.cpp
+++ b/libs/JSystem/JFramework/JFWSystem.cpp
@@ -4,6 +4,12 @@
//
#include "JSystem/JFramework/JFWSystem.h"
+#include "JSystem/JKernel/JKRAram.h"
+#include "JSystem/JUtility/JUTAssert.h"
+#include "JSystem/JUtility/JUTDirectPrint.h"
+#include "JSystem/JUtility/JUTException.h"
+#include "JSystem/JUtility/JUTGamePad.h"
+#include "JSystem/JUtility/JUTVideo.h"
#include "dol2asm.h"
#include "dolphin/types.h"
@@ -11,57 +17,10 @@
// Types:
//
-struct OSThread {};
-
-struct JUTVideo {
- /* 802E4C54 */ void createManager(_GXRenderModeObj const*);
-};
-
-struct JKRHeap {
- /* 802CE4D4 */ void alloc(u32, int);
-};
-
-struct JUTResFont {
- /* 802DEF94 */ JUTResFont(ResFONT const*, JKRHeap*);
-};
-
struct JUTGraphFifo {
/* 802DEB58 */ JUTGraphFifo(u32);
-};
-
-struct JUTGamePad {
- /* 802E0898 */ void init();
-};
-
-struct JUTDirectPrint {
- /* 802E4240 */ void start();
-};
-
-struct JUTException {
- /* 802E1E40 */ void create(JUTDirectPrint*);
- /* 802E3FEC */ void createConsole(void*, u32);
-};
-
-struct JUTDbPrint {
- /* 802E0190 */ void start(JUTFont*, JKRHeap*);
- /* 802E0204 */ void changeFont(JUTFont*);
-};
-
-struct JUTAssertion {
- /* 802E495C */ void create();
-};
-
-struct JKRThread {
- /* 802D16B8 */ JKRThread(OSThread*, int);
-};
-
-struct JKRExpHeap {
- /* 802CEDB4 */ void createRoot(int, bool);
- /* 802CEE2C */ void create(u32, JKRHeap*, bool);
-};
-struct JKRAram {
- /* 802D1FA4 */ void create(u32, u32, s32, s32, s32);
+ u8 field_0x0[0x1C];
};
//
@@ -111,10 +70,7 @@ extern "C" void create__12JUTAssertionFv();
extern "C" void createManager__8JUTVideoFPC16_GXRenderModeObj();
extern "C" void create__10JUTConsoleFUiUiP7JKRHeap();
extern "C" void createManager__17JUTConsoleManagerFP7JKRHeap();
-extern "C" void JUTSetReportConsole();
-extern "C" void JUTSetWarningConsole();
extern "C" void OSInit();
-extern "C" void OSGetCurrentThread();
extern "C" void DVDInit();
extern "C" extern u8 const JUTResFONT_Ascfont_fix12[16736];
extern "C" extern u8 GXNtsc480IntDf[60];
@@ -125,82 +81,78 @@ extern "C" extern u8 GXNtsc480IntDf[60];
/* ############################################################################################## */
/* 80450770-80450774 0001F0 0004+00 1/1 1/1 0/0 .sdata maxStdHeaps__Q29JFWSystem11CSetUpParam */
-SECTION_SDATA u32 JFWSystem::CSetUpParam::maxStdHeaps = 0x00000002;
+SECTION_SDATA s32 JFWSystem::CSetUpParam::maxStdHeaps = 2;
/* 80450774-80450778 0001F4 0004+00 1/1 1/1 0/0 .sdata sysHeapSize__Q29JFWSystem11CSetUpParam */
-SECTION_SDATA u32 JFWSystem::CSetUpParam::sysHeapSize = 0x00400000;
+SECTION_SDATA u32 JFWSystem::CSetUpParam::sysHeapSize = 0x400000;
/* 804511A0-804511A4 0006A0 0004+00 2/2 0/0 0/0 .sbss rootHeap__9JFWSystem */
-u8 JFWSystem::rootHeap[4];
+JKRExpHeap* JFWSystem::rootHeap;
/* 804511A4-804511A8 0006A4 0004+00 2/2 1/1 0/0 .sbss systemHeap__9JFWSystem */
-u8 JFWSystem::systemHeap[4];
+JKRExpHeap* JFWSystem::systemHeap;
/* 80271CD0-80271D18 26C610 0048+00 1/1 1/1 0/0 .text firstInit__9JFWSystemFv */
-#pragma push
-#pragma optimization_level 0
-#pragma optimizewithasm off
-asm void JFWSystem::firstInit() {
- nofralloc
-#include "asm/JSystem/JFramework/JFWSystem/firstInit__9JFWSystemFv.s"
+void JFWSystem::firstInit() {
+ OSInit();
+ DVDInit();
+ rootHeap = JKRExpHeap::createRoot(CSetUpParam::maxStdHeaps, false);
+ systemHeap = JKRExpHeap::create(CSetUpParam::sysHeapSize, rootHeap, false);
}
-#pragma pop
/* ############################################################################################## */
/* 80450778-8045077C 0001F8 0004+00 1/1 1/1 0/0 .sdata fifoBufSize__Q29JFWSystem11CSetUpParam */
-SECTION_SDATA u32 JFWSystem::CSetUpParam::fifoBufSize = 0x00040000;
+SECTION_SDATA u32 JFWSystem::CSetUpParam::fifoBufSize = 0x40000;
/* 8045077C-80450780 0001FC 0004+00 1/1 1/1 0/0 .sdata aramAudioBufSize__Q29JFWSystem11CSetUpParam
*/
-SECTION_SDATA u32 JFWSystem::CSetUpParam::aramAudioBufSize = 0x00800000;
+SECTION_SDATA u32 JFWSystem::CSetUpParam::aramAudioBufSize = 0x800000;
/* 80450780-80450784 000200 0004+00 1/1 1/1 0/0 .sdata aramGraphBufSize__Q29JFWSystem11CSetUpParam
*/
-SECTION_SDATA u32 JFWSystem::CSetUpParam::aramGraphBufSize = 0x00600000;
+SECTION_SDATA u32 JFWSystem::CSetUpParam::aramGraphBufSize = 0x600000;
/* 80450784-80450788 000204 0004+00 1/1 0/0 0/0 .sdata streamPriority__Q29JFWSystem11CSetUpParam
*/
-SECTION_SDATA u32 JFWSystem::CSetUpParam::streamPriority = 0x00000008;
+SECTION_SDATA u32 JFWSystem::CSetUpParam::streamPriority = 8;
/* 80450788-8045078C 000208 0004+00 1/1 0/0 0/0 .sdata decompPriority__Q29JFWSystem11CSetUpParam
*/
-SECTION_SDATA u32 JFWSystem::CSetUpParam::decompPriority = 0x00000007;
+SECTION_SDATA u32 JFWSystem::CSetUpParam::decompPriority = 7;
/* 8045078C-80450790 00020C 0004+00 1/1 0/0 0/0 .sdata aPiecePriority__Q29JFWSystem11CSetUpParam
*/
-SECTION_SDATA u32 JFWSystem::CSetUpParam::aPiecePriority = 0x00000006;
+SECTION_SDATA u32 JFWSystem::CSetUpParam::aPiecePriority = 6;
/* 80450790-80450794 -00001 0004+00 1/1 0/0 0/0 .sdata systemFontRes__Q29JFWSystem11CSetUpParam */
-SECTION_SDATA void* JFWSystem::CSetUpParam::systemFontRes = (void*)&JUTResFONT_Ascfont_fix12;
+SECTION_SDATA ResFONT* JFWSystem::CSetUpParam::systemFontRes = (ResFONT*)&JUTResFONT_Ascfont_fix12;
/* 80450794-80450798 -00001 0004+00 1/1 1/1 0/0 .sdata renderMode__Q29JFWSystem11CSetUpParam */
-SECTION_SDATA void* JFWSystem::CSetUpParam::renderMode = (void*)&GXNtsc480IntDf;
+SECTION_SDATA GXRenderModeObj* JFWSystem::CSetUpParam::renderMode =
+ (GXRenderModeObj*)&GXNtsc480IntDf;
/* 80450798-804507A0 000218 0004+04 1/1 0/0 0/0 .sdata
* exConsoleBufferSize__Q29JFWSystem11CSetUpParam */
-SECTION_SDATA u32 JFWSystem::CSetUpParam::exConsoleBufferSize[1 + 1 /* padding */] = {
- 0x000024FC,
- /* padding */
- 0x00000000,
-};
+SECTION_SDATA u32 JFWSystem::CSetUpParam::exConsoleBufferSize = 0x24FC;
/* 804511A8-804511AC 0006A8 0004+00 1/1 0/0 0/0 .sbss mainThread__9JFWSystem */
-u8 JFWSystem::mainThread[4];
+JKRThread* JFWSystem::mainThread;
/* 804511AC-804511B0 0006AC 0004+00 1/1 0/0 0/0 .sbss debugPrint__9JFWSystem */
-u8 JFWSystem::debugPrint[4];
+JUTDbPrint* JFWSystem::debugPrint;
/* 804511B0-804511B4 0006B0 0004+00 1/1 0/0 0/0 .sbss systemFont__9JFWSystem */
-u8 JFWSystem::systemFont[4];
+JUTResFont* JFWSystem::systemFont;
/* 804511B4-804511B8 0006B4 0004+00 1/1 0/0 0/0 .sbss systemConsoleManager__9JFWSystem */
-u8 JFWSystem::systemConsoleManager[4];
+JUTConsoleManager* JFWSystem::systemConsoleManager;
/* 804511B8-804511BC 0006B8 0004+00 1/1 7/7 0/0 .sbss systemConsole__9JFWSystem */
JUTConsole* JFWSystem::systemConsole;
/* 804511BC-804511C0 0006BC 0004+00 1/1 0/0 0/0 .sbss None */
-static u8 data_804511BC[4];
+static u8 data_804511BC;
+// static bool sInitCalled
/* 80455240-80455244 003840 0004+00 1/1 0/0 0/0 .sdata2 @2242 */
SECTION_SDATA2 static f32 lit_2242 = 0.5f;
@@ -212,6 +164,60 @@ SECTION_SDATA2 static f32 lit_2243 = 17.0f / 20.0f;
SECTION_SDATA2 static f64 lit_2245 = 4503601774854144.0 /* cast s32 to float */;
/* 80271D18-80272040 26C658 0328+00 0/0 1/1 0/0 .text init__9JFWSystemFv */
+// just regalloc in the beginning
+#ifdef NONMATCHING
+void JFWSystem::init() {
+ if (rootHeap == NULL) {
+ firstInit();
+ }
+ sInitCalled = true;
+
+ JKRAram::create(CSetUpParam::aramAudioBufSize, CSetUpParam::aramGraphBufSize,
+ CSetUpParam::streamPriority, CSetUpParam::decompPriority,
+ CSetUpParam::aPiecePriority);
+ mainThread = new JKRThread(OSGetCurrentThread(), 4);
+
+ JUTVideo::createManager(CSetUpParam::renderMode);
+
+ u32 fifoSize = CSetUpParam::fifoBufSize;
+ JUTGraphFifo* fifo = new JUTGraphFifo(fifoSize);
+
+ JUTGamePad::init();
+
+ JUTDirectPrint* dbPrint = JUTDirectPrint::start();
+
+ JUTAssertion::create();
+
+ JUTException::create(dbPrint);
+
+ systemFont = new JUTResFont(CSetUpParam::systemFontRes, NULL);
+
+ debugPrint = JUTDbPrint::start(NULL, NULL);
+ debugPrint->changeFont(systemFont);
+
+ systemConsoleManager = JUTConsoleManager::createManager(NULL);
+
+ systemConsole = JUTConsole::create(60, 200, NULL);
+ systemConsole->setFont(systemFont);
+
+ if (CSetUpParam::renderMode->efb_height < 300) {
+ systemConsole->setFontSize(systemFont->getWidth() * 0.85f, systemFont->getHeight() * 0.5f);
+ systemConsole->setPosition(20, 25);
+ } else {
+ systemConsole->setFontSize(systemFont->getWidth(), systemFont->getHeight());
+ systemConsole->setPosition(20, 50);
+ }
+
+ systemConsole->setHeight(25);
+ systemConsole->setVisible(false);
+ systemConsole->setOutput(JUTConsole::OUTPUT_OSREPORT | JUTConsole::OUTPUT_CONSOLE);
+ JUTSetReportConsole(systemConsole);
+ JUTSetWarningConsole(systemConsole);
+
+ void* buffer = systemHeap->alloc(CSetUpParam::exConsoleBufferSize, 4);
+ JUTException::createConsole(buffer, CSetUpParam::exConsoleBufferSize);
+}
+#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@@ -220,3 +226,4 @@ asm void JFWSystem::init() {
#include "asm/JSystem/JFramework/JFWSystem/init__9JFWSystemFv.s"
}
#pragma pop
+#endif
diff --git a/libs/JSystem/JParticle/JPAResource.cpp b/libs/JSystem/JParticle/JPAResource.cpp
index e25ed1a06c..ab95ac473c 100644
--- a/libs/JSystem/JParticle/JPAResource.cpp
+++ b/libs/JSystem/JParticle/JPAResource.cpp
@@ -180,7 +180,7 @@ JPAResource::JPAResource() {
/* ############################################################################################## */
/* 803C40C0-803C4220 0211E0 0144+1C 2/2 0/0 0/0 .data jpa_pos */
-SECTION_DATA static u8 jpa_pos[324 + 28 /* padding */] = {
+SECTION_DATA static u8 jpa_pos[324 + 28 /* padding */] ALIGN_DECL(32) = {
0x00,
0x00,
0x00,
diff --git a/libs/JSystem/JUtility/JUTException.cpp b/libs/JSystem/JUtility/JUTException.cpp
index ca000d5b10..de11b02146 100644
--- a/libs/JSystem/JUtility/JUTException.cpp
+++ b/libs/JSystem/JUtility/JUTException.cpp
@@ -1126,7 +1126,7 @@ void JUTException::createConsole(void* console_buffer, u32 console_buffer_size)
sConsole->setPosition(15, 26);
sConsole->setHeight(23);
sConsole->setVisible(true);
- sConsole->setOutput(3);
+ sConsole->setOutput(JUTConsole::OUTPUT_OSREPORT | JUTConsole::OUTPUT_CONSOLE);
}
}
diff --git a/libs/JSystem/JUtility/JUTProcBar.cpp b/libs/JSystem/JUtility/JUTProcBar.cpp
index 8b73c30aee..ed459566c6 100644
--- a/libs/JSystem/JUtility/JUTProcBar.cpp
+++ b/libs/JSystem/JUtility/JUTProcBar.cpp
@@ -11,47 +11,10 @@
// Types:
//
-struct JUtility {
- struct TColor {};
-};
-
struct JUTVideo {
static u8 sManager[4];
};
-struct JUTProcBar {
- struct CTime {
- /* 802E7340 */ CTime();
- };
-
- /* 802E5888 */ JUTProcBar();
- /* 802E599C */ ~JUTProcBar();
- /* 802E59E0 */ void create();
- /* 802E5A28 */ void destroy();
- /* 802E5A60 */ void clear();
- /* 802E5B30 */ void bar_subroutine(int, int, int, int, int, int, int, JUtility::TColor,
- JUtility::TColor);
- /* 802E5CC4 */ void adjustMeterLength(u32, f32*, f32, f32, int*);
- /* 802E5E08 */ void draw();
- /* 802E5E3C */ void drawProcessBar();
- /* 802E6FA0 */ void drawHeapBar();
-
- static u8 sManager[4];
-};
-
-struct JKRHeap {
- /* 802CE784 */ void getTotalFreeSize();
-
- static u8 sSystemHeap[4];
- static u8 sCurrentHeap[4];
- static u8 sRootHeap[4];
- static u8 mCodeStart[4];
- static u8 mCodeEnd[4];
- static u8 mUserRamStart[4];
- static u8 mUserRamEnd[4];
- static u8 mMemorySize[4];
-};
-
//
// Forward References:
//
@@ -82,7 +45,6 @@ extern "C" void __dl__FPv();
extern "C" void J2DDrawLine__FffffQ28JUtility6TColori();
extern "C" void J2DFillBox__FffffQ28JUtility6TColor();
extern "C" void J2DDrawFrame__FffffQ28JUtility6TColorUc();
-extern "C" void OSGetTick();
extern "C" void __construct_array();
extern "C" void _savegpr_21();
extern "C" void _savegpr_25();
@@ -118,7 +80,7 @@ asm JUTProcBar::JUTProcBar() {
/* ############################################################################################## */
/* 80451558-8045155C 000A58 0004+00 4/4 6/6 0/0 .sbss sManager__10JUTProcBar */
-u8 JUTProcBar::sManager[4];
+JUTProcBar* JUTProcBar::sManager;
/* 802E599C-802E59E0 2E02DC 0044+00 1/1 0/0 0/0 .text __dt__10JUTProcBarFv */
#pragma push
diff --git a/libs/JSystem/JUtility/JUTVideo.cpp b/libs/JSystem/JUtility/JUTVideo.cpp
index cff1fe483e..99d30ede73 100644
--- a/libs/JSystem/JUtility/JUTVideo.cpp
+++ b/libs/JSystem/JUtility/JUTVideo.cpp
@@ -15,7 +15,6 @@
//
extern "C" void GXSetDrawDone();
-extern "C" void GXCopyDisp(void*, BOOL);
//
// Declarations:
@@ -156,7 +155,7 @@ void JUTVideo::preRetraceProc(u32 retrace_count) {
s16 index = xfb->getDrawnXfbIndex();
if (index >= 0) {
xfb->setDisplayingXfbIndex(index);
- GXCopyDisp(xfb->getDisplayingXfb(), 1);
+ GXCopyDisp(xfb->getDisplayingXfb(), GX_TRUE);
GXFlush();
xfb->setSDrawingFlag(2);
frameBuffer = xfb->getDisplayingXfb();
diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp
index 8f12cebe78..e92b25e23a 100644
--- a/src/m_Do/m_Do_graphic.cpp
+++ b/src/m_Do/m_Do_graphic.cpp
@@ -68,10 +68,6 @@ struct cXyz {
static f32 Zero[3];
};
-struct JUTProcBar {
- static u8 sManager[4];
-};
-
struct JUTGamePad {
static u8 mPadStatus[48];
};
diff --git a/src/m_Do/m_Do_machine.cpp b/src/m_Do/m_Do_machine.cpp
index ff67445668..aea800a5a2 100644
--- a/src/m_Do/m_Do_machine.cpp
+++ b/src/m_Do/m_Do_machine.cpp
@@ -356,7 +356,8 @@ void myExceptionCallback(u16 param_0, OSContext* param_1, u32 param_2, u32 param
OSReport("JUTAssertionを可視化しました\n");
JUTAssertion::setVisible(true);
JUTDbPrint::getManager()->setVisible(true);
- JFWSystem::getSystemConsole()->setOutput(3);
+ JFWSystem::getSystemConsole()->setOutput(JUTConsole::OUTPUT_OSREPORT |
+ JUTConsole::OUTPUT_CONSOLE);
} else {
PPCHalt();
}
diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp
index c3286e0f64..5d77a1ec3d 100644
--- a/src/m_Do/m_Do_main.cpp
+++ b/src/m_Do/m_Do_main.cpp
@@ -544,7 +544,7 @@ bool Debug_console(u32 i_padNo) {
if (mDoCPd_c::getTrig(i_padNo) & CButton::A) {
console->dumpToTerminal(0xFFFFFFFF);
- console->setOutput(3);
+ console->setOutput(JUTConsole::OUTPUT_OSREPORT | JUTConsole::OUTPUT_CONSOLE);
}
JUTReport(0x1E, 0x186, 1, "Press X+Y+START to CLEAR console.");
@@ -709,7 +709,7 @@ void main01(void) {
JUTConsole* console = JFWSystem::getSystemConsole();
if (data_80450580 != 0) {
- console->setOutput(3);
+ console->setOutput(JUTConsole::OUTPUT_OSREPORT | JUTConsole::OUTPUT_CONSOLE);
}
console->setPosition(32, 42);