From eace114d30a9a09eb6b2fcfec19d9987f85339d1 Mon Sep 17 00:00:00 2001 From: koopthekoopa Date: Thu, 9 Jan 2025 22:52:03 +0000 Subject: [PATCH] Decompile and Link Gui Manager --- config/43E/symbols.txt | 9 +- config/43J/symbols.txt | 7 +- config/43K/symbols.txt | 7 +- config/43U/symbols.txt | 13 +- configure.py | 7 +- include/layout/GUIManager.h | 252 +++++ include/layout/iplGuiManager.h | 35 + include/layout/iplLayout.h | 31 +- include/math/iplMathTypes.h | 13 +- include/scene/iplSceneBase.h | 4 +- include/scene/iplSceneManager.h | 4 - include/system/iplChannelManager.h | 4 +- include/system/iplChannelRsoThread.h | 4 +- include/system/iplController.h | 32 +- include/system/iplDialogWindow.h | 120 ++- include/system/iplFramework.h | 6 +- include/system/iplHomeButton.h | 2 +- include/system/iplMessageManager.h | 2 +- include/system/iplNand.h | 14 +- include/system/iplNigaoe.h | 20 +- include/system/iplNigaoeManager.h | 2 - include/system/iplPointer.h | 2 +- include/system/iplPostmanManager.h | 2 +- include/system/iplResetHandler.h | 6 +- include/system/iplSystem.h | 7 +- libs/EGG/include/egg/core/eggAllocator.h | 3 + libs/MSL/include/new | 15 + libs/NW4R/include/nw4r/lyt.h | 3 + libs/NW4R/include/nw4r/lyt/animation.h | 4 +- .../include/nw4r/lyt/arcResourceAccessor.h | 5 +- libs/NW4R/include/nw4r/lyt/bounding.h | 17 + libs/NW4R/include/nw4r/lyt/layout.h | 2 +- libs/NW4R/include/nw4r/lyt/pane.h | 34 +- libs/NW4R/include/nw4r/lyt/picture.h | 17 + libs/NW4R/include/nw4r/lyt/textBox.h | 5 +- libs/NW4R/include/nw4r/lyt/window.h | 17 + libs/NW4R/include/nw4r/math/types.h | 31 +- libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h | 39 +- libs/NW4R/include/nw4r/ut/inlines.h | 2 - .../include/revolution/base/PPCWGPipe.h | 27 + libs/RVL_SDK/include/revolution/gx.h | 7 +- libs/RVL_SDK/include/revolution/gx/GXCull.h | 2 +- libs/RVL_SDK/include/revolution/gx/GXEnum.h | 899 +++++++++++++++--- libs/RVL_SDK/include/revolution/gx/GXFifo.h | 94 ++ .../include/revolution/gx/GXGeometry.h | 29 + libs/RVL_SDK/include/revolution/gx/GXLight.h | 18 + libs/RVL_SDK/include/revolution/gx/GXPixel.h | 2 + libs/RVL_SDK/include/revolution/gx/GXStruct.h | 8 +- libs/RVL_SDK/include/revolution/gx/GXTev.h | 21 + .../include/revolution/gx/GXTransform.h | 19 + libs/RVL_SDK/include/revolution/kpad.h | 14 +- .../include/revolution/mem/allocator.h | 11 +- libs/RVL_SDK/include/revolution/mtx.h | 16 +- .../RVL_SDK/include/revolution/mtx/GeoTypes.h | 17 +- src/homebutton/HBMFrameController.cpp | 2 +- src/layout/GUIManager.cpp | 341 +++++++ src/layout/iplGuiManager.cpp | 69 ++ src/layout/iplLayout.cpp | 4 +- src/scene/health/iplHealth.cpp | 8 +- src/system/iplDialogWindow.cpp | 529 +++++++++++ src/system/iplErrorHandler.cpp | 2 +- src/system/iplNigaoe.cpp | 8 +- src/system/iplNigaoeManager.cpp | 27 +- src/system/iplPointer.cpp | 6 +- src/system/iplPointerCore.cpp | 6 +- src/system/iplWarningHandler.cpp | 5 +- src/utility/iplFrameController.cpp | 2 +- 67 files changed, 2675 insertions(+), 317 deletions(-) create mode 100644 include/layout/GUIManager.h create mode 100644 include/layout/iplGuiManager.h create mode 100644 libs/MSL/include/new create mode 100644 libs/NW4R/include/nw4r/lyt/bounding.h create mode 100644 libs/NW4R/include/nw4r/lyt/picture.h create mode 100644 libs/NW4R/include/nw4r/lyt/window.h create mode 100644 libs/RVL_SDK/include/revolution/base/PPCWGPipe.h create mode 100644 libs/RVL_SDK/include/revolution/gx/GXFifo.h create mode 100644 libs/RVL_SDK/include/revolution/gx/GXGeometry.h create mode 100644 libs/RVL_SDK/include/revolution/gx/GXLight.h create mode 100644 libs/RVL_SDK/include/revolution/gx/GXTev.h create mode 100644 libs/RVL_SDK/include/revolution/gx/GXTransform.h create mode 100644 src/layout/GUIManager.cpp create mode 100644 src/layout/iplGuiManager.cpp create mode 100644 src/system/iplDialogWindow.cpp diff --git a/config/43E/symbols.txt b/config/43E/symbols.txt index 1166cc9b..c2573807 100644 --- a/config/43E/symbols.txt +++ b/config/43E/symbols.txt @@ -1615,7 +1615,7 @@ stt_select__Q23ipl12DialogWindowFv = .text:0x813455D8; // type:function size:0xF stt_fadeout__Q23ipl12DialogWindowFv = .text:0x813456CC; // type:function size:0x94 setEventHandler__Q23gui7ManagerFPQ23gui12EventHandler = .text:0x81345760; // type:function size:0x2C iplDialogWindow_81345718 = .text:0x8134578C; // type:function size:0x60 scope:local -iplDialogWindow_81345778 = .text:0x813457EC; // type:function size:0x108 scope:local +iplDialogWindow_81345778__Q23ipl12DialogWindowFv = .text:0x813457EC; // type:function size:0x108 scope:local iplDialogWindow_81345880 = .text:0x813458F4; // type:function size:0x5E4 scope:local DynamicCast__Q24nw4r2utFPQ34nw4r3lyt4Pane_PQ34nw4r3lyt7TextBox = .text:0x81345ED8; // type:function size:0x7C GetRuntimeTypeInfo__Q34nw4r3lyt4PaneCFv = .text:0x81345F54; // type:function size:0x8 @@ -2315,7 +2315,7 @@ ReadFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x8136851 WriteFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81368608; // type:function size:0xF0 UpdateFlagsFile__Q33ipl7utility7CSFlagsFv = .text:0x813686F8; // type:function size:0xB8 SetEULAFlag__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x813687B0; // type:function size:0x50 -GuiMgr_81368758 = .text:0x81368800; // type:function size:0x1C0 scope:local +drawLine___FfffffUcR8_GXColor = .text:0x81368800; // type:function size:0x1C0 scope:local update__Q23gui9ComponentFiffUlUlUlPv = .text:0x813689C0; // type:function size:0x2C0 isVisible__Q23gui9ComponentFv = .text:0x81368C80; // type:function size:0x8 isPointed__Q23gui9ComponentFi = .text:0x81368C88; // type:function size:0xC @@ -2352,8 +2352,7 @@ getPaneComponentByPane__Q23gui11PaneManagerFPQ34nw4r3lyt4Pane = .text:0x81369728 setAllBoundingBoxComponentTriggerTarget__Q23gui11PaneManagerFb = .text:0x81369798; // type:function size:0xAC contain__Q23gui13PaneComponentFff = .text:0x81369844; // type:function size:0x128 draw__Q23gui13PaneComponentFv = .text:0x8136996C; // type:function size:0x18C -GuiMgr_81369A50 = .text:0x81369AF8; // type:function size:0x2C scope:local -GuiMgr_81369A7C = .text:0x81369B24; // type:function size:0x4 scope:local +is_visible__FPQ34nw4r3lyt4Pane = .text:0x81369AF8; // type:function size:0x30 scope:local isVisible__Q23gui13PaneComponentFv = .text:0x81369B28; // type:function size:0x8 setFlightDuration__Q23gui9ComponentFiUs = .text:0x81369B30; // type:function size:0x10 getFlightDuration__Q23gui9ComponentFi = .text:0x81369B40; // type:function size:0x10 @@ -14427,7 +14426,7 @@ lbl_816426A0 = .data:0x816426A0; // type:object size:0x330 __vt__Q23gui13PaneComponent = .data:0x816429D0; // type:object size:0x74 __vt__Q23gui11PaneManager = .data:0x81642A44; // type:object size:0x5C __vt__Q23gui7Manager = .data:0x81642AA0; // type:object size:0x44 -__vt__Q23gui9Component = .data:0x81642AE4; // type:object size:0x68 +__vt__Q23gui9Component = .data:0x81642AE4; // type:object size:0x6C lbl_81642B50 = .data:0x81642B50; // type:object size:0x64 __vt__Q33ipl6layout6Object = .data:0x81642BB4; // type:object size:0xC __vt__Q33ipl6layout13GroupAnimator = .data:0x81642BC0; // type:object size:0x18 diff --git a/config/43J/symbols.txt b/config/43J/symbols.txt index 267d7bd4..cda324a4 100644 --- a/config/43J/symbols.txt +++ b/config/43J/symbols.txt @@ -2088,7 +2088,7 @@ ReadFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x8136791 WriteFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81367A14; // type:function size:0xF0 UpdateFlagsFile__Q33ipl7utility7CSFlagsFv = .text:0x81367B04; // type:function size:0xB8 SetEULAFlag__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81367BBC; // type:function size:0x50 -GuiMgr_81368758 = .text:0x81367C0C; // type:function size:0x1C0 scope:local +drawLine___FfffffUcR8_GXColor = .text:0x81367C0C; // type:function size:0x1C0 scope:local update__Q23gui9ComponentFiffUlUlUlPv = .text:0x81367DCC; // type:function size:0x2C0 isVisible__Q23gui9ComponentFv = .text:0x8136808C; // type:function size:0x8 isPointed__Q23gui9ComponentFi = .text:0x81368094; // type:function size:0xC @@ -2125,8 +2125,7 @@ getPaneComponentByPane__Q23gui11PaneManagerFPQ34nw4r3lyt4Pane = .text:0x81368B34 setAllBoundingBoxComponentTriggerTarget__Q23gui11PaneManagerFb = .text:0x81368BA4; // type:function size:0xAC contain__Q23gui13PaneComponentFff = .text:0x81368C50; // type:function size:0x128 draw__Q23gui13PaneComponentFv = .text:0x81368D78; // type:function size:0x18C -GuiMgr_81369A50 = .text:0x81368F04; // type:function size:0x2C scope:local -GuiMgr_81369A7C = .text:0x81368F30; // type:function size:0x4 scope:local +is_visible__FPQ34nw4r3lyt4Pane = .text:0x81368F04; // type:function size:0x30 scope:local isVisible__Q23gui13PaneComponentFv = .text:0x81368F34; // type:function size:0x8 setFlightDuration__Q23gui9ComponentFiUs = .text:0x81368F3C; // type:function size:0x10 getFlightDuration__Q23gui9ComponentFi = .text:0x81368F4C; // type:function size:0x10 @@ -14515,7 +14514,7 @@ lbl_81672CC0 = .data:0x81672CC0; // type:object size:0x330 __vt__Q23gui13PaneComponent = .data:0x81672FF0; // type:object size:0x74 __vt__Q23gui11PaneManager = .data:0x81673064; // type:object size:0x5C __vt__Q23gui7Manager = .data:0x816730C0; // type:object size:0x44 -__vt__Q23gui9Component = .data:0x81673104; // type:object size:0x68 +__vt__Q23gui9Component = .data:0x81673104; // type:object size:0x6C lbl_81673170 = .data:0x81673170; // type:object size:0x64 __vt__Q33ipl6layout6Object = .data:0x816731D4; // type:object size:0xC __vt__Q33ipl6layout13GroupAnimator = .data:0x816731E0; // type:object size:0x18 diff --git a/config/43K/symbols.txt b/config/43K/symbols.txt index 6bca0933..feefad12 100644 --- a/config/43K/symbols.txt +++ b/config/43K/symbols.txt @@ -2071,7 +2071,7 @@ ReadFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x813677F WriteFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x813678F4; // type:function size:0xF0 UpdateFlagsFile__Q33ipl7utility7CSFlagsFv = .text:0x813679E4; // type:function size:0xB8 SetEULAFlag__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81367A9C; // type:function size:0x50 -GuiMgr_81368758 = .text:0x81367AEC; // type:function size:0x1C0 scope:local +drawLine___FfffffUcR8_GXColor = .text:0x81367AEC; // type:function size:0x1C0 scope:local update__Q23gui9ComponentFiffUlUlUlPv = .text:0x81367CAC; // type:function size:0x2C0 isVisible__Q23gui9ComponentFv = .text:0x81367F6C; // type:function size:0x8 isPointed__Q23gui9ComponentFi = .text:0x81367F74; // type:function size:0xC @@ -2108,8 +2108,7 @@ getPaneComponentByPane__Q23gui11PaneManagerFPQ34nw4r3lyt4Pane = .text:0x81368A14 setAllBoundingBoxComponentTriggerTarget__Q23gui11PaneManagerFb = .text:0x81368A84; // type:function size:0xAC contain__Q23gui13PaneComponentFff = .text:0x81368B30; // type:function size:0x128 draw__Q23gui13PaneComponentFv = .text:0x81368C58; // type:function size:0x18C -GuiMgr_81369A50 = .text:0x81368DE4; // type:function size:0x2C scope:local -GuiMgr_81369A7C = .text:0x81368E10; // type:function size:0x4 scope:local +is_visible__FPQ34nw4r3lyt4Pane = .text:0x81368DE4; // type:function size:0x30 scope:local isVisible__Q23gui13PaneComponentFv = .text:0x81368E14; // type:function size:0x8 setFlightDuration__Q23gui9ComponentFiUs = .text:0x81368E1C; // type:function size:0x10 getFlightDuration__Q23gui9ComponentFi = .text:0x81368E2C; // type:function size:0x10 @@ -14007,7 +14006,7 @@ lbl_81617298 = .data:0x81617298; // type:object size:0x330 __vt__Q23gui13PaneComponent = .data:0x816175C8; // type:object size:0x74 __vt__Q23gui11PaneManager = .data:0x8161763C; // type:object size:0x5C __vt__Q23gui7Manager = .data:0x81617698; // type:object size:0x44 -__vt__Q23gui9Component = .data:0x816176DC; // type:object size:0x68 +__vt__Q23gui9Component = .data:0x816176DC; // type:object size:0x6C lbl_81617748 = .data:0x81617748; // type:object size:0x64 __vt__Q33ipl6layout6Object = .data:0x816177AC; // type:object size:0xC __vt__Q33ipl6layout13GroupAnimator = .data:0x816177B8; // type:object size:0x18 diff --git a/config/43U/symbols.txt b/config/43U/symbols.txt index 5e1c9ec7..8a25a5f1 100644 --- a/config/43U/symbols.txt +++ b/config/43U/symbols.txt @@ -1615,9 +1615,9 @@ stt_normal__Q23ipl12DialogWindowFv = .text:0x81345364; // type:function size:0x2 stt_select__Q23ipl12DialogWindowFv = .text:0x81345564; // type:function size:0xF4 stt_fadeout__Q23ipl12DialogWindowFv = .text:0x81345658; // type:function size:0x94 setEventHandler__Q23gui7ManagerFPQ23gui12EventHandler = .text:0x813456EC; // type:function size:0x2C -iplDialogWindow_81345718 = .text:0x81345718; // type:function size:0x60 scope:local -iplDialogWindow_81345778 = .text:0x81345778; // type:function size:0x108 scope:local -iplDialogWindow_81345880 = .text:0x81345880; // type:function size:0x5E4 scope:local +set_alpha__Q23ipl12DialogWindowFPQ34nw4r3lyt4PaneUc = .text:0x81345718; // type:function size:0x60 scope:local +iplDialogWindow_81345778__Q23ipl12DialogWindowFv = .text:0x81345778; // type:function size:0x108 scope:local +iplDialogWindow_81345880__Q23ipl12DialogWindowFv = .text:0x81345880; // type:function size:0x5E4 scope:local DynamicCast__Q24nw4r2utFPQ34nw4r3lyt4Pane_PQ34nw4r3lyt7TextBox = .text:0x81345E64; // type:function size:0x7C GetRuntimeTypeInfo__Q34nw4r3lyt4PaneCFv = .text:0x81345EE0; // type:function size:0x8 draw__Q23ipl12DialogWindowFv = .text:0x81345EE8; // type:function size:0x108 @@ -2316,7 +2316,7 @@ ReadFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x8136846 WriteFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81368560; // type:function size:0xF0 UpdateFlagsFile__Q33ipl7utility7CSFlagsFv = .text:0x81368650; // type:function size:0xB8 SetEULAFlag__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81368708; // type:function size:0x50 -GuiMgr_81368758 = .text:0x81368758; // type:function size:0x1C0 scope:local +drawLine___FfffffUcR8_GXColor = .text:0x81368758; // type:function size:0x1C0 scope:local update__Q23gui9ComponentFiffUlUlUlPv = .text:0x81368918; // type:function size:0x2C0 isVisible__Q23gui9ComponentFv = .text:0x81368BD8; // type:function size:0x8 isPointed__Q23gui9ComponentFi = .text:0x81368BE0; // type:function size:0xC @@ -2353,8 +2353,7 @@ getPaneComponentByPane__Q23gui11PaneManagerFPQ34nw4r3lyt4Pane = .text:0x81369680 setAllBoundingBoxComponentTriggerTarget__Q23gui11PaneManagerFb = .text:0x813696F0; // type:function size:0xAC contain__Q23gui13PaneComponentFff = .text:0x8136979C; // type:function size:0x128 draw__Q23gui13PaneComponentFv = .text:0x813698C4; // type:function size:0x18C -GuiMgr_81369A50 = .text:0x81369A50; // type:function size:0x2C scope:local -GuiMgr_81369A7C = .text:0x81369A7C; // type:function size:0x4 scope:local +is_visible__FPQ34nw4r3lyt4Pane = .text:0x81369A50; // type:function size:0x30 scope:local isVisible__Q23gui13PaneComponentFv = .text:0x81369A80; // type:function size:0x8 setFlightDuration__Q23gui9ComponentFiUs = .text:0x81369A88; // type:function size:0x10 getFlightDuration__Q23gui9ComponentFi = .text:0x81369A98; // type:function size:0x10 @@ -14429,7 +14428,7 @@ lbl_816423E0 = .data:0x816423E0; // type:object size:0x32D __vt__Q23gui13PaneComponent = .data:0x81642710; // type:object size:0x74 __vt__Q23gui11PaneManager = .data:0x81642784; // type:object size:0x5C __vt__Q23gui7Manager = .data:0x816427E0; // type:object size:0x44 -__vt__Q23gui9Component = .data:0x81642824; // type:object size:0x68 +__vt__Q23gui9Component = .data:0x81642824; // type:object size:0x6C lbl_81642890 = .data:0x81642890; // type:object size:0x64 __vt__Q33ipl6layout6Object = .data:0x816428F4; // type:object size:0xC __vt__Q33ipl6layout13GroupAnimator = .data:0x81642900; // type:object size:0x18 diff --git a/configure.py b/configure.py index 639008b6..8716a674 100644 --- a/configure.py +++ b/configure.py @@ -263,6 +263,7 @@ else: cflags_ipl = [ *cflags_base, "-gccinc", + "-fp_contract off", "-Cpp_exceptions off", "-O4,s", ] @@ -431,7 +432,7 @@ config.libs = [ Object(Matching, "system/iplNandMeta.cpp"), Object(NonMatching, "system/iplNandManager.cpp"), Object(Matching, "system/iplNandWall.cpp"), - Object(NonMatching, "system/iplFramework.cpp"), + Object(Matching, "system/iplFramework.cpp"), Object(NonMatching, "system/iplException.cpp"), Object(Matching, "system/iplMessage.cpp"), Object(Matching, "system/iplMessageManager.cpp"), @@ -482,9 +483,9 @@ config.libs = [ ), IPLSection("layout", [ - Object(NonMatching, "layout/GUIManager.cpp"), + Object(Matching, "layout/GUIManager.cpp"), Object(Matching, "layout/iplLayout.cpp"), - Object(NonMatching, "layout/iplGuiManager.cpp"), + Object(Matching, "layout/iplGuiManager.cpp"), ] ), IPLSection("sound", diff --git a/include/layout/GUIManager.h b/include/layout/GUIManager.h new file mode 100644 index 00000000..c0f557c8 --- /dev/null +++ b/include/layout/GUIManager.h @@ -0,0 +1,252 @@ +#ifndef GUI_MANAGER_H +#define GUI_MANAGER_H + +#include + +#include +#include +#include + +#include +#include + +namespace gui { + #define GUI_POINTS_MAX 8 + + class Interface; + class Component; + class Manager; + class EventHandler; + + class Interface { + public: + virtual void create(); // 0x08 (0x02) + + virtual void init(); // 0x0C (0x03) + virtual void calc(); // 0x10 (0x04) + + virtual void draw(Mtx& mtx); // 0x14 (0x05) + virtual void draw(); // 0x18 (0x06) + + virtual ~Interface() {} // 0x1C (0x07) + }; + + class EventHandler { + public: + enum { + ON_TRIG = 0, + ON_POINT, + ON_OFFPOINT, + ON_MOVE, + ON_HOLD, + ON_RELEASE, + }; + + EventHandler() : + mLatestCtrlNum(0) {} + + virtual void onEvent(u32 compId, u32 event, void* data) {} // 0x08 (0x02) + + virtual void setManager(Manager* manager) { mpManager = manager; } // 0x0C (0x03) + + virtual void setLatestEventCtrlNo(int ctrlNo) { mLatestCtrlNum = ctrlNo; } // 0x10 (0x04) + virtual int getLatestEventCtrl() { return mLatestCtrlNum; } // 0x14 (0x05) + + protected: + Manager* mpManager; // 0x04 + int mLatestCtrlNum; // 0x08 + }; + + class Component : public Interface { + public: + virtual void init() { // 0x0C (0x03) + for (int i = 0; i < GUI_POINTS_MAX; i++) { + mbPointed[i] = false; + mDraggingPos[i].z = mDraggingPos[i].y = mDraggingPos[i].x = 0; + mbDragging[i] = false; + mFlightDuration[i] = 0; + } + } + + Component(u32 id) : + mDraggingButton(0xFFFF), + mID(id), + mbTriggerTarget(false), + mpManager(NULL) { + init(); + } + virtual ~Component(); // 0x1C (0x07) + + virtual u32 getID() { return mID; } // 0x20 (0x08) + + virtual bool isPointed(int point) { return mbPointed[point]; } // 0x24 (0x09) + virtual bool isDragging(int point) { return mbDragging[point]; } // 0x28 (0x0A) + + virtual void setPointed(int point, bool bEnable) { mbPointed[point] = bEnable; } // 0x2C (0x0B) + + virtual void onPoint(int point) { mFlightDuration[point] = 0; } // 0x30 (0x0C) + virtual void offPoint(int point) { mFlightDuration[point] = 0; } // 0x34 (0x0D) + + virtual void onDrag(f32 x, f32 y) {} // 0x38 (0x0E) + virtual void onMove(int point, f32 x, f32 y) { mFlightDuration[point]++; } // 0x3C (0x0F) + virtual void onTrig(int point, u32 trig, Vec& dragPos) { // 0x40 (0x10) + if (trig & mDraggingButton) { + mDraggingPos[point] = dragPos; + mbDragging[point] = true; + mFlightDuration[point] = 0; + } + } + + virtual void setDraggingButton(u32 dragBtn) {mDraggingButton = dragBtn; } // 0x44 (0x11) + + virtual bool update(int point, const KPADStatus* kpad, f32, f32, void* data) { return false; } // 0x48 (0x12) + virtual bool update(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0x4C (0x13) + + virtual bool isTriggerTarger() { return mbTriggerTarget; } // 0x50 (0x14) "targer" + virtual void setTriggerTarget(bool bEnable) { mbTriggerTarget = bEnable; } // 0x54 (0x15) + + virtual void setManager(Manager* manager) { mpManager = manager; } // 0x58 (0x16) + + virtual bool isVisible() { return true; } // 0x58 (0x17) + + virtual u16 getFlightDuration(int point) { return mFlightDuration[point]; } // 0x60 (0x18) + virtual void setFlightDuration(int point, u16 flightDir) { mFlightDuration[point] = flightDir; } // 0x64 (0x19) + + virtual bool contain(f32 x, f32 y) = 0; // 0x68 (0x1A) + + protected: + bool mbPointed[GUI_POINTS_MAX]; // 0x04 + + bool mbDragging[GUI_POINTS_MAX]; // 0x0C + Vec mDraggingPos[GUI_POINTS_MAX]; // 0x14 + int mDraggingButton; // 0x74 + + int mID; // 0x78 + + bool mbTriggerTarget; // 0x7C + + Manager* mpManager; // 0x80 + + u16 mFlightDuration[GUI_POINTS_MAX]; // 0x84 + }; + + class Manager : public Interface { + public: + virtual void init(); // 0x0C (0x03) + virtual void calc(); // 0x10 (0x04) + + virtual void draw(); // 0x18 (0x06) + + Manager(EventHandler* event, MEMAllocator* allocator) : + mpEventHandler(event), + mpAllocator(allocator) { + if (mpEventHandler != NULL) { + mpEventHandler->setManager(this); + } + nw4r::ut::List_Init(&mComponents, offsetof(ComponentID, mLink)); + } + + virtual ~Manager(); // 0x1C (0x07) + + virtual void addComponent(Component* component); // 0x20 (0x08) + virtual Component* getComponent(u32 id); // 0x24 (0x09) + + virtual bool update(int point, const KPADStatus* kpad, f32, f32, void* data); // 0x28 (0x0A) + virtual bool update(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0x2C (0x0B) + + virtual void onEvent(u32 compId, u32 event, int point, void* data); // 0x30 (0x0C) + + virtual void setAllComponentTriggerTarget(bool bEnable); // 0x34 (0x0D) + + virtual void setEventHandler(EventHandler* eventHandler) { // 0x38 (0x0E) + mpEventHandler = eventHandler; + if (eventHandler) { + eventHandler->setManager(this); + } + } + virtual void changeEventHandler(EventHandler* event); // 0x3C (0x0F) + + virtual void setDraggingButton(u32 dragBtn); // 0x40 (0x10) + + protected: + class ComponentID { + public: + ComponentID(u32 id, Component* component) : + mID(id), + mpComponent(component) {} + + u32 mID; // 0x00 + Component* mpComponent; // 0x04 + + nw4r::ut::Link mLink; // 0x08 + }; + + EventHandler* mpEventHandler; // 0x04 + nw4r::ut::List mComponents; // 0x08 + MEMAllocator* mpAllocator; // 0x14 + }; + + class PaneComponent; + class PaneManager : public Manager { + public: + PaneManager(EventHandler* event, MEMAllocator* allocator, const nw4r::lyt::DrawInfo* drawInfo) : + Manager(event, allocator), + mpDrawInfo(drawInfo) { + nw4r::ut::List_Init(&mPaneComponents, offsetof(PaneComponentID, mLink)); + } + + virtual ~PaneManager(); // 0x1C (0x07) + + virtual void createLayoutScene(const nw4r::lyt::Layout& layout); // 0x44 (0x11) + + virtual PaneComponent* getPaneComponentByPane(nw4r::lyt::Pane* pane); // 0x48 (0x12) + + virtual const nw4r::lyt::DrawInfo* getDrawInfo() { return mpDrawInfo; } // 0x4C (0x13) + virtual void setDrawInfo(const nw4r::lyt::DrawInfo* drawInfo) { mpDrawInfo = drawInfo; } // 0x50 (0x14) + + virtual void setAllBoundingBoxComponentTriggerTarget(bool bEnable); // 0x54 (0x15) + virtual void walkInChildren(nw4r::lyt::PaneList& paneList); // 0x58 (0x16) + + protected: + class PaneComponentID { + public: + PaneComponentID(nw4r::lyt::Pane* pane, PaneComponent* component) : + mpPane(pane), + mpComponent(component) {} + + nw4r::lyt::Pane* mpPane; // 0x00 + PaneComponent* mpComponent; // 0x04 + + nw4r::ut::Link mLink; // 0x08 + }; + + nw4r::ut::List mPaneComponents; // 0x18 + + const nw4r::lyt::DrawInfo* mpDrawInfo; // 0x24 + + static u32 suIDCounter; + }; + + class PaneComponent : public Component { + public: + PaneComponent(u32 id) : Component(id) { + mpPane = NULL; + } + + virtual void draw(); // 0x18 (0x06) + + virtual ~PaneComponent() {} // 0x1C (0x07) + + virtual bool isVisible(); // 0x58 (0x17) + + virtual bool contain(f32 x, f32 y); // 0x68 (0x1A) + + virtual void setPane(nw4r::lyt::Pane* pane) { mpPane = pane; } // 0x6C (0x1B) + virtual nw4r::lyt::Pane* getPane() { return mpPane; } // 0x70 (0x1C) + + private: + nw4r::lyt::Pane* mpPane; // 0x88 + }; +} + +#endif // GUI_MANAGER_H diff --git a/include/layout/iplGuiManager.h b/include/layout/iplGuiManager.h new file mode 100644 index 00000000..971f0046 --- /dev/null +++ b/include/layout/iplGuiManager.h @@ -0,0 +1,35 @@ +#ifndef IPL_GUI_MANAGER_H +#define IPL_GUI_MANAGER_H + +#include "layout/GUIManager.h" + +#include + +namespace ipl { + namespace gui { + class PaneManager : public ::gui::PaneManager { + public: + PaneManager(::gui::EventHandler* event, const nw4r::lyt::DrawInfo* drawInfo, EGG::Heap* heap, EGG::Allocator* allocator, bool bDisableCon = false) : + ::gui::PaneManager(event, allocator, drawInfo), + mpHeap(heap), + mbDisableCon(bDisableCon) {} + + virtual ~PaneManager() {} + + void update(); + void update(int chan); + + void setTriggerTarget(nw4r::lyt::Pane* pane, bool bEnable); + void initPane(nw4r::lyt::Pane* pane); + + private: + u32 unk_0x28; + EGG::Heap* mpHeap; + + bool mbDisableCon; // 0x30 + bool mbDoneUpdateWithCon; // 0x31 + }; + } +} + +#endif // IPL_GUI_MANAGER_H diff --git a/include/layout/iplLayout.h b/include/layout/iplLayout.h index 0963b7ab..6da961d5 100644 --- a/include/layout/iplLayout.h +++ b/include/layout/iplLayout.h @@ -9,6 +9,7 @@ #include #include "nw4r/lyt/drawInfo.h" +#include "nw4r/ut/list.h" #include "revolution/types.h" #include "system/iplNand.h" @@ -31,12 +32,13 @@ namespace ipl { void initAnmFrame(float frame); protected: - nw4r::lyt::AnimTransform* mAnimTrans; // 0x20 + nw4r::lyt::AnimTransform* mAnimTrans; // 0x20 - u32 unused_0x24; - u32 unused_0x28; + nw4r::ut::Link mLink; // 0x24 - u32 mFlags; + u32 mFlags; // 0x2C + + friend class Object; }; class PaneAnimator : public Animator { @@ -112,9 +114,24 @@ namespace ipl { static Object* create(EGG::Heap* heap, u32 unk0, void* buffer, const char* directory, const char* fileName); /** @brief Gets the layout object. */ - nw4r::lyt::Layout* getLayout() { return &mLayout; } - /** @brief Gets the root of the layout. */ - nw4r::lyt::Pane* getRoot() { return getLayout()->GetRootPane(); } + nw4r::lyt::Layout* getLayout() { return &mLayout; } + /** @brief Gets the layout object. */ + nw4r::lyt::DrawInfo* getDrawInfo() { return &mDrawInfo; } + /** @brief Gets the root pane of the layout. */ + nw4r::lyt::Pane* getRoot() { return getLayout()->GetRootPane(); } + nw4r::lyt::Pane* findPane(const char *findName) { return getRoot()->FindPaneByName(findName); } + Animator* getAnim(u16 idx) { return (Animator*)nw4r::ut::List_GetNth(&mAnims, idx); } + + void playAnimFrame(Animator* anim) { + anim->initFrame(); + anim->setState(ANIM_STATE_PLAY); + } + void playAnimFrame(u16 idx) { + playAnimFrame(getAnim(idx)); + } + void playAnimFrame(int idx) { + playAnimFrame((u16)idx); + } private: void init_(const char* fileName); diff --git a/include/math/iplMathTypes.h b/include/math/iplMathTypes.h index eafd3e53..04421615 100644 --- a/include/math/iplMathTypes.h +++ b/include/math/iplMathTypes.h @@ -5,10 +5,19 @@ #include +#define IPL_MATH_CLAMP(x, min, max) x < min ? min : (x > max ? max : x) + +typedef union FU32 { + u32 u32; + f32 f32; +} FU32; +// HACK +#define IPL_MATH_INFINITY 0x1.FFFFFFP127f +#define IPL_MATH_NINFINITY -0x1.FFFFFFP127f +#define IPL_MATH_NULL_FLOAT IPL_MATH_INFINITY + namespace ipl { namespace math { - #define IPL_MATH_CLAMP(x, min, max) x < min ? min : (x > max ? max : x) - template inline T abs(const T& x) { return nw4r::math::FAbs(x); } diff --git a/include/scene/iplSceneBase.h b/include/scene/iplSceneBase.h index f926e6cb..dafbfedd 100644 --- a/include/scene/iplSceneBase.h +++ b/include/scene/iplSceneBase.h @@ -91,6 +91,6 @@ namespace ipl { } } +#include "system/iplSystem.h" + #endif // BASE_SCENE_H - - diff --git a/include/scene/iplSceneManager.h b/include/scene/iplSceneManager.h index 251044f0..7bda9c1f 100644 --- a/include/scene/iplSceneManager.h +++ b/include/scene/iplSceneManager.h @@ -54,8 +54,4 @@ namespace ipl { } } -#include "system/iplSystem.h" - #endif // IPL_SCENE_MANAGER_H - - diff --git a/include/system/iplChannelManager.h b/include/system/iplChannelManager.h index 2a2eef09..b4044288 100644 --- a/include/system/iplChannelManager.h +++ b/include/system/iplChannelManager.h @@ -5,8 +5,8 @@ namespace ipl { typedef struct { - u32 unk0; // 0x00 - u32 unk1; // 0x04 + u32 unk0; // 0x00 (x slot?) + u32 unk1; // 0x04 (y slot) ESTitleId titleId; // 0x08 } ChanEntry; } diff --git a/include/system/iplChannelRsoThread.h b/include/system/iplChannelRsoThread.h index 274466f3..951e6c8d 100644 --- a/include/system/iplChannelRsoThread.h +++ b/include/system/iplChannelRsoThread.h @@ -21,7 +21,7 @@ namespace ipl { /** @param func The new loop function. */ void setCalcFunc(CalcFunc func); - OSMessageQueue* getCalcQueue() { return &mCalcQueue; } + OSMessageQueue* getCalcQueue() { return &mCalcQueue; } private: u8* mpStack; // 0x32C @@ -36,5 +36,3 @@ namespace ipl { } #endif // IPL_CHANNEL_RSO_THREAD_H - - diff --git a/include/system/iplController.h b/include/system/iplController.h index 11ed01a0..689dee3b 100644 --- a/include/system/iplController.h +++ b/include/system/iplController.h @@ -26,21 +26,21 @@ namespace ipl { virtual int getChannel() const; // 0x10 virtual int down(u32 button) const; // 0x14 virtual int downTrg(u32 button) const; // 0x18 - virtual int unk_0x1C(); - virtual int unk_0x20(); - virtual int unk_0x24(); - virtual int unk_0x28(); - virtual int unk_0x2C(); - virtual int unk_0x30(); - virtual int unk_0x34(); - virtual int unk_0x38(); - virtual int unk_0x3C(); - virtual int unk_0x40(); - virtual int unk_0x44(); - virtual int unk_0x48(); - virtual int unk_0x4C(); - virtual int unk_0x50(); - virtual int unk_0x54(); + virtual int upTrg(u32 button) const; // 0x1C + virtual int pinch() const; // 0x20 + virtual int pinchTrg(); const // 0x24 + virtual int pinchOffTrg() const; // 0x28 + virtual int decide() const; // 0x2C + virtual int repeat(u32 button) const; // 0x30 + virtual int rumble(int timer) const; // 0x34 + virtual void cancelRumbling(); // 0x38 + virtual int getHoldFlag() const; // 0x3C + virtual int getTrigFlag() const; // 0x40 + virtual int getReleaseFlag() const; // 0x44 + virtual int getClassicHoldFlag() const; // 0x48 + virtual int getClassicTrigFlag() const; // 0x4C + virtual int getClassicReleaseFlag() const; // 0x50 + virtual math::VEC2 getDpdPos() const; // 0x54 /** * @brief Gets the IR sensor position of the Wii Remote. * @return The IR sensor X and Y as `ipl::math::VEC2`. @@ -54,7 +54,7 @@ namespace ipl { virtual int unk_0x60(); virtual int unk_0x64(); virtual int unk_0x68(); - virtual int unk_0x6C(); + virtual bool isValidBtn() const; // 0x6C /** * @brief If the Wii Remote is pointing to the IR sensor bar. * @return Whether it is pointing or not. diff --git a/include/system/iplDialogWindow.h b/include/system/iplDialogWindow.h index 823058fb..7bfa2fc5 100644 --- a/include/system/iplDialogWindow.h +++ b/include/system/iplDialogWindow.h @@ -3,19 +3,30 @@ #include -#include +#include "layout/iplLayout.h" +#include "layout/iplGuiManager.h" namespace ipl { - class DialogWindow { + class DialogWindow : public ::gui::EventHandler { public: - /** - * @param heap The work heap used. - */ + enum { + DIALOG_BTN_NONE = -1, + DIALOG_BTN_B = 1, + DIALOG_BTN_A, + DIALOG_BTN3_A, + DIALOG_BTN3_B, + DIALOG_BTN3_C, + }; + + /** @param heap The work heap used. */ DialogWindow(EGG::Heap* heap); + void init(); void calc(); void draw(); + virtual void onEvent(u32 compId, u32 event, void* data); + /** * @brief Create Dialog Window with one button. * @param messageStringID The Message String ID. @@ -23,18 +34,101 @@ namespace ipl { */ void callBtn1(u32 messageStringID, u32 buttonStringID); - /** @brief Check if the Dialog is available. */ - BOOL isActive() { return mpActive; } + int btnLastPressed() const { return mLastPressedBtn; } private: - u8 unk_0x00[0x24]; - - BOOL mpActive; // 0x24 + enum { + DIALOG_TYPE_NONE = -1, + DIALOG_TYPE_PROG, + DIALOG_TYPE_BTN1, + DIALOG_TYPE_BTN2, + DIALOG_TYPE_BTN3, + DIALOG_TYPE_BTN2B, + DIALOG_TYPE_MAX, + }; - u8 unk_0x28[0x73]; + enum { + DIALOG_BTN_TYPE_BTN1 = 0, + DIALOG_BTN_TYPE_BTN2, + DIALOG_BTN_TYPE_BTN3, + DIALOG_BTN_TYPE_MAX, + }; + + BOOL call(int type); + + void set_alpha(nw4r::lyt::Pane* pane, u8 alpha); + + void stt_fadein(); + void stt_normal(); + void stt_select(); + void stt_fadeout(); + + void set_message(u32 id); + void set_rbtn_text(u32 id); + void set_lbtn_text(u32 id); + + void iplDialogWindow_81345778(); + void iplDialogWindow_81345880(); + + class DialogUI { + public: + layout::Object* mpLayout; // 0x00 + gui::PaneManager* mpGui; // 0x04 + }; + + class DialogProp { + public: + u32 mMsgId; // 0x00 + u32 mRBtnMsgId; // 0x04 + u32 mLBtnMsgId; // 0x08 + bool unk_0x0C; + + ipl::layout::Object* mpLayout; // 0x10 + + f32 mLayoutY; // 0x14 + bool unk_0x18; + }; + + int mState; // 0x0C + ipl::nand::LayoutFile* mpLayoutFile; // 0x10 + + int unk_0x14[3]; + int mPressedBtn; // 0x20 + int mLastPressedBtn; // 0x24 + + int mDialogType; // 0x28 + int unk_0x2C; + + u32 unk_0x30; + + u8 unk_0x34; + u8 unk_0x35; + u8 unk_0x36; + u8 unk_0x37; + u8 unk_0x38; + + int unk_0x3C; + int unk_0x40; + int unk_0x44; + int unk_0x48; + int unk_0x4C; + + DialogUI mDialog[DIALOG_TYPE_MAX]; // 0x50 + DialogUI* mpCurDialog; // 0x78 + + layout::Object* unk_0x7C; + nw4r::math::VEC2 unk_0x80; + + DialogProp* mpDialogProp; // 0x88 + + int unk_0x8C; + int unk_0x90; + int unk_0x94; + u8 unk_0x98; + u8 unk_0x99; + + static char* mscBtnName[3]; }; } #endif // IPL_DIALOG_WINDOW_H - - diff --git a/include/system/iplFramework.h b/include/system/iplFramework.h index fdb778c8..72398145 100644 --- a/include/system/iplFramework.h +++ b/include/system/iplFramework.h @@ -21,9 +21,9 @@ namespace ipl { void resetRenderMode(); - GXRenderModeObj* getRenderMode() { return mpRMode; } - BOOL isWidescreen() { return mWideScreen; } - f32 getDelta() { return mDelta; } + GXRenderModeObj* getRenderMode() const { return mpRMode; } + BOOL isWidescreen() const { return mWideScreen; } + f32 getDelta() const { return mDelta; } private: void flip_xfb(); diff --git a/include/system/iplHomeButton.h b/include/system/iplHomeButton.h index 36bdc3a1..1e2023ff 100644 --- a/include/system/iplHomeButton.h +++ b/include/system/iplHomeButton.h @@ -14,7 +14,7 @@ namespace ipl { void disable(); void setUnk_0x05(bool value) { unk_0x05 = value; } - bool isUnk_0x05() { return unk_0x05; } + bool isUnk_0x05() const { return unk_0x05; } private: undefined4 unk_0x00; diff --git a/include/system/iplMessageManager.h b/include/system/iplMessageManager.h index 204347f8..eef91c53 100644 --- a/include/system/iplMessageManager.h +++ b/include/system/iplMessageManager.h @@ -12,7 +12,7 @@ namespace ipl { Manager(EGG::Heap* heap); /** @return The message data in use. */ - Message* getMessage() { return mpMessage; } + Message* getMessage() const { return mpMessage; } private: void initMessage(); diff --git a/include/system/iplNand.h b/include/system/iplNand.h index 8daaf95c..b871f706 100644 --- a/include/system/iplNand.h +++ b/include/system/iplNand.h @@ -51,10 +51,10 @@ namespace ipl { virtual bool checkData(); // 0x18 virtual bool isFatalError(); // 0x1C - u8* getBuffer() { return mpBuffer; } - u32 getLength() { return mpLength; } + u8* getBuffer() const { return mpBuffer; } + u32 getLength() const { return mpLength; } - bool isFullForTask() { return mbIsFullForTask; } + bool isFullForTask() const { return mbIsFullForTask; } protected: virtual BOOL open_(u8 attr); // 0x20 @@ -123,8 +123,8 @@ namespace ipl { virtual bool checkData(); // 0x18 virtual bool isFatalError(); // 0x1C - File* getCmnFile() { return mpCommonFile; } - File* getLangFile() { return mpLangFile; } + File* getCmnFile() const { return mpCommonFile; } + File* getLangFile() const { return mpLangFile; } private: File* mpCommonFile; // 0x04 @@ -154,8 +154,8 @@ namespace ipl { void closeContentsAll(); void sendToken(int token); - int getDescriptor() { return mDescriptor; } - ARCHandle* getArc() { return &mUnkArc; } + int getDescriptor() const { return mDescriptor; } + ARCHandle* getArc() { return &mUnkArc; } private: u8 unk_0x00[0x268]; diff --git a/include/system/iplNigaoe.h b/include/system/iplNigaoe.h index e45176d9..f2d8582e 100644 --- a/include/system/iplNigaoe.h +++ b/include/system/iplNigaoe.h @@ -1,10 +1,13 @@ #ifndef IPL_NIGAOE_H #define IPL_NIGAOE_H +#include "nw4r/ut/list.h" #include #include +#include + #include #include @@ -15,17 +18,17 @@ namespace ipl { public: typedef void (*MakeIconCallback)(Object*, void*); - Object(EGG::Heap* heap, int width, int height, int faceId, MakeIconCallback callback, void* callBackWork); - Object(EGG::Heap* heap, int width, int height, RFLiCharData* faceData, MakeIconCallback callback, void* callBackWork); + Object(EGG::Heap* heap, int width, int height, int faceId, MakeIconCallback callback, void* callbackWork); + Object(EGG::Heap* heap, int width, int height, RFLiCharData* faceData, MakeIconCallback callback, void* callbackWork); ~Object(); private: void init(EGG::Heap* heap, int width, int height); void make_icon(); - BOOL created() { return mbCreated; } - u8* getIconTexture() { return mpIconTex; } - + BOOL created() const { return mbCreated; } + u8* getIconTexture() const { return mpIconTex; } + u8* mpIconTex; // 0x00 u32 mIconSize; // 0x04 @@ -39,11 +42,12 @@ namespace ipl { MakeIconCallback mCallBack; // 0x40 void* mpCallBackWork; // 0x44 - undefined4 unk_0x48; - undefined4 unk_0x4C; + + nw4r::ut::Link mLink; // 0x48 + bool mbCreated; // 0x50 - friend class Manager; + friend class Manager; }; } } diff --git a/include/system/iplNigaoeManager.h b/include/system/iplNigaoeManager.h index aba7fd9b..4a992e75 100644 --- a/include/system/iplNigaoeManager.h +++ b/include/system/iplNigaoeManager.h @@ -36,5 +36,3 @@ namespace ipl { } #endif // IPL_NIGAOE_MANAGER_H - - diff --git a/include/system/iplPointer.h b/include/system/iplPointer.h index 75ee9421..2823815c 100644 --- a/include/system/iplPointer.h +++ b/include/system/iplPointer.h @@ -47,7 +47,7 @@ namespace ipl { void changeType(int newLayoutType) { mLayoutType = newLayoutType; } void setChan(int newChan) { mChan = newChan; } - int getChan() { return mChan; } + int getChan() const { return mChan; } private: layout::Object* mpLayout; // 0x00 diff --git a/include/system/iplPostmanManager.h b/include/system/iplPostmanManager.h index 68e0583c..0ff7863b 100644 --- a/include/system/iplPostmanManager.h +++ b/include/system/iplPostmanManager.h @@ -9,7 +9,7 @@ namespace ipl { public: Manager(); - int getUnk0x334() { return unk_0x334; } + int getUnk0x334() const { return unk_0x334; } private: u8 unk_0x00[0x334]; diff --git a/include/system/iplResetHandler.h b/include/system/iplResetHandler.h index e2f62171..417e8458 100644 --- a/include/system/iplResetHandler.h +++ b/include/system/iplResetHandler.h @@ -24,8 +24,8 @@ namespace ipl { void update(); void fatalUpdate(); - u32 getType() { return mType; } - u32 getFatalState() { return mFatalState; } + u32 getType() const { return mType; } + u32 getFatalState() const { return mFatalState; } void changeType(u32 value) { mType = value; } void changeFatalState(u32 value) { mFatalState = value; } @@ -39,7 +39,7 @@ namespace ipl { * Returns whether the reset handler to return to the system menu when resetting (calling `OSReturnToMenu()`) * instead of rebooting the system (calling `OSRebootSystem()`) */ - BOOL willResetToMenu() { return mbReturnToMenu; } + BOOL willResetToMenu() const { return mbReturnToMenu; } private: static void cbReset(); diff --git a/include/system/iplSystem.h b/include/system/iplSystem.h index 58b2a587..5745b7c0 100644 --- a/include/system/iplSystem.h +++ b/include/system/iplSystem.h @@ -101,7 +101,9 @@ namespace ipl { nand::File* mpChnTradMsg; // 0x150 nand::File* mpKorMsg; // 0x154 - u8 unk_0x158[0x1E0 - 0x158]; + u8 unk_0x158[0x18C - 0x158]; + nand::LayoutFile* mpDlgWdwFile; // 0x18C + u8 unk_0x190[0x1E0 - 0x190]; OSAlarm mUnkAlarm; // 0x1E0 u8 unk_0x210[0x2B0 - 0x210]; @@ -203,6 +205,8 @@ namespace ipl { static nand::File* getChnTradMsg() { return smArg.mpChnTradMsg; } /** @return The Korean message data. */ static nand::File* getKorMsg() { return smArg.mpKorMsg; } + /** @return The Dialog Window data. */ + static nand::LayoutFile* getDlgWdwFile() { return smArg.mpDlgWdwFile; } static bool isUnk_0x2B1() { return smArg.unk_0x2B1; } static bool hasCreatedAfter() { return smArg.mbCreatedAfter; } /** @return Whether the libraries needed have been created. */ @@ -260,6 +264,7 @@ namespace ipl { /** @return The Renderer of the IPL. */ static GXRenderModeObj* getRenderModeObj(); + static void getProjectionRect(nw4r::ut::Rect* rect); static void getProjectionRect4x3(nw4r::ut::Rect* rect); static void getProjectionRect16x9(nw4r::ut::Rect* rect); diff --git a/libs/EGG/include/egg/core/eggAllocator.h b/libs/EGG/include/egg/core/eggAllocator.h index e35ad6dc..604f7d4a 100644 --- a/libs/EGG/include/egg/core/eggAllocator.h +++ b/libs/EGG/include/egg/core/eggAllocator.h @@ -2,6 +2,7 @@ #define EGG_CORE_ALLOCATOR_H #include + #include namespace EGG { @@ -12,6 +13,8 @@ namespace EGG { virtual void* alloc(u32 size); virtual void free(void* buffer); + + operator MEMAllocator*() { return this; } }; } diff --git a/libs/MSL/include/new b/libs/MSL/include/new new file mode 100644 index 00000000..43be98f9 --- /dev/null +++ b/libs/MSL/include/new @@ -0,0 +1,15 @@ +#ifndef MSL_CPP_NEW_H +#define MSL_CPP_NEW_H + +#include + +#ifdef __cplusplus + +inline void* operator new(size_t size, void* ptr) { +#pragma unused(size) + return ptr; +} + +#endif // MSL_CPP_NEW_H + +#endif diff --git a/libs/NW4R/include/nw4r/lyt.h b/libs/NW4R/include/nw4r/lyt.h index 0f6755f7..5ae21f0a 100644 --- a/libs/NW4R/include/nw4r/lyt.h +++ b/libs/NW4R/include/nw4r/lyt.h @@ -10,7 +10,10 @@ #include #include +#include +#include #include +#include #include diff --git a/libs/NW4R/include/nw4r/lyt/animation.h b/libs/NW4R/include/nw4r/lyt/animation.h index d0402cae..457e8b6a 100644 --- a/libs/NW4R/include/nw4r/lyt/animation.h +++ b/libs/NW4R/include/nw4r/lyt/animation.h @@ -1,11 +1,11 @@ #ifndef NW4R_LYT_ANIMATION_H #define NW4R_LYT_ANIMATION_H -#include - #include #include +#include + namespace nw4r { namespace lyt { class Pane; diff --git a/libs/NW4R/include/nw4r/lyt/arcResourceAccessor.h b/libs/NW4R/include/nw4r/lyt/arcResourceAccessor.h index 826ea42b..04d0c1df 100644 --- a/libs/NW4R/include/nw4r/lyt/arcResourceAccessor.h +++ b/libs/NW4R/include/nw4r/lyt/arcResourceAccessor.h @@ -19,8 +19,7 @@ namespace nw4r { void Set(const char* name, ut::Font* pFont); - ut::Font* GetFont() const { return mpFont; } - char* GetFontName() { return mFontName; } + ut::Font* GetFont() const { return mpFont; } ut::LinkListNode mLink; @@ -37,7 +36,7 @@ namespace nw4r { void Set(void* archiveStart, const char* resRootDirectory); char* GetResRootDir() { return mResRootDir; } - ARCHandle* GetArcHandle() { return &mArcHandle; } + ARCHandle* GetArcHandle() { return &mArcHandle; } ut::LinkListNode mLink; diff --git a/libs/NW4R/include/nw4r/lyt/bounding.h b/libs/NW4R/include/nw4r/lyt/bounding.h new file mode 100644 index 00000000..936c9811 --- /dev/null +++ b/libs/NW4R/include/nw4r/lyt/bounding.h @@ -0,0 +1,17 @@ +#ifndef NW4R_LYT_BOUNDING_H +#define NW4R_LYT_BOUNDING_H + +#include + +namespace nw4r { + namespace lyt { + class Bounding : public Pane { + public: + NW4R_UT_RUNTIME_TYPEINFO; + }; + } +} + +#endif // NW4R_LYT_BOUNDING_H + + diff --git a/libs/NW4R/include/nw4r/lyt/layout.h b/libs/NW4R/include/nw4r/lyt/layout.h index 80c6c3a1..83b1fb94 100644 --- a/libs/NW4R/include/nw4r/lyt/layout.h +++ b/libs/NW4R/include/nw4r/lyt/layout.h @@ -49,7 +49,7 @@ namespace nw4r { Size mLayoutSize; // 0x18 - u8 mOriginType; // 0x20 + u8 mOrigin; // (?) 0x20 static MEMAllocator* mspAllocator; }; diff --git a/libs/NW4R/include/nw4r/lyt/pane.h b/libs/NW4R/include/nw4r/lyt/pane.h index bcdddf44..d26c8202 100644 --- a/libs/NW4R/include/nw4r/lyt/pane.h +++ b/libs/NW4R/include/nw4r/lyt/pane.h @@ -1,17 +1,17 @@ #ifndef NW4R_LYT_PANE_H #define NW4R_LYT_PANE_H -#include "drawInfo.h" #include +#include + #include #include +#include #include #include -#include - namespace nw4r { namespace lyt { class Pane; @@ -25,29 +25,29 @@ namespace nw4r { ut::LinkListNode mLink; }; } - typedef ut::LinkList PaneBaseList; + typedef ut::LinkList PaneList; class Pane : detail::PaneBase { - NW4R_UT_RUNTIME_TYPEINFO; - public: Pane(); virtual ~Pane(); // 0x08 + + NW4R_UT_RUNTIME_TYPEINFO; virtual void CalculateMtx(const DrawInfo& drawInfo); // 0x10 virtual void Draw(const DrawInfo& drawInfo); // 0x14 virtual void DrawSelf(const DrawInfo& drawInfo); // 0x18 - virtual void Animate(u32 option); // 0x1C - virtual void AnimateSelf(u32 option); // 0x20 + virtual void Animate(u32 option = 0); // 0x1C + virtual void AnimateSelf(u32 option = 0); // 0x20 virtual ut::Color GetVtxColor(u32 idx) const; // 0x24 virtual void SetVtxColor(u32 idx, ut::Color valuw); // 0x28 virtual u8 GetVtxColorElement(u32 idx) const; // 0x2C virtual void SetVtxColorElement(u32 idx, u8 element); // 0x30 - virtual undefined GetColorElement(u32 idx) const; // 0x34 + virtual u8 GetColorElement(u32 idx) const; // 0x34 virtual void SetColorElement(u32 idx, u8 color); // 0x38 virtual Pane* FindPaneByName(const char* findName, bool bRecursive = true); // 0x3C @@ -65,7 +65,10 @@ namespace nw4r { virtual Material* GetMaterial() const; // 0x5C - virtual void* LoadMtx(const undefined4& drawInfo); // 0x60 + virtual void* LoadMtx(const DrawInfo& drawInfo); // 0x60 + + Pane* GetParent() const { return mpParent; } + PaneList& GetChildList() { return mChildList; } const math::VEC3& GetTranslate() { return mTranslate; } void SetTranslate(const math::VEC3& translate) { mTranslate = translate; } @@ -80,12 +83,21 @@ namespace nw4r { const Size& GetSize() const { return mSize; } void SetSize(const Size& size) { mSize = size; } + bool IsVisible() { return detail::TestBit(mFlags, 0); }; void SetVisible(bool visible) { detail::SetBit(&mFlags, 0, visible); }; + + const math::MTX34& GetGlobalMtx() const { return mGlobalMtx; } + void SetGlobalMtx(const math::MTX34& mtx) { mGlobalMtx = mtx; } + + u8 GetAlpha() { return mAlpha; } + void SetAlpha(u8 alpha) { mAlpha = alpha; } + + const ut::Rect GetPaneRect(const DrawInfo& drawInfo) const; private: Pane* mpParent; // 0x0C - PaneBaseList mChildList; // 0x10 + PaneList mChildList; // 0x10 AnimationLinkList mAnimList; // 0x1C Material* mpMaterial; // 0x28 diff --git a/libs/NW4R/include/nw4r/lyt/picture.h b/libs/NW4R/include/nw4r/lyt/picture.h new file mode 100644 index 00000000..02ba9aa7 --- /dev/null +++ b/libs/NW4R/include/nw4r/lyt/picture.h @@ -0,0 +1,17 @@ +#ifndef NW4R_LYT_PICTURE_H +#define NW4R_LYT_PICTURE_H + +#include + +namespace nw4r { + namespace lyt { + class Picture : public Pane { + public: + NW4R_UT_RUNTIME_TYPEINFO; + }; + } +} + +#endif // NW4R_LYT_PICTURE_H + + diff --git a/libs/NW4R/include/nw4r/lyt/textBox.h b/libs/NW4R/include/nw4r/lyt/textBox.h index c7eab793..4f6e9239 100644 --- a/libs/NW4R/include/nw4r/lyt/textBox.h +++ b/libs/NW4R/include/nw4r/lyt/textBox.h @@ -2,16 +2,15 @@ #define NW4R_LYT_TEXTBOX_H #include -#include #include -#include - namespace nw4r { namespace lyt { class TextBox : public Pane { public: + NW4R_UT_RUNTIME_TYPEINFO; + TextBox(); virtual ~TextBox(); diff --git a/libs/NW4R/include/nw4r/lyt/window.h b/libs/NW4R/include/nw4r/lyt/window.h new file mode 100644 index 00000000..8a7b7678 --- /dev/null +++ b/libs/NW4R/include/nw4r/lyt/window.h @@ -0,0 +1,17 @@ +#ifndef NW4R_LYT_WINDOW_H +#define NW4R_LYT_WINDOW_H + +#include + +namespace nw4r { + namespace lyt { + class Window : public Pane { + public: + NW4R_UT_RUNTIME_TYPEINFO; + }; + } +} + +#endif // NW4R_LYT_WINDOW_H + + diff --git a/libs/NW4R/include/nw4r/math/types.h b/libs/NW4R/include/nw4r/math/types.h index cfb20416..8a38b290 100644 --- a/libs/NW4R/include/nw4r/math/types.h +++ b/libs/NW4R/include/nw4r/math/types.h @@ -14,7 +14,7 @@ namespace nw4r { f32 _20, _21, _22; }; f32 m[3][3]; - f32 a[9]; + f32 a[3 * 3]; }; }; @@ -30,19 +30,26 @@ namespace nw4r { }; f32 m[3][4]; - f32 a[12]; + f32 a[3 * 4]; Mtx mtx; }; }; typedef struct MTX34 : public _MTX34 { + typedef const f32 (*ConstMtxPtr)[4]; + MTX34() {} - MTX34(const f32 *); + MTX34(const f32*); MTX34(const Mtx &rhs); operator f32*() { return &_00; } - operator const f32*() const { return &_00; } + + operator const f32*() const { return &_00; } + + operator MtxPtr() { return (MtxPtr)&_00; } + + operator ConstMtxPtr() const { return (ConstMtxPtr)&_00; } } MTX34; struct _MTX44 { @@ -70,10 +77,12 @@ namespace nw4r { }; typedef struct VEC2 : public _VEC2 { - VEC2() {} + VEC2() {} - VEC2(const f32* pF) { x = pF[0]; y = pF[1]; } - VEC2(f32 fx, f32 fy) { x = fx; y = fy; } + VEC2(const f32* pF) { x = pF[0]; y = pF[1]; } + VEC2(f32 fx, f32 fy) { x = fx; y = fy; } + + operator Vec2*() { return (Vec2*)this; } } VEC2; struct _VEC3 { @@ -83,10 +92,12 @@ namespace nw4r { }; typedef struct VEC3 : public _VEC3 { - VEC3() {} + VEC3() {} - VEC3(const f32* pF) { x = pF[0]; y = pF[1]; z = pF[2]; } - VEC3(f32 fx, f32 fy, f32 fz) { x = fx; y = fy; z = fz; } + VEC3(const f32* pF) { x = pF[0]; y = pF[1]; z = pF[2]; } + VEC3(f32 fx, f32 fy, f32 fz) { x = fx; y = fy; z = fz; } + + operator Vec*() { return (Vec*)this; } } VEC3; struct _VEC4 { diff --git a/libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h b/libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h index 4e3f56b3..2beccbb1 100644 --- a/libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h +++ b/libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h @@ -1,27 +1,44 @@ #ifndef NW4R_UT_RUNTIME_TYPE_INFO_H #define NW4R_UT_RUNTIME_TYPE_INFO_H +#include + namespace nw4r { namespace ut { #define NW4R_UT_RUNTIME_TYPEINFO \ virtual const nw4r::ut::detail::RuntimeTypeInfo* GetRuntimeTypeInfo() const { return &typeInfo; } \ static const nw4r::ut::detail::RuntimeTypeInfo typeInfo - - #define NW4R_UT_RUNTIME_TYPEINFO_DEFINITION(derived,base) \ - const nw4r::ut::detail::RuntimeTypeInfo derived::typeInfo(&base::typeInfo) - - #define NW4R_UT_RUNTIME_TYPEINFO_ROOT_DEFINITION(root) \ - const nw4r::ut::detail::RuntimeTypeInfo root::typeInfo(NULL) namespace detail { struct RuntimeTypeInfo { - const RuntimeTypeInfo* mParentTypeInfo; - explicit RuntimeTypeInfo(const RuntimeTypeInfo *parent) : mParentTypeInfo(parent) {} + explicit RuntimeTypeInfo(const RuntimeTypeInfo* pBase) : mParentTypeInfo(pBase) {} + + bool IsDerivedFrom(const RuntimeTypeInfo* pBase) const { + for (const RuntimeTypeInfo* pIt = this; pIt != NULL; + pIt = pIt->mParentTypeInfo) { + if (pIt == pBase) { + return true; + } + } + return false; + } + const RuntimeTypeInfo* mParentTypeInfo; // 0x00 }; - }; + + template inline const RuntimeTypeInfo* GetTypeInfoFromPtr_(T* pPtr) { + return &pPtr->typeInfo; + } + } + + template inline TDerived DynamicCast(TBase* pPtr) { + const detail::RuntimeTypeInfo* pDerivedTypeInfo = + detail::GetTypeInfoFromPtr_(static_cast(NULL)); + if (pPtr->GetRuntimeTypeInfo()->IsDerivedFrom(pDerivedTypeInfo)) { + return static_cast(pPtr); + } + return NULL; + } } } #endif // NW4R_UT_RUNTIME_TYPE_INFO_H - - diff --git a/libs/NW4R/include/nw4r/ut/inlines.h b/libs/NW4R/include/nw4r/ut/inlines.h index 3dcc35d3..9cf14479 100644 --- a/libs/NW4R/include/nw4r/ut/inlines.h +++ b/libs/NW4R/include/nw4r/ut/inlines.h @@ -1,8 +1,6 @@ #ifndef NW4R_UT_INLINE_FUNCTIONS_H #define NW4R_UT_INLINE_FUNCTIONS_H -#include - namespace nw4r { namespace ut { class NonCopyable { diff --git a/libs/RVL_SDK/include/revolution/base/PPCWGPipe.h b/libs/RVL_SDK/include/revolution/base/PPCWGPipe.h new file mode 100644 index 00000000..fd2a8446 --- /dev/null +++ b/libs/RVL_SDK/include/revolution/base/PPCWGPipe.h @@ -0,0 +1,27 @@ +#ifndef REVOLUTION_BASE_PPCWGPIPE_H +#define REVOLUTION_BASE_PPCWGPIPE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union PPCWGPipe { + u8 u8; + u16 u16; + u32 u32; + u64 u64; + s8 s8; + s16 s16; + s32 s32; + s64 s64; + f32 f32; + f64 f64; +} PPCWGPipe; + +#ifdef __cplusplus +} +#endif + +#endif // REVOLUTION_BASE_PPCWGPIPE_H diff --git a/libs/RVL_SDK/include/revolution/gx.h b/libs/RVL_SDK/include/revolution/gx.h index 62a5d182..000e6bf6 100644 --- a/libs/RVL_SDK/include/revolution/gx.h +++ b/libs/RVL_SDK/include/revolution/gx.h @@ -13,12 +13,15 @@ extern "C" { #include #include #include +#include +#include +#include #include +#include +#include #ifdef __cplusplus } #endif #endif // REVOLUTION_GX_H - - diff --git a/libs/RVL_SDK/include/revolution/gx/GXCull.h b/libs/RVL_SDK/include/revolution/gx/GXCull.h index 99fa454b..43f9bddd 100644 --- a/libs/RVL_SDK/include/revolution/gx/GXCull.h +++ b/libs/RVL_SDK/include/revolution/gx/GXCull.h @@ -8,7 +8,7 @@ extern "C" { #endif -void GXSetCullMode ( GXCullMode mode ); +void GXSetCullMode(GXCullMode mode); #ifdef __cplusplus } diff --git a/libs/RVL_SDK/include/revolution/gx/GXEnum.h b/libs/RVL_SDK/include/revolution/gx/GXEnum.h index 2b0c4dba..6d2be087 100644 --- a/libs/RVL_SDK/include/revolution/gx/GXEnum.h +++ b/libs/RVL_SDK/include/revolution/gx/GXEnum.h @@ -9,11 +9,580 @@ extern "C" { typedef u8 GXBool; -#define GX_TRUE ((GXBool)TRUE) -#define GX_FALSE ((GXBool)FALSE) +#define GX_TRUE ((GXBool)1) +#define GX_FALSE ((GXBool)0) +#define GX_ENABLE ((GXBool)1) +#define GX_DISABLE ((GXBool)0) -#define _GX_TF_ZTF 0x10 /* Z Texture format */ -#define _GX_TF_CTF 0x20 /* Copy texture format */ +typedef enum _GXAttr { + GX_VA_PNMTXIDX = 0, + 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 = 9, + 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 _GXVtxFmt { + GX_VTXFMT0 = 0, + GX_VTXFMT1, + GX_VTXFMT2, + GX_VTXFMT3, + GX_VTXFMT4, + GX_VTXFMT5, + GX_VTXFMT6, + GX_VTXFMT7, + GX_MAX_VTXFMT +} GXVtxFmt; + +typedef enum _GXAttrType { + GX_NONE = 0, + GX_DIRECT, + GX_INDEX8, + GX_INDEX16 +} GXAttrType; + +typedef enum _GXTexCoordID { + GX_TEXCOORD0 = 0x0, + GX_TEXCOORD1, + GX_TEXCOORD2, + GX_TEXCOORD3, + GX_TEXCOORD4, + GX_TEXCOORD5, + GX_TEXCOORD6, + GX_TEXCOORD7, + GX_MAX_TEXCOORD = 8, + GX_TEXCOORD_NULL = 0xff +} GXTexCoordID; + +typedef enum _GXTexGenType { + GX_TG_MTX3x4 = 0, + 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 _GXTexGenSrc { + GX_TG_POS = 0, + 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 _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 _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 _GXColorSrc { GX_SRC_REG = 0, GX_SRC_VTX } GXColorSrc; + +typedef enum _GXTlut { + GX_TLUT0 = 0, + 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 _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 _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 _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 _GXIndTexStageID { + GX_INDTEXSTAGE0, + GX_INDTEXSTAGE1, + GX_INDTEXSTAGE2, + GX_INDTEXSTAGE3, + GX_MAX_INDTEXSTAGE +} GXIndTexStageID; + +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; + +#define _GX_TF_CTF 0x20 /* copy-texture-format only */ +#define _GX_TF_ZTF 0x10 /* Z-texture-format */ + +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 _GXTexOffset { + GX_TO_ZERO = 0, + GX_TO_SIXTEENTH = 1, + GX_TO_EIGHTH = 2, + GX_TO_FOURTH = 3, + GX_TO_HALF = 4, + GX_TO_ONE = 5, + GX_MAX_TEXOFFSET, +} GXTexOffset; + +typedef enum _GXCullMode { + GX_CULL_NONE, + GX_CULL_FRONT, + GX_CULL_BACK, + GX_CULL_ALL +} GXCullMode; + +typedef enum _GXClipMode { GX_CLIP_ENABLE = 0, GX_CLIP_DISABLE = 1 } GXClipMode; + +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 _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 = 0x000 +} GXLightID; + +typedef enum _GXDiffuseFn { + GX_DF_NONE = 0, + GX_DF_SIGN, + GX_DF_CLAMP +} GXDiffuseFn; + +typedef enum _GXAttnFn { GX_AF_SPEC = 0, GX_AF_SPOT = 1, GX_AF_NONE } GXAttnFn; + +typedef enum _GXCompCnt { + GX_POS_XY = 0, + GX_POS_XYZ = 1, + GX_NRM_XYZ = 0, + GX_NRM_NBT = 1, // one index per NBT + GX_NRM_NBT3 = 2, // one index per each of N/B/T + GX_CLR_RGB = 0, + GX_CLR_RGBA = 1, + GX_TEX_S = 0, + GX_TEX_ST = 1 +} GXCompCnt; + +typedef enum _GXTevRegID { + GX_TEVPREV = 0, + GX_TEVREG0, + GX_TEVREG1, + GX_TEVREG2, + GX_MAX_TEVREG +} GXTevRegID; + +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, // for alpha channel + GX_TEV_COMP_A8_EQ = GX_TEV_COMP_RGB8_EQ // for alpha channel +} GXTevOp; + +typedef enum _GXTevColorArg { + GX_CC_CPREV, + GX_CC_APREV, + GX_CC_C0, + GX_CC_A0, + GX_CC_C1, + GX_CC_A1, + GX_CC_C2, + GX_CC_A2, + GX_CC_TEXC, + GX_CC_TEXA, + GX_CC_RASC, + GX_CC_RASA, + GX_CC_ONE, + GX_CC_HALF, + GX_CC_KONST, + GX_CC_ZERO +} GXTevColorArg; + +typedef enum _GXTevAlphaArg { + GX_CA_APREV, + GX_CA_A0, + GX_CA_A1, + GX_CA_A2, + GX_CA_TEXA, + GX_CA_RASA, + GX_CA_KONST, + GX_CA_ZERO +} GXTevAlphaArg; + +typedef enum _GXTevBias { + GX_TB_ZERO, + GX_TB_ADDHALF, + GX_TB_SUBHALF, + GX_MAX_TEVBIAS +} GXTevBias; + +typedef enum _GXTevClampMode { + GX_TC_LINEAR, + GX_TC_GE, + GX_TC_EQ, + GX_TC_LE, + GX_MAX_TEVCLAMPMODE +} GXTevClampMode; + +typedef enum _GXTevKColorID { + GX_KCOLOR0 = 0, + GX_KCOLOR1, + GX_KCOLOR2, + GX_KCOLOR3, + GX_MAX_KCOLOR +} GXTevKColorID; + +typedef enum _GXTevKColorSel { + GX_TEV_KCSEL_8_8 = 0x00, + GX_TEV_KCSEL_7_8 = 0x01, + GX_TEV_KCSEL_6_8 = 0x02, + GX_TEV_KCSEL_5_8 = 0x03, + GX_TEV_KCSEL_4_8 = 0x04, + GX_TEV_KCSEL_3_8 = 0x05, + GX_TEV_KCSEL_2_8 = 0x06, + GX_TEV_KCSEL_1_8 = 0x07, + + GX_TEV_KCSEL_1 = GX_TEV_KCSEL_8_8, + GX_TEV_KCSEL_3_4 = GX_TEV_KCSEL_6_8, + GX_TEV_KCSEL_1_2 = GX_TEV_KCSEL_4_8, + GX_TEV_KCSEL_1_4 = GX_TEV_KCSEL_2_8, + + 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_8_8 = 0x00, + GX_TEV_KASEL_7_8 = 0x01, + GX_TEV_KASEL_6_8 = 0x02, + GX_TEV_KASEL_5_8 = 0x03, + GX_TEV_KASEL_4_8 = 0x04, + GX_TEV_KASEL_3_8 = 0x05, + GX_TEV_KASEL_2_8 = 0x06, + GX_TEV_KASEL_1_8 = 0x07, + + GX_TEV_KASEL_1 = GX_TEV_KASEL_8_8, + GX_TEV_KASEL_3_4 = GX_TEV_KASEL_6_8, + GX_TEV_KASEL_1_2 = GX_TEV_KASEL_4_8, + GX_TEV_KASEL_1_4 = GX_TEV_KASEL_2_8, + + 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 _GXAlphaOp { + GX_AOP_AND, + GX_AOP_OR, + GX_AOP_XOR, + GX_AOP_XNOR, + GX_MAX_ALPHAOP +} GXAlphaOp; + +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 _GXFogType { + GX_FOG_NONE = 0x00, + GX_FOG_PERSP_LIN = 0x02, + GX_FOG_PERSP_EXP = 0x04, + GX_FOG_PERSP_EXP2 = 0x05, + GX_FOG_PERSP_REVEXP = 0x06, + GX_FOG_PERSP_REVEXP2 = 0x07, + GX_FOG_ORTHO_LIN = 0x0A, + GX_FOG_ORTHO_EXP = 0x0C, + GX_FOG_ORTHO_EXP2 = 0x0D, + GX_FOG_ORTHO_REVEXP = 0x0E, + GX_FOG_ORTHO_REVEXP2 = 0x0F, + GX_FOG_LIN = GX_FOG_PERSP_LIN, + GX_FOG_EXP = GX_FOG_PERSP_EXP, + GX_FOG_EXP2 = GX_FOG_PERSP_EXP2, + GX_FOG_REVEXP = GX_FOG_PERSP_REVEXP, + GX_FOG_REVEXP2 = GX_FOG_PERSP_REVEXP2 +} GXFogType; + +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 _GXCompare { GX_NEVER, @@ -26,135 +595,239 @@ typedef enum _GXCompare { GX_ALWAYS } GXCompare; -typedef enum _GXTexFmt { - GX_TF_I4 = 0x00, - GX_TF_I8 = 0x01, - GX_TF_IA4 = 0x02, - GX_TF_IA8 = 0x03, - GX_TF_RGB565 = 0x04, - GX_TF_RGB5A3 = 0x05, - GX_TF_RGBA8 = 0x06, - GX_TF_CMPR = 0x0E, - - GX_TF_Z8 = 0x01 | _GX_TF_ZTF, - GX_TF_Z16 = 0x03 | _GX_TF_ZTF, - GX_TF_Z24X8 = 0x06 | _GX_TF_ZTF, - - GX_CTF_R4 = 0x00 | _GX_TF_CTF, - GX_CTF_RA4 = 0x02 | _GX_TF_CTF, - GX_CTF_RA8 = 0x03 | _GX_TF_CTF, - GX_CTF_YUVA8 = 0x06 | _GX_TF_CTF, - GX_CTF_A8 = 0x07 | _GX_TF_CTF, - GX_CTF_R8 = 0x08 | _GX_TF_CTF, - GX_CTF_G8 = 0x09 | _GX_TF_CTF, - GX_CTF_B8 = 0x0A | _GX_TF_CTF, - GX_CTF_RG8 = 0x0B | _GX_TF_CTF, - GX_CTF_GB8 = 0x0C | _GX_TF_CTF, +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; - GX_CTF_Z4 = 0x00 | _GX_TF_ZTF | _GX_TF_CTF, - GX_CTF_Z8M = 0x09 | _GX_TF_ZTF | _GX_TF_CTF, - GX_CTF_Z8L = 0x0A | _GX_TF_ZTF | _GX_TF_CTF, - GX_CTF_Z16L = 0x0C | _GX_TF_ZTF | _GX_TF_CTF, +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; - GX_TF_A8 = GX_CTF_A8 -} GXTexFmt; +typedef enum _GXZFmt16 { + GX_ZC_LINEAR, + GX_ZC_NEAR, + GX_ZC_MID, + GX_ZC_FAR +} GXZFmt16; -typedef enum _GXCITexFmt { - GX_TF_C4 = 0x08, - GX_TF_C8 = 0x09, - GX_TF_C14X2 = 0x0A, -} GXCITexFmt; +typedef enum _GXTevMode { + GX_MODULATE, + GX_DECAL, + GX_BLEND, + GX_REPLACE, + GX_PASSCLR +} GXTevMode; -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 _GXGamma { GX_GM_1_0, GX_GM_1_7, GX_GM_2_2 } GXGamma; -typedef enum _GXTexWrapMode { - GX_CLAMP, - GX_REPEAT, - GX_MIRROR, - GX_MAX_TEXWRAPMODE -} GXTexWrapMode; +typedef enum _GXProjectionType { + GX_PERSPECTIVE, + GX_ORTHOGRAPHIC +} GXProjectionType; -typedef enum _GXTexFilter { - GX_NEAR = 0, - GX_LINEAR, - GX_NEAR_MIP_NEAR, - GX_LIN_MIP_NEAR, - GX_NEAR_MIP_LIN, - GX_LIN_MIP_LIN -} GXTexFilter; +typedef enum _GXEvent { + GX_VCACHE_MISS_ALL, + GX_VCACHE_MISS_POS, + GX_VCACHE_MISS_NRM +} GXEvent; + +typedef enum _GXFBClamp { + GX_CLAMP_NONE, + GX_CLAMP_TOP, + GX_CLAMP_BOTTOM +} GXFBClamp; typedef enum _GXAnisotropy { - GX_ANISO_1 = 0, + GX_ANISO_1, GX_ANISO_2, GX_ANISO_4, GX_MAX_ANISOTROPY } GXAnisotropy; -typedef enum _GXDistAttnFn { - GX_DA_OFF = 0, - GX_DA_GENTLE, - GX_DA_MEDIUM, - GX_DA_STEEP -} GXDistAttnFn; +typedef enum _GXZTexOp { + GX_ZT_DISABLE, + GX_ZT_ADD, + GX_ZT_REPLACE, + GX_MAX_ZTEXOP -typedef enum _GXSpotFn { - GX_SP_OFF = 0, - GX_SP_FLAT, - GX_SP_COS, - GX_SP_COS2 , - GX_SP_SHARP, - GX_SP_RING1, - GX_SP_RING2, -} GXSpotFn; +} GXZTexOp; -typedef enum _GXLightID { - GX_LIGHT0 = (1 << 0), - GX_LIGHT1 = (1 << 1), - GX_LIGHT2 = (1 << 2), - GX_LIGHT3 = (1 << 3), - GX_LIGHT4 = (1 << 4), - GX_LIGHT5 = (1 << 5), - GX_LIGHT6 = (1 << 6), - GX_LIGHT7 = (1 << 7), +typedef enum _GXTexMtxType { GX_MTX3x4 = 0, GX_MTX2x4 } GXTexMtxType; - GX_MAX_LIGHT = (1 << 8), - GX_LIGHT_NULL = 0 -} GXLightID; +typedef enum _GXPrimitive { + GX_POINTS = 0xb8, + GX_LINES = 0xa8, + GX_LINESTRIP = 0xb0, + GX_TRIANGLES = 0x90, + GX_TRIANGLESTRIP = 0x98, + GX_TRIANGLEFAN = 0xa0, + GX_QUADS = 0x80 +} GXPrimitive; -typedef enum _GXFogType { - GX_FOG_NONE, +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; - 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, +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; - // Fourth bit is set to mark orthographic - GX_FOG_ORTHO_LIN = 1 << 3 | GX_FOG_PERSP_LIN, - GX_FOG_ORTHO_EXP = 1 << 3 | GX_FOG_PERSP_EXP, - GX_FOG_ORTHO_EXP2 = 1 << 3 | GX_FOG_PERSP_EXP2, - GX_FOG_ORTHO_REVEXP = 1 << 3 | GX_FOG_PERSP_REVEXP, - GX_FOG_ORTHO_REVEXP2 = 1 << 3 | GX_FOG_PERSP_REVEXP2 -} GXFogType; +typedef enum _GXVCachePerf { + GX_VC_POS, + GX_VC_NRM, + GX_VC_CLR0, + GX_VC_CLR1, + GX_VC_TEX0, + GX_VC_TEX1, + GX_VC_TEX2, + GX_VC_TEX3, + GX_VC_TEX4, + GX_VC_TEX5, + GX_VC_TEX6, + GX_VC_TEX7, + GX_VC_ALL = 0xf +} GXVCachePerf; + +typedef enum _GXCopyMode { + GX_COPY_PROGRESSIVE = 0, + GX_COPY_INTLC_EVEN = 2, + GX_COPY_INTLC_ODD = 3 +} GXCopyMode; + +typedef enum _GXTlutFmt { + GX_TL_IA8 = 0x0, + GX_TL_RGB565 = 0x1, + GX_TL_RGB5A3 = 0x2, + GX_MAX_TLUTFMT +} GXTlutFmt; + +typedef enum _GXTevSwapSel { + GX_TEV_SWAP0 = 0, + GX_TEV_SWAP1, + GX_TEV_SWAP2, + GX_TEV_SWAP3, + GX_MAX_TEVSWAP +} GXTevSwapSel; + +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 _GXTevColorChan { + GX_CH_RED = 0, + GX_CH_GREEN, + GX_CH_BLUE, + GX_CH_ALPHA +} GXTevColorChan; + +typedef enum _GXCITexFmt { + GX_TF_C4 = 0x8, + GX_TF_C8 = 0x9, + GX_TF_C14X2 = 0xA +} GXCITexFmt; -typedef enum _GXCullMode { - GX_CULL_NONE, - GX_CULL_FRONT, - GX_CULL_BACK, - GX_CULL_ALL -} GXCullMode; #ifdef __cplusplus } diff --git a/libs/RVL_SDK/include/revolution/gx/GXFifo.h b/libs/RVL_SDK/include/revolution/gx/GXFifo.h new file mode 100644 index 00000000..bc1c4619 --- /dev/null +++ b/libs/RVL_SDK/include/revolution/gx/GXFifo.h @@ -0,0 +1,94 @@ +#ifndef REVOLUTION_GX_FIFO_H +#define REVOLUTION_GX_FIFO_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define GXFIFO_ADDR 0xCC008000 + +volatile PPCWGPipe GXWGFifo : GXFIFO_ADDR; + +static inline void GXPosition2f32(const f32 x, const f32 y) { + GXWGFifo.f32 = x; + GXWGFifo.f32 = y; +} + +static inline void GXPosition3s16(const s16 x, const s16 y, const s16 z) { + GXWGFifo.s16 = x; + GXWGFifo.s16 = y; + GXWGFifo.s16 = z; +} + +static inline void GXPosition3u16(const u16 x, const u16 y, const u16 z) { + GXWGFifo.u16 = x; + GXWGFifo.u16 = y; + GXWGFifo.u16 = z; +} + +static inline void GXPosition3f32(f32 x, f32 y, f32 z) { + GXWGFifo.f32 = x; + GXWGFifo.f32 = y; + GXWGFifo.f32 = z; +} + +static inline void GXNormal3f32(const f32 x, const f32 y, const f32 z) { + GXWGFifo.f32 = x; + GXWGFifo.f32 = y; + GXWGFifo.f32 = z; +} + +static inline void GXColor1(GXColor* color) { + GXWGFifo.u32 = *(u32*)&color; +} + +static inline void GXColor1u32(u32 c) { + GXWGFifo.u32 = c; +} + +static inline void GXColor4u8(const u8 r, const u8 g, const u8 b, const u8 a) { + GXWGFifo.u8 = r; + GXWGFifo.u8 = g; + GXWGFifo.u8 = b; + GXWGFifo.u8 = a; +} + +static inline void GXTexCoord2s8(const s8 u, const s8 v) { + GXWGFifo.s8 = u; + GXWGFifo.s8 = v; +} + +static inline void GXTexCoord2u8(u8 s, u8 t) { + GXWGFifo.u8 = s; + GXWGFifo.u8 = t; +} + +static inline void GXPosition2u16(u16 x, u16 y) { + GXWGFifo.u16 = x; + GXWGFifo.u16 = y; +} + +static inline void GXTexCoord2s16(const s16 u, const s16 v) { + GXWGFifo.s16 = u; + GXWGFifo.s16 = v; +} + +static inline void GXTexCoord2u16(const u16 u, const u16 v) { + GXWGFifo.u16 = u; + GXWGFifo.u16 = v; +} + +static inline void GXTexCoord2f32(const f32 u, const f32 v) { + GXWGFifo.f32 = u; + GXWGFifo.f32 = v; +} + +#ifdef __cplusplus +} +#endif + +#endif // REVOLUTION_GX_FIFO_H diff --git a/libs/RVL_SDK/include/revolution/gx/GXGeometry.h b/libs/RVL_SDK/include/revolution/gx/GXGeometry.h new file mode 100644 index 00000000..cae7196d --- /dev/null +++ b/libs/RVL_SDK/include/revolution/gx/GXGeometry.h @@ -0,0 +1,29 @@ +#ifndef REVOLUTION_GX_GEOMETRY_H +#define REVOLUTION_GX_GEOMETRY_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void GXBegin(GXPrimitive type, GXVtxFmt format, u16 numVertices); + +void GXClearVtxDesc(); +void GXSetVtxDesc(GXAttr attr, GXAttrType type); +void GXSetVtxAttrFmt(GXVtxFmt format, GXAttr attr, GXCompCnt count, GXCompType type, u8 frac); + +void GXSetNumTexGens(u8 count); + +void GXSetLineWidth(u8 width, GXTexOffset offset); +void GXSetPointSize(u8 pointSize, GXTexOffset offset); + +static inline void GXEnd() {} + +#ifdef __cplusplus +} +#endif + +#endif // REVOLUTION_GX_GEOMETRY_H diff --git a/libs/RVL_SDK/include/revolution/gx/GXLight.h b/libs/RVL_SDK/include/revolution/gx/GXLight.h new file mode 100644 index 00000000..19145bfc --- /dev/null +++ b/libs/RVL_SDK/include/revolution/gx/GXLight.h @@ -0,0 +1,18 @@ +#ifndef REVOLUTION_GX_LIGHT_H +#define REVOLUTION_GX_LIGHT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void GXSetNumChans(u8 count); +void GXSetChanCtrl(GXChannelID channel, GXBool doEnable, GXColorSrc ambSrc, GXColorSrc matSrc, u32 mask, GXDiffuseFn diffFunc, GXAttnFn attnFunc); + +#ifdef __cplusplus +} +#endif + +#endif // REVOLUTION_GX_LIGHT_H diff --git a/libs/RVL_SDK/include/revolution/gx/GXPixel.h b/libs/RVL_SDK/include/revolution/gx/GXPixel.h index c180d5dc..afe4e052 100644 --- a/libs/RVL_SDK/include/revolution/gx/GXPixel.h +++ b/libs/RVL_SDK/include/revolution/gx/GXPixel.h @@ -16,6 +16,8 @@ void GXSetZMode(GXBool compare_enable, GXCompare func, GXBool update_enable); void GXSetColorUpdate(GXBool update_enable); void GXSetAlphaUpdate(GXBool update_enable); +void GXSetBlendMode(GXBlendMode type, GXBlendFactor srcFactor, GXBlendFactor destFactor, GXLogicOp op); + #ifdef __cplusplus } #endif diff --git a/libs/RVL_SDK/include/revolution/gx/GXStruct.h b/libs/RVL_SDK/include/revolution/gx/GXStruct.h index f7127ab3..3c832e62 100644 --- a/libs/RVL_SDK/include/revolution/gx/GXStruct.h +++ b/libs/RVL_SDK/include/revolution/gx/GXStruct.h @@ -9,15 +9,15 @@ extern "C" { #endif -typedef struct { +typedef struct _GXColor { u8 r, g, b, a; // 0x00 } GXColor; -typedef struct { +typedef struct _GXColorS10 { s16 r, g, b, a; // 0x00 } GXColorS10; -typedef struct { +typedef struct _GXTexObj { u32 dummy[8]; // 0x00 } GXTexObj; @@ -42,5 +42,3 @@ typedef struct _GXRenderModeObj { #endif #endif // REVOLUTION_GX_STRUCTS_H - - diff --git a/libs/RVL_SDK/include/revolution/gx/GXTev.h b/libs/RVL_SDK/include/revolution/gx/GXTev.h new file mode 100644 index 00000000..ab2be20a --- /dev/null +++ b/libs/RVL_SDK/include/revolution/gx/GXTev.h @@ -0,0 +1,21 @@ +#ifndef REVOLUTION_GX_TEV_H +#define REVOLUTION_GX_TEV_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void GXSetNumTevStages(u8 count); + +void GXSetTevOp(GXTevStageID stage, GXTevMode mode); +void GXSetTevOrder(GXTevStageID stage, GXTexCoordID coord, GXTexMapID map, GXChannelID color); + +#ifdef __cplusplus +} +#endif + +#endif // REVOLUTION_GX_TEV_H diff --git a/libs/RVL_SDK/include/revolution/gx/GXTransform.h b/libs/RVL_SDK/include/revolution/gx/GXTransform.h new file mode 100644 index 00000000..6f3d2ee4 --- /dev/null +++ b/libs/RVL_SDK/include/revolution/gx/GXTransform.h @@ -0,0 +1,19 @@ +#ifndef REVOLUTION_GX_TRANSFORM_H +#define REVOLUTION_GX_TRANSFORM_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void GXLoadPosMtxImm(Mtx mtx, u32 id); + +#ifdef __cplusplus +} +#endif + +#endif // REVOLUTION_GX_TRANSFORM_H diff --git a/libs/RVL_SDK/include/revolution/kpad.h b/libs/RVL_SDK/include/revolution/kpad.h index f46a1aa9..41a95d1a 100644 --- a/libs/RVL_SDK/include/revolution/kpad.h +++ b/libs/RVL_SDK/include/revolution/kpad.h @@ -7,17 +7,7 @@ extern "C" { #endif // __cplusplus #include - -typedef struct Vec { - f32 x; // 0x00 - f32 y; // 0x04 - f32 z; // 0x08 -} Vec; - -typedef struct Vec2 { - f32 x; // 0x00 - f32 y; // 0x04 -} Vec2; +#include typedef union KPADEXStatus { struct { @@ -79,5 +69,3 @@ s32 KPADRead(s32 chan, KPADStatus* status, u32 length); #endif // __cplusplus #endif // REVOLUTION_KPAD_H - - diff --git a/libs/RVL_SDK/include/revolution/mem/allocator.h b/libs/RVL_SDK/include/revolution/mem/allocator.h index fd063fb3..e431ce84 100644 --- a/libs/RVL_SDK/include/revolution/mem/allocator.h +++ b/libs/RVL_SDK/include/revolution/mem/allocator.h @@ -7,10 +7,10 @@ extern "C" { #endif -typedef struct MEMAllocator; +typedef struct MEMAllocator MEMAllocator; -typedef void* (*MEMAllocatorAllocFunc)(struct MEMAllocator* allocator, u32 size); -typedef void (*MEMAllocatorFreeFunc)(struct MEMAllocator* allocator, void* block); +typedef void* (*MEMAllocatorAllocFunc)(MEMAllocator* allocator, u32 size); +typedef void (*MEMAllocatorFreeFunc)(MEMAllocator* allocator, void* block); typedef struct MEMAllocatorFuncs { MEMAllocatorAllocFunc allocFunc; // 0x00 @@ -26,10 +26,11 @@ typedef struct MEMAllocator { u32 heapParam2; // 0x0C } MEMAllocator; +void* MEMAllocFromAllocator(MEMAllocator*, u32 size); +void MEMFreeToAllocator(MEMAllocator*, void* buffer); + #ifdef __cplusplus } #endif #endif // REVOLUTION_MEM_ALLOCATOR_H - - diff --git a/libs/RVL_SDK/include/revolution/mtx.h b/libs/RVL_SDK/include/revolution/mtx.h index 0da1fd44..083b12c2 100644 --- a/libs/RVL_SDK/include/revolution/mtx.h +++ b/libs/RVL_SDK/include/revolution/mtx.h @@ -3,6 +3,18 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + +u32 PSMTXInverse(const Mtx src, Mtx inv); + +void PSMTXTrans(Mtx mtx, f32 xT, f32 yT, f32 zT); + +void PSMTXMultVec(const Mtx mtx, const Vec* in, Vec* out); + +#ifdef __cplusplus +} +#endif + #endif // REVOLUTION_MTX_H - - diff --git a/libs/RVL_SDK/include/revolution/mtx/GeoTypes.h b/libs/RVL_SDK/include/revolution/mtx/GeoTypes.h index 54b35d06..bad0c315 100644 --- a/libs/RVL_SDK/include/revolution/mtx/GeoTypes.h +++ b/libs/RVL_SDK/include/revolution/mtx/GeoTypes.h @@ -7,13 +7,26 @@ extern "C" { #endif +typedef struct Vec { + f32 x; // 0x00 + f32 y; // 0x04 + f32 z; // 0x08 +} Vec; + +typedef struct Vec2 { + f32 x; // 0x00 + f32 y; // 0x04 +} Vec2; + typedef f32 Mtx[3][4]; +typedef f32 Mtx33[3][3]; typedef f32 Mtx44[4][4]; +typedef f32 (*Mtx3Ptr)[3]; +typedef f32 (*MtxPtr)[4]; + #ifdef __cplusplus } #endif #endif // REVOLUTION_MTX_GEO_TYPES_H - - diff --git a/src/homebutton/HBMFrameController.cpp b/src/homebutton/HBMFrameController.cpp index 239e7382..fc7688db 100644 --- a/src/homebutton/HBMFrameController.cpp +++ b/src/homebutton/HBMFrameController.cpp @@ -1,5 +1,5 @@ #include "homebutton/HBMFrameController.h" -#pragma sym on + namespace homebutton { void FrameController::init(int type, f32 maxFrame, f32 minFrame, f32 delta) { mAnmType = type; diff --git a/src/layout/GUIManager.cpp b/src/layout/GUIManager.cpp new file mode 100644 index 00000000..eaa543c1 --- /dev/null +++ b/src/layout/GUIManager.cpp @@ -0,0 +1,341 @@ +#include "layout/GUIManager.h" +#include "revolution/mtx.h" +#include "revolution/mtx/GeoTypes.h" + +#include + +#include + +void drawLine_(f32 x0, f32 y0, f32 x1, f32 y1, f32 z, u8 width, GXColor& color) { + Mtx mtx; + + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + + GXSetCullMode(GX_CULL_NONE); + + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE); + + GXSetNumTexGens(0); + GXSetNumTevStages(1); + + GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + + GXSetBlendMode(GX_BM_NONE, GX_BL_ZERO, GX_BL_ZERO, GX_LO_NOOP); + + PSMTXTrans(mtx, 0.0f, 0.0f, 0.0f); + GXLoadPosMtxImm(mtx, 0); + + GXSetLineWidth(width, GX_TO_ZERO); + + // Draw the line + GXBegin(GX_LINES, GX_VTXFMT0, 2); { + GXPosition3f32(x0, y0, z); + GXColor1u32(*(u32*)&color); + GXPosition3f32(x1, y1, z); + GXColor1u32(*(u32*)&color); + } GXEnd(); +} + +namespace gui { + bool Component::update(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) { + bool touched = false; + + if (isVisible()) { + if (contain(x, y)) { + // Colliding with component + if (isPointed(point)) { + onMove(point, x, y); + mpManager->onEvent(getID(), EventHandler::ON_MOVE, point, data); + } + else { + setPointed(point, true); + onPoint(point); + mpManager->onEvent(getID(), EventHandler::ON_POINT, point, data); + } + + touched = true; + } + else { + // Not colliding with component + if (isPointed(point)) { + setPointed(point, false); + offPoint(point); + mpManager->onEvent(getID(), EventHandler::ON_OFFPOINT, point, data); + } + } + + // Pressing the drag button. + if (mbDragging[point]) { + onDrag(x - mDraggingPos[point].x, y - mDraggingPos[point].y); + mDraggingPos[point].x = x; + mDraggingPos[point].y = y; + mpManager->onEvent(getID(), EventHandler::ON_HOLD, point, data); + } + } + + if (hold == 0 && mbDragging[point]) { + mbDragging[point] = false; + } + + return touched; + } + + Manager::~Manager() { + ComponentID* componentID = (ComponentID*)nw4r::ut::List_GetFirst(&mComponents); + while (componentID) { + // Remove them from the list + nw4r::ut::List_Remove(&mComponents, componentID); + // Then delete them from memory. + if (mpAllocator) { + MEMFreeToAllocator(mpAllocator, componentID); + } + else { + delete componentID; + } + // Next component to kill! + componentID = (ComponentID*)nw4r::ut::List_GetFirst(&mComponents); + } + } + + void Manager::init() { + for (u32 i = 0; i < nw4r::ut::List_GetSize(&mComponents); i++) { + ComponentID* componentID = (ComponentID*)nw4r::ut::List_GetNth(&mComponents, (u16)i); + componentID->mpComponent->init(); + } + } + + void Manager::addComponent(Component* component) { + int id = component->getID(); + + component->setManager(this); + if (mpAllocator) { + void* allocCompID = MEMAllocFromAllocator(mpAllocator, sizeof(ComponentID)); + ComponentID* componentID = new(allocCompID) ComponentID(id, component); + nw4r::ut::List_Append(&mComponents, componentID); + } + else { + ComponentID* componentID = new ComponentID(id, component); + nw4r::ut::List_Append(&mComponents, componentID); + } + } + + Component* Manager::getComponent(u32 id) { + ComponentID* componentID = (ComponentID*)nw4r::ut::List_GetNth(&mComponents, (u16)id); + return componentID->mpComponent; + } + + bool Manager::update(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) { + bool touched = false; + + Component* triggerCom = NULL; + for (ComponentID* componentID = (ComponentID*)nw4r::ut::List_GetFirst(&mComponents); componentID != NULL; + componentID = (ComponentID*)nw4r::ut::List_GetNext(&mComponents, componentID)) { + + bool touchedCom = componentID->mpComponent->update(point, x, y, trig, hold, release, data); + + if (touchedCom) { + if (componentID->mpComponent->isTriggerTarger()) { + triggerCom = componentID->mpComponent; + } + touched = true; + } + } + + if (triggerCom) { + if (trig) { + Vec pos = {x, y, 0.0f}; + triggerCom->onTrig(point, trig, pos); + onEvent(triggerCom->getID(), EventHandler::ON_TRIG, point, data); + } + if (release) { + onEvent(triggerCom->getID(), EventHandler::ON_RELEASE, point, data); + } + } + + return touched; + } + + void Manager::calc() { + for (u32 i = 0; i < nw4r::ut::List_GetSize(&mComponents); i++) { + ComponentID* componentID = (ComponentID*)nw4r::ut::List_GetNth(&mComponents, (u16)i); + componentID->mpComponent->calc(); + } + } + + void Manager::draw() { + for (u32 i = 0; i < nw4r::ut::List_GetSize(&mComponents); i++) { + ComponentID* componentID = (ComponentID*)nw4r::ut::List_GetNth(&mComponents, (u16)i); + componentID->mpComponent->draw(); + } + } + + void Manager::setAllComponentTriggerTarget(bool bEnable) { + for (u32 i = 0; i < nw4r::ut::List_GetSize(&mComponents); i++) { + ComponentID* componentID = (ComponentID*)nw4r::ut::List_GetNth(&mComponents, (u16)i); + componentID->mpComponent->setTriggerTarget(bEnable); + } + } + + void Manager::setDraggingButton(u32 dragBtn) { + for (u32 i = 0; i < nw4r::ut::List_GetSize(&mComponents); i++) { + ComponentID* componentID = (ComponentID*)nw4r::ut::List_GetNth(&mComponents, (u16)i); + componentID->mpComponent->setDraggingButton(dragBtn); + } + } + + u32 PaneManager::suIDCounter = 0; + + PaneManager::~PaneManager() { + PaneComponentID* componentID = (PaneComponentID*)nw4r::ut::List_GetFirst(&mPaneComponents); + while (componentID) { + // Remove them from the list + nw4r::ut::List_Remove(&mPaneComponents, componentID); + // Then delete them from memory. + if (mpAllocator) { + MEMFreeToAllocator(mpAllocator, componentID->mpComponent); + MEMFreeToAllocator(mpAllocator, componentID); + } + else { + delete componentID->mpComponent; + delete componentID; + } + // Next component to kill! + componentID = (PaneComponentID*)nw4r::ut::List_GetFirst(&mPaneComponents); + } + } + + Component::~Component() {} // Wouldn't auto generate + + void PaneManager::createLayoutScene(const nw4r::lyt::Layout& layout) { + suIDCounter = 0; + walkInChildren(layout.GetRootPane()->GetChildList()); + } + + void PaneManager::walkInChildren(nw4r::lyt::PaneList& paneList) { + PaneComponent* component; + PaneComponentID* componentID; + + for (nw4r::lyt::PaneList::Iterator it = paneList.GetBeginIter(); it != paneList.GetEndIter(); it++) { + // Create the component and it's ID + if (mpAllocator) { + void* allocComp = MEMAllocFromAllocator(mpAllocator, sizeof(PaneComponent)); + void* allocCompID = MEMAllocFromAllocator(mpAllocator, sizeof(PaneComponentID)); + component = new(allocComp) PaneComponent(suIDCounter); + componentID = new(allocCompID) PaneComponentID(&*it, component); + } + else { + component = new PaneComponent(suIDCounter); + componentID = new PaneComponentID(&*it, component); + } + + // Append it + nw4r::ut::List_Append(&mPaneComponents, componentID); + suIDCounter++; + + component->setPane(&*it); + + // Trigger target for pictures panes + if (nw4r::ut::DynamicCast(&*it)) { + component->setTriggerTarget(true); + } + if (nw4r::ut::DynamicCast(&*it)) { + component->setTriggerTarget(true); + } + + addComponent(component); + walkInChildren(it->GetChildList()); + } + } + + PaneComponent* PaneManager::getPaneComponentByPane(nw4r::lyt::Pane* pane) { + for (u32 i = 0; i < nw4r::ut::List_GetSize(&mComponents); i++) { + PaneComponentID* componentID = (PaneComponentID*)nw4r::ut::List_GetNth(&mPaneComponents, (u16)i); + if (componentID->mpPane == pane) { + return componentID->mpComponent; + } + } + return NULL; + } + + void PaneManager::setAllBoundingBoxComponentTriggerTarget(bool bEnable) { + for (u32 i = 0; i < nw4r::ut::List_GetSize(&mComponents); i++) { + PaneComponentID* componentID = (PaneComponentID*)nw4r::ut::List_GetNth(&mPaneComponents, (u16)i); + if (nw4r::ut::DynamicCast(componentID->mpPane)) { + componentID->mpComponent->setTriggerTarget(bEnable); + } + } + } + + bool PaneComponent::contain(f32 x, f32 y) { + // Abort if no manager + if (mpManager == NULL) { + return false; + } + + // Abort if no draw info + const nw4r::lyt::DrawInfo* drawInfo = ((PaneManager*)mpManager)->getDrawInfo(); + if (drawInfo == NULL) { + return false; + } + + nw4r::math::MTX34 globalMtx; + PSMTXInverse(mpPane->GetGlobalMtx(), globalMtx); + + nw4r::math::VEC3 pos; + PSMTXMultVec(globalMtx, nw4r::math::VEC3(x, y, 0), pos); + + nw4r::ut::Rect rect = mpPane->GetPaneRect(*drawInfo); + + // If position is touching pane? + if (rect.left <= pos.x && pos.x <= rect.right + && rect.bottom <= pos.y && pos.y <= rect.top) { + return true; + } + else { + return false; + } + } + + void PaneComponent::draw() { + if (((PaneManager*)mpManager)->getDrawInfo()) { + nw4r::lyt::Size size = mpPane->GetSize(); + const nw4r::math::MTX34& mtx = mpPane->GetGlobalMtx(); + + f32 x = mtx.m[0][3]; + f32 y = mtx.m[1][3]; + + // Red line + GXColor color = {255, 0, 0, 255}; + if (mbPointed[0]) { + // If pointed, set to blue. + color.r = 0; + color.b = 255; + } + + drawLine_(x - size.width / 2, y - size.height / 2, x + size.width / 2, y - size.height / 2, 0, 8, color); + drawLine_(x + size.width / 2, y - size.height / 2, x + size.width / 2, y + size.height / 2, 0, 8, color); + drawLine_(x + size.width / 2, y + size.height / 2, x - size.width / 2, y + size.height / 2, 0, 8, color); + drawLine_(x - size.width / 2, y + size.height / 2, x - size.width / 2, y - size.height / 2, 0, 8, color); + } + } +} + +static bool is_visible(nw4r::lyt::Pane* pane) { + if (!pane->IsVisible()) { + return false; + } + if (pane->GetParent() == NULL) { + return true; + } + return is_visible(pane->GetParent()); +} + +bool gui::PaneComponent::isVisible() { + return is_visible(mpPane); +} diff --git a/src/layout/iplGuiManager.cpp b/src/layout/iplGuiManager.cpp new file mode 100644 index 00000000..4a8d0751 --- /dev/null +++ b/src/layout/iplGuiManager.cpp @@ -0,0 +1,69 @@ +#include "layout/iplGuiManager.h" + +#include "iplMath.h" + +#include "system/iplController.h" +#include "system/iplSystem.h" + +namespace ipl { + namespace gui { + #pragma sym on + void PaneManager::update() { + mbDoneUpdateWithCon = false; + for (int i = 0; i < WPAD_MAX_CONTROLLERS; i++) { + update(i); + } + } + + void PaneManager::update(int chan) { + controller::Interface* con = System::getController(chan); + + if (System::getFader()->getStatus() == EGG::Fader::STATUS_PREPARE_OUT) { + if (con && (!mbDisableCon || !mbDoneUpdateWithCon)) { + // Get Projection Area + nw4r::ut::Rect projRect(0.0f ,0.0f, 0.0f, 0.0f); + System::getProjectionRect(&projRect); + + // Get Cursor Position + ipl::math::VEC2 conProjPos = con->getDpdProjectionPos(); + if ((projRect.left > conProjPos.x || conProjPos.x > projRect.right) + || (projRect.top > conProjPos.y && conProjPos.y > projRect.bottom)) { + conProjPos.y = IPL_MATH_NULL_FLOAT; + conProjPos.x = IPL_MATH_NULL_FLOAT; + } + + // Update the base manager with controller input + ::gui::Manager::update(chan, + conProjPos.x, -conProjPos.y, + con->getTrigFlag() | con->getClassicTrigFlag(), + con->getHoldFlag() | con->getClassicHoldFlag(), + con->getReleaseFlag() | con->getClassicReleaseFlag(), + con); + + mbDoneUpdateWithCon = true; + } + else { + // Update the base manager without controller input + ::gui::Manager::update(chan, + IPL_MATH_NULL_FLOAT, IPL_MATH_NULL_FLOAT, + 0, + 0, + 0, + NULL); + } + } + } + + void PaneManager::setTriggerTarget(nw4r::lyt::Pane* pane, bool bEnable) { + ::gui::PaneComponent* component = getPaneComponentByPane(pane); + component->setTriggerTarget(bEnable); + } + + void PaneManager::initPane(nw4r::lyt::Pane* pane) { + ::gui::PaneComponent* component = getPaneComponentByPane(pane); + if (component) { + component->init(); + } + } + } +} diff --git a/src/layout/iplLayout.cpp b/src/layout/iplLayout.cpp index 1fe4938d..4c9caf48 100644 --- a/src/layout/iplLayout.cpp +++ b/src/layout/iplLayout.cpp @@ -152,7 +152,7 @@ namespace ipl { Object::~Object() { Animator* anim; - while (anim = (Animator*)nw4r::ut::List_GetNext(&mAnims, NULL), anim != NULL) { + while (anim = (Animator*)nw4r::ut::List_GetFirst(&mAnims), anim != NULL) { nw4r::ut::List_Remove(&mAnims, anim); delete anim; } @@ -161,7 +161,7 @@ namespace ipl { } void Object::init_(const char* fileName) { - nw4r::ut::List_Init(&mAnims, 36); + nw4r::ut::List_Init(&mAnims, (u16)offsetof(Animator, mLink)); attach_font(); diff --git a/src/scene/health/iplHealth.cpp b/src/scene/health/iplHealth.cpp index 06ed9e0b..91f60b77 100644 --- a/src/scene/health/iplHealth.cpp +++ b/src/scene/health/iplHealth.cpp @@ -175,8 +175,8 @@ namespace ipl { // Make all of the panes invisible for (int i = 0; i < ARRSIZE(has_pane_name); i++) { - pHasPane = mpLayout->getRoot()->FindPaneByName(has_pane_name[i]); - pPushPane = mpLayout->getRoot()->FindPaneByName(push_pane_name[i]); + pHasPane = mpLayout->findPane(has_pane_name[i]); + pPushPane = mpLayout->findPane(push_pane_name[i]); pHasPane->SetVisible(false); pPushPane->SetVisible(false); @@ -184,8 +184,8 @@ namespace ipl { // Make the necessary panes visible u32 country = getCountryIndex_(); - mpHasPane = mpLayout->getRoot()->FindPaneByName(has_pane_name[country]); - mpPushPane = mpLayout->getRoot()->FindPaneByName(push_pane_name[country]); + mpHasPane = mpLayout->findPane(has_pane_name[country]); + mpPushPane = mpLayout->findPane(push_pane_name[country]); mpHasPane->SetVisible(true); diff --git a/src/system/iplDialogWindow.cpp b/src/system/iplDialogWindow.cpp new file mode 100644 index 00000000..12fcfae1 --- /dev/null +++ b/src/system/iplDialogWindow.cpp @@ -0,0 +1,529 @@ +#include "system/iplDialogWindow.h" + +#include "system/iplSystem.h" + +#pragma sym on +namespace ipl { + char* DialogWindow::mscBtnName[3] = { + "B_BtnB", + #define BUTTON_ONE_MAX 1 + "B_BtnA", + #define BUTTON_TWO_MAX 2 + "B_BtnC" + #define BUTTON_THREE_MAX 3 + }; + + enum { + ANIM_CMN_DIALOG_IN = 0, + ANIM_CMN_DIALOG_OUT, + ANIM_CMN_MAIN, + }; + + enum { + ANIM_PROG_DIALOG_IN = 0, + ANIM_PROG_DIALOG_OUT, + ANIM_PROG_WAIT, + ANIM_PROG_PROGRESS, + }; + + enum { + ANIM_BTN1_DIALOG_IN = 0, + ANIM_BTN1_DIALOG_OUT, + ANIM_BTN1_FOCUS_BTN_ON, + ANIM_BTN1_FOCUS_BTN_OFF, + ANIM_BTN1_SELECT_BTN, + }; + + enum { + ANIM_BTN2_DIALOG_IN = 0, + ANIM_BTN2_DIALOG_OUT, + ANIM_BTN2_FOCUS_BTN_B_ON, + ANIM_BTN2_FOCUS_BTN_B_OFF, + ANIM_BTN2_SELECT_BTN_B, + ANIM_BTN2_FOCUS_BTN_A_ON, + ANIM_BTN2_FOCUS_BTN_A_OFF, + ANIM_BTN2_SELECT_BTN_A, + }; + + enum { + ANIM_BTN3_DIALOG_IN = 0, + ANIM_BTN3_DIALOG_OUT, + ANIM_BTN3_FOCUS_BTN_B_ON, + ANIM_BTN3_FOCUS_BTN_B_OFF, + ANIM_BTN3_SELECT_BTN_B, + ANIM_BTN3_FOCUS_BTN_A_ON, + ANIM_BTN3_FOCUS_BTN_A_OFF, + ANIM_BTN3_SELECT_BTN_A, + ANIM_BTN3_FOCUS_BTN_C_ON, + ANIM_BTN3_FOCUS_BTN_C_OFF, + ANIM_BTN3_SELECT_BTN_C, + }; + + enum { + ANIM_BTN2B_DIALOG_IN = 0, + ANIM_BTN2B_DIALOG_OUT, + ANIM_BTN2B_FOCUS_BTN_B_ON, + ANIM_BTN2B_FOCUS_BTN_B_OFF, + ANIM_BTN2B_SELECT_BTN_B, + ANIM_BTN2B_FOCUS_BTN_A_ON, + ANIM_BTN2B_FOCUS_BTN_A_OFF, + ANIM_BTN2B_SELECT_BTN_A, + }; + + enum { + DIALOG_STATE_NONE = 0, + DIALOG_STATE_FADE_IN, + DIALOG_STATE_NORMAL, + DIALOG_STATE_SELECT, + DIALOG_STATE_FADE_OUT, + DIALOG_STATE_5, + DIALOG_STATE_6, + }; + + DialogWindow::DialogWindow(EGG::Heap* heap) : + ::gui::EventHandler(), + mState(DIALOG_STATE_NONE), + mPressedBtn(DIALOG_BTN_NONE), + mLastPressedBtn(DIALOG_BTN_NONE), + mDialogType(DIALOG_TYPE_NONE), + unk_0x2C(0), + unk_0x34(0), + unk_0x35(0), + unk_0x36(0), + unk_0x37(0), + unk_0x38(0), + unk_0x3C(0), + unk_0x40(0), + mpCurDialog(NULL), + unk_0x7C(NULL), + unk_0x8C(-1), + unk_0x90(0), + unk_0x98(0), + unk_0x99(0) { + EGG::Allocator* allocator = new(heap, CLASS_HEAP) EGG::Allocator(heap, CLASS_HEAP); + nw4r::lyt::Layout::SetAllocator(allocator); + + init(); + + mpLayoutFile = System::getDlgWdwFile(); + + // Progress Dialog + mDialog[DIALOG_TYPE_PROG].mpLayout = new(heap, CLASS_HEAP) layout::Object(heap, mpLayoutFile, "arc", "my_DialogWindow_a0.brlyt"); + mDialog[DIALOG_TYPE_PROG].mpLayout->bindToGroup("my_DialogWindow_a0_DialogIn.brlan", "G_InOut", false); + mDialog[DIALOG_TYPE_PROG].mpLayout->bindToGroup("my_DialogWindow_a0_DialogOut.brlan", "G_InOut", false, false); + mDialog[DIALOG_TYPE_PROG].mpLayout->bindToGroup("my_DialogWindow_a0_Wait.brlan", "G_Wait", false, false); + mDialog[DIALOG_TYPE_PROG].mpLayout->bindToGroup("my_DialogWindow_a0_Progres.brlan", "G_Prog", false); + mDialog[DIALOG_TYPE_PROG].mpLayout->findPane("Wait_00")->SetVisible(false); + mDialog[DIALOG_TYPE_PROG].mpLayout->findPane("N_Prog")->SetVisible(false); + mDialog[DIALOG_TYPE_PROG].mpLayout->finishBinding(); + mDialog[DIALOG_TYPE_PROG].mpGui = NULL; // No user interaction for progress dialog + + // Dialog with one button + mDialog[DIALOG_TYPE_BTN1].mpLayout = new(heap, CLASS_HEAP) layout::Object(heap, mpLayoutFile, "arc", "my_DialogWindow_a1.brlyt"); + mDialog[DIALOG_TYPE_BTN1].mpLayout->bindToGroup("my_DialogWindow_a1_DialogIn.brlan", "G_InOut", false); + mDialog[DIALOG_TYPE_BTN1].mpLayout->bindToGroup("my_DialogWindow_a1_DialogOut.brlan", "G_InOut", false, false); + mDialog[DIALOG_TYPE_BTN1].mpLayout->bindToGroup("my_DialogWindow_a1_FocusBtn_on.brlan", "G_FocusBtnB", false, false); + mDialog[DIALOG_TYPE_BTN1].mpLayout->bindToGroup("my_DialogWindow_a1_FocusBtn_off.brlan", "G_FocusBtnB", false, false); + mDialog[DIALOG_TYPE_BTN1].mpLayout->bindToGroup("my_DialogWindow_a1_SelectBtn_Ac.brlan", "G_SelectBtnB", false, false); + mDialog[DIALOG_TYPE_BTN1].mpLayout->finishBinding(); + mDialog[DIALOG_TYPE_BTN1].mpGui = new(heap, CLASS_HEAP) gui::PaneManager(NULL, mDialog[DIALOG_TYPE_BTN1].mpLayout->getDrawInfo(), NULL, allocator); + mDialog[DIALOG_TYPE_BTN1].mpGui->createLayoutScene(*mDialog[DIALOG_TYPE_BTN1].mpLayout->getLayout()); + mDialog[DIALOG_TYPE_BTN1].mpGui->setAllComponentTriggerTarget(false); + for (int i = 0; i <= (BUTTON_ONE_MAX - 1); i++) { + mDialog[DIALOG_TYPE_BTN1].mpGui->setTriggerTarget(mDialog[DIALOG_TYPE_BTN1].mpLayout->findPane(mscBtnName[i]), true); + } + + // Dialog with two buttons + mDialog[DIALOG_TYPE_BTN2].mpLayout = new(heap, CLASS_HEAP) layout::Object(heap, mpLayoutFile, "arc", "my_DialogWindow_a2.brlyt"); + mDialog[DIALOG_TYPE_BTN2].mpLayout->bindToGroup("my_DialogWindow_a2_DialogIn.brlan", "G_InOut", false); + mDialog[DIALOG_TYPE_BTN2].mpLayout->bindToGroup("my_DialogWindow_a2_DialogOut.brlan", "G_InOut", false, false); + mDialog[DIALOG_TYPE_BTN2].mpLayout->bindToGroup("my_DialogWindow_a2_FocusBtn_on.brlan", "G_FocusBtnB", false, false); + mDialog[DIALOG_TYPE_BTN2].mpLayout->bindToGroup("my_DialogWindow_a2_FocusBtn_off.brlan", "G_FocusBtnB", false, false); + mDialog[DIALOG_TYPE_BTN2].mpLayout->bindToGroup("my_DialogWindow_a2_SelectBtn_Ac.brlan", "G_SelectBtnB", false, false); + mDialog[DIALOG_TYPE_BTN2].mpLayout->bindToGroup("my_DialogWindow_a2_FocusBtn_on.brlan", "G_FocusBtnA", false, false); + mDialog[DIALOG_TYPE_BTN2].mpLayout->bindToGroup("my_DialogWindow_a2_FocusBtn_off.brlan", "G_FocusBtnA", false, false); + mDialog[DIALOG_TYPE_BTN2].mpLayout->bindToGroup("my_DialogWindow_a2_SelectBtn_Ac.brlan", "G_SelectBtnA", false, false); + mDialog[DIALOG_TYPE_BTN2].mpLayout->finishBinding(); + mDialog[DIALOG_TYPE_BTN2].mpGui = new(heap, CLASS_HEAP) gui::PaneManager(NULL, mDialog[DIALOG_TYPE_BTN2].mpLayout->getDrawInfo(), NULL, allocator); + mDialog[DIALOG_TYPE_BTN2].mpGui->createLayoutScene(*mDialog[DIALOG_TYPE_BTN2].mpLayout->getLayout()); + mDialog[DIALOG_TYPE_BTN2].mpGui->setAllComponentTriggerTarget(false); + for (int i = 0; i <= (BUTTON_TWO_MAX - 1); i++) { + mDialog[DIALOG_TYPE_BTN2].mpGui->setTriggerTarget(mDialog[DIALOG_TYPE_BTN2].mpLayout->findPane(mscBtnName[i]), true); + } + + // Dialog with three buttons + mDialog[DIALOG_TYPE_BTN3].mpLayout = new(heap, CLASS_HEAP) layout::Object(heap, mpLayoutFile, "arc", "my_DialogWindow_a3.brlyt"); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_DialogIn.brlan", "G_InOut", false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_DialogOut.brlan", "G_InOut", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_FocusBtn_on.brlan", "G_FocusBtnB", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_FocusBtn_off.brlan", "G_FocusBtnB", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_SelectBtn_Ac.brlan", "G_SelectBtnB", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_FocusBtn_on.brlan", "G_FocusBtnA", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_FocusBtn_off.brlan", "G_FocusBtnA", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_SelectBtn_Ac.brlan", "G_SelectBtnA", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_FocusBtn_on.brlan", "G_FocusBtnC", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_FocusBtn_off.brlan", "G_FocusBtnC", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->bindToGroup("my_DialogWindow_a3_SelectBtn_Ac.brlan", "G_SelectBtnC", false, false); + mDialog[DIALOG_TYPE_BTN3].mpLayout->finishBinding(); + mDialog[DIALOG_TYPE_BTN3].mpGui = new(heap, CLASS_HEAP) gui::PaneManager(NULL, mDialog[DIALOG_TYPE_BTN3].mpLayout->getDrawInfo(), NULL, allocator); + mDialog[DIALOG_TYPE_BTN3].mpGui->createLayoutScene(*mDialog[DIALOG_TYPE_BTN3].mpLayout->getLayout()); + mDialog[DIALOG_TYPE_BTN3].mpGui->setAllComponentTriggerTarget(false); + for (int i = 0; i <= (BUTTON_THREE_MAX - 1); i++) { + mDialog[DIALOG_TYPE_BTN3].mpGui->setTriggerTarget(mDialog[DIALOG_TYPE_BTN3].mpLayout->findPane(mscBtnName[i]), true); + } + + // Dialog with two buttons (alternative) + mDialog[DIALOG_TYPE_BTN2B].mpLayout = new(heap, CLASS_HEAP) layout::Object(heap, mpLayoutFile, "arc", "my_DialogWindow_b.brlyt"); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->bindToGroup("my_DialogWindow_b_DialogIn.brlan", "G_InOut", false); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->bindToGroup("my_DialogWindow_b_DialogOut.brlan", "G_InOut", false, false); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->bindToGroup("my_DialogWindow_b_FocusBtn_on.brlan", "G_FocusBtnB", false, false); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->bindToGroup("my_DialogWindow_b_FocusBtn_off.brlan", "G_FocusBtnB", false, false); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->bindToGroup("my_DialogWindow_b_SelectBtn_Ac.brlan", "G_SelectBtnB", false, false); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->bindToGroup("my_DialogWindow_b_FocusBtn_on.brlan", "G_FocusBtnA", false, false); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->bindToGroup("my_DialogWindow_b_FocusBtn_off.brlan", "G_FocusBtnA", false, false); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->bindToGroup("my_DialogWindow_b_SelectBtn_Ac.brlan", "G_SelectBtnA", false, false); + mDialog[DIALOG_TYPE_BTN2B].mpLayout->finishBinding(); + mDialog[DIALOG_TYPE_BTN2B].mpGui = new(heap, CLASS_HEAP) gui::PaneManager(NULL, mDialog[DIALOG_TYPE_BTN2B].mpLayout->getDrawInfo(), NULL, allocator); + mDialog[DIALOG_TYPE_BTN2B].mpGui->createLayoutScene(*mDialog[DIALOG_TYPE_BTN2B].mpLayout->getLayout()); + mDialog[DIALOG_TYPE_BTN2B].mpGui->setAllComponentTriggerTarget(false); + for (int i = 0; i <= (BUTTON_TWO_MAX - 1); i++) { + mDialog[DIALOG_TYPE_BTN2B].mpGui->setTriggerTarget(mDialog[DIALOG_TYPE_BTN2B].mpLayout->findPane(mscBtnName[i]), true); + } + } + + void DialogWindow::init() { + for (int i = 0; i < DIALOG_BTN_TYPE_MAX; i++) { + unk_0x14[i] = 0; + } + + mLastPressedBtn = DIALOG_BTN_NONE; + unk_0x2C = 0; + mPressedBtn = DIALOG_BTN_NONE; + + unk_0x35 = false; + unk_0x36 = false; + unk_0x37 = false; + unk_0x38 = false; + + unk_0x3C = 0; + unk_0x40 = 0; + + if (mpCurDialog) { + if (mpCurDialog->mpLayout->getAnim(2)) { + mpCurDialog->mpLayout->getAnim(2)->initAnmFrame(); + } + if (mpCurDialog->mpLayout->getAnim(5)) { + mpCurDialog->mpLayout->getAnim(5)->initAnmFrame(); + } + if (mpCurDialog->mpGui) { + mpCurDialog->mpGui->init(); + } + } + } + + void DialogWindow::calc() { + unk_0x34 = false; + + switch (mState) { + case DIALOG_STATE_FADE_IN: { + stt_fadein(); + break; + } + case DIALOG_STATE_NORMAL: { + stt_normal(); + break; + } + case DIALOG_STATE_SELECT: { + stt_select(); + break; + } + case DIALOG_STATE_FADE_OUT: { + stt_fadeout(); + break; + } + case DIALOG_STATE_5: { + iplDialogWindow_81345880(); + break; + } + case DIALOG_STATE_6: { + iplDialogWindow_81345778(); + break; + } + } + + if (mpCurDialog) { + mpCurDialog->mpLayout->calc(); + } + } + + void DialogWindow::stt_fadein() { + if (!mpCurDialog->mpLayout->getAnim(ANIM_CMN_DIALOG_IN)->isPlaying()) { + mState = DIALOG_STATE_NORMAL; + } + } + + void DialogWindow::stt_select() { + s16 anim = -1; + + if (mDialogType == DIALOG_TYPE_BTN3) { + switch (mPressedBtn) { + case DIALOG_BTN3_A: { + anim = ANIM_BTN3_SELECT_BTN_A; + break; + } + case DIALOG_BTN3_B: { + anim = ANIM_BTN3_SELECT_BTN_B; + break; + } + case DIALOG_BTN3_C: { + anim = ANIM_BTN3_SELECT_BTN_C; + break; + } + } + } + else { + switch (mPressedBtn) { + case DIALOG_BTN_B: { + anim = ANIM_BTN2_SELECT_BTN_B; + break; + } + case DIALOG_BTN_A: { + anim = ANIM_BTN2_SELECT_BTN_A; + break; + } + } + } + + if (!mpCurDialog->mpLayout->getAnim(anim)->isPlaying()) { + mpCurDialog->mpLayout->playAnimFrame(ANIM_CMN_DIALOG_OUT); + + mState = DIALOG_STATE_FADE_OUT; + } + } + + void DialogWindow::stt_fadeout() { + if (!mpCurDialog->mpLayout->getAnim(ANIM_CMN_DIALOG_OUT)->isPlaying()) { + mLastPressedBtn = mPressedBtn; + mPressedBtn = DIALOG_BTN_NONE; + + if (mpCurDialog->mpGui) { + mpCurDialog->mpGui->setEventHandler(NULL); + } + mpCurDialog = NULL; + + mState = DIALOG_STATE_NONE; + + unk_0x8C = -1; + unk_0x90 = 0; + } + } + + void DialogWindow::set_alpha(nw4r::lyt::Pane* pane, u8 alpha) { + for (nw4r::lyt::PaneList::Iterator it = pane->GetChildList().GetBeginIter(); it != pane->GetChildList().GetEndIter(); it++) { + it->SetAlpha(alpha); + set_alpha(&*it, alpha); + } + } + + void DialogWindow::iplDialogWindow_81345778() { + if (mpCurDialog->mpGui) { + mpCurDialog->mpGui->update(); + } + + if (!mpCurDialog->mpLayout->isPlaying(ANIM_BTN2_SELECT_BTN_B) && !mpCurDialog->mpLayout->isPlaying(ANIM_BTN2_SELECT_BTN_A)) { + if (mPressedBtn == DIALOG_BTN_A) { + if (unk_0x14[DIALOG_BTN_TYPE_BTN2] != 0 && mpDialogProp[unk_0x90].unk_0x0C) { + mpCurDialog->mpLayout->playAnimFrame(ANIM_BTN2_FOCUS_BTN_A_ON); + } + } + else { + if (unk_0x14[DIALOG_BTN_TYPE_BTN1] != 0) { + mpCurDialog->mpLayout->playAnimFrame(ANIM_BTN1_FOCUS_BTN_ON); + } + } + mState = DIALOG_STATE_5; + } + } + + void DialogWindow::iplDialogWindow_81345880() { + if (mpCurDialog->mpGui) { + mpCurDialog->mpGui->update(); + } + + switch (unk_0x4C) { + case 0: { + unk_0x44 += unk_0x48; + if (unk_0x44 > 255) { + unk_0x44 = 255; + } + nw4r::lyt::TextBox* textBox = nw4r::ut::DynamicCast(mpCurDialog->mpLayout->findPane("T_Dialog")); + textBox->SetAlpha(unk_0x44); + + if (mpDialogProp[unk_0x90].unk_0x0C != mpDialogProp[unk_0x94].unk_0x0C + && mpDialogProp[unk_0x90].unk_0x0C == true) { + nw4r::lyt::Pane* pBtnA = mpCurDialog->mpLayout->findPane("N_BtnA"); + nw4r::lyt::Pane* pBtnAPic = mpCurDialog->mpLayout->findPane("N_BtnA_Pic"); + + pBtnA->SetVisible(true); + + if (unk_0x44) { + set_alpha(pBtnAPic, unk_0x44); + if (unk_0x44 == 255) { + unk_0x14[DIALOG_BTN_TYPE_BTN2] = 0; + mpCurDialog->mpLayout->getAnim(ANIM_BTN2_FOCUS_BTN_A_ON)->initAnmFrame(); + } + } + else { + set_alpha(pBtnAPic, 255); + pBtnA->SetVisible(false); + } + } + else { + if (mpDialogProp[unk_0x90].mLBtnMsgId != mpDialogProp[unk_0x94].mLBtnMsgId) { + nw4r::lyt::Pane* pPane = mpCurDialog->mpLayout->findPane("T_BtnA"); + pPane->SetAlpha(unk_0x44); + } + } + + if (mpDialogProp[unk_0x90].mRBtnMsgId != mpDialogProp[unk_0x94].mRBtnMsgId) { + nw4r::lyt::Pane* pPane = mpCurDialog->mpLayout->findPane("T_BtnB"); + pPane->SetAlpha(unk_0x44); + } + + if (mpDialogProp[unk_0x90].mpLayout != mpDialogProp[unk_0x94].mpLayout + && mpDialogProp[unk_0x90].mpLayout) { + set_alpha(mpDialogProp[unk_0x90].mpLayout->getRoot(), unk_0x44); + if (mpDialogProp[unk_0x90].unk_0x18 && unk_0x44 == 255) { + mpDialogProp[unk_0x90].mpLayout->playAnimFrame(ANIM_CMN_DIALOG_IN); + } + } + + if (unk_0x44 == 255) { + unk_0x4C = 2; + mState = DIALOG_STATE_NORMAL; + } + break; + } + case 1: { + unk_0x44 -= unk_0x48; + if (unk_0x44 < 0) { + unk_0x44 = 0; + } + nw4r::lyt::TextBox* textBox = nw4r::ut::DynamicCast(mpCurDialog->mpLayout->findPane("T_Dialog")); + textBox->SetAlpha(unk_0x44); + + if (mpDialogProp[unk_0x90].unk_0x0C != mpDialogProp[unk_0x94].unk_0x0C + && mpDialogProp[unk_0x94].unk_0x0C == true) { + nw4r::lyt::Pane* pBtnA = mpCurDialog->mpLayout->findPane("N_BtnA"); + nw4r::lyt::Pane* pBtnAPic = mpCurDialog->mpLayout->findPane("N_BtnA_Pic"); + + // Random calculations that are never used + { + vs32 an_int = 0x4330; + an_int = unk_0x44 ^ 0x8000; + // float stuff next + } + + if (unk_0x44) { + set_alpha(pBtnAPic, unk_0x44); + } + else { + set_alpha(pBtnAPic, 255); + pBtnA->SetVisible(false); + unk_0x14[DIALOG_BTN_TYPE_BTN2] = 0; + mpCurDialog->mpLayout->getAnim(ANIM_BTN2_FOCUS_BTN_A_ON)->initAnmFrame(); + } + } + else { + if (mpDialogProp[unk_0x90].mLBtnMsgId != mpDialogProp[unk_0x94].mLBtnMsgId) { + nw4r::lyt::Pane* pPane = mpCurDialog->mpLayout->findPane("T_BtnA"); + pPane->SetAlpha(unk_0x44); + } + } + + if (mpDialogProp[unk_0x90].mRBtnMsgId != mpDialogProp[unk_0x94].mRBtnMsgId) { + nw4r::lyt::Pane* pPane = mpCurDialog->mpLayout->findPane("T_BtnB"); + pPane->SetAlpha(unk_0x44); + } + + if (mpDialogProp[unk_0x90].mpLayout != mpDialogProp[unk_0x94].mpLayout + && mpDialogProp[unk_0x94].mpLayout) { + nw4r::lyt::Pane* pPane = mpDialogProp[unk_0x94].mpLayout->getRoot(); + if (unk_0x44) { + set_alpha(pPane, unk_0x44); + } + else { + if (mpDialogProp[unk_0x94].unk_0x18) { + mpDialogProp[unk_0x94].mpLayout->getAnim(0)->initAnmFrame(); + } + set_alpha(pPane, 255); + } + } + + if (unk_0x44 == 0) { + unk_0x4C = 0; + + set_message(mpDialogProp[unk_0x90].mMsgId); + set_rbtn_text(mpDialogProp[unk_0x90].mRBtnMsgId); + set_lbtn_text(mpDialogProp[unk_0x90].mLBtnMsgId); + + unk_0x7C = mpDialogProp[unk_0x90].mpLayout; + + unk_0x80.x = 0.0f; + unk_0x80.y = mpDialogProp[unk_0x90].mLayoutY; + } + break; + } + } + } + + BOOL DialogWindow::call(int type) { + BOOL result = FALSE; + + mDialogType = type; + + if (mState == DIALOG_STATE_NONE) { + mpCurDialog = &mDialog[type]; + + init(); + + if (mpCurDialog->mpGui) { + mpCurDialog->mpGui->setEventHandler(this); + } + + mpCurDialog->mpLayout->playAnimFrame(ANIM_CMN_DIALOG_IN); + + mState = DIALOG_STATE_FADE_IN; + + unk_0x4C = 2; + unk_0x7C = NULL; + + nw4r::lyt::Pane* pPane = mpCurDialog->mpLayout->findPane("Shade"); + if (pPane) { + if (unk_0x98) { + pPane->SetVisible(false); + } + else { + pPane->SetVisible(true); + } + } + + pPane = mpCurDialog->mpLayout->findPane("N_BtnA"); + if (pPane) { + if (unk_0x99) { + pPane->SetVisible(false); + } + else { + pPane->SetVisible(true); + } + } + + result = TRUE; + } + + unk_0x98 = false; + unk_0x99 = false; + + return result; + } +} diff --git a/src/system/iplErrorHandler.cpp b/src/system/iplErrorHandler.cpp index 16b2a36e..5666f152 100644 --- a/src/system/iplErrorHandler.cpp +++ b/src/system/iplErrorHandler.cpp @@ -115,7 +115,7 @@ namespace ipl { ErrorMsg.setResource(pMsg); // Set the on-screen text. - nw4r::lyt::TextBox* pTextBox = (nw4r::lyt::TextBox*)mpLayout->getRoot()->FindPaneByName("TextBox_00"); + nw4r::lyt::TextBox* pTextBox = (nw4r::lyt::TextBox*)mpLayout->findPane("TextBox_00"); pTextBox->SetString(ErrorMsg.getMessage(mMessageID)); // Prepare for error screen. diff --git a/src/system/iplNigaoe.cpp b/src/system/iplNigaoe.cpp index 5202ede5..8af44fc2 100644 --- a/src/system/iplNigaoe.cpp +++ b/src/system/iplNigaoe.cpp @@ -10,20 +10,20 @@ namespace ipl { namespace nigaoe { - Object::Object(EGG::Heap* heap, int width, int height, int faceId, MakeIconCallback callback, void* callBackWork) : + Object::Object(EGG::Heap* heap, int width, int height, int faceId, MakeIconCallback callback, void* callbackWork) : mFaceId(faceId), mpCharData(NULL), mCallBack(callback), - mpCallBackWork(callBackWork), + mpCallBackWork(callbackWork), mbCreated(false) { init(heap, width, height); } - Object::Object(EGG::Heap* heap, int width, int height, RFLiCharData* faceData, MakeIconCallback callback, void* callBackWork) : + Object::Object(EGG::Heap* heap, int width, int height, RFLiCharData* faceData, MakeIconCallback callback, void* callbackWork) : mFaceId(-1), mpCharData(faceData), mCallBack(callback), - mpCallBackWork(callBackWork), + mpCallBackWork(callbackWork), mbCreated(false) { init(heap, width, height); } diff --git a/src/system/iplNigaoeManager.cpp b/src/system/iplNigaoeManager.cpp index bb07b7ab..67f3843b 100644 --- a/src/system/iplNigaoeManager.cpp +++ b/src/system/iplNigaoeManager.cpp @@ -10,6 +10,8 @@ #include #include +#include + namespace ipl { namespace nigaoe { #define IPL_NIGAOE_ICON_MAX 10 @@ -19,22 +21,25 @@ namespace ipl { void* work = heap->alloc(RFLGetWorkSize(FALSE), BUFFER_HEAP); - mErrcode = RFLInitRes(work, mResFile->getBuffer(), mResFile->getLength(), FALSE); + mErrcode = RFLInitRes(work, + mResFile->getBuffer(), + mResFile->getLength(), + FALSE); - nw4r::ut::List_Init(&mObjects, 0x48); + nw4r::ut::List_Init(&mObjects, (u16)offsetof(Object, mLink)); { - // init strings + // Init strings unsigned char mac[NCD_MACADDRESS_LENGTH + 1]; mac[6] = mac[5] = mac[4] = mac[3] = mac[2] = mac[1] = mac[0] = 0; unsigned char temp[3]; temp[2] = temp[1] = temp[0] = 0; - // setup work + // Setup work unsigned char* ncd_mac = ncd::NCDSetting::getMacAddr(); - // get mac values + // Get mac values for (int i = 1; i < NCD_MACADDRESS_LENGTH; i++) { memcpy(temp, &ncd_mac[i * sizeof(temp)], sizeof(temp) - 1); mac[i] = strtol((char*)temp, NULL, 16); @@ -46,14 +51,20 @@ namespace ipl { Object* Manager::create(EGG::Heap* heap, int width, int height, int faceId, Object::MakeIconCallback callback, void* callbackWork) { // Create mii and append to list - Object* obj = new(heap, CLASS_HEAP) Object(heap, width, height, faceId, callback, callbackWork); + Object* obj = new(heap, CLASS_HEAP) Object(heap, + width, height, + faceId, + callback, callbackWork); nw4r::ut::List_Append(&mObjects, obj); return obj; } Object* Manager::create(EGG::Heap* heap, int width, int height, RFLiCharData* faceData, Object::MakeIconCallback callback, void* callbackWork) { // Create mii and append to list - Object* obj = new(heap, CLASS_HEAP) Object(heap, width, height, faceData, callback, callbackWork); + Object* obj = new(heap, CLASS_HEAP) Object(heap, + width, height, + faceData, + callback, callbackWork); nw4r::ut::List_Append(&mObjects, obj); return obj; } @@ -127,5 +138,3 @@ namespace ipl { } } } - - diff --git a/src/system/iplPointer.cpp b/src/system/iplPointer.cpp index 248f127c..83241c01 100644 --- a/src/system/iplPointer.cpp +++ b/src/system/iplPointer.cpp @@ -68,9 +68,9 @@ namespace ipl { // Update the scrolling cursor if (mIsScrolling >= POINT_SCROLLING) { - nw4r::lyt::Pane* pRootPane = mpLayout[LYT_SCROLLER_ID]->getRoot()->FindPaneByName("N_BArw"); - nw4r::lyt::Pane* pLengthPane = mpLayout[LYT_SCROLLER_ID]->getRoot()->FindPaneByName("W_BArw"); - nw4r::lyt::Pane* pOriginPane = mpLayout[LYT_SCROLLER_ID]->getRoot()->FindPaneByName("BArwBase"); + nw4r::lyt::Pane* pRootPane = mpLayout[LYT_SCROLLER_ID]->findPane("N_BArw"); + nw4r::lyt::Pane* pLengthPane = mpLayout[LYT_SCROLLER_ID]->findPane("W_BArw"); + nw4r::lyt::Pane* pOriginPane = mpLayout[LYT_SCROLLER_ID]->findPane("BArwBase"); // Arrow Position pRootPane->SetTranslate(mOriginPos); diff --git a/src/system/iplPointerCore.cpp b/src/system/iplPointerCore.cpp index 1d0b7eed..0494c584 100644 --- a/src/system/iplPointerCore.cpp +++ b/src/system/iplPointerCore.cpp @@ -27,14 +27,14 @@ namespace ipl { mpLayout = pointer->get_layout(mChan, mLayoutType); // Move - nw4r::lyt::Pane* pMovePane = mpLayout->getRoot()->FindPaneByName("N_Trans"); + nw4r::lyt::Pane* pMovePane = mpLayout->findPane("N_Trans"); pMovePane->SetTranslate(utility::get_cursor_pos(pController->getDpdProjectionPos())); // Rotation math::VEC2 cursorHorizon(pController->getHorizon()); math::VEC3 cursorRotateVec(0.f, 0.f, nw4r::math::Atan2Deg(-cursorHorizon.y, cursorHorizon.x)); - nw4r::lyt::Pane *pRotatePane = mpLayout->getRoot()->FindPaneByName("N_Rot"); - nw4r::lyt::Pane* pRotateShadowPane = mpLayout->getRoot()->FindPaneByName("N_SRot"); + nw4r::lyt::Pane *pRotatePane = mpLayout->findPane("N_Rot"); + nw4r::lyt::Pane* pRotateShadowPane = mpLayout->findPane("N_SRot"); pRotatePane->SetRotate(cursorRotateVec); pRotateShadowPane->SetRotate(cursorRotateVec); diff --git a/src/system/iplWarningHandler.cpp b/src/system/iplWarningHandler.cpp index 56a52afd..9cbe1a0b 100644 --- a/src/system/iplWarningHandler.cpp +++ b/src/system/iplWarningHandler.cpp @@ -1,5 +1,6 @@ #include "system/iplWarningHandler.h" +#include "system/iplDialogWindow.h" #include "system/iplSystem.h" #include "system/iplHomeButton.h" #include "system/iplMessage.h" @@ -34,8 +35,6 @@ namespace ipl { } BOOL WarningHandler::check() { - return mpDialog->isActive(); + return mpDialog->btnLastPressed(); } } - - diff --git a/src/utility/iplFrameController.cpp b/src/utility/iplFrameController.cpp index 0c608261..e6ae3cc7 100644 --- a/src/utility/iplFrameController.cpp +++ b/src/utility/iplFrameController.cpp @@ -11,7 +11,7 @@ namespace ipl { mSpeed = speed; - mState = 0; + mState = ANIM_STATE_READY; mbBounceBack = false;