summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTakaRikka <38417346+TakaRikka@users.noreply.github.com>2025-10-19 10:30:49 -0700
committerGitHub <noreply@github.com>2025-10-19 20:30:49 +0300
commit850fae1aa304f7703ef973cf2126f246048ca25d (patch)
treef00b1bc2a000fd33dcc10ea08e2d57b8887fac70 /include
parent31c0f94a1052de4cd5cc9c829d41c4389b3fc7b7 (diff)
m_Do_main / f_ap_game / f_op_actor debug work and misc (#2744)
* m_Do_main / f_ap_game debug stuff * revolution sdk compatibility * f_op_actor debug work * rename fopAcM_SetupActor to fopAcM_ct * fix build * fix jp/pal splits
Diffstat (limited to 'include')
-rw-r--r--include/DynamicLink.h21
-rw-r--r--include/JSystem/J3DGraphBase/J3DSys.h2
-rw-r--r--include/JSystem/J3DGraphLoader/J3DModelSaver.h14
-rw-r--r--include/JSystem/JFramework/JFWDisplay.h3
-rw-r--r--include/JSystem/JHostIO/JORServer.h3
-rw-r--r--include/JSystem/JKernel/JKRAram.h12
-rw-r--r--include/JSystem/JKernel/JKRAramArchive.h1
-rw-r--r--include/JSystem/JKernel/JKRAramHeap.h8
-rw-r--r--include/JSystem/JUtility/JUTProcBar.h1
-rw-r--r--include/c/c_dylink.h2
-rw-r--r--include/d/actor/d_a_alink.h8
-rw-r--r--include/d/actor/d_a_guard_mng.h2
-rw-r--r--include/d/actor/d_a_midna.h2
-rw-r--r--include/d/actor/d_a_tag_arena.h2
-rw-r--r--include/d/actor/d_a_tag_assistance.h2
-rw-r--r--include/d/actor/d_a_tag_chkpoint.h2
-rw-r--r--include/d/actor/d_a_tag_gra.h2
-rw-r--r--include/d/actor/d_a_tag_schedule.h2
-rw-r--r--include/d/actor/d_a_tag_theB_hint.h2
-rw-r--r--include/d/d_attention.h1
-rw-r--r--include/d/d_bg_s.h2
-rw-r--r--include/d/d_cc_s.h2
-rw-r--r--include/d/d_com_inf_game.h18
-rw-r--r--include/d/d_demo.h6
-rw-r--r--include/d/d_particle.h2
-rw-r--r--include/d/d_resorce.h7
-rw-r--r--include/d/d_s_play.h10
-rw-r--r--include/d/d_s_play_env.h37
-rw-r--r--include/d/d_stage.h4
-rw-r--r--include/d/d_tresure.h4
-rw-r--r--include/dolphin/ai.h4
-rw-r--r--include/dolphin/ax.h4
-rw-r--r--include/dolphin/axart.h4
-rw-r--r--include/dolphin/axfx.h4
-rw-r--r--include/dolphin/base/PPCArch.h4
-rw-r--r--include/dolphin/db.h4
-rw-r--r--include/dolphin/db/DBInterface.h4
-rw-r--r--include/dolphin/dolphin.h4
-rw-r--r--include/dolphin/dsp.h4
-rw-r--r--include/dolphin/dvd.h4
-rw-r--r--include/dolphin/exi.h4
-rw-r--r--include/dolphin/gd.h4
-rw-r--r--include/dolphin/gd/GDBase.h4
-rw-r--r--include/dolphin/gd/GDFile.h4
-rw-r--r--include/dolphin/gd/GDGeometry.h4
-rw-r--r--include/dolphin/gd/GDIndirect.h4
-rw-r--r--include/dolphin/gd/GDLight.h4
-rw-r--r--include/dolphin/gd/GDPixel.h4
-rw-r--r--include/dolphin/gd/GDTev.h4
-rw-r--r--include/dolphin/gd/GDTexture.h4
-rw-r--r--include/dolphin/gd/GDTransform.h4
-rw-r--r--include/dolphin/gf.h4
-rw-r--r--include/dolphin/gf/GFGeometry.h10
-rw-r--r--include/dolphin/gf/GFLight.h10
-rw-r--r--include/dolphin/gf/GFPixel.h10
-rw-r--r--include/dolphin/gf/GFTev.h10
-rw-r--r--include/dolphin/gx.h4
-rw-r--r--include/dolphin/gx/GXBump.h4
-rw-r--r--include/dolphin/gx/GXCommandList.h4
-rw-r--r--include/dolphin/gx/GXCpu2Efb.h4
-rw-r--r--include/dolphin/gx/GXCull.h4
-rw-r--r--include/dolphin/gx/GXDispList.h4
-rw-r--r--include/dolphin/gx/GXDraw.h4
-rw-r--r--include/dolphin/gx/GXEnum.h4
-rw-r--r--include/dolphin/gx/GXFifo.h4
-rw-r--r--include/dolphin/gx/GXFrameBuffer.h4
-rw-r--r--include/dolphin/gx/GXGeometry.h4
-rw-r--r--include/dolphin/gx/GXGet.h4
-rw-r--r--include/dolphin/gx/GXLighting.h4
-rw-r--r--include/dolphin/gx/GXManage.h4
-rw-r--r--include/dolphin/gx/GXPerf.h4
-rw-r--r--include/dolphin/gx/GXPixel.h4
-rw-r--r--include/dolphin/gx/GXStruct.h4
-rw-r--r--include/dolphin/gx/GXTev.h4
-rw-r--r--include/dolphin/gx/GXTexture.h4
-rw-r--r--include/dolphin/gx/GXTransform.h5
-rw-r--r--include/dolphin/gx/GXVerify.h4
-rw-r--r--include/dolphin/gx/GXVert.h4
-rw-r--r--include/dolphin/mix.h4
-rw-r--r--include/dolphin/mtx.h4
-rw-r--r--include/dolphin/os.h4
-rw-r--r--include/dolphin/os/OSAlarm.h4
-rw-r--r--include/dolphin/os/OSAlloc.h4
-rw-r--r--include/dolphin/os/OSCache.h4
-rw-r--r--include/dolphin/os/OSContext.h4
-rw-r--r--include/dolphin/os/OSDC.h5
-rw-r--r--include/dolphin/os/OSError.h4
-rw-r--r--include/dolphin/os/OSException.h4
-rw-r--r--include/dolphin/os/OSExec.h4
-rw-r--r--include/dolphin/os/OSFont.h4
-rw-r--r--include/dolphin/os/OSIC.h5
-rw-r--r--include/dolphin/os/OSInterrupt.h4
-rw-r--r--include/dolphin/os/OSL2.h4
-rw-r--r--include/dolphin/os/OSLC.h4
-rw-r--r--include/dolphin/os/OSMemory.h4
-rw-r--r--include/dolphin/os/OSMessage.h4
-rw-r--r--include/dolphin/os/OSModule.h4
-rw-r--r--include/dolphin/os/OSMutex.h4
-rw-r--r--include/dolphin/os/OSReboot.h4
-rw-r--r--include/dolphin/os/OSReset.h4
-rw-r--r--include/dolphin/os/OSResetSW.h4
-rw-r--r--include/dolphin/os/OSRtc.h4
-rw-r--r--include/dolphin/os/OSSemaphore.h4
-rw-r--r--include/dolphin/os/OSSerial.h4
-rw-r--r--include/dolphin/os/OSThread.h4
-rw-r--r--include/dolphin/os/OSTime.h4
-rw-r--r--include/dolphin/os/OSTimer.h4
-rw-r--r--include/dolphin/os/OSUtf.h4
-rw-r--r--include/dolphin/pad.h4
-rw-r--r--include/dolphin/seq.h4
-rw-r--r--include/dolphin/si.h4
-rw-r--r--include/dolphin/sp.h4
-rw-r--r--include/dolphin/syn.h4
-rw-r--r--include/dolphin/types.h4
-rw-r--r--include/dolphin/vi.h4
-rw-r--r--include/dolphin/vi/vifuncs.h4
-rw-r--r--include/dolphin/vi/vitypes.h4
-rw-r--r--include/f_ap/f_ap_game.h141
-rw-r--r--include/f_op/f_op_actor.h74
-rw-r--r--include/f_op/f_op_actor_mng.h11
-rw-r--r--include/f_op/f_op_msg.h4
-rw-r--r--include/f_pc/f_pc_layer_iter.h1
-rw-r--r--include/m_Do/m_Do_MemCard.h4
-rw-r--r--include/m_Do/m_Do_Reset.h3
-rw-r--r--include/m_Do/m_Do_dvd_thread.h5
-rw-r--r--include/m_Do/m_Do_ext.h5
-rw-r--r--include/m_Do/m_Do_ext2.h30
-rw-r--r--include/m_Do/m_Do_graphic.h15
-rw-r--r--include/m_Do/m_Do_machine.h14
-rw-r--r--include/m_Do/m_Do_main.h9
-rw-r--r--include/m_Do/m_Do_printf.h12
-rw-r--r--include/revolution/ai.h50
-rw-r--r--include/revolution/amc/AmcExi2Comm.h123
-rw-r--r--include/revolution/amc/AmcTypes.h9
-rw-r--r--include/revolution/ax.h325
-rw-r--r--include/revolution/axart.h224
-rw-r--r--include/revolution/axfx.h196
-rw-r--r--include/revolution/base/PPCArch.h542
-rw-r--r--include/revolution/db.h22
-rw-r--r--include/revolution/db/DBInterface.h31
-rw-r--r--include/revolution/dsp.h57
-rw-r--r--include/revolution/dvd.h236
-rw-r--r--include/revolution/exi.h103
-rw-r--r--include/revolution/fake_tgmath.h66
-rw-r--r--include/revolution/gd.h14
-rw-r--r--include/revolution/gd/GDBase.h151
-rw-r--r--include/revolution/gd/GDFile.h31
-rw-r--r--include/revolution/gd/GDGeometry.h524
-rw-r--r--include/revolution/gd/GDIndirect.h91
-rw-r--r--include/revolution/gd/GDLight.h74
-rw-r--r--include/revolution/gd/GDPixel.h95
-rw-r--r--include/revolution/gd/GDTev.h133
-rw-r--r--include/revolution/gd/GDTexture.h127
-rw-r--r--include/revolution/gd/GDTransform.h56
-rw-r--r--include/revolution/gf.h9
-rw-r--r--include/revolution/gf/GFGeometry.h41
-rw-r--r--include/revolution/gf/GFLight.h8
-rw-r--r--include/revolution/gf/GFPixel.h13
-rw-r--r--include/revolution/gf/GFTev.h8
-rw-r--r--include/revolution/gx.h40
-rw-r--r--include/revolution/gx/GXBump.h29
-rw-r--r--include/revolution/gx/GXCommandList.h37
-rw-r--r--include/revolution/gx/GXCpu2Efb.h29
-rw-r--r--include/revolution/gx/GXCull.h18
-rw-r--r--include/revolution/gx/GXDispList.h18
-rw-r--r--include/revolution/gx/GXDraw.h24
-rw-r--r--include/revolution/gx/GXEnum.h924
-rw-r--r--include/revolution/gx/GXFifo.h46
-rw-r--r--include/revolution/gx/GXFrameBuffer.h66
-rw-r--r--include/revolution/gx/GXGeometry.h47
-rw-r--r--include/revolution/gx/GXGet.h64
-rw-r--r--include/revolution/gx/GXLighting.h32
-rw-r--r--include/revolution/gx/GXManage.h36
-rw-r--r--include/revolution/gx/GXPerf.h30
-rw-r--r--include/revolution/gx/GXPixel.h30
-rw-r--r--include/revolution/gx/GXStruct.h75
-rw-r--r--include/revolution/gx/GXTev.h33
-rw-r--r--include/revolution/gx/GXTexture.h52
-rw-r--r--include/revolution/gx/GXTransform.h34
-rw-r--r--include/revolution/gx/GXVerify.h29
-rw-r--r--include/revolution/gx/GXVert.h140
-rw-r--r--include/revolution/hw_regs.h116
-rw-r--r--include/revolution/mix.h95
-rw-r--r--include/revolution/mtx.h4
-rw-r--r--include/revolution/os.h354
-rw-r--r--include/revolution/os/OSAlarm.h36
-rw-r--r--include/revolution/os/OSAlloc.h34
-rw-r--r--include/revolution/os/OSCache.h38
-rw-r--r--include/revolution/os/OSContext.h173
-rw-r--r--include/revolution/os/OSDC.h23
-rw-r--r--include/revolution/os/OSError.h38
-rw-r--r--include/revolution/os/OSException.h61
-rw-r--r--include/revolution/os/OSExec.h35
-rw-r--r--include/revolution/os/OSFont.h58
-rw-r--r--include/revolution/os/OSIC.h20
-rw-r--r--include/revolution/os/OSInterrupt.h118
-rw-r--r--include/revolution/os/OSL2.h20
-rw-r--r--include/revolution/os/OSLC.h19
-rw-r--r--include/revolution/os/OSMemory.h28
-rw-r--r--include/revolution/os/OSMessage.h33
-rw-r--r--include/revolution/os/OSModule.h117
-rw-r--r--include/revolution/os/OSMutex.h33
-rw-r--r--include/revolution/os/OSReboot.h19
-rw-r--r--include/revolution/os/OSReset.h39
-rw-r--r--include/revolution/os/OSResetSW.h20
-rw-r--r--include/revolution/os/OSRtc.h84
-rw-r--r--include/revolution/os/OSSemaphore.h25
-rw-r--r--include/revolution/os/OSSerial.h6
-rw-r--r--include/revolution/os/OSThread.h112
-rw-r--r--include/revolution/os/OSTime.h44
-rw-r--r--include/revolution/os/OSTimer.h21
-rw-r--r--include/revolution/os/OSUtf.h23
-rw-r--r--include/revolution/pad.h104
-rw-r--r--include/revolution/revolution.h18
-rw-r--r--include/revolution/sc.h34
-rw-r--r--include/revolution/seq.h54
-rw-r--r--include/revolution/si.h175
-rw-r--r--include/revolution/sp.h40
-rw-r--r--include/revolution/syn.h172
-rw-r--r--include/revolution/types.h4
-rw-r--r--include/revolution/vi.h7
-rw-r--r--include/revolution/vi/vifuncs.h36
-rw-r--r--include/revolution/vi/vitypes.h41
223 files changed, 8520 insertions, 90 deletions
diff --git a/include/DynamicLink.h b/include/DynamicLink.h
index db282a3ee9..21ea5b722f 100644
--- a/include/DynamicLink.h
+++ b/include/DynamicLink.h
@@ -1,7 +1,9 @@
#ifndef DYNAMICLINK_H
#define DYNAMICLINK_H
-#include "dolphin/os.h"
+#include <dolphin/os.h>
+#include "JSystem/JKernel/JKRHeap.h"
+#include "global.h"
class JKRArchive;
class JKRFileCache;
@@ -23,6 +25,8 @@ struct DynamicModuleControlBase {
virtual void dump();
#endif
/* 80262470 */ static void dump();
+ static void dump(char*);
+
/* 802631FC */ virtual void dump2() {};
/* 802631DC */ virtual bool do_load() {return true;};
/* 802631F4 */ virtual BOOL do_load_async() {return true;};
@@ -39,8 +43,23 @@ struct DynamicModuleControlBase {
inline DynamicModuleControlBase* getNextClass() { return mNext; }
bool isLinked() const { return mLinkCount != 0; }
+ #if DEBUG
+ static void resetDoLinkCount() {} // TODO
+ static void dumpTag() {} // TODO
+ #endif
+
static DynamicModuleControlBase* mFirst;
static DynamicModuleControlBase* mLast;
+
+ #if DEBUG
+ static u8 verbose;
+ #endif
+
+ #if PLATFORM_WII || PLATFORM_SHIELD
+ static JKRHeap* getHeap() { return m_heap; }
+
+ static JKRHeap* m_heap;
+ #endif
};
struct DynamicModuleControl : DynamicModuleControlBase {
diff --git a/include/JSystem/J3DGraphBase/J3DSys.h b/include/JSystem/J3DGraphBase/J3DSys.h
index 141ec0296e..b819dd0793 100644
--- a/include/JSystem/J3DGraphBase/J3DSys.h
+++ b/include/JSystem/J3DGraphBase/J3DSys.h
@@ -162,7 +162,7 @@ struct J3DSys {
Mtx& getModelDrawMtx(u16 no) { return mModelDrawMtx[no]; }
J3DShapePacket* getShapePacket() { return mShapePacket; }
- void setViewMtx(Mtx m) { MTXCopy(m, mViewMtx); }
+ void setViewMtx(const Mtx m) { MTXCopy(m, mViewMtx); }
J3DModel* getModel() { return mModel; }
diff --git a/include/JSystem/J3DGraphLoader/J3DModelSaver.h b/include/JSystem/J3DGraphLoader/J3DModelSaver.h
new file mode 100644
index 0000000000..239a43fc52
--- /dev/null
+++ b/include/JSystem/J3DGraphLoader/J3DModelSaver.h
@@ -0,0 +1,14 @@
+#ifndef J3DMODELSAVER_H
+#define J3DMODELSAVER_H
+
+#include "JSystem/J3DGraphAnimator/J3DModel.h"
+
+enum J3DBinaryDisplayListSaverFlag {
+ J3DBinaryDisplayListSaverFlag_UNK_1 = 1,
+};
+
+namespace J3DModelSaverDataBase {
+ void* saveBinaryDisplayList(const J3DModel*, J3DBinaryDisplayListSaverFlag, u32);
+};
+
+#endif
diff --git a/include/JSystem/JFramework/JFWDisplay.h b/include/JSystem/JFramework/JFWDisplay.h
index cb43d8e07e..79a115046c 100644
--- a/include/JSystem/JFramework/JFWDisplay.h
+++ b/include/JSystem/JFramework/JFWDisplay.h
@@ -101,6 +101,9 @@ public:
void resetFader() { setFader(NULL); }
JUTFader* getFader() const { return mFader; }
void setClearColor(JUtility::TColor color) { mClearColor = color; }
+ int getEfbWidth() const { return JUTVideo::getManager()->getFbWidth(); }
+ int getEfbHeight() const { return JUTVideo::getManager()->getEfbHeight(); }
+ JUTXfb* getXfbManager() const { return mXfbManager; }
static JFWDisplay* sManager;
diff --git a/include/JSystem/JHostIO/JORServer.h b/include/JSystem/JHostIO/JORServer.h
index 99fdf51f9d..acec1227bb 100644
--- a/include/JSystem/JHostIO/JORServer.h
+++ b/include/JSystem/JHostIO/JORServer.h
@@ -7,6 +7,9 @@
#include "JSystem/JUtility/JUTAssert.h"
void JOR_MESSAGELOOP();
+void JOR_INIT();
+void JOR_SETROOTNODE(const char*, JORReflexible*, u32, u32);
+
u32 JORMessageBox(const char* message, const char* title, u32 style);
struct JOREventCallbackListNode {
diff --git a/include/JSystem/JKernel/JKRAram.h b/include/JSystem/JKernel/JKRAram.h
index ef935112ee..2d992749ce 100644
--- a/include/JSystem/JKernel/JKRAram.h
+++ b/include/JSystem/JKernel/JKRAram.h
@@ -89,6 +89,18 @@ inline JKRAramBlock *JKRMainRamToAram(u8 *buf, u32 bufSize, u32 alignedSize, JKR
return JKRAram::mainRamToAram(buf, bufSize, alignedSize, expandSwitch, fileSize, heap, id, pSize);
}
+inline u32 JKRGetAramTotalFreeSize() {
+ return JKRAram::getAramHeap()->getTotalFreeSize();
+}
+
+inline u32 JKRGetAramFreeSize() {
+ return JKRAram::getAramHeap()->getFreeSize();
+}
+
+inline u32 JKRGetAramUsedSize(u8 param_0) {
+ return JKRAram::getAramHeap()->getUsedSize(param_0);
+}
+
// void JKRDecompressFromAramToMainRam(u32, void*, u32, u32, u32, u32*);
#endif /* JKRARAM_H */
diff --git a/include/JSystem/JKernel/JKRAramArchive.h b/include/JSystem/JKernel/JKRAramArchive.h
index 2ea5f2863b..131dccbaa8 100644
--- a/include/JSystem/JKernel/JKRAramArchive.h
+++ b/include/JSystem/JKernel/JKRAramArchive.h
@@ -27,7 +27,6 @@ public:
static u32 fetchResource_subroutine(u32, u32, u8*, u32, int);
static u32 fetchResource_subroutine(u32, u32, JKRHeap*, int, u8**);
-private:
/* 0x00 */ // vtable
/* 0x04 */ // JKRArchive
/* 0x64 */ JKRAramBlock* mBlock;
diff --git a/include/JSystem/JKernel/JKRAramHeap.h b/include/JSystem/JKernel/JKRAramHeap.h
index 14f786a21f..3dd0bbd741 100644
--- a/include/JSystem/JKernel/JKRAramHeap.h
+++ b/include/JSystem/JKernel/JKRAramHeap.h
@@ -26,10 +26,10 @@ public:
JKRAramBlock* alloc(u32, EAllocMode);
JKRAramBlock* allocFromHead(u32);
JKRAramBlock* allocFromTail(u32);
- u32 getFreeSize(void);
- u32 getTotalFreeSize(void);
- // u32 getUsedSize(void);
- void dump(void);
+ u32 getFreeSize();
+ u32 getTotalFreeSize();
+ u32 getUsedSize(u8);
+ void dump();
void free(JKRAramBlock *block) {
delete block;
}
diff --git a/include/JSystem/JUtility/JUTProcBar.h b/include/JSystem/JUtility/JUTProcBar.h
index 42111ee765..f5099956d4 100644
--- a/include/JSystem/JUtility/JUTProcBar.h
+++ b/include/JSystem/JUtility/JUTProcBar.h
@@ -96,6 +96,7 @@ public:
void setCostFrame(int frame) { mCostFrame = frame; }
void setVisible(bool visible) { mVisible = visible; }
void setVisibleHeapBar(bool visible) { mHeapBarVisible = visible; }
+ void setWatchHeap(JKRHeap* pHeap) { mWatchHeap = pHeap; }
static JUTProcBar* getManager() { return sManager; }
diff --git a/include/c/c_dylink.h b/include/c/c_dylink.h
index e77ca3c2e1..8d213efd4a 100644
--- a/include/c/c_dylink.h
+++ b/include/c/c_dylink.h
@@ -23,4 +23,6 @@ BOOL cDyl_IsLinked(s16 i_ProfName);
BOOL cDyl_Unlink(s16 i_ProfName);
int cDyl_LinkASync(s16 i_ProfName);
+BOOL cCc_Check();
+
#endif /* C_C_DYLINK_H */
diff --git a/include/d/actor/d_a_alink.h b/include/d/actor/d_a_alink.h
index 3c6ce1aef5..28c160a6bd 100644
--- a/include/d/actor/d_a_alink.h
+++ b/include/d/actor/d_a_alink.h
@@ -3750,9 +3750,9 @@ public:
s16 getHookshotStopTime() const { return field_0x3026; }
bool getHookshotLeft() const { return field_0x3020 == 0; }
- static int getBallModelIdx() { return 0x25; }
- static int getBallBtkIdx() { return 0x49; }
- static int getBallBrkIdx() { return 0x41; }
+ static u16 getBallModelIdx() { return 0x25; }
+ static u16 getBallBtkIdx() { return 0x49; }
+ static u16 getBallBrkIdx() { return 0x41; }
bool checkRootTransClearMode() { return field_0x2f99 & 7; }
bool checkRootTransZClearMode() { return field_0x2f99 & 4; }
@@ -3828,6 +3828,8 @@ public:
u16 getReadyItem() { return dComIfGp_getSelectItem(mSelectItemId); }
+ static u32 getOtherHeapSize() { return 0xF0A60; }
+
static daAlink_BckData const m_mainBckShield[20];
static daAlink_BckData const m_mainBckSword[5];
static daAlink_BckData const m_mainBckFishing[28];
diff --git a/include/d/actor/d_a_guard_mng.h b/include/d/actor/d_a_guard_mng.h
index 4d7e2e6c52..8b2262d394 100644
--- a/include/d/actor/d_a_guard_mng.h
+++ b/include/d/actor/d_a_guard_mng.h
@@ -56,7 +56,7 @@ public:
}
int create() {
- fopAcM_SetupActor(this, daGuardMng_c);
+ fopAcM_ct(this, daGuardMng_c);
create_init();
return cPhs_COMPLEATE_e;
}
diff --git a/include/d/actor/d_a_midna.h b/include/d/actor/d_a_midna.h
index efadec9dc7..d5a885f629 100644
--- a/include/d/actor/d_a_midna.h
+++ b/include/d/actor/d_a_midna.h
@@ -391,6 +391,8 @@ public:
onStateFlg0(daMidna_FLG0(FLG0_PORTAL_OBJ_CALL | FLG0_TAG_WAIT));
}
+ static u32 getOtherHeapSize() { return 0x1D0; }
+
static daMidna_texData_s const m_texDataTable[21];
static daMidna_anmData_s const m_anmDataTable[53];
diff --git a/include/d/actor/d_a_tag_arena.h b/include/d/actor/d_a_tag_arena.h
index 829a4cbd5f..bb2d158185 100644
--- a/include/d/actor/d_a_tag_arena.h
+++ b/include/d/actor/d_a_tag_arena.h
@@ -6,7 +6,7 @@
class daTagArena_c : public fopAc_ac_c {
public:
int create() {
- fopAcM_SetupActor(this, daTagArena_c);
+ fopAcM_ct(this, daTagArena_c);
return cPhs_COMPLEATE_e;
}
diff --git a/include/d/actor/d_a_tag_assistance.h b/include/d/actor/d_a_tag_assistance.h
index 6b93b9e5c3..73f71e297f 100644
--- a/include/d/actor/d_a_tag_assistance.h
+++ b/include/d/actor/d_a_tag_assistance.h
@@ -11,7 +11,7 @@ public:
}
int create() {
- fopAcM_SetupActor(this, daTagAssist_c);
+ fopAcM_ct(this, daTagAssist_c);
create_init();
return cPhs_COMPLEATE_e;
}
diff --git a/include/d/actor/d_a_tag_chkpoint.h b/include/d/actor/d_a_tag_chkpoint.h
index 887ff97f9c..c13c63c75e 100644
--- a/include/d/actor/d_a_tag_chkpoint.h
+++ b/include/d/actor/d_a_tag_chkpoint.h
@@ -14,7 +14,7 @@ public:
u8 getSwBit2() { return fopAcM_GetParam(this) >> 16; }
int create() {
- fopAcM_SetupActor(this, daTag_Chk_c);
+ fopAcM_ct(this, daTag_Chk_c);
if (getAreaType() == 0) {
scale.x *= 50.0f;
diff --git a/include/d/actor/d_a_tag_gra.h b/include/d/actor/d_a_tag_gra.h
index 7586d39918..9d2eaef1bd 100644
--- a/include/d/actor/d_a_tag_gra.h
+++ b/include/d/actor/d_a_tag_gra.h
@@ -30,7 +30,7 @@ public:
}
int create() {
- fopAcM_SetupActor(this, daTagGra_c);
+ fopAcM_ct(this, daTagGra_c);
if (getMode() == 2) {
if (dComIfGs_isSwitch(getSwBit(),fopAcM_GetRoomNo(this))) {
diff --git a/include/d/actor/d_a_tag_schedule.h b/include/d/actor/d_a_tag_schedule.h
index 7acd08601f..67fd484167 100644
--- a/include/d/actor/d_a_tag_schedule.h
+++ b/include/d/actor/d_a_tag_schedule.h
@@ -6,7 +6,7 @@
class daTagSchedule_c : public fopAc_ac_c {
public:
int create() {
- fopAcM_SetupActor(this, daTagSchedule_c);
+ fopAcM_ct(this, daTagSchedule_c);
return cPhs_COMPLEATE_e;
}
diff --git a/include/d/actor/d_a_tag_theB_hint.h b/include/d/actor/d_a_tag_theB_hint.h
index 5eabf046c6..25d708f1a0 100644
--- a/include/d/actor/d_a_tag_theB_hint.h
+++ b/include/d/actor/d_a_tag_theB_hint.h
@@ -68,7 +68,7 @@ public:
}
int create() {
- fopAcM_SetupActor(this, daTagTheBHint_c);
+ fopAcM_ct(this, daTagTheBHint_c);
field_0x568 = pow(scale.x * 100.0f,2.0f);
return cPhs_COMPLEATE_e;
}
diff --git a/include/d/d_attention.h b/include/d/d_attention.h
index 879f88aeba..865bd1baf1 100644
--- a/include/d/d_attention.h
+++ b/include/d/d_attention.h
@@ -249,6 +249,7 @@ public:
void runDebugDisp0();
#endif
+ JKRSolidHeap* getHeap() { return heap; }
fopAc_ac_c* getCatghTarget() { return mCatghTarget.getCatghTarget(); }
fopAc_ac_c* getZHintTarget() { return mZHintTarget.getZHintTarget(); }
u8 getCatchChgItem() { return mCatghTarget.getChangeItem(); }
diff --git a/include/d/d_bg_s.h b/include/d/d_bg_s.h
index c6727486a5..9a2213c4cd 100644
--- a/include/d/d_bg_s.h
+++ b/include/d/d_bg_s.h
@@ -141,6 +141,8 @@ public:
fopAc_ac_c* GetActorPointer(cBgS_PolyInfo const& param_0) const { return cBgS::GetActorPointer(param_0); }
f32 GroundCross(cBgS_GndChk* i_gndChk) { return (f32)((cBgS*)this)->GroundCross(i_gndChk); }
+ void ChkDeleteActorRegist(fopAc_ac_c*);
+
#ifdef DEBUG
/* 0x1404 */ u8 field_0x1404[0x1408 - 0x1404];
/* 0x1408 */ dBgS_HIO m_hio;
diff --git a/include/d/d_cc_s.h b/include/d/d_cc_s.h
index af4428d1d4..8ca908dd5e 100644
--- a/include/d/d_cc_s.h
+++ b/include/d/d_cc_s.h
@@ -59,6 +59,8 @@ public:
mMass_Mng.SetAttr(radius, height, param_2, param_3);
}
+ void ChkActor(fopAc_ac_c*);
+
static bool m_mtrl_hit_tbl[64];
// /* 0x0000 */ cCcS mCCcS;
diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h
index 34a08bc343..910a297975 100644
--- a/include/d/d_com_inf_game.h
+++ b/include/d/d_com_inf_game.h
@@ -295,6 +295,7 @@ public:
dEvent_manager_c& getEvtManager() { return mEvtManager; }
dAttention_c* getAttention() { return &mAttention; }
dStage_startStage_c* getStartStage() { return &mStartStage; }
+ dSmplMdl_draw_c* getSimpleModel() { return mSimpleModel; }
void setCurrentGrafPort(J2DOrthoGraph* i_graf) { mCurrentGrafPort = i_graf; }
void setCurrentWindow(dDlst_window_c* i_window) { mCurrentWindow = i_window; }
@@ -589,6 +590,7 @@ public:
void setExpHeap2D(void* heap) { mItemInfo.mExpHeap2D = (JKRExpHeap*)heap; }
void setMsgExpHeap(void* heap) { mItemInfo.mMsgExpHeap = (JKRExpHeap*)heap; }
+ JKRArchive* getMsgDtArchive() { return mMsgDtArchive[0]; }
JKRArchive* getMsgDtArchive(int idx) { return mMsgDtArchive[idx]; }
JKRArchive* getMsgArchive(int idx) { return mMsgArchive[idx]; }
JKRArchive* getMsgCommonArchive() { return mMsgCommonArchive; }
@@ -864,6 +866,10 @@ extern GXColor g_clearColor;
extern GXColor g_whiteColor;
extern GXColor g_saftyWhiteColor;
+inline void dComIfG_ct() {
+ g_dComIfG_gameInfo.ct();
+}
+
int dComLbG_PhaseHandler(request_of_phase_process_class*, request_of_phase_process_fn*, void*);
BOOL dComIfG_resetToOpening(scene_class* scene);
char* dComIfG_getRoomArcName(int roomNo);
@@ -979,6 +985,10 @@ inline void* dComIfG_getObjectRes(const char* i_arcName, int i_index) {
return g_dComIfG_gameInfo.mResControl.getObjectRes(i_arcName, i_index);
}
+inline void dComIfG_dumpResControl() {
+ g_dComIfG_gameInfo.mResControl.dump();
+}
+
inline dBgS& dComIfG_Bgsp() {
return g_dComIfG_gameInfo.play.mBgs;
}
@@ -1816,6 +1826,10 @@ inline void dComIfGs_removeZone(int i_zoneNo) {
g_dComIfG_gameInfo.info.removeZone(i_zoneNo);
}
+inline dSmplMdl_draw_c* dComIfGp_getSimpleModel() {
+ return g_dComIfG_gameInfo.play.getSimpleModel();
+}
+
inline int dComIfGp_addSimpleModel(J3DModelData* i_modelData, int roomNo, u8 i_drawBG) {
return g_dComIfG_gameInfo.play.addSimpleModel(i_modelData, roomNo, i_drawBG);
}
@@ -2314,6 +2328,10 @@ inline JKRArchive* dComIfGp_getDemoMsgArchive() {
return g_dComIfG_gameInfo.play.getDemoMsgArchive();
}
+inline JKRArchive* dComIfGp_getMsgDtArchive() {
+ return g_dComIfG_gameInfo.play.getMsgDtArchive();
+}
+
inline JKRArchive* dComIfGp_getMsgDtArchive(int idx) {
return g_dComIfG_gameInfo.play.getMsgDtArchive(idx);
}
diff --git a/include/d/d_demo.h b/include/d/d_demo.h
index ce72547a31..513ffbb2bf 100644
--- a/include/d/d_demo.h
+++ b/include/d/d_demo.h
@@ -361,7 +361,11 @@ public:
/* 80039EEC */ static void setBranchId(u16, s16);
/* 80039F04 */ static void reset();
- static dDemo_actor_c* getActor(u8 param_0) { return m_object->getActor(param_0); }
+ static dDemo_actor_c* getActor(u8 param_0) {
+ JUT_ASSERT(546, m_object != NULL);
+ return m_object->getActor(param_0);
+ }
+
static u32 getFrameNoMsg() { return m_frameNoMsg; }
static s32 getMode() { return m_mode; }
static u32 getFrame() { return m_frame; }
diff --git a/include/d/d_particle.h b/include/d/d_particle.h
index c1c01f91ff..956466a758 100644
--- a/include/d/d_particle.h
+++ b/include/d/d_particle.h
@@ -403,6 +403,8 @@ public:
void draw2DmenuFore(JPADrawInfo* i_drawInfo) { draw(i_drawInfo, 17); }
void draw2DmenuBack(JPADrawInfo* i_drawInfo) { draw(i_drawInfo, 18); }
+ JKRSolidHeap* getHeap() { return mHeap; }
+ JKRSolidHeap* getSceneHeap() { return m_sceneHeap; }
JKRExpHeap* getResHeap() { return m_resHeap; }
void levelAllForceOnEventMove() { field_0x210.allForceOnEventMove(); }
diff --git a/include/d/d_resorce.h b/include/d/d_resorce.h
index 9da681c3f0..3d00f861e6 100644
--- a/include/d/d_resorce.h
+++ b/include/d/d_resorce.h
@@ -67,6 +67,7 @@ public:
int setObjectRes(char const* i_arcName, void* i_archiveRes, u32 i_bufferSize, JKRHeap* i_heap);
int setStageRes(char const* i_arcName, JKRHeap* i_heap);
void dump();
+ void dump(char*);
int getObjectResName2Index(char const* i_arcName, char const* i_resName);
static int setRes(char const* i_arcName, dRes_info_c* i_resInfo, int i_infoNum, char const* i_path, u8 i_mountDirection, JKRHeap* i_heap);
@@ -126,6 +127,12 @@ public:
dRes_info_c* getStageResInfo(const char* i_arcName) {
return getResInfo(i_arcName, mStageInfo, ARRAY_SIZEU(mStageInfo));
}
+
+ #if DEBUG
+ void dumpTag() {
+ // TODO
+ }
+ #endif
/* 0x0000 */ dRes_info_c mObjectInfo[128];
/* 0x1200 */ dRes_info_c mStageInfo[64];
diff --git a/include/d/d_s_play.h b/include/d/d_s_play.h
index 190402d1e6..e6a9644298 100644
--- a/include/d/d_s_play.h
+++ b/include/d/d_s_play.h
@@ -15,13 +15,17 @@ public:
/* 0x7C */ s16 mShortReg[10];
};
-class dScnPly_reg_HIO_c {
+class dScnPly_reg_HIO_c : public JORReflexible {
public:
/* 8025AD78 */ virtual ~dScnPly_reg_HIO_c() {}
- /* 0x4 */ u8 field_0x4[0x8 - 0x4];
#ifdef DEBUG
+ void genMessage(JORMContext*);
+
+ /* 0x4 */ s8 id;
/* 0x8 */ dScnPly_reg_childHIO_c mChildReg[26];
+#else
+ /* 0x4 */ u8 field_0x4[0x8 - 0x4];
#endif
};
@@ -50,7 +54,7 @@ public:
virtual void genMessage(JORMContext*);
virtual ~dScnPly_preset_HIO_c() {}
- /* 0x0004 */ u8 field_0x4;
+ /* 0x0004 */ s8 field_0x4;
/* 0x0005 */ u8 field_0x5;
/* 0x0006 */ u8 mPresetData[10000];
/* 0x2716 */ u8 field_0x2716;
diff --git a/include/d/d_s_play_env.h b/include/d/d_s_play_env.h
index b8b0172e20..f67306fd08 100644
--- a/include/d/d_s_play_env.h
+++ b/include/d/d_s_play_env.h
@@ -8,14 +8,37 @@ public:
/* 8025AC0C */ virtual ~dScnPly_env_otherHIO_c() {}
void genMessage(JORMContext*);
- /* 0x04 */ f32 mShadowDensity;
- /* 0x08 */ u8 mLODBias;
- /* 0x09 */ u8 field_0x9;
- /* 0x0A */ u8 mDispTransCylinder;
#ifdef DEBUG
- /* 0x0B */ u8 field_0xb[0x46 - 0xb];
- /* 0x46 */ u8 field_0x46;
- /* 0x47 */ u8 field_0x47[0x4f - 0x47];
+ /* 0x04 */ s8 field_0x04;
+ #endif
+
+ /* 0x08 */ f32 mShadowDensity;
+
+ #ifdef DEBUG
+ /* 0x0C */ f32 mCullFarValue;
+ /* 0x10 */ f32 mRailSize;
+ /* 0x14 */ s16 mRailColorR;
+ /* 0x16 */ s16 mRailColorG;
+ /* 0x18 */ s16 mRailColorB;
+ /* 0x1A */ s16 field_0x1a;
+ /* 0x1C */ s16 field_0x1c[20];
+ #endif
+
+ /* 0x44 */ u8 mAdjustLODBias;
+ /* 0x45 */ u8 field_0x45;
+ /* 0x46 */ u8 mDisplayTransparentCyl;
+
+ #ifdef DEBUG
+ /* 0x47 */ u8 mDisplayShadows;
+ /* 0x48 */ u8 mDisplayShadowImage;
+ /* 0x49 */ u8 mDisplayShadowPoly;
+ /* 0x4A */ u8 mDisplayCullBox;
+ /* 0x4B */ u8 mLoadAllRooms;
+ /* 0x4C */ u8 mDepthOfField;
+ /* 0x4D */ u8 mDisplayParticleInfo;
+ /* 0x4E */ u8 field_0x4e;
+ /* 0x4F */ u8 field_0x4f;
+ /* 0x50 */ u8 mAdjustCullFar;
#endif
};
diff --git a/include/d/d_stage.h b/include/d/d_stage.h
index d027dc9941..9976a4b801 100644
--- a/include/d/d_stage.h
+++ b/include/d/d_stage.h
@@ -1153,6 +1153,8 @@ public:
return cLib_onBit(mStatus[i_roomNo].mFlag, flag);
}
+ static JKRExpHeap* getMemoryBlockHeap(int i_no) { return mMemoryBlock[i_no]; }
+
static const int MEMORY_BLOCK_MAX = 19;
static JKRExpHeap* mMemoryBlock[MEMORY_BLOCK_MAX];
@@ -1426,7 +1428,7 @@ inline u32 dStage_FileList_dt_GetEnemyAppear1Flag(dStage_FileList_dt_c* p_fList)
return p_fList->mParameters & 0x20000000;
}
-inline int dStage_FileList_dt_GetBitSw(dStage_FileList_dt_c* p_fList) {
+inline u8 dStage_FileList_dt_GetBitSw(dStage_FileList_dt_c* p_fList) {
return p_fList->mBitSw;
}
diff --git a/include/d/d_tresure.h b/include/d/d_tresure.h
index f6649180e2..54c776227c 100644
--- a/include/d/d_tresure.h
+++ b/include/d/d_tresure.h
@@ -94,6 +94,10 @@ public:
offStatus(0, param_0, i_flag);
}
+ static typeGroupData_c* getTypeGroupData() {
+ return mTypeGroupData;
+ }
+
static u8 const typeToTypeGroup[17][2];
static type_group_list mTypeGroupListAll[17];
static typeGroupData_c* mTypeGroupData;
diff --git a/include/dolphin/ai.h b/include/dolphin/ai.h
index 84db3343b0..a42a59da2f 100644
--- a/include/dolphin/ai.h
+++ b/include/dolphin/ai.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_AI_H_
#define _DOLPHIN_AI_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/ai.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -48,3 +51,4 @@ void AIReset(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/ax.h b/include/dolphin/ax.h
index 0148446ee8..c43a3cb639 100644
--- a/include/dolphin/ax.h
+++ b/include/dolphin/ax.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_AX_H_
#define _DOLPHIN_AX_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/ax.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -322,4 +325,5 @@ extern u16 axDspSlave[AX_DSP_SLAVE_LENGTH];
}
#endif
+#endif
#endif // _DOLPHIN_AX_H_
diff --git a/include/dolphin/axart.h b/include/dolphin/axart.h
index 46c375f71c..1f12409f8f 100644
--- a/include/dolphin/axart.h
+++ b/include/dolphin/axart.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_AXART_H_
#define _DOLPHIN_AXART_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/axart.h>
+#else
#include <dolphin/types.h>
#include <dolphin/ax.h>
@@ -221,4 +224,5 @@ void AXARTLpf(AXART_LPF*, AXVPB*);
}
#endif
+#endif
#endif // _DOLPHIN_AXART_H_
diff --git a/include/dolphin/axfx.h b/include/dolphin/axfx.h
index 53933c858f..93b34d33b6 100644
--- a/include/dolphin/axfx.h
+++ b/include/dolphin/axfx.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_AXFX_H_
#define _DOLPHIN_AXFX_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/axfx.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -193,4 +196,5 @@ void AXFXReverbStdCallback(AXFX_BUFFERUPDATE* bufferUpdate, AXFX_REVERBSTD* reve
}
#endif
+#endif
#endif // _DOLPHIN_AXFX_H_
diff --git a/include/dolphin/base/PPCArch.h b/include/dolphin/base/PPCArch.h
index 35f5da9c71..fa67b8a021 100644
--- a/include/dolphin/base/PPCArch.h
+++ b/include/dolphin/base/PPCArch.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_PPCARCH
#define _DOLPHIN_PPCARCH
+#ifdef __REVOLUTION_SDK__
+#include <revolution/base/PPCArch.h>
+#else
#include "dolphin/types.h"
#ifdef __cplusplus
@@ -539,4 +542,5 @@ void PMInstructions(void);
}
#endif
+#endif
#endif // _DOLPHIN_PPCARCH
diff --git a/include/dolphin/db.h b/include/dolphin/db.h
index c62f188e40..0a35c06198 100644
--- a/include/dolphin/db.h
+++ b/include/dolphin/db.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_DB_H_
#define _DOLPHIN_DB_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/db.h>
+#else
#include <dolphin/types.h>
#include <dolphin/db/DBInterface.h>
@@ -19,4 +22,5 @@ u32 DBRead(u8*, u32);
}
#endif
+#endif
#endif // _DOLPHIN_DB_H_
diff --git a/include/dolphin/db/DBInterface.h b/include/dolphin/db/DBInterface.h
index 7bfa354272..58a90f1e5d 100644
--- a/include/dolphin/db/DBInterface.h
+++ b/include/dolphin/db/DBInterface.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_DBINTERFACE_H_
#define _DOLPHIN_DBINTERFACE_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/db/DBInterface.h>
+#else
#include <dolphin/os.h>
#ifdef __cplusplus
@@ -29,3 +32,4 @@ void __DBSetPresent(u32 value);
#endif
#endif
+#endif
diff --git a/include/dolphin/dolphin.h b/include/dolphin/dolphin.h
index ac1ebcf7b0..a81740a6cf 100644
--- a/include/dolphin/dolphin.h
+++ b/include/dolphin/dolphin.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_H_
#define _DOLPHIN_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/revolution.h>
+#else
#include <dolphin/types.h>
#include <dolphin/os.h>
#include <dolphin/dsp.h>
@@ -22,3 +25,4 @@
#include <dolphin/si.h>
#endif
+#endif
diff --git a/include/dolphin/dsp.h b/include/dolphin/dsp.h
index e3a20b9088..a9790c37d9 100644
--- a/include/dolphin/dsp.h
+++ b/include/dolphin/dsp.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_DSP_H_
#define _DOLPHIN_DSP_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/dsp.h>
+#else
#include <dolphin/os.h>
#ifdef __cplusplus
@@ -55,3 +58,4 @@ DSPTaskInfo* __DSPGetCurrentTask(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/dvd.h b/include/dolphin/dvd.h
index ae036cad3f..382e82c318 100644
--- a/include/dolphin/dvd.h
+++ b/include/dolphin/dvd.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_DVD_H_
#define _DOLPHIN_DVD_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/dvd.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -234,3 +237,4 @@ void DVDDumpWaitingQueue(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/exi.h b/include/dolphin/exi.h
index f094c36130..17cfc7d563 100644
--- a/include/dolphin/exi.h
+++ b/include/dolphin/exi.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_EXI_H_
#define _DOLPHIN_EXI_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/exi.h>
+#else
#include <dolphin/os.h>
#ifdef __cplusplus
@@ -101,3 +104,4 @@ char* EXIGetTypeString(u32 type);
#endif
#endif
+#endif
diff --git a/include/dolphin/gd.h b/include/dolphin/gd.h
index 57c929dad6..2a39517353 100644
--- a/include/dolphin/gd.h
+++ b/include/dolphin/gd.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_H_
#define _DOLPHIN_GD_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd.h>
+#else
#include <dolphin/gd/GDBase.h>
#include <dolphin/gd/GDFile.h>
#include <dolphin/gd/GDGeometry.h>
@@ -12,3 +15,4 @@
#include <dolphin/gd/GDTransform.h>
#endif
+#endif
diff --git a/include/dolphin/gd/GDBase.h b/include/dolphin/gd/GDBase.h
index 3e148c3228..264f25bc4d 100644
--- a/include/dolphin/gd/GDBase.h
+++ b/include/dolphin/gd/GDBase.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_BASE_H
#define _DOLPHIN_GD_BASE_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDBase.h>
+#else
#include <dolphin/types.h>
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXCommandList.h>
@@ -149,3 +152,4 @@ static inline u32 GDGetGDLObjOffset(const GDLObj* dl) {
#endif
#endif
+#endif
diff --git a/include/dolphin/gd/GDFile.h b/include/dolphin/gd/GDFile.h
index 3589fbb7ee..8ccd30a19b 100644
--- a/include/dolphin/gd/GDFile.h
+++ b/include/dolphin/gd/GDFile.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_FILE_H
#define _DOLPHIN_GD_FILE_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDFile.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -29,3 +32,4 @@ s32 GDReadDLFile(const char* fName, u32* numDLs, u32* numPLs, GDGList** DLDescAr
#endif
#endif
+#endif
diff --git a/include/dolphin/gd/GDGeometry.h b/include/dolphin/gd/GDGeometry.h
index 3b0424fbd4..77bb313725 100644
--- a/include/dolphin/gd/GDGeometry.h
+++ b/include/dolphin/gd/GDGeometry.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_GEOMETRY_H_
#define _DOLPHIN_GD_GEOMETRY_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDGeometry.h>
+#else
#include <dolphin/gx/GXStruct.h>
#ifdef __cplusplus
@@ -522,3 +525,4 @@ void GDSetCoPlanar(u8 enable);
#endif
#endif
+#endif
diff --git a/include/dolphin/gd/GDIndirect.h b/include/dolphin/gd/GDIndirect.h
index 4ca854c31b..80064d577c 100644
--- a/include/dolphin/gd/GDIndirect.h
+++ b/include/dolphin/gd/GDIndirect.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_INDIRECT_H_
#define _DOLPHIN_GD_INDIRECT_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDIndirect.h>
+#else
#include <dolphin/types.h>
#include <dolphin/gx/GXEnum.h>
#include <dolphin/mtx.h>
@@ -89,3 +92,4 @@ void __GDSetIndTexMask(u32 mask);
#endif
#endif
+#endif
diff --git a/include/dolphin/gd/GDLight.h b/include/dolphin/gd/GDLight.h
index 549b07a26e..a725830fe4 100644
--- a/include/dolphin/gd/GDLight.h
+++ b/include/dolphin/gd/GDLight.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_LIGHT_H_
#define _DOLPHIN_GD_LIGHT_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDLight.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
#include "global.h"
@@ -72,3 +75,4 @@ inline static u16 __GDLightID2Offset(GXLightID id) {
#endif
#endif
+#endif
diff --git a/include/dolphin/gd/GDPixel.h b/include/dolphin/gd/GDPixel.h
index 158b04ec1f..8d9611f22f 100644
--- a/include/dolphin/gd/GDPixel.h
+++ b/include/dolphin/gd/GDPixel.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_PIXEL_H
#define _DOLPHIN_GD_PIXEL_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDPixel.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -93,3 +96,4 @@ void GDSetDrawSync(u16 token);
#endif
#endif
+#endif
diff --git a/include/dolphin/gd/GDTev.h b/include/dolphin/gd/GDTev.h
index baec8b5e2e..f81cba54ed 100644
--- a/include/dolphin/gd/GDTev.h
+++ b/include/dolphin/gd/GDTev.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_TEV_H
#define _DOLPHIN_GD_TEV_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDTev.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -131,3 +134,4 @@ void GDSetTevOrder(GXTevStageID evenStage, GXTexCoordID coord0, GXTexMapID map0,
#endif
#endif
+#endif
diff --git a/include/dolphin/gd/GDTexture.h b/include/dolphin/gd/GDTexture.h
index 2370cbb52b..d041de665b 100644
--- a/include/dolphin/gd/GDTexture.h
+++ b/include/dolphin/gd/GDTexture.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_TEXTURE_H
#define _DOLPHIN_GD_TEXTURE_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDTexture.h>
+#else
#include <dolphin/types.h>
#include <dolphin/gx/GXEnum.h>
@@ -125,3 +128,4 @@ void GDLoadTlutRaw(u32 tlut_ptr_raw, u32 tmem_addr, GXTlutSize size);
#endif
#endif
+#endif
diff --git a/include/dolphin/gd/GDTransform.h b/include/dolphin/gd/GDTransform.h
index 8d0159fdb0..e3699519f9 100644
--- a/include/dolphin/gd/GDTransform.h
+++ b/include/dolphin/gd/GDTransform.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GD_TRANSFORM_H_
#define _DOLPHIN_GD_TRANSFORM_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gd/GDTransform.h>
+#else
#include <dolphin/types.h>
#include <dolphin/gx/GXEnum.h>
#include <dolphin/mtx.h>
@@ -54,3 +57,4 @@ void GDSetProjection(const Mtx44 mtx, GXProjectionType type);
#endif
#endif
+#endif
diff --git a/include/dolphin/gf.h b/include/dolphin/gf.h
index 50676aeab8..31a7fd5910 100644
--- a/include/dolphin/gf.h
+++ b/include/dolphin/gf.h
@@ -1,9 +1,13 @@
#ifndef _DOLPHIN_GF_H_
#define _DOLPHIN_GF_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gf.h>
+#else
#include <dolphin/gf/GFGeometry.h>
#include <dolphin/gf/GFLight.h>
#include <dolphin/gf/GFPixel.h>
#include <dolphin/gf/GFTev.h>
#endif
+#endif
diff --git a/include/dolphin/gf/GFGeometry.h b/include/dolphin/gf/GFGeometry.h
index 759d18c355..4d6c885807 100644
--- a/include/dolphin/gf/GFGeometry.h
+++ b/include/dolphin/gf/GFGeometry.h
@@ -1,6 +1,9 @@
-#ifndef GFGEOMETRY_H
-#define GFGEOMETRY_H
+#ifndef _DOLPHIN_GF_GFGEOMETRY_H_
+#define _DOLPHIN_GF_GFGEOMETRY_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gf/GFGeometry.h>
+#else
#include <dolphin/gx.h>
#define GF_GEN_MODE(nTexGens, nChans, nTevs, cm, nInds) \
@@ -38,4 +41,5 @@ static inline void GFWriteXFCmd(u16 addr, u32 val) {
void GFSetGenMode2(u8 nTexGens, u8 nChans, u8 nTevs, u8 nInds, GXCullMode cm);
-#endif /* GFGEOMETRY_H */
+#endif
+#endif /* _DOLPHIN_GF_GFGEOMETRY_H_ */
diff --git a/include/dolphin/gf/GFLight.h b/include/dolphin/gf/GFLight.h
index 15d9644340..570f58e88e 100644
--- a/include/dolphin/gf/GFLight.h
+++ b/include/dolphin/gf/GFLight.h
@@ -1,8 +1,12 @@
-#ifndef GFLIGHT_H
-#define GFLIGHT_H
+#ifndef _DOLPHIN_GF_GFLIGHT_H
+#define _DOLPHIN_GF_GFLIGHT_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gf/GFLight.h>
+#else
#include <dolphin/gx.h>
void GFSetChanAmbColor(GXChannelID chan, GXColor color);
-#endif /* GFLIGHT_H */
+#endif
+#endif /* _DOLPHIN_GF_GFLIGHT_H */
diff --git a/include/dolphin/gf/GFPixel.h b/include/dolphin/gf/GFPixel.h
index 9260dcf348..a200b776f1 100644
--- a/include/dolphin/gf/GFPixel.h
+++ b/include/dolphin/gf/GFPixel.h
@@ -1,6 +1,9 @@
-#ifndef GFPIXEL_H
-#define GFPIXEL_H
+#ifndef _DOLPHIN_GF_GFPIXEL_H
+#define _DOLPHIN_GF_GFPIXEL_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gf/GFPixel.h>
+#else
#include <dolphin/gx.h>
void GFSetFog(GXFogType type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor color);
@@ -10,4 +13,5 @@ void GFSetBlendModeEtc(GXBlendMode type, GXBlendFactor src_factor,
u8 dither_enable);
void GFSetZMode(u8 compare_enable, GXCompare func, u8 update_enable);
-#endif /* GFPIXEL_H */
+#endif
+#endif /* _DOLPHIN_GF_GFPIXEL_H */
diff --git a/include/dolphin/gf/GFTev.h b/include/dolphin/gf/GFTev.h
index 49921795e8..2a20479e70 100644
--- a/include/dolphin/gf/GFTev.h
+++ b/include/dolphin/gf/GFTev.h
@@ -1,8 +1,12 @@
-#ifndef GFTEV_H
-#define GFTEV_H
+#ifndef _DOLPHIN_GF_GFTEV_H
+#define _DOLPHIN_GF_GFTEV_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gf/GFTev.h>
+#else
#include <dolphin/gx.h>
void GFSetTevColorS10(GXTevRegID reg, GXColorS10 color);
-#endif /* GFTEV_H */
+#endif
+#endif /* _DOLPHIN_GF_GFTEV_H */
diff --git a/include/dolphin/gx.h b/include/dolphin/gx.h
index 0e90e543e1..100fe8a8d9 100644
--- a/include/dolphin/gx.h
+++ b/include/dolphin/gx.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_H_
#define _DOLPHIN_GX_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx.h>
+#else
#include <dolphin/gx/GXStruct.h>
#include <dolphin/gx/GXTransform.h>
#include <dolphin/gx/GXTev.h>
@@ -38,3 +41,4 @@ void GXSetDrawSync(u16 token);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXBump.h b/include/dolphin/gx/GXBump.h
index 2a24dc69f8..61118c0876 100644
--- a/include/dolphin/gx/GXBump.h
+++ b/include/dolphin/gx/GXBump.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXBUMP_H_
#define _DOLPHIN_GX_GXBUMP_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXBump.h>
+#else
#include <dolphin/gx/GXEnum.h>
#ifdef __cplusplus
@@ -27,3 +30,4 @@ void __GXSetIndirectMask(u32 mask);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXCommandList.h b/include/dolphin/gx/GXCommandList.h
index 9adae3cb79..e89037e774 100644
--- a/include/dolphin/gx/GXCommandList.h
+++ b/include/dolphin/gx/GXCommandList.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXCOMMANDLIST_H_
#define _DOLPHIN_GX_GXCOMMANDLIST_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXCommandList.h>
+#else
#include <dolphin/types.h>
#define GX_NOP 0x00
@@ -35,3 +38,4 @@ extern u8 GXTexImage3Ids[8];
extern u8 GXTexTlutIds[8];
#endif
+#endif
diff --git a/include/dolphin/gx/GXCpu2Efb.h b/include/dolphin/gx/GXCpu2Efb.h
index 46aa3e3369..32263310b9 100644
--- a/include/dolphin/gx/GXCpu2Efb.h
+++ b/include/dolphin/gx/GXCpu2Efb.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXCPU2EFB_H_
#define _DOLPHIN_GX_GXCPU2EFB_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXCpu2Efb.h>
+#else
#include <dolphin/gx/GXEnum.h>
#ifdef __cplusplus
@@ -27,3 +30,4 @@ u32 GXDecompressZ16(u32 z16, GXZFmt16 zfmt);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXCull.h b/include/dolphin/gx/GXCull.h
index cac4381812..14a3fcbfd3 100644
--- a/include/dolphin/gx/GXCull.h
+++ b/include/dolphin/gx/GXCull.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXCULL_H_
#define _DOLPHIN_GX_GXCULL_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXCull.h>
+#else
#include <dolphin/gx/GXEnum.h>
#ifdef __cplusplus
@@ -16,3 +19,4 @@ void GXSetCoPlanar(GXBool enable);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXDispList.h b/include/dolphin/gx/GXDispList.h
index 357fb8f7e0..fb6fd3d400 100644
--- a/include/dolphin/gx/GXDispList.h
+++ b/include/dolphin/gx/GXDispList.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXDISPLIST_H_
#define _DOLPHIN_GX_GXDISPLIST_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXDispList.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -16,3 +19,4 @@ void GXCallDisplayList(void* list, u32 nbytes);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXDraw.h b/include/dolphin/gx/GXDraw.h
index c8e779345a..75e58d7408 100644
--- a/include/dolphin/gx/GXDraw.h
+++ b/include/dolphin/gx/GXDraw.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXDRAW_H_
#define _DOLPHIN_GX_GXDRAW_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXDraw.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -22,3 +25,4 @@ u32 GXGenNormalTable(u8 depth, f32* table);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXEnum.h b/include/dolphin/gx/GXEnum.h
index cd84f22399..49f97ace7b 100644
--- a/include/dolphin/gx/GXEnum.h
+++ b/include/dolphin/gx/GXEnum.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXENUM_H_
#define _DOLPHIN_GX_GXENUM_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXEnum.h>
+#else
#include <dolphin/types.h>
typedef u8 GXBool;
@@ -922,3 +925,4 @@ typedef enum _GXCPRegs {
} GXCPRegs;
#endif
+#endif
diff --git a/include/dolphin/gx/GXFifo.h b/include/dolphin/gx/GXFifo.h
index 069f36a4ea..8dbc020363 100644
--- a/include/dolphin/gx/GXFifo.h
+++ b/include/dolphin/gx/GXFifo.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXFIFO_H_
#define _DOLPHIN_GX_GXFIFO_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXFifo.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/os/OSThread.h>
@@ -44,3 +47,4 @@ void GXRestoreWriteGatherPipe(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXFrameBuffer.h b/include/dolphin/gx/GXFrameBuffer.h
index 73b513fa32..99b1af436f 100644
--- a/include/dolphin/gx/GXFrameBuffer.h
+++ b/include/dolphin/gx/GXFrameBuffer.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXFRAMEBUFFER_H_
#define _DOLPHIN_GX_GXFRAMEBUFFER_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXFrameBuffer.h>
+#else
#include <dolphin/gx/GXStruct.h>
#include <dolphin/gx/GXEnum.h>
@@ -64,3 +67,4 @@ f32 GXGetYScaleFactor(u16 efbHeight, u16 xfbHeight);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXGeometry.h b/include/dolphin/gx/GXGeometry.h
index c12a6f1b46..f2e9965ad0 100644
--- a/include/dolphin/gx/GXGeometry.h
+++ b/include/dolphin/gx/GXGeometry.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXGEOMETRY_H_
#define _DOLPHIN_GX_GXGEOMETRY_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXGeometry.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -45,3 +48,4 @@ void GXEnableTexOffsets(GXTexCoordID coord, u8 line_enable, u8 point_enable);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXGet.h b/include/dolphin/gx/GXGet.h
index d1ba630a46..553201d51f 100644
--- a/include/dolphin/gx/GXGet.h
+++ b/include/dolphin/gx/GXGet.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXGET_H_
#define _DOLPHIN_GX_GXGET_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXGet.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -62,3 +65,4 @@ void GXGetScissor(u32* left, u32* top, u32* wd, u32* ht);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXLighting.h b/include/dolphin/gx/GXLighting.h
index 83c5aae423..fb1af06882 100644
--- a/include/dolphin/gx/GXLighting.h
+++ b/include/dolphin/gx/GXLighting.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXLIGHTING_H_
#define _DOLPHIN_GX_GXLIGHTING_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXLighting.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -30,3 +33,4 @@ void GXSetChanCtrl(GXChannelID chan, GXBool enable, GXColorSrc amb_src, GXColorS
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXManage.h b/include/dolphin/gx/GXManage.h
index fd899d3619..2a5784b84a 100644
--- a/include/dolphin/gx/GXManage.h
+++ b/include/dolphin/gx/GXManage.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXMANAGE_H_
#define _DOLPHIN_GX_GXMANAGE_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXManage.h>
+#else
#include <dolphin/gx/GXFifo.h>
#ifdef __cplusplus
@@ -34,3 +37,4 @@ GXDrawDoneCallback GXSetDrawDoneCallback(GXDrawDoneCallback cb);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXPerf.h b/include/dolphin/gx/GXPerf.h
index bd1b474aa8..f579e4201a 100644
--- a/include/dolphin/gx/GXPerf.h
+++ b/include/dolphin/gx/GXPerf.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXPERF_H_
#define _DOLPHIN_GX_GXPERF_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXPerf.h>
+#else
#include <dolphin/gx/GXEnum.h>
#ifdef __cplusplus
@@ -28,3 +31,4 @@ u32 GXReadClksPerVtx(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXPixel.h b/include/dolphin/gx/GXPixel.h
index d61838d1a9..ed3e245db5 100644
--- a/include/dolphin/gx/GXPixel.h
+++ b/include/dolphin/gx/GXPixel.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXPIXEL_H_
#define _DOLPHIN_GX_GXPIXEL_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXPixel.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -28,3 +31,4 @@ void GXSetFogColor(GXColor color);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXStruct.h b/include/dolphin/gx/GXStruct.h
index 0e7dc0be69..faba188d24 100644
--- a/include/dolphin/gx/GXStruct.h
+++ b/include/dolphin/gx/GXStruct.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXSTRUCT_H_
#define _DOLPHIN_GX_GXSTRUCT_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXStruct.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/vi/vitypes.h>
@@ -73,3 +76,4 @@ typedef struct _GXVtxAttrFmtList {
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXTev.h b/include/dolphin/gx/GXTev.h
index 8deb22d083..a804fd0ccd 100644
--- a/include/dolphin/gx/GXTev.h
+++ b/include/dolphin/gx/GXTev.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXTEV_H_
#define _DOLPHIN_GX_GXTEV_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXTev.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -31,3 +34,4 @@ void GXSetNumTevStages(u8 nStages);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXTexture.h b/include/dolphin/gx/GXTexture.h
index f42dc2295a..e84dcffe47 100644
--- a/include/dolphin/gx/GXTexture.h
+++ b/include/dolphin/gx/GXTexture.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXTEXTURE_H_
#define _DOLPHIN_GX_GXTEXTURE_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXTexture.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -50,3 +53,4 @@ void GXInitTexObjMaxAniso(GXTexObj* obj, GXAnisotropy max_aniso);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXTransform.h b/include/dolphin/gx/GXTransform.h
index 1e7f94e579..f433f65f44 100644
--- a/include/dolphin/gx/GXTransform.h
+++ b/include/dolphin/gx/GXTransform.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXTRANSFORM_H_
#define _DOLPHIN_GX_GXTRANSFORM_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXTransform.h>
+#else
#include <dolphin/gx/GXEnum.h>
#ifdef __cplusplus
@@ -30,5 +33,5 @@ void GXSetZScaleOffset(f32 scale, f32 offset);
#ifdef __cplusplus
}
#endif
-
+#endif
#endif
diff --git a/include/dolphin/gx/GXVerify.h b/include/dolphin/gx/GXVerify.h
index 93a1b29e58..b1a299e0da 100644
--- a/include/dolphin/gx/GXVerify.h
+++ b/include/dolphin/gx/GXVerify.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXVERIFY_H_
#define _DOLPHIN_GX_GXVERIFY_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXVerify.h>
+#else
#include <dolphin/gx/GXEnum.h>
#include <dolphin/gx/GXStruct.h>
@@ -27,3 +30,4 @@ void __GXVerifyVATImm(GXAttr attr, GXCompCnt cnt, GXCompType type, u8 frac);
#endif
#endif
+#endif
diff --git a/include/dolphin/gx/GXVert.h b/include/dolphin/gx/GXVert.h
index 91b7d7cc0b..c508e164bb 100644
--- a/include/dolphin/gx/GXVert.h
+++ b/include/dolphin/gx/GXVert.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_GX_GXVERT_H_
#define _DOLPHIN_GX_GXVERT_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/gx/GXVert.h>
+#else
#include <dolphin/types.h>
#include <dolphin/os.h>
@@ -138,3 +141,4 @@ FUNC_1PARAM(GXMatrixIndex, u8)
#endif
#endif
+#endif
diff --git a/include/dolphin/mix.h b/include/dolphin/mix.h
index f58b3d63dc..aa9a22b1dd 100644
--- a/include/dolphin/mix.h
+++ b/include/dolphin/mix.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_MIX_H_
#define _DOLPHIN_MIX_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/mix.h>
+#else
#include <dolphin/types.h>
#include <dolphin/ax.h>
@@ -92,4 +95,5 @@ void MIXUpdateSettings(void);
}
#endif
+#endif
#endif // _DOLPHIN_MIX_H_
diff --git a/include/dolphin/mtx.h b/include/dolphin/mtx.h
index 4d20a6cc4d..c818376fa3 100644
--- a/include/dolphin/mtx.h
+++ b/include/dolphin/mtx.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_MTX_H_
#define _DOLPHIN_MTX_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/mtx.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -381,3 +384,4 @@ void C_QUATCompA(const Quaternion* qprev, const Quaternion* q, const Quaternion*
#endif
#endif
+#endif
diff --git a/include/dolphin/os.h b/include/dolphin/os.h
index c38031b324..e3034658d3 100644
--- a/include/dolphin/os.h
+++ b/include/dolphin/os.h
@@ -3,6 +3,9 @@
#include <stdio.h>
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os.h>
+#else
#include <dolphin/types.h>
#include <dolphin/gx/GXStruct.h>
void OSReportInit(void);
@@ -351,3 +354,4 @@ static inline void OSInitFastCast(void) {
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSAlarm.h b/include/dolphin/os/OSAlarm.h
index 3105039181..43e4822142 100644
--- a/include/dolphin/os/OSAlarm.h
+++ b/include/dolphin/os/OSAlarm.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSALARM_H_
#define _DOLPHIN_OSALARM_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSAlarm.h>
+#else
#include <dolphin/os.h>
#ifdef __cplusplus
@@ -33,4 +36,5 @@ void OSCancelAlarms(u32 tag);
}
#endif
+#endif
#endif // _DOLPHIN_OSALARM_H_
diff --git a/include/dolphin/os/OSAlloc.h b/include/dolphin/os/OSAlloc.h
index 77eb88661f..426b6ae439 100644
--- a/include/dolphin/os/OSAlloc.h
+++ b/include/dolphin/os/OSAlloc.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSALLOC_H_
#define _DOLPHIN_OSALLOC_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSAlloc.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -32,3 +35,4 @@ void OSVisitAllocated(void (*visitor)(void*, u32));
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSCache.h b/include/dolphin/os/OSCache.h
index 89e7ce96ba..2b4bbfd07e 100644
--- a/include/dolphin/os/OSCache.h
+++ b/include/dolphin/os/OSCache.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSCACHE_H_
#define _DOLPHIN_OSCACHE_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSCache.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -36,3 +39,4 @@ void __OSCacheInit(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSContext.h b/include/dolphin/os/OSContext.h
index cbb0b92e4e..900baf40af 100644
--- a/include/dolphin/os/OSContext.h
+++ b/include/dolphin/os/OSContext.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSCONTEXT_H_
#define _DOLPHIN_OSCONTEXT_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSContext.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -171,3 +174,4 @@ void OSFillFPUContext(OSContext* context);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSDC.h b/include/dolphin/os/OSDC.h
index bab2d68edc..995c1630cc 100644
--- a/include/dolphin/os/OSDC.h
+++ b/include/dolphin/os/OSDC.h
@@ -1,6 +1,10 @@
#ifndef _DOLPHIN_OSDC_H_
#define _DOLPHIN_OSDC_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSDC.h>
+#else
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -21,3 +25,4 @@ void DCBlockInvalidate(void* addr);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSError.h b/include/dolphin/os/OSError.h
index 4a2fc7bd71..aeeaede148 100644
--- a/include/dolphin/os/OSError.h
+++ b/include/dolphin/os/OSError.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSERROR_H_
#define _DOLPHIN_OSERROR_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSError.h>
+#else
#include <dolphin/os/OSContext.h>
#ifdef __cplusplus
@@ -36,3 +39,4 @@ extern OSErrorHandler __OSErrorTable[17];
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSException.h b/include/dolphin/os/OSException.h
index e9a2f22569..0b909ca202 100644
--- a/include/dolphin/os/OSException.h
+++ b/include/dolphin/os/OSException.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSEXCEPTION_H_
#define _DOLPHIN_OSEXCEPTION_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSException.h>
+#else
#include <dolphin/os/OSContext.h>
#include <dolphin/types.h>
@@ -58,4 +61,5 @@ __OSExceptionHandler __OSGetExceptionHandler(__OSException exception);
}
#endif
+#endif
#endif // _DOLPHIN_OSEXCEPTION_H_
diff --git a/include/dolphin/os/OSExec.h b/include/dolphin/os/OSExec.h
index af0dc4da0c..7fd5380b70 100644
--- a/include/dolphin/os/OSExec.h
+++ b/include/dolphin/os/OSExec.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSEXEC_H_
#define _DOLPHIN_OSEXEC_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSExec.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -33,3 +36,4 @@ void OSExecl(const char* dolfile, const char* arg0, ...);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSFont.h b/include/dolphin/os/OSFont.h
index 1fff41a629..1c1d480ab4 100644
--- a/include/dolphin/os/OSFont.h
+++ b/include/dolphin/os/OSFont.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSFONT_H_
#define _DOLPHIN_OSFONT_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSFont.h>
+#else
#include <dolphin/types.h>
#include <dolphin/os/OSUtf.h>
@@ -56,3 +59,4 @@ int OSSetFontWidth(int fixed);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSIC.h b/include/dolphin/os/OSIC.h
index 3309d3a6f1..20156e6874 100644
--- a/include/dolphin/os/OSIC.h
+++ b/include/dolphin/os/OSIC.h
@@ -1,6 +1,10 @@
#ifndef _DOLPHIN_OSIC_H_
#define _DOLPHIN_OSIC_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSIC.h>
+#else
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -18,3 +22,4 @@ void ICSync(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSInterrupt.h b/include/dolphin/os/OSInterrupt.h
index fb74135a2b..37e4f96958 100644
--- a/include/dolphin/os/OSInterrupt.h
+++ b/include/dolphin/os/OSInterrupt.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSINTERRUPT_H_
#define _DOLPHIN_OSINTERRUPT_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSInterrupt.h>
+#else
#include <dolphin/types.h>
#include <dolphin/os/OSException.h>
@@ -116,3 +119,4 @@ OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSL2.h b/include/dolphin/os/OSL2.h
index 01b4a620c0..0622de06dd 100644
--- a/include/dolphin/os/OSL2.h
+++ b/include/dolphin/os/OSL2.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSL2_H_
#define _DOLPHIN_OSL2_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSL2.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -18,3 +21,4 @@ void L2SetWriteThrough(BOOL writeThrough);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSLC.h b/include/dolphin/os/OSLC.h
index af49708b14..c266b20e7b 100644
--- a/include/dolphin/os/OSLC.h
+++ b/include/dolphin/os/OSLC.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSLC_H_
#define _DOLPHIN_OSLC_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSLC.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -17,3 +20,4 @@ void LCAllocNoInvalidate(void *addr, u32 nBytes);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSMemory.h b/include/dolphin/os/OSMemory.h
index a5debebc90..b1eaaf498c 100644
--- a/include/dolphin/os/OSMemory.h
+++ b/include/dolphin/os/OSMemory.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSMEMORY_H_
#define _DOLPHIN_OSMEMORY_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSMemory.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -26,3 +29,4 @@ u32 OSGetConsoleSimulatedMemSize(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSMessage.h b/include/dolphin/os/OSMessage.h
index 8cdd3f1b02..0660be565d 100644
--- a/include/dolphin/os/OSMessage.h
+++ b/include/dolphin/os/OSMessage.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSMESSAGE_H_
#define _DOLPHIN_OSMESSAGE_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSMessage.h>
+#else
#include <dolphin/os/OSThread.h>
#ifdef __cplusplus
@@ -30,4 +33,5 @@ int OSJamMessage(OSMessageQueue* mq, void* msg, s32 flags);
}
#endif
+#endif
#endif // _DOLPHIN_OSMESSAGE_H_
diff --git a/include/dolphin/os/OSModule.h b/include/dolphin/os/OSModule.h
index 6e66e9b003..d104cf7a18 100644
--- a/include/dolphin/os/OSModule.h
+++ b/include/dolphin/os/OSModule.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSMODULE_H_
#define _DOLPHIN_OSMODULE_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSModule.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -115,3 +118,4 @@ void OSNotifyUnlink(OSModuleInfo* module);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSMutex.h b/include/dolphin/os/OSMutex.h
index ef5565eb67..58985f7a3c 100644
--- a/include/dolphin/os/OSMutex.h
+++ b/include/dolphin/os/OSMutex.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSMUTEX_H_
#define _DOLPHIN_OSMUTEX_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSMutex.h>
+#else
#include <dolphin/os/OSThread.h>
#ifdef __cplusplus
@@ -31,3 +34,4 @@ void OSSignalCond(OSCond* cond);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSReboot.h b/include/dolphin/os/OSReboot.h
index 6509534793..517851aa34 100644
--- a/include/dolphin/os/OSReboot.h
+++ b/include/dolphin/os/OSReboot.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSREBOOT_H_
#define _DOLPHIN_OSREBOOT_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSReboot.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -17,3 +20,4 @@ void __OSReboot(u32 resetCode, u32 bootDol);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSReset.h b/include/dolphin/os/OSReset.h
index 15c2ba62ff..221861a4a6 100644
--- a/include/dolphin/os/OSReset.h
+++ b/include/dolphin/os/OSReset.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSRESET_H_
#define _DOLPHIN_OSRESET_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSReset.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -37,3 +40,4 @@ u32 OSSetBootDol(u32 dolOffset);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSResetSW.h b/include/dolphin/os/OSResetSW.h
index 3c630b8573..88a7f194f4 100644
--- a/include/dolphin/os/OSResetSW.h
+++ b/include/dolphin/os/OSResetSW.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSRESETSW_H_
#define _DOLPHIN_OSRESETSW_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSResetSW.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -18,3 +21,4 @@ BOOL OSGetResetButtonState(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSRtc.h b/include/dolphin/os/OSRtc.h
index 583043f4a4..e35525dae9 100644
--- a/include/dolphin/os/OSRtc.h
+++ b/include/dolphin/os/OSRtc.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSRTC_H_
#define _DOLPHIN_OSRTC_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSRtc.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -81,4 +84,5 @@ void OSSetWirelessID(s32 chan, u16 id);
}
#endif
+#endif
#endif // _DOLPHIN_OSRTC_H_
diff --git a/include/dolphin/os/OSSemaphore.h b/include/dolphin/os/OSSemaphore.h
index aac23811a8..93b942f9e1 100644
--- a/include/dolphin/os/OSSemaphore.h
+++ b/include/dolphin/os/OSSemaphore.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSSEMAPHORE_H_
#define _DOLPHIN_OSSEMAPHORE_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSSemaphore.h>
+#else
#include <dolphin/os/OSThread.h>
#ifdef __cplusplus
@@ -22,4 +25,5 @@ s32 OSGetSemaphoreCount(OSSemaphore* sem);
}
#endif
+#endif
#endif // _DOLPHIN_OSSEMAPHORE_H_
diff --git a/include/dolphin/os/OSSerial.h b/include/dolphin/os/OSSerial.h
index 7c38395f71..c6dd0a59e4 100644
--- a/include/dolphin/os/OSSerial.h
+++ b/include/dolphin/os/OSSerial.h
@@ -1,6 +1,10 @@
#ifndef _DOLPHIN_OSSERIAL_H
#define _DOLPHIN_OSSERIAL_H
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSSerial.h>
+#else
#include <dolphin/hw_regs.h>
+#endif
#endif // _DOLPHIN_OSSERIAL_H
diff --git a/include/dolphin/os/OSThread.h b/include/dolphin/os/OSThread.h
index 5511c7595b..c113575983 100644
--- a/include/dolphin/os/OSThread.h
+++ b/include/dolphin/os/OSThread.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSTHREAD_H_
#define _DOLPHIN_OSTHREAD_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSThread.h>
+#else
#include <dolphin/os/OSContext.h>
#ifdef __cplusplus
@@ -110,3 +113,4 @@ OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback callback
#endif
#endif
+#endif
diff --git a/include/dolphin/os/OSTime.h b/include/dolphin/os/OSTime.h
index 118adee7c2..b6e9fd7b8c 100644
--- a/include/dolphin/os/OSTime.h
+++ b/include/dolphin/os/OSTime.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSTIME_H_
#define _DOLPHIN_OSTIME_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSTime.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -41,4 +44,5 @@ extern "C" {
}
#endif
+#endif
#endif // _DOLPHIN_OSTIME_H_
diff --git a/include/dolphin/os/OSTimer.h b/include/dolphin/os/OSTimer.h
index 490cccb67c..caa4076ffe 100644
--- a/include/dolphin/os/OSTimer.h
+++ b/include/dolphin/os/OSTimer.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSTIMER_H_
#define _DOLPHIN_OSTIMER_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSTimer.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -18,4 +21,5 @@ void OSStopTimer(void);
}
#endif
+#endif
#endif // _DOLPHIN_OSTIMER_H_
diff --git a/include/dolphin/os/OSUtf.h b/include/dolphin/os/OSUtf.h
index 2f721d5787..44c908ef0f 100644
--- a/include/dolphin/os/OSUtf.h
+++ b/include/dolphin/os/OSUtf.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_OSUTF_H_
#define _DOLPHIN_OSUTF_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/os/OSUtf.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -20,4 +23,5 @@ u32 OSSJIStoUTF32(u16 sjis);
}
#endif
+#endif
#endif // _DOLPHIN_OSUTF_H_
diff --git a/include/dolphin/pad.h b/include/dolphin/pad.h
index d966b80945..eb208d4287 100644
--- a/include/dolphin/pad.h
+++ b/include/dolphin/pad.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_PAD_H_
#define _DOLPHIN_PAD_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/pad.h>
+#else
#include <dolphin/types.h>
#ifdef __cplusplus
@@ -102,3 +105,4 @@ void PADClampCircle(PADStatus* status);
#endif
#endif
+#endif
diff --git a/include/dolphin/seq.h b/include/dolphin/seq.h
index 754798093d..8c950ca2a3 100644
--- a/include/dolphin/seq.h
+++ b/include/dolphin/seq.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_SEQ_H_
#define _DOLPHIN_SEQ_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/seq.h>
+#else
#include <dolphin/syn.h>
#ifdef __cplusplus
@@ -51,4 +54,5 @@ s32 SEQGetVolume(SEQSEQUENCE* sequence);
}
#endif
+#endif
#endif // _DOLPHIN_SEQ_H_
diff --git a/include/dolphin/si.h b/include/dolphin/si.h
index 04b01ba4d7..ed1b442ad8 100644
--- a/include/dolphin/si.h
+++ b/include/dolphin/si.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_SI_H_
#define _DOLPHIN_SI_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/si.h>
+#else
#include <dolphin/os.h>
#ifdef __cplusplus
@@ -172,4 +175,5 @@ void SIControlSteering(s32 chan, u32 control, s32 level);
}
#endif
+#endif
#endif // _DOLPHIN_SI_H_
diff --git a/include/dolphin/sp.h b/include/dolphin/sp.h
index 52f4fff020..4401b8c9fc 100644
--- a/include/dolphin/sp.h
+++ b/include/dolphin/sp.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_SP_H_
#define _DOLPHIN_SP_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/sp.h>
+#else
#include <dolphin/types.h>
#include <dolphin/ax.h>
@@ -38,3 +41,4 @@ void SPPrepareEnd(SPSoundEntry* sound, AXVPB* axvpb);
#endif
#endif
+#endif
diff --git a/include/dolphin/syn.h b/include/dolphin/syn.h
index 8373c5db91..0b8848f9d4 100644
--- a/include/dolphin/syn.h
+++ b/include/dolphin/syn.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_SYN_H_
#define _DOLPHIN_SYN_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/syn.h>
+#else
#include <dolphin/types.h>
#include <dolphin/ax.h>
@@ -169,4 +172,5 @@ u8 SYNGetMidiController(SYNSYNTH* synth, u8 midiChannel, u8 function);
}
#endif
+#endif
#endif // _DOLPHIN_SYN_H_
diff --git a/include/dolphin/types.h b/include/dolphin/types.h
index 9d061526b5..a44be3988c 100644
--- a/include/dolphin/types.h
+++ b/include/dolphin/types.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_TYPES_H_
#define _DOLPHIN_TYPES_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/types.h>
+#else
typedef signed char s8;
typedef unsigned char u8;
typedef signed short int s16;
@@ -56,3 +59,4 @@ typedef unsigned int uint;
#include "stddef.h"
#endif
+#endif
diff --git a/include/dolphin/vi.h b/include/dolphin/vi.h
index af41844266..b8fa79160e 100644
--- a/include/dolphin/vi.h
+++ b/include/dolphin/vi.h
@@ -1,7 +1,11 @@
#ifndef _DOLPHIN_VI_H_
#define _DOLPHIN_VI_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/vi.h>
+#else
#include <dolphin/vi/vifuncs.h>
#include <dolphin/vi/vitypes.h>
#endif
+#endif
diff --git a/include/dolphin/vi/vifuncs.h b/include/dolphin/vi/vifuncs.h
index eb95984ede..b05611a427 100644
--- a/include/dolphin/vi/vifuncs.h
+++ b/include/dolphin/vi/vifuncs.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_VIFUNCS_H_
#define _DOLPHIN_VIFUNCS_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/vi/vifuncs.h>
+#else
#include <dolphin/types.h>
#include <dolphin/vi/vitypes.h>
#include <dolphin/gx/GXStruct.h>
@@ -34,3 +37,4 @@ u32 VIGetDTVStatus(void);
#endif
#endif
+#endif
diff --git a/include/dolphin/vi/vitypes.h b/include/dolphin/vi/vitypes.h
index 983a89b7ea..998082d3c9 100644
--- a/include/dolphin/vi/vitypes.h
+++ b/include/dolphin/vi/vitypes.h
@@ -1,6 +1,9 @@
#ifndef _DOLPHIN_VITYPES_H_
#define _DOLPHIN_VITYPES_H_
+#ifdef __REVOLUTION_SDK__
+#include <revolution/vi/vitypes.h>
+#else
#include <dolphin/types.h>
#define VI_TVMODE(format, interlace) (((format) << 2) + (interlace))
@@ -39,3 +42,4 @@ typedef enum {
typedef void (*VIRetraceCallback)(u32 retraceCount);
#endif
+#endif
diff --git a/include/f_ap/f_ap_game.h b/include/f_ap/f_ap_game.h
index f7cf3d6ca7..b5cc371d80 100644
--- a/include/f_ap/f_ap_game.h
+++ b/include/f_ap/f_ap_game.h
@@ -2,41 +2,106 @@
#define F_AP_F_AP_GAME_H
#include "JSystem/JUtility/TColor.h"
+#include "JSystem/JHostIO/JORReflexible.h"
+#include "JSystem/JFramework/JFWDisplay.h"
+#include "JSystem/JUtility/JUTAssert.h"
+#include <string.h>
void fapGm_After();
void fapGm_Create();
void fapGm_Execute();
-class fapGm_HIO_c {
+struct CaptureScreen {
+ CaptureScreen(const JFWDisplay* i_display) {
+ field_0x0 = i_display;
+ field_0x4 = 0;
+ }
+
+ /* 0x0 */ const JFWDisplay* field_0x0;
+ /* 0x4 */ int field_0x4;
+};
+
+class fapGm_HIO_c : public JORReflexible {
public:
/* 80018944 */ fapGm_HIO_c();
+
+ #if DEBUG
+ virtual void listenPropertyEvent(const JORPropertyEvent*);
+ virtual void genMessage(JORMContext*);
+ #endif
/* 80018AE0 */ virtual ~fapGm_HIO_c();
+ #if DEBUG
+ static void startCpuTimer();
+ static void stopCpuTimer(const char*);
+ static void printCpuTimer(const char*);
+ static void executeCaptureScreen();
+
+ static void createCaptureScreen() {
+ mCaptureScreen = new CaptureScreen(JFWDisplay::getManager());
+ JUT_ASSERT(46, mCaptureScreen != NULL);
+ }
+
+ static void onCpuTimer() {
+ m_CpuTimerOn = TRUE;
+ }
+
+ static void offCpuTimer() {
+ m_CpuTimerOff = FALSE;
+ }
+ #endif
+
+ #if DEBUG
+ static u8 m_CpuTimerOn;
+ static u8 m_CpuTimerOff;
+ static u8 m_CpuTimerStart;
+ static u32 m_CpuTimerTick;
+
+ static CaptureScreen* mCaptureScreen;
+ static void* mCaptureScreenBuffer;
+ static s16 mCaptureScreenFlag;
+ static u16 mCaptureScreenWidth;
+ static u16 mCaptureScreenHeight;
+ static u16 mCaptureScreenLinePf;
+ static u16 mCaptureScreenLineNum;
+ static u8 mCaptureScreenNumH;
+ static u8 mCaptureScreenNumV;
+
+ static u8 mParticle254Fix;
+ #endif
+
/* 0x04 */ s8 field_0x04;
/* 0x05 */ u8 field_0x03[3];
/* 0x08 */ JUtility::TColor mColor;
/* 0x0C */ f32 mLROnValue;
/* 0x10 */ f32 mLROffValue;
- /* 0x14 */ bool mUsingHostIO;
+ /* 0x14 */ u8 mUsingHostIO;
/* 0x15 */ u8 mDisplayMeter;
/* 0x16 */ u8 mDisplayPrint;
- /* 0x17 */ bool mDisplay2D;
- /* 0x18 */ bool mDisplayParticle;
- /* 0x19 */ bool mDisplayProcessID;
- /* 0x1A */ bool mMemBlockOff;
+ /* 0x17 */ u8 mDisplay2D;
+ /* 0x18 */ u8 mDisplayParticle;
+ /* 0x19 */ u8 mDisplayProcessID;
+ #if DEBUG
+ /* 0x1A */ u8 mTrapFilter;
+ /* 0x1B */ u8 mGammaCorrection;
+ #endif
+ /* 0x1A */ u8 mMemBlockOff;
/* 0x1C */ s16 mRegister0;
/* 0x1E */ s16 mRegister1;
/* 0x20 */ s16 mRegister2;
/* 0x22 */ s16 mRegister3;
+ #if DEBUG
+ /* 0x26 */ u8 field_0x26[2];
+ #endif
/* 0x24 */ JUtility::TColor mLetterTopColor;
/* 0x28 */ JUtility::TColor mLetterBottomColor;
/* 0x2C */ JUtility::TColor mLetterTopShadowColor;
/* 0x30 */ JUtility::TColor mLetterBottomShadowColor;
- /* 0x34 */ u16 mLetterPositionX;
- /* 0x36 */ u16 mLetterPositionY;
- /* 0x38 */ u16 mLineSpacing;
- /* 0x3A */ u16 mLetterSpacing;
- /* 0x3C */ u16 mLetterFontSize;
+ /* 0x34 */ s16 mLetterPositionX;
+ /* 0x36 */ s16 mLetterPositionY;
+ /* 0x38 */ s16 mLineSpacing;
+ /* 0x3A */ s16 mLetterSpacing;
+ /* 0x3C */ s16 mLetterFontSize;
/* 0x3E */ u8 mBackgroundAlpha;
}; // Size: 0x40
@@ -70,4 +135,58 @@ inline f32 fapGmHIO_getLROffValue() {
return g_HIO.mLROffValue;
}
+inline u8 fapGmHIO_getHostIO() {
+ return g_HIO.mUsingHostIO;
+}
+
+struct fapGm_dataMem {
+ enum HeapType_e {
+ HeapType_Error_e,
+ HeapType_ARAM_e,
+ HeapType_Root_e,
+ HeapType_System_e,
+ HeapType_Zelda_e,
+ HeapType_Archive_e,
+ HeapType_Game_e,
+ HeapType_Command_e,
+ HeapType_Stage_e,
+ HeapType_J2D_e,
+ HeapType_Dynamic_e,
+ };
+
+ enum TagAttribute_e {
+ TagAtt_Fixed_e,
+ TagAtt_Variable_e,
+ };
+
+ enum TagType_e {
+ TagType_Audio_e,
+ TagType_Particle_e,
+ TagType_System_e,
+ TagType_Unknown_e,
+ TagType_Message_e,
+ TagType_2D_e,
+ TagType_Player_e,
+ TagType_Archive_e,
+ TagType_ArchiveSub_e,
+ TagType_ArchiveStage_e,
+ TagType_ArchiveStageSub_e,
+ TagType_Program_e,
+ TagType_Object_e,
+ TagType_Stage_e,
+ TagType_Heap_e,
+ };
+
+ static void printfTag(int, int, int, const char*, void*, u32, const char*, const char*);
+ static int findParentHeap(void*);
+ static void dumpTag();
+ static void dumpCsv();
+
+ static int getCsvSize() { return strlen(mCsv); }
+ static char* getCsv() { return mCsv; }
+ static inline char* getCsvEnd() { return mCsv + strlen(mCsv); }
+
+ static char mCsv[0x8000];
+};
+
#endif /* F_AP_F_AP_GAME_H */
diff --git a/include/f_op/f_op_actor.h b/include/f_op/f_op_actor.h
index c995c9a366..8c567e5046 100644
--- a/include/f_op/f_op_actor.h
+++ b/include/f_op/f_op_actor.h
@@ -284,19 +284,39 @@ STATIC_ASSERT(sizeof(fopAc_ac_c) == 0x568);
class fopEn_enemy_c : public fopAc_ac_c {
public:
+ enum fopEn_flag {
+ fopEn_flag_Down = 0x1,
+ fopEn_flag_CutDownHit = 0x2,
+ fopEn_flag_WolfDownStart = 0x4,
+ fopEn_flag_Dead = 0x8,
+ fopEn_flag_WolfDownPull = 0x10,
+ fopEn_flag_WolfDownPullEnd = 0x20,
+ fopEn_flag_WolfBiteDamage = 0x40,
+ fopEn_flag_HeadLock = 0x80,
+
+ fopEn_flag_WolfNoLock = 0x200,
+ };
+
+ enum fopEn_throwMode {
+ fopEn_throwMode_Catch = 0x2,
+ fopEn_throwMode_Dash = 0x4,
+ fopEn_throwMode_ThrowLeft = 0x8,
+ fopEn_throwMode_ThrowRight = 0x10,
+ };
+
/* 80019404 */ BOOL initBallModel();
/* 800194FC */ bool checkBallModelDraw();
/* 80019520 */ void setBallModelEffect(dKy_tevstr_c*);
/* 800196A0 */ void drawBallModel(dKy_tevstr_c*);
- bool checkWolfNoLock() const { return mFlags & 0x200; }
- bool checkHeadLockFlg() const { return mFlags & 0x80; }
- bool checkWolfBiteDamage() const { return mFlags & 0x40; }
- bool checkWolfDownPullFlg() const { return mFlags & 0x10; }
- bool checkDownFlg() { return mFlags & 0x1; }
- bool checkCutDownHitFlg() const { return mFlags & 0x2; }
- bool checkWolfDownStartFlg() const { return mFlags & 0x4; }
- bool checkDeadFlg() const { return mFlags & 0x8; }
+ bool checkWolfNoLock() const { return mFlags & fopEn_flag_WolfNoLock; }
+ bool checkHeadLockFlg() const { return mFlags & fopEn_flag_HeadLock; }
+ bool checkWolfBiteDamage() const { return mFlags & fopEn_flag_WolfBiteDamage; }
+ bool checkWolfDownPullFlg() const { return mFlags & fopEn_flag_WolfDownPull; }
+ bool checkDownFlg() { return mFlags & fopEn_flag_Down; }
+ bool checkCutDownHitFlg() const { return mFlags & fopEn_flag_CutDownHit; }
+ bool checkWolfDownStartFlg() const { return mFlags & fopEn_flag_WolfDownStart; }
+ bool checkDeadFlg() const { return mFlags & fopEn_flag_Dead; }
bool checkThrowMode(u8 param_1) const { return mThrowMode & param_1; }
u32* getMidnaBindID(int i_idx) { return mMidnaBindID + i_idx; }
@@ -304,28 +324,28 @@ public:
cXyz& getDownPos() { return mDownPos; }
cXyz& getHeadLockPos() { return mHeadLockPos; }
- void onCutDownHitFlg() { mFlags |= 2; }
- void onWolfBiteDamage() { mFlags |= 0x40; }
- void onWolfDownStartFlg() { mFlags |= 0x14; }
- void onWolfDownPullEndFlg() { mFlags |= 0x20; }
- void onWolfNoLock() { mFlags |= 0x200; }
- void onDownFlg() { mFlags |= 1; }
- void onHeadLockFlg() { mFlags |= 0x80; }
-
- void offWolfBiteDamage() { mFlags &= ~0x40; }
- void offCutDownHitFlg() { mFlags &= ~0x2; }
- void offWolfDownPullFlg() { mFlags &= ~0x10; }
- void offDownFlg() { mFlags &= ~0x17; }
- void offWolfNoLock() { mFlags &= ~0x200; }
- void offHeadLockFlg() { mFlags &= ~0x80; }
+ void onCutDownHitFlg() { mFlags |= fopEn_flag_CutDownHit; }
+ void onWolfBiteDamage() { mFlags |= fopEn_flag_WolfBiteDamage; }
+ void onWolfDownStartFlg() { mFlags |= (fopEn_flag_WolfDownPull | fopEn_flag_WolfDownStart); }
+ void onWolfDownPullEndFlg() { mFlags |= fopEn_flag_WolfDownPullEnd; }
+ void onWolfNoLock() { mFlags |= fopEn_flag_WolfNoLock; }
+ void onDownFlg() { mFlags |= fopEn_flag_Down; }
+ void onHeadLockFlg() { mFlags |= fopEn_flag_HeadLock; }
+
+ void offWolfBiteDamage() { mFlags &= ~fopEn_flag_WolfBiteDamage; }
+ void offCutDownHitFlg() { mFlags &= ~fopEn_flag_CutDownHit; }
+ void offWolfDownPullFlg() { mFlags &= ~fopEn_flag_WolfDownPull; }
+ void offDownFlg() { mFlags &= ~(fopEn_flag_WolfDownPull | fopEn_flag_WolfDownStart | fopEn_flag_CutDownHit | fopEn_flag_Down); }
+ void offWolfNoLock() { mFlags &= ~fopEn_flag_WolfNoLock; }
+ void offHeadLockFlg() { mFlags &= ~fopEn_flag_HeadLock; }
void offThrowMode(u8 throwMode) { mThrowMode &= ~throwMode; }
void setMidnaBindMode(u8 i_bindMode) { mMidnaBindMode = i_bindMode; }
void setMidnaBindID(u8 i_idx, u32 i_bindID) { mMidnaBindID[i_idx] = i_bindID; }
- void setThrowModeCatch() { mThrowMode |= 2; }
- void setThrowModeDash() { mThrowMode |= 4; }
- void setThrowModeThrowRight() { mThrowMode |= 0x10; }
- void setThrowModeThrowLeft() { mThrowMode |= 8; }
+ void setThrowModeCatch() { mThrowMode |= fopEn_throwMode_Catch; }
+ void setThrowModeDash() { mThrowMode |= fopEn_throwMode_Dash; }
+ void setThrowModeThrowRight() { mThrowMode |= fopEn_throwMode_ThrowRight; }
+ void setThrowModeThrowLeft() { mThrowMode |= fopEn_throwMode_ThrowLeft; }
void setDownPos(const cXyz* i_pos) { mDownPos = *i_pos; }
void setHeadLockPos(const cXyz* i_pos) { mHeadLockPos = *i_pos; }
@@ -337,7 +357,7 @@ public:
/* 0x58C */ u8 field_0x58c;
/* 0x58D */ u8 mThrowMode;
/* 0x58E */ u16 mFlags;
- /* 0x590 */ f32 field_0x590;
+ /* 0x590 */ f32 mAnmFrame;
/* 0x594 */ u32 mEffectID1;
/* 0x598 */ u32 mEffectID2;
/* 0x59C */ u32 mMidnaBindID[3];
diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h
index 33c0f51300..545d650dc7 100644
--- a/include/f_op/f_op_actor_mng.h
+++ b/include/f_op/f_op_actor_mng.h
@@ -12,7 +12,7 @@
#include "f_pc/f_pc_manager.h"
#include "m_Do/m_Do_hostIO.h"
-#define fopAcM_SetupActor(ptr, ClassName) \
+#define fopAcM_ct(ptr, ClassName) \
if (!fopAcM_CheckCondition(ptr, fopAcCnd_INIT_e)) { \
new (ptr) ClassName(); \
fopAcM_OnCondition(ptr, fopAcCnd_INIT_e); \
@@ -693,7 +693,7 @@ s32 fopAcM_riverStream(cXyz*, s16*, f32*, f32);
s32 fopAcM_carryOffRevise(fopAc_ac_c*);
void fopAcM_setEffectMtx(const fopAc_ac_c*, const J3DModelData*);
-static const char* fopAcM_getProcNameString(const fopAc_ac_c* i_actor);
+const char* fopAcM_getProcNameString(const fopAc_ac_c* i_actor);
static const fopAc_ac_c* fopAcM_findObjectCB(fopAc_ac_c const* i_actor, void* i_data);
@@ -709,6 +709,8 @@ s32 fopAcM_getWaterStream(const cXyz*, const cBgS_PolyInfo&, cXyz*, int*, int);
s16 fopAcM_getPolygonAngle(const cBgS_PolyInfo&, s16);
s16 fopAcM_getPolygonAngle(cM3dGPla const* param_0, s16 param_1);
+void fopAcM_DrawCullingBox(const fopAc_ac_c*, const GXColor&);
+
inline void make_prm_warp_hole(u32* o_params, u8 prm1, u8 prm2, u8 prm3) {
u32 pprm1 = (prm3 << 0x8);
u32 pprm2 = (prm2 << 0x10);
@@ -824,6 +826,11 @@ inline void fopAcM_setWarningMessage_f(const fopAc_ac_c* i_actor, const char* i_
#endif
}
+void fopAcM_showAssert_f(const fopAc_ac_c*, const char*, int, const char*, ...);
+
+#define fopAcM_assert(line, actor, COND, msg) \
+ (COND) ? (void)0 : (fopAcM_showAssert_f(actor, __FILE__, line, msg));
+
#ifdef DEBUG
#define fopAcM_setWarningMessage(i_actor, i_filename, i_line, i_msg) \
fopAcM_setWarningMessage_f(i_actor, i_filename, i_line, i_msg)
diff --git a/include/f_op/f_op_msg.h b/include/f_op/f_op_msg.h
index 53fc419f62..72a57b594f 100644
--- a/include/f_op/f_op_msg.h
+++ b/include/f_op/f_op_msg.h
@@ -38,4 +38,8 @@ struct msg_class {
extern leafdraw_method_class g_fopMsg_Method;
+namespace fopMsg {
+ extern u8 MemCheck;
+}
+
#endif /* F_OP_F_OP_MSG_H */
diff --git a/include/f_pc/f_pc_layer_iter.h b/include/f_pc/f_pc_layer_iter.h
index 2fb33ad90e..49e6bf5eaf 100644
--- a/include/f_pc/f_pc_layer_iter.h
+++ b/include/f_pc/f_pc_layer_iter.h
@@ -15,6 +15,7 @@ typedef void* (*fpcLyIt_JudgeFunc)(void*, void*);
s32 fpcLyIt_OnlyHere(layer_class* i_layer, fpcLyIt_OnlyHereFunc i_func, void* i_data);
s32 fpcLyIt_OnlyHereLY(layer_class* i_layer, fpcLyIt_OnlyHereFunc i_func, void* i_data);
+s32 fpcLyIt_All(fpcLyIt_OnlyHereFunc i_func, void* i_data);
void* fpcLyIt_Judge(layer_class* i_layer, fpcLyIt_JudgeFunc i_func, void* i_data);
void* fpcLyIt_AllJudge(fpcLyIt_JudgeFunc i_func, void* i_data);
diff --git a/include/m_Do/m_Do_MemCard.h b/include/m_Do/m_Do_MemCard.h
index 8464766950..128a6a6b52 100644
--- a/include/m_Do/m_Do_MemCard.h
+++ b/include/m_Do/m_Do_MemCard.h
@@ -163,4 +163,8 @@ inline void mDoMemCd_setCardStatus(s32 fileNo, CARDStat* stat) {
g_mDoMemCd_control.setCardStatus(fileNo, stat);
}
+inline void mDoMemCd_UpDate() {
+ g_mDoMemCd_control.update();
+}
+
#endif /* M_DO_M_DO_MEMCARD_H */
diff --git a/include/m_Do/m_Do_Reset.h b/include/m_Do/m_Do_Reset.h
index a40d331ef4..76272c3774 100644
--- a/include/m_Do/m_Do_Reset.h
+++ b/include/m_Do/m_Do_Reset.h
@@ -6,9 +6,6 @@
void mDoRst_reset(int, u32, int);
void mDoRst_resetCallBack(int, void*);
-extern bool SyncWidthSound;
-extern u8 sDefaultDirection;
-
struct mDoRstData {
/* 0x00 */ int mReset;
/* 0x04 */ int mResetPrepare;
diff --git a/include/m_Do/m_Do_dvd_thread.h b/include/m_Do/m_Do_dvd_thread.h
index f0df50ac9b..505778cbe4 100644
--- a/include/m_Do/m_Do_dvd_thread.h
+++ b/include/m_Do/m_Do_dvd_thread.h
@@ -120,6 +120,11 @@ struct mDoDvdThd {
static OSThread l_thread;
static mDoDvdThdStack l_threadStack;
static mDoDvdThd_param_c l_param;
+
+ static u8 verbose;
+ static u8 DVDLogoMode;
+ static bool SyncWidthSound;
+ static u8 Report_DVDRead;
};
#endif /* M_DO_M_DO_DVD_THREAD_H */
diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h
index 5af346ec4f..8cd9408747 100644
--- a/include/m_Do/m_Do_ext.h
+++ b/include/m_Do/m_Do_ext.h
@@ -859,7 +859,12 @@ void mDoExt_modelUpdateDL(J3DModel* i_model);
J3DModel* mDoExt_J3DModel__create(J3DModelData* i_modelData, u32 i_modelFlag,
u32 i_differedDlistFlag);
+extern u32 aram_cache_size;
void mDoExt_setAraCacheSize(u32 size);
+inline u32 mDoExt_getAraCacheSize() {
+ return aram_cache_size;
+}
+
int mDoExt_resIDToIndex(JKRArchive* p_archive, u16 id);
void mDoExt_modelEntryDL(J3DModel* i_model);
void mDoExt_brkAnmRemove(J3DModelData* i_modelData);
diff --git a/include/m_Do/m_Do_ext2.h b/include/m_Do/m_Do_ext2.h
new file mode 100644
index 0000000000..45c72fe6ef
--- /dev/null
+++ b/include/m_Do/m_Do_ext2.h
@@ -0,0 +1,30 @@
+#ifndef M_DO_EXT2_H
+#define M_DO_EXT2_H
+
+#include "JSystem/JKernel/JKRHeap.h"
+
+class FixedMemoryCheck {
+public:
+ FixedMemoryCheck(u32*, u32, JKRHeap*);
+
+ void alloc();
+ void save();
+ void check();
+ void diff();
+
+ static void easyCreate(void*, s32);
+ static void easyCreate(void*, u32);
+ static void checkAll();
+ static void diffAll();
+ static void saveAll();
+
+ /* 0x00 */ u32* field_0x00;
+ /* 0x04 */ u32 field_0x04;
+ /* 0x08 */ u32* field_0x08;
+ /* 0x0C */ JKRHeap* mpHeap;
+ /* 0x10 */ int field_0x10;
+ /* 0x14 */ u8 field_0x14;
+ /* 0x18 */ FixedMemoryCheck* field_0x18;
+};
+
+#endif
diff --git a/include/m_Do/m_Do_graphic.h b/include/m_Do/m_Do_graphic.h
index ed795a0773..2910ab9e50 100644
--- a/include/m_Do/m_Do_graphic.h
+++ b/include/m_Do/m_Do_graphic.h
@@ -27,6 +27,7 @@ public:
void setBlendColor(GXColor i_color) { mBlendColor = i_color; }
void setMonoColor(GXColor i_color) { mMonoColor = i_color; }
void setMode(u8 i_mode) { mMode = i_mode; }
+ void* getBuffer() { return m_buffer; }
/* 0x00 */ GXColor mBlendColor;
/* 0x04 */ GXColor mMonoColor;
@@ -147,6 +148,15 @@ public:
static void setWideZoomLightProjection(Mtx m) {}
static void setFrameRate(u16 i_rate) { JFWDisplay::getManager()->setFrameRate(i_rate); }
+ static int getFrameBufferSize() {
+ #define RoundUp16b(x) (u16)(((u16)(x) + 16 - 1) & ~(16 - 1))
+ return RoundUp16b(JFWDisplay::getManager()->getEfbWidth()) * JFWDisplay::getManager()->getEfbHeight() * 2;
+ }
+
+ static void* getFrameBufferMemory() {
+ return JFWDisplay::getManager()->getXfbManager()->getDisplayingXfb();
+ }
+
// NONMATCHING - Need to define all mDoGph_gInf_c shieldD members
static u8 isWide() {
#if PLATFORM_WII || PLATFORM_SHIELD
@@ -183,6 +193,11 @@ public:
static bool mAutoForcus;
#if PLATFORM_WII || PLATFORM_SHIELD
+ static JKRHeap* getHeap() {
+ return m_heap;
+ }
+
+ static JKRHeap* m_heap;
static cXyz m_nowEffPos;
static cXyz m_oldEffPos;
static cXyz m_oldOldEffPos;
diff --git a/include/m_Do/m_Do_machine.h b/include/m_Do/m_Do_machine.h
index 75b275a7d2..4fe72f05f0 100644
--- a/include/m_Do/m_Do_machine.h
+++ b/include/m_Do/m_Do_machine.h
@@ -13,6 +13,7 @@ void exceptionRestart();
void myExceptionCallback(u16, OSContext*, u32, u32);
void my_SysPrintHeap(char const*, void*, u32);
void mDoMch_HeapCheckAll();
+void mDoMch_HeapFreeFillAll();
int mDoMch_Create();
extern GXRenderModeObj g_ntscZeldaProg;
@@ -29,4 +30,17 @@ public:
static GXRenderModeObj* mRenderModeObj;
};
+namespace mDoMch {
+ extern u8 mDebugFill;
+ extern u8 mDebugFillNotuse;
+ extern u8 mDebugFillNew;
+ extern u8 mDebugFillDelete;
+
+ extern u8 myHeapVerbose;
+ extern u8 myHeapCallbackCheck;
+ extern u8 FpscrEnableBits;
+ extern u8 GXWarningLevel;
+ extern u8 GXWarningExecuteFrame;
+};
+
#endif /* M_DO_M_DO_MACHINE_H */
diff --git a/include/m_Do/m_Do_main.h b/include/m_Do/m_Do_main.h
index 6ece441c63..f005c5c9d7 100644
--- a/include/m_Do/m_Do_main.h
+++ b/include/m_Do/m_Do_main.h
@@ -26,16 +26,23 @@ public:
u32& getUsedCountRef() { return mUsedCount; }
u32& getTotalUsedSizeRef() { return mTotalUsedSize; }
JKRExpHeap* getHeap() { return mHeap; }
- void setHeap(JKRExpHeap* i_heap) { mHeap = i_heap; }
void setHeapSize(u32 i_size) { mTargetHeapSize = i_size; }
s32 getMaxTotalUsedSize() const { return mMaxTotalUsedSize; }
s32 getMaxTotalFreeSize() { return mMaxTotalFreeSize; }
const char* getName() const { return mName; }
+ const char* getJName() const { return mJName; }
void saveRelBase() {
mUsedCount = getUsedCount();
mTotalUsedSize = mHeap->getTotalUsedSize();
}
+ void setHeap(JKRExpHeap* i_heap) {
+ mHeap = i_heap;
+ if (i_heap != NULL) {
+ mTargetHeapSize = i_heap->getHeapSize();
+ }
+ }
+
u32 getTargetHeapSize() const { return mTargetHeapSize; }
u32 getRelUsedCount() const { return getUsedCount() - mUsedCount; }
diff --git a/include/m_Do/m_Do_printf.h b/include/m_Do/m_Do_printf.h
index d27e5bd627..84d6c080b4 100644
--- a/include/m_Do/m_Do_printf.h
+++ b/include/m_Do/m_Do_printf.h
@@ -9,4 +9,16 @@ void mDoPrintf_vprintf_Thread(char const*, va_list);
void mDoPrintf_vprintf(const char*, va_list);
extern "C" void mDoPrintf_VReport(const char*, va_list);
+extern u32 print_counts;
+extern u32 print_errors;
+extern u32 print_warings;
+extern u32 print_systems;
+extern u8 print_initialized;
+
+extern u8 print_mutex_initialized;
+extern u8 print_highPriority;
+extern u8 print_threadID;
+extern u8 print_callerPC;
+extern u8 print_callerPCLevel;
+
#endif /* M_DO_M_DO_PRINTF_H */
diff --git a/include/revolution/ai.h b/include/revolution/ai.h
new file mode 100644
index 0000000000..340da848b2
--- /dev/null
+++ b/include/revolution/ai.h
@@ -0,0 +1,50 @@
+#ifndef _REVOLUTION_AI_H_
+#define _REVOLUTION_AI_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*AISCallback)(u32 count);
+typedef void (*AIDCallback)();
+
+#define AI_STREAM_START 1
+#define AI_STREAM_STOP 0
+
+#define AI_SAMPLERATE_32KHZ 0
+#define AI_SAMPLERATE_48KHZ 1
+
+AIDCallback AIRegisterDMACallback(AIDCallback callback);
+void AIInitDMA(u32 start_addr, u32 length);
+BOOL AIGetDMAEnableFlag(void);
+void AIStartDMA(void);
+void AIStopDMA(void);
+u32 AIGetDMABytesLeft(void);
+u32 AIGetDMAStartAddr(void);
+u32 AIGetDMALength(void);
+BOOL AICheckInit(void);
+AISCallback AIRegisterStreamCallback(AISCallback callback);
+u32 AIGetStreamSampleCount(void);
+void AIResetStreamSampleCount(void);
+void AISetStreamTrigger(u32 trigger);
+u32 AIGetStreamTrigger(void);
+void AISetStreamPlayState(u32 state);
+u32 AIGetStreamPlayState(void);
+void AISetDSPSampleRate(u32 rate);
+u32 AIGetDSPSampleRate(void);
+void AISetStreamSampleRate(u32 rate);
+u32 AIGetStreamSampleRate(void);
+void AISetStreamVolLeft(u8 vol);
+u8 AIGetStreamVolLeft(void);
+void AISetStreamVolRight(u8 vol);
+u8 AIGetStreamVolRight(void);
+void AIInit(u8* stack);
+void AIReset(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/amc/AmcExi2Comm.h b/include/revolution/amc/AmcExi2Comm.h
new file mode 100644
index 0000000000..0fff2a34b0
--- /dev/null
+++ b/include/revolution/amc/AmcExi2Comm.h
@@ -0,0 +1,123 @@
+#ifndef _REVOLUTION_AMC_AMCEXI2COMM_H_
+#define _REVOLUTION_AMC_AMCEXI2COMM_H_
+
+#include <revolution/os.h>
+#include <revolution/amc/AmcTypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+ AMC_EXI_NO_ERROR = 0,
+ AMC_EXI_UNSELECTED,
+} AmcExiError;
+
+// ---------------------------------------------------------------------------
+//
+// void EXI2_Init( volatile unsigned char **inputPendingPtrRef,
+// EXICallback monitorCallback );
+//
+// Description: Initialize the EXI2 driver (without interrupts). The
+// parameter 'inputPendingPtrref' is a flag showing whether input
+// is waiting in the EXI2 buffer and 'monitorCallback' is a
+// pointer to a callback function that is invoked at the end of
+// the EXI2 ISR.
+//
+// ---------------------------------------------------------------------------
+void EXI2_Init(volatile unsigned char **inputPendingPtrRef, EXICallback monitorCallback);
+
+// ---------------------------------------------------------------------------
+//
+// void EXI2_EnableInterrupts( void );
+//
+// Description: Enable EXI2 interrupts. This function must be called to use
+// interrupts on the EXI2 interface. Call this function only
+// after EXI2_Init() has been invoked.
+//
+// ---------------------------------------------------------------------------
+void EXI2_EnableInterrupts( void );
+
+
+
+// ---------------------------------------------------------------------------
+//
+// int EXI2_Poll( void );
+//
+// Description: Returns the number of bytes waiting to be read in the EXI2
+// buffer.
+//
+// ---------------------------------------------------------------------------
+int EXI2_Poll( void );
+
+
+
+// ---------------------------------------------------------------------------
+//
+// AmcExiError EXI2_ReadN( void *bytes, unsigned long length );
+//
+// Description: Read length bytes and return in bytes[] array.
+//
+// Returns: One of AMC_EXI_*.
+//
+// ---------------------------------------------------------------------------
+AmcExiError EXI2_ReadN( void *bytes, unsigned long length);
+
+
+
+// ---------------------------------------------------------------------------
+//
+// AmcExiError EXI2_WriteN( const void *bytes, unsigned long length );
+//
+// Description: Write length bytes stored in bytes[] array.
+//
+// Returns: One of AMC_EXI_*.
+//
+// ---------------------------------------------------------------------------
+AmcExiError EXI2_WriteN( const void *bytes, unsigned long length);
+
+
+
+// ---------------------------------------------------------------------------
+//
+// void EXI2_Reserve( void );
+//
+// Description: Disable non-monitor communications over the EXI2 port.
+// This function must be called before the monitor takes
+// control of the processor.
+//
+// ---------------------------------------------------------------------------
+void EXI2_Reserve( void );
+
+
+
+// ---------------------------------------------------------------------------
+//
+// void EXI2_Unreserve( void );
+//
+// Description: Re-enable non-monitor communications over the EXI2 port.
+// This function must be called just before the monitor
+// gives control of the processor back to the application.
+//
+// ---------------------------------------------------------------------------
+void EXI2_Unreserve( void );
+
+
+
+// ---------------------------------------------------------------------------
+//
+// AmcExiError EXI2_GetStatusReg( u16* pu16StatusReg );
+//
+// Description: Read and store the value of the status register into
+// *pu16StatusReg.
+//
+// Returns: One of AMC_EXI_*.
+// ---------------------------------------------------------------------------
+AmcExiError EXI2_GetStatusReg( u16* pu16StatusReg );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/amc/AmcTypes.h b/include/revolution/amc/AmcTypes.h
new file mode 100644
index 0000000000..b9fa6ac9ae
--- /dev/null
+++ b/include/revolution/amc/AmcTypes.h
@@ -0,0 +1,9 @@
+#ifndef _INCLUDE_REVOLUTION_AMCTYPES_H_
+#define _INCLUDE_REVOLUTION_AMCTYPES_H_
+
+#include <revolution/os.h>
+
+// EXI callback function pointer type
+typedef void (*EXICallback)(s32 chan, OSContext* context);
+
+#endif
diff --git a/include/revolution/ax.h b/include/revolution/ax.h
new file mode 100644
index 0000000000..a1a85ddd87
--- /dev/null
+++ b/include/revolution/ax.h
@@ -0,0 +1,325 @@
+#ifndef _REVOLUTION_AX_H_
+#define _REVOLUTION_AX_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _AXPBMIX {
+ /* 0x00 */ u16 vL;
+ /* 0x02 */ u16 vDeltaL;
+ /* 0x04 */ u16 vR;
+ /* 0x06 */ u16 vDeltaR;
+ /* 0x08 */ u16 vAuxAL;
+ /* 0x0A */ u16 vDeltaAuxAL;
+ /* 0x0C */ u16 vAuxAR;
+ /* 0x0E */ u16 vDeltaAuxAR;
+ /* 0x10 */ u16 vAuxBL;
+ /* 0x12 */ u16 vDeltaAuxBL;
+ /* 0x14 */ u16 vAuxBR;
+ /* 0x16 */ u16 vDeltaAuxBR;
+ /* 0x18 */ u16 vAuxBS;
+ /* 0x1A */ u16 vDeltaAuxBS;
+ /* 0x1C */ u16 vS;
+ /* 0x1E */ u16 vDeltaS;
+ /* 0x20 */ u16 vAuxAS;
+ /* 0x22 */ u16 vDeltaAuxAS;
+} AXPBMIX;
+
+typedef struct _AXPBITD {
+ /* 0x00 */ u16 flag;
+ /* 0x02 */ u16 bufferHi;
+ /* 0x04 */ u16 bufferLo;
+ /* 0x06 */ u16 shiftL;
+ /* 0x08 */ u16 shiftR;
+ /* 0x0A */ u16 targetShiftL;
+ /* 0x0C */ u16 targetShiftR;
+} AXPBITD;
+
+typedef struct _AXPBUPDATE {
+ /* 0x00 */ u16 updNum[5];
+ /* 0x0A */ u16 dataHi;
+ /* 0x0C */ u16 dataLo;
+} AXPBUPDATE;
+
+typedef struct _AXPBDPOP {
+ /* 0x00 */ s16 aL;
+ /* 0x02 */ s16 aAuxAL;
+ /* 0x04 */ s16 aAuxBL;
+ /* 0x06 */ s16 aR;
+ /* 0x08 */ s16 aAuxAR;
+ /* 0x0A */ s16 aAuxBR;
+ /* 0x0C */ s16 aS;
+ /* 0x0E */ s16 aAuxAS;
+ /* 0x10 */ s16 aAuxBS;
+} AXPBDPOP;
+
+typedef struct _AXPBVE {
+ /* 0x00 */ u16 currentVolume;
+ /* 0x02 */ s16 currentDelta;
+} AXPBVE;
+
+typedef struct _AXPBFIR {
+ /* 0x00 */ u16 numCoefs;
+ /* 0x02 */ u16 coefsHi;
+ /* 0x04 */ u16 coefsLo;
+} AXPBFIR;
+
+typedef struct _AXPBADDR {
+ /* 0x00 */ u16 loopFlag;
+ /* 0x02 */ u16 format;
+ /* 0x04 */ u16 loopAddressHi;
+ /* 0x06 */ u16 loopAddressLo;
+ /* 0x08 */ u16 endAddressHi;
+ /* 0x0A */ u16 endAddressLo;
+ /* 0x0C */ u16 currentAddressHi;
+ /* 0x0E */ u16 currentAddressLo;
+} AXPBADDR;
+
+typedef struct _AXPBADPCM {
+ /* 0x00 */ u16 a[8][2];
+ /* 0x20 */ u16 gain;
+ /* 0x22 */ u16 pred_scale;
+ /* 0x24 */ u16 yn1;
+ /* 0x26 */ u16 yn2;
+} AXPBADPCM;
+
+typedef struct _AXPBSRC {
+ /* 0x00 */ u16 ratioHi;
+ /* 0x02 */ u16 ratioLo;
+ /* 0x04 */ u16 currentAddressFrac;
+ /* 0x06 */ u16 last_samples[4];
+} AXPBSRC;
+
+typedef struct _AXPBADPCMLOOP {
+ /* 0x00 */ u16 loop_pred_scale;
+ /* 0x02 */ u16 loop_yn1;
+ /* 0x04 */ u16 loop_yn2;
+} AXPBADPCMLOOP;
+
+typedef struct _AXPBLPF {
+ u16 on;
+ u16 yn1;
+ u16 a0;
+ u16 b0;
+} AXPBLPF;
+
+typedef struct _AXPB {
+ /* 0x00 */ u16 nextHi;
+ /* 0x02 */ u16 nextLo;
+ /* 0x04 */ u16 currHi;
+ /* 0x06 */ u16 currLo;
+ /* 0x08 */ u16 srcSelect;
+ /* 0x0A */ u16 coefSelect;
+ /* 0x0C */ u16 mixerCtrl;
+ /* 0x0E */ u16 state;
+ /* 0x10 */ u16 type;
+ /* 0x12 */ AXPBMIX mix;
+ /* 0x36 */ AXPBITD itd;
+ /* 0x44 */ AXPBUPDATE update;
+ /* 0x52 */ AXPBDPOP dpop;
+ /* 0x64 */ AXPBVE ve;
+ /* 0x68 */ AXPBFIR fir;
+ /* 0x6E */ AXPBADDR addr;
+ /* 0x7E */ AXPBADPCM adpcm;
+ /* 0xA6 */ AXPBSRC src;
+ /* 0xB4 */ AXPBADPCMLOOP adpcmLoop;
+ /* 0xBA */ AXPBLPF lpf;
+ /* 0xC2 */ u16 pad[25];
+} AXPB;
+
+typedef struct _AXVPB {
+ /* 0x000 */ void* next;
+ /* 0x004 */ void* prev;
+ /* 0x008 */ void* next1;
+ /* 0x00C */ u32 priority;
+ /* 0x010 */ void (*callback)(void*);
+ /* 0x014 */ u32 userContext;
+ /* 0x018 */ u32 index;
+ /* 0x01C */ u32 sync;
+ /* 0x020 */ u32 depop;
+ /* 0x024 */ u32 updateMS;
+ /* 0x028 */ u32 updateCounter;
+ /* 0x02C */ u32 updateTotal;
+ /* 0x030 */ u16* updateWrite;
+ /* 0x034 */ u16 updateData[128];
+ /* 0x134 */ void* itdBuffer;
+ /* 0x138 */ AXPB pb;
+} AXVPB;
+
+typedef struct _AXPBITDBUFFER {
+ /* 0x00 */ s16 data[32];
+} AXPBITDBUFFER;
+
+typedef struct _AXPBU {
+ /* 0x00 */ u16 data[128];
+} AXPBU;
+
+typedef struct _AXSPB {
+ /* 0x00 */ u16 dpopLHi;
+ /* 0x02 */ u16 dpopLLo;
+ /* 0x04 */ s16 dpopLDelta;
+ /* 0x06 */ u16 dpopRHi;
+ /* 0x08 */ u16 dpopRLo;
+ /* 0x0A */ s16 dpopRDelta;
+ /* 0x0C */ u16 dpopSHi;
+ /* 0x0E */ u16 dpopSLo;
+ /* 0x10 */ s16 dpopSDelta;
+ /* 0x12 */ u16 dpopALHi;
+ /* 0x14 */ u16 dpopALLo;
+ /* 0x16 */ s16 dpopALDelta;
+ /* 0x18 */ u16 dpopARHi;
+ /* 0x1A */ u16 dpopARLo;
+ /* 0x1C */ s16 dpopARDelta;
+ /* 0x1E */ u16 dpopASHi;
+ /* 0x20 */ u16 dpopASLo;
+ /* 0x22 */ s16 dpopASDelta;
+ /* 0x24 */ u16 dpopBLHi;
+ /* 0x26 */ u16 dpopBLLo;
+ /* 0x28 */ s16 dpopBLDelta;
+ /* 0x2A */ u16 dpopBRHi;
+ /* 0x2C */ u16 dpopBRLo;
+ /* 0x2E */ s16 dpopBRDelta;
+ /* 0x30 */ u16 dpopBSHi;
+ /* 0x32 */ u16 dpopBSLo;
+ /* 0x34 */ s16 dpopBSDelta;
+} AXSPB;
+
+typedef struct _AXPROFILE {
+ /* 0x00 */ u64 axFrameStart;
+ /* 0x08 */ u64 auxProcessingStart;
+ /* 0x10 */ u64 auxProcessingEnd;
+ /* 0x18 */ u64 userCallbackStart;
+ /* 0x20 */ u64 userCallbackEnd;
+ /* 0x28 */ u64 axFrameEnd;
+ /* 0x30 */ u32 axNumVoices;
+} AXPROFILE;
+
+typedef struct AX_AUX_DATA {
+ /* 0x00 */ s32* l;
+ /* 0x00 */ s32* r;
+ /* 0x00 */ s32* s;
+} AX_AUX_DATA;
+
+typedef struct AX_AUX_DATA_DPL2 {
+ /* 0x00 */ s32* l;
+ /* 0x00 */ s32* r;
+ /* 0x00 */ s32* ls;
+ /* 0x00 */ s32* rs;
+} AX_AUX_DATA_DPL2;
+
+typedef void (*AXCallback)();
+
+#define AX_DSP_SLAVE_LENGTH 0xF80
+#define AX_MAX_VOICES 64
+
+#define AX_SRC_TYPE_NONE 0
+#define AX_SRC_TYPE_LINEAR 1
+#define AX_SRC_TYPE_4TAP_8K 2
+#define AX_SRC_TYPE_4TAP_12K 3
+#define AX_SRC_TYPE_4TAP_16K 4
+
+// sync flags
+#define AX_SYNC_FLAG_COPYALL (1 << 31)
+#define AX_SYNC_FLAG_UNK1 (1 << 30) // reserved, unused?
+#define AX_SYNC_FLAG_UNK2 (1 << 29) // reserved, unused?
+#define AX_SYNC_FLAG_UNK3 (1 << 28) // reserved, unused?
+#define AX_SYNC_FLAG_UNK4 (1 << 27) // reserved, unused?
+#define AX_SYNC_FLAG_UNK5 (1 << 26) // reserved, unused?
+#define AX_SYNC_FLAG_UNK6 (1 << 25) // reserved, unused?
+#define AX_SYNC_FLAG_UNK7 (1 << 24) // reserved, unused?
+#define AX_SYNC_FLAG_UNK8 (1 << 23) // reserved, unused?
+#define AX_SYNC_FLAG_UNK9 (1 << 22) // reserved, unused?
+#define AX_SYNC_FLAG_UNK10 (1 << 21) // reserved, unused?
+#define AX_SYNC_FLAG_COPYADPCMLOOP (1 << 20)
+#define AX_SYNC_FLAG_COPYRATIO (1 << 19)
+#define AX_SYNC_FLAG_COPYSRC (1 << 18)
+#define AX_SYNC_FLAG_COPYADPCM (1 << 17)
+#define AX_SYNC_FLAG_COPYCURADDR (1 << 16)
+#define AX_SYNC_FLAG_COPYENDADDR (1 << 15)
+#define AX_SYNC_FLAG_COPYLOOPADDR (1 << 14)
+#define AX_SYNC_FLAG_COPYLOOP (1 << 13)
+#define AX_SYNC_FLAG_COPYADDR (1 << 12)
+#define AX_SYNC_FLAG_COPYFIR (1 << 11)
+#define AX_SYNC_FLAG_SWAPVOL (1 << 10)
+#define AX_SYNC_FLAG_COPYVOL (1 << 9)
+#define AX_SYNC_FLAG_COPYDPOP (1 << 8)
+#define AX_SYNC_FLAG_COPYUPDATE (1 << 7)
+#define AX_SYNC_FLAG_COPYTSHIFT (1 << 6)
+#define AX_SYNC_FLAG_COPYITD (1 << 5)
+#define AX_SYNC_FLAG_COPYAXPBMIX (1 << 4)
+#define AX_SYNC_FLAG_COPYTYPE (1 << 3)
+#define AX_SYNC_FLAG_COPYSTATE (1 << 2)
+#define AX_SYNC_FLAG_COPYMXRCTRL (1 << 1)
+#define AX_SYNC_FLAG_COPYSELECT (1 << 0)
+
+#define AX_PRIORITY_STACKS 32
+
+// AX
+void AXInit(void);
+void AXInitEx(u32 outputBufferMode);
+void AXQuit(void);
+
+// AXAlloc
+void AXFreeVoice(AXVPB* p);
+AXVPB* AXAcquireVoice(u32 priority, void (*callback)(void *), u32 userContext);
+void AXSetVoicePriority(AXVPB* p, u32 priority);
+
+// AXAux
+void AXRegisterAuxACallback(void (*callback)(void*, void*), void* context);
+void AXRegisterAuxBCallback(void (*callback)(void*, void*), void* context);
+
+// AXCL
+void AXSetMode(u32 mode);
+u32 AXGetMode(void);
+
+// AXOut
+extern AXPROFILE __AXLocalProfile;
+
+void AXSetStepMode(u32 i);
+AXCallback AXRegisterCallback(AXCallback callback);
+
+// AXProf
+void AXInitProfile(AXPROFILE* profile, u32 maxProfiles);
+u32 AXGetProfile(void);
+
+// AXVPB
+void AXSetVoiceSrcType(AXVPB* p, u32 type);
+void AXSetVoiceState(AXVPB* p, u16 state);
+void AXSetVoiceType(AXVPB* p, u16 type);
+void AXSetVoiceMix(AXVPB* p, AXPBMIX* mix);
+void AXSetVoiceItdOn(AXVPB* p);
+void AXSetVoiceItdTarget(AXVPB* p, u16 lShift, u16 rShift);
+void AXSetVoiceUpdateIncrement(AXVPB* p);
+void AXSetVoiceUpdateWrite(AXVPB* p, u16 param, u16 data);
+void AXSetVoiceDpop(AXVPB* p, AXPBDPOP* dpop);
+void AXSetVoiceVe(AXVPB* p, AXPBVE* ve);
+void AXSetVoiceVeDelta(AXVPB* p, s16 delta);
+void AXSetVoiceFir(AXVPB* p, AXPBFIR* fir);
+void AXSetVoiceAddr(AXVPB* p, AXPBADDR* addr);
+void AXSetVoiceLoop(AXVPB* p, u16 loop);
+void AXSetVoiceLoopAddr(AXVPB* p, u32 addr);
+void AXSetVoiceEndAddr(AXVPB* p, u32 addr);
+void AXSetVoiceCurrentAddr(AXVPB* p, u32 addr);
+void AXSetVoiceAdpcm(AXVPB* p, AXPBADPCM* adpcm);
+void AXSetVoiceSrc(AXVPB* p, AXPBSRC* src_);
+void AXSetVoiceSrcRatio(AXVPB* p, f32 ratio);
+void AXSetVoiceAdpcmLoop(AXVPB* p, AXPBADPCMLOOP* adpcmloop);
+void AXSetMaxDspCycles(u32 cycles);
+u32 AXGetMaxDspCycles(void);
+u32 AXGetDspCycles(void);
+void AXSetVoiceLpf(AXVPB* p, AXPBLPF* lpf);
+void AXSetVoiceLpfCoefs(AXVPB* p, u16 a0, u16 b0);
+void AXGetLpfCoefs(u16 freq, u16* a0, u16* b0);
+
+// DSPCode
+extern u16 axDspSlaveLength;
+extern u16 axDspSlave[AX_DSP_SLAVE_LENGTH];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_AX_H_
diff --git a/include/revolution/axart.h b/include/revolution/axart.h
new file mode 100644
index 0000000000..1ef2ca1dcc
--- /dev/null
+++ b/include/revolution/axart.h
@@ -0,0 +1,224 @@
+#ifndef _REVOLUTION_AXART_H_
+#define _REVOLUTION_AXART_H_
+
+#include <revolution/types.h>
+#include <revolution/ax.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum __axart_type {
+ AXART_TYPE_NONE,
+ AXART_TYPE_3D,
+ AXART_TYPE_PANNING,
+ AXART_TYPE_ITD,
+ AXART_TYPE_SRC,
+ AXART_TYPE_PITCH,
+ AXART_TYPE_PITCH_ENV,
+ AXART_TYPE_PITCH_MOD,
+ AXART_TYPE_VOLUME,
+ AXART_TYPE_AUX_A_VOLUME,
+ AXART_TYPE_AUX_B_VOLUME,
+ AXART_TYPE_VOLUME_ENV,
+ AXART_TYPE_AUX_A_VOLUME_ENV,
+ AXART_TYPE_AUX_B_VOLUME_ENV,
+ AXART_TYPE_VOLUME_MOD,
+ AXART_TYPE_AUX_A_VOLUME_MOD,
+ AXART_TYPE_AUX_B_VOLUME_MOD,
+ AXART_TYPE_LPF,
+
+ AXART_TYPE_NUM
+};
+
+typedef struct {
+ void* next;
+ u32 type;
+} AXART_ART;
+
+typedef struct {
+ f32* lfo;
+ u32 length;
+ f32 delta;
+ u32 sampleIndex;
+ f32 counter;
+ f32 sample1;
+ f32 sample;
+ f32 output;
+} AXART_LFO;
+
+typedef struct {
+ AXART_ART art;
+ f32 hAngle;
+ f32 vAngle;
+ f32 dist;
+ f32 closingSpeed;
+ u32 update;
+ u8 pan;
+ u8 span;
+ u8 src;
+ u16 itdL;
+ u16 itdR;
+ f32 pitch;
+ s32 attenuation;
+} AXART_3D;
+
+typedef struct {
+ AXART_ART art;
+ u8 pan;
+ u8 span;
+} AXART_PANNING;
+
+typedef struct {
+ AXART_ART art;
+ u16 itdL;
+ u16 itdR;
+} AXART_ITD;
+
+typedef struct {
+ AXART_ART art;
+ u8 src;
+} AXART_SRC;
+
+typedef struct {
+ AXART_ART art;
+ s32 cents;
+} AXART_PITCH;
+
+typedef struct {
+ AXART_ART art;
+ s32 delta;
+ s32 target;
+ s32 cents;
+} AXART_PITCH_ENV;
+
+typedef struct {
+ AXART_ART art;
+ AXART_LFO lfo;
+ s32 cents;
+} AXART_PITCH_MOD;
+
+typedef struct {
+ AXART_ART art;
+ s32 attenuation;
+} AXART_VOLUME;
+
+typedef struct {
+ AXART_ART art;
+ s32 attenuation;
+} AXART_AUXA_VOLUME;
+
+typedef struct {
+ AXART_ART art;
+ s32 attenuation;
+} AXART_AUXB_VOLUME;
+
+typedef struct {
+ AXART_ART art;
+ s32 delta;
+ s32 target;
+ s32 attenuation;
+} AXART_VOLUME_ENV;
+
+typedef struct {
+ AXART_ART art;
+ s32 delta;
+ s32 target;
+ s32 attenuation;
+} AXART_AUXA_VOLUME_ENV;
+
+typedef struct {
+ AXART_ART art;
+ s32 delta;
+ s32 target;
+ s32 attenuation;
+} AXART_AUXB_VOLUME_ENV;
+
+typedef struct {
+ AXART_ART art;
+ AXART_LFO lfo;
+ s32 attenuation;
+} AXART_VOLUME_MOD;
+
+typedef struct {
+ AXART_ART art;
+ AXART_LFO lfo;
+ s32 attenuation;
+} AXART_AUXA_VOLUME_MOD;
+
+typedef struct {
+ AXART_ART art;
+ AXART_LFO lfo;
+ s32 attenuation;
+} AXART_AUXB_VOLUME_MOD;
+
+typedef struct {
+ AXART_ART art;
+ u32 initLPF;
+ u32 frequency;
+ u32 update;
+} AXART_LPF;
+
+typedef struct {
+ void* next;
+ void* prev;
+ AXVPB* axvpb;
+ f32 sampleRate;
+ AXART_ART* articulators;
+} AXART_SOUND;
+
+#define AXART_SINE_CNT 64
+extern f32 AXARTSine[AXART_SINE_CNT];
+
+// axart
+void AXARTInit(void);
+void AXARTQuit(void);
+void AXARTServiceSounds(void);
+void AXARTAddSound(AXART_SOUND* sound);
+void AXARTRemoveSound(AXART_SOUND* sound);
+void AXARTInitLfo(AXART_LFO* lfo, f32* samples, u32 length, f32 delta);
+void AXARTInitArt3D(AXART_3D* articulator);
+void AXARTInitArtPanning(AXART_PANNING* articulator);
+void AXARTInitArtItd(AXART_ITD* articulator);
+void AXARTInitArtSrctype(AXART_SRC* articulator);
+void AXARTInitArtPitch(AXART_PITCH* articulator);
+void AXARTInitArtPitchEnv(AXART_PITCH_ENV* articulator);
+void AXARTInitArtPitchMod(AXART_PITCH_MOD* articulator);
+void AXARTInitArtVolume(AXART_VOLUME* articulator);
+void AXARTInitArtAuxAVolume(AXART_AUXA_VOLUME* articulator);
+void AXARTInitArtAuxBVolume(AXART_AUXB_VOLUME* articulator);
+void AXARTInitArtVolumeEnv(AXART_VOLUME_ENV* articulator);
+void AXARTInitArtAuxAVolumeEnv(AXART_AUXA_VOLUME_ENV* articulator);
+void AXARTInitArtAuxBVolumeEnv(AXART_AUXB_VOLUME_ENV* articulator);
+void AXARTInitArtVolumeMod(AXART_VOLUME_MOD* articulator);
+void AXARTInitArtAuxAVolumeMod(AXART_AUXA_VOLUME_MOD* articulator);
+void AXARTInitArtAuxBVolumeMod(AXART_AUXB_VOLUME_MOD* articulator);
+void AXARTInitArtLpf(AXART_LPF* articulator);
+
+// axart3d
+void AXARTSet3DDistanceScale(f32 scale);
+void AXARTSet3DDopplerScale(f32 scale);
+void AXART3DSound(AXART_3D* articulator);
+
+// axartcents
+f32 AXARTCents(s32 cents);
+
+// axartenv
+void AXARTPitchEnv(AXART_PITCH_ENV* articulator);
+void AXARTVolumeEnv(AXART_VOLUME_ENV* articulator);
+
+// axartlfo
+void AXARTLfo(AXART_LFO* lfo);
+
+// axartsound
+void AXARTServiceSound(AXART_SOUND* sound);
+void AXARTAddArticulator(AXART_SOUND* sound, AXART_ART* articulator);
+
+// axartlpf
+void AXARTLpf(AXART_LPF*, AXVPB*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_AXART_H_
diff --git a/include/revolution/axfx.h b/include/revolution/axfx.h
new file mode 100644
index 0000000000..259e73e7b5
--- /dev/null
+++ b/include/revolution/axfx.h
@@ -0,0 +1,196 @@
+#ifndef _REVOLUTION_AXFX_H_
+#define _REVOLUTION_AXFX_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct AXFX_REVSTD_DELAYLINE {
+ /* 0x00 */ s32 inPoint;
+ /* 0x04 */ s32 outPoint;
+ /* 0x08 */ s32 length;
+ /* 0x0C */ f32* inputs;
+ /* 0x10 */ f32 lastOutput;
+} AXFX_REVSTD_DELAYLINE;
+
+typedef struct AXFX_REVSTD_WORK {
+ /* 0x000 */ AXFX_REVSTD_DELAYLINE AP[6];
+ /* 0x078 */ AXFX_REVSTD_DELAYLINE C[6];
+ /* 0x0F0 */ f32 allPassCoeff;
+ /* 0x0F4 */ f32 combCoef[6];
+ /* 0x10C */ f32 lpLastout[3];
+ /* 0x118 */ f32 level;
+ /* 0x11C */ f32 damping;
+ /* 0x120 */ s32 preDelayTime;
+ /* 0x124 */ f32* preDelayLine[3];
+ /* 0x130 */ f32* preDelayPtr[3];
+} AXFX_REVSTD_WORK;
+
+typedef struct AXFX_REVERBSTD {
+ /* 0x000 */ AXFX_REVSTD_WORK rv;
+ /* 0x13C */ u8 tempDisableFX;
+ /* 0x140 */ f32 coloration;
+ /* 0x144 */ f32 mix;
+ /* 0x148 */ f32 time;
+ /* 0x14C */ f32 damping;
+ /* 0x150 */ f32 preDelay;
+} AXFX_REVERBSTD;
+
+typedef struct AXFX_BUFFERUPDATE {
+ /* 0x00 */ s32* left;
+ /* 0x04 */ s32* right;
+ /* 0x08 */ s32* surround;
+} AXFX_BUFFERUPDATE;
+
+typedef struct AXFX_BUFFERUPDATE_DPL2 {
+ /* 0x00 */ s32* L;
+ /* 0x04 */ s32* R;
+ /* 0x08 */ s32* Ls;
+ /* 0x0C */ s32* Rs;
+} AXFX_BUFFERUPDATE_DPL2;
+
+// REVHI Structs
+
+typedef struct AXFX_REVHI_DELAYLINE {
+ /* 0x00 */ s32 inPoint;
+ /* 0x04 */ s32 outPoint;
+ /* 0x08 */ s32 length;
+ /* 0x0C */ f32* inputs;
+ /* 0x10 */ f32 lastOutput;
+} AXFX_REVHI_DELAYLINE;
+
+typedef struct AXFX_REVHI_WORK {
+ /* 0x000 */ AXFX_REVHI_DELAYLINE AP[9];
+ /* 0x0B4 */ AXFX_REVHI_DELAYLINE C[9];
+ /* 0x168 */ f32 allPassCoeff;
+ /* 0x16C */ f32 combCoef[9];
+ /* 0x190 */ f32 lpLastout[3];
+ /* 0x19C */ f32 level;
+ /* 0x1A0 */ f32 damping;
+ /* 0x1A4 */ s32 preDelayTime;
+ /* 0x1A8 */ f32 crosstalk;
+ /* 0x1AC */ f32* preDelayLine[3];
+ /* 0x1B8 */ f32* preDelayPtr[3];
+} AXFX_REVHI_WORK;
+
+typedef struct AXFX_REVHI_WORK_DPL2 {
+ /* 0x000 */ AXFX_REVHI_DELAYLINE AP[12];
+ /* 0x0F0 */ AXFX_REVHI_DELAYLINE C[12];
+ /* 0x1E0 */ f32 allPassCoeff;
+ /* 0x1E4 */ f32 combCoef[12];
+ /* 0x214 */ f32 lpLastout[4];
+ /* 0x224 */ f32 level;
+ /* 0x228 */ f32 damping;
+ /* 0x22C */ s32 preDelayTime;
+ /* 0x230 */ f32 crosstalk;
+ /* 0x234 */ f32* preDelayLine[4];
+ /* 0x244 */ f32* preDelayPtr[4];
+} AXFX_REVHI_WORK_DPL2;
+
+typedef struct AXFX_REVERBHI {
+ /* 0x000 */ AXFX_REVHI_WORK rv;
+ /* 0x1C4 */ u8 tempDisableFX;
+ /* 0x1C8 */ f32 coloration;
+ /* 0x1CC */ f32 mix;
+ /* 0x1D0 */ f32 time;
+ /* 0x1D4 */ f32 damping;
+ /* 0x1D8 */ f32 preDelay;
+ /* 0x1DC */ f32 crosstalk;
+} AXFX_REVERBHI;
+
+typedef struct AXFX_REVERBHI_DPL2 {
+ /* 0x000 */ AXFX_REVHI_WORK_DPL2 rv;
+ /* 0x254 */ u8 tempDisableFX;
+ /* 0x258 */ f32 coloration;
+ /* 0x25C */ f32 mix;
+ /* 0x260 */ f32 time;
+ /* 0x264 */ f32 damping;
+ /* 0x268 */ f32 preDelay;
+} AXFX_REVERBHI_DPL2;
+
+typedef struct AXFX_DELAY {
+ /* 0x00 */ u32 currentSize[3];
+ /* 0x0C */ u32 currentPos[3];
+ /* 0x18 */ u32 currentFeedback[3];
+ /* 0x24 */ u32 currentOutput[3];
+ /* 0x30 */ s32* left;
+ /* 0x34 */ s32* right;
+ /* 0x38 */ s32* sur;
+ /* 0x3C */ u32 delay[3];
+ /* 0x48 */ u32 feedback[3];
+ /* 0x54 */ u32 output[3];
+} AXFX_DELAY;
+
+typedef struct AXFX_CHORUS_SRCINFO {
+ /* 0x00 */ s32* dest;
+ /* 0x04 */ s32* smpBase;
+ /* 0x08 */ s32* old;
+ /* 0x0C */ u32 posLo;
+ /* 0x10 */ u32 posHi;
+ /* 0x14 */ u32 pitchLo;
+ /* 0x18 */ u32 pitchHi;
+ /* 0x1C */ u32 trigger;
+ /* 0x20 */ u32 target;
+} AXFX_CHORUS_SRCINFO;
+
+typedef struct AXFX_CHORUS_WORK {
+ /* 0x00 */ s32* lastLeft[3];
+ /* 0x0C */ s32* lastRight[3];
+ /* 0x18 */ s32* lastSur[3];
+ /* 0x24 */ u8 currentLast;
+ /* 0x28 */ s32 oldLeft[4];
+ /* 0x38 */ s32 oldRight[4];
+ /* 0x48 */ s32 oldSur[4];
+ /* 0x58 */ u32 currentPosLo;
+ /* 0x5C */ u32 currentPosHi;
+ /* 0x60 */ s32 pitchOffset;
+ /* 0x64 */ u32 pitchOffsetPeriodCount;
+ /* 0x68 */ u32 pitchOffsetPeriod;
+ /* 0x6C */ AXFX_CHORUS_SRCINFO src;
+} AXFX_CHORUS_WORK;
+
+typedef struct AXFX_CHORUS {
+ /* 0x00 */ AXFX_CHORUS_WORK work;
+ /* 0x90 */ u32 baseDelay;
+ /* 0x94 */ u32 variation;
+ /* 0x98 */ u32 period;
+} AXFX_CHORUS;
+
+// chorus
+int AXFXChorusInit(AXFX_CHORUS* c);
+int AXFXChorusShutdown(AXFX_CHORUS* c);
+int AXFXChorusSettings(AXFX_CHORUS* c);
+void AXFXChorusCallback(AXFX_BUFFERUPDATE* bufferUpdate, AXFX_CHORUS* chorus);
+
+// delay
+void AXFXDelayCallback(AXFX_BUFFERUPDATE* bufferUpdate, AXFX_DELAY* delay);
+int AXFXDelaySettings(AXFX_DELAY* delay);
+int AXFXDelayInit(AXFX_DELAY* delay);
+int AXFXDelayShutdown(AXFX_DELAY* delay);
+
+// reverb_hi
+void DoCrossTalk(s32* l, s32* r, f32 cross, f32 invcross);
+int AXFXReverbHiInit(AXFX_REVERBHI* rev);
+int AXFXReverbHiShutdown(AXFX_REVERBHI* rev);
+int AXFXReverbHiSettings(AXFX_REVERBHI* rev);
+void AXFXReverbHiCallback(AXFX_BUFFERUPDATE* bufferUpdate, AXFX_REVERBHI* reverb);
+
+// reverb_hi_4ch
+int AXFXReverbHiInitDpl2(AXFX_REVERBHI_DPL2* reverb);
+int AXFXReverbHiShutdownDpl2(AXFX_REVERBHI_DPL2* reverb);
+int AXFXReverbHiSettingsDpl2(AXFX_REVERBHI_DPL2* rev);
+void AXFXReverbHiCallbackDpl2(AXFX_BUFFERUPDATE_DPL2* bufferUpdate, AXFX_REVERBHI_DPL2* reverb);
+
+// reverb_std
+int AXFXReverbStdInit(AXFX_REVERBSTD* rev);
+int AXFXReverbStdShutdown(AXFX_REVERBSTD* rev);
+int AXFXReverbStdSettings(AXFX_REVERBSTD* rev);
+void AXFXReverbStdCallback(AXFX_BUFFERUPDATE* bufferUpdate, AXFX_REVERBSTD* reverb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_AXFX_H_
diff --git a/include/revolution/base/PPCArch.h b/include/revolution/base/PPCArch.h
new file mode 100644
index 0000000000..65afa27995
--- /dev/null
+++ b/include/revolution/base/PPCArch.h
@@ -0,0 +1,542 @@
+#ifndef _REVOLUTION_PPCARCH
+#define _REVOLUTION_PPCARCH
+
+#include "dolphin/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CTR 9
+#define XER 1
+#define LR 8
+
+#define UPMC1 937
+#define UPMC2 938
+#define UPMC3 941
+#define UPMC4 942
+
+#define USIA 939
+
+#define UMMCR0 936
+#define UMMCR1 940
+
+#define HID0 1008
+#define HID1 1009
+
+#define PVR 287
+
+#define IBAT0U 528
+#define IBAT0L 529
+#define IBAT1U 530
+#define IBAT1L 531
+#define IBAT2U 532
+#define IBAT2L 533
+#define IBAT3U 534
+#define IBAT3L 535
+
+#define DBAT0U 536
+#define DBAT0L 537
+#define DBAT1U 538
+#define DBAT1L 539
+#define DBAT2U 540
+#define DBAT2L 541
+#define DBAT3U 542
+#define DBAT3L 543
+
+#define SDR1 25
+
+#define SPRG0 272
+#define SPRG1 273
+#define SPRG2 274
+#define SPRG3 275
+
+#define DAR 19
+#define DSISR 18
+
+#define SRR0 26
+#define SRR1 27
+
+#define EAR 282
+
+#define DABR 1013
+
+#define TBL 284
+#define TBU 285
+
+#define L2CR 1017
+
+#define DEC 22
+
+#define IABR 1010
+
+#define PMC1 953
+#define PMC2 954
+#define PMC3 957
+#define PMC4 958
+
+#define SIA 955
+
+#define MMCR0 952
+#define MMCR1 956
+
+#define THRM1 1020
+#define THRM2 1021
+#define THRM3 1022
+
+#define ICTC 1019
+
+#define GQR0 912
+#define GQR1 913
+#define GQR2 914
+#define GQR3 915
+#define GQR4 916
+#define GQR5 917
+#define GQR6 918
+#define GQR7 919
+
+#define HID2 920
+
+#define WPAR 921
+
+#define DMA_U 922
+#define DMA_L 923
+
+#define MSR_POW 0x00040000 // Power Management
+#define MSR_ILE 0x00010000 // Interrupt Little Endian
+#define MSR_EE 0x00008000 // external interrupt
+#define MSR_PR 0x00004000 // privilege level(should be 0)
+#define MSR_FP 0x00002000 // floating point available
+#define MSR_ME 0x00001000 // machine check enable
+#define MSR_FE0 0x00000800 // floating point exception enable
+#define MSR_SE 0x00000400 // single step trace enable
+#define MSR_BE 0x00000200 // branch trace enable
+#define MSR_FE1 0x00000100 // floating point exception enable
+#define MSR_IP 0x00000040 // Exception prefix
+#define MSR_IR 0x00000020 // instruction relocate
+#define MSR_DR 0x00000010 // data relocate
+#define MSR_PM 0x00000004 // Performance monitor marked mode
+#define MSR_RI 0x00000002 // Recoverable interrupt
+#define MSR_LE 0x00000001 // Little Endian
+
+#define MSR_POW_BIT 13 // Power Management
+#define MSR_ILE_BIT 15 // Interrupt Little Endian
+#define MSR_EE_BIT 16 // external interrupt
+#define MSR_PR_BIT 17 // privilege level (should be 0)
+#define MSR_FP_BIT 18 // floating point available
+#define MSR_ME_BIT 19 // machine check enable
+#define MSR_FE0_BIT 20 // floating point exception enable
+#define MSR_SE_BIT 21 // single step trace enable
+#define MSR_BE_BIT 22 // branch trace enable
+#define MSR_FE1_BIT 23 // floating point exception enable
+#define MSR_IP_BIT 25 // Exception prefix
+#define MSR_IR_BIT 26 // instruction relocate
+#define MSR_DR_BIT 27 // data relocate
+#define MSR_PM_BIT 29 // Performance monitor marked mode
+#define MSR_RI_BIT 30 // Recoverable interrupt
+#define MSR_LE_BIT 31 // Little Endian
+
+/*---------------------------------------------------------------------------*
+ HID0 bits
+ *---------------------------------------------------------------------------*/
+#define HID0_EMCP 0x80000000u // Enable MCP
+#define HID0_DBP 0x40000000u // Enable 60x bus address and data parity chk
+#define HID0_EBA 0x20000000u // Enable 60x address parity checking
+#define HID0_EBD 0x10000000u // Enable 60x data parity checking
+#define HID0_BCLK 0x08000000u // CLK_OUT output enable and clk selection
+#define HID0_ECLK 0x02000000u // CLK_OUT output enable and clk selection
+#define HID0_PAR 0x01000000u // Disable !ARTRY precharge
+#define HID0_DOZE 0x00800000u // Doze mode enable
+#define HID0_NAP 0x00400000u // Nap mode enable
+#define HID0_SLEEP 0x00200000u // Sleep mode enable
+#define HID0_DPM 0x00100000u // Dynamic power management enable
+#define HID0_NHR 0x00010000u // Not hard reset (0 hard reset if s/w set it)
+#define HID0_ICE 0x00008000u // Instruction cache enable
+#define HID0_DCE 0x00004000u // Data cache enable
+#define HID0_ILOCK 0x00002000u // ICache lock
+#define HID0_DLOCK 0x00001000u // DCache lock
+#define HID0_ICFI 0x00000800u // ICache flash invalidate
+#define HID0_DCFI 0x00000400u // DCache flash invalidate
+#define HID0_SPD 0x00000200u // Speculative cache access enable (0 enable)
+#define HID0_IFEM 0x00000100u // Enable M bit on bus for Ifetch
+#define HID0_SGE 0x00000080u // Store gathering enable
+#define HID0_DCFA 0x00000040u // DCache flush assist - set before a flush
+#define HID0_BTIC 0x00000020u // Branch target icache enable
+#define HID0_ABE 0x00000008u // Address bcast enable
+#define HID0_BHT 0x00000004u // Branch history table enable
+#define HID0_NOOPTI 0x00000001u // No-op Dcache touch instructions
+
+#define HID0_ICE_BIT 16 // Instruction cache enable
+#define HID0_DCE_BIT 17 // Data cache enable
+#define HID0_ILOCK_BIT 18 // ICache lock
+#define HID0_DLOCK_BIT 19 // DCache lock
+
+#define HID2_LSQE 0x80000000 // L/S quantize enable
+#define HID2_WPE 0x40000000 // Write pipe enable
+#define HID2_PSE 0x20000000 // Paired single enable
+#define HID2_LCE 0x10000000 // Locked cache enable
+
+#define HID2_DCHERR 0x00800000 // ERROR: dcbz_l cache hit
+#define HID2_DNCERR 0x00400000 // ERROR: DMA access to normal cache
+#define HID2_DCMERR 0x00200000 // ERROR: DMA cache miss error
+#define HID2_DQOERR 0x00100000 // ERROR: DMA queue overflow
+#define HID2_DCHEE 0x00080000 // dcbz_l cache hit error enable
+#define HID2_DNCEE 0x00040000 // DMA access to normal cache error enable
+#define HID2_DCMEE 0x00020000 // DMA cache miss error error enable
+#define HID2_DQOEE 0x00010000 // DMA queue overflow error enable
+
+#define HID2_DMAQL_MASK 0x0F000000 // DMA queue length mask
+#define HID2_DMAQL_SHIFT 24 // DMA queue shift
+
+#define HID2_LSQE_BIT 0
+#define HID2_WPE_BIT 1
+#define HID2_PSE_BIT 2
+#define HID2_LCE_BIT 3
+
+#define HID2_DCHERR_BIT 8
+#define HID2_DNCERR_BIT 9
+#define HID2_DCMERR_BIT 10
+#define HID2_DQOERR_BIT 11
+#define HID2_DCHEE_BIT 12
+#define HID2_DNCEE_BIT 13
+#define HID2_DCMEE_BIT 14
+#define HID2_DQOEE_BIT 15
+
+#define GQR_LOAD_SCALE_MASK 0x3F000000 // load scale field
+#define GQR_LOAD_TYPE_MASK 0x00070000 // load type field
+#define GQR_STORE_SCALE_MASK 0x00003F00 // store scale field
+#define GQR_STORE_TYPE_MASK 0x00000007 // store type field
+
+typedef struct
+{
+ u32 _pad0 :2;
+ u32 loadScale :6;
+ u32 _pad1 :5;
+ u32 loadType :3;
+ u32 _pad2 :2;
+ u32 storeScale :6;
+ u32 _pad3 :5;
+ u32 storeType :3;
+} PPC_GQR_t;
+
+typedef union
+{
+ u32 val;
+ PPC_GQR_t f;
+} PPC_GQR_u;
+
+
+#define DMA_U_ADDR_MASK 0xFFFFFFE0 // Start addr in memory
+#define DMA_U_LEN_U_MASK 0x0000001F // lines to transfer (U)
+
+#define DMA_L_LC_ADDR_MASK 0xFFFFFFE0 // Start addr in LC
+#define DMA_L_LOAD 0x00000010 // 0 - store, 1 - load
+#define DMA_L_STORE 0x00000000 // 0 - store, 1 - load
+#define DMA_L_LEN_MASK 0x0000000C // lines to transfer (L)
+#define DMA_L_TRIGGER 0x00000002 // 0 - cmd inactive, 1 - cmd rdy
+#define DMA_L_FLUSH 0x00000001 // 1 - Flush DMA queue
+
+typedef struct
+{
+ u32 memAddr :27;
+ u32 dmaLenU :5;
+} PPC_DMA_U_t;
+
+typedef union
+{
+ u32 val;
+ PPC_DMA_U_t f;
+} PPC_DMA_U_u;
+
+
+typedef struct
+{
+ u32 lcAddr :27;
+ u32 dmaLd :1;
+ u32 dmaLenL :2;
+ u32 dmaTrigger :1;
+ u32 dmaFlush :1;
+} PPC_DMA_L_t;
+
+
+typedef union
+{
+ u32 val;
+ PPC_DMA_L_t f;
+} PPC_DMA_L_u;
+
+
+#define WPAR_ADDR 0xFFFFFFE0 // 32byte gather address
+#define WPAR_BNE 0x00000001 // Buffer not empty (R)
+
+#define SRR1_DMA_BIT 0x00200000
+#define SRR1_L2DP_BIT 0x00100000
+
+#define L2CR_L2E 0x80000000 // L2 Enable
+#define L2CR_L2PE 0x40000000 // L2 data parity generation and checking enable
+
+#define L2CR_L2SIZ_256K 0x10000000 // L2 size 256K
+#define L2CR_L2SIZ_512K 0x20000000 // L2 size 512
+#define L2CR_L2SIZ_1M 0x30000000 // L2 size 1M
+
+#define L2CR_L2CLK_1_0 0x02000000 // L2 clock ratio 1
+#define L2CR_L2CLK_1_5 0x04000000 // L2 clock ratio 1.5
+#define L2CR_L2CLK_2_0 0x08000000 // L2 clock ratio 2
+#define L2CR_L2CLK_2_5 0x0A000000 // L2 clock ratio 2.5
+#define L2CR_L2CLK_3_0 0x0C000000 // L2 clock ratio 3
+
+#define L2CR_RAM_FLOW_THRU_BURST 0x00000000 // L2 RAM type flow-through sync. burst SRAM
+#define L2CR_RAM_PIPELINE_BURST 0x01000000 // L2 RAM type pipelined sync. burst SRAM
+#define L2CR_RAM_PIPELINE_LATE 0x01800000 // L2 RAM type pipelined sync. late-write SRAM
+
+#define L2CR_L2DO 0x00400000 // Data only
+#define L2CR_L2I 0x00200000 // Global invalidate
+#define L2CR_L2CTL 0x00100000 // ZZ enable
+#define L2CR_L2WT 0x00080000 // L2 write through
+#define L2CR_L2TS 0x00040000 // L2 test support
+
+#define L2CR_L2OH_0_5 0x00000000 // L2 output hold 0.5 ns
+#define L2CR_L2OH_1_0 0x00010000 // L2 output hold 1.0 ns
+
+#define L2CR_L2SL 0x00008000 // L2 DLL slow
+#define L2CR_L2DF 0x00004000 // L2 differential clock
+#define L2CR_L2BYP 0x00002000 // L2 DLL bypass
+#define L2CR_L2CS 0x00000200 // L2 clock stop
+#define L2CR_L2DRO 0x00000100 // L2 DLL rollover checkstop enable
+#define L2CR_L2CTR_MASK 0x000000FE // L2 counter value mask
+#define L2CR_L2IP 0x00000001 // L2 global invalidate in progress
+
+#define MMCR0_DIS 0x80000000 // Disables counting unconditionally
+#define MMCR0_DP 0x40000000 // Disables counting while in supervisor mode
+#define MMCR0_DU 0x20000000 // Disables counting while in user mode
+#define MMCR0_DMS 0x10000000 // Disables counting while MSR[PM] is set
+#define MMCR0_DMR 0x08000000 // Disables counting while MSR[PM] is zero
+#define MMCR0_ENINT 0x04000000 // Enables performance monitor interrupt signaling
+#define MMCR0_DISCOUNT 0x02000000 // Disables counting of PMCn when a performance monitor interrupt is signaled or...
+#define MMCR0_RTCSELECT_MASK 0x01800000 // 64-bit time base, bit selection enable
+#define MMCR0_RTCSELECT_63 0x00000000 // Pick bit 63 to count
+#define MMCR0_RTCSELECT_55 0x00800000 // Pick bit 55 to count
+#define MMCR0_RTCSELECT_51 0x01000000 // Pick bit 51 to count
+#define MMCR0_RTCSELECT_47 0x01800000 // Pick bit 47 to count
+#define MMCR0_INTONBITTRANS 0x00400000 // Causes interrupt signaling on bit transition from off to on
+#define MMCR0_THRESHOLD_MASK 0x003F0000 // Threshold value
+#define MMCR0_THRESHOLD(n) ((n) << 16) // Threshold value (0 - 63)
+#define MMCR0_PMC1INTCONTROL 0x00008000 // Enables interrupt signaling due to PMC1 counter overflow
+#define MMCR0_PMC2INTCONTROL 0x00004000 // Enables interrupt signaling due to PMC2-PMC4 counter overflow
+#define MMCR0_PMCTRIGGER 0x00002000 // Can be used to trigger counting of PMC2-PMC4 after PMC1 has overflowed or...
+#define MMCR0_PMC1SELECT_MASK 0x00001FC0 // PMC1 input selector
+#define MMCR0_PMC2SELECT_MASK 0x0000003F // PMC2 input selector
+
+#define MMCR1_PMC3SELECT_MASK 0xF8000000 // PMC3 input selector
+#define MMCR1_PMC4SELECT_MASK 0x07C00000 // PMC4 input selector
+
+#define PMC1_OV 0x80000000 // Overflow
+#define PMC1_COUNTER 0x7FFFFFFF // Counter value
+#define PMC2_OV 0x80000000 // Overflow
+#define PMC2_COUNTER 0x7FFFFFFF // Counter value
+#define PMC3_OV 0x80000000 // Overflow
+#define PMC3_COUNTER 0x7FFFFFFF // Counter value
+#define PMC4_OV 0x80000000 // Overflow
+#define PMC4_COUNTER 0x7FFFFFFF // Counter value
+
+/*---------------------------------------------------------------------------*
+ PMC1 Events
+ *---------------------------------------------------------------------------*/
+#define MMCR0_PMC1_HOLD 0x00000000 // Register holds current value
+#define MMCR0_PMC1_CYCLE 0x00000040 // Processor cycles
+#define MMCR0_PMC1_INSTRUCTION 0x00000080 // # of instructions completed.
+#define MMCR0_PMC1_TRANSITION 0x000000C0 // # of transitions for 0 to 1
+#define MMCR0_PMC1_DISPATCHED 0x00000100 // # of instructions dispatched
+#define MMCR0_PMC1_EIEIO 0x00000140 // # of eieio instructions completed
+#define MMCR0_PMC1_ITLB_CYCLE 0x00000180 // # of cycles spent performing table search op. for the ITLB
+#define MMCR0_PMC1_L2_HIT 0x000001C0 // # of access that hit the L2.
+#define MMCR0_PMC1_EA 0x00000200 // # of valid instruction EAs delivered to the memory subsystem
+#define MMCR0_PMC1_IABR 0x00000240 // # of time the address of an instruction matches the IABR
+#define MMCR0_PMC1_L1_MISS 0x00000280 // # of loads that miss the L1
+#define MMCR0_PMC1_Bx_UNRESOLVED 0x000002C0 // # of branches that are unresolved when processed
+#define MMCR0_PMC1_Bx_STALL_CYCLE 0x00000300 // # of cycles that dispatcher stalls due to a second
+ // unresolved branch in the instruction stream
+#define MMCR0_PMC1_IC_FETCH_MISS 0x00000340 // # of times an instruction fetch missed the L1 Icache
+#define MMCR0_PMC2_HOLD 0x00000000 // Register holds current value
+#define MMCR0_PMC2_CYCLE 0x00000001 // Processor cycles
+#define MMCR0_PMC2_INSTRUCTION 0x00000002 // # of instructions completed
+#define MMCR0_PMC2_TRANSITION 0x00000003 // # of time-base (lower) bit transitions
+#define MMCR0_PMC2_DISPATCHED 0x00000004 // # of instructions dispatched
+#define MMCR0_PMC2_IC_MISS 0x00000005 // # of L1 instruction cache misses
+#define MMCR0_PMC2_ITLB_MISS 0x00000006 // # of ITLB misses
+#define MMCR0_PMC2_L2_I_MISS 0x00000007 // # of L2 instruction misses
+#define MMCR0_PMC2_Bx_FALL_TROUGH 0x00000008 // # of fall-through branches
+#define MMCR0_PMC2_PR_SWITCH 0x00000009 // # of MSR[PR] bit toggles
+#define MMCR0_PMC2_RESERVED_LOAD 0x0000000A // # of reserved loads completed
+#define MMCR0_PMC2_LOAD_STORE 0x0000000B // # of completed loads and stores
+#define MMCR0_PMC2_SNOOP 0x0000000C // # of snoops
+#define MMCR0_PMC2_L1_CASTOUT 0x0000000D // # of L1 castouts to L2
+#define MMCR0_PMC2_SYSTEM 0x0000000E // # of completed system unit instructions
+#define MMCR0_PMC2_IC_FETCH_MISS 0x0000000F // # of instruction fetch misses in the L1
+#define MMCR0_PMC2_Bx_OUT_OF_ORDER 0x00000010 // # of branches allowing out-of-order execution
+
+/*---------------------------------------------------------------------------*
+ PMC3 Events
+ *---------------------------------------------------------------------------*/
+#define MMCR1_PMC3_HOLD 0x00000000 // Register holds current value
+#define MMCR1_PMC3_CYCLE 0x08000000 // Processor cycles
+#define MMCR1_PMC3_INSTRUCTION 0x10000000 // # of instructions completed
+#define MMCR1_PMC3_TRANSITION 0x18000000 // # of time-base (lower) bit transitions
+#define MMCR1_PMC3_DISPATCHED 0x20000000 // # of instructions dispatched
+#define MMCR1_PMC3_DC_MISS 0x28000000 // # of L1 data cache misses
+#define MMCR1_PMC3_DTLB_MISS 0x30000000 // # of DTLB misses
+#define MMCR1_PMC3_L2_D_MISS 0x38000000 // # of L2 data misses
+#define MMCR1_PMC3_Bx_TAKEN 0x40000000 // # predicted branches that were taken
+#define MMCR1_PMC3_PM_SWITCH 0x48000000 // # of transitions between marked and unmarked processes
+#define MMCR1_PMC3_COND_STORE 0x50000000 // # of store conditional instructions completed
+#define MMCR1_PMC3_FPU 0x58000000 // # of instructions completed from the FPU
+#define MMCR1_PMC3_L2_SNOOP_CASTOUT 0x60000000 // # of L2 castout caused by snoops to modified lines
+#define MMCR1_PMC3_L2_HIT 0x68000000 // # of cache operations that hit in the L2 cache
+#define MMCR1_PMC3_L1_MISS_CYCLE 0x78000000 // # of cycles generated by L1 load misses
+#define MMCR1_PMC3_Bx_SECOND 0x80000000 // # of branches in the second speculative branch
+ // resolved correctly
+#define MMCR1_PMC3_BPU_LR_CR 0x88000000 // # of cycles the BPU stalls due to LR or CR unresolved
+ // dependencies
+
+#define MMCR1_PMC4_HOLD 0x00000000 // Register holds current value
+#define MMCR1_PMC4_CYCLE 0x00400000 // Processor cycles
+#define MMCR1_PMC4_INSTRUCTION 0x00800000 // # of instructions completed
+#define MMCR1_PMC4_TRANSITION 0x00C00000 // # of time-base (lower) bit transitions
+#define MMCR1_PMC4_DISPATCHED 0x01000000 // # of instructions dispatched
+#define MMCR1_PMC4_L2_CASTOUT 0x01400000 // # of L2 castouts
+#define MMCR1_PMC4_DTLB_CYCLE 0x01800000 // # of cycles spent performing table searches for DTLB accesses
+#define MMCR1_PMC4_Bx_MISSED 0x02000000 // # of mispredicted branches
+#define MMCR1_PMC4_COND_STORE_INT 0x02800000 // # of store conditional instructions completed
+ // with reservation intact
+#define MMCR1_PMC4_SYNC 0x02C00000 // # of completed sync instructions
+#define MMCR1_PMC4_SNOOP_RETRY 0x03000000 // # of snoop request retries
+#define MMCR1_PMC4_INTEGER 0x03400000 // # of completed integer operations
+#define MMCR1_PMC4_BPU_THIRD 0x03800000 // # of cycles the BPU cannot process new branches
+ // due to having two unresolved branches
+#define MMCR1_PMC4_DC_MISS 0x07C00000 // # of L1 data cache misses
+
+/*---------------------------------------------------------------------------*
+ FPSCR bits
+ *---------------------------------------------------------------------------*/
+#ifndef FPSCR_FX
+#define FPSCR_FX 0x80000000 // Exception summary
+#define FPSCR_FEX 0x40000000 // Enabled exception summary
+#define FPSCR_VX 0x20000000 // Invalid operation
+#define FPSCR_OX 0x10000000 // Overflow exception
+#define FPSCR_UX 0x08000000 // Underflow exception
+#define FPSCR_ZX 0x04000000 // Zero divide exception
+#define FPSCR_XX 0x02000000 // Inexact exception
+#define FPSCR_VXSNAN 0x01000000 // SNaN
+#define FPSCR_VXISI 0x00800000 // Infinity - Infinity
+#define FPSCR_VXIDI 0x00400000 // Infinity / Infinity
+#define FPSCR_VXZDZ 0x00200000 // 0 / 0
+#define FPSCR_VXIMZ 0x00100000 // Infinity * 0
+#define FPSCR_VXVC 0x00080000 // Invalid compare
+#define FPSCR_FR 0x00040000 // Fraction rounded
+#define FPSCR_FI 0x00020000 // Fraction inexact
+#define FPSCR_VXSOFT 0x00000400 // Software request
+#define FPSCR_VXSQRT 0x00000200 // Invalid square root
+#define FPSCR_VXCVI 0x00000100 // Invalid integer convert
+#define FPSCR_VE 0x00000080 // Invalid operation exception enable
+#define FPSCR_OE 0x00000040 // Overflow exception enable
+#define FPSCR_UE 0x00000020 // Underflow exception enable
+#define FPSCR_ZE 0x00000010 // Zero divide exception enable
+#define FPSCR_XE 0x00000008 // Inexact exception enable
+#define FPSCR_NI 0x00000004 // Non-IEEE mode
+#endif
+
+#ifndef FPSCR_FX_BIT
+#define FPSCR_FX_BIT 0 // Exception summary
+#define FPSCR_FEX_BIT 1 // Enabled exception summary
+#define FPSCR_VX_BIT 2 // Invalid operation
+#define FPSCR_OX_BIT 3 // Overflow exception
+#define FPSCR_UX_BIT 4 // Underflow exception
+#define FPSCR_ZX_BIT 5 // Zero divide exception
+#define FPSCR_XX_BIT 6 // Inexact exception
+#define FPSCR_VXSNAN_BIT 7 // SNaN
+#define FPSCR_VXISI_BIT 8 // Infinity - Infinity
+#define FPSCR_VXIDI_BIT 9 // Infinity / Infinity
+#define FPSCR_VXZDZ_BIT 10 // 0 / 0
+#define FPSCR_VXIMZ_BIT 11 // Infinity * 0
+#define FPSCR_VXVC_BIT 12 // Invalid compare
+#define FPSCR_FR_BIT 13 // Fraction rounded
+#define FPSCR_FI_BIT 14 // Fraction inexact
+#define FPSCR_VXSOFT_BIT 21 // Software request
+#define FPSCR_VXSQRT_BIT 22 // Invalid square root
+#define FPSCR_VXCVI_BIT 23 // Invalid integer convert
+#define FPSCR_VE_BIT 24 // Invalid operation exception enable
+#define FPSCR_OE_BIT 25 // Overflow exception enable
+#define FPSCR_UE_BIT 26 // Underflow exception enable
+#define FPSCR_ZE_BIT 27 // Zero divide exception enable
+#define FPSCR_XE_BIT 28 // Inexact exception enable
+#define FPSCR_NI_BIT 29 // Non-IEEE mode
+#endif
+
+union FpscrUnion {
+ f64 f;
+ struct {
+ u32 fpscr_pad;
+ u32 fpscr;
+ } u;
+};
+
+// PPCArch
+u32 PPCMfmsr();
+void PPCMtmsr(u32 newMSR);
+u32 PPCOrMsr(u32 value);
+u32 PPCMfhid0();
+void PPCMthid0(u32 newHID0);
+u32 PPCMfl2cr();
+void PPCMtl2cr(u32 newL2cr);
+void PPCMtdec(u32 newDec);
+void PPCSync();
+void PPCHalt();
+u32 PPCMffpscr();
+void PPCMtfpscr(u32 newFPSCR);
+u32 PPCMfhid2();
+void PPCMthid2(u32 newhid2);
+u32 PPCMfwpar();
+void PPCMtwpar(u32 newwpar);
+void PPCEnableSpeculation();
+void PPCDisableSpeculation();
+void PPCSetFpIEEEMode();
+void PPCSetFpNonIEEEMode();
+u32 PPCMfpmc4();
+u32 PPCMfpmc3();
+u32 PPCMfpmc1();
+void PPCMtpmc1(u32 newPmc1);
+void PPCMtpmc2(u32 newPmc1);
+void PPCMtpmc3(u32 newPmc1);
+void PPCMtpmc4(u32 newPmc1);
+void PPCMtmmcr0(u32 newMmcr0);
+void PPCMtmmcr1(u32 newMmcr0);
+void PPCMtdmaU(u32 newdmau);
+void PPCMtdmaL(u32 newdmal);
+u32 PPCMfdec(void);
+u32 PPCMfpmc2(void);
+u32 PPCAndMsr(u32 value);
+u32 PPCAndCMsr(u32 value);
+u32 PPCMfhid1();
+void PPCEieio();
+u32 PPCMfmmcr0();
+u32 PPCMfmmcr1();
+u32 PPCMfpmc2();
+u32 PPCMfsia();
+void PPCMtsia(u32 newSia);
+u32 PPCMfdmaL();
+u32 PPCMfpvr();
+u32 PPCMfdmaU();
+
+// PPCPm
+void PMBegin(void);
+void PMEnd(void);
+void PMCycles(void);
+void PML1FetchMisses(void);
+void PML1MissCycles(void);
+void PMInstructions(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_PPCARCH
diff --git a/include/revolution/db.h b/include/revolution/db.h
new file mode 100644
index 0000000000..2282c261da
--- /dev/null
+++ b/include/revolution/db.h
@@ -0,0 +1,22 @@
+#ifndef _REVOLUTION_DB_H_
+#define _REVOLUTION_DB_H_
+
+#include <revolution/types.h>
+#include <revolution/db/DBInterface.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OS_DBINTERFACE_ADDR 0x00000040
+
+BOOL DBIsDebuggerPresent(void);
+void DBPrintf(char* str, ...);
+s32 DBQueryData(void);
+u32 DBRead(u8*, u32);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_DB_H_
diff --git a/include/revolution/db/DBInterface.h b/include/revolution/db/DBInterface.h
new file mode 100644
index 0000000000..e350326a2e
--- /dev/null
+++ b/include/revolution/db/DBInterface.h
@@ -0,0 +1,31 @@
+#ifndef _REVOLUTION_DBINTERFACE_H_
+#define _REVOLUTION_DBINTERFACE_H_
+
+#include <revolution/os.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct DBInterface {
+ u32 bPresent;
+ u32 exceptionMask;
+ void (*ExceptionDestination)(void);
+ void* exceptionReturn;
+} DBInterface;
+
+extern DBInterface* __DBInterface;
+
+void DBInit(void);
+void DBInitComm(int* inputFlagPtr, int* mtrCallback);
+void __DBExceptionDestination(void);
+void __DBExceptionDestinationAux(void);
+BOOL __DBIsExceptionMarked(__OSException exception);
+void __DBMarkException(u8 exception, int value);
+void __DBSetPresent(u32 value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/dsp.h b/include/revolution/dsp.h
new file mode 100644
index 0000000000..e8fc5762ae
--- /dev/null
+++ b/include/revolution/dsp.h
@@ -0,0 +1,57 @@
+#ifndef _REVOLUTION_DSP_H_
+#define _REVOLUTION_DSP_H_
+
+#include <revolution/os.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*DSPCallback)(void* task);
+typedef struct STRUCT_DSP_TASK DSPTaskInfo;
+
+typedef struct STRUCT_DSP_TASK {
+ /* 0x00 */ volatile u32 state;
+ /* 0x04 */ volatile u32 priority;
+ /* 0x08 */ volatile u32 flags;
+ /* 0x0C */ u16* iram_mmem_addr;
+ /* 0x10 */ u32 iram_length;
+ /* 0x14 */ u32 iram_addr;
+ /* 0x18 */ u16* dram_mmem_addr;
+ /* 0x1C */ u32 dram_length;
+ /* 0x20 */ u32 dram_addr;
+ /* 0x24 */ u16 dsp_init_vector;
+ /* 0x26 */ u16 dsp_resume_vector;
+ /* 0x28 */ DSPCallback init_cb;
+ /* 0x2C */ DSPCallback res_cb;
+ /* 0x30 */ DSPCallback done_cb;
+ /* 0x34 */ DSPCallback req_cb;
+ /* 0x38 */ DSPTaskInfo* next;
+ /* 0x3C */ DSPTaskInfo* prev;
+ /* 0x40 */ OSTime t_context;
+ /* 0x48 */ OSTime t_task;
+} DSPTaskInfo;
+
+u32 DSPCheckMailToDSP(void);
+u32 DSPCheckMailFromDSP(void);
+u32 DSPReadCPUToDSPMbox(void);
+u32 DSPReadMailFromDSP(void);
+void DSPSendMailToDSP(u32 mail);
+void DSPAssertInt(void);
+void DSPInit(void);
+BOOL DSPCheckInit(void);
+void DSPReset(void);
+void DSPHalt(void);
+void DSPUnhalt(void);
+u32 DSPGetDMAStatus(void);
+__declspec(weak) DSPTaskInfo* DSPAddTask(DSPTaskInfo* task);
+DSPTaskInfo* DSPCancelTask(DSPTaskInfo* task);
+DSPTaskInfo* DSPAssertTask(DSPTaskInfo* task);
+
+DSPTaskInfo* __DSPGetCurrentTask(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/dvd.h b/include/revolution/dvd.h
new file mode 100644
index 0000000000..67e8bd21be
--- /dev/null
+++ b/include/revolution/dvd.h
@@ -0,0 +1,236 @@
+#ifndef _REVOLUTION_DVD_H_
+#define _REVOLUTION_DVD_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DVD_ASSERTMSGLINE(line, cond, msg) \
+ if (!(cond)) \
+ OSPanic(__FILE__, line, msg)
+
+#define DVD_ASSERTMSG1LINE(line, cond, msg, arg1) \
+ if (!(cond)) \
+ OSPanic(__FILE__, line, msg, arg1)
+
+#define DVD_ASSERTMSG2LINE(line, cond, msg, arg1, arg2) \
+ if (!(cond)) \
+ OSPanic(__FILE__, line, msg, arg1, arg2)
+
+#define DVD_RESULT_GOOD 0
+#define DVD_RESULT_FATAL_ERROR -1
+#define DVD_RESULT_IGNORED -2
+#define DVD_RESULT_CANCELED -6
+
+#define DVD_STATE_FATAL_ERROR -1
+#define DVD_STATE_END 0
+#define DVD_STATE_BUSY 1
+#define DVD_STATE_WAITING 2
+#define DVD_STATE_COVER_CLOSED 3
+#define DVD_STATE_NO_DISK 4
+#define DVD_STATE_COVER_OPEN 5
+#define DVD_STATE_WRONG_DISK 6
+#define DVD_STATE_MOTOR_STOPPED 7
+#define DVD_STATE_PAUSING 8
+#define DVD_STATE_IGNORED 9
+#define DVD_STATE_CANCELED 10
+#define DVD_STATE_RETRY 11
+
+#define DVD_MIN_TRANSFER_SIZE 32
+
+// could be bitfields
+#define DVD_INTTYPE_TC 1
+#define DVD_INTTYPE_DE 2
+// unk type 3
+#define DVD_INTTYPE_CVR 4
+
+// DVD Commands
+#define DVD_COMMAND_NONE 0
+#define DVD_COMMAND_READ 1
+#define DVD_COMMAND_SEEK 2
+#define DVD_COMMAND_CHANGE_DISK 3
+#define DVD_COMMAND_BSREAD 4
+#define DVD_COMMAND_READID 5
+#define DVD_COMMAND_INITSTREAM 6
+#define DVD_COMMAND_CANCELSTREAM 7
+#define DVD_COMMAND_STOP_STREAM_AT_END 8
+#define DVD_COMMAND_REQUEST_AUDIO_ERROR 9
+#define DVD_COMMAND_REQUEST_PLAY_ADDR 10
+#define DVD_COMMAND_REQUEST_START_ADDR 11
+#define DVD_COMMAND_REQUEST_LENGTH 12
+#define DVD_COMMAND_AUDIO_BUFFER_CONFIG 13
+#define DVD_COMMAND_INQUIRY 14
+#define DVD_COMMAND_BS_CHANGE_DISK 15
+#define DVD_COMMAND_UNK_16 16
+
+typedef struct DVDDiskID {
+ char gameName[4];
+ char company[2];
+ u8 diskNumber;
+ u8 gameVersion;
+ u8 streaming;
+ u8 streamingBufSize;
+ u8 padding[22];
+} DVDDiskID;
+
+typedef struct DVDCommandBlock DVDCommandBlock;
+typedef void (*DVDCBCallback)(s32 result, DVDCommandBlock* block);
+typedef void (*DVDLowCallback)(u32);
+
+typedef void (*DVDCommandCheckerCallback)(u32);
+typedef void (*DVDCommandChecker)(DVDCommandBlock*, DVDCommandCheckerCallback);
+
+struct DVDCommandBlock {
+ /* 0x00 */ DVDCommandBlock* next;
+ /* 0x04 */ DVDCommandBlock* prev;
+ /* 0x08 */ u32 command;
+ /* 0x0C */ s32 state;
+ /* 0x10 */ u32 offset;
+ /* 0x14 */ u32 length;
+ /* 0x18 */ void* addr;
+ /* 0x1C */ u32 currTransferSize;
+ /* 0x20 */ u32 transferredSize;
+ /* 0x24 */ DVDDiskID* id;
+ /* 0x28 */ DVDCBCallback callback;
+ /* 0x2C */ void* userData;
+};
+
+typedef struct DVDFileInfo DVDFileInfo;
+typedef void (*DVDCallback)(s32 result, DVDFileInfo *fileInfo);
+struct DVDFileInfo {
+ /* 0x00 */ DVDCommandBlock cb;
+ /* 0x30 */ u32 startAddr;
+ /* 0x34 */ u32 length;
+ /* 0x38 */ DVDCallback callback;
+};
+
+typedef struct {
+ u32 entryNum;
+ u32 location;
+ u32 next;
+} DVDDir;
+
+typedef struct {
+ u32 entryNum;
+ BOOL isDir;
+ char* name;
+} DVDDirEntry;
+
+typedef struct DVDBB2 {
+ /* 0x00 */ u32 bootFilePosition;
+ /* 0x04 */ u32 FSTPosition;
+ /* 0x08 */ u32 FSTLength;
+ /* 0x0C */ u32 FSTMaxLength;
+ /* 0x10 */ void* FSTAddress;
+ /* 0x14 */ u32 userPosition;
+ /* 0x18 */ u32 userLength;
+ /* 0x1C */ u32 padding0;
+} DVDBB2;
+
+typedef struct DVDDriveInfo {
+ /* 0x00 */ u16 revisionLevel;
+ /* 0x02 */ u16 deviceCode;
+ /* 0x04 */ u32 releaseDate;
+ /* 0x08 */ u8 padding[24];
+} DVDDriveInfo;
+
+// DVD
+void DVDInit(void);
+int DVDReadAbsAsyncPrio(DVDCommandBlock* block, void* addr, s32 length, s32 offset, DVDCBCallback callback, s32 prio);
+int DVDSeekAbsAsyncPrio(DVDCommandBlock* block, s32 offset, DVDCBCallback callback, s32 prio);
+int DVDReadAbsAsyncForBS(DVDCommandBlock* block, void* addr, s32 length, s32 offset, DVDCBCallback callback);
+int DVDReadDiskID(DVDCommandBlock* block, DVDDiskID* diskID, DVDCBCallback callback);
+int DVDPrepareStreamAbsAsync(DVDCommandBlock* block, u32 length, u32 offset, DVDCBCallback callback);
+int DVDCancelStreamAsync(DVDCommandBlock* block, DVDCBCallback callback);
+s32 DVDCancelStream(DVDCommandBlock* block);
+int DVDStopStreamAtEndAsync(DVDCommandBlock* block, DVDCBCallback callback);
+s32 DVDStopStreamAtEnd(DVDCommandBlock* block);
+int DVDGetStreamErrorStatusAsync(DVDCommandBlock* block, DVDCBCallback callback);
+s32 DVDGetStreamErrorStatus(DVDCommandBlock* block);
+int DVDGetStreamPlayAddrAsync(DVDCommandBlock* block, DVDCBCallback callback);
+s32 DVDGetStreamPlayAddr(DVDCommandBlock* block);
+int DVDGetStreamStartAddrAsync(DVDCommandBlock* block, DVDCBCallback callback);
+s32 DVDGetStreamStartAddr(DVDCommandBlock* block);
+int DVDGetStreamLengthAsync(DVDCommandBlock* block, DVDCBCallback callback);
+s32 DVDGetStreamLength(DVDCommandBlock* block);
+int DVDChangeDiskAsyncForBS(DVDCommandBlock* block, DVDCBCallback callback);
+int DVDChangeDiskAsync(DVDCommandBlock* block, DVDDiskID* id, DVDCBCallback callback);
+s32 DVDChangeDisk(DVDCommandBlock* block, DVDDiskID* id);
+int DVDStopMotorAsync(DVDCommandBlock* block, DVDCBCallback callback);
+s32 DVDStopMotor(DVDCommandBlock* block);
+int DVDInquiryAsync(DVDCommandBlock* block, DVDDriveInfo* info, DVDCBCallback callback);
+s32 DVDInquiry(DVDCommandBlock* block, DVDDriveInfo* info);
+void DVDReset(void);
+int DVDResetRequired(void);
+s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block);
+s32 DVDGetDriveStatus(void);
+BOOL DVDSetAutoInvalidation(BOOL autoInval);
+void DVDPause(void);
+void DVDResume(void);
+int DVDCancelAsync(DVDCommandBlock* block, DVDCBCallback callback);
+s32 DVDCancel(volatile DVDCommandBlock* block);
+int DVDCancelAllAsync(DVDCBCallback callback);
+s32 DVDCancelAll(void);
+DVDDiskID* DVDGetCurrentDiskID(void);
+BOOL DVDCheckDisk(void);
+
+// DVD FATAL
+int DVDSetAutoFatalMessaging(BOOL enable);
+
+// DVD FS
+s32 DVDConvertPathToEntrynum(const char* pathPtr);
+BOOL DVDFastOpen(s32 entrynum, DVDFileInfo* fileInfo);
+BOOL DVDOpen(const char* fileName, DVDFileInfo* fileInfo);
+BOOL DVDClose(DVDFileInfo* fileInfo);
+BOOL DVDGetCurrentDir(char* path, u32 maxlen);
+BOOL DVDChangeDir(const char* dirName);
+BOOL DVDReadAsyncPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset,
+ DVDCallback callback, s32 prio);
+s32 DVDReadPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, s32 prio);
+int DVDSeekAsyncPrio(DVDFileInfo* fileInfo, s32 offset, void (* callback)(s32, DVDFileInfo *), s32 prio);
+s32 DVDSeekPrio(DVDFileInfo* fileInfo, s32 offset, s32 prio);
+s32 DVDGetFileInfoStatus(const DVDFileInfo* fileInfo);
+BOOL DVDFastOpenDir(s32 entrynum, DVDDir* dir);
+int DVDOpenDir(const char* dirName, DVDDir* dir);
+int DVDReadDir(DVDDir* dir, DVDDirEntry* dirent);
+int DVDCloseDir(DVDDir* dir);
+void DVDRewindDir(DVDDir* dir);
+void* DVDGetFSTLocation(void);
+BOOL DVDPrepareStreamAsync(DVDFileInfo* fileInfo, u32 length, u32 offset, DVDCallback callback);
+s32 DVDPrepareStream(DVDFileInfo* fileInfo, u32 length, u32 offset);
+s32 DVDGetTransferredSize(DVDFileInfo* fileinfo);
+
+#define DVDReadAsync(fileInfo, addr, length, offset, callback) \
+ DVDReadAsyncPrio((fileInfo), (addr), (length), (offset), (callback), 2)
+
+// DVD ID UTILS
+int DVDCompareDiskID(const DVDDiskID* id1, const DVDDiskID* id2);
+DVDDiskID* DVDGenerateDiskID(DVDDiskID* id, const char* game, const char* company, u8 diskNum, u8 version);
+
+// DVD LOW
+BOOL DVDLowRead(void* addr, u32 length, u32 offset, DVDLowCallback callback);
+BOOL DVDLowSeek(u32 offset, DVDLowCallback callback);
+BOOL DVDLowWaitCoverClose(DVDLowCallback callback);
+BOOL DVDLowReadDiskID(DVDDiskID* diskID, DVDLowCallback callback);
+BOOL DVDLowStopMotor(DVDLowCallback callback);
+BOOL DVDLowRequestError(DVDLowCallback callback);
+BOOL DVDLowInquiry(DVDDriveInfo* info, DVDLowCallback callback);
+BOOL DVDLowAudioStream(u32 subcmd, u32 length, u32 offset, DVDLowCallback callback);
+BOOL DVDLowRequestAudioStatus(u32 subcmd, DVDLowCallback callback);
+BOOL DVDLowAudioBufferConfig(BOOL enable, u32 size, DVDLowCallback callback);
+void DVDLowReset(void);
+DVDLowCallback DVDLowSetResetCoverCallback(DVDLowCallback callback);
+BOOL DVDLowBreak(void);
+DVDLowCallback DVDLowClearCallback(void);
+u32 DVDLowGetCoverStatus(void);
+
+// DVD QUEUE
+void DVDDumpWaitingQueue(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/exi.h b/include/revolution/exi.h
new file mode 100644
index 0000000000..9672a30aa6
--- /dev/null
+++ b/include/revolution/exi.h
@@ -0,0 +1,103 @@
+#ifndef _REVOLUTION_EXI_H_
+#define _REVOLUTION_EXI_H_
+
+#include <revolution/os.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define EXI_MEMORY_CARD_59 0x00000004
+#define EXI_MEMORY_CARD_123 0x00000008
+#define EXI_MEMORY_CARD_251 0x00000010
+#define EXI_MEMORY_CARD_507 0x00000020
+
+#define EXI_MEMORY_CARD_1019 0x00000040
+#define EXI_MEMORY_CARD_2043 0x00000080
+
+#define EXI_MEMORY_CARD_1019A 0x00000140
+#define EXI_MEMORY_CARD_1019B 0x00000240
+#define EXI_MEMORY_CARD_1019C 0x00000340
+#define EXI_MEMORY_CARD_1019D 0x00000440
+#define EXI_MEMORY_CARD_1019E 0x00000540
+#define EXI_MEMORY_CARD_1019F 0x00000640
+#define EXI_MEMORY_CARD_1019G 0x00000740
+
+#define EXI_MEMORY_CARD_2043A 0x00000180
+#define EXI_MEMORY_CARD_2043B 0x00000280
+#define EXI_MEMORY_CARD_2043C 0x00000380
+#define EXI_MEMORY_CARD_2043D 0x00000480
+#define EXI_MEMORY_CARD_2043E 0x00000580
+#define EXI_MEMORY_CARD_2043F 0x00000680
+#define EXI_MEMORY_CARD_2043G 0x00000780
+
+#define EXI_USB_ADAPTER 0x01010000
+#define EXI_NPDP_GDEV 0x01020000
+
+#define EXI_MODEM 0x02020000
+#define EXI_ETHER 0x04020200
+#define EXI_MIC 0x04060000
+#define EXI_AD16 0x04120000
+#define EXI_RS232C 0x04040404
+#define EXI_ETHER_VIEWER 0x04220001
+#define EXI_STREAM_HANGER 0x04130000
+
+#define EXI_MARLIN 0x03010000
+
+#define EXI_IS_VIEWER 0x05070000
+
+#define EXI_READ 0
+#define EXI_WRITE 1
+
+#define EXI_FREQ_1M 0
+#define EXI_FREQ_2M 1
+#define EXI_FREQ_4M 2
+#define EXI_FREQ_8M 3
+#define EXI_FREQ_16M 4
+#define EXI_FREQ_32M 5
+
+typedef void (*EXICallback)(s32 chan, OSContext* context);
+typedef struct EXIControl {
+ EXICallback exiCallback;
+ EXICallback tcCallback;
+ EXICallback extCallback;
+ volatile u32 state;
+ int immLen;
+ u8* immBuf;
+ u32 dev;
+ u32 id;
+ s32 idTime;
+ int items;
+ struct {
+ u32 dev;
+ EXICallback callback;
+ } queue[3];
+} EXIControl;
+
+EXICallback EXISetExiCallback(s32 channel, EXICallback callback);
+
+void EXIInit(void);
+BOOL EXILock(s32 channel, u32 device, EXICallback callback);
+BOOL EXIUnlock(s32 channel);
+BOOL EXISelect(s32 channel, u32 device, u32 frequency);
+BOOL EXIDeselect(s32 channel);
+BOOL EXIImm(s32 channel, void* buffer, s32 length, u32 type, EXICallback callback);
+BOOL EXIImmEx(s32 channel, void* buffer, s32 length, u32 type);
+BOOL EXIDma(s32 channel, void* buffer, s32 length, u32 type, EXICallback callback);
+BOOL EXISync(s32 channel);
+BOOL EXIProbe(s32 channel);
+s32 EXIProbeEx(s32 channel);
+BOOL EXIAttach(s32 channel, EXICallback callback);
+BOOL EXIDetach(s32 channel);
+u32 EXIGetState(s32 channel);
+s32 EXIGetID(s32 channel, u32 device, u32* id);
+void EXIProbeReset(void);
+int EXISelectSD(s32 chan, u32 dev, u32 freq);
+s32 EXIGetType(s32 chan, u32 dev, u32* type);
+char* EXIGetTypeString(u32 type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/fake_tgmath.h b/include/revolution/fake_tgmath.h
new file mode 100644
index 0000000000..41a982106d
--- /dev/null
+++ b/include/revolution/fake_tgmath.h
@@ -0,0 +1,66 @@
+#pragma cplusplus on
+
+extern inline float sqrtf(float x) {
+ static const double _half=.5;
+ static const double _three=3.0;
+ volatile float y;
+ if(x > 0.0f) {
+ double guess = __frsqrte((double)x); // returns an approximation to
+ guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits
+ guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits
+ guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
+ y=(float)(x*guess);
+ return y ;
+ }
+ return x ;
+}
+
+extern inline float sqrt(float x) {
+ static const double _half=.5;
+ static const double _three=3.0;
+ volatile float y;
+ if(x > 0.0f) {
+ double guess = __frsqrte((double)x); // returns an approximation to
+ guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits
+ guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits
+ guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
+ guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
+
+ y=(float)(x*guess);
+ return y ;
+ }
+ return x ;
+}
+
+extern inline float fabs(float x) {
+#if __MIPS__
+ return fabsf(x);
+#else
+ (*(int*)&x)&=0x7fffffff;
+ return x;
+#endif
+}
+
+extern inline float fabsf(float x) {
+ return __fabsf(x);
+}
+
+extern float cosf(float);
+extern inline float cos(float x) {
+ return cosf(x);
+}
+
+inline float floor(float x) {
+ int i=(int)x;
+ float y=x-(float)i;
+
+ if(!y || x > 8388608.0f)
+ return x ; // x is already an int
+
+ if(x < 0)
+ return (float)--i;
+ // x < 0 -> int conversion of x above rounded toward zero(so decrement)
+ return (float)i;
+}
+
+#pragma cplusplus reset
diff --git a/include/revolution/gd.h b/include/revolution/gd.h
new file mode 100644
index 0000000000..bb7a328812
--- /dev/null
+++ b/include/revolution/gd.h
@@ -0,0 +1,14 @@
+#ifndef _REVOLUTION_GD_H_
+#define _REVOLUTION_GD_H_
+
+#include <revolution/gd/GDBase.h>
+#include <revolution/gd/GDFile.h>
+#include <revolution/gd/GDGeometry.h>
+#include <revolution/gd/GDIndirect.h>
+#include <revolution/gd/GDLight.h>
+#include <revolution/gd/GDPixel.h>
+#include <revolution/gd/GDTev.h>
+#include <revolution/gd/GDTexture.h>
+#include <revolution/gd/GDTransform.h>
+
+#endif
diff --git a/include/revolution/gd/GDBase.h b/include/revolution/gd/GDBase.h
new file mode 100644
index 0000000000..02427ac679
--- /dev/null
+++ b/include/revolution/gd/GDBase.h
@@ -0,0 +1,151 @@
+#ifndef _REVOLUTION_GD_BASE_H
+#define _REVOLUTION_GD_BASE_H
+
+#include <revolution/types.h>
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXCommandList.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*GDOverflowCb)(void);
+
+typedef struct _GDLObj {
+ u8* start;
+ u32 length;
+ u8* ptr;
+ u8* top;
+} GDLObj;
+
+extern GDLObj* __GDCurrentDL;
+
+void GDInitGDLObj(GDLObj* dl, void* start, u32 length);
+void GDFlushCurrToMem(void);
+void GDPadCurr32(void);
+void GDOverflowed(void);
+void GDSetOverflowCallback(GDOverflowCb callback);
+GDOverflowCb GDGetOverflowCallback(void);
+
+inline static void GDOverflowCheck(u32 size) {
+ if (__GDCurrentDL->ptr + size > __GDCurrentDL->top) {
+ GDOverflowed();
+ }
+}
+
+inline static void __GDWrite(u8 data) {
+ *__GDCurrentDL->ptr++ = data;
+}
+
+inline static void GDWrite_u8(u8 data) {
+ GDOverflowCheck(sizeof(u8));
+ __GDWrite(data);
+}
+
+inline static void GDWrite_u16(u16 data) {
+ GDOverflowCheck(sizeof(u16));
+ __GDWrite((u8)((data >> 8)));
+ __GDWrite((u8)((data >> 0) & 0xFF));
+}
+
+inline static void GDWrite_u24(u32 data) {
+ GDOverflowCheck(3);
+ __GDWrite((u8)((data >> 16) & 0xFF));
+ __GDWrite((u8)((data >> 8) & 0xFF));
+ __GDWrite((u8)((data >> 0) & 0xFF));
+}
+
+inline static void GDWrite_u32(u32 data) {
+ GDOverflowCheck(sizeof(u32));
+ __GDWrite((u8)((data >> 24) & 0xFF));
+ __GDWrite((u8)((data >> 16) & 0xFF));
+ __GDWrite((u8)((data >> 8) & 0xFF));
+ __GDWrite((u8)((data >> 0) & 0xFF));
+}
+
+inline static void GDWrite_f32(f32 data) {
+ union {
+ f32 f;
+ u32 u;
+ } fid;
+ fid.f = data;
+ GDWrite_u32(fid.u);
+}
+
+inline static void GDWriteXFCmdHdr(u16 addr, u8 len) {
+ GDWrite_u8(GX_LOAD_XF_REG);
+ GDWrite_u16(len - 1);
+ GDWrite_u16(addr);
+}
+
+inline static void GDWriteXFCmd(u16 addr, u32 val) {
+ GDWrite_u8(GX_LOAD_XF_REG);
+ GDWrite_u16(0);
+ GDWrite_u16(addr);
+ GDWrite_u32(val);
+}
+
+inline static void GDWriteXFIndxDCmd(u16 addr, u8 len, u16 index) {
+ GDWrite_u8(GX_LOAD_INDX_D);
+ GDWrite_u16(index);
+ GDWrite_u16((len - 1) << 12 | addr);
+}
+
+inline static void GDWriteXFIndxACmd(u16 addr, u8 len, u16 index) {
+ GDWrite_u8(GX_LOAD_INDX_A);
+ GDWrite_u16(index);
+ GDWrite_u16(((len - 1) << 12) | addr);
+}
+
+inline static void GDWriteXFIndxBCmd(u16 addr, u8 len, u16 index) {
+ GDWrite_u8(GX_LOAD_INDX_B);
+ GDWrite_u16(index);
+ GDWrite_u16(((len - 1) << 12) | addr);
+}
+
+inline static void GDWriteXFIndxCCmd(u16 addr, u8 len, u16 index) {
+ GDWrite_u8(GX_LOAD_INDX_C);
+ GDWrite_u16(index);
+ GDWrite_u16(((len - 1) << 12) | addr);
+}
+
+inline static void GDWriteCPCmd(u8 addr, u32 val) {
+ GDWrite_u8(GX_LOAD_CP_REG);
+ GDWrite_u8(addr);
+ GDWrite_u32(val);
+}
+
+inline static void GDWriteBPCmd(u32 regval) {
+ GDWrite_u8(GX_LOAD_BP_REG);
+ GDWrite_u32(regval);
+}
+
+inline static void GDSetCurrent(GDLObj* dl) {
+ __GDCurrentDL = dl;
+}
+
+static inline u32 GDGetCurrOffset(void) {
+ return (u32)(__GDCurrentDL->ptr - __GDCurrentDL->start);
+}
+
+static inline void GDSetCurrOffset(u32 offset) {
+ __GDCurrentDL->ptr = __GDCurrentDL->start + offset;
+}
+
+static inline void* GDGetCurrPointer(void) {
+ return (void*)__GDCurrentDL->ptr;
+}
+
+static inline u8* GDGetCurrPointer2(void) {
+ return __GDCurrentDL->ptr;
+}
+
+static inline u32 GDGetGDLObjOffset(const GDLObj* dl) {
+ return (u32)(dl->ptr - dl->start);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gd/GDFile.h b/include/revolution/gd/GDFile.h
new file mode 100644
index 0000000000..6105de8f72
--- /dev/null
+++ b/include/revolution/gd/GDFile.h
@@ -0,0 +1,31 @@
+#ifndef _REVOLUTION_GD_FILE_H
+#define _REVOLUTION_GD_FILE_H
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GD_FILE_VERSION_NUMBER 0x11223344
+
+typedef struct _GDGList {
+ void* ptr;
+ u32 byteLength;
+} GDGList;
+
+typedef struct _GDFileHeader {
+ u32 versionNumber;
+ u32 numDLs;
+ u32 numPLs;
+ GDGList* DLDescArray;
+ GDGList* PLDescArray;
+} GDFileHeader;
+
+s32 GDReadDLFile(const char* fName, u32* numDLs, u32* numPLs, GDGList** DLDescArray, GDGList** PLDescArray);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gd/GDGeometry.h b/include/revolution/gd/GDGeometry.h
new file mode 100644
index 0000000000..16969bd37e
--- /dev/null
+++ b/include/revolution/gd/GDGeometry.h
@@ -0,0 +1,524 @@
+#ifndef _REVOLUTION_GD_GEOMETRY_H_
+#define _REVOLUTION_GD_GEOMETRY_H_
+
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Command processor register IDs
+#define CP_REG_MTXIDXA_ID 0x30 // Matrix index A
+#define CP_REG_MTXIDXB_ID 0x40 // Matrix index B
+#define CP_REG_VCD_LO_ID 0x50 // Vertex descriptor (lo)
+#define CP_REG_VCD_HI_ID 0x60 // Vertex descriptor (hi)
+#define CP_REG_VAT_GRP0_ID 0x70 // Vertex attribute table (group 0)
+#define CP_REG_VAT_GRP1_ID 0x80 // Vertex attribute table (group 1)
+#define CP_REG_VAT_GRP2_ID 0x90 // Vertex attribute table (group 2)
+#define CP_REG_ARRAYBASE_ID 0xA0 // Vertex array start/base
+#define CP_REG_ARRAYSTRIDE_ID 0xB0 // Vertex array stride
+
+// XF locators for textures
+// Projection type [30-30]
+#define GX_XF_TEX_PROJTYPE_ST 30
+#define GX_XF_TEX_PROJTYPE_END 30
+
+// Input format [29-29]
+#define GX_XF_TEX_INPUTFORM_ST 29
+#define GX_XF_TEX_INPUTFORM_END 29
+
+// Texture gen type [25-27]
+#define GX_XF_TEX_TEXGENTYPE_ST 25
+#define GX_XF_TEX_TEXGENTYPE_END 27
+
+// Source row [20-24]
+#define GX_XF_TEX_SRCROW_ST 20
+#define GX_XF_TEX_SRCROW_END 24
+
+// Bump source texture [17-19]
+#define GX_XF_TEX_BUMPSRCTEX_ST 17
+#define GX_XF_TEX_BUMPSRCTEX_END 19
+
+// Bump source light [14-16]
+#define GX_XF_TEX_BUMPSRCLIGHT_ST 14
+#define GX_XF_TEX_BUMPSRCLIGHT_END 16
+
+// Blitting processor registers.
+#define GX_BP_REG_GENMODE 0x0 // gen mode
+
+// display copy filters
+#define GX_BP_REG_DISPCOPYFILTER0 0x1 // display copy filter 0
+#define GX_BP_REG_DISPCOPYFILTER1 0x2 // display copy filter 1
+#define GX_BP_REG_DISPCOPYFILTER2 0x3 // display copy filter 2
+#define GX_BP_REG_DISPCOPYFILTER3 0x4 // display copy filter 3
+
+// indirect matrices
+#define GX_BP_REG_INDMTX0A 0x6 // indirect matrix 0A
+#define GX_BP_REG_INDMTX0B 0x7 // indirect matrix 0B
+#define GX_BP_REG_INDMTX0C 0x8 // indirect matrix 0C
+#define GX_BP_REG_INDMTX1A 0x9 // indirect matrix 1A
+#define GX_BP_REG_INDMTX1B 0xA // indirect matrix 1B
+#define GX_BP_REG_INDMTX1C 0xB // indirect matrix 1C
+#define GX_BP_REG_INDMTX2A 0xC // indirect matrix 2A
+#define GX_BP_REG_INDMTX2B 0xD // indirect matrix 2B
+#define GX_BP_REG_INDMTX2C 0xE // indirect matrix 2C
+#define GX_BP_REG_INDIMASK 0xF // indirect mask
+
+// indirect TEV stages
+#define GX_BP_REG_INDTEVSTAGE0 0x10 // indirect TEV stage 0
+#define GX_BP_REG_INDTEVSTAGE1 0x11 // indirect TEV stage 1
+#define GX_BP_REG_INDTEVSTAGE2 0x12 // indirect TEV stage 2
+#define GX_BP_REG_INDTEVSTAGE3 0x13 // indirect TEV stage 3
+#define GX_BP_REG_INDTEVSTAGE4 0x14 // indirect TEV stage 4
+#define GX_BP_REG_INDTEVSTAGE5 0x15 // indirect TEV stage 5
+#define GX_BP_REG_INDTEVSTAGE6 0x16 // indirect TEV stage 6
+#define GX_BP_REG_INDTEVSTAGE7 0x17 // indirect TEV stage 7
+#define GX_BP_REG_INDTEVSTAGE8 0x18 // indirect TEV stage 8
+#define GX_BP_REG_INDTEVSTAGE9 0x19 // indirect TEV stage 9
+#define GX_BP_REG_INDTEVSTAGE10 0x1A // indirect TEV stage 10
+#define GX_BP_REG_INDTEVSTAGE11 0x1B // indirect TEV stage 11
+#define GX_BP_REG_INDTEVSTAGE12 0x1C // indirect TEV stage 12
+#define GX_BP_REG_INDTEVSTAGE13 0x1D // indirect TEV stage 13
+#define GX_BP_REG_INDTEVSTAGE14 0x1E // indirect TEV stage 14
+#define GX_BP_REG_INDTEVSTAGE15 0x1F // indirect TEV stage 15
+
+// performance manips
+#define GX_BP_REG_SCISSORTL 0x20 // scissor top left
+#define GX_BP_REG_SCISSORBR 0x21 // scissor bottom right
+#define GX_BP_REG_LINEPTWIDTH 0x22 // line point width
+#define GX_BP_REG_PERF0TRI 0x23 // performance 0 (triangle)
+#define GX_BP_REG_PERF0QUAD 0x24 // performance 0 (quad)
+
+// rasters
+#define GX_BP_REG_RAS1_SS0 0x25
+#define GX_BP_REG_RAS1_SS1 0x26
+#define GX_BP_REG_RAS1_IREF 0x27
+#define GX_BP_REG_RAS1_TREF0 0x28
+#define GX_BP_REG_RAS1_TREF1 0x29
+#define GX_BP_REG_RAS1_TREF2 0x2A
+#define GX_BP_REG_RAS1_TREF3 0x2B
+#define GX_BP_REG_RAS1_TREF4 0x2C
+#define GX_BP_REG_RAS1_TREF5 0x2D
+#define GX_BP_REG_RAS1_TREF6 0x2E
+#define GX_BP_REG_RAS1_TREF7 0x2F
+
+// setup sizes
+#define GX_BP_REG_SU_SSIZE0 0x30
+#define GX_BP_REG_SU_TSIZE0 0x31
+#define GX_BP_REG_SU_SSIZE1 0x32
+#define GX_BP_REG_SU_TSIZE1 0x33
+#define GX_BP_REG_SU_SSIZE2 0x34
+#define GX_BP_REG_SU_TSIZE2 0x35
+#define GX_BP_REG_SU_SSIZE3 0x36
+#define GX_BP_REG_SU_TSIZE3 0x37
+#define GX_BP_REG_SU_SSIZE4 0x38
+#define GX_BP_REG_SU_TSIZE4 0x39
+#define GX_BP_REG_SU_SSIZE5 0x3A
+#define GX_BP_REG_SU_TSIZE5 0x3B
+#define GX_BP_REG_SU_SSIZE6 0x3C
+#define GX_BP_REG_SU_TSIZE6 0x3D
+#define GX_BP_REG_SU_SSIZE7 0x3E
+#define GX_BP_REG_SU_TSIZE7 0x3F
+
+// Z and blend controls
+#define GX_BP_REG_ZMODE 0x40
+#define GX_BP_REG_BLENDMODE 0x41
+#define GX_BP_REG_DSTALPHA 0x42
+#define GX_BP_REG_ZCONTROL 0x43
+#define GX_BP_REG_FIELDMASK 0x44
+#define GX_BP_REG_DRAWDONE 0x45
+#define GX_BP_REG_PETOKEN 0x47
+#define GX_BP_REG_PETOKENINT 0x48
+
+// copying
+#define GX_BP_REG_TEXCOPYSRCXY 0x49
+#define GX_BP_REG_TEXCOPYSRCWH 0x4A
+#define GX_BP_REG_TEXCOPYDST 0x4B
+#define GX_BP_REG_DISPCOPYSTRIDE 0x4D
+#define GX_BP_REG_DISPCOPYSCALEY 0x4E
+#define GX_BP_REG_COPYCLEARAR 0x4F
+#define GX_BP_REG_COPYCLEARGB 0x50
+#define GX_BP_REG_COPYCLEARZ 0x51
+#define GX_BP_REG_COPYFILTER0 0x53
+#define GX_BP_REG_COPYFILTER1 0x54
+
+//
+#define GX_BP_REG_BOUNDINGBOX0 0x55
+#define GX_BP_REG_BOUNDINGBOX1 0x56
+
+#define GX_BP_REG_SCISSOROFFSET 0x59
+
+// texture memory
+#define GX_BP_REG_TMEMPRELOADADDR 0x60
+#define GX_BP_REG_TMEMPRELOADEVEN 0x61
+#define GX_BP_REG_TMEMPRELOADODD 0x62
+#define GX_BP_REG_TMEMPRELOADMODE 0x63
+#define GX_BP_REG_TMEMTLUTSRC 0x64
+#define GX_BP_REG_TMEMTLUTDST 0x65
+#define GX_BP_REG_TMEMTEXINVALIDATE 0x66
+
+// performance 1
+#define GX_BP_REG_PERF1 0x67
+#define GX_BP_REG_FIELDMODE 0x68
+
+// set modes
+#define GX_BP_REG_SETMODE0_TEX0 0x80
+#define GX_BP_REG_SETMODE0_TEX1 0x81
+#define GX_BP_REG_SETMODE0_TEX2 0x82
+#define GX_BP_REG_SETMODE0_TEX3 0x83
+#define GX_BP_REG_SETMODE1_TEX0 0x84
+#define GX_BP_REG_SETMODE1_TEX1 0x85
+#define GX_BP_REG_SETMODE1_TEX2 0x86
+#define GX_BP_REG_SETMODE1_TEX3 0x87
+
+// set images
+#define GX_BP_REG_SETIMAGE0_TEX0 0x88
+#define GX_BP_REG_SETIMAGE0_TEX1 0x89
+#define GX_BP_REG_SETIMAGE0_TEX2 0x8A
+#define GX_BP_REG_SETIMAGE0_TEX3 0x8B
+#define GX_BP_REG_SETIMAGE1_TEX0 0x8C
+#define GX_BP_REG_SETIMAGE1_TEX1 0x8D
+#define GX_BP_REG_SETIMAGE1_TEX2 0x8E
+#define GX_BP_REG_SETIMAGE1_TEX3 0x8F
+#define GX_BP_REG_SETIMAGE2_TEX0 0x90
+#define GX_BP_REG_SETIMAGE2_TEX1 0x91
+#define GX_BP_REG_SETIMAGE2_TEX2 0x92
+#define GX_BP_REG_SETIMAGE2_TEX3 0x93
+#define GX_BP_REG_SETIMAGE3_TEX0 0x94
+#define GX_BP_REG_SETIMAGE3_TEX1 0x95
+#define GX_BP_REG_SETIMAGE3_TEX2 0x96
+#define GX_BP_REG_SETIMAGE3_TEX3 0x97
+
+// set texture lookups
+#define GX_BP_REG_SETTLUT_TEX0 0x98
+#define GX_BP_REG_SETTLUT_TEX1 0x99
+#define GX_BP_REG_SETTLUT_TEX2 0x9A
+#define GX_BP_REG_SETTLUT_TEX3 0x9B
+
+// set modes continued
+#define GX_BP_REG_SETMODE0_TEX4 0xA0
+#define GX_BP_REG_SETMODE0_TEX5 0xA1
+#define GX_BP_REG_SETMODE0_TEX6 0xA2
+#define GX_BP_REG_SETMODE0_TEX7 0xA3
+#define GX_BP_REG_SETMODE1_TEX4 0xA4
+#define GX_BP_REG_SETMODE1_TEX5 0xA5
+#define GX_BP_REG_SETMODE1_TEX6 0xA6
+#define GX_BP_REG_SETMODE1_TEX7 0xA7
+
+// set images continued
+#define GX_BP_REG_SETIMAGE0_TEX4 0xA8
+#define GX_BP_REG_SETIMAGE0_TEX5 0xA9
+#define GX_BP_REG_SETIMAGE0_TEX6 0xAA
+#define GX_BP_REG_SETIMAGE0_TEX7 0xAB
+#define GX_BP_REG_SETIMAGE1_TEX4 0xAC
+#define GX_BP_REG_SETIMAGE1_TEX5 0xAD
+#define GX_BP_REG_SETIMAGE1_TEX6 0xAE
+#define GX_BP_REG_SETIMAGE1_TEX7 0xAF
+#define GX_BP_REG_SETIMAGE2_TEX4 0xB0
+#define GX_BP_REG_SETIMAGE2_TEX5 0xB1
+#define GX_BP_REG_SETIMAGE2_TEX6 0xB2
+#define GX_BP_REG_SETIMAGE2_TEX7 0xB3
+#define GX_BP_REG_SETIMAGE3_TEX4 0xB4
+#define GX_BP_REG_SETIMAGE3_TEX5 0xB5
+#define GX_BP_REG_SETIMAGE3_TEX6 0xB6
+#define GX_BP_REG_SETIMAGE3_TEX7 0xB7
+
+// set texture lookups continued
+#define GX_BP_REG_SETTLUT_TEX4 0xB8
+#define GX_BP_REG_SETTLUT_TEX5 0xB9
+#define GX_BP_REG_SETTLUT_TEX6 0xBA
+#define GX_BP_REG_SETTLUT_TEX7 0xBB
+
+// TEV color manips
+#define GX_BP_REG_TEVCOLORCOMBINER0 0xC0
+#define GX_BP_REG_TEVALPHACOMBINER0 0xC1
+#define GX_BP_REG_TEVCOLORCOMBINER1 0xC2
+#define GX_BP_REG_TEVALPHACOMBINER1 0xC3
+#define GX_BP_REG_TEVCOLORCOMBINER2 0xC4
+#define GX_BP_REG_TEVALPHACOMBINER2 0xC5
+#define GX_BP_REG_TEVCOLORCOMBINER3 0xC6
+#define GX_BP_REG_TEVALPHACOMBINER3 0xC7
+#define GX_BP_REG_TEVCOLORCOMBINER4 0xC8
+#define GX_BP_REG_TEVALPHACOMBINER4 0xC9
+#define GX_BP_REG_TEVCOLORCOMBINER5 0xCA
+#define GX_BP_REG_TEVALPHACOMBINER5 0xCB
+#define GX_BP_REG_TEVCOLORCOMBINER6 0xCC
+#define GX_BP_REG_TEVALPHACOMBINER6 0xCD
+#define GX_BP_REG_TEVCOLORCOMBINER7 0xCE
+#define GX_BP_REG_TEVALPHACOMBINER7 0xCF
+#define GX_BP_REG_TEVCOLORCOMBINER8 0xD0
+#define GX_BP_REG_TEVALPHACOMBINER8 0xD1
+#define GX_BP_REG_TEVCOLORCOMBINER9 0xD2
+#define GX_BP_REG_TEVALPHACOMBINER9 0xD3
+#define GX_BP_REG_TEVCOLORCOMBINER10 0xD4
+#define GX_BP_REG_TEVALPHACOMBINER10 0xD5
+#define GX_BP_REG_TEVCOLORCOMBINER11 0xD6
+#define GX_BP_REG_TEVALPHACOMBINER11 0xD7
+#define GX_BP_REG_TEVCOLORCOMBINER12 0xD8
+#define GX_BP_REG_TEVALPHACOMBINER12 0xD9
+#define GX_BP_REG_TEVCOLORCOMBINER13 0xDA
+#define GX_BP_REG_TEVALPHACOMBINER13 0xDB
+#define GX_BP_REG_TEVCOLORCOMBINER14 0xDC
+#define GX_BP_REG_TEVALPHACOMBINER14 0xDD
+#define GX_BP_REG_TEVCOLORCOMBINER15 0xDE
+#define GX_BP_REG_TEVALPHACOMBINER15 0xDF
+
+// TEV registers
+#define GX_BP_REG_TEVREG0LO 0xE0
+#define GX_BP_REG_TEVREG0HI 0xE1
+#define GX_BP_REG_TEVREG1LO 0xE2
+#define GX_BP_REG_TEVREG1HI 0xE3
+#define GX_BP_REG_TEVREG2LO 0xE4
+#define GX_BP_REG_TEVREG2HI 0xE5
+#define GX_BP_REG_TEVREG3LO 0xE6
+#define GX_BP_REG_TEVREG3HI 0xE7
+
+// fog registers
+#define GX_BP_REG_FOGRANGE 0xE8
+#define GX_BP_REG_FOGRANGEK0 0xE9
+#define GX_BP_REG_FOGRANGEK1 0xEA
+#define GX_BP_REG_FOGRANGEK2 0xEB
+#define GX_BP_REG_FOGRANGEK3 0xEC
+#define GX_BP_REG_FOGRANGEK4 0xED
+#define GX_BP_REG_FOGPARAM0 0xEE
+#define GX_BP_REG_FOGPARAM1 0xEF
+#define GX_BP_REG_FOGPARAM2 0xF0
+#define GX_BP_REG_FOGPARAM3 0xF1
+#define GX_BP_REG_FOGCOLOR 0xF2
+
+// performance manip registers
+#define GX_BP_REG_ALPHACOMPARE 0xF3
+#define GX_BP_REG_ZTEXTURE0 0xF4
+#define GX_BP_REG_ZTEXTURE1 0xF5
+
+// TEV K selectors
+#define GX_BP_REG_TEVKSEL0 0xF6
+#define GX_BP_REG_TEVKSEL1 0xF7
+#define GX_BP_REG_TEVKSEL2 0xF8
+#define GX_BP_REG_TEVKSEL3 0xF9
+#define GX_BP_REG_TEVKSEL4 0xFA
+#define GX_BP_REG_TEVKSEL5 0xFB
+#define GX_BP_REG_TEVKSEL6 0xFC
+#define GX_BP_REG_TEVKSEL7 0xFD
+
+// SS mask
+#define GX_BP_REG_SSMASK 0xFE
+
+// Transform Unit Registers
+#define GX_XF_REG_ERROR 0x1000
+#define GX_XF_REG_DIAGNOSTICS 0x1001
+#define GX_XF_REG_STATE0 0x1002
+#define GX_XF_REG_STATE1 0x1003
+#define GX_XF_REG_CLOCK 0x1004
+#define GX_XF_REG_CLIPDISABLE 0x1005
+#define GX_XF_REG_PERF0 0x1006
+#define GX_XF_REG_PERF1 0x1007
+#define GX_XF_REG_INVERTEXSPEC 0x1008
+#define GX_XF_REG_NUMCOLORS 0x1009
+#define GX_XF_REG_AMBIENT0 0x100A
+#define GX_XF_REG_AMBIENT1 0x100B
+#define GX_XF_REG_MATERIAL0 0x100C
+#define GX_XF_REG_MATERIAL1 0x100D
+#define GX_XF_REG_COLOR0CNTRL 0x100E
+#define GX_XF_REG_COLOR1CNTRL 0x100F
+#define GX_XF_REG_ALPHA0CNTRL 0x1010
+#define GX_XF_REG_ALPHA1CNTRL 0x1011
+#define GX_XF_REG_DUALTEXTRAN 0x1012
+#define GX_XF_REG_MATRIXINDEX0 0x1018
+#define GX_XF_REG_MATRIXINDEX1 0x1019
+#define GX_XF_REG_SCALEX 0x101A
+#define GX_XF_REG_SCALEY 0x101B
+#define GX_XF_REG_SCALEZ 0x101C
+#define GX_XF_REG_OFFSETX 0x101D
+#define GX_XF_REG_OFFSETY 0x101E
+#define GX_XF_REG_OFFSETZ 0x101F
+#define GX_XF_REG_PROJECTIONA 0x1020
+#define GX_XF_REG_PROJECTIONB 0x1021
+#define GX_XF_REG_PROJECTIONC 0x1022
+#define GX_XF_REG_PROJECTIOND 0x1023
+#define GX_XF_REG_PROJECTIONE 0x1024
+#define GX_XF_REG_PROJECTIONF 0x1025
+#define GX_XF_REG_PROJECTORTHO 0x1026
+#define GX_XF_REG_NUMTEX 0x103F
+#define GX_XF_REG_TEX0 0x1040
+#define GX_XF_REG_TEX1 0x1041
+#define GX_XF_REG_TEX2 0x1042
+#define GX_XF_REG_TEX3 0x1043
+#define GX_XF_REG_TEX4 0x1044
+#define GX_XF_REG_TEX5 0x1045
+#define GX_XF_REG_TEX6 0x1046
+#define GX_XF_REG_TEX7 0x1047
+#define GX_XF_REG_DUALTEX0 0x1050
+#define GX_XF_REG_DUALTEX1 0x1051
+#define GX_XF_REG_DUALTEX2 0x1052
+#define GX_XF_REG_DUALTEX3 0x1053
+#define GX_XF_REG_DUALTEX4 0x1054
+#define GX_XF_REG_DUALTEX5 0x1055
+#define GX_XF_REG_DUALTEX6 0x1056
+#define GX_XF_REG_DUALTEX7 0x1057
+
+#define CP_REG_VCD_LO(pnMtxIdx, txMtxIdxMask, posn, norm, col0, col1) \
+ ( \
+ (pnMtxIdx) << 0 | \
+ (txMtxIdxMask) << 1 | \
+ (posn) << 9 | \
+ (norm) << 11 | \
+ (col0) << 13 | \
+ (col1) << 15 \
+ )
+
+#define CP_REG_VCD_HI(tex0, tex1, tex2, tex3, tex4, tex5, tex6, tex7) \
+ ( \
+ (tex0) << 0 | \
+ (tex1) << 2 | \
+ (tex2) << 4 | \
+ (tex3) << 6 | \
+ (tex4) << 8 | \
+ (tex5) << 10 | \
+ (tex6) << 12 | \
+ (tex7) << 14 \
+ )
+
+#define CP_REG_VAT_GRP0(posCnt, posType, posFrac, nrmCnt, nrmType, c0Cnt, c0Type, c1Cnt, c1Type, tx0Cnt, tx0Type, tx0Frac, p12, nrmIdx3) \
+ ( \
+ (posCnt) << 0 | \
+ (posType) << 1 | \
+ (posFrac) << 4 | \
+ (nrmCnt) << 9 | \
+ (nrmType) << 10 | \
+ (c0Cnt) << 13 | \
+ (c0Type) << 14 | \
+ (c1Cnt) << 17 | \
+ (c1Type) << 18 | \
+ (tx0Cnt) << 21 | \
+ (tx0Type) << 22 | \
+ (tx0Frac) << 25 | \
+ (p12) << 30 | \
+ (nrmIdx3) << 31 \
+ )
+
+#define CP_REG_VAT_GRP1(tx1Cnt, tx1Type, tx1Frac, tx2Cnt, tx2Type, tx2Frac, tx3Cnt, tx3Type, tx3Frac, tx4Cnt, tx4Type, p11) \
+ ( \
+ (tx1Cnt) << 0 | \
+ (tx1Type) << 1 | \
+ (tx1Frac) << 4 | \
+ (tx2Cnt) << 9 | \
+ (tx2Type) << 10 | \
+ (tx2Frac) << 13 | \
+ (tx3Cnt) << 18 | \
+ (tx3Type) << 19 | \
+ (tx3Frac) << 22 | \
+ (tx4Cnt) << 27 | \
+ (tx4Type) << 28 | \
+ p11 << 31 \
+ )
+
+#define CP_REG_VAT_GRP2(tx4Frac, tx5Cnt, tx5Type, tx5Frac, tx6Cnt, tx6Type, tx6Frac, tx7Cnt, tx7Type, tx7Frac) \
+ ( \
+ (tx4Frac) << 0 | \
+ (tx5Cnt) << 5 | \
+ (tx5Type) << 6 | \
+ (tx5Frac) << 9 | \
+ (tx6Cnt) << 14 | \
+ (tx6Type) << 15 | \
+ (tx6Frac) << 18 | \
+ (tx7Cnt) << 23 | \
+ (tx7Type) << 24 | \
+ (tx7Frac) << 27 \
+ )
+
+// Transform unit register IDs
+#define XF_REG_ERROR_ID 0x1000
+#define XF_REG_DIAGNOSTICS_ID 0x1001
+#define XF_REG_STATE0_ID 0x1002
+#define XF_REG_STATE1_ID 0x1003
+#define XF_REG_CLOCK_ID 0x1004
+#define XF_REG_CLIPDISABLE_ID 0x1005
+#define XF_REG_PERF0_ID 0x1006
+#define XF_REG_PERF1_ID 0x1007
+#define XF_REG_INVERTEXSPEC_ID 0x1008
+#define XF_REG_NUMCOLORS_ID 0x1009
+#define XF_REG_DUALTEXTRAN_ID 0x1012
+#define XF_REG_SCALEX_ID 0x101A
+#define XF_REG_SCALEY_ID 0x101B
+#define XF_REG_SCALEZ_ID 0x101C
+#define XF_REG_OFFSETX_ID 0x101D
+#define XF_REG_OFFSETY_ID 0x101E
+#define XF_REG_OFFSETZ_ID 0x101F
+#define XF_REG_NUMTEX_ID 0x103F
+#define XF_REG_TEX0_ID 0x1040
+#define XF_REG_TEX1_ID 0x1041
+#define XF_REG_TEX2_ID 0x1042
+#define XF_REG_TEX3_ID 0x1043
+#define XF_REG_TEX4_ID 0x1044
+#define XF_REG_TEX5_ID 0x1045
+#define XF_REG_TEX6_ID 0x1046
+#define XF_REG_TEX7_ID 0x1047
+#define XF_REG_DUALTEX0_ID 0x1050
+#define XF_REG_DUALTEX1_ID 0x1051
+#define XF_REG_DUALTEX2_ID 0x1052
+#define XF_REG_DUALTEX3_ID 0x1053
+#define XF_REG_DUALTEX4_ID 0x1054
+#define XF_REG_DUALTEX5_ID 0x1055
+#define XF_REG_DUALTEX6_ID 0x1056
+#define XF_REG_DUALTEX7_ID 0x1057
+
+#define XF_REG_INVTXSPEC(ncols, nnorms, ntexs) \
+ ( \
+ (ncols) << 0 | \
+ (nnorms) << 2 | \
+ (ntexs) << 4 \
+ )
+
+#define XF_REG_TEX(proj, form, tgType, row, embossRow, embossLit) \
+ ( \
+ (proj) << 1 | \
+ (form) << 2 | \
+ (tgType) << 4 | \
+ (row) << 7 | \
+ (embossRow) << 12 | \
+ (embossLit) << 15 \
+ )
+
+#define XF_REG_DUALTEX(mtx, normalize) \
+ ( \
+ (mtx) << 0 | \
+ (normalize) << 8 \
+ )
+
+#define BP_GEN_MODE(nTexGens, nChans, nTevs, p4, nInds) \
+ ( \
+ (u32)(nTexGens) << 0 | \
+ (u32)(nChans) << 4 | \
+ (u32)(nTevs) << 10 | \
+ (u32)(p4) << 14 | \
+ (u32)(nInds) << 16 \
+ )
+
+#define BP_LP_SIZE(lineWidth, pointSize, lineOffset, pointOffset, lineHalfAspect, p5) \
+ ( \
+ (u32)(lineWidth) << 0 | \
+ (u32)(pointSize) << 8 | \
+ (u32)(lineOffset) << 16 | \
+ (u32)(pointOffset) << 19 | \
+ (u32)(lineHalfAspect) << 22 | \
+ (u32)(p5) << 24 \
+ )
+
+void GDSetVtxDescv(const GXVtxDescList* attrPtr);
+void GDSetVtxAttrFmtv(GXVtxFmt vtxfmt, const GXVtxAttrFmtList* list);
+void GDSetArray(GXAttr attr, void* base_ptr, u8 stride);
+void GDSetArrayRaw(GXAttr attr, u32 base_ptr_raw, u8 stride);
+void GDPatchArrayPtr(void* base_ptr);
+void GDSetTexCoordGen(GXTexCoordID dst_coord, GXTexGenType func, GXTexGenSrc src_param, u8 normalize, u32 postmtx);
+void GDSetCullMode(GXCullMode mode);
+void GDSetGenMode(u8 nTexGens, u8 nChans, u8 nTevs);
+void GDSetGenMode2(u8 nTexGens, u8 nChans, u8 nTevs, u8 nInds, GXCullMode cm);
+void GDSetLPSize(u8 lineWidth, u8 pointSize, GXTexOffset lineOffset, GXTexOffset pointOffset, u8 lineHalfAspect);
+void GDSetCoPlanar(u8 enable);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gd/GDIndirect.h b/include/revolution/gd/GDIndirect.h
new file mode 100644
index 0000000000..ea79ebaab0
--- /dev/null
+++ b/include/revolution/gd/GDIndirect.h
@@ -0,0 +1,91 @@
+#ifndef _REVOLUTION_GD_INDIRECT_H_
+#define _REVOLUTION_GD_INDIRECT_H_
+
+#include <revolution/types.h>
+#include <revolution/gx/GXEnum.h>
+#include <revolution/mtx.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BP_TEV_INDIRECT(ind_stage, format, bias_sel, alpha_sel, mtx_sel, wrap_s, wrap_t, utc_lod, add_prev, id) \
+ ( \
+ (u32)(ind_stage) << 0 | \
+ (u32)(format) << 2 | \
+ (u32)(bias_sel) << 4 | \
+ (u32)(alpha_sel) << 7 | \
+ (u32)(mtx_sel) << 9 | \
+ (u32)(wrap_s) << 13 | \
+ (u32)(wrap_t) << 16 | \
+ (u32)(utc_lod) << 19 | \
+ (u32)(add_prev) << 20 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_IND_MTX(m0, m1, scale_exp, id) \
+ ( \
+ (u32)(m0) << 0 | \
+ (u32)(m1) << 11 | \
+ (u32)(scale_exp) << 22 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_IND_TEXCOORD_SCALE(scaleS0, scaleT0, scaleS1, scaleT1, id) \
+ ( \
+ (u32)(scaleS0) << 0 | \
+ (u32)(scaleT0) << 4 | \
+ (u32)(scaleS1) << 8 | \
+ (u32)(scaleT1) << 12 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_IND_TEX_ORDER(map0, coord0, map1, coord1, map2, coord2, map3, coord3, id) \
+ ( \
+ (u32)(map0) << 0 | \
+ (u32)(coord0) << 3 | \
+ (u32)(map1) << 6 | \
+ (u32)(coord1) << 9 | \
+ (u32)(map2) << 12 | \
+ (u32)(coord2) << 15 | \
+ (u32)(map3) << 18 | \
+ (u32)(coord3) << 21 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_IND_MASK(mask, id) \
+ ( \
+ (u32)(mask) << 0 | \
+ (u32)(id) << 24 \
+ )
+
+void GDSetTevIndirect(GXTevStageID tev_stage, GXIndTexStageID ind_stage,
+ GXIndTexFormat format, GXIndTexBiasSel bias_sel,
+ GXIndTexMtxID matrix_sel, GXIndTexWrap wrap_s,
+ GXIndTexWrap wrap_t, u8 add_prev, u8 utc_lod,
+ GXIndTexAlphaSel alpha_sel);
+void GDSetIndTexMtx(GXIndTexMtxID mtx_id, const f32 offset[2][3], s8 scale_exp);
+void GDSetIndTexCoordScale(GXIndTexStageID indStageEven, GXIndTexScale scaleS0,
+ GXIndTexScale scaleT0, GXIndTexScale scaleS1,
+ GXIndTexScale scaleT1);
+void GDSetIndTexOrder(GXTexCoordID texCoord0, GXTexMapID texMap0,
+ GXTexCoordID texCoord1, GXTexMapID texMap1,
+ GXTexCoordID texCoord2, GXTexMapID texMap2,
+ GXTexCoordID texCoord3, GXTexMapID texMap3);
+void GDSetTevDirect(GXTevStageID tev_stage);
+void GDSetTevIndWarp(GXTevStageID tev_stage, GXIndTexStageID ind_stage, u8 signed_offset, u8 replace_mode, GXIndTexMtxID matrix_sel);
+void GDSetTevIndTile(GXTevStageID tev_stage, GXIndTexStageID ind_stage,
+ u16 tilesize_s, u16 tilesize_t, u16 tilespacing_s,
+ u16 tilespacing_t, GXIndTexFormat format,
+ GXIndTexMtxID matrix_sel, GXIndTexBiasSel bias_sel,
+ GXIndTexAlphaSel alpha_sel);
+void GDSetTevIndBumpST(GXTevStageID tev_stage, GXIndTexStageID ind_stage, GXIndTexMtxID matrix_sel);
+void GDSetTevIndBumpXYZ(GXTevStageID tev_stage, GXIndTexStageID ind_stage, GXIndTexMtxID matrix_sel);
+void GDSetTevIndRepeat(GXTevStageID tev_stage);
+void __GDSetIndTexMask(u32 mask);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gd/GDLight.h b/include/revolution/gd/GDLight.h
new file mode 100644
index 0000000000..f5ee020f5d
--- /dev/null
+++ b/include/revolution/gd/GDLight.h
@@ -0,0 +1,74 @@
+#ifndef _REVOLUTION_GD_LIGHT_H_
+#define _REVOLUTION_GD_LIGHT_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+#include "global.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define XF_LIGHT_ID 0x0600
+#define XF_LIGHT_COLOR_ID 0x0603
+#define XF_LIGHT_ATTN_ID 0x0604
+#define XF_LIGHT_DISTATTN_ID 0x0607
+#define XF_LIGHT_POS_ID 0x060A
+#define XF_LIGHT_SPEC_DIR_ID 0x060A
+#define XF_LIGHT_DIR_ID 0x060D
+
+#define XF_REG_AMBIENT0_ID 0x100A
+#define XF_REG_AMBIENT1_ID 0x100B
+#define XF_REG_MATERIAL0_ID 0x100C
+#define XF_REG_MATERIAL1_ID 0x100D
+#define XF_REG_COLOR0CNTRL_ID 0x100E
+#define XF_REG_COLOR1CNTRL_ID 0x100F
+#define XF_REG_ALPHA0CNTRL_ID 0x1010
+#define XF_REG_ALPHA1CNTRL_ID 0x1011
+
+#define XF_REG_CHAN_CTRL(matsrc, enable, lightmask0, ambsrc, diff_fn, p5, p6, lightmask4) \
+ ( \
+ (u32)(matsrc) << 0 | \
+ (u32)(enable) << 1 | \
+ (u32)(lightmask0) << 2 | \
+ (u32)(ambsrc) << 6 | \
+ (u32)(diff_fn) << 7 | \
+ (u32)(p5) << 9 | \
+ (u32)(p6) << 10 | \
+ (u32)(lightmask4) << 11 \
+ )
+
+void GDSetLightAttn(GXLightID light, f32 a0, f32 a1, f32 a2, f32 k0, f32 k1, f32 k2);
+void GDSetLightSpot(GXLightID light, f32 cutoff, GXSpotFn spot_func);
+void GDSetLightDistAttn(GXLightID light, f32 ref_dist, f32 ref_br, GXDistAttnFn dist_func);
+void GDSetLightColor(GXLightID light, GXColor color);
+void GDSetLightPos(GXLightID light, f32 x, f32 y, f32 z);
+void GDSetLightDir(GXLightID light, f32 nx, f32 ny, f32 nz);
+void GDSetSpecularDirHA(GXLightID light, f32 nx, f32 ny, f32 nz, f32 hx, f32 hy, f32 hz);
+void GDSetSpecularDir(GXLightID light, f32 nx, f32 ny, f32 nz);
+void GDLoadLightObjIndx(u32 lt_obj_indx, GXLightID light);
+void GDSetChanAmbColor(GXChannelID chan, GXColor color);
+void GDSetChanMatColor(GXChannelID chan, GXColor color);
+void GDSetChanCtrl(GXChannelID chan, u8 enable, GXColorSrc amb_src,
+ GXColorSrc mat_src, u32 light_mask, GXDiffuseFn diff_fn,
+ GXAttnFn attn_fn);
+
+inline static u16 __GDLightID2Index(GXLightID id) {
+ u16 idx;
+
+ idx = 0x1F - __cntlzw(id);
+ if (idx > 7) {
+ idx = 0;
+ }
+ return idx;
+}
+
+inline static u16 __GDLightID2Offset(GXLightID id) {
+ return __GDLightID2Index(id) * 16;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gd/GDPixel.h b/include/revolution/gd/GDPixel.h
new file mode 100644
index 0000000000..ce377aca98
--- /dev/null
+++ b/include/revolution/gd/GDPixel.h
@@ -0,0 +1,95 @@
+#ifndef _REVOLUTION_GD_PIXEL_H
+#define _REVOLUTION_GD_PIXEL_H
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BP_FOG_UNK0(a, id) \
+ ( \
+ (u32)(a) << 0 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_FOG_UNK1(b_m, id) \
+ ( \
+ (u32)(b_m) << 0 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_FOG_UNK2(b_expn, id) \
+ ( \
+ (u32)(b_expn) << 0 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_FOG_UNK3(c, proj, fsel, id) \
+ ( \
+ (u32)(c) << 0 | \
+ (u32)(proj) << 20 | \
+ (u32)(fsel) << 21 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_FOG_COLOR(r, g, b, id) \
+ ( \
+ (u32)(b) << 0 | \
+ (u32)(g) << 8 | \
+ (u32)(r) << 16 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_BLEND_MODE(enable, enable_logic, enable_dither, enable_color_update, enable_alpha_update, dst_factor, src_factor, blend_sub, logic_op, id) \
+ ( \
+ (u32)(enable) << 0 | \
+ (u32)(enable_logic) << 1 | \
+ (u32)(enable_dither) << 2 | \
+ (u32)(enable_color_update) << 3 | \
+ (u32)(enable_alpha_update) << 4 | \
+ (u32)(dst_factor) << 5 | \
+ (u32)(src_factor) << 8 | \
+ (u32)(blend_sub) << 11 | \
+ (u32)(logic_op) << 12 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_Z_MODE(enable_compare, compare_fn, enable_update, id) \
+ ( \
+ (u32)(enable_compare) << 0 | \
+ (u32)(compare_fn) << 1 | \
+ (u32)(enable_update) << 4 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_DST_ALPHA(alpha, enable, id) \
+ ( \
+ (u32)(alpha) << 0 | \
+ (u32)(enable) << 8 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TOKEN(token, id) \
+ ( \
+ (u32)(token) << 0 | \
+ (u32)(id) << 24 \
+ )
+
+void GDSetFog(GXFogType type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor color);
+void GDSetBlendMode(GXBlendMode type, GXBlendFactor src_factor, GXBlendFactor dst_factor, GXLogicOp logic_op);
+void GDSetBlendModeEtc(GXBlendMode type, GXBlendFactor src_factor,
+ GXBlendFactor dst_factor, GXLogicOp logic_op,
+ u8 color_update_enable,
+ u8 alpha_update_enable,
+ u8 dither_enable);
+void GDSetZMode(u8 compare_enable, GXCompare func, u8 update_enable);
+void GDSetDstAlpha(u8 enable, u8 alpha);
+void GDSetDrawSync(u16 token);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gd/GDTev.h b/include/revolution/gd/GDTev.h
new file mode 100644
index 0000000000..b7e61ee021
--- /dev/null
+++ b/include/revolution/gd/GDTev.h
@@ -0,0 +1,133 @@
+#ifndef _REVOLUTION_GD_TEV_H
+#define _REVOLUTION_GD_TEV_H
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BP_TEV_COLOR(d, c, b, a, bias, op, clamp, scale, out, id) \
+ ( \
+ (u32)(d) << 0 | \
+ (u32)(c) << 4 | \
+ (u32)(b) << 8 | \
+ (u32)(a) << 12 | \
+ (u32)(bias) << 16 | \
+ (u32)(op) << 18 | \
+ (u32)(clamp) << 19 | \
+ (u32)(scale) << 20 | \
+ (u32)(out) << 22 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEV_ALPHA(ras_sel, tex_sel, d, c, b, a, bias, op, clamp, scale, out, id) \
+ ( \
+ (u32)(ras_sel) << 0 | \
+ (u32)(tex_sel) << 2 | \
+ (u32)(d) << 4 | \
+ (u32)(c) << 7 | \
+ (u32)(b) << 10 | \
+ (u32)(a) << 13 | \
+ (u32)(bias) << 16 | \
+ (u32)(op) << 18 | \
+ (u32)(clamp) << 19 | \
+ (u32)(scale) << 20 | \
+ (u32)(out) << 22 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEV_COLOR_REG_RA(r, a, reg, id) \
+ ( \
+ (u32)(r) << 0 | \
+ (u32)(a) << 12 | \
+ (u32)(reg) << 23 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEV_COLOR_REG_BG(b, g, reg, id) \
+ ( \
+ (u32)(b) << 0 | \
+ (u32)(g) << 12 | \
+ (u32)(reg) << 23 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEV_KSEL(rb, ga, kcsel0, kasel0, kcsel1, kasel1, id) \
+ ( \
+ (u32)(rb) << 0 | \
+ (u32)(ga) << 2 | \
+ (u32)(kcsel0) << 4 | \
+ (u32)(kasel0) << 9 | \
+ (u32)(kcsel1) << 14 | \
+ (u32)(kasel1) << 19 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_ALPHA_COMPARE(ref0, ref1, comp0, comp1, op, id) \
+ ( \
+ (u32)(ref0) << 0 | \
+ (u32)(ref1) << 8 | \
+ (u32)(comp0) << 16 | \
+ (u32)(comp1) << 19 | \
+ (u32)(op) << 22 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_ZTEX_PARAMS_0(bias, id) \
+ ( \
+ (u32)(bias) << 0 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_ZTEX_PARAMS_1(zfmt, op, id) \
+ ( \
+ (u32)(zfmt) << 0 | \
+ (u32)(op) << 2 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEV_ORDER(map0, coord0, enable0, color0, map1, coord1, enable1, color1, id) \
+ ( \
+ (u32)(map0) << 0 | \
+ (u32)(coord0) << 3 | \
+ (u32)(enable0) << 6 | \
+ (u32)(color0) << 7 | \
+ (u32)(map1) << 12 | \
+ (u32)(coord1) << 15 | \
+ (u32)(enable1) << 18 | \
+ (u32)(color1) << 19 | \
+ (u32)(id) << 24 \
+ )
+
+void GDSetTevOp(GXTevStageID stage, GXTevMode mode);
+void GDSetTevColorCalc(GXTevStageID stage, GXTevColorArg a, GXTevColorArg b,
+ GXTevColorArg c, GXTevColorArg d, GXTevOp op,
+ GXTevBias bias, GXTevScale scale, u8 clamp,
+ GXTevRegID out_reg);
+void GDSetTevAlphaCalcAndSwap(GXTevStageID stage, GXTevAlphaArg a,
+ GXTevAlphaArg b, GXTevAlphaArg c, GXTevAlphaArg d,
+ GXTevOp op, GXTevBias bias, GXTevScale scale,
+ u8 clamp, GXTevRegID out_reg,
+ GXTevSwapSel ras_sel, GXTevSwapSel tex_sel);
+void GDSetTevColor(GXTevRegID reg, GXColor color);
+void GDSetTevColorS10(GXTevRegID reg, GXColorS10 color);
+void GDSetTevKColor(GXTevKColorID reg, GXColor color);
+void GDSetTevKonstantSel(GXTevStageID evenStage, GXTevKColorSel kcsel0,
+ GXTevKAlphaSel kasel0, GXTevKColorSel kcsel1,
+ GXTevKAlphaSel kasel1);
+void GDSetTevSwapModeTable(GXTevSwapSel table, GXTevColorChan red,
+ GXTevColorChan green, GXTevColorChan blue,
+ GXTevColorChan alpha);
+void GDSetAlphaCompare(GXCompare comp0, u8 ref0, GXAlphaOp op, GXCompare comp1, u8 ref1);
+void GDSetZTexture(GXZTexOp op, GXTexFmt fmt, u32 bias);
+void GDSetTevOrder(GXTevStageID evenStage, GXTexCoordID coord0, GXTexMapID map0,
+ GXChannelID color0, GXTexCoordID coord1, GXTexMapID map1,
+ GXChannelID color1);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gd/GDTexture.h b/include/revolution/gd/GDTexture.h
new file mode 100644
index 0000000000..7aba716486
--- /dev/null
+++ b/include/revolution/gd/GDTexture.h
@@ -0,0 +1,127 @@
+#ifndef _REVOLUTION_GD_TEXTURE_H
+#define _REVOLUTION_GD_TEXTURE_H
+
+#include <revolution/types.h>
+#include <revolution/gx/GXEnum.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BP_TEX_MODE0(wrap_s, wrap_t, mag_filt, min_filt, edge_lod, lod_bias, max_aniso, bias_clamp, id) \
+ ( \
+ (u32)(wrap_s) << 0 | \
+ (u32)(wrap_t) << 2 | \
+ (u32)(mag_filt) << 4 | \
+ (u32)(min_filt) << 5 | \
+ (u32)(edge_lod) << 8 | \
+ (u32)(lod_bias) << 9 | \
+ (u32)(max_aniso) << 19 | \
+ (u32)(bias_clamp) << 21 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEX_MODE1(min_lod, max_lod, id) \
+ ( \
+ (u32)(min_lod) << 0 | \
+ (u32)(max_lod) << 8 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_IMAGE_ATTR(width, height, format, id) \
+ ( \
+ (u32)(width) << 0 | \
+ (u32)(height) << 10 | \
+ (u32)(format) << 20 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_IMAGE_PTR(ptr, id) \
+ ( \
+ (u32)(ptr) << 0 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEX_CACHE_EVEN(tmem, size0, size1, type, id) \
+ ( \
+ (u32)(tmem) << 0 | \
+ (u32)(size0) << 15 | \
+ (u32)(size1) << 18 | \
+ (u32)(type) << 21 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEX_CACHE_ODD(tmem, size0, size1, id) \
+ ( \
+ (u32)(tmem) << 0 | \
+ (u32)(size0) << 15 | \
+ (u32)(size1) << 18 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEX_TLUT(tmem, format, id) \
+ ( \
+ (u32)(tmem) << 0 | \
+ (u32)(format) << 10 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEXCOORD_S_SCALE(s_scale, s_bias, s_wrap, line_offset, point_offset, id) \
+ ( \
+ (u32)(s_scale) << 0 | \
+ (u32)(s_bias) << 16 | \
+ (u32)(s_wrap) << 17 | \
+ (u32)(line_offset) << 18 | \
+ (u32)(point_offset) << 19 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_TEXCOORD_T_SCALE(t_scale, t_bias, t_wrap, id) \
+ ( \
+ (u32)(t_scale) << 0 | \
+ (u32)(t_bias) << 16 | \
+ (u32)(t_wrap) << 17 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_LOAD_TLUT0(ptr, id) \
+ ( \
+ (u32)(ptr) << 0 | \
+ (u32)(id) << 24 \
+ )
+
+#define BP_LOAD_TLUT1(ptr, size, id) \
+ ( \
+ (u32)(ptr) << 0 | \
+ (u32)(size) << 10 | \
+ (u32)(id) << 24 \
+ )
+
+void GDSetTexLookupMode(GXTexMapID id, GXTexWrapMode wrap_s,
+ GXTexWrapMode wrap_t, GXTexFilter min_filt,
+ GXTexFilter mag_filt, f32 min_lod, f32 max_lod,
+ f32 lod_bias, u8 bias_clamp, u8 do_edge_lod,
+ GXAnisotropy max_aniso);
+
+void GDSetTexImgAttr(GXTexMapID id, u16 width, u16 height, GXTexFmt format);
+void GDSetTexImgPtr(GXTexMapID id, void* image_ptr);
+void GDSetTexImgPtrRaw(GXTexMapID id, u32 image_ptr_raw);
+void GDPatchTexImgPtr(void* image_ptr);
+void GDSetTexCached(GXTexMapID id, u32 tmem_even, GXTexCacheSize size_even,
+ u32 tmem_odd, GXTexCacheSize size_odd);
+void GDSetTexPreLoaded(GXTexMapID id, u32 tmem_even, u32 tmem_odd);
+void GDSetTexTlut(GXTexMapID id, u32 tmem_addr, GXTlutFmt format);
+void GDSetTexCoordScale(GXTexCoordID coord, u16 s_scale, u16 t_scale);
+void GDSetTexCoordScale2(GXTexCoordID coord, u16 s_scale, u8 s_bias,
+ u8 s_wrap, u16 t_scale, u8 t_bias, u8 t_wrap);
+void GDSetTexCoordScaleAndTOEs(GXTexCoordID coord, u16 s_scale, u8 s_bias,
+ u8 s_wrap, u16 t_scale, u8 t_bias, u8 t_wrap,
+ u8 line_offset, u8 point_offset);
+void GDLoadTlut(void* tlut_ptr, u32 tmem_addr, GXTlutSize size);
+void GDLoadTlutRaw(u32 tlut_ptr_raw, u32 tmem_addr, GXTlutSize size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gd/GDTransform.h b/include/revolution/gd/GDTransform.h
new file mode 100644
index 0000000000..18d53f98a2
--- /dev/null
+++ b/include/revolution/gd/GDTransform.h
@@ -0,0 +1,56 @@
+#ifndef _REVOLUTION_GD_TRANSFORM_H_
+#define _REVOLUTION_GD_TRANSFORM_H_
+
+#include <revolution/types.h>
+#include <revolution/gx/GXEnum.h>
+#include <revolution/mtx.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CP_MTX_REG_A_ID 0x30
+#define CP_MTX_REG_B_ID 0x40
+
+#define XF_REG_MATRIXINDEX0_ID 0x1018
+#define XF_REG_MATRIXINDEX1_ID 0x1019
+#define XF_REG_PROJECTIONA_ID 0x1020
+#define XF_REG_PROJECTIONB_ID 0x1021
+#define XF_REG_PROJECTIONC_ID 0x1022
+#define XF_REG_PROJECTIOND_ID 0x1023
+#define XF_REG_PROJECTIONE_ID 0x1024
+#define XF_REG_PROJECTIONF_ID 0x1025
+#define XF_REG_PROJECTORTHO_ID 0x1026
+
+#define CP_MTX_REG_A(pn, t0, t1, t2, t3) \
+ ( \
+ (u32)(pn) << 0 | \
+ (u32)(t0) << 6 | \
+ (u32)(t1) << 12 | \
+ (u32)(t2) << 18 | \
+ (u32)(t3) << 24 \
+ )
+
+#define CP_MTX_REG_B(t4, t5, t6, t7) \
+ ( \
+ (u32)(t4) << 0 | \
+ (u32)(t5) << 6 | \
+ (u32)(t6) << 12 | \
+ (u32)(t7) << 18 \
+ )
+
+void GDLoadPosMtxImm(const Mtx mtx, u32 id);
+void GDLoadPosMtxIndx(u16 mtx_indx, u32 id);
+void GDLoadNrmMtxImm(const Mtx mtx, u32 id);
+void GDLoadNrmMtxImm3x3(const f32 mtx[3][3], u32 id);
+void GDLoadNrmMtxIndx3x3(u16 mtx_indx, u32 id);
+void GDLoadTexMtxImm(const Mtx mtx, u32 id, GXTexMtxType type);
+void GDLoadTexMtxIndx(u16 mtx_indx, u32 id, GXTexMtxType type);
+void GDSetCurrentMtx(u32 pn, u32 t0, u32 t1, u32 t2, u32 t3, u32 t4, u32 t5, u32 t6, u32 t7);
+void GDSetProjection(const Mtx44 mtx, GXProjectionType type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gf.h b/include/revolution/gf.h
new file mode 100644
index 0000000000..7cb0b25392
--- /dev/null
+++ b/include/revolution/gf.h
@@ -0,0 +1,9 @@
+#ifndef _REVOLUTION_GF_H_
+#define _REVOLUTION_GF_H_
+
+#include <revolution/gf/GFGeometry.h>
+#include <revolution/gf/GFLight.h>
+#include <revolution/gf/GFPixel.h>
+#include <revolution/gf/GFTev.h>
+
+#endif
diff --git a/include/revolution/gf/GFGeometry.h b/include/revolution/gf/GFGeometry.h
new file mode 100644
index 0000000000..0a8a2c9a8c
--- /dev/null
+++ b/include/revolution/gf/GFGeometry.h
@@ -0,0 +1,41 @@
+#ifndef _REVOLUTION_GF_GFGEOMETRY_H
+#define _REVOLUTION_GF_GFGEOMETRY_H
+
+#include <revolution/gx.h>
+
+#define GF_GEN_MODE(nTexGens, nChans, nTevs, cm, nInds) \
+ ( \
+ (u32)(nTexGens) << 0 | \
+ (u32)(nChans) << 4 | \
+ (u32)(nTevs) << 10 | \
+ (u32)(cm) << 14 | \
+ (u32)(nInds) << 16 \
+ )
+
+static inline void GFWrite_u8(u8 data) {
+ GXCmd1u8(data);
+}
+
+static inline void GFWrite_u32(u32 data) {
+ GXCmd1u32(data);
+}
+
+static inline void GFWrite_u16(u16 data) {
+ GXCmd1u16(data);
+}
+
+static inline void GFWriteBPCmd(u32 regval) {
+ GFWrite_u8(GX_LOAD_BP_REG);
+ GFWrite_u32(regval);
+}
+
+static inline void GFWriteXFCmd(u16 addr, u32 val) {
+ GFWrite_u8(GX_LOAD_XF_REG);
+ GFWrite_u16(0);
+ GFWrite_u16(addr);
+ GFWrite_u32(val);
+}
+
+void GFSetGenMode2(u8 nTexGens, u8 nChans, u8 nTevs, u8 nInds, GXCullMode cm);
+
+#endif /* _REVOLUTION_GF_GFGEOMETRY_H */
diff --git a/include/revolution/gf/GFLight.h b/include/revolution/gf/GFLight.h
new file mode 100644
index 0000000000..0de95863a3
--- /dev/null
+++ b/include/revolution/gf/GFLight.h
@@ -0,0 +1,8 @@
+#ifndef _REVOLUTION_GF_GFLIGHT_H
+#define _REVOLUTION_GF_GFLIGHT_H
+
+#include <revolution/gx.h>
+
+void GFSetChanAmbColor(GXChannelID chan, GXColor color);
+
+#endif /* _REVOLUTION_GF_GFLIGHT_H */
diff --git a/include/revolution/gf/GFPixel.h b/include/revolution/gf/GFPixel.h
new file mode 100644
index 0000000000..a536840c54
--- /dev/null
+++ b/include/revolution/gf/GFPixel.h
@@ -0,0 +1,13 @@
+#ifndef _REVOLUTION_GF_GFPIXEL_H
+#define _REVOLUTION_GF_GFPIXEL_H
+
+#include <revolution/gx.h>
+
+void GFSetFog(GXFogType type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor color);
+void GFSetBlendModeEtc(GXBlendMode type, GXBlendFactor src_factor,
+ GXBlendFactor dst_factor, GXLogicOp logic_op,
+ u8 color_update_enable, u8 alpha_update_enable,
+ u8 dither_enable);
+void GFSetZMode(u8 compare_enable, GXCompare func, u8 update_enable);
+
+#endif /* _REVOLUTION_GF_GFPIXEL_H */
diff --git a/include/revolution/gf/GFTev.h b/include/revolution/gf/GFTev.h
new file mode 100644
index 0000000000..ad7a2a5b03
--- /dev/null
+++ b/include/revolution/gf/GFTev.h
@@ -0,0 +1,8 @@
+#ifndef _REVOLUTION_GF_GFTEV_H
+#define _REVOLUTION_GF_GFTEV_H
+
+#include <revolution/gx.h>
+
+void GFSetTevColorS10(GXTevRegID reg, GXColorS10 color);
+
+#endif /* _REVOLUTION_GF_GFTEV_H */
diff --git a/include/revolution/gx.h b/include/revolution/gx.h
new file mode 100644
index 0000000000..708b85e8b2
--- /dev/null
+++ b/include/revolution/gx.h
@@ -0,0 +1,40 @@
+#ifndef _REVOLUTION_GX_H_
+#define _REVOLUTION_GX_H_
+
+#include <revolution/gx/GXStruct.h>
+#include <revolution/gx/GXTransform.h>
+#include <revolution/gx/GXTev.h>
+#include <revolution/gx/GXPixel.h>
+#include <revolution/gx/GXManage.h>
+#include <revolution/gx/GXFifo.h>
+#include <revolution/gx/GXCull.h>
+#include <revolution/gx/GXGeometry.h>
+#include <revolution/gx/GXVert.h>
+#include <revolution/gx/GXTexture.h>
+#include <revolution/gx/GXTev.h>
+#include <revolution/gx/GXLighting.h>
+#include <revolution/gx/GXDispList.h>
+#include <revolution/gx/GXCommandList.h>
+#include <revolution/gx/GXBump.h>
+#include <revolution/gx/GXFrameBuffer.h>
+#include <revolution/gx/GXGet.h>
+#include <revolution/gx/GXDraw.h>
+#include <revolution/gx/GXPerf.h>
+#include <revolution/gx/GXCpu2Efb.h>
+#include <revolution/gx/GXVerify.h>
+
+// unsorted GX externs
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// GXMisc
+void (*GXSetDrawSyncCallback(void (*cb)(u16)))(u16);
+void GXSetDrawSync(u16 token);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXBump.h b/include/revolution/gx/GXBump.h
new file mode 100644
index 0000000000..9b4f9273e2
--- /dev/null
+++ b/include/revolution/gx/GXBump.h
@@ -0,0 +1,29 @@
+#ifndef _REVOLUTION_GX_GXBUMP_H_
+#define _REVOLUTION_GX_GXBUMP_H_
+
+#include <revolution/gx/GXEnum.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXSetTevIndirect(GXTevStageID tev_stage, GXIndTexStageID ind_stage, GXIndTexFormat format, GXIndTexBiasSel bias_sel, GXIndTexMtxID matrix_sel, GXIndTexWrap wrap_s, GXIndTexWrap wrap_t, GXBool add_prev, GXBool utc_lod, GXIndTexAlphaSel alpha_sel);
+void GXSetIndTexMtx(GXIndTexMtxID mtx_id, const f32 offset[2][3], s8 scale_exp);
+void GXSetIndTexCoordScale(GXIndTexStageID ind_state, GXIndTexScale scale_s, GXIndTexScale scale_t);
+void GXSetIndTexOrder(GXIndTexStageID ind_stage, GXTexCoordID tex_coord, GXTexMapID tex_map);
+void GXSetNumIndStages(u8 nIndStages);
+void GXSetTevDirect(GXTevStageID tev_stage);
+void GXSetTevIndWarp(GXTevStageID tev_stage, GXIndTexStageID ind_stage, u8 signed_offset, u8 replace_mode, GXIndTexMtxID matrix_sel);
+void GXSetTevIndTile(GXTevStageID tev_stage, GXIndTexStageID ind_stage, u16 tilesize_s,
+ u16 tilesize_t, u16 tilespacing_s, u16 tilespacing_t, GXIndTexFormat format,
+ GXIndTexMtxID matrix_sel, GXIndTexBiasSel bias_sel, GXIndTexAlphaSel alpha_sel);
+void GXSetTevIndBumpST(GXTevStageID tev_stage, GXIndTexStageID ind_stage, GXIndTexMtxID matrix_sel);
+void GXSetTevIndBumpXYZ(GXTevStageID tev_stage, GXIndTexStageID ind_stage, GXIndTexMtxID matrix_sel);
+void GXSetTevIndRepeat(GXTevStageID tev_stage);
+void __GXSetIndirectMask(u32 mask);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXCommandList.h b/include/revolution/gx/GXCommandList.h
new file mode 100644
index 0000000000..a7ce1fdb3f
--- /dev/null
+++ b/include/revolution/gx/GXCommandList.h
@@ -0,0 +1,37 @@
+#ifndef _REVOLUTION_GX_GXCOMMANDLIST_H_
+#define _REVOLUTION_GX_GXCOMMANDLIST_H_
+
+#include <revolution/types.h>
+
+#define GX_NOP 0x00
+#define GX_LOAD_CP_REG 0x08
+#define GX_LOAD_XF_REG 0x10
+#define GX_LOAD_INDX_A 0x20
+#define GX_LOAD_INDX_B 0x28
+#define GX_LOAD_INDX_C 0x30
+#define GX_LOAD_INDX_D 0x38
+#define GX_LOAD_BP_REG 0x61
+
+#define GX_DRAW_QUADS 0x80
+#define GX_DRAW_TRIANGLES 0x90
+#define GX_DRAW_TRIANGLE_STRIP 0x98
+#define GX_DRAW_TRIANGLE_FAN 0xA0
+#define GX_DRAW_LINES 0xA8
+#define GX_DRAW_LINE_STRIP 0xB0
+#define GX_DRAW_POINTS 0xB8
+
+#define GX_CMD_CALL_DL 0x40
+#define GX_CMD_INVAL_VTX 0x48
+
+#define GX_OPCODE_MASK 0xF8
+#define GX_VAT_MASK 0x07
+
+extern u8 GXTexMode0Ids[8];
+extern u8 GXTexMode1Ids[8];
+extern u8 GXTexImage0Ids[8];
+extern u8 GXTexImage1Ids[8];
+extern u8 GXTexImage2Ids[8];
+extern u8 GXTexImage3Ids[8];
+extern u8 GXTexTlutIds[8];
+
+#endif
diff --git a/include/revolution/gx/GXCpu2Efb.h b/include/revolution/gx/GXCpu2Efb.h
new file mode 100644
index 0000000000..16ba190ea2
--- /dev/null
+++ b/include/revolution/gx/GXCpu2Efb.h
@@ -0,0 +1,29 @@
+#ifndef _REVOLUTION_GX_GXCPU2EFB_H_
+#define _REVOLUTION_GX_GXCPU2EFB_H_
+
+#include <revolution/gx/GXEnum.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXPokeAlphaMode(GXCompare func, u8 threshold);
+void GXPokeAlphaRead(GXAlphaReadMode mode);
+void GXPokeAlphaUpdate(GXBool update_enable);
+void GXPokeBlendMode(GXBlendMode type, GXBlendFactor src_factor, GXBlendFactor dst_factor, GXLogicOp op);
+void GXPokeColorUpdate(GXBool update_enable);
+void GXPokeDstAlpha(GXBool enable, u8 alpha);
+void GXPokeDither(GXBool dither);
+void GXPokeZMode(GXBool compare_enable, GXCompare func, GXBool update_enable);
+void GXPeekARGB(u16 x, u16 y, u32* color);
+void GXPokeARGB(u16 x, u16 y, u32 color);
+void GXPeekZ(u16 x, u16 y, u32* z);
+void GXPokeZ(u16 x, u16 y, u32 z);
+u32 GXCompressZ16(u32 z24, GXZFmt16 zfmt);
+u32 GXDecompressZ16(u32 z16, GXZFmt16 zfmt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXCull.h b/include/revolution/gx/GXCull.h
new file mode 100644
index 0000000000..2c33e1bb74
--- /dev/null
+++ b/include/revolution/gx/GXCull.h
@@ -0,0 +1,18 @@
+#ifndef _REVOLUTION_GX_GXCULL_H_
+#define _REVOLUTION_GX_GXCULL_H_
+
+#include <revolution/gx/GXEnum.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXSetScissor(u32 left, u32 top, u32 wd, u32 ht);
+void GXSetCullMode(GXCullMode mode);
+void GXSetCoPlanar(GXBool enable);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXDispList.h b/include/revolution/gx/GXDispList.h
new file mode 100644
index 0000000000..81c9e400df
--- /dev/null
+++ b/include/revolution/gx/GXDispList.h
@@ -0,0 +1,18 @@
+#ifndef _REVOLUTION_GX_GXDISPLIST_H_
+#define _REVOLUTION_GX_GXDISPLIST_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXBeginDisplayList(void* list, u32 size);
+u32 GXEndDisplayList(void);
+void GXCallDisplayList(void* list, u32 nbytes);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXDraw.h b/include/revolution/gx/GXDraw.h
new file mode 100644
index 0000000000..6dd46a8366
--- /dev/null
+++ b/include/revolution/gx/GXDraw.h
@@ -0,0 +1,24 @@
+#ifndef _REVOLUTION_GX_GXDRAW_H_
+#define _REVOLUTION_GX_GXDRAW_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXDrawCylinder(u8 numEdges);
+void GXDrawTorus(f32 rc, u8 numc, u8 numt);
+void GXDrawSphere(u8 numMajor, u8 numMinor);
+void GXDrawCube(void);
+void GXDrawDodeca(void);
+void GXDrawOctahedron(void);
+void GXDrawIcosahedron(void);
+void GXDrawSphere1(u8 depth);
+u32 GXGenNormalTable(u8 depth, f32* table);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXEnum.h b/include/revolution/gx/GXEnum.h
new file mode 100644
index 0000000000..0a719b5103
--- /dev/null
+++ b/include/revolution/gx/GXEnum.h
@@ -0,0 +1,924 @@
+#ifndef _REVOLUTION_GX_GXENUM_H_
+#define _REVOLUTION_GX_GXENUM_H_
+
+#include <revolution/types.h>
+
+typedef u8 GXBool;
+
+#define GX_FALSE ((GXBool)0)
+#define GX_TRUE ((GXBool)1)
+
+#define GX_ENABLE ((GXBool)1)
+#define GX_DISABLE ((GXBool)0)
+
+typedef enum _GXProjectionType {
+ GX_PERSPECTIVE,
+ GX_ORTHOGRAPHIC,
+} GXProjectionType;
+
+typedef enum _GXCompare {
+ GX_NEVER,
+ GX_LESS,
+ GX_EQUAL,
+ GX_LEQUAL,
+ GX_GREATER,
+ GX_NEQUAL,
+ GX_GEQUAL,
+ GX_ALWAYS,
+} GXCompare;
+
+typedef enum _GXAlphaOp {
+ GX_AOP_AND,
+ GX_AOP_OR,
+ GX_AOP_XOR,
+ GX_AOP_XNOR,
+ GX_MAX_ALPHAOP,
+} GXAlphaOp;
+
+typedef enum _GXZFmt16 {
+ GX_ZC_LINEAR,
+ GX_ZC_NEAR,
+ GX_ZC_MID,
+ GX_ZC_FAR,
+} GXZFmt16;
+
+typedef enum _GXGamma {
+ GX_GM_1_0,
+ GX_GM_1_7,
+ GX_GM_2_2,
+} GXGamma;
+
+typedef enum _GXPixelFmt {
+ GX_PF_RGB8_Z24,
+ GX_PF_RGBA6_Z24,
+ GX_PF_RGB565_Z16,
+ GX_PF_Z24,
+ GX_PF_Y8,
+ GX_PF_U8,
+ GX_PF_V8,
+ GX_PF_YUV420,
+} GXPixelFmt;
+
+typedef enum _GXPrimitive {
+ GX_QUADS = 0x80,
+ GX_TRIANGLES = 0x90,
+ GX_TRIANGLESTRIP = 0x98,
+ GX_TRIANGLEFAN = 0xA0,
+ GX_LINES = 0xA8,
+ GX_LINESTRIP = 0xB0,
+ GX_POINTS = 0xB8,
+} GXPrimitive;
+
+typedef enum _GXVtxFmt {
+ GX_VTXFMT0,
+ GX_VTXFMT1,
+ GX_VTXFMT2,
+ GX_VTXFMT3,
+ GX_VTXFMT4,
+ GX_VTXFMT5,
+ GX_VTXFMT6,
+ GX_VTXFMT7,
+ GX_MAX_VTXFMT,
+} GXVtxFmt;
+
+typedef enum _GXAttr {
+ GX_VA_PNMTXIDX,
+ GX_VA_TEX0MTXIDX,
+ GX_VA_TEX1MTXIDX,
+ GX_VA_TEX2MTXIDX,
+ GX_VA_TEX3MTXIDX,
+ GX_VA_TEX4MTXIDX,
+ GX_VA_TEX5MTXIDX,
+ GX_VA_TEX6MTXIDX,
+ GX_VA_TEX7MTXIDX,
+ GX_VA_POS,
+ GX_VA_NRM,
+ GX_VA_CLR0,
+ GX_VA_CLR1,
+ GX_VA_TEX0,
+ GX_VA_TEX1,
+ GX_VA_TEX2,
+ GX_VA_TEX3,
+ GX_VA_TEX4,
+ GX_VA_TEX5,
+ GX_VA_TEX6,
+ GX_VA_TEX7,
+ GX_POS_MTX_ARRAY,
+ GX_NRM_MTX_ARRAY,
+ GX_TEX_MTX_ARRAY,
+ GX_LIGHT_ARRAY,
+ GX_VA_NBT,
+ GX_VA_MAX_ATTR,
+ GX_VA_NULL = 0xFF,
+} GXAttr;
+
+typedef enum _GXAttrType {
+ GX_NONE,
+ GX_DIRECT,
+ GX_INDEX8,
+ GX_INDEX16,
+} GXAttrType;
+
+#define _GX_TF_CTF 0x20
+#define _GX_TF_ZTF 0x10
+
+typedef enum _GXTexFmt {
+ GX_TF_I4 = 0x0,
+ GX_TF_I8 = 0x1,
+ GX_TF_IA4 = 0x2,
+ GX_TF_IA8 = 0x3,
+ GX_TF_RGB565 = 0x4,
+ GX_TF_RGB5A3 = 0x5,
+ GX_TF_RGBA8 = 0x6,
+ GX_TF_CMPR = 0xE,
+
+ GX_CTF_R4 = 0x0 | _GX_TF_CTF,
+ GX_CTF_RA4 = 0x2 | _GX_TF_CTF,
+ GX_CTF_RA8 = 0x3 | _GX_TF_CTF,
+ GX_CTF_YUVA8 = 0x6 | _GX_TF_CTF,
+ GX_CTF_A8 = 0x7 | _GX_TF_CTF,
+ GX_CTF_R8 = 0x8 | _GX_TF_CTF,
+ GX_CTF_G8 = 0x9 | _GX_TF_CTF,
+ GX_CTF_B8 = 0xA | _GX_TF_CTF,
+ GX_CTF_RG8 = 0xB | _GX_TF_CTF,
+ GX_CTF_GB8 = 0xC | _GX_TF_CTF,
+
+ GX_TF_Z8 = 0x1 | _GX_TF_ZTF,
+ GX_TF_Z16 = 0x3 | _GX_TF_ZTF,
+ GX_TF_Z24X8 = 0x6 | _GX_TF_ZTF,
+
+ GX_CTF_Z4 = 0x0 | _GX_TF_ZTF | _GX_TF_CTF,
+ GX_CTF_Z8M = 0x9 | _GX_TF_ZTF | _GX_TF_CTF,
+ GX_CTF_Z8L = 0xA | _GX_TF_ZTF | _GX_TF_CTF,
+ GX_CTF_Z16L = 0xC | _GX_TF_ZTF | _GX_TF_CTF,
+
+ GX_TF_A8 = GX_CTF_A8,
+} GXTexFmt;
+
+typedef enum _GXCITexFmt {
+ GX_TF_C4 = 0x8,
+ GX_TF_C8 = 0x9,
+ GX_TF_C14X2 = 0xA,
+} GXCITexFmt;
+
+typedef enum _GXTexWrapMode {
+ GX_CLAMP,
+ GX_REPEAT,
+ GX_MIRROR,
+ GX_MAX_TEXWRAPMODE,
+} GXTexWrapMode;
+
+typedef enum _GXTexFilter {
+ GX_NEAR,
+ GX_LINEAR,
+ GX_NEAR_MIP_NEAR,
+ GX_LIN_MIP_NEAR,
+ GX_NEAR_MIP_LIN,
+ GX_LIN_MIP_LIN,
+} GXTexFilter;
+
+typedef enum _GXAnisotropy {
+ GX_ANISO_1,
+ GX_ANISO_2,
+ GX_ANISO_4,
+ GX_MAX_ANISOTROPY,
+} GXAnisotropy;
+
+typedef enum _GXTexMapID {
+ GX_TEXMAP0,
+ GX_TEXMAP1,
+ GX_TEXMAP2,
+ GX_TEXMAP3,
+ GX_TEXMAP4,
+ GX_TEXMAP5,
+ GX_TEXMAP6,
+ GX_TEXMAP7,
+ GX_MAX_TEXMAP,
+ GX_TEXMAP_NULL = 0xFF,
+ GX_TEX_DISABLE = 0x100,
+} GXTexMapID;
+
+typedef enum _GXTexCoordID {
+ GX_TEXCOORD0,
+ GX_TEXCOORD1,
+ GX_TEXCOORD2,
+ GX_TEXCOORD3,
+ GX_TEXCOORD4,
+ GX_TEXCOORD5,
+ GX_TEXCOORD6,
+ GX_TEXCOORD7,
+ GX_MAX_TEXCOORD,
+ GX_TEXCOORD_NULL = 0xFF,
+} GXTexCoordID;
+
+typedef enum _GXTevStageID {
+ GX_TEVSTAGE0,
+ GX_TEVSTAGE1,
+ GX_TEVSTAGE2,
+ GX_TEVSTAGE3,
+ GX_TEVSTAGE4,
+ GX_TEVSTAGE5,
+ GX_TEVSTAGE6,
+ GX_TEVSTAGE7,
+ GX_TEVSTAGE8,
+ GX_TEVSTAGE9,
+ GX_TEVSTAGE10,
+ GX_TEVSTAGE11,
+ GX_TEVSTAGE12,
+ GX_TEVSTAGE13,
+ GX_TEVSTAGE14,
+ GX_TEVSTAGE15,
+ GX_MAX_TEVSTAGE,
+} GXTevStageID;
+
+typedef enum _GXTevMode {
+ GX_MODULATE,
+ GX_DECAL,
+ GX_BLEND,
+ GX_REPLACE,
+ GX_PASSCLR,
+} GXTevMode;
+
+typedef enum _GXTexMtxType {
+ GX_MTX3x4,
+ GX_MTX2x4,
+} GXTexMtxType;
+
+typedef enum _GXTexGenType {
+ GX_TG_MTX3x4,
+ GX_TG_MTX2x4,
+ GX_TG_BUMP0,
+ GX_TG_BUMP1,
+ GX_TG_BUMP2,
+ GX_TG_BUMP3,
+ GX_TG_BUMP4,
+ GX_TG_BUMP5,
+ GX_TG_BUMP6,
+ GX_TG_BUMP7,
+ GX_TG_SRTG,
+} GXTexGenType;
+
+typedef enum _GXPosNrmMtx {
+ GX_PNMTX0 = 0,
+ GX_PNMTX1 = 3,
+ GX_PNMTX2 = 6,
+ GX_PNMTX3 = 9,
+ GX_PNMTX4 = 12,
+ GX_PNMTX5 = 15,
+ GX_PNMTX6 = 18,
+ GX_PNMTX7 = 21,
+ GX_PNMTX8 = 24,
+ GX_PNMTX9 = 27,
+} GXPosNrmMtx;
+
+typedef enum _GXTexMtx {
+ GX_TEXMTX0 = 30,
+ GX_TEXMTX1 = 33,
+ GX_TEXMTX2 = 36,
+ GX_TEXMTX3 = 39,
+ GX_TEXMTX4 = 42,
+ GX_TEXMTX5 = 45,
+ GX_TEXMTX6 = 48,
+ GX_TEXMTX7 = 51,
+ GX_TEXMTX8 = 54,
+ GX_TEXMTX9 = 57,
+ GX_IDENTITY = 60,
+} GXTexMtx;
+
+typedef enum _GXChannelID {
+ GX_COLOR0,
+ GX_COLOR1,
+ GX_ALPHA0,
+ GX_ALPHA1,
+ GX_COLOR0A0,
+ GX_COLOR1A1,
+ GX_COLOR_ZERO,
+ GX_ALPHA_BUMP,
+ GX_ALPHA_BUMPN,
+ GX_COLOR_NULL = 0xFF,
+} GXChannelID;
+
+typedef enum _GXTexGenSrc {
+ GX_TG_POS,
+ GX_TG_NRM,
+ GX_TG_BINRM,
+ GX_TG_TANGENT,
+ GX_TG_TEX0,
+ GX_TG_TEX1,
+ GX_TG_TEX2,
+ GX_TG_TEX3,
+ GX_TG_TEX4,
+ GX_TG_TEX5,
+ GX_TG_TEX6,
+ GX_TG_TEX7,
+ GX_TG_TEXCOORD0,
+ GX_TG_TEXCOORD1,
+ GX_TG_TEXCOORD2,
+ GX_TG_TEXCOORD3,
+ GX_TG_TEXCOORD4,
+ GX_TG_TEXCOORD5,
+ GX_TG_TEXCOORD6,
+ GX_TG_COLOR0,
+ GX_TG_COLOR1,
+} GXTexGenSrc;
+
+typedef enum _GXBlendMode {
+ GX_BM_NONE,
+ GX_BM_BLEND,
+ GX_BM_LOGIC,
+ GX_BM_SUBTRACT,
+ GX_MAX_BLENDMODE,
+} GXBlendMode;
+
+typedef enum _GXBlendFactor {
+ GX_BL_ZERO,
+ GX_BL_ONE,
+ GX_BL_SRCCLR,
+ GX_BL_INVSRCCLR,
+ GX_BL_SRCALPHA,
+ GX_BL_INVSRCALPHA,
+ GX_BL_DSTALPHA,
+ GX_BL_INVDSTALPHA,
+ GX_BL_DSTCLR = GX_BL_SRCCLR,
+ GX_BL_INVDSTCLR = GX_BL_INVSRCCLR,
+} GXBlendFactor;
+
+typedef enum _GXLogicOp {
+ GX_LO_CLEAR,
+ GX_LO_AND,
+ GX_LO_REVAND,
+ GX_LO_COPY,
+ GX_LO_INVAND,
+ GX_LO_NOOP,
+ GX_LO_XOR,
+ GX_LO_OR,
+ GX_LO_NOR,
+ GX_LO_EQUIV,
+ GX_LO_INV,
+ GX_LO_REVOR,
+ GX_LO_INVCOPY,
+ GX_LO_INVOR,
+ GX_LO_NAND,
+ GX_LO_SET,
+} GXLogicOp;
+
+typedef enum _GXCompCnt {
+ GX_POS_XY = 0,
+ GX_POS_XYZ = 1,
+ GX_NRM_XYZ = 0,
+ GX_NRM_NBT = 1,
+ GX_NRM_NBT3 = 2,
+ GX_CLR_RGB = 0,
+ GX_CLR_RGBA = 1,
+ GX_TEX_S = 0,
+ GX_TEX_ST = 1,
+} GXCompCnt;
+
+typedef enum _GXCompType {
+ GX_U8 = 0,
+ GX_S8 = 1,
+ GX_U16 = 2,
+ GX_S16 = 3,
+ GX_F32 = 4,
+ GX_RGB565 = 0,
+ GX_RGB8 = 1,
+ GX_RGBX8 = 2,
+ GX_RGBA4 = 3,
+ GX_RGBA6 = 4,
+ GX_RGBA8 = 5,
+} GXCompType;
+
+typedef enum _GXPTTexMtx {
+ GX_PTTEXMTX0 = 64,
+ GX_PTTEXMTX1 = 67,
+ GX_PTTEXMTX2 = 70,
+ GX_PTTEXMTX3 = 73,
+ GX_PTTEXMTX4 = 76,
+ GX_PTTEXMTX5 = 79,
+ GX_PTTEXMTX6 = 82,
+ GX_PTTEXMTX7 = 85,
+ GX_PTTEXMTX8 = 88,
+ GX_PTTEXMTX9 = 91,
+ GX_PTTEXMTX10 = 94,
+ GX_PTTEXMTX11 = 97,
+ GX_PTTEXMTX12 = 100,
+ GX_PTTEXMTX13 = 103,
+ GX_PTTEXMTX14 = 106,
+ GX_PTTEXMTX15 = 109,
+ GX_PTTEXMTX16 = 112,
+ GX_PTTEXMTX17 = 115,
+ GX_PTTEXMTX18 = 118,
+ GX_PTTEXMTX19 = 121,
+ GX_PTIDENTITY = 125,
+} GXPTTexMtx;
+
+typedef enum _GXTevRegID {
+ GX_TEVPREV,
+ GX_TEVREG0,
+ GX_TEVREG1,
+ GX_TEVREG2,
+ GX_MAX_TEVREG,
+} GXTevRegID;
+
+typedef enum _GXDiffuseFn {
+ GX_DF_NONE,
+ GX_DF_SIGN,
+ GX_DF_CLAMP,
+} GXDiffuseFn;
+
+typedef enum _GXColorSrc {
+ GX_SRC_REG,
+ GX_SRC_VTX,
+} GXColorSrc;
+
+typedef enum _GXAttnFn {
+ GX_AF_SPEC,
+ GX_AF_SPOT,
+ GX_AF_NONE,
+} GXAttnFn;
+
+typedef enum _GXLightID {
+ GX_LIGHT0 = 0x001,
+ GX_LIGHT1 = 0x002,
+ GX_LIGHT2 = 0x004,
+ GX_LIGHT3 = 0x008,
+ GX_LIGHT4 = 0x010,
+ GX_LIGHT5 = 0x020,
+ GX_LIGHT6 = 0x040,
+ GX_LIGHT7 = 0x080,
+ GX_MAX_LIGHT = 0x100,
+ GX_LIGHT_NULL = 0,
+} GXLightID;
+
+typedef enum _GXTexOffset {
+ GX_TO_ZERO,
+ GX_TO_SIXTEENTH,
+ GX_TO_EIGHTH,
+ GX_TO_FOURTH,
+ GX_TO_HALF,
+ GX_TO_ONE,
+ GX_MAX_TEXOFFSET,
+} GXTexOffset;
+
+typedef enum _GXSpotFn {
+ GX_SP_OFF,
+ GX_SP_FLAT,
+ GX_SP_COS,
+ GX_SP_COS2,
+ GX_SP_SHARP,
+ GX_SP_RING1,
+ GX_SP_RING2,
+} GXSpotFn;
+
+typedef enum _GXDistAttnFn {
+ GX_DA_OFF,
+ GX_DA_GENTLE,
+ GX_DA_MEDIUM,
+ GX_DA_STEEP,
+} GXDistAttnFn;
+
+typedef enum _GXCullMode {
+ GX_CULL_NONE,
+ GX_CULL_FRONT,
+ GX_CULL_BACK,
+ GX_CULL_ALL
+} GXCullMode;
+
+typedef enum _GXTevSwapSel {
+ GX_TEV_SWAP0 = 0,
+ GX_TEV_SWAP1,
+ GX_TEV_SWAP2,
+ GX_TEV_SWAP3,
+ GX_MAX_TEVSWAP
+} GXTevSwapSel;
+
+typedef enum _GXTevColorChan {
+ GX_CH_RED = 0,
+ GX_CH_GREEN,
+ GX_CH_BLUE,
+ GX_CH_ALPHA
+} GXTevColorChan;
+
+typedef enum _GXFogType {
+ GX_FOG_NONE = 0,
+ GX_FOG_PERSP_LIN = 2,
+ GX_FOG_PERSP_EXP = 4,
+ GX_FOG_PERSP_EXP2 = 5,
+ GX_FOG_PERSP_REVEXP = 6,
+ GX_FOG_PERSP_REVEXP2 = 7,
+ GX_FOG_ORTHO_LIN = 10,
+ GX_FOG_ORTHO_EXP = 12,
+ GX_FOG_ORTHO_EXP2 = 13,
+ GX_FOG_ORTHO_REVEXP = 14,
+ GX_FOG_ORTHO_REVEXP2 = 15,
+ GX_FOG_LIN = 2,
+ GX_FOG_EXP = 4,
+ GX_FOG_EXP2 = 5,
+ GX_FOG_REVEXP = 6,
+ GX_FOG_REVEXP2 = 7,
+} GXFogType;
+
+typedef enum _GXTevColorArg {
+ GX_CC_CPREV = 0,
+ GX_CC_APREV = 1,
+ GX_CC_C0 = 2,
+ GX_CC_A0 = 3,
+ GX_CC_C1 = 4,
+ GX_CC_A1 = 5,
+ GX_CC_C2 = 6,
+ GX_CC_A2 = 7,
+ GX_CC_TEXC = 8,
+ GX_CC_TEXA = 9,
+ GX_CC_RASC = 10,
+ GX_CC_RASA = 11,
+ GX_CC_ONE = 12,
+ GX_CC_HALF = 13,
+ GX_CC_KONST = 14,
+ GX_CC_ZERO = 15,
+ GX_CC_TEXRRR = 16,
+ GX_CC_TEXGGG = 17,
+ GX_CC_TEXBBB = 18,
+ GX_CC_QUARTER = 14,
+} GXTevColorArg;
+
+typedef enum _GXTevAlphaArg {
+ GX_CA_APREV = 0,
+ GX_CA_A0 = 1,
+ GX_CA_A1 = 2,
+ GX_CA_A2 = 3,
+ GX_CA_TEXA = 4,
+ GX_CA_RASA = 5,
+ GX_CA_KONST = 6,
+ GX_CA_ZERO = 7,
+ GX_CA_ONE = 6,
+} GXTevAlphaArg;
+
+typedef enum _GXTevOp {
+ GX_TEV_ADD = 0,
+ GX_TEV_SUB = 1,
+ GX_TEV_COMP_R8_GT = 8,
+ GX_TEV_COMP_R8_EQ = 9,
+ GX_TEV_COMP_GR16_GT = 10,
+ GX_TEV_COMP_GR16_EQ = 11,
+ GX_TEV_COMP_BGR24_GT = 12,
+ GX_TEV_COMP_BGR24_EQ = 13,
+ GX_TEV_COMP_RGB8_GT = 14,
+ GX_TEV_COMP_RGB8_EQ = 15,
+ GX_TEV_COMP_A8_GT = GX_TEV_COMP_RGB8_GT,
+ GX_TEV_COMP_A8_EQ = GX_TEV_COMP_RGB8_EQ
+} GXTevOp;
+
+typedef enum _GXTevBias {
+ GX_TB_ZERO,
+ GX_TB_ADDHALF,
+ GX_TB_SUBHALF,
+ GX_MAX_TEVBIAS
+} GXTevBias;
+
+typedef enum _GXTevScale {
+ GX_CS_SCALE_1,
+ GX_CS_SCALE_2,
+ GX_CS_SCALE_4,
+ GX_CS_DIVIDE_2,
+ GX_MAX_TEVSCALE
+} GXTevScale;
+
+typedef enum _GXTevKColorSel {
+ GX_TEV_KCSEL_1 = 0x00,
+ GX_TEV_KCSEL_7_8 = 0x01,
+ GX_TEV_KCSEL_3_4 = 0x02,
+ GX_TEV_KCSEL_5_8 = 0x03,
+ GX_TEV_KCSEL_1_2 = 0x04,
+ GX_TEV_KCSEL_3_8 = 0x05,
+ GX_TEV_KCSEL_1_4 = 0x06,
+ GX_TEV_KCSEL_1_8 = 0x07,
+ GX_TEV_KCSEL_K0 = 0x0C,
+ GX_TEV_KCSEL_K1 = 0x0D,
+ GX_TEV_KCSEL_K2 = 0x0E,
+ GX_TEV_KCSEL_K3 = 0x0F,
+ GX_TEV_KCSEL_K0_R = 0x10,
+ GX_TEV_KCSEL_K1_R = 0x11,
+ GX_TEV_KCSEL_K2_R = 0x12,
+ GX_TEV_KCSEL_K3_R = 0x13,
+ GX_TEV_KCSEL_K0_G = 0x14,
+ GX_TEV_KCSEL_K1_G = 0x15,
+ GX_TEV_KCSEL_K2_G = 0x16,
+ GX_TEV_KCSEL_K3_G = 0x17,
+ GX_TEV_KCSEL_K0_B = 0x18,
+ GX_TEV_KCSEL_K1_B = 0x19,
+ GX_TEV_KCSEL_K2_B = 0x1A,
+ GX_TEV_KCSEL_K3_B = 0x1B,
+ GX_TEV_KCSEL_K0_A = 0x1C,
+ GX_TEV_KCSEL_K1_A = 0x1D,
+ GX_TEV_KCSEL_K2_A = 0x1E,
+ GX_TEV_KCSEL_K3_A = 0x1F
+} GXTevKColorSel;
+
+typedef enum _GXTevKAlphaSel {
+ GX_TEV_KASEL_1 = 0x00,
+ GX_TEV_KASEL_7_8 = 0x01,
+ GX_TEV_KASEL_3_4 = 0x02,
+ GX_TEV_KASEL_5_8 = 0x03,
+ GX_TEV_KASEL_1_2 = 0x04,
+ GX_TEV_KASEL_3_8 = 0x05,
+ GX_TEV_KASEL_1_4 = 0x06,
+ GX_TEV_KASEL_1_8 = 0x07,
+ GX_TEV_KASEL_K0_R = 0x10,
+ GX_TEV_KASEL_K1_R = 0x11,
+ GX_TEV_KASEL_K2_R = 0x12,
+ GX_TEV_KASEL_K3_R = 0x13,
+ GX_TEV_KASEL_K0_G = 0x14,
+ GX_TEV_KASEL_K1_G = 0x15,
+ GX_TEV_KASEL_K2_G = 0x16,
+ GX_TEV_KASEL_K3_G = 0x17,
+ GX_TEV_KASEL_K0_B = 0x18,
+ GX_TEV_KASEL_K1_B = 0x19,
+ GX_TEV_KASEL_K2_B = 0x1A,
+ GX_TEV_KASEL_K3_B = 0x1B,
+ GX_TEV_KASEL_K0_A = 0x1C,
+ GX_TEV_KASEL_K1_A = 0x1D,
+ GX_TEV_KASEL_K2_A = 0x1E,
+ GX_TEV_KASEL_K3_A = 0x1F
+} GXTevKAlphaSel;
+
+typedef enum _GXTevKColorID {
+ GX_KCOLOR0 = 0,
+ GX_KCOLOR1,
+ GX_KCOLOR2,
+ GX_KCOLOR3,
+ GX_MAX_KCOLOR
+} GXTevKColorID;
+
+typedef enum _GXZTexOp {
+ GX_ZT_DISABLE,
+ GX_ZT_ADD,
+ GX_ZT_REPLACE,
+ GX_MAX_ZTEXOP,
+} GXZTexOp;
+
+typedef enum _GXIndTexFormat {
+ GX_ITF_8,
+ GX_ITF_5,
+ GX_ITF_4,
+ GX_ITF_3,
+ GX_MAX_ITFORMAT,
+} GXIndTexFormat;
+
+typedef enum _GXIndTexBiasSel {
+ GX_ITB_NONE,
+ GX_ITB_S,
+ GX_ITB_T,
+ GX_ITB_ST,
+ GX_ITB_U,
+ GX_ITB_SU,
+ GX_ITB_TU,
+ GX_ITB_STU,
+ GX_MAX_ITBIAS,
+} GXIndTexBiasSel;
+
+typedef enum _GXIndTexAlphaSel {
+ GX_ITBA_OFF,
+ GX_ITBA_S,
+ GX_ITBA_T,
+ GX_ITBA_U,
+ GX_MAX_ITBALPHA,
+} GXIndTexAlphaSel;
+
+typedef enum _GXIndTexMtxID {
+ GX_ITM_OFF,
+ GX_ITM_0,
+ GX_ITM_1,
+ GX_ITM_2,
+ GX_ITM_S0 = 5,
+ GX_ITM_S1,
+ GX_ITM_S2,
+ GX_ITM_T0 = 9,
+ GX_ITM_T1,
+ GX_ITM_T2,
+} GXIndTexMtxID;
+
+typedef enum _GXIndTexWrap {
+ GX_ITW_OFF,
+ GX_ITW_256,
+ GX_ITW_128,
+ GX_ITW_64,
+ GX_ITW_32,
+ GX_ITW_16,
+ GX_ITW_0,
+ GX_MAX_ITWRAP,
+} GXIndTexWrap;
+
+typedef enum _GXIndTexStageID {
+ GX_INDTEXSTAGE0,
+ GX_INDTEXSTAGE1,
+ GX_INDTEXSTAGE2,
+ GX_INDTEXSTAGE3,
+ GX_MAX_INDTEXSTAGE,
+} GXIndTexStageID;
+
+typedef enum _GXIndTexScale {
+ GX_ITS_1,
+ GX_ITS_2,
+ GX_ITS_4,
+ GX_ITS_8,
+ GX_ITS_16,
+ GX_ITS_32,
+ GX_ITS_64,
+ GX_ITS_128,
+ GX_ITS_256,
+ GX_MAX_ITSCALE,
+} GXIndTexScale;
+
+typedef enum _GXPerf0 {
+ GX_PERF0_VERTICES,
+ GX_PERF0_CLIP_VTX,
+ GX_PERF0_CLIP_CLKS,
+ GX_PERF0_XF_WAIT_IN,
+ GX_PERF0_XF_WAIT_OUT,
+ GX_PERF0_XF_XFRM_CLKS,
+ GX_PERF0_XF_LIT_CLKS,
+ GX_PERF0_XF_BOT_CLKS,
+ GX_PERF0_XF_REGLD_CLKS,
+ GX_PERF0_XF_REGRD_CLKS,
+ GX_PERF0_CLIP_RATIO,
+
+ GX_PERF0_TRIANGLES,
+ GX_PERF0_TRIANGLES_CULLED,
+ GX_PERF0_TRIANGLES_PASSED,
+ GX_PERF0_TRIANGLES_SCISSORED,
+ GX_PERF0_TRIANGLES_0TEX,
+ GX_PERF0_TRIANGLES_1TEX,
+ GX_PERF0_TRIANGLES_2TEX,
+ GX_PERF0_TRIANGLES_3TEX,
+ GX_PERF0_TRIANGLES_4TEX,
+ GX_PERF0_TRIANGLES_5TEX,
+ GX_PERF0_TRIANGLES_6TEX,
+ GX_PERF0_TRIANGLES_7TEX,
+ GX_PERF0_TRIANGLES_8TEX,
+ GX_PERF0_TRIANGLES_0CLR,
+ GX_PERF0_TRIANGLES_1CLR,
+ GX_PERF0_TRIANGLES_2CLR,
+
+ GX_PERF0_QUAD_0CVG,
+ GX_PERF0_QUAD_NON0CVG,
+ GX_PERF0_QUAD_1CVG,
+ GX_PERF0_QUAD_2CVG,
+ GX_PERF0_QUAD_3CVG,
+ GX_PERF0_QUAD_4CVG,
+ GX_PERF0_AVG_QUAD_CNT,
+
+ GX_PERF0_CLOCKS,
+ GX_PERF0_NONE,
+} GXPerf0;
+
+typedef enum _GXPerf1 {
+ GX_PERF1_TEXELS,
+ GX_PERF1_TX_IDLE,
+ GX_PERF1_TX_REGS,
+ GX_PERF1_TX_MEMSTALL,
+ GX_PERF1_TC_CHECK1_2,
+ GX_PERF1_TC_CHECK3_4,
+ GX_PERF1_TC_CHECK5_6,
+ GX_PERF1_TC_CHECK7_8,
+ GX_PERF1_TC_MISS,
+
+ GX_PERF1_VC_ELEMQ_FULL,
+ GX_PERF1_VC_MISSQ_FULL,
+ GX_PERF1_VC_MEMREQ_FULL,
+ GX_PERF1_VC_STATUS7,
+ GX_PERF1_VC_MISSREP_FULL,
+ GX_PERF1_VC_STREAMBUF_LOW,
+ GX_PERF1_VC_ALL_STALLS,
+ GX_PERF1_VERTICES,
+
+ GX_PERF1_FIFO_REQ,
+ GX_PERF1_CALL_REQ,
+ GX_PERF1_VC_MISS_REQ,
+ GX_PERF1_CP_ALL_REQ,
+
+ GX_PERF1_CLOCKS,
+ GX_PERF1_NONE,
+} GXPerf1;
+
+typedef enum _GXVCachePerf {
+ GX_VC_POS = 0,
+ GX_VC_NRM = 1,
+ GX_VC_CLR0 = 2,
+ GX_VC_CLR1 = 3,
+ GX_VC_TEX0 = 4,
+ GX_VC_TEX1 = 5,
+ GX_VC_TEX2 = 6,
+ GX_VC_TEX3 = 7,
+ GX_VC_TEX4 = 8,
+ GX_VC_TEX5 = 9,
+ GX_VC_TEX6 = 10,
+ GX_VC_TEX7 = 11,
+ GX_VC_ALL = 15,
+} GXVCachePerf;
+
+typedef enum _GXClipMode {
+ GX_CLIP_ENABLE = 0,
+ GX_CLIP_DISABLE = 1,
+} GXClipMode;
+
+typedef enum _GXFBClamp {
+ GX_CLAMP_NONE = 0,
+ GX_CLAMP_TOP = 1,
+ GX_CLAMP_BOTTOM = 2,
+} GXFBClamp;
+
+typedef enum _GXCopyMode {
+ GX_COPY_PROGRESSIVE = 0,
+ GX_COPY_INTLC_EVEN = 2,
+ GX_COPY_INTLC_ODD = 3,
+} GXCopyMode;
+
+typedef enum _GXAlphaReadMode {
+ GX_READ_00,
+ GX_READ_FF,
+ GX_READ_NONE,
+} GXAlphaReadMode;
+
+typedef enum _GXTexCacheSize {
+ GX_TEXCACHE_32K,
+ GX_TEXCACHE_128K,
+ GX_TEXCACHE_512K,
+ GX_TEXCACHE_NONE,
+} GXTexCacheSize;
+
+typedef enum _GXTlut {
+ GX_TLUT0,
+ GX_TLUT1,
+ GX_TLUT2,
+ GX_TLUT3,
+ GX_TLUT4,
+ GX_TLUT5,
+ GX_TLUT6,
+ GX_TLUT7,
+ GX_TLUT8,
+ GX_TLUT9,
+ GX_TLUT10,
+ GX_TLUT11,
+ GX_TLUT12,
+ GX_TLUT13,
+ GX_TLUT14,
+ GX_TLUT15,
+ GX_BIGTLUT0,
+ GX_BIGTLUT1,
+ GX_BIGTLUT2,
+ GX_BIGTLUT3,
+} GXTlut;
+
+typedef enum _GXTlutFmt {
+ GX_TL_IA8,
+ GX_TL_RGB565,
+ GX_TL_RGB5A3,
+ GX_MAX_TLUTFMT,
+} GXTlutFmt;
+
+typedef enum _GXTlutSize {
+ GX_TLUT_16 = 1,
+ GX_TLUT_32 = 2,
+ GX_TLUT_64 = 4,
+ GX_TLUT_128 = 8,
+ GX_TLUT_256 = 16,
+ GX_TLUT_512 = 32,
+ GX_TLUT_1K = 64,
+ GX_TLUT_2K = 128,
+ GX_TLUT_4K = 256,
+ GX_TLUT_8K = 512,
+ GX_TLUT_16K = 1024,
+} GXTlutSize;
+
+typedef enum _GXMiscToken {
+ GX_MT_XF_FLUSH = 1,
+ GX_MT_DL_SAVE_CONTEXT = 2,
+ GX_MT_ABORT_WAIT_COPYOUT = 3,
+ GX_MT_NULL = 0,
+} GXMiscToken;
+
+// temporary
+typedef enum _GXCommand {
+ GX_CMD_LOAD_INDX_A = 0x20,
+ GX_CMD_LOAD_INDX_B = 0x28,
+ GX_CMD_LOAD_INDX_C = 0x30,
+ GX_CMD_LOAD_INDX_D = 0x38,
+
+ GX_CMD_LOAD_CP_REG = 0x08,
+ GX_CMD_LOAD_XF_REG = 0x10,
+ GX_CMD_LOAD_BP_REG = 0x61,
+} GXCommand;
+
+typedef enum _GXCPRegs {
+ GX_CP_REG_MTXIDXA = 0x30, // Matrix index A
+ GX_CP_REG_MTXIDXB = 0x40, // Matrix index B
+ GX_CP_REG_VCD_LO = 0x50, // Vertex descriptor (lo)
+ GX_CP_REG_VCD_HI = 0x60, // Vertex descriptor (hi)
+ GX_CP_REG_VAT_GRP0 = 0x70, // Vertex attribute table (group 0)
+ GX_CP_REG_VAT_GRP1 = 0x80, // Vertex attribute table (group 1)
+ GX_CP_REG_VAT_GRP2 = 0x90, // Vertex attribute table (group 2)
+ GX_CP_REG_ARRAYBASE = 0xA0, // Vertex array start/base
+ GX_CP_REG_ARRAYSTRIDE = 0xB0, // Vertex array stride
+} GXCPRegs;
+
+#endif
diff --git a/include/revolution/gx/GXFifo.h b/include/revolution/gx/GXFifo.h
new file mode 100644
index 0000000000..b595b4c6fc
--- /dev/null
+++ b/include/revolution/gx/GXFifo.h
@@ -0,0 +1,46 @@
+#ifndef _REVOLUTION_GX_GXFIFO_H_
+#define _REVOLUTION_GX_GXFIFO_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/os/OSThread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ u8 pad[128];
+} GXFifoObj;
+
+typedef void (*GXBreakPtCallback)(void);
+
+void GXInitFifoBase(GXFifoObj* fifo, void* base, u32 size);
+void GXInitFifoPtrs(GXFifoObj* fifo, void* readPtr, void* writePtr);
+void GXInitFifoLimits(GXFifoObj* fifo, u32 hiWatermark, u32 loWatermark);
+void GXSetCPUFifo(GXFifoObj* fifo);
+void GXSetGPFifo(GXFifoObj* fifo);
+void GXSaveCPUFifo(GXFifoObj* fifo);
+void GXSaveGPFifo(GXFifoObj* fifo);
+void GXGetGPStatus(GXBool* overhi, GXBool* underlow, GXBool* readIdle, GXBool* cmdIdle, GXBool* brkpt);
+void GXGetFifoStatus(GXFifoObj* fifo, GXBool* overhi, GXBool* underflow, u32* fifoCount, GXBool* cpuWrite, GXBool* gpRead, GXBool* fifowrap);
+void GXGetFifoPtrs(GXFifoObj* fifo, void** readPtr, void** writePtr);
+void* GXGetFifoBase(const GXFifoObj* fifo);
+u32 GXGetFifoSize(const GXFifoObj* fifo);
+void GXGetFifoLimits(const GXFifoObj* fifo, u32* hi, u32* lo);
+GXBreakPtCallback GXSetBreakPtCallback(GXBreakPtCallback cb);
+void GXEnableBreakPt(void* break_pt);
+void GXDisableBreakPt(void);
+OSThread* GXSetCurrentGXThread(void);
+OSThread* GXGetCurrentGXThread(void);
+GXFifoObj* GXGetCPUFifo(void);
+GXFifoObj* GXGetGPFifo(void);
+u32 GXGetOverflowCount(void);
+u32 GXResetOverflowCount(void);
+volatile void* GXRedirectWriteGatherPipe(void* ptr);
+void GXRestoreWriteGatherPipe(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXFrameBuffer.h b/include/revolution/gx/GXFrameBuffer.h
new file mode 100644
index 0000000000..e1e538f47f
--- /dev/null
+++ b/include/revolution/gx/GXFrameBuffer.h
@@ -0,0 +1,66 @@
+#ifndef _REVOLUTION_GX_GXFRAMEBUFFER_H_
+#define _REVOLUTION_GX_GXFRAMEBUFFER_H_
+
+#include <revolution/gx/GXStruct.h>
+#include <revolution/gx/GXEnum.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GX_MAX_Z24 0x00ffffff
+
+extern GXRenderModeObj GXNtsc240Ds;
+extern GXRenderModeObj GXNtsc240DsAa;
+extern GXRenderModeObj GXNtsc240Int;
+extern GXRenderModeObj GXNtsc240IntAa;
+extern GXRenderModeObj GXNtsc480IntDf;
+extern GXRenderModeObj GXNtsc480Int;
+extern GXRenderModeObj GXNtsc480IntAa;
+extern GXRenderModeObj GXNtsc480Prog;
+extern GXRenderModeObj GXNtsc480ProgAa;
+extern GXRenderModeObj GXMpal240Ds;
+extern GXRenderModeObj GXMpal240DsAa;
+extern GXRenderModeObj GXMpal240Int;
+extern GXRenderModeObj GXMpal240IntAa;
+extern GXRenderModeObj GXMpal480IntDf;
+extern GXRenderModeObj GXMpal480Int;
+extern GXRenderModeObj GXMpal480IntAa;
+extern GXRenderModeObj GXPal264Ds;
+extern GXRenderModeObj GXPal264DsAa;
+extern GXRenderModeObj GXPal264Int;
+extern GXRenderModeObj GXPal264IntAa;
+extern GXRenderModeObj GXPal528IntDf;
+extern GXRenderModeObj GXPal528Int;
+extern GXRenderModeObj GXPal528IntAa;
+extern GXRenderModeObj GXEurgb60Hz240Ds;
+extern GXRenderModeObj GXEurgb60Hz240DsAa;
+extern GXRenderModeObj GXEurgb60Hz240Int;
+extern GXRenderModeObj GXEurgb60Hz240IntAa;
+extern GXRenderModeObj GXEurgb60Hz480IntDf;
+extern GXRenderModeObj GXEurgb60Hz480Int;
+extern GXRenderModeObj GXEurgb60Hz480IntAa;
+
+void GXAdjustForOverscan(const GXRenderModeObj* rmin, GXRenderModeObj* rmout, u16 hor, u16 ver);
+void GXSetDispCopySrc(u16 left, u16 top, u16 wd, u16 ht);
+void GXSetTexCopySrc(u16 left, u16 top, u16 wd, u16 ht);
+void GXSetDispCopyDst(u16 wd, u16 ht);
+void GXSetTexCopyDst(u16 wd, u16 ht, GXTexFmt fmt, GXBool mipmap);
+void GXSetDispCopyFrame2Field(GXCopyMode mode);
+void GXSetCopyClamp(GXFBClamp clamp);
+u32 GXSetDispCopyYScale(f32 vscale);
+void GXSetCopyClear(GXColor clear_clr, u32 clear_z);
+void GXSetCopyFilter(GXBool aa, const u8 sample_pattern[12][2], GXBool vf, const u8 vfilter[7]);
+void GXSetDispCopyGamma(GXGamma gamma);
+void GXCopyDisp(void* dest, GXBool clear);
+void GXCopyTex(void* dest, GXBool clear);
+void GXClearBoundingBox(void);
+void GXReadBoundingBox(u16* left, u16* top, u16* right, u16* bottom);
+u16 GXGetNumXfbLines(u16 efbHeight, f32 yScale);
+f32 GXGetYScaleFactor(u16 efbHeight, u16 xfbHeight);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXGeometry.h b/include/revolution/gx/GXGeometry.h
new file mode 100644
index 0000000000..8bbf9e49d9
--- /dev/null
+++ b/include/revolution/gx/GXGeometry.h
@@ -0,0 +1,47 @@
+#ifndef _REVOLUTION_GX_GXGEOMETRY_H_
+#define _REVOLUTION_GX_GXGEOMETRY_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void __GXCalculateVLim();
+void GXSetVtxDesc(GXAttr attr, GXAttrType type);
+void GXSetVtxDescv(const GXVtxDescList* attrPtr);
+void GXClearVtxDesc(void);
+void GXSetVtxAttrFmt(GXVtxFmt vtxfmt, GXAttr attr, GXCompCnt cnt, GXCompType type, u8 frac);
+void GXSetVtxAttrFmtv(GXVtxFmt vtxfmt, const GXVtxAttrFmtList* list);
+void GXSetArray(GXAttr attr, void* base_ptr, u8 stride);
+void GXInvalidateVtxCache(void);
+void GXSetTexCoordGen2(GXTexCoordID dst_coord, GXTexGenType func, GXTexGenSrc src_param, u32 mtx, GXBool normalize, u32 pt_texmtx);
+void GXSetNumTexGens(u8 nTexGens);
+
+static inline void GXSetTexCoordGen(GXTexCoordID dst_coord, GXTexGenType func, GXTexGenSrc src_param, u32 mtx) {
+ GXSetTexCoordGen2(dst_coord, func, src_param, mtx, GX_FALSE, GX_PTIDENTITY);
+}
+
+void GXBegin(GXPrimitive type, GXVtxFmt vtxfmt, u16 nverts);
+
+static inline void GXEnd(void) {
+#if DEBUG
+ extern GXBool __GXinBegin;
+ extern void OSPanic(const char* file, int line, const char* msg, ...);
+ if (!__GXinBegin) {
+ OSPanic(__FILE__, 127, "GXEnd: called without a GXBegin");
+ }
+ __GXinBegin = GX_FALSE;
+#endif
+}
+
+void GXSetLineWidth(u8 width, GXTexOffset texOffsets);
+void GXSetPointSize(u8 pointSize, GXTexOffset texOffsets);
+void GXEnableTexOffsets(GXTexCoordID coord, u8 line_enable, u8 point_enable);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXGet.h b/include/revolution/gx/GXGet.h
new file mode 100644
index 0000000000..c20612d921
--- /dev/null
+++ b/include/revolution/gx/GXGet.h
@@ -0,0 +1,64 @@
+#ifndef _REVOLUTION_GX_GXGET_H_
+#define _REVOLUTION_GX_GXGET_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Attr
+void GXGetVtxDesc(GXAttr attr, GXAttrType* type);
+void GXGetVtxDescv(GXVtxDescList* vcd);
+void GXGetVtxAttrFmt(GXVtxFmt fmt, GXAttr attr, GXCompCnt* cnt, GXCompType* type, u8* frac);
+void GXGetVtxAttrFmtv(GXVtxFmt fmt, GXVtxAttrFmtList* vat);
+
+// Geometry
+void GXGetLineWidth(u8* width, GXTexOffset* texOffsets);
+void GXGetPointSize(u8* pointSize, GXTexOffset* texOffsets);
+void GXGetCullMode(GXCullMode* mode);
+
+// Light
+void GXGetLightAttnA(const GXLightObj* lt_obj, f32* a0, f32* a1, f32* a2);
+void GXGetLightAttnK(const GXLightObj* lt_obj, f32* k0, f32* k1, f32* k2);
+void GXGetLightPos(const GXLightObj* lt_obj, f32* x, f32* y, f32* z);
+void GXGetLightDir(const GXLightObj* lt_obj, f32* nx, f32* ny, f32* nz);
+void GXGetLightColor(const GXLightObj* lt_obj, GXColor* color);
+
+// Texture
+GXBool GXGetTexObjMipMap(const GXTexObj* to);
+GXTexFmt GXGetTexObjFmt(const GXTexObj* to);
+u16 GXGetTexObjWidth(const GXTexObj* to);
+u16 GXGetTexObjHeight(const GXTexObj* to);
+GXTexWrapMode GXGetTexObjWrapS(const GXTexObj* to);
+GXTexWrapMode GXGetTexObjWrapT(const GXTexObj* to);
+void* GXGetTexObjData(const GXTexObj* to);;
+void GXGetTexObjAll(const GXTexObj* obj, void** image_ptr, u16* width, u16* height, GXTexFmt* format, GXTexWrapMode* wrap_s, GXTexWrapMode* wrap_t, u8* mipmap);
+void GXGetTexObjLODAll(const GXTexObj* tex_obj, GXTexFilter* min_filt, GXTexFilter* mag_filt, f32* min_lod, f32* max_lod, f32* lod_bias, u8* bias_clamp, u8* do_edge_lod, GXAnisotropy* max_aniso);
+GXTexFilter GXGetTexObjMinFilt(const GXTexObj* tex_obj);
+GXTexFilter GXGetTexObjMagFilt(const GXTexObj* tex_obj);
+f32 GXGetTexObjMinLOD(const GXTexObj* tex_obj);
+f32 GXGetTexObjMaxLOD(const GXTexObj* tex_obj);
+f32 GXGetTexObjLODBias(const GXTexObj* tex_obj);
+GXBool GXGetTexObjBiasClamp(const GXTexObj* tex_obj);
+GXBool GXGetTexObjEdgeLOD(const GXTexObj* tex_obj);
+GXAnisotropy GXGetTexObjMaxAniso(const GXTexObj* tex_obj);
+u32 GXGetTexObjTlut(const GXTexObj* tex_obj);
+void GXGetTlutObjAll(const GXTlutObj* tlut_obj, void** data, GXTlutFmt* format, u16* numEntries);
+void* GXGetTlutObjData(const GXTlutObj* tlut_obj);
+GXTlutFmt GXGetTlutObjFmt(const GXTlutObj* tlut_obj);
+u16 GXGetTlutObjNumEntries(const GXTlutObj* tlut_obj);
+void GXGetTexRegionAll(const GXTexRegion* region, u8* is_cached, u8* is_32b_mipmap, u32* tmem_even, u32* size_even, u32* tmem_odd, u32* size_odd);
+void GXGetTlutRegionAll(const GXTlutRegion* region, u32* tmem_addr, GXTlutSize* tlut_size);
+
+// Transform
+void GXGetProjectionv(f32* ptr);
+void GXGetViewportv(f32* vp);
+void GXGetScissor(u32* left, u32* top, u32* wd, u32* ht);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXLighting.h b/include/revolution/gx/GXLighting.h
new file mode 100644
index 0000000000..099c20f2db
--- /dev/null
+++ b/include/revolution/gx/GXLighting.h
@@ -0,0 +1,32 @@
+#ifndef _REVOLUTION_GX_GXLIGHTING_H_
+#define _REVOLUTION_GX_GXLIGHTING_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXInitLightAttn(GXLightObj* lt_obj, f32 a0, f32 a1, f32 a2, f32 k0, f32 k1, f32 k2);
+void GXInitLightAttnA(GXLightObj* lt_obj, f32 a0, f32 a1, f32 a2);
+void GXInitLightAttnK(GXLightObj* lt_obj, f32 k0, f32 k1, f32 k2);
+void GXInitLightSpot(GXLightObj* lt_obj, f32 cutoff, GXSpotFn spot_func);
+void GXInitLightDistAttn(GXLightObj* lt_obj, f32 ref_dist, f32 ref_br, GXDistAttnFn dist_func);
+void GXInitLightPos(GXLightObj* lt_obj, f32 x, f32 y, f32 z);
+void GXInitLightDir(GXLightObj* lt_obj, f32 nx, f32 ny, f32 nz);
+void GXInitSpecularDir(GXLightObj* lt_obj, f32 nx, f32 ny, f32 nz);
+void GXInitSpecularDirHA(GXLightObj* lt_obj, f32 nx, f32 ny, f32 nz, f32 hx, f32 hy, f32 hz);
+void GXInitLightColor(GXLightObj* lt_obj, GXColor color);
+void GXLoadLightObjImm(const GXLightObj* lt_obj, GXLightID light);
+void GXLoadLightObjIndx(u32 lt_obj_indx, GXLightID light);
+void GXSetChanAmbColor(GXChannelID chan, GXColor amb_color);
+void GXSetChanMatColor(GXChannelID chan, GXColor mat_color);
+void GXSetNumChans(u8 nChans);
+void GXSetChanCtrl(GXChannelID chan, GXBool enable, GXColorSrc amb_src, GXColorSrc mat_src, u32 light_mask, GXDiffuseFn diff_fn, GXAttnFn attn_fn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXManage.h b/include/revolution/gx/GXManage.h
new file mode 100644
index 0000000000..e0c592d6f4
--- /dev/null
+++ b/include/revolution/gx/GXManage.h
@@ -0,0 +1,36 @@
+#ifndef _REVOLUTION_GX_GXMANAGE_H_
+#define _REVOLUTION_GX_GXMANAGE_H_
+
+#include <revolution/gx/GXFifo.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*GXDrawSyncCallback)(u16 token);
+typedef void (*GXDrawDoneCallback)(void);
+
+// Init
+BOOL IsWriteGatherBufferEmpty(void);
+GXFifoObj* GXInit(void* base, u32 size);
+
+// Misc
+void GXSetMisc(GXMiscToken token, u32 val);
+void GXFlush(void);
+void GXResetWriteGatherPipe(void);
+void GXAbortFrame(void);
+void GXSetDrawSync(u16 token);
+u16 GXReadDrawSync(void);
+void GXSetDrawDone(void);
+void GXWaitDrawDone(void);
+void GXDrawDone(void);
+void GXPixModeSync(void);
+void GXTexModeSync(void);
+GXDrawSyncCallback GXSetDrawSyncCallback(GXDrawSyncCallback cb);
+GXDrawDoneCallback GXSetDrawDoneCallback(GXDrawDoneCallback cb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXPerf.h b/include/revolution/gx/GXPerf.h
new file mode 100644
index 0000000000..86a7ce5852
--- /dev/null
+++ b/include/revolution/gx/GXPerf.h
@@ -0,0 +1,30 @@
+#ifndef _REVOLUTION_GX_GXPERF_H_
+#define _REVOLUTION_GX_GXPERF_H_
+
+#include <revolution/gx/GXEnum.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1);
+void GXReadGPMetric(u32* cnt0, u32* cnt1);
+void GXClearGPMetric(void);
+u32 GXReadGP0Metric(void);
+u32 GXReadGP1Metric(void);
+void GXReadMemMetric(u32* cp_req, u32* tc_req, u32* cpu_rd_req, u32* cpu_wr_req, u32* dsp_req, u32* io_req, u32* vi_req, u32* pe_req, u32* rf_req, u32* fi_req);
+void GXClearMemMetric(void);
+void GXReadPixMetric(u32* top_pixels_in, u32* top_pixels_out, u32* bot_pixels_in, u32* bot_pixels_out, u32* clr_pixels_in, u32* copy_clks);
+void GXClearPixMetric(void);
+void GXSetVCacheMetric(GXVCachePerf attr);
+void GXReadVCacheMetric(u32* check, u32* miss, u32* stall);
+void GXClearVCacheMetric(void);
+void GXInitXfRasMetric(void);
+void GXReadXfRasMetric(u32* xf_wait_in, u32* xf_wait_out, u32* ras_busy, u32* clocks);
+u32 GXReadClksPerVtx(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXPixel.h b/include/revolution/gx/GXPixel.h
new file mode 100644
index 0000000000..a92a4b4ce7
--- /dev/null
+++ b/include/revolution/gx/GXPixel.h
@@ -0,0 +1,30 @@
+#ifndef _REVOLUTION_GX_GXPIXEL_H_
+#define _REVOLUTION_GX_GXPIXEL_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXSetFog(GXFogType type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor color);
+void GXInitFogAdjTable(GXFogAdjTable* table, u16 width, const f32 projmtx[4][4]);
+void GXSetFogRangeAdj(GXBool enable, u16 center, const GXFogAdjTable* table);
+void GXSetBlendMode(GXBlendMode type, GXBlendFactor src_factor, GXBlendFactor dst_factor, GXLogicOp op);
+void GXSetColorUpdate(GXBool update_enable);
+void GXSetAlphaUpdate(GXBool update_enable);
+void GXSetZMode(GXBool compare_enable, GXCompare func, GXBool update_enable);
+void GXSetZCompLoc(GXBool before_tex);
+void GXSetPixelFmt(GXPixelFmt pix_fmt, GXZFmt16 z_fmt);
+void GXSetDither(GXBool dither);
+void GXSetDstAlpha(GXBool enable, u8 alpha);
+void GXSetFieldMask(GXBool odd_mask, GXBool even_mask);
+void GXSetFieldMode(GXBool field_mode, GXBool half_aspect_ratio);
+void GXSetFogColor(GXColor color);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXStruct.h b/include/revolution/gx/GXStruct.h
new file mode 100644
index 0000000000..4a875fb02b
--- /dev/null
+++ b/include/revolution/gx/GXStruct.h
@@ -0,0 +1,75 @@
+#ifndef _REVOLUTION_GX_GXSTRUCT_H_
+#define _REVOLUTION_GX_GXSTRUCT_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/vi/vitypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _GXRenderModeObj {
+ /* 0x00 */ VITVMode viTVmode;
+ /* 0x04 */ u16 fbWidth;
+ /* 0x06 */ u16 efbHeight;
+ /* 0x08 */ u16 xfbHeight;
+ /* 0x0A */ u16 viXOrigin;
+ /* 0x0C */ u16 viYOrigin;
+ /* 0x0E */ u16 viWidth;
+ /* 0x10 */ u16 viHeight;
+ /* 0x14 */ VIXFBMode xFBmode;
+ /* 0x18 */ u8 field_rendering;
+ /* 0x19 */ u8 aa;
+ /* 0x20 */ u8 sample_pattern[12][2];
+ /* 0x38 */ u8 vfilter[7];
+} GXRenderModeObj;
+
+typedef struct _GXColor {
+ u8 r, g, b, a;
+} GXColor;
+
+typedef struct _GXColorS10 {
+ s16 r, g, b, a;
+} GXColorS10;
+
+typedef struct _GXTexObj {
+ u32 dummy[8];
+} GXTexObj;
+
+typedef struct _GXLightObj {
+ u32 dummy[16];
+} GXLightObj;
+
+typedef struct _GXTexRegion {
+ u32 dummy[4];
+} GXTexRegion;
+
+typedef struct _GXTlutObj {
+ u32 dummy[3];
+} GXTlutObj;
+
+typedef struct _GXTlutRegion {
+ u32 dummy[4];
+} GXTlutRegion;
+
+typedef struct _GXFogAdjTable {
+ u16 r[10];
+} GXFogAdjTable;
+
+typedef struct _GXVtxDescList {
+ GXAttr attr;
+ GXAttrType type;
+} GXVtxDescList;
+
+typedef struct _GXVtxAttrFmtList {
+ GXAttr attr;
+ GXCompCnt cnt;
+ GXCompType type;
+ u8 frac;
+} GXVtxAttrFmtList;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXTev.h b/include/revolution/gx/GXTev.h
new file mode 100644
index 0000000000..375195aa36
--- /dev/null
+++ b/include/revolution/gx/GXTev.h
@@ -0,0 +1,33 @@
+#ifndef _REVOLUTION_GX_GXTEV_H_
+#define _REVOLUTION_GX_GXTEV_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GXSetTevOp(GXTevStageID id, GXTevMode mode);
+void GXSetTevColorIn(GXTevStageID stage, GXTevColorArg a, GXTevColorArg b, GXTevColorArg c, GXTevColorArg d);
+void GXSetTevAlphaIn(GXTevStageID stage, GXTevAlphaArg a, GXTevAlphaArg b, GXTevAlphaArg c, GXTevAlphaArg d);
+void GXSetTevColorOp(GXTevStageID stage, GXTevOp op, GXTevBias bias, GXTevScale scale, GXBool clamp, GXTevRegID out_reg);
+void GXSetTevAlphaOp(GXTevStageID stage, GXTevOp op, GXTevBias bias, GXTevScale scale, GXBool clamp, GXTevRegID out_reg);
+void GXSetTevColor(GXTevRegID id, GXColor color);
+void GXSetTevColorS10(GXTevRegID id, GXColorS10 color);
+void GXSetTevKColor(GXTevKColorID id, GXColor color);
+void GXSetTevKColorSel(GXTevStageID stage, GXTevKColorSel sel);
+void GXSetTevKAlphaSel(GXTevStageID stage, GXTevKAlphaSel sel);
+void GXSetTevSwapMode(GXTevStageID stage, GXTevSwapSel ras_sel, GXTevSwapSel tex_sel);
+void GXSetTevSwapModeTable(GXTevSwapSel table, GXTevColorChan red, GXTevColorChan green, GXTevColorChan blue, GXTevColorChan alpha);
+void GXSetTevClampMode(void);
+void GXSetAlphaCompare(GXCompare comp0, u8 ref0, GXAlphaOp op, GXCompare comp1, u8 ref1);
+void GXSetZTexture(GXZTexOp op, GXTexFmt fmt, u32 bias);
+void GXSetTevOrder(GXTevStageID stage, GXTexCoordID coord, GXTexMapID map, GXChannelID color);
+void GXSetNumTevStages(u8 nStages);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXTexture.h b/include/revolution/gx/GXTexture.h
new file mode 100644
index 0000000000..bdac23c866
--- /dev/null
+++ b/include/revolution/gx/GXTexture.h
@@ -0,0 +1,52 @@
+#ifndef _REVOLUTION_GX_GXTEXTURE_H_
+#define _REVOLUTION_GX_GXTEXTURE_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef GXTexRegion *(*GXTexRegionCallback)(GXTexObj* t_obj, GXTexMapID id);
+typedef GXTlutRegion *(*GXTlutRegionCallback)(u32 idx);
+
+u32 GXGetTexBufferSize(u16 width, u16 height, u32 format, u8 mipmap, u8 max_lod);
+void GXInitTexObj(GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t, u8 mipmap);
+void GXInitTexObjCI(GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXCITexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t, u8 mipmap, u32 tlut_name);
+void GXInitTexObjLOD(GXTexObj* obj, GXTexFilter min_filt, GXTexFilter mag_filt,
+ f32 min_lod, f32 max_lod, f32 lod_bias, GXBool bias_clamp,
+ GXBool do_edge_lod, GXAnisotropy max_aniso);
+void GXInitTexObjData(GXTexObj* obj, void* image_ptr);
+void GXInitTexObjWrapMode(GXTexObj* obj, GXTexWrapMode s, GXTexWrapMode t);
+void GXInitTexObjTlut(GXTexObj* obj, u32 tlut_name);
+void GXInitTexObjUserData(GXTexObj* obj, void* user_data);
+void* GXGetTexObjUserData(const GXTexObj* obj);
+void GXLoadTexObjPreLoaded(GXTexObj* obj, GXTexRegion* region, GXTexMapID id);
+void GXLoadTexObj(GXTexObj* obj, GXTexMapID id);
+void GXInitTlutObj(GXTlutObj* tlut_obj, void* lut, GXTlutFmt fmt, u16 n_entries);
+void GXLoadTlut(GXTlutObj* tlut_obj, u32 tlut_name);
+void GXInitTexCacheRegion(GXTexRegion* region, u8 is_32b_mipmap, u32 tmem_even, GXTexCacheSize size_even, u32 tmem_odd, GXTexCacheSize size_odd);
+void GXInitTexPreLoadRegion(GXTexRegion* region, u32 tmem_even, u32 size_even, u32 tmem_odd, u32 size_odd);
+void GXInitTlutRegion(GXTlutRegion* region, u32 tmem_addr, GXTlutSize tlut_size);
+void GXInvalidateTexRegion(GXTexRegion* region);
+void GXInvalidateTexAll(void);
+GXTexRegionCallback GXSetTexRegionCallback(GXTexRegionCallback f);
+GXTlutRegionCallback GXSetTlutRegionCallback(GXTlutRegionCallback f);
+void GXPreLoadEntireTexture(GXTexObj* tex_obj, GXTexRegion* region);
+void GXSetTexCoordScaleManually(GXTexCoordID coord, u8 enable, u16 ss, u16 ts);
+void GXSetTexCoordCylWrap(GXTexCoordID coord, u8 s_enable, u8 t_enable);
+void GXSetTexCoordBias(GXTexCoordID coord, u8 s_enable, u8 t_enable);
+void GXInitTexObjFilter(GXTexObj* obj, GXTexFilter min_filt, GXTexFilter mag_filt);
+void GXInitTexObjMaxLOD(GXTexObj* obj, f32 max_lod);
+void GXInitTexObjMinLOD(GXTexObj* obj, f32 min_lod);
+void GXInitTexObjLODBias(GXTexObj* obj, f32 lod_bias);
+void GXInitTexObjBiasClamp(GXTexObj* obj, u8 bias_clamp);
+void GXInitTexObjEdgeLOD(GXTexObj* obj, u8 do_edge_lod);
+void GXInitTexObjMaxAniso(GXTexObj* obj, GXAnisotropy max_aniso);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXTransform.h b/include/revolution/gx/GXTransform.h
new file mode 100644
index 0000000000..19026d185c
--- /dev/null
+++ b/include/revolution/gx/GXTransform.h
@@ -0,0 +1,34 @@
+#ifndef _REVOLUTION_GX_GXTRANSFORM_H_
+#define _REVOLUTION_GX_GXTRANSFORM_H_
+
+#include <revolution/gx/GXEnum.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GX_PROJECTION_SZ 7
+#define GX_VIEWPORT_SZ 6
+
+void GXProject(f32 x, f32 y, f32 z, const f32 mtx[3][4], const f32* pm, const f32* vp, f32* sx, f32* sy, f32* sz);
+void GXSetProjection(const f32 mtx[4][4], GXProjectionType type);
+void GXSetProjectionv(const f32* ptr);
+void GXLoadPosMtxImm(const f32 mtx[3][4], u32 id);
+void GXLoadPosMtxIndx(u16 mtx_indx, u32 id);
+void GXLoadNrmMtxImm(const f32 mtx[3][4], u32 id);
+void GXLoadNrmMtxImm3x3(const f32 mtx[3][3], u32 id);
+void GXLoadNrmMtxIndx3x3(u16 mtx_indx, u32 id);
+void GXSetCurrentMtx(u32 id);
+void GXLoadTexMtxImm(const f32 mtx[][4], u32 id, GXTexMtxType type);
+void GXLoadTexMtxIndx(u16 mtx_indx, u32 id, GXTexMtxType type);
+void GXSetViewportJitter(f32 left, f32 top, f32 wd, f32 ht, f32 nearz, f32 farz, u32 field);
+void GXSetViewport(f32 left, f32 top, f32 wd, f32 ht, f32 nearz, f32 farz);
+void GXSetScissorBoxOffset(s32 x_off, s32 y_off);
+void GXSetClipMode(GXClipMode mode);
+void GXSetZScaleOffset(f32 scale, f32 offset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXVerify.h b/include/revolution/gx/GXVerify.h
new file mode 100644
index 0000000000..5262d5c675
--- /dev/null
+++ b/include/revolution/gx/GXVerify.h
@@ -0,0 +1,29 @@
+#ifndef _REVOLUTION_GX_GXVERIFY_H_
+#define _REVOLUTION_GX_GXVERIFY_H_
+
+#include <revolution/gx/GXEnum.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ GX_WARN_NONE,
+ GX_WARN_SEVERE,
+ GX_WARN_MEDIUM,
+ GX_WARN_ALL
+} GXWarningLevel;
+
+typedef void (*GXVerifyCallback)(GXWarningLevel level, u32 id, char* msg);
+
+void GXSetVerifyLevel(GXWarningLevel level);
+GXVerifyCallback GXSetVerifyCallback(GXVerifyCallback cb);
+
+void __GXVerifyVATImm(GXAttr attr, GXCompCnt cnt, GXCompType type, u8 frac);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/gx/GXVert.h b/include/revolution/gx/GXVert.h
new file mode 100644
index 0000000000..1ecbeb2506
--- /dev/null
+++ b/include/revolution/gx/GXVert.h
@@ -0,0 +1,140 @@
+#ifndef _REVOLUTION_GX_GXVERT_H_
+#define _REVOLUTION_GX_GXVERT_H_
+
+#include <revolution/types.h>
+#include <revolution/os.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GXFIFO_ADDR 0xCC008000
+
+typedef union {
+ u8 u8;
+ u16 u16;
+ u32 u32;
+ u64 u64;
+ s8 s8;
+ s16 s16;
+ s32 s32;
+ s64 s64;
+ f32 f32;
+ f64 f64;
+} PPCWGPipe;
+
+#ifdef __MWERKS__
+volatile PPCWGPipe GXWGFifo AT_ADDRESS(GXFIFO_ADDR);
+#else
+#define GXWGFifo (*(volatile PPCWGPipe *)GXFIFO_ADDR)
+#endif
+
+#if DEBUG
+
+// external functions
+
+#define FUNC_1PARAM(name, T) void name##1##T(const T x);
+#define FUNC_2PARAM(name, T) void name##2##T(const T x, const T y);
+#define FUNC_3PARAM(name, T) void name##3##T(const T x, const T y, const T z);
+#define FUNC_4PARAM(name, T) void name##4##T(const T x, const T y, const T z, const T w);
+#define FUNC_INDEX8(name) void name##1x8(const u8 x);
+#define FUNC_INDEX16(name) void name##1x16(const u16 x);
+
+#else
+
+// inline functions
+
+#define FUNC_1PARAM(name, T) \
+static inline void name##1##T(const T x) { GXWGFifo.T = x; }
+
+#define FUNC_2PARAM(name, T) \
+static inline void name##2##T(const T x, const T y) { GXWGFifo.T = x; GXWGFifo.T = y; }
+
+#define FUNC_3PARAM(name, T) \
+static inline void name##3##T(const T x, const T y, const T z) { GXWGFifo.T = x; GXWGFifo.T = y; GXWGFifo.T = z; }
+
+#define FUNC_4PARAM(name, T) \
+static inline void name##4##T(const T x, const T y, const T z, const T w) { GXWGFifo.T = x; GXWGFifo.T = y; GXWGFifo.T = z; GXWGFifo.T = w; }
+
+#define FUNC_INDEX8(name) \
+static inline void name##1x8(const u8 x) { GXWGFifo.u8 = x; }
+
+#define FUNC_INDEX16(name) \
+static inline void name##1x16(const u16 x) { GXWGFifo.u16 = x; }
+
+#endif
+
+// GXCmd
+FUNC_1PARAM(GXCmd, u8)
+FUNC_1PARAM(GXCmd, u16)
+FUNC_1PARAM(GXCmd, u32)
+
+// GXParam
+FUNC_1PARAM(GXParam, u8)
+FUNC_1PARAM(GXParam, u16)
+FUNC_1PARAM(GXParam, u32)
+FUNC_1PARAM(GXParam, s8)
+FUNC_1PARAM(GXParam, s16)
+FUNC_1PARAM(GXParam, s32)
+FUNC_1PARAM(GXParam, f32)
+FUNC_3PARAM(GXParam, f32)
+FUNC_4PARAM(GXParam, f32)
+
+// GXPosition
+FUNC_3PARAM(GXPosition, f32)
+FUNC_3PARAM(GXPosition, u8)
+FUNC_3PARAM(GXPosition, s8)
+FUNC_3PARAM(GXPosition, u16)
+FUNC_3PARAM(GXPosition, s16)
+FUNC_2PARAM(GXPosition, f32)
+FUNC_2PARAM(GXPosition, u8)
+FUNC_2PARAM(GXPosition, s8)
+FUNC_2PARAM(GXPosition, u16)
+FUNC_2PARAM(GXPosition, s16)
+FUNC_INDEX16(GXPosition)
+FUNC_INDEX8(GXPosition)
+
+// GXNormal
+FUNC_3PARAM(GXNormal, f32)
+FUNC_3PARAM(GXNormal, s16)
+FUNC_3PARAM(GXNormal, s8)
+FUNC_INDEX16(GXNormal)
+FUNC_INDEX8(GXNormal)
+
+// GXColor
+FUNC_4PARAM(GXColor, u8)
+FUNC_1PARAM(GXColor, u32)
+FUNC_3PARAM(GXColor, u8)
+FUNC_1PARAM(GXColor, u16)
+FUNC_INDEX16(GXColor)
+FUNC_INDEX8(GXColor)
+
+// GXTexCoord
+FUNC_2PARAM(GXTexCoord, f32)
+FUNC_2PARAM(GXTexCoord, s16)
+FUNC_2PARAM(GXTexCoord, u16)
+FUNC_2PARAM(GXTexCoord, s8)
+FUNC_2PARAM(GXTexCoord, u8)
+FUNC_1PARAM(GXTexCoord, f32)
+FUNC_1PARAM(GXTexCoord, s16)
+FUNC_1PARAM(GXTexCoord, u16)
+FUNC_1PARAM(GXTexCoord, s8)
+FUNC_1PARAM(GXTexCoord, u8)
+FUNC_INDEX16(GXTexCoord)
+FUNC_INDEX8(GXTexCoord)
+
+// GXMatrixIndex
+FUNC_1PARAM(GXMatrixIndex, u8)
+
+#undef FUNC_1PARAM
+#undef FUNC_2PARAM
+#undef FUNC_3PARAM
+#undef FUNC_4PARAM
+#undef FUNC_INDEX8
+#undef FUNC_INDEX16
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/hw_regs.h b/include/revolution/hw_regs.h
new file mode 100644
index 0000000000..fd81060f15
--- /dev/null
+++ b/include/revolution/hw_regs.h
@@ -0,0 +1,116 @@
+#ifndef _REVOLUTION_HW_REGS_H_
+#define _REVOLUTION_HW_REGS_H_
+
+#include <revolution/types.h>
+
+#ifdef __MWERKS__
+volatile u16 __VIRegs[59] AT_ADDRESS(0xCC002000);
+volatile u32 __PIRegs[12] AT_ADDRESS(0xCC003000);
+volatile u16 __MEMRegs[64] AT_ADDRESS(0xCC004000);
+volatile u16 __DSPRegs[] AT_ADDRESS(0xCC005000);
+volatile u32 __DIRegs[] AT_ADDRESS(0xCC006000);
+volatile u32 __SIRegs[0x100] AT_ADDRESS(0xCC006400);
+volatile u32 __EXIRegs[0x40] AT_ADDRESS(0xCC006800);
+volatile u32 __AIRegs[8] AT_ADDRESS(0xCC006C00);
+#else
+#define __VIRegs ((volatile u16 *)0xCC002000)
+#define __PIRegs ((volatile u32 *)0xCC003000)
+#define __MEMRegs ((volatile u16 *)0xCC004000)
+#define __DSPRegs ((volatile u16 *)0xCC005000)
+#define __DIRegs ((volatile u32 *)0xCC006000)
+#define __SIRegs ((volatile u32 *)0xCC006400)
+#define __EXIRegs ((volatile u32 *)0xCC006800)
+#define __AIRegs ((volatile u32 *)0xCC006C00)
+#endif
+
+// Offsets for __VIRegs
+
+// offsets for __VIRegs[i]
+#define VI_VERT_TIMING (0)
+#define VI_DISP_CONFIG (1)
+#define VI_HORIZ_TIMING_0L (2)
+#define VI_HORIZ_TIMING_0U (3)
+#define VI_HORIZ_TIMING_1L (4)
+#define VI_HORIZ_TIMING_1U (5)
+#define VI_VERT_TIMING_ODD (6)
+#define VI_VERT_TIMING_ODD_U (7)
+#define VI_VERT_TIMING_EVEN (8)
+#define VI_VERT_TIMING_EVEN_U (9)
+
+#define VI_BBI_ODD (10) // burst blanking interval
+#define VI_BBI_ODD_U (11) // burst blanking interval
+#define VI_BBI_EVEN (12) // burst blanking interval
+#define VI_BBI_EVEN_U (13) // burst blanking interval
+
+#define VI_TOP_FIELD_BASE_LEFT (14) // top in 2d, top of left pic in 3d
+#define VI_TOP_FIELD_BASE_LEFT_U (15) // top in 2d, top of left pic in 3d
+
+#define VI_TOP_FIELD_BASE_RIGHT (16) // top of right pic in 3d
+#define VI_TOP_FIELD_BASE_RIGHT_U (17) // top of right pic in 3d
+
+#define VI_BTTM_FIELD_BASE_LEFT (18) // bottom in 2d, bottom of left pic in 3d
+#define VI_BTTM_FIELD_BASE_LEFT_U (19) // bottom in 2d, bottom of left pic in 3d
+
+#define VI_BTTM_FIELD_BASE_RIGHT (20) // bottom of right pic in 3d
+#define VI_BTTM_FIELD_BASE_RIGHT_U (21) // bottom of right pic in 3d
+
+#define VI_VERT_COUNT (22) // vertical display position
+#define VI_HORIZ_COUNT (23) // horizontal display position
+
+#define VI_DISP_INT_0 (24) // display interrupt 0L
+#define VI_DISP_INT_0U (25) // display interrupt 0U
+#define VI_DISP_INT_1 (26) // display interrupt 1L
+#define VI_DISP_INT_1U (27) // display interrupt 1U
+#define VI_DISP_INT_2 (28) // display interrupt 2L
+#define VI_DISP_INT_2U (29) // display interrupt 2U
+#define VI_DISP_INT_3 (30) // display interrupt 3L
+#define VI_DISP_INT_3U (31) // display interrupt 3U
+
+#define VI_HSW (36) // horizontal scaling width
+#define VI_HSR (37) // horizontal scaling register
+
+#define VI_FCT_0 (38) // filter coefficient table 0L
+#define VI_FCT_0U (39) // filter coefficient table 0U
+#define VI_FCT_1 (40) // filter coefficient table 1L
+#define VI_FCT_1U (41) // filter coefficient table 1U
+#define VI_FCT_2 (42) // filter coefficient table 2L
+#define VI_FCT_2U (43) // filter coefficient table 2U
+#define VI_FCT_3 (44) // filter coefficient table 3L
+#define VI_FCT_3U (45) // filter coefficient table 3U
+#define VI_FCT_4 (46) // filter coefficient table 4L
+#define VI_FCT_4U (47) // filter coefficient table 4U
+#define VI_FCT_5 (48) // filter coefficient table 5L
+#define VI_FCT_5U (49) // filter coefficient table 5U
+#define VI_FCT_6 (50) // filter coefficient table 6L
+#define VI_FCT_6U (51) // filter coefficient table 6U
+
+#define VI_CLOCK_SEL (54) // clock select
+#define VI_DTV_STAT (55) // DTV status
+
+#define VI_WIDTH (56)
+
+// offsets for __DSPRegs[i]
+#define DSP_MAILBOX_IN_HI (0)
+#define DSP_MAILBOX_IN_LO (1)
+#define DSP_MAILBOX_OUT_HI (2)
+#define DSP_MAILBOX_OUT_LO (3)
+#define DSP_CONTROL_STATUS (5)
+
+#define DSP_ARAM_SIZE (9)
+#define DSP_ARAM_MODE (11)
+#define DSP_ARAM_REFRESH (13)
+#define DSP_ARAM_DMA_MM_HI (16) // Main mem address
+#define DSP_ARAM_DMA_MM_LO (17)
+#define DSP_ARAM_DMA_ARAM_HI (18) // ARAM address
+#define DSP_ARAM_DMA_ARAM_LO (19)
+#define DSP_ARAM_DMA_SIZE_HI (20) // DMA buffer size
+#define DSP_ARAM_DMA_SIZE_LO (21)
+
+#define DSP_DMA_START_HI (24) // DMA start address
+#define DSP_DMA_START_LO (25)
+#define DSP_DMA_CONTROL_LEN (27)
+#define DSP_DMA_BYTES_LEFT (29)
+
+#define DSP_DMA_START_FLAG (0x8000) // set to start DSP
+
+#endif
diff --git a/include/revolution/mix.h b/include/revolution/mix.h
new file mode 100644
index 0000000000..20f10b6905
--- /dev/null
+++ b/include/revolution/mix.h
@@ -0,0 +1,95 @@
+#ifndef _REVOLUTION_MIX_H_
+#define _REVOLUTION_MIX_H_
+
+#include <revolution/types.h>
+#include <revolution/ax.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MIX_SOUND_MODE_MONO 0
+#define MIX_SOUND_MODE_STEREO 1
+#define MIX_SOUND_MODE_SURROUND 2
+#define MIX_SOUND_MODE_DPL2 3
+
+typedef struct MIXChannel {
+ /* 0x00 */ AXVPB* axvpb;
+ /* 0x04 */ u32 mode;
+ /* 0x08 */ int input;
+ /* 0x0C */ int auxA;
+ /* 0x10 */ int auxB;
+ /* 0x14 */ int pan;
+ /* 0x18 */ int span;
+ /* 0x1C */ int fader;
+ /* 0x20 */ int l;
+ /* 0x24 */ int r;
+ /* 0x28 */ int f;
+ /* 0x2C */ int b;
+ /* 0x30 */ int l1;
+ /* 0x34 */ int r1;
+ /* 0x38 */ u16 v;
+ /* 0x3A */ u16 v1;
+ /* 0x3C */ u16 vL;
+ /* 0x3E */ u16 vL1;
+ /* 0x40 */ u16 vR;
+ /* 0x42 */ u16 vR1;
+ /* 0x44 */ u16 vS;
+ /* 0x46 */ u16 vS1;
+ /* 0x48 */ u16 vAL;
+ /* 0x4A */ u16 vAL1;
+ /* 0x4C */ u16 vAR;
+ /* 0x4E */ u16 vAR1;
+ /* 0x50 */ u16 vAS;
+ /* 0x52 */ u16 vAS1;
+ /* 0x54 */ u16 vBL;
+ /* 0x56 */ u16 vBL1;
+ /* 0x58 */ u16 vBR;
+ /* 0x5A */ u16 vBR1;
+ /* 0x5C */ u16 vBS;
+ /* 0x5E */ u16 vBS1;
+} MIXChannel;
+
+void MIXInit(void);
+void MIXQuit(void);
+void MIXSetSoundMode(u32 mode);
+u32 MIXGetSoundMode(void);
+void MIXInitChannel(AXVPB* axvpb, u32 mode, int input, int auxA, int auxB, int pan, int span, int fader);
+void MIXReleaseChannel(AXVPB* axvpb);
+void MIXResetControls(AXVPB* p);
+void MIXSetInput(AXVPB* p, int dB);
+void MIXAdjustInput(AXVPB* p, int dB);
+int MIXGetInput(AXVPB* p);
+void MIXAuxAPostFader(AXVPB* p);
+void MIXAuxAPreFader(AXVPB* p);
+int MIXAuxAIsPostFader(AXVPB* p);
+void MIXSetAuxA(AXVPB* p, int dB);
+void MIXAdjustAuxA(AXVPB* p, int dB);
+int MIXGetAuxA(AXVPB* p);
+void MIXAuxBPostFader(AXVPB* p);
+void MIXAuxBPreFader(AXVPB* p);
+int MIXAuxBIsPostFader(AXVPB* p);
+void MIXSetAuxB(AXVPB* p, int dB);
+void MIXAdjustAuxB(AXVPB* p, int dB);
+int MIXGetAuxB(AXVPB* p);
+void MIXSetPan(AXVPB* p, int pan);
+void MIXAdjustPan(AXVPB* p, int pan);
+int MIXGetPan(AXVPB* p);
+void MIXSetSPan(AXVPB* p, int span);
+void MIXAdjustSPan(AXVPB* p, int span);
+int MIXGetSPan(AXVPB* p);
+void MIXMute(AXVPB* p);
+void MIXUnMute(AXVPB* p);
+int MIXIsMute(AXVPB* p);
+void MIXSetFader(AXVPB* p, int dB);
+void MIXAdjustFader(AXVPB* p, int dB);
+int MIXGetFader(AXVPB* p);
+void MIXSetDvdStreamFader(int dB);
+int MIXGetDvdStreamFader(void);
+void MIXUpdateSettings(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_MIX_H_
diff --git a/include/revolution/mtx.h b/include/revolution/mtx.h
index 91519664ae..bb1051f696 100644
--- a/include/revolution/mtx.h
+++ b/include/revolution/mtx.h
@@ -1,5 +1,5 @@
-#ifndef _DOLPHIN_MTX_H_
-#define _DOLPHIN_MTX_H_
+#ifndef _REVOLUTION_MTX_H_
+#define _REVOLUTION_MTX_H_
#include <revolution/types.h>
diff --git a/include/revolution/os.h b/include/revolution/os.h
new file mode 100644
index 0000000000..f2525f8668
--- /dev/null
+++ b/include/revolution/os.h
@@ -0,0 +1,354 @@
+#ifndef _REVOLUTION_OS_H_
+#define _REVOLUTION_OS_H_
+
+#include <stdio.h>
+
+#include <revolution/types.h>
+#include <revolution/gx/GXStruct.h>
+void OSReportInit(void);
+void OSVAttention(const char* fmt, va_list args);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef s64 OSTime;
+typedef u32 OSTick;
+
+#include <revolution/os/OSAlloc.h>
+#include <revolution/os/OSCache.h>
+#include <revolution/os/OSContext.h>
+#include <revolution/os/OSInterrupt.h>
+#include <revolution/os/OSModule.h>
+#include <revolution/os/OSThread.h>
+#include <revolution/os/OSMutex.h>
+#include <revolution/os/OSFont.h>
+#include <revolution/os/OSReset.h>
+#include <revolution/os/OSResetSW.h>
+#include <revolution/os/OSError.h>
+#include <revolution/os/OSTime.h>
+#include <revolution/os/OSSerial.h>
+#include <revolution/os/OSRtc.h>
+#include <revolution/os/OSMessage.h>
+#include <revolution/os/OSException.h>
+#include <revolution/os/OSAlarm.h>
+#include <revolution/os/OSDC.h>
+#include <revolution/os/OSIC.h>
+#include <revolution/os/OSLC.h>
+#include <revolution/os/OSL2.h>
+#include <revolution/os/OSReboot.h>
+#include <revolution/os/OSExec.h>
+#include <revolution/os/OSMemory.h>
+#include <revolution/os/OSSemaphore.h>
+#include <revolution/os/OSUtf.h>
+#include <revolution/os/OSTimer.h>
+
+// private macro, maybe shouldn't be defined here?
+#define OFFSET(addr, align) (((u32)(addr) & ((align)-1)))
+
+#define DOLPHIN_ALIGNMENT 32
+
+// Upper words of the masks, since UIMM is only 16 bits
+#define OS_CACHED_REGION_PREFIX 0x8000
+#define OS_UNCACHED_REGION_PREFIX 0xC000
+#define OS_PHYSICAL_MASK 0x3FFF
+
+#define OS_BASE_CACHED (OS_CACHED_REGION_PREFIX << 16)
+#define OS_BASE_UNCACHED (OS_UNCACHED_REGION_PREFIX << 16)
+
+#ifdef __MWERKS__
+u32 __OSPhysicalMemSize AT_ADDRESS(OS_BASE_CACHED | 0x0028);
+volatile int __OSTVMode AT_ADDRESS(OS_BASE_CACHED | 0x00CC);
+OSThreadQueue __OSActiveThreadQueue AT_ADDRESS(OS_BASE_CACHED | 0x00DC);
+OSThread* __OSCurrentThread AT_ADDRESS(OS_BASE_CACHED | 0x00E4);
+u32 __OSSimulatedMemSize AT_ADDRESS(OS_BASE_CACHED | 0x00F0);
+u32 __OSBusClock AT_ADDRESS(OS_BASE_CACHED | 0x00F8);
+u32 __OSCoreClock AT_ADDRESS(OS_BASE_CACHED | 0x00FC);
+volatile u16 __OSDeviceCode AT_ADDRESS(OS_BASE_CACHED | 0x30E6);
+u16 __OSWirelessPadFixMode AT_ADDRESS(OS_BASE_CACHED | 0x30E0);
+
+// unknowns
+OSThread* __gUnkThread1 AT_ADDRESS(OS_BASE_CACHED | 0x00D8);
+int __gUnknown800030C0[2] AT_ADDRESS(OS_BASE_CACHED | 0x30C0);
+u8 __gUnknown800030E3 AT_ADDRESS(OS_BASE_CACHED | 0x30E3);
+#else
+#define __OSBusClock (*(u32 *)(OS_BASE_CACHED | 0x00F8))
+#define __OSCoreClock (*(u32 *)(OS_BASE_CACHED | 0x00FC))
+#endif
+
+#define OS_BUS_CLOCK __OSBusClock
+#define OS_CORE_CLOCK __OSCoreClock
+#define OS_TIMER_CLOCK (OS_BUS_CLOCK/4)
+
+#define OSTicksToSeconds(ticks) ((ticks) / (OS_TIMER_CLOCK))
+#define OSTicksToMilliseconds(ticks) ((ticks) / (OS_TIMER_CLOCK/1000))
+#define OSTicksToMicroseconds(ticks) ((ticks) * 8 / (OS_TIMER_CLOCK/125000))
+#define OSSecondsToTicks(sec) ((sec) * (OS_TIMER_CLOCK))
+#define OSMillisecondsToTicks(msec) ((msec) * (OS_TIMER_CLOCK / 1000))
+#define OSNanosecondsToTicks(nsec) (((nsec) * (OS_TIMER_CLOCK / 125000)) / 8000)
+#define OSMicrosecondsToTicks(usec) (((usec) * (OS_TIMER_CLOCK / 125000)) / 8)
+
+u32 OSGetConsoleType(void);
+void OSInit(void);
+void OSRegisterVersion(const char* id);
+
+void* OSGetArenaHi(void);
+void* OSGetArenaLo(void);
+void OSSetArenaHi(void* newHi);
+void OSSetArenaLo(void* newLo);
+void* OSAllocFromMEM1ArenaLo(u32 size, u32 align);
+void* OSAllocFromMEM1ArenaHi(u32 size, u32 align);
+
+u32 OSGetPhysicalMemSize(void);
+
+void __OSPSInit(void);
+void __OSFPRInit(void);
+u32 __OSGetDIConfig(void);
+
+void OSDefaultExceptionHandler(__OSException exception, OSContext* context);
+
+typedef struct OSCalendarTime {
+ /* 0x00 */ int sec;
+ /* 0x04 */ int min;
+ /* 0x08 */ int hour;
+ /* 0x0C */ int mday;
+ /* 0x10 */ int mon;
+ /* 0x14 */ int year;
+ /* 0x18 */ int wday;
+ /* 0x1C */ int yday;
+ /* 0x20 */ int msec;
+ /* 0x24 */ int usec;
+} OSCalendarTime;
+
+#include <revolution/dvd.h>
+typedef struct OSBootInfo_s {
+ DVDDiskID DVDDiskID;
+ u32 magic;
+ u32 version;
+ u32 memorySize;
+ u32 consoleType;
+ void* arenaLo;
+ void* arenaHi;
+ void* FSTLocation;
+ u32 FSTMaxLength;
+} OSBootInfo;
+
+typedef struct OSStopwatch {
+ char* name;
+ u32 hits;
+ OSTime total;
+ OSTime min;
+ OSTime max;
+ OSTime last;
+ BOOL running;
+ u32 _padding;
+} OSStopwatch;
+
+void OSInitStopwatch(OSStopwatch* sw, char* name);
+void OSStartStopwatch(OSStopwatch* sw);
+void OSStopStopwatch(OSStopwatch* sw);
+OSTime OSCheckStopwatch(OSStopwatch* sw);
+void OSResetStopwatch(OSStopwatch* sw);
+void OSDumpStopwatch(OSStopwatch* sw);
+
+OSTick OSGetTick(void);
+OSTime OSGetTime(void);
+void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* td);
+OSTime OSCalendarTimeToTicks(OSCalendarTime* td);
+BOOL OSEnableInterrupts(void);
+BOOL OSDisableInterrupts(void);
+BOOL OSRestoreInterrupts(BOOL level);
+
+#define OS_CONSOLE_MASK 0xF0000000
+#define OS_CONSOLE_RETAIL 0x00000000
+#define OS_CONSOLE_DEVELOPMENT 0x10000000
+#define OS_CONSOLE_TDEV 0x20000000
+
+#define OS_CONSOLE_RETAIL4 0x00000004
+#define OS_CONSOLE_RETAIL3 0x00000003
+#define OS_CONSOLE_RETAIL2 0x00000002
+#define OS_CONSOLE_RETAIL1 0x00000001
+#define OS_CONSOLE_TDEVHW4 0x20000007
+#define OS_CONSOLE_TDEVHW3 0x20000006
+#define OS_CONSOLE_TDEVHW2 0x20000005
+#define OS_CONSOLE_TDEVHW1 0x20000004
+#define OS_CONSOLE_DEVHW4 0x10000007
+#define OS_CONSOLE_DEVHW3 0x10000006
+#define OS_CONSOLE_DEVHW2 0x10000005
+#define OS_CONSOLE_DEVHW1 0x10000004
+#define OS_CONSOLE_MINNOW 0x10000003
+#define OS_CONSOLE_ARTHUR 0x10000002
+#define OS_CONSOLE_PC_EMULATOR 0x10000001
+#define OS_CONSOLE_EMULATOR 0x10000000
+
+#define OS_SOUND_MODE_MONO 0
+#define OS_SOUND_MODE_STEREO 1
+
+u32 OSGetSoundMode(void);
+void OSSetSoundMode(u32 mode);
+
+__declspec(weak) void OSReport(const char* msg, ...);
+__declspec(weak) void OSVReport(const char* msg, va_list list);
+__declspec(weak) void OSPanic(const char* file, int line, const char* msg, ...);
+void OSFatal(GXColor fg, GXColor bg, const char* msg);
+
+// do these belong here?
+__declspec(weak) void OSAttention(const char* msg, ...);
+__declspec(weak) void OSReport_Error(const char* fmt, ...);
+__declspec(weak) void OSReport_FatalError(const char* fmt, ...);
+__declspec(weak) void OSReport_System(const char* fmt, ...);
+__declspec(weak) void OSReport_Warning(const char* fmt, ...);
+__declspec(weak) void OSReportDisable(void);
+__declspec(weak) void OSReportEnable(void);
+__declspec(weak) void OSReportForceEnableOff(void);
+__declspec(weak) void OSReportForceEnableOn(void);
+__declspec(weak) void OSVReport(const char* format, va_list list);
+
+__declspec(weak) void OSSwitchFiberEx(u32, u32, u32, u32, u32, u32);
+
+#ifdef DEBUG
+#define OS_REPORT(...) OSReport(__VA_ARGS__)
+#define OS_WARNING(...) OSReport_Warning(__VA_ARGS__)
+#define OS_REPORT_ERROR(...) OSReport_Error(__VA_ARGS__)
+#define OS_PANIC(line, msg) OSPanic(__FILE__, line, msg)
+#else
+#define OS_REPORT(...)
+#define OS_WARNING(...)
+#define OS_REPORT_ERROR(...)
+#define OS_PANIC(...)
+#endif
+
+extern u8 __OSReport_disable;
+extern u8 __OSReport_Error_disable;
+extern u8 __OSReport_Warning_disable;
+extern u8 __OSReport_System_disable;
+extern u8 __OSReport_enable;
+
+#define OSRoundUp32B(x) (((u32)(x) + 32 - 1) & ~(32 - 1))
+#define OSRoundDown32B(x) (((u32)(x)) & ~(32 - 1))
+
+void* OSPhysicalToCached(u32 paddr);
+void* OSPhysicalToUncached(u32 paddr);
+u32 OSCachedToPhysical(void* caddr);
+u32 OSUncachedToPhysical(void* ucaddr);
+void* OSCachedToUncached(void* caddr);
+void* OSUncachedToCached(void* ucaddr);
+
+#if !DEBUG
+#define OSPhysicalToCached(paddr) ((void*) ((u32)(OS_BASE_CACHED + (u32)(paddr))))
+#define OSPhysicalToUncached(paddr) ((void*) ((u32)(OS_BASE_UNCACHED + (u32)(paddr))))
+#define OSCachedToPhysical(caddr) ((u32) ((u32)(caddr) - OS_BASE_CACHED))
+#define OSUncachedToPhysical(ucaddr) ((u32) ((u32)(ucaddr) - OS_BASE_UNCACHED))
+#define OSCachedToUncached(caddr) ((void*) ((u8*)(caddr) + (OS_BASE_UNCACHED - OS_BASE_CACHED)))
+#define OSUncachedToCached(ucaddr) ((void*) ((u8*)(ucaddr) - (OS_BASE_UNCACHED - OS_BASE_CACHED)))
+#endif
+
+// unsorted externs
+extern OSTime __OSGetSystemTime(void);
+__declspec(weak) extern int __OSIsGcam;
+extern OSExecParams __OSRebootParams;
+extern OSTime __OSStartTime;
+extern int __OSInIPL;
+
+// helper for assert line numbers in different revisions
+#if SDK_REVISION < 1
+ #define LINE(l0, l1, l2) (l0)
+#elif SDK_REVISION < 2
+ #define LINE(l0, l1, l2) (l1)
+#else
+ #define LINE(l0, l1, l2) (l2)
+#endif
+
+#ifdef DEBUG
+#define ASSERTLINE(line, cond) \
+ ((cond) || (OSPanic(__FILE__, line, "Failed assertion " #cond), 0))
+
+#define ASSERTMSGLINE(line, cond, msg) \
+ ((cond) || (OSPanic(__FILE__, line, msg), 0))
+
+// This is dumb but we dont have a Metrowerks way to do variadic macros in the macro to make this done in a not scrubby way.
+#define ASSERTMSG1LINE(line, cond, msg, arg1) \
+ ((cond) || (OSPanic(__FILE__, line, msg, arg1), 0))
+
+#define ASSERTMSG2LINE(line, cond, msg, arg1, arg2) \
+ ((cond) || (OSPanic(__FILE__, line, msg, arg1, arg2), 0))
+
+#define ASSERTMSGLINEV(line, cond, ...) \
+ ((cond) || (OSPanic(__FILE__, line, __VA_ARGS__), 0))
+
+#else
+#define ASSERTLINE(line, cond) (void)0
+#define ASSERTMSGLINE(line, cond, msg) (void)0
+#define ASSERTMSG1LINE(line, cond, msg, arg1) (void)0
+#define ASSERTMSG2LINE(line, cond, msg, arg1, arg2) (void)0
+#define ASSERTMSGLINEV(line, cond, ...) (void)0
+#endif
+
+#define ASSERT(cond) ASSERTLINE(__LINE__, cond)
+
+inline s16 __OSf32tos16(register f32 inF) {
+ register s16 out;
+ u32 tmp;
+ register u32* tmpPtr = &tmp;
+ // clang-format off
+#ifdef __MWERKS__
+ asm {
+ psq_st inF, 0(tmpPtr), 0x1, 5
+ lha out, 0(tmpPtr)
+ }
+#endif
+ // clang-format on
+
+ return out;
+}
+
+inline void OSf32tos16(f32* f, s16* out) {
+ *out = __OSf32tos16(*f);
+}
+
+inline u8 __OSf32tou8(register f32 inF) {
+ register u8 out;
+ u32 tmp;
+ register u32* tmpPtr = &tmp;
+ // clang-format off
+#ifdef __MWERKS__
+ asm {
+ psq_st inF, 0(tmpPtr), 0x1, 2
+ lbz out, 0(tmpPtr)
+ }
+#endif
+ // clang-format on
+
+ return out;
+}
+
+inline void OSf32tou8(f32* f, u8* out) {
+ *out = __OSf32tou8(*f);
+}
+
+static inline void OSInitFastCast(void) {
+ // clang-format off
+#ifdef __MWERKS__
+ asm {
+ li r3, 4
+ oris r3, r3, 4
+ mtspr 0x392, r3
+ li r3, 5
+ oris r3, r3, 5
+ mtspr 0x393, r3
+ li r3, 6
+ oris r3, r3, 6
+ mtspr 0x394, r3
+ li r3, 7
+ oris r3, r3, 7
+ mtspr 0x395, r3
+ }
+#endif
+ // clang-format on
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSAlarm.h b/include/revolution/os/OSAlarm.h
new file mode 100644
index 0000000000..1f1ad948ad
--- /dev/null
+++ b/include/revolution/os/OSAlarm.h
@@ -0,0 +1,36 @@
+#ifndef _REVOLUTION_OSALARM_H_
+#define _REVOLUTION_OSALARM_H_
+
+#include <revolution/os.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct OSAlarm OSAlarm;
+typedef void (*OSAlarmHandler)(OSAlarm* alarm, OSContext* context);
+struct OSAlarm {
+ OSAlarmHandler handler;
+ u32 tag;
+ OSTime fire;
+ OSAlarm* prev;
+ OSAlarm* next;
+ OSTime period;
+ OSTime start;
+};
+
+BOOL OSCheckAlarmQueue(void);
+void OSInitAlarm(void);
+void OSCreateAlarm(OSAlarm* alarm);
+void OSSetAlarm(OSAlarm* alarm, OSTime tick, OSAlarmHandler handler);
+void OSSetAbsAlarm(OSAlarm* alarm, OSTime time, OSAlarmHandler handler);
+void OSSetPeriodicAlarm(OSAlarm* alarm, OSTime start, OSTime period, OSAlarmHandler handler);
+void OSCancelAlarm(OSAlarm *alarm);
+void OSSetAlarmTag(OSAlarm* alarm, u32 tag);
+void OSCancelAlarms(u32 tag);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_OSALARM_H_
diff --git a/include/revolution/os/OSAlloc.h b/include/revolution/os/OSAlloc.h
new file mode 100644
index 0000000000..50245521e3
--- /dev/null
+++ b/include/revolution/os/OSAlloc.h
@@ -0,0 +1,34 @@
+#ifndef _REVOLUTION_OSALLOC_H_
+#define _REVOLUTION_OSALLOC_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int OSHeapHandle;
+
+extern volatile OSHeapHandle __OSCurrHeap;
+
+void* OSAllocFromHeap(int heap, u32 size);
+void* OSAllocFixed(void* rstart, void* rend);
+void OSFreeToHeap(int heap, void* ptr);
+int OSSetCurrentHeap(int heap);
+void* OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps);
+int OSCreateHeap(void* start, void* end);
+void OSDestroyHeap(int heap);
+void OSAddToHeap(int heap, void* start, void* end);
+s32 OSCheckHeap(int heap);
+u32 OSReferentSize(void* ptr);
+void OSDumpHeap(int heap);
+void OSVisitAllocated(void (*visitor)(void*, u32));
+
+#define OSAlloc(size) OSAllocFromHeap(__OSCurrHeap, (size))
+#define OSFree(ptr) OSFreeToHeap(__OSCurrHeap, (ptr))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSCache.h b/include/revolution/os/OSCache.h
new file mode 100644
index 0000000000..f35a1db9e1
--- /dev/null
+++ b/include/revolution/os/OSCache.h
@@ -0,0 +1,38 @@
+#ifndef _REVOLUTION_OSCACHE_H_
+#define _REVOLUTION_OSCACHE_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void DCInvalidateRange(void* addr, u32 nBytes);
+void DCFlushRange(void* addr, u32 nBytes);
+void DCStoreRange(void* addr, u32 nBytes);
+void DCFlushRangeNoSync(void* addr, u32 nBytes);
+void DCStoreRangeNoSync(void* addr, u32 nBytes);
+void DCZeroRange(void* addr, u32 nBytes);
+void DCTouchRange(void* addr, u32 nBytes);
+void ICInvalidateRange(void* addr, u32 nBytes);
+
+#define LC_BASE_PREFIX 0xE000
+#define LC_BASE (LC_BASE_PREFIX << 16)
+#define LCGetBase() ((void*)LC_BASE)
+
+void LCEnable(void);
+void LCDisable(void);
+void LCLoadBlocks(void* destTag, void* srcAddr, u32 numBlocks);
+void LCStoreBlocks(void* destAddr, void* srcTag, u32 numBlocks);
+u32 LCLoadData(void* destAddr, void* srcAddr, u32 nBytes);
+u32 LCStoreData(void* destAddr, void* srcAddr, u32 nBytes);
+u32 LCQueueLength(void);
+void LCQueueWait(u32 len);
+void LCFlushQueue(void);
+void __OSCacheInit(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSContext.h b/include/revolution/os/OSContext.h
new file mode 100644
index 0000000000..0f1f462f1f
--- /dev/null
+++ b/include/revolution/os/OSContext.h
@@ -0,0 +1,173 @@
+#ifndef _REVOLUTION_OSCONTEXT_H_
+#define _REVOLUTION_OSCONTEXT_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __OS_CONTEXT_FRAME 768
+
+#define OS_CONTEXT_R0 0
+#define OS_CONTEXT_R1 4
+#define OS_CONTEXT_R2 8
+#define OS_CONTEXT_R3 12
+#define OS_CONTEXT_R4 16
+#define OS_CONTEXT_R5 20
+#define OS_CONTEXT_R6 24
+#define OS_CONTEXT_R7 28
+#define OS_CONTEXT_R8 32
+#define OS_CONTEXT_R9 36
+#define OS_CONTEXT_R10 40
+#define OS_CONTEXT_R11 44
+#define OS_CONTEXT_R12 48
+#define OS_CONTEXT_R13 52
+#define OS_CONTEXT_R14 56
+#define OS_CONTEXT_R15 60
+#define OS_CONTEXT_R16 64
+#define OS_CONTEXT_R17 68
+#define OS_CONTEXT_R18 72
+#define OS_CONTEXT_R19 76
+#define OS_CONTEXT_R20 80
+#define OS_CONTEXT_R21 84
+#define OS_CONTEXT_R22 88
+#define OS_CONTEXT_R23 92
+#define OS_CONTEXT_R24 96
+#define OS_CONTEXT_R25 100
+#define OS_CONTEXT_R26 104
+#define OS_CONTEXT_R27 108
+#define OS_CONTEXT_R28 112
+#define OS_CONTEXT_R29 116
+#define OS_CONTEXT_R30 120
+#define OS_CONTEXT_R31 124
+
+#define OS_CONTEXT_CR 128
+#define OS_CONTEXT_LR 132
+#define OS_CONTEXT_CTR 136
+#define OS_CONTEXT_XER 140
+
+#define OS_CONTEXT_FPR0 144
+#define OS_CONTEXT_FPR1 152
+#define OS_CONTEXT_FPR2 160
+#define OS_CONTEXT_FPR3 168
+#define OS_CONTEXT_FPR4 176
+#define OS_CONTEXT_FPR5 184
+#define OS_CONTEXT_FPR6 192
+#define OS_CONTEXT_FPR7 200
+#define OS_CONTEXT_FPR8 208
+#define OS_CONTEXT_FPR9 216
+#define OS_CONTEXT_FPR10 224
+#define OS_CONTEXT_FPR11 232
+#define OS_CONTEXT_FPR12 240
+#define OS_CONTEXT_FPR13 248
+#define OS_CONTEXT_FPR14 256
+#define OS_CONTEXT_FPR15 264
+#define OS_CONTEXT_FPR16 272
+#define OS_CONTEXT_FPR17 280
+#define OS_CONTEXT_FPR18 288
+#define OS_CONTEXT_FPR19 296
+#define OS_CONTEXT_FPR20 304
+#define OS_CONTEXT_FPR21 312
+#define OS_CONTEXT_FPR22 320
+#define OS_CONTEXT_FPR23 328
+#define OS_CONTEXT_FPR24 336
+#define OS_CONTEXT_FPR25 344
+#define OS_CONTEXT_FPR26 352
+#define OS_CONTEXT_FPR27 360
+#define OS_CONTEXT_FPR28 368
+#define OS_CONTEXT_FPR29 376
+#define OS_CONTEXT_FPR30 384
+#define OS_CONTEXT_FPR31 392
+
+#define OS_CONTEXT_FPSCR 400
+
+#define OS_CONTEXT_SRR0 408
+#define OS_CONTEXT_SRR1 412
+
+#define OS_CONTEXT_MODE 416
+#define OS_CONTEXT_STATE 418
+
+#define OS_CONTEXT_GQR0 420
+#define OS_CONTEXT_GQR1 424
+#define OS_CONTEXT_GQR2 428
+#define OS_CONTEXT_GQR3 432
+#define OS_CONTEXT_GQR4 436
+#define OS_CONTEXT_GQR5 440
+#define OS_CONTEXT_GQR6 444
+#define OS_CONTEXT_GQR7 448
+#define __OSCONTEXT_PADDING 452
+
+#define OS_CONTEXT_PSF0 456
+#define OS_CONTEXT_PSF1 464
+#define OS_CONTEXT_PSF2 472
+#define OS_CONTEXT_PSF3 480
+#define OS_CONTEXT_PSF4 488
+#define OS_CONTEXT_PSF5 496
+#define OS_CONTEXT_PSF6 504
+#define OS_CONTEXT_PSF7 512
+#define OS_CONTEXT_PSF8 520
+#define OS_CONTEXT_PSF9 528
+#define OS_CONTEXT_PSF10 536
+#define OS_CONTEXT_PSF11 544
+#define OS_CONTEXT_PSF12 552
+#define OS_CONTEXT_PSF13 560
+#define OS_CONTEXT_PSF14 568
+#define OS_CONTEXT_PSF15 576
+#define OS_CONTEXT_PSF16 584
+#define OS_CONTEXT_PSF17 592
+#define OS_CONTEXT_PSF18 600
+#define OS_CONTEXT_PSF19 608
+#define OS_CONTEXT_PSF20 616
+#define OS_CONTEXT_PSF21 624
+#define OS_CONTEXT_PSF22 632
+#define OS_CONTEXT_PSF23 640
+#define OS_CONTEXT_PSF24 648
+#define OS_CONTEXT_PSF25 656
+#define OS_CONTEXT_PSF26 664
+#define OS_CONTEXT_PSF27 672
+#define OS_CONTEXT_PSF28 680
+#define OS_CONTEXT_PSF29 688
+#define OS_CONTEXT_PSF30 696
+#define OS_CONTEXT_PSF31 704
+#define OS_CONTEXT_STATE_EXC 0x02u
+
+#define OS_CONTEXT_STATE_FPSAVED 0x01u
+
+typedef struct OSContext {
+ /* 0x000 */ u32 gpr[32];
+ /* 0x080 */ u32 cr;
+ /* 0x084 */ u32 lr;
+ /* 0x088 */ u32 ctr;
+ /* 0x08C */ u32 xer;
+ /* 0x090 */ f64 fpr[32];
+ /* 0x190 */ u32 fpscr_pad;
+ /* 0x194 */ u32 fpscr;
+ /* 0x198 */ u32 srr0;
+ /* 0x19C */ u32 srr1;
+ /* 0x1A0 */ u16 mode;
+ /* 0x1A2 */ u16 state;
+ /* 0x1A4 */ u32 gqr[8];
+ /* 0x1C4 */ u32 psf_pad;
+ /* 0x1C8 */ f64 psf[32];
+} OSContext;
+
+u32 OSGetStackPointer(void);
+void OSDumpContext(OSContext* context);
+void OSLoadContext(OSContext* context);
+u32 OSSaveContext(OSContext* context);
+void OSClearContext(OSContext* context);
+OSContext* OSGetCurrentContext(void);
+void OSSetCurrentContext(OSContext* context);
+void OSLoadFPUContext(OSContext* fpucontext);
+void OSSaveFPUContext(OSContext* fpucontext);
+u32 OSSwitchStack(u32 newsp);
+int OSSwitchFiber(u32 pc, u32 newsp);
+void OSInitContext(OSContext* context, u32 pc, u32 newsp);
+void OSFillFPUContext(OSContext* context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSDC.h b/include/revolution/os/OSDC.h
new file mode 100644
index 0000000000..74dc87bcfb
--- /dev/null
+++ b/include/revolution/os/OSDC.h
@@ -0,0 +1,23 @@
+#ifndef _REVOLUTION_OSDC_H_
+#define _REVOLUTION_OSDC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void DCFlashInvalidate(void);
+void DCEnable(void);
+void DCDisable(void);
+void DCFreeze(void);
+void DCUnfreeze(void);
+void DCTouchLoad(void* addr);
+void DCBlockZero(void* addr);
+void DCBlockStore(void* addr);
+void DCBlockFlush(void* addr);
+void DCBlockInvalidate(void* addr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSError.h b/include/revolution/os/OSError.h
new file mode 100644
index 0000000000..bfe3a4486e
--- /dev/null
+++ b/include/revolution/os/OSError.h
@@ -0,0 +1,38 @@
+#ifndef _REVOLUTION_OSERROR_H_
+#define _REVOLUTION_OSERROR_H_
+
+#include <revolution/os/OSContext.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef u16 OSError;
+typedef void (*OSErrorHandler)(OSError error, OSContext* context, ...);
+
+#define OS_ERROR_SYSTEM_RESET 0
+#define OS_ERROR_MACHINE_CHECK 1
+#define OS_ERROR_DSI 2
+#define OS_ERROR_ISI 3
+#define OS_ERROR_EXTERNAL_INTERRUPT 4
+#define OS_ERROR_ALIGNMENT 5
+#define OS_ERROR_PROGRAM 6
+#define OS_ERROR_FLOATING_POINT 7
+#define OS_ERROR_DECREMENTER 8
+#define OS_ERROR_SYSTEM_CALL 9
+#define OS_ERROR_TRACE 10
+#define OS_ERROR_PERFORMACE_MONITOR 11
+#define OS_ERROR_BREAKPOINT 12
+#define OS_ERROR_SYSTEM_INTERRUPT 13
+#define OS_ERROR_THERMAL_INTERRUPT 14
+#define OS_ERROR_MAX (OS_ERROR_THERMAL_INTERRUPT + 1)
+
+OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler);
+extern u32 __OSFpscrEnableBits;
+extern OSErrorHandler __OSErrorTable[17];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSException.h b/include/revolution/os/OSException.h
new file mode 100644
index 0000000000..c2ee00a479
--- /dev/null
+++ b/include/revolution/os/OSException.h
@@ -0,0 +1,61 @@
+#ifndef _REVOLUTION_OSEXCEPTION_H_
+#define _REVOLUTION_OSEXCEPTION_H_
+
+#include <revolution/os/OSContext.h>
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __OS_EXCEPTION_SYSTEM_RESET 0
+#define __OS_EXCEPTION_MACHINE_CHECK 1
+#define __OS_EXCEPTION_DSI 2
+#define __OS_EXCEPTION_ISI 3
+#define __OS_EXCEPTION_EXTERNAL_INTERRUPT 4
+#define __OS_EXCEPTION_ALIGNMENT 5
+#define __OS_EXCEPTION_PROGRAM 6
+#define __OS_EXCEPTION_FLOATING_POINT 7
+#define __OS_EXCEPTION_DECREMENTER 8
+#define __OS_EXCEPTION_SYSTEM_CALL 9
+#define __OS_EXCEPTION_TRACE 10
+#define __OS_EXCEPTION_PERFORMACE_MONITOR 11
+#define __OS_EXCEPTION_BREAKPOINT 12
+#define __OS_EXCEPTION_SYSTEM_INTERRUPT 13
+#define __OS_EXCEPTION_THERMAL_INTERRUPT 14
+#define __OS_EXCEPTION_MEMORY_PROTECTION 15
+#define __OS_EXCEPTION_FLOATING_POINT_EXCEPTION 16
+#define __OS_EXCEPTION_MAX \
+ (__OS_EXCEPTION_THERMAL_INTERRUPT+1)
+
+typedef u8 __OSException;
+typedef void (*__OSExceptionHandler)(__OSException exception, OSContext* context);
+
+__OSExceptionHandler __OSSetExceptionHandler(__OSException exception, __OSExceptionHandler handler);
+__OSExceptionHandler __OSGetExceptionHandler(__OSException exception);
+
+#define OS_EXCEPTION_SAVE_GPRS(context) \
+ stw r0, OS_CONTEXT_R0(context); \
+ stw r1, OS_CONTEXT_R1(context); \
+ stw r2, OS_CONTEXT_R2(context); \
+ stmw r6, OS_CONTEXT_R6(context); \
+ mfspr r0, GQR1; \
+ stw r0, OS_CONTEXT_GQR1(context); \
+ mfspr r0, GQR2; \
+ stw r0, OS_CONTEXT_GQR2(context); \
+ mfspr r0, GQR3; \
+ stw r0, OS_CONTEXT_GQR3(context); \
+ mfspr r0, GQR4; \
+ stw r0, OS_CONTEXT_GQR4(context); \
+ mfspr r0, GQR5; \
+ stw r0, OS_CONTEXT_GQR5(context); \
+ mfspr r0, GQR6; \
+ stw r0, OS_CONTEXT_GQR6(context); \
+ mfspr r0, GQR7; \
+ stw r0, OS_CONTEXT_GQR7(context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_OSEXCEPTION_H_
diff --git a/include/revolution/os/OSExec.h b/include/revolution/os/OSExec.h
new file mode 100644
index 0000000000..a2f384c06e
--- /dev/null
+++ b/include/revolution/os/OSExec.h
@@ -0,0 +1,35 @@
+#ifndef _REVOLUTION_OSEXEC_H_
+#define _REVOLUTION_OSEXEC_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ BOOL valid;
+ u32 restartCode;
+ u32 bootDol;
+ void* regionStart;
+ void* regionEnd;
+ int argsUseDefault;
+ void* argsAddr;
+} OSExecParams;
+
+typedef int (*appGetNextCallback)(void*, u32*, u32*);
+typedef void (*appInitCallback)(void (*)(char*));
+typedef void* (*appGetEntryCallback)();
+typedef void (*AppLoaderCallback)(appInitCallback*, appGetNextCallback*, appGetEntryCallback*);
+
+OSExecParams* __OSExecParams AT_ADDRESS(0x800030F0);
+s32 __OSAppLoaderOffset AT_ADDRESS(0x800030F4);
+
+void OSExecv(const char* dolfile, const char** argv);
+void OSExecl(const char* dolfile, const char* arg0, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSFont.h b/include/revolution/os/OSFont.h
new file mode 100644
index 0000000000..5e6cf76e26
--- /dev/null
+++ b/include/revolution/os/OSFont.h
@@ -0,0 +1,58 @@
+#ifndef _REVOLUTION_OSFONT_H_
+#define _REVOLUTION_OSFONT_H_
+
+#include <revolution/types.h>
+#include <revolution/os/OSUtf.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OS_FONT_ENCODE_ANSI 0u
+#define OS_FONT_ENCODE_SJIS 1u
+#define OS_FONT_ENCODE_MAX 5u
+#define OS_FONT_SIZE_ANSI (288 + 131072) // 9 sheets
+#define OS_FONT_SIZE_SJIS (3840 + 1179648) // 1 sheet
+#define OS_FONT_ROM_SIZE_ANSI 0x03000
+#define OS_FONT_ROM_SIZE_SJIS 0x4D000
+
+typedef struct OSFontHeader {
+ u16 fontType;
+ u16 firstChar;
+ u16 lastChar;
+ u16 invalChar;
+ u16 ascent;
+ u16 descent;
+ u16 width;
+ u16 leading;
+ u16 cellWidth;
+ u16 cellHeight;
+ u32 sheetSize;
+ u16 sheetFormat;
+ u16 sheetColumn;
+ u16 sheetRow;
+ u16 sheetWidth;
+ u16 sheetHeight;
+ u16 widthTable;
+ u32 sheetImage;
+ u32 sheetFullSize;
+ u8 c0;
+ u8 c1;
+ u8 c2;
+ u8 c3;
+} OSFontHeader;
+
+u16 OSGetFontEncode(void);
+u16 OSSetFontEncode(u16 encode);
+BOOL OSInitFont(OSFontHeader* fontData);
+u32 OSLoadFont(OSFontHeader* fontData, void* tmp);
+char* OSGetFontTexture(const char* string, void** image, s32* x, s32* y, s32* width);
+char* OSGetFontWidth(const char* string, s32* width);
+char* OSGetFontTexel(const char* string, void* image, s32 pos, s32 stride, s32* width);
+int OSSetFontWidth(int fixed);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSIC.h b/include/revolution/os/OSIC.h
new file mode 100644
index 0000000000..163c42d1ed
--- /dev/null
+++ b/include/revolution/os/OSIC.h
@@ -0,0 +1,20 @@
+#ifndef _REVOLUTION_OSIC_H_
+#define _REVOLUTION_OSIC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void ICFlashInvalidate(void);
+void ICEnable(void);
+void ICDisable(void);
+void ICFreeze(void);
+void ICUnfreeze(void);
+void ICBlockInvalidate(void *addr);
+void ICSync(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSInterrupt.h b/include/revolution/os/OSInterrupt.h
new file mode 100644
index 0000000000..babf3fe1ff
--- /dev/null
+++ b/include/revolution/os/OSInterrupt.h
@@ -0,0 +1,118 @@
+#ifndef _REVOLUTION_OSINTERRUPT_H_
+#define _REVOLUTION_OSINTERRUPT_H_
+
+#include <revolution/types.h>
+#include <revolution/os/OSException.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef s16 __OSInterrupt;
+typedef u32 OSInterruptMask;
+
+#define __OS_INTERRUPT_MEM_0 0
+#define __OS_INTERRUPT_MEM_1 1
+#define __OS_INTERRUPT_MEM_2 2
+#define __OS_INTERRUPT_MEM_3 3
+#define __OS_INTERRUPT_MEM_ADDRESS 4
+#define __OS_INTERRUPT_DSP_AI 5
+#define __OS_INTERRUPT_DSP_ARAM 6
+#define __OS_INTERRUPT_DSP_DSP 7
+#define __OS_INTERRUPT_AI_AI 8
+#define __OS_INTERRUPT_EXI_0_EXI 9
+#define __OS_INTERRUPT_EXI_0_TC 10
+#define __OS_INTERRUPT_EXI_0_EXT 11
+#define __OS_INTERRUPT_EXI_1_EXI 12
+#define __OS_INTERRUPT_EXI_1_TC 13
+#define __OS_INTERRUPT_EXI_1_EXT 14
+#define __OS_INTERRUPT_EXI_2_EXI 15
+#define __OS_INTERRUPT_EXI_2_TC 16
+#define __OS_INTERRUPT_PI_CP 17
+#define __OS_INTERRUPT_PI_PE_TOKEN 18
+#define __OS_INTERRUPT_PI_PE_FINISH 19
+#define __OS_INTERRUPT_PI_SI 20
+#define __OS_INTERRUPT_PI_DI 21
+#define __OS_INTERRUPT_PI_RSW 22
+#define __OS_INTERRUPT_PI_ERROR 23
+#define __OS_INTERRUPT_PI_VI 24
+#define __OS_INTERRUPT_PI_DEBUG 25
+#define __OS_INTERRUPT_PI_HSP 26
+#define __OS_INTERRUPT_MAX 32
+
+#define OS_INTERRUPTMASK(interrupt) (0x80000000u >> (interrupt))
+
+#define OS_INTERRUPTMASK_MEM_0 OS_INTERRUPTMASK(__OS_INTERRUPT_MEM_0)
+#define OS_INTERRUPTMASK_MEM_1 OS_INTERRUPTMASK(__OS_INTERRUPT_MEM_1)
+#define OS_INTERRUPTMASK_MEM_2 OS_INTERRUPTMASK(__OS_INTERRUPT_MEM_2)
+#define OS_INTERRUPTMASK_MEM_3 OS_INTERRUPTMASK(__OS_INTERRUPT_MEM_3)
+#define OS_INTERRUPTMASK_MEM_ADDRESS OS_INTERRUPTMASK(__OS_INTERRUPT_MEM_ADDRESS)
+#define OS_INTERRUPTMASK_MEM_RESET \
+ (OS_INTERRUPTMASK_MEM_0 | OS_INTERRUPTMASK_MEM_1 | OS_INTERRUPTMASK_MEM_2 | \
+ OS_INTERRUPTMASK_MEM_3)
+#define OS_INTERRUPTMASK_MEM \
+ (OS_INTERRUPTMASK_MEM_0 | OS_INTERRUPTMASK_MEM_1 | OS_INTERRUPTMASK_MEM_2 | \
+ OS_INTERRUPTMASK_MEM_3 | OS_INTERRUPTMASK_MEM_ADDRESS)
+#define OS_INTERRUPTMASK_DSP_AI OS_INTERRUPTMASK(__OS_INTERRUPT_DSP_AI)
+#define OS_INTERRUPTMASK_DSP_ARAM OS_INTERRUPTMASK(__OS_INTERRUPT_DSP_ARAM)
+#define OS_INTERRUPTMASK_DSP_DSP OS_INTERRUPTMASK(__OS_INTERRUPT_DSP_DSP)
+#define OS_INTERRUPTMASK_DSP \
+ (OS_INTERRUPTMASK_DSP_AI | OS_INTERRUPTMASK_DSP_ARAM | OS_INTERRUPTMASK_DSP_DSP)
+#define OS_INTERRUPTMASK_AI_AI OS_INTERRUPTMASK(__OS_INTERRUPT_AI_AI)
+#define OS_INTERRUPTMASK_AI (OS_INTERRUPTMASK_AI_AI)
+#define OS_INTERRUPTMASK_EXI_0_EXI OS_INTERRUPTMASK(__OS_INTERRUPT_EXI_0_EXI)
+#define OS_INTERRUPTMASK_EXI_0_TC OS_INTERRUPTMASK(__OS_INTERRUPT_EXI_0_TC)
+#define OS_INTERRUPTMASK_EXI_0_EXT OS_INTERRUPTMASK(__OS_INTERRUPT_EXI_0_EXT)
+#define OS_INTERRUPTMASK_EXI_0 \
+ (OS_INTERRUPTMASK_EXI_0_EXI | OS_INTERRUPTMASK_EXI_0_TC | OS_INTERRUPTMASK_EXI_0_EXT)
+#define OS_INTERRUPTMASK_EXI_1_EXI OS_INTERRUPTMASK(__OS_INTERRUPT_EXI_1_EXI)
+#define OS_INTERRUPTMASK_EXI_1_TC OS_INTERRUPTMASK(__OS_INTERRUPT_EXI_1_TC)
+#define OS_INTERRUPTMASK_EXI_1_EXT OS_INTERRUPTMASK(__OS_INTERRUPT_EXI_1_EXT)
+#define OS_INTERRUPTMASK_EXI_1 \
+ (OS_INTERRUPTMASK_EXI_1_EXI | OS_INTERRUPTMASK_EXI_1_TC | OS_INTERRUPTMASK_EXI_1_EXT)
+#define OS_INTERRUPTMASK_EXI_2_EXI OS_INTERRUPTMASK(__OS_INTERRUPT_EXI_2_EXI)
+#define OS_INTERRUPTMASK_EXI_2_TC OS_INTERRUPTMASK(__OS_INTERRUPT_EXI_2_TC)
+#define OS_INTERRUPTMASK_EXI_2 (OS_INTERRUPTMASK_EXI_2_EXI | OS_INTERRUPTMASK_EXI_2_TC)
+#define OS_INTERRUPTMASK_EXI \
+ (OS_INTERRUPTMASK_EXI_0_EXI | OS_INTERRUPTMASK_EXI_0_TC | OS_INTERRUPTMASK_EXI_0_EXT | \
+ OS_INTERRUPTMASK_EXI_1_EXI | OS_INTERRUPTMASK_EXI_1_TC | OS_INTERRUPTMASK_EXI_1_EXT | \
+ OS_INTERRUPTMASK_EXI_2_EXI | OS_INTERRUPTMASK_EXI_2_TC)
+#define OS_INTERRUPTMASK_PI_PE_TOKEN OS_INTERRUPTMASK(__OS_INTERRUPT_PI_PE_TOKEN)
+#define OS_INTERRUPTMASK_PI_PE_FINISH OS_INTERRUPTMASK(__OS_INTERRUPT_PI_PE_FINISH)
+#define OS_INTERRUPTMASK_PI_PE (OS_INTERRUPTMASK_PI_PE_TOKEN | OS_INTERRUPTMASK_PI_PE_FINISH)
+#define OS_INTERRUPTMASK_PI_CP OS_INTERRUPTMASK(__OS_INTERRUPT_PI_CP)
+#define OS_INTERRUPTMASK_PI_SI OS_INTERRUPTMASK(__OS_INTERRUPT_PI_SI)
+#define OS_INTERRUPTMASK_PI_DI OS_INTERRUPTMASK(__OS_INTERRUPT_PI_DI)
+#define OS_INTERRUPTMASK_PI_RSW OS_INTERRUPTMASK(__OS_INTERRUPT_PI_RSW)
+#define OS_INTERRUPTMASK_PI_ERROR OS_INTERRUPTMASK(__OS_INTERRUPT_PI_ERROR)
+#define OS_INTERRUPTMASK_PI_VI OS_INTERRUPTMASK(__OS_INTERRUPT_PI_VI)
+#define OS_INTERRUPTMASK_PI_DEBUG OS_INTERRUPTMASK(__OS_INTERRUPT_PI_DEBUG)
+#define OS_INTERRUPTMASK_PI_HSP OS_INTERRUPTMASK(__OS_INTERRUPT_PI_HSP)
+#define OS_INTERRUPTMASK_PI \
+ (OS_INTERRUPTMASK_PI_CP | OS_INTERRUPTMASK_PI_SI | OS_INTERRUPTMASK_PI_DI | \
+ OS_INTERRUPTMASK_PI_RSW | OS_INTERRUPTMASK_PI_ERROR | OS_INTERRUPTMASK_PI_VI | \
+ OS_INTERRUPTMASK_PI_PE_TOKEN | OS_INTERRUPTMASK_PI_PE_FINISH | OS_INTERRUPTMASK_PI_DEBUG | \
+ OS_INTERRUPTMASK_PI_HSP)
+
+typedef void (*__OSInterruptHandler)(__OSInterrupt interrupt, OSContext* context);
+
+extern volatile __OSInterrupt __OSLastInterrupt;
+extern volatile u32 __OSLastInterruptSrr0;
+extern volatile OSTime __OSLastInterruptTime;
+
+__OSInterruptHandler __OSSetInterruptHandler(__OSInterrupt interrupt, __OSInterruptHandler handler);
+
+__OSInterruptHandler __OSGetInterruptHandler(__OSInterrupt interrupt);
+
+void __OSDispatchInterrupt(__OSException exception, OSContext* context);
+
+OSInterruptMask OSGetInterruptMask(void);
+OSInterruptMask OSSetInterruptMask(OSInterruptMask mask);
+OSInterruptMask __OSMaskInterrupts(OSInterruptMask mask);
+OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSL2.h b/include/revolution/os/OSL2.h
new file mode 100644
index 0000000000..f48bd39fed
--- /dev/null
+++ b/include/revolution/os/OSL2.h
@@ -0,0 +1,20 @@
+#ifndef _REVOLUTION_OSL2_H_
+#define _REVOLUTION_OSL2_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void L2Enable(void);
+void L2Disable(void);
+void L2GlobalInvalidate(void);
+void L2SetDataOnly(BOOL dataOnly);
+void L2SetWriteThrough(BOOL writeThrough);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSLC.h b/include/revolution/os/OSLC.h
new file mode 100644
index 0000000000..7c59f5f5fb
--- /dev/null
+++ b/include/revolution/os/OSLC.h
@@ -0,0 +1,19 @@
+#ifndef _REVOLUTION_OSLC_H_
+#define _REVOLUTION_OSLC_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void LCAllocOneTag(BOOL invalidate, void *tag);
+void LCAllocTags(BOOL invalidate, void *startTag, u32 numBlocks);
+void LCAlloc(void *addr, u32 nBytes);
+void LCAllocNoInvalidate(void *addr, u32 nBytes);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSMemory.h b/include/revolution/os/OSMemory.h
new file mode 100644
index 0000000000..9d4bbdd881
--- /dev/null
+++ b/include/revolution/os/OSMemory.h
@@ -0,0 +1,28 @@
+#ifndef _REVOLUTION_OSMEMORY_H_
+#define _REVOLUTION_OSMEMORY_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OS_PROTECT_CHAN0 0
+#define OS_PROTECT_CHAN1 1
+#define OS_PROTECT_CHAN2 2
+#define OS_PROTECT_CHAN3 3
+
+#define OS_PROTECT_CONTROL_NONE 0x00
+#define OS_PROTECT_CONTROL_READ 0x01
+#define OS_PROTECT_CONTROL_WRITE 0x02
+#define OS_PROTECT_CONTROL_RDWR (OS_PROTECT_CONTROL_READ | OS_PROTECT_CONTROL_WRITE)
+
+void OSProtectRange(u32 chan, void* addr, u32 nBytes, u32 control);
+u32 OSGetPhysicalMemSize(void);
+u32 OSGetConsoleSimulatedMemSize(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSMessage.h b/include/revolution/os/OSMessage.h
new file mode 100644
index 0000000000..a7d0fa4e41
--- /dev/null
+++ b/include/revolution/os/OSMessage.h
@@ -0,0 +1,33 @@
+#ifndef _REVOLUTION_OSMESSAGE_H_
+#define _REVOLUTION_OSMESSAGE_H_
+
+#include <revolution/os/OSThread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void* OSMessage;
+
+#define OS_MESSAGE_NOBLOCK 0
+#define OS_MESSAGE_BLOCK 1
+
+typedef struct {
+ OSThreadQueue queueSend;
+ OSThreadQueue queueReceive;
+ void* msgArray;
+ s32 msgCount;
+ s32 firstIndex;
+ s32 usedCount;
+} OSMessageQueue;
+
+void OSInitMessageQueue(OSMessageQueue* mq, void* msgArray, s32 msgCount);
+int OSSendMessage(OSMessageQueue* mq, void* msg, s32 flags);
+int OSReceiveMessage(OSMessageQueue* mq, void* msg, s32 flags);
+int OSJamMessage(OSMessageQueue* mq, void* msg, s32 flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_OSMESSAGE_H_
diff --git a/include/revolution/os/OSModule.h b/include/revolution/os/OSModule.h
new file mode 100644
index 0000000000..079a259ba3
--- /dev/null
+++ b/include/revolution/os/OSModule.h
@@ -0,0 +1,117 @@
+#ifndef _REVOLUTION_OSMODULE_H_
+#define _REVOLUTION_OSMODULE_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OS_MODULE_VERSION 3
+typedef struct OSModuleHeader OSModuleHeader;
+
+typedef u32 OSModuleID;
+typedef struct OSModuleQueue OSModuleQueue;
+typedef struct OSModuleLink OSModuleLink;
+typedef struct OSModuleInfo OSModuleInfo;
+typedef struct OSSectionInfo OSSectionInfo;
+typedef struct OSImportInfo OSImportInfo;
+typedef struct OSRel OSRel;
+
+struct OSModuleQueue {
+ OSModuleInfo* head;
+ OSModuleInfo* tail;
+};
+
+struct OSModuleLink {
+ OSModuleInfo* next;
+ OSModuleInfo* prev;
+};
+
+struct OSModuleInfo {
+ OSModuleID id; // unique identifier for the module
+ OSModuleLink link; // doubly linked list of modules
+ u32 numSections; // # of sections
+ u32 sectionInfoOffset; // offset to section info table
+ u32 nameOffset; // offset to module name
+ u32 nameSize; // size of module name
+ u32 version; // version number
+};
+
+struct OSModuleHeader {
+ // CAUTION: info must be the 1st member
+ OSModuleInfo info;
+
+ // OS_MODULE_VERSION == 1
+ u32 bssSize; // total size of bss sections in bytes
+ u32 relOffset;
+ u32 impOffset;
+ u32 impSize; // size in bytes
+ u8 prologSection; // section # for prolog function
+ u8 epilogSection; // section # for epilog function
+ u8 unresolvedSection; // section # for unresolved function
+ u8 bssSection; // section # for bss section (set at run-time)
+ u32 prolog; // prolog function offset
+ u32 epilog; // epilog function offset
+ u32 unresolved; // unresolved function offset
+
+ // OS_MODULE_VERSION == 2
+#if (2 <= OS_MODULE_VERSION)
+ u32 align; // module alignment constraint
+ u32 bssAlign; // bss alignment constraint
+#endif
+
+ // OS_MODULE_VERSION == 3
+#if (3 <= OS_MODULE_VERSION)
+ u32 fixSize;
+#endif
+};
+
+#define OSGetSectionInfo(module) ((OSSectionInfo*)(((OSModuleInfo*)(module))->sectionInfoOffset))
+
+struct OSSectionInfo {
+ u32 offset;
+ u32 size;
+};
+
+// OSSectionInfo.offset bit
+#define OS_SECTIONINFO_EXEC 0x1
+#define OS_SECTIONINFO_OFFSET(offset) ((offset) & ~0x1)
+
+struct OSImportInfo {
+ OSModuleID id; // external module id
+ u32 offset; // offset to OSRel instructions
+};
+
+struct OSRel {
+ u16 offset; // byte offset from the previous entry
+ u8 type;
+ u8 section;
+ u32 addend;
+};
+
+#define R_REVOLUTION_NOP 201 // C9h current offset += OSRel.offset
+#define R_REVOLUTION_SECTION 202 // CAh current section = OSRel.section
+#define R_REVOLUTION_END 203 // CBh
+#define R_REVOLUTION_MRKREF 204 // CCh
+
+void OSSetStringTable(void* stringTable);
+BOOL OSLink(OSModuleInfo* newModule, void* bss);
+
+#if (3 <= OS_MODULE_VERSION)
+BOOL OSLinkFixed(OSModuleInfo* newModule, void* bss);
+#endif
+
+BOOL OSUnlink(OSModuleInfo* oldModule);
+
+OSModuleInfo* OSSearchModule(void* ptr, u32* section, u32* offset);
+
+// debugger notification
+void OSNotifyLink(OSModuleInfo* module);
+void OSNotifyUnlink(OSModuleInfo* module);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSMutex.h b/include/revolution/os/OSMutex.h
new file mode 100644
index 0000000000..f5ea089b73
--- /dev/null
+++ b/include/revolution/os/OSMutex.h
@@ -0,0 +1,33 @@
+#ifndef _REVOLUTION_OSMUTEX_H_
+#define _REVOLUTION_OSMUTEX_H_
+
+#include <revolution/os/OSThread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct OSMutex {
+ /* 0x00 */ OSThreadQueue queue;
+ /* 0x08 */ OSThread* thread;
+ /* 0x0C */ s32 count;
+ /* 0x10 */ OSMutexLink link;
+};
+
+typedef struct OSCond {
+ OSThreadQueue queue;
+} OSCond;
+
+void OSInitMutex(OSMutex* mutex);
+void OSLockMutex(OSMutex* mutex);
+void OSUnlockMutex(OSMutex* mutex);
+BOOL OSTryLockMutex(OSMutex* mutex);
+void OSInitCond(OSCond* cond);
+void OSWaitCond(OSCond* cond, OSMutex* mutex);
+void OSSignalCond(OSCond* cond);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSReboot.h b/include/revolution/os/OSReboot.h
new file mode 100644
index 0000000000..cd62bbe72a
--- /dev/null
+++ b/include/revolution/os/OSReboot.h
@@ -0,0 +1,19 @@
+#ifndef _REVOLUTION_OSREBOOT_H_
+#define _REVOLUTION_OSREBOOT_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void OSSetSaveRegion(void* start, void* end);
+void OSGetSaveRegion(void** start, void** end);
+void OSGetSavedRegion(void** start, void** end);
+void __OSReboot(u32 resetCode, u32 bootDol);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSReset.h b/include/revolution/os/OSReset.h
new file mode 100644
index 0000000000..9e3f9ead45
--- /dev/null
+++ b/include/revolution/os/OSReset.h
@@ -0,0 +1,39 @@
+#ifndef _REVOLUTION_OSRESET_H_
+#define _REVOLUTION_OSRESET_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OS_RESET_RESTART 0
+#define OS_RESET_HOTRESET 1
+#define OS_RESET_SHUTDOWN 2
+
+typedef struct OSResetFunctionInfo OSResetFunctionInfo;
+typedef struct OSResetFunctionQueue {
+ OSResetFunctionInfo* head;
+ OSResetFunctionInfo* tail;
+} OSResetFunctionQueue;
+
+typedef BOOL (*OSResetFunction)(BOOL);
+
+struct OSResetFunctionInfo {
+ OSResetFunction func;
+ u32 priority;
+ OSResetFunctionInfo* next;
+ OSResetFunctionInfo* prev;
+};
+
+void OSRegisterResetFunction(OSResetFunctionInfo* info);
+void OSUnregisterResetFunction(OSResetFunctionInfo* info);
+void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu);
+u32 OSGetResetCode();
+u32 OSSetBootDol(u32 dolOffset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSResetSW.h b/include/revolution/os/OSResetSW.h
new file mode 100644
index 0000000000..6124c02b4d
--- /dev/null
+++ b/include/revolution/os/OSResetSW.h
@@ -0,0 +1,20 @@
+#ifndef _REVOLUTION_OSRESETSW_H_
+#define _REVOLUTION_OSRESETSW_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*OSResetCallback)(void);
+
+OSResetCallback OSSetResetCallback(OSResetCallback callback);
+BOOL OSGetResetSwitchState(void);
+BOOL OSGetResetButtonState(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSRtc.h b/include/revolution/os/OSRtc.h
new file mode 100644
index 0000000000..5226b30026
--- /dev/null
+++ b/include/revolution/os/OSRtc.h
@@ -0,0 +1,84 @@
+#ifndef _REVOLUTION_OSRTC_H_
+#define _REVOLUTION_OSRTC_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// make the assert happy
+#define OS_SOUND_MODE_MONO 0
+#define OS_SOUND_MODE_STEREO 1
+
+// make the asserts happy
+#define OS_VIDEO_MODE_NTSC 0
+#define OS_VIDEO_MODE_MPAL 2
+
+#define OS_PROGRESSIVE_MODE_OFF 0
+#define OS_PROGRESSIVE_MODE_ON 1
+
+#define OS_EURGB60_OFF 0
+#define OS_EURGB60_ON 1
+
+#define OS_LANGUAGE_ENGLISH 0
+#define OS_LANGUAGE_GERMAN 1
+#define OS_LANGUAGE_FRENCH 2
+#define OS_LANGUAGE_SPANISH 3
+#define OS_LANGUAGE_ITALIAN 4
+#define OS_LANGUAGE_DUTCH 5
+
+typedef struct OSSram {
+ u16 checkSum;
+ u16 checkSumInv;
+ u32 ead0;
+ u32 ead1;
+ u32 counterBias;
+ s8 displayOffsetH;
+ u8 ntd;
+ u8 language;
+ u8 flags;
+} OSSram;
+
+typedef struct OSSramEx {
+ u8 flashID[2][12];
+ u32 wirelessKeyboardID;
+ u16 wirelessPadID[4];
+ u8 dvdErrorCode;
+ u8 _padding0;
+ u8 flashIDCheckSum[2];
+ u16 gbs;
+ u8 _padding1[2];
+} OSSramEx;
+
+#define SRAM_SIZE (sizeof(OSSram) + sizeof(OSSramEx))
+
+typedef struct SramControl {
+ u8 sram[SRAM_SIZE]; // dummy for OSSram + OSSramEx
+ u32 offset;
+ BOOL enabled;
+ BOOL locked;
+ int sync;
+ void (*callback)();
+} SramControl;
+
+u32 OSGetSoundMode(void);
+void OSSetSoundMode(u32 mode);
+u32 OSGetVideoMode(void);
+void OSSetVideoMode(u32 mode);
+u8 OSGetLanguage(void);
+void OSSetLanguage(u8 language);
+u16 OSGetGbsMode(void);
+void OSSetGbsMode(u16 mode);
+u32 OSGetProgressiveMode(void);
+void OSSetProgressiveMode(u32 on);
+u32 OSGetEuRgb60Mode(void);
+void OSSetEuRgb60Mode(u32 on);
+u16 OSGetWirelessID(s32 chan);
+void OSSetWirelessID(s32 chan, u16 id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_OSRTC_H_
diff --git a/include/revolution/os/OSSemaphore.h b/include/revolution/os/OSSemaphore.h
new file mode 100644
index 0000000000..1b21f384bf
--- /dev/null
+++ b/include/revolution/os/OSSemaphore.h
@@ -0,0 +1,25 @@
+#ifndef _REVOLUTION_OSSEMAPHORE_H_
+#define _REVOLUTION_OSSEMAPHORE_H_
+
+#include <revolution/os/OSThread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct OSSemaphore {
+ s32 count;
+ OSThreadQueue queue;
+} OSSemaphore;
+
+void OSInitSemaphore(OSSemaphore* sem, s32 count);
+s32 OSWaitSemaphore(OSSemaphore* sem);
+s32 OSTryWaitSemaphore(OSSemaphore* sem);
+s32 OSSignalSemaphore(OSSemaphore* sem);
+s32 OSGetSemaphoreCount(OSSemaphore* sem);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_OSSEMAPHORE_H_
diff --git a/include/revolution/os/OSSerial.h b/include/revolution/os/OSSerial.h
new file mode 100644
index 0000000000..96c5cd9b16
--- /dev/null
+++ b/include/revolution/os/OSSerial.h
@@ -0,0 +1,6 @@
+#ifndef _REVOLUTION_OSSERIAL_H
+#define _REVOLUTION_OSSERIAL_H
+
+#include <revolution/hw_regs.h>
+
+#endif // _REVOLUTION_OSSERIAL_H
diff --git a/include/revolution/os/OSThread.h b/include/revolution/os/OSThread.h
new file mode 100644
index 0000000000..cd67538d35
--- /dev/null
+++ b/include/revolution/os/OSThread.h
@@ -0,0 +1,112 @@
+#ifndef _REVOLUTION_OSTHREAD_H_
+#define _REVOLUTION_OSTHREAD_H_
+
+#include <revolution/os/OSContext.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef s32 OSPriority;
+
+typedef struct OSThread OSThread;
+typedef struct OSMutex OSMutex;
+typedef struct OSThreadQueue OSThreadQueue;
+typedef struct OSMutexQueue OSMutexQueue;
+typedef struct OSThreadLink OSThreadLink;
+typedef struct OSMutexLink OSMutexLink;
+
+struct OSThreadQueue {
+ OSThread* head;
+ OSThread* tail;
+};
+
+struct OSThreadLink {
+ OSThread* next;
+ OSThread* prev;
+};
+
+struct OSMutexQueue {
+ OSMutex* head;
+ OSMutex* tail;
+};
+
+struct OSMutexLink {
+ OSMutex* next;
+ OSMutex* prev;
+};
+
+struct OSThread {
+ /* 0x000 */ OSContext context;
+ /* 0x2C8 */ u16 state;
+ /* 0x2CA */ u16 attr;
+ /* 0x2CC */ s32 suspend;
+ /* 0x2D0 */ OSPriority priority;
+ /* 0x2D4 */ OSPriority base;
+ /* 0x2D8 */ void* val;
+ /* 0x2DC */ OSThreadQueue* queue;
+ /* 0x2E0 */ OSThreadLink link;
+ /* 0x2E8 */ OSThreadQueue queueJoin;
+ /* 0x2F0 */ OSMutex* mutex;
+ /* 0x2F4 */ OSMutexQueue queueMutex;
+ /* 0x2FC */ OSThreadLink linkActive;
+ /* 0x304 */ u8* stackBase;
+ /* 0x308 */ u32* stackEnd;
+ /* 0x30C */ s32 error;
+ /* 0x310 */ void* specific[2];
+};
+
+enum OS_THREAD_STATE {
+ OS_THREAD_STATE_READY = 1,
+ OS_THREAD_STATE_RUNNING = 2,
+ OS_THREAD_STATE_WAITING = 4,
+ OS_THREAD_STATE_MORIBUND = 8,
+};
+
+#define OS_PRIORITY_MIN 0 // highest
+#define OS_PRIORITY_MAX 31 // lowest
+#define OS_PRIORITY_IDLE OS_PRIORITY_MAX
+
+#define OS_THREAD_SPECIFIC_MAX 2
+
+#define OS_THREAD_ATTR_DETACH 0x0001u
+
+#define OS_THREAD_STACK_MAGIC 0xDEADBABE
+
+typedef void (*OSSwitchThreadCallback)(OSThread*, OSThread*);
+typedef void (*OSIdleFunction)(void*);
+
+void OSInitThreadQueue(OSThreadQueue* queue);
+void OSSleepThread(OSThreadQueue* queue);
+void OSWakeupThread(OSThreadQueue* queue);
+s32 OSSuspendThread(OSThread* thread);
+s32 OSResumeThread(OSThread* thread);
+OSThread* OSGetCurrentThread(void);
+s32 OSEnableScheduler(void);
+s32 OSDisableScheduler(void);
+void OSCancelThread(OSThread* thread);
+void OSClearStack(u8 val);
+BOOL OSIsThreadSuspended(OSThread* thread);
+BOOL OSIsThreadTerminated(OSThread* thread);
+void OSYieldThread(void);
+int OSCreateThread(OSThread* thread, void* (*func)(void*), void* param, void* stack, u32 stackSize, OSPriority priority, u16 attr);
+void OSExitThread(void* val);
+int OSJoinThread(OSThread* thread, void* val);
+void OSDetachThread(OSThread* thread);
+int OSSetThreadPriority(OSThread* thread, OSPriority priority);
+s32 OSGetThreadPriority(OSThread* thread);
+OSThread* OSSetIdleFunction(OSIdleFunction idleFunction, void* param, void* stack, u32 stackSize);
+OSThread* OSGetIdleFunction(void);
+s32 OSCheckActiveThreads(void);
+void OSSetThreadSpecific(s32 index, void* ptr);
+void* OSGetThreadSpecific(s32 index);
+
+OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback callback);
+
+#define IsSuspended(suspend) (suspend > 0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/os/OSTime.h b/include/revolution/os/OSTime.h
new file mode 100644
index 0000000000..abd8eaa2f6
--- /dev/null
+++ b/include/revolution/os/OSTime.h
@@ -0,0 +1,44 @@
+#ifndef _REVOLUTION_OSTIME_H_
+#define _REVOLUTION_OSTIME_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Time base frequency = 1/4 bus clock
+#define OS_TIME_SPEED (OS_BUS_CLOCK / 4)
+
+// OS time -> Real time
+#define OS_TICKS_TO_SEC(x) ((x) / (OS_TIME_SPEED))
+#define OS_TICKS_TO_MSEC(x) ((x) / (OS_TIME_SPEED / 1000))
+#define OS_TICKS_TO_USEC(x) (((x)*8) / (OS_TIME_SPEED / 125000))
+#define OS_TICKS_TO_NSEC(x) (((x)*8000) / (OS_TIME_SPEED / 125000))
+
+// Real time -> OS time
+#define OS_SEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED))
+#define OS_MSEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED / 1000))
+#define OS_USEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED / 125000) / 8)
+#define OS_NSEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED / 125000) / 8000)
+
+#define USEC_MAX 1000
+#define MSEC_MAX 1000
+#define MONTH_MAX 12
+#define WEEK_DAY_MAX 7
+#define YEAR_DAY_MAX 365
+
+#define SECS_IN_MIN 60
+#define SECS_IN_HOUR (SECS_IN_MIN * 60)
+#define SECS_IN_DAY (SECS_IN_HOUR * 24)
+#define SECS_IN_YEAR (SECS_IN_DAY * 365)
+
+#define BIAS 0xB2575
+
+#define __OSSystemTime (OSTime*)0x800030D8
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_OSTIME_H_
diff --git a/include/revolution/os/OSTimer.h b/include/revolution/os/OSTimer.h
new file mode 100644
index 0000000000..2e12593ae9
--- /dev/null
+++ b/include/revolution/os/OSTimer.h
@@ -0,0 +1,21 @@
+#ifndef _REVOLUTION_OSTIMER_H_
+#define _REVOLUTION_OSTIMER_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*OSTimerCallback)(void);
+
+OSTimerCallback OSSetTimerCallback(OSTimerCallback callback);
+void OSInitTimer(u32 time, u32 mode);
+void OSStartTimer(void);
+void OSStopTimer(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_OSTIMER_H_
diff --git a/include/revolution/os/OSUtf.h b/include/revolution/os/OSUtf.h
new file mode 100644
index 0000000000..974599035b
--- /dev/null
+++ b/include/revolution/os/OSUtf.h
@@ -0,0 +1,23 @@
+#ifndef _REVOLUTION_OSUTF_H_
+#define _REVOLUTION_OSUTF_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char* OSUTF8to32(const char* utf8, u32* utf32);
+char* OSUTF32to8(u32 utf32, char* utf8);
+u16* OSUTF16to32(const u16* utf16, u32* utf32);
+u16* OSUTF32to16(u32 utf32, u16* utf16);
+u8 OSUTF32toANSI(u32 utf32);
+u32 OSANSItoUTF32(u8 ansi);
+u16 OSUTF32toSJIS(u32 utf32);
+u32 OSSJIStoUTF32(u16 sjis);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_OSUTF_H_
diff --git a/include/revolution/pad.h b/include/revolution/pad.h
new file mode 100644
index 0000000000..a220ddd1cb
--- /dev/null
+++ b/include/revolution/pad.h
@@ -0,0 +1,104 @@
+#ifndef _REVOLUTION_PAD_H_
+#define _REVOLUTION_PAD_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PAD_SPEC_0 0
+#define PAD_SPEC_1 1
+#define PAD_SPEC_2 2
+#define PAD_SPEC_3 3
+#define PAD_SPEC_4 4
+#define PAD_SPEC_5 5
+
+#define PAD_MOTOR_STOP 0
+#define PAD_MOTOR_RUMBLE 1
+#define PAD_MOTOR_STOP_HARD 2
+
+#define PAD_CHAN0_BIT 0x80000000
+#define PAD_CHAN1_BIT 0x40000000
+#define PAD_CHAN2_BIT 0x20000000
+#define PAD_CHAN3_BIT 0x10000000
+
+#define PAD_MAX_CONTROLLERS 4
+
+#define PAD_BUTTON_LEFT (1 << 0) // 0x0001
+#define PAD_BUTTON_RIGHT (1 << 1) // 0x0002
+#define PAD_BUTTON_DOWN (1 << 2) // 0x0004
+#define PAD_BUTTON_UP (1 << 3) // 0x0008
+#define PAD_TRIGGER_Z (1 << 4) // 0x0010
+#define PAD_TRIGGER_R (1 << 5) // 0x0020
+#define PAD_TRIGGER_L (1 << 6) // 0x0040
+#define PAD_BUTTON_A (1 << 8) // 0x0100
+#define PAD_BUTTON_B (1 << 9) // 0x0200
+#define PAD_BUTTON_X (1 << 10) // 0x0400
+#define PAD_BUTTON_Y (1 << 11) // 0x0800
+#define PAD_BUTTON_MENU (1 << 12) // 0x1000
+#define PAD_BUTTON_START (1 << 12) // 0x1000
+
+#define PAD_ERR_NONE 0
+#define PAD_ERR_NO_CONTROLLER -1
+#define PAD_ERR_NOT_READY -2
+#define PAD_ERR_TRANSFER -3
+
+#define RES_WIRELESS_LITE 0x40000
+
+typedef struct PADStatus {
+ /* 0x00 */ u16 button;
+ /* 0x02 */ s8 stickX;
+ /* 0x03 */ s8 stickY;
+ /* 0x04 */ s8 substickX;
+ /* 0x05 */ s8 substickY;
+ /* 0x06 */ u8 triggerLeft;
+ /* 0x07 */ u8 triggerRight;
+ /* 0x08 */ u8 analogA;
+ /* 0x09 */ u8 analogB;
+ /* 0x0A */ s8 err;
+} PADStatus;
+
+typedef struct PADClampRegion {
+ u8 minTrigger;
+ u8 maxTrigger;
+ s8 minStick;
+ s8 maxStick;
+ s8 xyStick;
+ s8 minSubstick;
+ s8 maxSubstick;
+ s8 xySubstick;
+ s8 radStick;
+ s8 radSubstick;
+} PADClampRegion;
+
+typedef void (*PADSamplingCallback)(void);
+
+// Pad
+int PADReset(u32 mask);
+BOOL PADRecalibrate(u32 mask);
+BOOL PADInit();
+u32 PADRead(PADStatus* status);
+void PADSetSamplingRate(u32 msec);
+void __PADTestSamplingRate(u32 tvmode);
+void PADControlAllMotors(const u32* commandArray);
+void PADControlMotor(s32 chan, u32 command);
+void PADSetSpec(u32 spec);
+u32 PADGetSpec();
+int PADGetType(s32 chan, u32* type);
+BOOL PADSync(void);
+void PADSetAnalogMode(u32 mode);
+BOOL __PADDisableRecalibration(BOOL disable);
+BOOL PADIsBarrel(s32 chan);
+
+PADSamplingCallback PADSetSamplingCallback(PADSamplingCallback callback);
+
+// Padclamp
+void PADClamp(PADStatus* status);
+void PADClampCircle(PADStatus* status);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/revolution.h b/include/revolution/revolution.h
new file mode 100644
index 0000000000..f8bb1b995f
--- /dev/null
+++ b/include/revolution/revolution.h
@@ -0,0 +1,18 @@
+#ifndef _REVOLUTION_H_
+#define _REVOLUTION_H_
+
+#include <revolution/types.h>
+#include <revolution/os.h>
+#include <revolution/dsp.h>
+#include <revolution/dvd.h>
+#include <revolution/gx.h>
+#include <revolution/mtx.h>
+#include <revolution/vi.h>
+#include <revolution/base/PPCArch.h>
+#include <revolution/db.h>
+#include <revolution/pad.h>
+#include <revolution/ai.h>
+#include <revolution/exi.h>
+#include <revolution/si.h>
+
+#endif
diff --git a/include/revolution/sc.h b/include/revolution/sc.h
new file mode 100644
index 0000000000..dd389bb3eb
--- /dev/null
+++ b/include/revolution/sc.h
@@ -0,0 +1,34 @@
+#ifndef _REVOLUTION_SC_H_
+#define _REVOLUTION_SC_H_
+
+#include <revolution/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void SCInit(void);
+u32 SCCheckStatus(void);
+int SCReloadConfFileAsync(void* bufp, u32 bufSize, int);
+BOOL SCFindByteArrayItem(u8* data, u32, u32 itemID);
+BOOL SCFindIntegerItem(int* data, u32 itemID, u8 type);
+BOOL SCFindU8Item(u8* data, u32 itemID);
+BOOL SCFindS8Item(s8* data, u32 itemID);
+BOOL SCFindU32Item(u32* data, u32 itemID);
+u8 SCGetAspectRatio(void);
+u8 SCGetDisplayOffsetH(void);
+BOOL SCGetIdleMode(u8* data);
+u8 SCGetLanguage(void);
+u8 SCGetProgressiveMode(void);
+u8 SCGetScreenSaverMode(void);
+u8 SCGetSoundMode(void);
+u8 SCGetCounterBias(void);
+BOOL SCGetProductAreaString(const char*, int);
+u32 SCGetProductArea(void);
+u32 SCGetProductGameRegion(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/seq.h b/include/revolution/seq.h
new file mode 100644
index 0000000000..63617707bf
--- /dev/null
+++ b/include/revolution/seq.h
@@ -0,0 +1,54 @@
+#ifndef _REVOLUTION_SEQ_H_
+#define _REVOLUTION_SEQ_H_
+
+#include <revolution/syn.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _SEQTRACK {
+ /* 0x00 */ void* sequence;
+ /* 0x04 */ u8* start;
+ /* 0x08 */ u8* end;
+ /* 0x0C */ u8* current;
+ /* 0x10 */ u8 status;
+ /* 0x14 */ f32 beatsPerSec;
+ /* 0x18 */ u32 defaultTicksPerFrame;
+ /* 0x1C */ u32 ticksPerFrame;
+ /* 0x20 */ u32 delay;
+ /* 0x24 */ u32 state;
+} SEQTRACK;
+
+typedef struct _SEQSEQUENCE {
+ /* 0x0000 */ void* next;
+ /* 0x0004 */ u32 state;
+ /* 0x0008 */ u16 nTracks;
+ /* 0x000A */ s16 timeFormat;
+ /* 0x000C */ u32 tracksRunning;
+ /* 0x0010 */ u32 end;
+ /* 0x0014 */ SYNSYNTH synth;
+ /* 0x3154 */ void (*callback[128])(void*, u8);
+ /* 0x3354 */ SEQTRACK track[64];
+} SEQSEQUENCE;
+
+#define SEQ_ALL_TRACKS -1
+
+void SEQInit(void);
+void SEQQuit(void);
+void SEQRunAudioFrame(void);
+void SEQAddSequence(SEQSEQUENCE* sequence, u8* midiStream, void* wt, u32 aramBase, u32 zeroBase, u32 priorityVoiceAlloc, u32 priorityNoteOn, u32 priorityNoteRelease);
+void SEQRemoveSequence(SEQSEQUENCE* sequence);
+void SEQRegisterControllerCallback(SEQSEQUENCE* sequence, u8 controller, void (*callback)(void*, u8));
+void SEQSetState(SEQSEQUENCE* sequence, u32 state);
+u32 SEQGetState(SEQSEQUENCE* sequence);
+void SEQSetTempo(SEQSEQUENCE* sequence, u32 trackIndex, f32 bpm);
+f32 SEQGetTempo(SEQSEQUENCE* sequence, u32 trackIndex);
+void SEQSetVolume(SEQSEQUENCE* sequence, s32 dB);
+s32 SEQGetVolume(SEQSEQUENCE* sequence);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_SEQ_H_
diff --git a/include/revolution/si.h b/include/revolution/si.h
new file mode 100644
index 0000000000..48ecdcb9af
--- /dev/null
+++ b/include/revolution/si.h
@@ -0,0 +1,175 @@
+#ifndef _REVOLUTION_SI_H_
+#define _REVOLUTION_SI_H_
+
+#include <revolution/os.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SI_MAX_CHAN 4
+#define SI_MAX_TYPE 4
+
+#define SI_COMCSR_IDX 13
+#define SI_STATUS_IDX 14
+
+#define SI_COMCSR_TCINT_MASK (1 << 31)
+#define SI_COMCSR_TCINTMSK_MASK (1 << 30)
+#define SI_COMCSR_COMERR_MASK (1 << 29)
+#define SI_COMCSR_RDSTINT_MASK (1 << 28)
+#define SI_COMCSR_RDSTINTMSK_MASK (1 << 27)
+
+// 4 bits of padding
+#define SI_COMCSR_OUTLNGTH_MASK (1 << 22) \
+ | (1 << 21) \
+ | (1 << 20) \
+ | (1 << 19) \
+ | (1 << 18) \
+ | (1 << 17) \
+ | (1 << 16)
+
+// 1 bit of padding
+#define SI_COMCSR_INLNGTH_MASK (1 << 14) \
+ | (1 << 13) \
+ | (1 << 12) \
+ | (1 << 11) \
+ | (1 << 10) \
+ | (1 << 9) \
+ | (1 << 8)
+
+// 5 bits of padding
+#define SI_COMCSR_CHANNEL_MASK (1 << 2) \
+ | (1 << 1)
+
+#define SI_COMCSR_TSTART_MASK (1 << 0)
+
+#define SI_ERROR_UNDER_RUN 0x0001
+#define SI_ERROR_OVER_RUN 0x0002
+#define SI_ERROR_COLLISION 0x0004
+#define SI_ERROR_NO_RESPONSE 0x0008
+#define SI_ERROR_WRST 0x0010
+#define SI_ERROR_RDST 0x0020
+#define SI_ERROR_UNKNOWN 0x0040
+#define SI_ERROR_BUSY 0x0080
+
+#define SI_TYPE_MASK 0x18000000u
+#define SI_TYPE_N64 0x00000000u
+#define SI_TYPE_DOLPHIN 0x08000000u
+#define SI_TYPE_GC SI_TYPE_DOLPHIN
+#define SI_GC_WIRELESS 0x80000000
+#define SI_GC_NOMOTOR 0x20000000
+#define SI_GC_STANDARD 0x01000000
+#define SI_WIRELESS_RECEIVED 0x40000000
+#define SI_WIRELESS_IR 0x04000000
+#define SI_WIRELESS_STATE 0x02000000
+#define SI_WIRELESS_ORIGIN 0x00200000
+#define SI_WIRELESS_FIX_ID 0x00100000
+#define SI_WIRELESS_TYPE 0x000f0000
+#define SI_WIRELESS_LITE_MASK 0x000c0000
+#define SI_WIRELESS_LITE 0x00040000
+#define SI_WIRELESS_CONT_MASK 0x00080000
+#define SI_WIRELESS_CONT 0x00000000
+#define SI_WIRELESS_ID 0x00c0ff00
+#define SI_WIRELESS_TYPE_ID (SI_WIRELESS_TYPE | SI_WIRELESS_ID)
+#define SI_N64_CONTROLLER (SI_TYPE_N64 | 0x05000000)
+#define SI_N64_MIC (SI_TYPE_N64 | 0x00010000)
+#define SI_N64_KEYBOARD (SI_TYPE_N64 | 0x00020000)
+#define SI_N64_MOUSE (SI_TYPE_N64 | 0x02000000)
+#define SI_GBA (SI_TYPE_N64 | 0x00040000)
+#define SI_GC_CONTROLLER (SI_TYPE_GC | SI_GC_STANDARD)
+#define SI_GC_RECEIVER (SI_TYPE_GC | SI_GC_WIRELESS)
+#define SI_GC_WAVEBIRD (SI_TYPE_GC | SI_GC_WIRELESS | SI_GC_STANDARD | SI_WIRELESS_STATE | SI_WIRELESS_FIX_ID)
+#define SI_GC_KEYBOARD (SI_TYPE_GC | 0x00200000)
+#define SI_GC_STEERING (SI_TYPE_GC | 0x00000000)
+
+typedef void (*SICallback)(s32 chan, u32 sr, OSContext *context);
+typedef void (*SITypeCallback)(s32 chan, u32 type);
+
+typedef struct {
+ s32 chan;
+ u32 poll;
+ u32 inputBytes;
+ void* input;
+ SICallback callback;
+} SIControl;
+
+typedef struct {
+ s32 chan;
+ void* output;
+ u32 outputBytes;
+ void* input;
+ u32 inputBytes;
+ SICallback callback;
+ OSTime fire;
+} SIPacket;
+
+// SIBios
+BOOL SIBusy(void);
+BOOL SIIsChanBusy(s32 chan);
+BOOL SIRegisterPollingHandler(__OSInterruptHandler handler);
+BOOL SIUnregisterPollingHandler(__OSInterruptHandler handler);
+void SIInit(void);
+u32 SISync(void);
+u32 SIGetStatus(s32 chan);
+void SISetCommand(s32 chan, u32 command);
+u32 SIGetCommand(s32 chan);
+void SITransferCommands(void);
+u32 SISetXY(u32 x, u32 y);
+u32 SIEnablePolling(u32 poll);
+u32 SIDisablePolling(u32 poll);
+BOOL SIGetResponse(s32 chan, void* data);
+BOOL SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u32 inputBytes, SICallback callback, OSTime delay);
+u32 SIGetType(s32 chan);
+u32 SIGetTypeAsync(s32 chan, SITypeCallback callback);
+u32 SIDecodeType(u32 type);
+u32 SIProbe(s32 chan);
+char* SIGetTypeString(u32 type);
+
+extern u32 __PADFixBits;
+
+// SISamplingRate
+void SISetSamplingRate(u32 msec);
+void SIRefreshSamplingRate(void);
+
+// SISteering
+typedef void (*SISteeringCallback)(s32 chan, s32);
+
+typedef struct {
+ u8 output[3];
+ u8 input[8];
+ u32 outputBytes;
+ u32 inputBytes;
+ SISteeringCallback callback;
+ s32 ret;
+ OSThreadQueue threadQueue;
+ void (*proc)(s32);
+} SISteeringControl;
+
+typedef struct {
+ u16 button;
+ u8 misc;
+ s8 steering;
+ u8 gas;
+ u8 brake;
+ u8 left;
+ u8 right;
+ s8 err;
+} SISteeringStatus;
+
+extern SISteeringControl __SISteering[4];
+extern u32 __SISteeringEnableBits;
+extern BOOL __SIResetSteering;
+
+void SIInitSteering(void);
+s32 SIResetSteeringAsync(s32 chan, SISteeringCallback callback);
+s32 SIResetSteering(s32 chan);
+
+s32 SIReadSteering(s32 chan, SISteeringStatus* status);
+void (* SISetSteeringSamplingCallback(void (*callback)()))();
+void SIControlSteering(s32 chan, u32 control, s32 level);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_SI_H_
diff --git a/include/revolution/sp.h b/include/revolution/sp.h
new file mode 100644
index 0000000000..d5141a86ca
--- /dev/null
+++ b/include/revolution/sp.h
@@ -0,0 +1,40 @@
+#ifndef _REVOLUTION_SP_H_
+#define _REVOLUTION_SP_H_
+
+#include <revolution/types.h>
+#include <revolution/ax.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ AXPBADPCM adpcm;
+ AXPBADPCMLOOP adpcmloop;
+} SPADPCM;
+
+typedef struct {
+ u32 type;
+ u32 sampleRate;
+ u32 loopAddr;
+ u32 loopEndAddr;
+ u32 endAddr;
+ u32 currentAddr;
+ SPADPCM* adpcm;
+} SPSoundEntry;
+
+typedef struct {
+ u32 entries;
+ SPSoundEntry sound[1];
+} SPSoundTable;
+
+void SPInitSoundTable(SPSoundTable* table, u32 aramBase, u32 zeroBase);
+SPSoundEntry* SPGetSoundEntry(SPSoundTable* table, u32 index);
+void SPPrepareSound(SPSoundEntry* sound, AXVPB* axvpb, u32 sampleRate);
+void SPPrepareEnd(SPSoundEntry* sound, AXVPB* axvpb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/syn.h b/include/revolution/syn.h
new file mode 100644
index 0000000000..98afb43f34
--- /dev/null
+++ b/include/revolution/syn.h
@@ -0,0 +1,172 @@
+#ifndef _REVOLUTION_SYN_H_
+#define _REVOLUTION_SYN_H_
+
+#include <revolution/types.h>
+#include <revolution/ax.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SYN_INPUT_BUFFER_SIZE 0x100
+
+typedef struct WTINST {
+ /* 0x00 */ u16 keyRegion[128];
+} WTINST;
+
+typedef struct WTREGION {
+ /* 0x00 */ u8 unityNote;
+ /* 0x01 */ u8 keyGroup;
+ /* 0x02 */ s16 fineTune;
+ /* 0x04 */ s32 attn;
+ /* 0x08 */ u32 loopStart;
+ /* 0x0C */ u32 loopLength;
+ /* 0x10 */ u32 articulationIndex;
+ /* 0x14 */ u32 sampleIndex;
+} WTREGION;
+
+typedef struct WTART {
+ /* 0x00 */ s32 lfoFreq;
+ /* 0x04 */ s32 lfoDelay;
+ /* 0x08 */ s32 lfoAtten;
+ /* 0x0C */ s32 lfoPitch;
+ /* 0x10 */ s32 lfoMod2Atten;
+ /* 0x14 */ s32 lfoMod2Pitch;
+ /* 0x18 */ s32 eg1Attack;
+ /* 0x1C */ s32 eg1Decay;
+ /* 0x20 */ s32 eg1Sustain;
+ /* 0x24 */ s32 eg1Release;
+ /* 0x28 */ s32 eg1Vel2Attack;
+ /* 0x2C */ s32 eg1Key2Decay;
+ /* 0x30 */ s32 eg2Attack;
+ /* 0x34 */ s32 eg2Decay;
+ /* 0x38 */ s32 eg2Sustain;
+ /* 0x3C */ s32 eg2Release;
+ /* 0x40 */ s32 eg2Vel2Attack;
+ /* 0x44 */ s32 eg2Key2Decay;
+ /* 0x48 */ s32 eg2Pitch;
+ /* 0x4C */ s32 pan;
+} WTART;
+
+typedef struct WTSAMPLE {
+ /* 0x00 */ u16 format;
+ /* 0x02 */ u16 sampleRate;
+ /* 0x04 */ u32 offset;
+ /* 0x08 */ u32 length;
+ /* 0x0C */ u16 adpcmIndex;
+} WTSAMPLE;
+
+typedef struct WTADPCM {
+ /* 0x00 */ u16 a[8][2];
+ /* 0x20 */ u16 gain;
+ /* 0x22 */ u16 pred_scale;
+ /* 0x24 */ u16 yn1;
+ /* 0x26 */ u16 yn2;
+ /* 0x28 */ u16 loop_pred_scale;
+ /* 0x2A */ u16 loop_yn1;
+ /* 0x2C */ u16 loop_yn2;
+} WTADPCM;
+
+typedef struct SYNSYNTH {
+ /* 0x0000 */ void* next;
+ /* 0x0004 */ WTINST* percussiveInst;
+ /* 0x0008 */ WTINST* melodicInst;
+ /* 0x000C */ WTREGION* region;
+ /* 0x0010 */ WTART* art;
+ /* 0x0014 */ WTSAMPLE* sample;
+ /* 0x0018 */ WTADPCM* adpcm;
+ /* 0x001C */ u32 aramBaseWord;
+ /* 0x0020 */ u32 aramBaseByte;
+ /* 0x0024 */ u32 aramBaseNibble;
+ /* 0x0028 */ u32 zeroBaseWord;
+ /* 0x002C */ u32 zeroBaseByte;
+ /* 0x0030 */ u32 zeroBaseNibble;
+ /* 0x0034 */ u32 priorityVoiceAlloc;
+ /* 0x0038 */ u32 priorityNoteOn;
+ /* 0x003C */ u32 priorityNoteRelease;
+ /* 0x0040 */ WTINST* inst[16];
+ /* 0x0080 */ s32 masterVolume;
+ /* 0x0084 */ u8 controller[16][128];
+ /* 0x0844 */ u8 rpn[16];
+ /* 0x0894 */ s16 dataEntry[16];
+ /* 0x08B4 */ s32 pwMaxCents[16];
+ /* 0x08F4 */ s32 pwCents[16];
+ /* 0x0934 */ s32 volAttn[16];
+ /* 0x0974 */ s32 expAttn[16];
+ /* 0x09B4 */ s32 auxAAttn[16];
+ /* 0x09F4 */ s32 auxBAttn[16];
+ /* 0x0A34 */ u8 input[SYN_INPUT_BUFFER_SIZE][3];
+ /* 0x0D34 */ u8* inputPosition;
+ /* 0x0D38 */ u32 inputCounter;
+ /* 0x0D3C */ u32 notes;
+ /* 0x0D40 */ void* keyGroup[16][16];
+ /* 0x1140 */ void* voice[16][128];
+} SYNSYNTH;
+
+typedef struct SYNVOICE {
+ /* 0x00 */ void* next;
+ /* 0x04 */ AXVPB* axvpb;
+ /* 0x08 */ SYNSYNTH* synth;
+ /* 0x0C */ u8 midiChannel;
+ /* 0x0D */ u8 keyNum;
+ /* 0x0E */ u8 keyVel;
+ /* 0x0F */ u8 pan;
+ /* 0x10 */ u8 keyGroup;
+ /* 0x14 */ WTREGION* region;
+ /* 0x18 */ WTART* art;
+ /* 0x1C */ WTSAMPLE* sample;
+ /* 0x20 */ WTADPCM* adpcm;
+ /* 0x24 */ u32 hold;
+ /* 0x28 */ u32 type;
+ /* 0x2C */ f32 srcRatio;
+ /* 0x30 */ s32 cents;
+ /* 0x34 */ s32 attn;
+ /* 0x38 */ s32 lfoState;
+ /* 0x3C */ s32 lfoAttn;
+ /* 0x40 */ s32 lfoCents;
+ /* 0x44 */ s32 lfoFreq;
+ /* 0x48 */ s32 lfoDelay;
+ /* 0x4C */ s32 lfoAttn_;
+ /* 0x50 */ s32 lfoCents_;
+ /* 0x54 */ s32 lfoModAttn;
+ /* 0x58 */ s32 lfoModCents;
+ /* 0x5C */ u32 veState;
+ /* 0x60 */ s32 veAttn;
+ /* 0x64 */ s32 veAttack;
+ /* 0x68 */ s32 veAttackDelta;
+ /* 0x6C */ s32 veDecay;
+ /* 0x70 */ s32 veSustain;
+ /* 0x74 */ s32 veRelease;
+ /* 0x78 */ u32 peState;
+ /* 0x7C */ s32 peCents;
+ /* 0x80 */ s32 peAttack;
+ /* 0x84 */ s32 peDecay;
+ /* 0x88 */ s32 peSustain;
+ /* 0x8C */ s32 peRelease;
+ /* 0x90 */ s32 pePitch;
+} SYNVOICE;
+
+// sample formats
+#define SYN_SAMPLE_FORMAT_ADPCM 0
+#define SYN_SAMPLE_FORMAT_PCM16 1
+#define SYN_SAMPLE_FORMAT_PCM8 2
+
+// SYN
+void SYNInit(void);
+void SYNQuit(void);
+void SYNRunAudioFrame(void);
+void SYNInitSynth(SYNSYNTH* synth, void* wavetable, u32 aramBase, u32 zeroBase, u32 priorityVoiceAlloc, u32 priorityNoteOn, u32 priorityNoteRelease);
+void SYNQuitSynth(SYNSYNTH* synth);
+void SYNMidiInput(SYNSYNTH* synth, u8* input);
+void SYNSetMasterVolume(SYNSYNTH* synth, s32 dB);
+s32 SYNGetMasterVolume(SYNSYNTH* synth);
+u32 SYNGetActiveNotes(SYNSYNTH* synth);
+
+// SYNCTRL
+u8 SYNGetMidiController(SYNSYNTH* synth, u8 midiChannel, u8 function);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _REVOLUTION_SYN_H_
diff --git a/include/revolution/types.h b/include/revolution/types.h
index 9d061526b5..fdb5fb8ef6 100644
--- a/include/revolution/types.h
+++ b/include/revolution/types.h
@@ -1,5 +1,5 @@
-#ifndef _DOLPHIN_TYPES_H_
-#define _DOLPHIN_TYPES_H_
+#ifndef _REVOLUTION_TYPES_H_
+#define _REVOLUTION_TYPES_H_
typedef signed char s8;
typedef unsigned char u8;
diff --git a/include/revolution/vi.h b/include/revolution/vi.h
new file mode 100644
index 0000000000..c347e33f27
--- /dev/null
+++ b/include/revolution/vi.h
@@ -0,0 +1,7 @@
+#ifndef _REVOLUTION_VI_H_
+#define _REVOLUTION_VI_H_
+
+#include <revolution/vi/vifuncs.h>
+#include <revolution/vi/vitypes.h>
+
+#endif
diff --git a/include/revolution/vi/vifuncs.h b/include/revolution/vi/vifuncs.h
new file mode 100644
index 0000000000..3c1647b37f
--- /dev/null
+++ b/include/revolution/vi/vifuncs.h
@@ -0,0 +1,36 @@
+#ifndef _REVOLUTION_VIFUNCS_H_
+#define _REVOLUTION_VIFUNCS_H_
+
+#include <revolution/types.h>
+#include <revolution/vi/vitypes.h>
+#include <revolution/gx/GXStruct.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+VIRetraceCallback VISetPreRetraceCallback(VIRetraceCallback cb);
+VIRetraceCallback VISetPostRetraceCallback(VIRetraceCallback cb);
+void VIInit(void);
+void VIWaitForRetrace(void);
+void VIConfigure(const GXRenderModeObj* rm);
+void VIConfigurePan(u16 xOrg, u16 yOrg, u16 width, u16 height);
+void VIFlush(void);
+void VISetNextFrameBuffer(void* fb);
+void VISetNextRightFrameBuffer(void* fb);
+void VISetBlack(BOOL black);
+void VISet3D(BOOL threeD);
+u32 VIGetRetraceCount(void);
+u32 VIGetNextField(void);
+u32 VIGetCurrentLine(void);
+u32 VIGetTvFormat(void);
+void* VIGetNextFrameBuffer(void);
+void* VIGetCurrentFrameBuffer(void);
+u32 VIGetScanMode(void);
+u32 VIGetDTVStatus(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/revolution/vi/vitypes.h b/include/revolution/vi/vitypes.h
new file mode 100644
index 0000000000..807af6d5e9
--- /dev/null
+++ b/include/revolution/vi/vitypes.h
@@ -0,0 +1,41 @@
+#ifndef _REVOLUTION_VITYPES_H_
+#define _REVOLUTION_VITYPES_H_
+
+#include <revolution/types.h>
+
+#define VI_TVMODE(format, interlace) (((format) << 2) + (interlace))
+
+#define VI_INTERLACE 0
+#define VI_NON_INTERLACE 1
+#define VI_PROGRESSIVE 2
+
+#define VI_NTSC 0
+#define VI_PAL 1
+#define VI_MPAL 2
+#define VI_DEBUG 3
+#define VI_DEBUG_PAL 4
+#define VI_EURGB60 5
+
+typedef enum {
+ VI_TVMODE_NTSC_INT = VI_TVMODE(VI_NTSC, VI_INTERLACE),
+ VI_TVMODE_NTSC_DS = VI_TVMODE(VI_NTSC, VI_NON_INTERLACE),
+ VI_TVMODE_NTSC_PROG = VI_TVMODE(VI_NTSC, VI_PROGRESSIVE),
+ VI_TVMODE_PAL_INT = VI_TVMODE(VI_PAL, VI_INTERLACE),
+ VI_TVMODE_PAL_DS = VI_TVMODE(VI_PAL, VI_NON_INTERLACE),
+ VI_TVMODE_EURGB60_INT = VI_TVMODE(VI_EURGB60, VI_INTERLACE),
+ VI_TVMODE_EURGB60_DS = VI_TVMODE(VI_EURGB60, VI_NON_INTERLACE),
+ VI_TVMODE_MPAL_INT = VI_TVMODE(VI_MPAL, VI_INTERLACE),
+ VI_TVMODE_MPAL_DS = VI_TVMODE(VI_MPAL, VI_NON_INTERLACE),
+ VI_TVMODE_DEBUG_INT = VI_TVMODE(VI_DEBUG, VI_INTERLACE),
+ VI_TVMODE_DEBUG_PAL_INT = VI_TVMODE(VI_DEBUG_PAL, VI_INTERLACE),
+ VI_TVMODE_DEBUG_PAL_DS = VI_TVMODE(VI_DEBUG_PAL, VI_NON_INTERLACE)
+} VITVMode;
+
+typedef enum {
+ VI_XFBMODE_SF = 0,
+ VI_XFBMODE_DF
+} VIXFBMode;
+
+typedef void (*VIRetraceCallback)(u32 retraceCount);
+
+#endif