From 49889ead2e09cf3311b2fcb6e3e022f80a0c6a94 Mon Sep 17 00:00:00 2001 From: Dean Southwood Date: Fri, 20 Dec 2024 21:01:15 +1100 Subject: [PATCH] misc Ogawa and Yamashita work --- configure.py | 10 +- include/AIPerf.h | 3 +- include/Demo.h | 4 +- include/DynParticle.h | 2 + include/GameCoreSection.h | 30 +- include/Generator.h | 38 +- include/Graphics.h | 2 +- include/Light.h | 2 + include/Navi.h | 2 +- include/P2D/Graph.h | 91 ++- include/P2D/Pane.h | 47 +- include/P2D/Picture.h | 2 + include/P2D/Screen.h | 18 +- include/P2D/Stream.h | 5 +- include/P2D/TextBox.h | 11 +- include/P2D/Window.h | 2 + include/PSU/LinkList.h | 39 +- include/PSU/Tree.h | 58 +- include/PUT/Geometry.h | 33 +- include/Pcam/CameraManager.h | 2 + include/SoundMgr.h | 4 +- include/Stream.h | 10 +- include/TAI/Amove.h | 13 +- include/UtEffect.h | 2 + include/WorkObject.h | 2 + include/math.h | 2 + include/system.h | 3 + include/teki.h | 4 +- include/zen/DrawAccount.h | 6 +- include/zen/DrawCommon.h | 48 +- include/zen/DrawContainer.h | 6 +- include/zen/DrawGameInfo.h | 3 +- include/zen/DrawHurryUp.h | 6 +- include/zen/ogFileChkSel.h | 29 +- include/zen/ogFileSelect.h | 6 +- include/zen/ogMap.h | 29 +- include/zen/ogStart.h | 19 +- include/zen/ogSub.h | 34 +- src/plugPikiKando/gameCoreSection.cpp | 204 +++++- src/plugPikiOgawa/ogFileChkSel.cpp | 414 +++--------- src/plugPikiOgawa/ogFileSelect.cpp | 2 +- src/plugPikiOgawa/ogMap.cpp | 301 +++------ src/plugPikiOgawa/ogPause.cpp | 39 -- src/plugPikiOgawa/ogStart.cpp | 355 +++-------- src/plugPikiOgawa/ogSub.cpp | 222 ++----- src/plugPikiOgawa/ogTest.cpp | 4 +- src/plugPikiYamashita/P2DGrafContext.cpp | 503 +++------------ src/plugPikiYamashita/P2DPane.cpp | 764 ++++------------------- src/plugPikiYamashita/P2DPerspGraph.cpp | 106 +--- src/plugPikiYamashita/P2DScreen.cpp | 2 +- src/plugPikiYamashita/P2DStream.cpp | 30 +- src/plugPikiYamashita/PSUList.cpp | 269 ++------ src/plugPikiYamashita/PUTRect.cpp | 240 +++---- src/plugPikiYamashita/TAIAmove.cpp | 23 + src/plugPikiYamashita/TAImar.cpp | 39 +- src/plugPikiYamashita/drawCommon.cpp | 33 +- src/plugPikiYamashita/drawGameInfo.cpp | 32 - src/sysCommon/stream.cpp | 4 +- 58 files changed, 1473 insertions(+), 2740 deletions(-) diff --git a/configure.py b/configure.py index 664c16a5..ac889cb3 100755 --- a/configure.py +++ b/configure.py @@ -736,7 +736,7 @@ def MatchingFor(*versions): Object(NonMatching, "plugPikiOgawa/ogMemChk.cpp"), Object(NonMatching, "plugPikiOgawa/ogDiary.cpp"), Object(NonMatching, "plugPikiOgawa/ogMenu.cpp"), - Object(NonMatching, "plugPikiOgawa/ogFileChkSel.cpp"), + Object(Matching, "plugPikiOgawa/ogFileChkSel.cpp"), Object(NonMatching, "plugPikiOgawa/ogMakeDefault.cpp"), Object(NonMatching, "plugPikiOgawa/ogTotalScore.cpp"), Object(NonMatching, "plugPikiOgawa/ogSave.cpp"), @@ -744,7 +744,7 @@ def MatchingFor(*versions): Object(NonMatching, "plugPikiOgawa/ogFileCopy.cpp"), Object(NonMatching, "plugPikiOgawa/ogFileDelete.cpp"), Object(NonMatching, "plugPikiOgawa/ogGraph.cpp"), - Object(NonMatching, "plugPikiOgawa/ogStart.cpp"), + Object(Matching, "plugPikiOgawa/ogStart.cpp"), Object(NonMatching, "plugPikiOgawa/ogCallBack.cpp"), ], }, @@ -776,15 +776,15 @@ def MatchingFor(*versions): Object(Matching, "plugPikiYamashita/TAIAmotion.cpp"), Object(NonMatching, "plugPikiYamashita/TAIAjudge.cpp"), Object(NonMatching, "plugPikiYamashita/TAIAattack.cpp"), - Object(NonMatching, "plugPikiYamashita/P2DGrafContext.cpp"), + Object(Matching, "plugPikiYamashita/P2DGrafContext.cpp"), Object(NonMatching, "plugPikiYamashita/P2DOrthoGraph.cpp"), Object(NonMatching, "plugPikiYamashita/P2DPerspGraph.cpp"), Object(NonMatching, "plugPikiYamashita/P2DPane.cpp"), Object(NonMatching, "plugPikiYamashita/P2DPicture.cpp"), Object(NonMatching, "plugPikiYamashita/P2DScreen.cpp"), Object(NonMatching, "plugPikiYamashita/P2DStream.cpp"), - Object(NonMatching, "plugPikiYamashita/PSUList.cpp"), - Object(NonMatching, "plugPikiYamashita/PUTRect.cpp"), + Object(Matching, "plugPikiYamashita/PSUList.cpp"), + Object(Matching, "plugPikiYamashita/PUTRect.cpp"), Object(NonMatching, "plugPikiYamashita/P2DWindow.cpp"), Object(NonMatching, "plugPikiYamashita/P2DTextBox.cpp"), Object(NonMatching, "plugPikiYamashita/P2DPrint.cpp"), diff --git a/include/AIPerf.h b/include/AIPerf.h index 3fad52c5..bb15c442 100644 --- a/include/AIPerf.h +++ b/include/AIPerf.h @@ -10,7 +10,6 @@ struct Menu; */ struct AIPerf { void clearCounts(); - void addMenu(Menu*); void toggleMoveType(Menu&); void toggleGeneratorMode(Menu&); void toggleBridge(Menu&); @@ -31,6 +30,8 @@ struct AIPerf { void flowerPiki(Menu&); void breakSluice(Menu&); + static void addMenu(Menu*); + // unused/inlined: void toggleAIGrid(Menu&); void toggleUpdateMgr(Menu&); diff --git a/include/Demo.h b/include/Demo.h index b19b7f0c..c8807486 100644 --- a/include/Demo.h +++ b/include/Demo.h @@ -76,6 +76,8 @@ struct DemoFlags { /** * @brief TODO + * + * @note Size: 0x1 (empty). */ struct DemoEventMgr { DemoEventMgr(); @@ -86,7 +88,7 @@ struct DemoEventMgr { void getEventName(int, int); void getSenderName(int); - // TODO: members + // no members }; extern DemoEventMgr* demoEventMgr; diff --git a/include/DynParticle.h b/include/DynParticle.h index 497613aa..a6199308 100644 --- a/include/DynParticle.h +++ b/include/DynParticle.h @@ -35,4 +35,6 @@ struct DynParticleHeap { // TODO: members }; +extern DynParticleHeap* particleHeap; + #endif diff --git a/include/GameCoreSection.h b/include/GameCoreSection.h index 37d61851..3e5d1057 100644 --- a/include/GameCoreSection.h +++ b/include/GameCoreSection.h @@ -3,12 +3,21 @@ #include "types.h" #include "Node.h" +#include "Light.h" struct Camera; struct Controller; struct Creature; +struct Font; struct MapMgr; +struct Menu; +struct Navi; struct RectArea; +struct SearchSystem; + +namespace zen { +struct DrawGameInfo; +} /** * @brief TODO @@ -63,7 +72,26 @@ struct GameCoreSection : public Node { // _00 = VTBL // _00-_20 = Node - // TODO: members + Controller* mController; // _20 + u8 _24[0x4]; // _24, unknown + u32 _28; // _28, unknown + u32 _2C; // _2C, unknown + u8 _30; // _30 + u8 _31; // _31 + u32 _34; // _34, unknown + u8 _38[0x4]; // _38, unknown + Menu* _3C; // _3C, unknown + u8 _40[0x50 - 0x40]; // _40, unknown + u32 _50; // _50, unknown + SearchSystem* _54; // _54 + Navi* mNavi; // _58 + u8 _5C[0x64 - 0x5C]; // _5C, unknown + MapMgr* mMapMgr; // _64 + Texture* _68; // _68 + Font* mBigFont; // _6C + Light _70; // _70 + u8 _2BC[0x344 - 0x2BC]; // _2BC + zen::DrawGameInfo* mDrawGameInfo; // _344 }; inline void clearCorePauseFlag() { GameCoreSection::pauseFlag = 0; } diff --git a/include/Generator.h b/include/Generator.h index 6a94d348..296da564 100644 --- a/include/Generator.h +++ b/include/Generator.h @@ -113,6 +113,8 @@ struct GeneratorCache { /** * @brief TODO + * + * @note Size: 0x4. */ struct GeneratorList { GeneratorList(); @@ -120,10 +122,14 @@ struct GeneratorList { void findGenerator(int); void createRamGenerators(); void updateUseList(); + + u8 _00[0x4]; // _04, unknown }; /** * @brief TODO + * + * @note Size: 0x60. */ struct GeneratorMgr : public Node { GeneratorMgr(); @@ -142,8 +148,9 @@ struct GeneratorMgr : public Node { void changeNaviPos(); // _00 = VTBL - // _00-_1C = Node - // TODO: members + // _00-_20 = Node + u8 _20[0x5C - 0x20]; // _20, unknown + u8 _5C; // _5C }; /** @@ -206,7 +213,7 @@ struct GenObjectActor : public GenObject { virtual void doRead(RandomAccessStream&); // _14 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); // _04 = VTBL // _00-_18 = GenObject @@ -229,7 +236,8 @@ struct GenObjectBoss : public GenObject { virtual void updateUseList(Generator*, int); // _24 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); + void readParameters(RandomAccessStream&); void writeParameters(RandomAccessStream&); @@ -247,7 +255,7 @@ struct GenObjectDebug : public GenObject { virtual void doRead(RandomAccessStream&); // _14 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); // _04 = VTBL // _00-_18 = GenObject @@ -270,7 +278,7 @@ struct GenObjectItem : public GenObject { virtual void updateUseList(Generator*, int); // _24 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); // _04 = VTBL // _00-_18 = GenObject @@ -312,7 +320,7 @@ struct GenObjectMapParts : public GenObject { virtual void render(Graphics&, Generator*); // _30 virtual void* birth(BirthInfo&); // _34 - void initialise(MapMgr*); + static void initialise(MapMgr*); // _04 = VTBL // _00-_18 = GenObject @@ -328,7 +336,7 @@ struct GenObjectNavi : public GenObject { virtual void doRead(RandomAccessStream&); // _14 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); // _04 = VTBL // _00-_18 = GenObject @@ -346,7 +354,7 @@ struct GenObjectPellet : public GenObject { virtual void updateUseList(Generator*, int); // _24 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); // _04 = VTBL // _00-_18 = GenObject @@ -386,7 +394,7 @@ struct GenObjectPlant : public GenObject { virtual void render(Graphics&, Generator*); // _30 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); // _04 = VTBL // _00-_18 = GenObject @@ -406,7 +414,7 @@ struct GenObjectTeki : public GenObject { virtual void updateUseList(Generator*, int); // _24 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); // _04 = VTBL // _00-_18 = GenObject @@ -427,7 +435,7 @@ struct GenObjectWorkObject : public GenObject { virtual void updateUseList(Generator*, int); // _24 virtual void* birth(BirthInfo&); // _34 - void initialise(); + static void initialise(); // _04 = VTBL // _00-_18 = GenObject @@ -647,5 +655,11 @@ struct GenAreaFactory : public Factory { }; extern GeneratorCache* generatorCache; +extern GeneratorList* generatorList; +extern GeneratorMgr* generatorMgr; +extern GeneratorMgr* onceGeneratorMgr; +extern GeneratorMgr* dailyGeneratorMgr; +extern GeneratorMgr* plantGeneratorMgr; +extern GeneratorMgr* limitGeneratorMgr; #endif diff --git a/include/Graphics.h b/include/Graphics.h index eb2e70e8..69646bc5 100644 --- a/include/Graphics.h +++ b/include/Graphics.h @@ -55,7 +55,7 @@ struct Graphics { Light mLight; // _10 u8 _25C[0x2E4 - 0x25C]; // _25C, unknown Camera* mCamera; // _2E4 - u32 _2E8; // _2E8 + u32 _2E8; // _2E8 u8 _2EC[0x30C - 0x2EC]; // _2EC, unknown int mScreenWidth; // _30C, maybe viewport width? int mScreenHeight; // _310, maybe viewport height? diff --git a/include/Light.h b/include/Light.h index b8730361..de14d9dc 100644 --- a/include/Light.h +++ b/include/Light.h @@ -70,6 +70,8 @@ struct LFlareGroup : public CoreNode { /** * @brief TODO + * + * @note Size: 0x24C? */ struct Light : public CoreNode { Light(); diff --git a/include/Navi.h b/include/Navi.h index e2e7c0a7..17b0ed75 100644 --- a/include/Navi.h +++ b/include/Navi.h @@ -123,7 +123,7 @@ struct Navi : public Creature, public PaniAnimKeyListener, public PelletView { u8 _2E0; // _2E0 bool mIsPellet; // _2E1, is lying down/carryable Kontroller* mKontroller; // _2E4 - u8 _2E8[0x2EC - 0x2E8]; // _2E8, unknown + Camera* mNaviCamera; // _2E8, could be CullFrustum*, but probably Camera* Vector3f* mLookAtPosPtr; // _2EC u8 _2F0; // _2F0 u8 _2F1[0x314 - 0x2F1]; // _2F1, unknown diff --git a/include/P2D/Graph.h b/include/P2D/Graph.h index 9c392bc5..8ded1ea9 100644 --- a/include/P2D/Graph.h +++ b/include/P2D/Graph.h @@ -2,30 +2,41 @@ #define _P2D_GRAPH_H #include "types.h" +#include "PUT/Geometry.h" +#include "Matrix4f.h" +#include "Colour.h" -struct Colour; -struct Matrix4f; -struct PUTRect; -struct PUTPoint; +/** + * @brief TODO + */ +enum P2DGrafType { + P2DGRAF_Ortho = 1, + P2DGRAF_Persp = 2, +}; /** * @brief TODO + * + * @note Size: 0xD4. */ struct P2DGrafContext { - P2DGrafContext(int, int, int, int); + P2DGrafContext(int x0, int y0, int width, int height); P2DGrafContext(const PUTRect&); // unused/inlined - virtual ~P2DGrafContext(); // _08 - virtual void place(const PUTRect&); // _0C - virtual void place(int, int, int, int); // _10 - virtual void setPort(); // _14 - virtual void setup2D(); // _18 - virtual void setScissor(); // _1C - virtual void setLookat(); // _20 - - void scissor(const PUTRect&); + virtual ~P2DGrafContext() { } // _08 + virtual void place(const PUTRect& pos); // _0C + virtual void place(int x0, int y0, int width, int height) // _10 + { + place(PUTRect(x0, y0, x0 + width, y0 + height)); + } + virtual void setPort(); // _14 + virtual void setup2D(); // _18 + virtual void setScissor(); // _1C + virtual void setLookat() { } // _20 + + void scissor(const PUTRect& pos); void setColor(Colour&, Colour&, Colour&, Colour&); - void setLineWidth(u8); + void setLineWidth(u8 width); // unused/inlined: void fillBox(const PUTRect&); @@ -37,32 +48,58 @@ struct P2DGrafContext { void polylineTo(PUTPoint*, int); void polylineTo(int*, int); - // TODO: members + // _00 = VTBL + int mGrafType; // _04, see P2DGrafType enum + PUTRect _08; // _08 + PUTRect _10; // _10 + Colour _18; // _18 + Colour _1C; // _1C + Colour _20; // _20 + Colour _24; // _24 + u8 mLineWidth; // _28 + u16 _2A; // _2A + u16 _2C; // _2C + u8 _2E[0x70 - 0x2E]; // _2E, unknown + Matrix4f _70; // _70 + int _B0; // _B0 + int _B4; // _B4 + int _B8; // _B8 + int _BC; // _BC + int _C0; // _C0 + int _C4; // _C4 + int _C8; // _C8 + int _CC; // _CC + int _D0; // _D0 }; /** * @brief TODO + * + * @note Size: 0xE4. */ struct P2DPerspGraph : public P2DGrafContext { - P2DPerspGraph(int, int, int, int, f32, f32, f32); + P2DPerspGraph(int x0, int y0, int width, int height, f32 fovy, f32, f32); P2DPerspGraph(); // unused/inlined P2DPerspGraph(const PUTRect&, f32, f32, f32); // unused/inlined - virtual ~P2DPerspGraph(); // _08 (weak) - virtual void setPort(); // _14 - virtual void setLookat(); // _20 + virtual ~P2DPerspGraph() { } // _08 (weak) + virtual void setPort(); // _14 + virtual void setLookat(); // _20 - void set(f32, f32, f32); - void setFovy(f32); + void set(f32 fovy, f32, f32); + void setFovy(f32 fovy); void makeLookat(); // unused/inlined: void getMatrix(Matrix4f&); void setDistance(f32); - // _00 = VTBL? - // _00-_?? = P2DGrafContext - // TODO: members + // _00 = VTBL + // _00-_D4 = P2DGrafContext + f32 mFovy; // _D4 + f32 _D8; // _D8 + f32 _DC; // _DC + f32 _E0; // _E0, lookat? }; /** @@ -83,8 +120,8 @@ struct P2DOrthoGraph : public P2DGrafContext { void setOrtho(const PUTRect&, int, int); void setOrigin(int, int); - // _00 = VTBL? - // _00-_?? = P2DGrafContext + // _00 = VTBL + // _00-_D4 = P2DGrafContext // TODO: members }; diff --git a/include/P2D/Pane.h b/include/P2D/Pane.h index 221dbc56..f4d4c5d1 100644 --- a/include/P2D/Pane.h +++ b/include/P2D/Pane.h @@ -3,22 +3,23 @@ #include "types.h" #include "zen/CallBack.h" +#include "PSU/Tree.h" +#include "PUT/Geometry.h" +#include "Vector.h" +#include "Matrix4f.h" #include "P2D/Util.h" +#include "Delegate.h" struct P2DGrafContext; struct P2DPane; -struct PUTRect; -struct Matrix4f; struct RandomAccessStream; -struct Vector3f; /** * @brief TODO - * - * @note Might be a struct? */ enum P2DPaneType { - + PANETYPE_Screen = 8, + PANETYPE_Unk16 = 16, }; /** @@ -46,6 +47,8 @@ struct P2DPaneCallBack : public zen::CallBack1, public P2DPaneCallBack /** * @brief TODO + * + * @note Size: 0xEC. */ struct P2DPane { P2DPane(); @@ -65,25 +68,51 @@ struct P2DPane { virtual void resize(int, int); // _28 virtual void drawSelf(int, int); // _2C virtual void drawSelf(int, int, Matrix4f*); // _30 - virtual void search(u32, bool); // _34 + virtual P2DPane* search(u32, bool); // _34 virtual void makeMatrix(int, int); // _38 void setCallBack(P2DPaneCallBack*); void printTagName(bool); void update(); void draw(int, int, const P2DGrafContext*, bool); - void clip(const PUTRect&); + bool clip(const PUTRect&); void loadChildResource(); void rotate(P2DRotateAxis, f32); void hide(); + inline u16 getPaneType() const { return mPaneType; } + inline PSUTree* getPaneTree() { return &mPaneTree; } + + // don't ask. pls fix later if there's a better way to generate this rlwimi + inline void setFlag(u32 newFlag, u32 shift, u32 size) + { + u32 flag = newFlag; + _0C = __rlwimi((int)_0C, flag, shift, 32 - shift - size, 31 - shift); + } + // unused/inlined: void init(); void setCullBack(bool); // _00 = VTBL P2DPaneCallBack* mCallBack; // _04 - // TODO: members + u16 mPaneType; // _08, see P2DPaneType enum + u16 _0A; // _0A, maybe? + u8 _0C; // _0C, flag of some description + u32 mTagName; // _10, unknown + f32 mPaneZ; // _14 + PUTRect _18; // _18 + PUTRect _20; // _20 + PUTRect _28; // _28 + PUTRect _30; // _30 + u8 _38[0x78 - 0x38]; // _38, unknown + Matrix4f _78; // _78 + u16 _B8; // _B8 + u16 _BA; // _BA + f32 _BC; // _BC + Vector3f _C0; // _C0 + int mCullMode; // _CC + PSUTree mPaneTree; // _D0 }; #endif diff --git a/include/P2D/Picture.h b/include/P2D/Picture.h index 18da6bb1..b66f8da4 100644 --- a/include/P2D/Picture.h +++ b/include/P2D/Picture.h @@ -9,6 +9,8 @@ struct Texture; /** * @brief TODO + * + * @note Size: 0x114. */ struct P2DPicture : public P2DPane { P2DPicture(P2DPane*, RandomAccessStream*, u16); diff --git a/include/P2D/Screen.h b/include/P2D/Screen.h index f4ddb117..23149b2f 100644 --- a/include/P2D/Screen.h +++ b/include/P2D/Screen.h @@ -7,11 +7,21 @@ /** * @brief TODO + * + * @note Size: 0xF8. */ struct P2DScreen : public P2DPane { + inline P2DScreen() + : P2DPane(nullptr, PANETYPE_Screen, true, 'root', PUTRect(640, 480)) + { + _EC = 0; + _F0 = 0; + _F4 = 0; + } + virtual void loadResource(); // _08 virtual ~P2DScreen(); // _10 - virtual void search(u32, bool); // _34 + virtual P2DPane* search(u32, bool); // _34 virtual void makeUserPane(u16, P2DPane*, RandomAccessStream*); // _3C void update(); @@ -25,8 +35,10 @@ struct P2DScreen : public P2DPane { void stop(); // _00 = VTBL - // _00-_?? = P2DPane - // TODO: members + // _00-_EC = P2DPane + u8 _EC; // _EC + u32 _F0; // _F0, unknown + u32 _F4; // _F4, unknown }; #endif diff --git a/include/P2D/Stream.h b/include/P2D/Stream.h index 50544305..435521f3 100644 --- a/include/P2D/Stream.h +++ b/include/P2D/Stream.h @@ -2,18 +2,19 @@ #define _P2D_STREAM_H #include "types.h" +#include /** * @brief TODO */ struct P2DStream { - void getResource(int); + void* getResource(int); void align(int); // unused/inlined: ~P2DStream(); - // TODO: members + RandomAccessStream* mStream; // _00 }; #endif diff --git a/include/P2D/TextBox.h b/include/P2D/TextBox.h index 2c3310ba..d6419ae4 100644 --- a/include/P2D/TextBox.h +++ b/include/P2D/TextBox.h @@ -9,6 +9,8 @@ struct Texture; /** * @brief TODO + * + * @note Size: 0x118. */ struct P2DTextBox : public P2DPane { P2DTextBox(P2DPane*, RandomAccessStream*, u16); @@ -19,9 +21,14 @@ struct P2DTextBox : public P2DPane { virtual void drawSelf(int, int); // _2C virtual void drawSelf(int, int, Matrix4f*); // _30 + inline char* getText() const { return mText; } + inline void setText(char* text) { mText = text; } + // _00 = VTBL - // _00-_?? = P2DPane - // TODO: members + // _00-_EC = P2DPane + u8 _EC[0x10C - 0xEC]; // _EC, unknown + char* mText; // _10C + // TODO: members }; #endif diff --git a/include/P2D/Window.h b/include/P2D/Window.h index 3f6e3513..1f1066b4 100644 --- a/include/P2D/Window.h +++ b/include/P2D/Window.h @@ -7,6 +7,8 @@ /** * @brief TODO + * + * @note Size: 0x12C. */ struct P2DWindow : public P2DPane { diff --git a/include/PSU/LinkList.h b/include/PSU/LinkList.h index b1065b70..f6d5752f 100644 --- a/include/PSU/LinkList.h +++ b/include/PSU/LinkList.h @@ -3,6 +3,9 @@ #include "types.h" +struct PSUPtrList; +struct PSUPtrLink; + /** * @brief TODO */ @@ -11,22 +14,29 @@ struct PSUPtrLink { ~PSUPtrLink(); - // TODO: members + void* getObjectPtr() const { return mObject; } + PSUPtrLink* getNext() const { return mNext; } + + void* mObject; // _00 + PSUPtrList* mList; // _04 + PSUPtrLink* mPrev; // _08 + PSUPtrLink* mNext; // _0C }; /** * @brief TODO */ struct PSUPtrList { + PSUPtrList() { initiate(); } PSUPtrList(bool); // unused/inlined ~PSUPtrList(); void initiate(); - void append(PSUPtrLink*); - void remove(PSUPtrLink*); + bool append(PSUPtrLink*); + bool remove(PSUPtrLink*); - void getFirstLink() const; + PSUPtrLink* getFirstLink() const { return mHead; } // unused/inlined: void setFirst(PSUPtrLink*); @@ -34,18 +44,25 @@ struct PSUPtrList { void insert(PSUPtrLink*, PSUPtrLink*); void getNthLink(u32) const; - // TODO: members + PSUPtrLink* mHead; // _00 + PSUPtrLink* mTail; // _04 + u32 mLinkCount; // _08 }; /** * @brief TODO - * - * @note Does this inherit from PSUPtrLink? Check later. */ template -struct PSULink { +struct PSULink : public PSUPtrLink { + inline PSULink(T* object) + : PSUPtrLink((void*)object) + { + } + ~PSULink(); // unused/inlined + inline T* getObject() const { return (T*)getObjectPtr(); } + // TODO: members }; @@ -55,9 +72,13 @@ struct PSULink { * @note Does this inherit from PSUPtrList? Check later. */ template -struct PSUList { +struct PSUList : public PSUPtrList { ~PSUList(); // unused/inlined + inline PSULink* getFirst() const { return (PSULink*)getFirstLink(); } + + bool append(PSULink* link) { return PSUPtrList::append((PSUPtrLink*)link); } + // TODO: members }; diff --git a/include/PSU/Tree.h b/include/PSU/Tree.h index 0be584ed..572eeba7 100644 --- a/include/PSU/Tree.h +++ b/include/PSU/Tree.h @@ -2,18 +2,68 @@ #define _PSU_TREE_H #include "types.h" +#include "PSU/LinkList.h" /** * @brief TODO + * + * @note Size: 0x1C. */ template -struct PSUTree { +struct PSUTree : public PSUList, public PSULink { + inline PSUTree(T* owner) + : PSUList() + , PSULink(owner) + { + } + ~PSUTree(); - PSUTree* getFirstChild() const; - PSUTree* getEndChild() const; + PSUTree* getFirstChild() const { return (PSUTree*)getFirst(); } + PSUTree* getEndChild() const { return nullptr; } + PSUTree* getNextChild() const { return (PSUTree*)mNext; } + T* getObject() const { return (T*)mObject; } + + // PSUList at _00 + // PSULink at _0C +}; + +/** + * @brief TODO + */ +template +struct PSUTreeIterator { + PSUTreeIterator() + : mTree(nullptr) + { + } + PSUTreeIterator(PSUTree* tree) + : mTree(tree) + { + } + + bool operator==(PSUTree* other) { return mTree == other; } + bool operator!=(const PSUTree* other) const { return mTree != other; }; + + inline PSUTreeIterator operator++(int) + { + PSUTreeIterator prev = *this; + mTree = mTree->getNextChild(); + return prev; + } + + inline PSUTreeIterator& operator++() + { + mTree = mTree->getNextChild(); + return *this; + } + + T& operator*() { return *(getObject()); } + T* operator->() const { return mTree->getObject(); } + + T* getObject() const { return mTree->getObject(); } - // TODO: members + PSUTree* mTree; // _00 }; #endif diff --git a/include/PUT/Geometry.h b/include/PUT/Geometry.h index 9642f687..324f9d8d 100644 --- a/include/PUT/Geometry.h +++ b/include/PUT/Geometry.h @@ -2,35 +2,46 @@ #define _PUT_GEOMETRY_H #include "types.h" +#include "Stream.h" /** * @brief TODO */ struct PUTPoint { - // TODO: members + s16 x, y; // _00, _02 }; /** * @brief TODO + * + * @note Size: 0x8. */ struct PUTRect { - void set(int, int, int, int); - void copy(const PUTRect&); - void add(int, int); - void intersect(const PUTRect&); - void move(int, int); - void resize(int, int); + PUTRect() { set(0, 0, 0, 0); } + PUTRect(int maxX, int maxY) { set(0, 0, maxX, maxY); } + PUTRect(int x0, int y0, int x1, int y1) { set(x0, y0, x1, y1); } + + PUTRect(const PUTRect& other) { copy(other); } + + void set(int x0, int y0, int x1, int y1); + void copy(const PUTRect& other); + void add(int x, int y); + bool intersect(const PUTRect& other); + void move(int newMinX, int newMinY); + void resize(int width, int height); void normalize(); - void isEmpty() const; - s16 getWidth() const; - s16 getHeight() const; + bool isEmpty() const; + + int getWidth() const { return mMax.x - mMin.x; } + int getHeight() const { return mMax.y - mMin.y; } // unused/inlined: void add(const PUTPoint&); void move(const PUTPoint&); void reform(int, int, int, int); - // TODO: members + PUTPoint mMin; // _00 + PUTPoint mMax; // _04 }; #endif diff --git a/include/Pcam/CameraManager.h b/include/Pcam/CameraManager.h index 42aa9e2e..ec5f040e 100644 --- a/include/Pcam/CameraManager.h +++ b/include/Pcam/CameraManager.h @@ -52,4 +52,6 @@ struct PcamCameraManager : public Node { PeveEvent** mVibrationEvents; // _2C, array of events indexed by mCurrEventIndex }; +extern PcamCameraManager* cameraMgr; + #endif diff --git a/include/SoundMgr.h b/include/SoundMgr.h index a024ebe2..bf7edeb5 100644 --- a/include/SoundMgr.h +++ b/include/SoundMgr.h @@ -155,8 +155,6 @@ struct SeSystem { void calcCameraPos(Vector3f&, Vector3f&); void getJacID(int); void exitCourse(); - void playSysSe(int); - void stopSysSe(int); void stopPlayerSe(int); // unused/inlined: @@ -165,6 +163,8 @@ struct SeSystem { void getEventType(int); void isLoopType(int); + static void playSysSe(int); + static void stopSysSe(int); static void playPlayerSe(int); // TODO: members diff --git a/include/Stream.h b/include/Stream.h index 2e41fb28..46afbaa9 100644 --- a/include/Stream.h +++ b/include/Stream.h @@ -16,7 +16,7 @@ struct Stream { char* mPath; // _00 virtual int readInt(); // _08 - virtual char readByte(); // _0C + virtual u8 readByte(); // _0C virtual s16 readShort(); // _10 virtual f32 readFloat(); // _14 virtual void readString(char*, int); // _18 @@ -58,6 +58,14 @@ struct RandomAccessStream : public Stream { } } + inline BOOL checkInput() + { + if (readByte() == 0) { + return false; + } + return true; + } + // unused/inlined: void writeTo(int, void*, int); diff --git a/include/TAI/Amove.h b/include/TAI/Amove.h index 959ff8ef..96a4afdf 100644 --- a/include/TAI/Amove.h +++ b/include/TAI/Amove.h @@ -440,10 +440,12 @@ struct TAIAflyingToGoal : public TAIAreserveMotion { */ struct FlyingDistance { - virtual f32 getOffset(Teki&); // _08 - - // _00 = VTBL + // _0C = VTBL + f32 _00; // _00 f32 mOffset; // _04 + f32 _08; // _08 + + virtual f32 getOffset(Teki&); // _08 }; /** @@ -451,7 +453,7 @@ struct FlyingDistance { */ struct TAIAflyingDistance : public TaiAction, public FlyingDistance { inline TAIAflyingDistance() // TODO: this is a guess - : TaiAction(-1) + : TaiAction(12) { } @@ -462,8 +464,7 @@ struct TAIAflyingDistance : public TaiAction, public FlyingDistance { // _04 = VTBL 1 // _08 = VTBL 2 // _00-_08 = TaiAction - // _08-_10 = FlyingDistance - // TODO: members + // _08-_18 = FlyingDistance }; /** diff --git a/include/UtEffect.h b/include/UtEffect.h index 3941416b..c29da76a 100644 --- a/include/UtEffect.h +++ b/include/UtEffect.h @@ -311,4 +311,6 @@ struct UtEffectMgr { // TODO: members }; +extern UtEffectMgr* utEffectMgr; + #endif diff --git a/include/WorkObject.h b/include/WorkObject.h index 25b8803f..12664f3b 100644 --- a/include/WorkObject.h +++ b/include/WorkObject.h @@ -192,4 +192,6 @@ struct HinderRock : public WorkObject { Vector3f _460[2]; // _460 }; +extern WorkObjectMgr* workObjectMgr; + #endif diff --git a/include/math.h b/include/math.h index 9917c50e..707935d3 100644 --- a/include/math.h +++ b/include/math.h @@ -76,6 +76,8 @@ static inline f32 sqrtf(f32 x) static inline f32 absF(f32 val) { return __fabs(val); } +static inline f32 absVal(f32 val) { return (val < 0.0f) ? -val : val; } + #ifdef __cplusplus // Pikmin-specific global math functions struct Vector3f; diff --git a/include/system.h b/include/system.h index 9d18c13c..99c698e4 100644 --- a/include/system.h +++ b/include/system.h @@ -365,6 +365,9 @@ struct DVDStream : public RandomAccessStream { bool mIsFileOpen; // _4C, trigger to do DVDClose on close() }; +extern int glnWidth; +extern int glnHeight; + static inline f32 randFloat() { return System::getRand(1.0f); } static inline f32 randFloat(f32 max) { return max * System::getRand(1.0f); } static inline f32 randBalanced(f32 centre) { return System::getRand(1.0f) - centre; } diff --git a/include/teki.h b/include/teki.h index 5c69200f..0d67f381 100644 --- a/include/teki.h +++ b/include/teki.h @@ -474,7 +474,9 @@ struct YTeki : public NTeki { u32 _470; // _470, unknown u8 _474[0x4]; // _474, TODO: work out members f32 _478; // _478 - u8 _47C[0x498 - 0x47C]; // _47C, TODO: work out members + u8 _47C[0x490 - 0x47C]; // _47C, TODO: work out members + f32 _490; // _490 + u8 _494[0x4]; // _494, unknown u32 _498[8]; // _498, array of something, probably not u32s u8 _4B8[0x4C8 - 0x4B8]; // _4B8, TODO: work out members u8 _4C8; // _4C8, bitflag? diff --git a/include/zen/DrawAccount.h b/include/zen/DrawAccount.h index 9a8f0960..3f6b143c 100644 --- a/include/zen/DrawAccount.h +++ b/include/zen/DrawAccount.h @@ -17,6 +17,8 @@ struct AccountData { /** * @brief TODO + * + * @note Size: 0x120. */ struct DrawAccount : public DrawScreen { @@ -29,9 +31,11 @@ struct DrawAccount : public DrawScreen { // unused/inlined: - // TODO: members + u8 _00[0x120]; // _00, unknown }; } // namespace zen +extern zen::DrawAccount* accountWindow; + #endif diff --git a/include/zen/DrawCommon.h b/include/zen/DrawCommon.h index 5eb28435..05ce6ddd 100644 --- a/include/zen/DrawCommon.h +++ b/include/zen/DrawCommon.h @@ -2,7 +2,7 @@ #define _ZEN_DRAWCOMMON_H #include "types.h" -#include "P2D/Pane.h" +#include "P2D/Screen.h" struct Graphics; @@ -24,29 +24,8 @@ struct DrawScreen { // unused/inlined: ~DrawScreen(); - // TODO: members -}; - -/** - * @brief TODO - */ -struct P2DPaneLibrary { - - void makeResident(P2DPane*); - void setFamilyAlpha(P2DPane*, u8); - void setAlpha(P2DPane*, u8); - void setFamilyMirror(P2DPane*, P2DMirror); - void getParentPane(P2DPane*); - void getWorldPos(P2DPane*, int*, int*); - void changeParent(P2DPane*, P2DPane*); - - // unused/inlined: - void setMirror(P2DPane*, P2DMirror); - void printTag(P2DPane*); - void printUseTexName(P2DPane*, IDelegate1*); - void printUseTexName(char*, IDelegate1*); - - // TODO: members + // _00 = VTBL + P2DScreen mPane; // _04 }; /** @@ -63,6 +42,27 @@ struct BalloonPane : public P2DPaneCallBack { // TODO: members }; +/** + * @brief TODO + * + * @note Might be a struct? I think it's a namespace. + */ +namespace P2DPaneLibrary { +void makeResident(P2DPane*); +void setFamilyAlpha(P2DPane*, u8); +void setAlpha(P2DPane*, u8); +void setFamilyMirror(P2DPane*, P2DMirror); +void getParentPane(P2DPane*); +void getWorldPos(P2DPane*, int*, int*); +void changeParent(P2DPane*, P2DPane*); + +// unused/inlined: +void setMirror(P2DPane*, P2DMirror); +void printTag(P2DPane*); +void printUseTexName(P2DPane*, IDelegate1*); +void printUseTexName(char*, IDelegate1*); +}; // namespace P2DPaneLibrary + } // namespace zen #endif diff --git a/include/zen/DrawContainer.h b/include/zen/DrawContainer.h index 922292ec..e662cb19 100644 --- a/include/zen/DrawContainer.h +++ b/include/zen/DrawContainer.h @@ -12,6 +12,8 @@ namespace zen { /** * @brief TODO + * + * @note Size: 0x1E0. */ struct DrawContainer { @@ -36,7 +38,7 @@ struct DrawContainer { void startStatus(); void endStatus(); - // TODO: members + u8 _00[0x1E0]; // _00, unknown }; /** @@ -127,4 +129,6 @@ struct WindowPaneMgr { } // namespace zen +extern zen::DrawContainer* containerWindow; + #endif diff --git a/include/zen/DrawGameInfo.h b/include/zen/DrawGameInfo.h index 1fc45d39..0c44d791 100644 --- a/include/zen/DrawGameInfo.h +++ b/include/zen/DrawGameInfo.h @@ -152,7 +152,8 @@ struct DrawGameInfo { * @brief TODO */ enum playModeFlag { - // TODO: this + MODE_Story = 0, + MODE_Challenge = 1, }; DrawGameInfo(playModeFlag); diff --git a/include/zen/DrawHurryUp.h b/include/zen/DrawHurryUp.h index 4c69376b..7c96807d 100644 --- a/include/zen/DrawHurryUp.h +++ b/include/zen/DrawHurryUp.h @@ -9,6 +9,8 @@ namespace zen { /** * @brief TODO + * + * @note Size: 0x154. */ struct DrawHurryUp { @@ -34,9 +36,11 @@ struct DrawHurryUp { void brightShotStatus(); void brightStatus(); - // TODO: members + u8 _00[0x154]; // _00, unknown }; } // namespace zen +extern zen::DrawHurryUp* hurryupWindow; + #endif diff --git a/include/zen/ogFileChkSel.h b/include/zen/ogFileChkSel.h index cbde1ab1..a8a24564 100644 --- a/include/zen/ogFileChkSel.h +++ b/include/zen/ogFileChkSel.h @@ -6,9 +6,29 @@ struct Controller; struct CardQuickInfo; struct Graphics; +struct P2DScreen; namespace zen { +struct ogScrMemChkMgr; +struct ogScrFileSelectMgr; + +/** + * @brief TODO + */ +enum ogScrFileChkSelState { + FILECHKSEL_NULL = -1, + FILECHKSEL_Unk0 = 0, + + FILECHKSEL_Unk1 = 1, + FILECHKSEL_Unk2 = 2, + FILECHKSEL_Unk3 = 3, + FILECHKSEL_Unk4 = 4, + FILECHKSEL_Unk5 = 5, + + FILECHKSEL_Exit = FILECHKSEL_Unk1, // anything above this is an error/exit +}; + /** * @brief TODO * @@ -26,7 +46,14 @@ struct ogScrFileChkSelMgr { void init(); void startSub(); - u8 _00[0x18]; // _00, unknown + int mState; // _00 + bool _04; // _04 + P2DScreen* mDataBScreen; // _08 + bool _0C; // _0C + bool _0D; // _0D + bool mIsScreenVisible; // _0E + ogScrMemChkMgr* mMemChkMgr; // _10 + ogScrFileSelectMgr* mFileSelectMgr; // _14 }; } // namespace zen diff --git a/include/zen/ogFileSelect.h b/include/zen/ogFileSelect.h index f91566aa..2b319e61 100644 --- a/include/zen/ogFileSelect.h +++ b/include/zen/ogFileSelect.h @@ -11,6 +11,8 @@ namespace zen { /** * @brief TODO + * + * @note Size: 0x11A4. */ struct ogScrFileSelectMgr { @@ -53,7 +55,7 @@ struct ogScrFileSelectMgr { void OperateSelect(Controller*); void KetteiEffectStart(); void TailEffectStart(); - void update(Controller*, CardQuickInfo&); + int update(Controller*, CardQuickInfo&); void draw(Graphics&); // unused/inlined: @@ -77,7 +79,7 @@ struct ogScrFileSelectMgr { void MoveCpyCursor(int, f32); void DeleteEffectStart(); - // TODO: members + u8 _00[0x11A4]; // _00, unknown }; } // namespace zen diff --git a/include/zen/ogMap.h b/include/zen/ogMap.h index 64befaf1..9d26a7ca 100644 --- a/include/zen/ogMap.h +++ b/include/zen/ogMap.h @@ -5,10 +5,25 @@ struct Controller; struct Graphics; +struct P2DPane; struct P2DTextBox; +struct P2DScreen; namespace zen { +struct TypingTextMgr; + +/** + * @brief TODO + */ +enum ogScrMapState { + MAP_NULL = -1, + MAP_Unk0 = 0, + MAP_Unk1 = 1, + MAP_Unk2 = 2, + MAP_Unk4 = 4, +}; + /** * @brief TODO * @@ -21,7 +36,19 @@ struct ogScrMapMgr { int update(Controller*); void draw(Graphics&); - u8 _00[0x30]; // _00, unknown + int mState; // _00 + P2DScreen* _04; // _04 + P2DScreen* mTestScreen; // _08, test.blo + P2DScreen* mTest2Screen; // _0C, test2.blo + TypingTextMgr* mTypingTextMgr; // _10 + s16 _14; // _14 + f32 _18; // _18 + P2DPane* mPic1; // _1C + P2DPane* mCursorPane; // _20 + f32 _24; // _24 + f32 _28; // _28 + s16 _2C; // _2C + s16 _2E; // _2E }; } // namespace zen diff --git a/include/zen/ogStart.h b/include/zen/ogStart.h index 6b8450ef..d63615e3 100644 --- a/include/zen/ogStart.h +++ b/include/zen/ogStart.h @@ -5,9 +5,22 @@ struct Controller; struct Graphics; +struct P2DPane; +struct P2DScreen; namespace zen { +/** + * @brief TODO + */ +enum ogScrStartState { + START_NULL = -1, + START_Oscillate = 0, + START_FadeIn = 1, + START_FadeOut = 2, + START_Exit = 3, +}; + /** * @brief TODO * @@ -21,7 +34,11 @@ struct ogScrStartMgr { int update(Controller*); void draw(Graphics&); - u8 _00[0x14]; // _00, unknown + int mState; // _00, see ogScrStartState enum + int mExitState; // _04, see ogScrStartState enum + P2DScreen* mPressStartScreen; // _08 + P2DPane* mRootPane; // _0C, pane 'root' + f32 mFadeTimer; // _10, controls oscillating alpha level + fade in/out }; } // namespace zen diff --git a/include/zen/ogSub.h b/include/zen/ogSub.h index d4865697..f819c259 100644 --- a/include/zen/ogSub.h +++ b/include/zen/ogSub.h @@ -89,34 +89,44 @@ struct ogTexAnimSubMgr { /** * @brief TODO + * + * @note Size: 0x18. */ -struct TypingTextMgr { - TypingTextMgr(P2DTextBox*); +struct ogMsgCtrlTagMgr { + ogMsgCtrlTagMgr(); - void start(); - void update(); + void CheckCtrlTag(char*, s16*, f32*); - // TODO: members + u8 _00[0x18]; // _00, unknown }; /** * @brief TODO + * + * @note Size: 0x418. */ -struct ogMsgCtrlTagMgr { - ogMsgCtrlTagMgr(); +struct TypingTextMgr { + TypingTextMgr(P2DTextBox*); - void CheckCtrlTag(char*, s16*, f32*); + void start(); + void update(); - // TODO: members + int _00; // _00 + ogMsgCtrlTagMgr* mCtrlTagMgr; // _04 + P2DTextBox* mTextBox; // _08 + char* mTextPtr; // _0C + char mTextBuf[0x400]; // _10 + f32 _410; // _410 + u16 _414; // _414 }; // global utility functions -void ogCheckInsCard(); -void calcPuruPuruScale(f32); +bool ogCheckInsCard(); +f32 calcPuruPuruScale(f32); void setNumberTag(P2DScreen*, u32, int*, int); void setTextColor(P2DTextBox*, P2DPicture*); void getStringCVS(char*, char*, s16); -void getSpecialNumber(int); +int getSpecialNumber(int); void setSpecialNumber(int, int); void cnvSpecialNumber(char*); void cnvSpecialNumberHyphen(char*); diff --git a/src/plugPikiKando/gameCoreSection.cpp b/src/plugPikiKando/gameCoreSection.cpp index 62fb3fd7..f70aadba 100644 --- a/src/plugPikiKando/gameCoreSection.cpp +++ b/src/plugPikiKando/gameCoreSection.cpp @@ -1,6 +1,37 @@ #include "GameCoreSection.h" #include "gameflow.h" #include "Omake.h" +#include "Demo.h" +#include "MemStat.h" +#include "SoundMgr.h" +#include "Generator.h" +#include "zen/DrawContainer.h" +#include "zen/DrawHurryUp.h" +#include "zen/DrawAccount.h" +#include "zen/DrawGameInfo.h" +#include "CodeInitializer.h" +#include "Pellet.h" +#include "WorkObject.h" +#include "sysNew.h" +#include "Font.h" +#include "DynParticle.h" +#include "Menu.h" +#include "AIPerf.h" +#include "UpdateMgr.h" +#include "AIConstant.h" +#include "KeyConfig.h" +#include "GlobalShape.h" +#include "PikiInfo.h" +#include "NaviMgr.h" +#include "UtEffect.h" +#include "Kontroller.h" +#include "Boss.h" +#include "teki.h" +#include "ItemMgr.h" +#include "PlantMgr.h" +#include "Pcam/CameraManager.h" +#include "PlayerState.h" +#include "RadarInfo.h" #include "Interface.h" #include "Dolphin/os.h" @@ -3807,8 +3838,179 @@ void GameCoreSection::finalSetup() * Address: 8010FE4C * Size: 0009A4 */ -GameCoreSection::GameCoreSection(Controller*, MapMgr*, Camera&) +GameCoreSection::GameCoreSection(Controller* controller, MapMgr* mgr, Camera& camera) + : Node("gamecore") { + _28 = 0; + textDemoState = 0; + pauseFlag = 0; + _2C = 0; + demoEventMgr = new DemoEventMgr(); + radarInfo = new RadarInfo(); + _34 = 0; + _31 = 0; + + memStat->start("gamecore"); + seSystem = new SeSystem(); + generatorList = new GeneratorList(); + + mController = controller; + mMapMgr = mgr; + + memStat->start("gui"); + containerWindow = new zen::DrawContainer(); + hurryupWindow = new zen::DrawHurryUp(); + accountWindow = new zen::DrawAccount(); + memStat->end("gui"); + + FastGrid::initAIGrid(7); + _70._18 = 500.0f; + NakataCodeInitializer::init(); + + if (!preloadUFO) { + memStat->start("pellet"); + pelletMgr = new PelletMgr(mMapMgr); + gameflow.addGenNode("ペレットマネージャ", pelletMgr); // 'pellet manager' + memStat->end("pellet"); + } + + memStat->start("mapMgr"); + + memStat->start("workobj"); + workObjectMgr = new WorkObjectMgr(); + gameflow.addGenNode("仕事オブジェマネージャ", workObjectMgr); // 'work object manager' + memStat->end("workobj"); + + memStat->end("mapMgr"); + + _50 = 0; + _68 = gsys->loadTexture("effects/shadow.txe", true); + _68->_06 = 0x105; + mBigFont = new Font(); + mBigFont->setTexture(gsys->loadTexture("bigFont.bti", true), 21, 36); + + memStat->start("dynamics"); + particleHeap = new DynParticleHeap(0x400); + memStat->end("dynamics"); + + _3C = new Menu(mController, gsys->mConsFont, false); + _3C->_48 = glnWidth / 2; + _3C->mPositionOffsetY = glnHeight / 2; + AIPerf::addMenu(_3C); + GlobalShape::init(); + + pikiUpdateMgr = new UpdateMgr(); + pikiUpdateMgr->create(10); + + searchUpdateMgr = new UpdateMgr(); + searchUpdateMgr->create(9); + + pikiLookUpdateMgr = new UpdateMgr(); + pikiLookUpdateMgr->create(20); + + pikiOptUpdateMgr = new UpdateMgr(); + pikiOptUpdateMgr->create(2); + + tekiOptUpdateMgr = new UpdateMgr(); + tekiOptUpdateMgr->create(3); + + seMgr = new SeMgr(); + + AIConstant::createInstance(); + gameflow.addGenNode("AI定数", AIConstant::_instance); // 'AI Constants' + + KeyConfig::createInstance(); + gameflow.addGenNode("Key Setting", KeyConfig::_instance); + + _54 = new SearchSystem(); + + PikiShapeObject::init(); + SAIEventInit(); + + pikiInfo = new PikiInfo(); + + memStat->start("navi"); + naviMgr = new NaviMgr(); + naviMgr->create(1); + mNavi = static_cast(naviMgr->birth()); + gameflow.addGenNode("naviMgr", naviMgr); + memStat->end("navi"); + + utEffectMgr = new UtEffectMgr(); + + memStat->start("generator"); + generatorMgr = new GeneratorMgr(); + generatorMgr->setName("default"); + gameflow.addGenNode("ジェネレータ(default)", generatorMgr); // 'generator (default)' + + GenObjectDebug::initialise(); + GenObjectItem::initialise(); + GenObjectPellet::initialise(); + GenObjectWorkObject::initialise(); + GenObjectPlant::initialise(); + GenObjectMapParts::initialise(mMapMgr); + GenObjectTeki::initialise(); + GenObjectBoss::initialise(); + GenObjectMapObject::initialise(mMapMgr); + GenObjectNavi::initialise(); + GenObjectActor::initialise(); + + onceGeneratorMgr = new GeneratorMgr(); + onceGeneratorMgr->setName("init"); + gameflow.addGenNode("ジェネレータ(init)", onceGeneratorMgr); // 'generator (init)' + + dailyGeneratorMgr = new GeneratorMgr(); + dailyGeneratorMgr->setName("daily"); + gameflow.addGenNode("ジェネレータ(daily)", dailyGeneratorMgr); // 'generator (daily)' + + plantGeneratorMgr = new GeneratorMgr(); + plantGeneratorMgr->setName("plant"); + gameflow.addGenNode("ジェネレータ(plants)", plantGeneratorMgr); // 'generator (plants)' + + limitGeneratorMgr = new GeneratorMgr(); + limitGeneratorMgr->_5C = 1; + limitGeneratorMgr->setName("limit"); + gameflow.addGenNode("ジェネレータ(limit)", limitGeneratorMgr); // 'generator (limit)' + memStat->end("generator"); + + memStat->start("boss"); + int prevBossHeap = gsys->setHeap(SYSHEAP_Teki); + bossMgr = new BossMgr(); + gsys->setHeap(prevBossHeap); + memStat->end("boss"); + gameflow.addGenNode("bossMgr", bossMgr); + + memStat->start("teki"); + int prevTekiHeap = gsys->setHeap(SYSHEAP_Teki); + tekiMgr = new TekiMgr(); + gsys->setHeap(prevTekiHeap); + memStat->end("teki"); + gameflow.addGenNode("tekiMgr", tekiMgr); + + if (!preloadUFO) { + memStat->start("item"); + itemMgr = new ItemMgr(); + memStat->end("item"); + } + + memStat->start("mapMgr"); + memStat->start("plant"); + plantMgr = new PlantMgr(mMapMgr); + memStat->end("plant"); + memStat->end("mapMgr"); + + mNavi->mNaviCamera = &camera; + mNavi->init(); + camera.mPosition.x = 500.0f * sinf(camera.mRotation.x); + camera.mPosition.y = 140.0f; + camera.mPosition.z = 500.0f * cosf(camera.mRotation.x); + gsys->setFade(1.0f, 3.0f); + cameraMgr = new PcamCameraManager(&camera, mNavi->mKontroller); + gameflow.addGenNode("cameraMgr", cameraMgr); + memStat->end("gamecore"); + + mDrawGameInfo + = new zen::DrawGameInfo(gameflow.mIsChallengeMode == FALSE ? zen::DrawGameInfo::MODE_Story : zen::DrawGameInfo::MODE_Challenge); /* .loc_0x0: mflr r0 diff --git a/src/plugPikiOgawa/ogFileChkSel.cpp b/src/plugPikiOgawa/ogFileChkSel.cpp index 56faa854..2133e8dc 100644 --- a/src/plugPikiOgawa/ogFileChkSel.cpp +++ b/src/plugPikiOgawa/ogFileChkSel.cpp @@ -1,4 +1,11 @@ #include "zen/ogFileChkSel.h" +#include "zen/ogMemChk.h" +#include "zen/ogFileSelect.h" +#include "zen/ogSub.h" +#include "P2D/Screen.h" +#include "P2D/Graph.h" +#include "SoundMgr.h" +#include "sysNew.h" /* * --INFO-- @@ -37,83 +44,14 @@ void zen::ogScrFileChkSelMgr::init() */ zen::ogScrFileChkSelMgr::ogScrFileChkSelMgr() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - li r0, -0x1 - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - li r31, 0 - stw r30, 0x20(r1) - stw r29, 0x1C(r1) - addi r29, r3, 0 - stw r0, 0x0(r3) - li r3, 0xF8 - stb r31, 0x4(r29) - stb r31, 0xD(r29) - stb r31, 0xE(r29) - bl -0x14C5C8 - addi r30, r3, 0 - mr. r0, r30 - beq- .loc_0x98 - addi r3, r1, 0xC - li r4, 0 - li r5, 0 - li r6, 0x280 - li r7, 0x1E0 - bl 0x20038 - lis r4, 0x726F - addi r7, r4, 0x6F74 - addi r8, r1, 0xC - addi r3, r30, 0 - li r4, 0 - li r5, 0x8 - li r6, 0x1 - bl 0x1D3BC - lis r3, 0x802E - addi r0, r3, 0x7E0 - stw r0, 0x0(r30) - stb r31, 0xEC(r30) - stw r31, 0xF0(r30) - stw r31, 0xF4(r30) - - .loc_0x98: - stw r30, 0x8(r29) - lis r3, 0x802D - addi r4, r3, 0x6010 - lwz r3, 0x8(r29) - li r5, 0x1 - li r6, 0x1 - li r7, 0x1 - bl 0x1F5B8 - li r3, 0x10C - bl -0x14C64C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xD0 - bl -0x6614 - - .loc_0xD0: - stw r30, 0x10(r29) - li r3, 0x11A4 - bl -0x14C668 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xEC - bl -0x9FC0 - - .loc_0xEC: - stw r30, 0x14(r29) - mr r3, r29 - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - lwz r29, 0x1C(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + mState = FILECHKSEL_NULL; + _04 = false; + _0D = false; + mIsScreenVisible = false; + mDataBScreen = new P2DScreen(); + mDataBScreen->set("screen/blo/data_b.blo", true, true, true); + mMemChkMgr = new ogScrMemChkMgr(); + mFileSelectMgr = new ogScrFileSelectMgr(); } /* @@ -131,31 +69,14 @@ void zen::ogScrFileChkSelMgr::startSub() * Address: 801936A4 * Size: 000050 */ -void zen::ogScrFileChkSelMgr::start(bool) +void zen::ogScrFileChkSelMgr::start(bool p1) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - li r31, 0 - stw r30, 0x10(r1) - mr r30, r3 - stb r4, 0xD(r3) - stb r31, 0x4(r3) - stw r31, 0x0(r3) - lwz r3, 0x10(r3) - bl -0x59A8 - stb r31, 0xC(r30) - stb r31, 0xE(r30) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + _0D = p1; + _04 = false; + mState = FILECHKSEL_Unk0; + mMemChkMgr->start(); + _0C = false; + mIsScreenVisible = false; } /* @@ -165,30 +86,12 @@ void zen::ogScrFileChkSelMgr::start(bool) */ void zen::ogScrFileChkSelMgr::startSave() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - li r0, 0x1 - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - li r31, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - stb r31, 0xD(r3) - stb r0, 0x4(r3) - stw r31, 0x0(r3) - lwz r3, 0x10(r3) - bl -0x59FC - stb r31, 0xC(r30) - stb r31, 0xE(r30) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + _0D = false; + _04 = true; + mState = FILECHKSEL_Unk0; + mMemChkMgr->start(); + _0C = false; + mIsScreenVisible = false; } /* @@ -196,143 +99,64 @@ void zen::ogScrFileChkSelMgr::startSave() * Address: 80193748 * Size: 000198 */ -int zen::ogScrFileChkSelMgr::update(Controller*, CardQuickInfo&) +int zen::ogScrFileChkSelMgr::update(Controller* controller, CardQuickInfo& cardInfo) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - addi r31, r5, 0 - stw r30, 0x20(r1) - addi r30, r4, 0 - stw r29, 0x1C(r1) - mr r29, r3 - lwz r3, 0x0(r3) - cmpwi r3, -0x1 - bne- .loc_0x34 - b .loc_0x17C - - .loc_0x34: - cmpwi r3, 0x1 - blt- .loc_0x4C - li r0, -0x1 - stw r0, 0x0(r29) - lwz r3, 0x0(r29) - b .loc_0x17C - - .loc_0x4C: - lwz r3, 0x10(r29) - mr r4, r30 - bl -0x56C0 - cmpwi r3, 0x15 - bne- .loc_0x98 - lbz r0, 0xD(r29) - cmplwi r0, 0 - beq- .loc_0x7C - li r0, 0x5 - stw r0, 0x0(r29) - lwz r3, 0x0(r29) - b .loc_0x17C - - .loc_0x7C: - lwz r3, 0x14(r29) - li r5, 0 - lbz r4, 0x4(r29) - bl -0x9360 - li r0, 0x1 - stb r0, 0xE(r29) - b .loc_0x178 - - .loc_0x98: - cmpwi r3, 0x14 - bne- .loc_0xB0 - li r0, 0x5 - stw r0, 0x0(r29) - lwz r3, 0x0(r29) - b .loc_0x17C - - .loc_0xB0: - cmpwi r3, 0x13 - bne- .loc_0xC8 - li r0, 0x1 - stw r0, 0x0(r29) - lwz r3, 0x0(r29) - b .loc_0x17C - - .loc_0xC8: - cmpwi r3, -0x1 - bne- .loc_0x178 - bl -0x14FC8 - rlwinm. r0,r3,0,24,31 - bne- .loc_0xFC - li r3, 0x128 - bl -0xEE480 - li r3, 0x12A - bl -0xEE4BC - li r0, 0x1 - stw r0, 0x0(r29) - lwz r3, 0x0(r29) - b .loc_0x17C - - .loc_0xFC: - lwz r3, 0x8(r29) - bl 0x1F308 - lwz r3, 0x14(r29) - addi r4, r30, 0 - addi r5, r31, 0 - bl -0x88A8 - cmpwi r3, 0x8 - beq- .loc_0x158 - bge- .loc_0x130 - cmpwi r3, 0x6 - beq- .loc_0x140 - bge- .loc_0x14C - b .loc_0x178 - - .loc_0x130: - cmpwi r3, 0xA - beq- .loc_0x170 - bge- .loc_0x178 - b .loc_0x164 - - .loc_0x140: - li r0, 0x1 - stw r0, 0x0(r29) - b .loc_0x178 - - .loc_0x14C: - li r0, 0x2 - stw r0, 0x0(r29) - b .loc_0x178 - - .loc_0x158: - li r0, 0x3 - stw r0, 0x0(r29) - b .loc_0x178 - - .loc_0x164: - li r0, 0x4 - stw r0, 0x0(r29) - b .loc_0x178 - - .loc_0x170: - li r0, 0x5 - stw r0, 0x0(r29) - - .loc_0x178: - lwz r3, 0x0(r29) - - .loc_0x17C: - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - lwz r29, 0x1C(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + if (mState == FILECHKSEL_NULL) { + return mState; + } + + if (mState >= FILECHKSEL_Exit) { + mState = FILECHKSEL_NULL; + return mState; + } + + int memChkState = mMemChkMgr->update(controller); + if (memChkState == 21) { + if (_0D) { + mState = FILECHKSEL_Unk5; + return mState; + } + + mFileSelectMgr->start(_04, 0); + mIsScreenVisible = true; + + } else if (memChkState == 20) { + mState = FILECHKSEL_Unk5; + return mState; + + } else if (memChkState == 19) { + mState = FILECHKSEL_Unk1; + return mState; + + } else if (memChkState == -1) { + if (!ogCheckInsCard()) { + SeSystem::stopSysSe(0x128); + SeSystem::playSysSe(0x12A); + mState = FILECHKSEL_Unk1; + return mState; + } + + mDataBScreen->update(); + switch (mFileSelectMgr->update(controller, cardInfo)) { + case 6: + mState = FILECHKSEL_Unk1; + break; + case 7: + mState = FILECHKSEL_Unk2; + break; + case 8: + mState = FILECHKSEL_Unk3; + break; + case 9: + mState = FILECHKSEL_Unk4; + break; + case 10: + mState = FILECHKSEL_Unk5; + break; + } + } + + return mState; } /* @@ -340,60 +164,18 @@ int zen::ogScrFileChkSelMgr::update(Controller*, CardQuickInfo&) * Address: 801938E0 * Size: 0000BC */ -void zen::ogScrFileChkSelMgr::draw(Graphics&) +void zen::ogScrFileChkSelMgr::draw(Graphics& gfx) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x100(r1) - stw r31, 0xFC(r1) - addi r31, r4, 0 - stw r30, 0xF8(r1) - mr r30, r3 - lwz r0, 0x0(r3) - cmpwi r0, -0x1 - beq- .loc_0xA4 - lbz r0, 0xE(r30) - cmplwi r0, 0 - beq- .loc_0x8C - lfs f1, -0x4E18(r2) - addi r3, r1, 0x10 - lfs f2, -0x4E14(r2) - li r4, 0 - lfs f3, -0x4E10(r2) - li r5, 0 - li r6, 0x280 - li r7, 0x1E0 - bl 0x1C85C - addi r3, r1, 0x10 - bl 0x1C964 - lwz r3, 0x8(r30) - addi r6, r1, 0x10 - li r4, 0 - li r5, 0 - bl 0x1F584 - lis r3, 0x802E - addi r0, r3, 0x698 - lis r3, 0x802E - stw r0, 0x10(r1) - addi r0, r3, 0x5D4 - stw r0, 0x10(r1) - - .loc_0x8C: - lwz r3, 0x14(r30) - mr r4, r31 - bl -0x7F80 - lwz r3, 0x10(r30) - mr r4, r31 - bl -0x49E0 - - .loc_0xA4: - lwz r0, 0x104(r1) - lwz r31, 0xFC(r1) - lwz r30, 0xF8(r1) - addi r1, r1, 0x100 - mtlr r0 - blr - */ + if (mState == FILECHKSEL_NULL) { + return; + } + + if (mIsScreenVisible) { + P2DPerspGraph perspGraph(0, 0, 640, 480, 30.0f, 1.0f, 5000.0f); + perspGraph.setPort(); + mDataBScreen->draw(0, 0, &perspGraph); + } + + mFileSelectMgr->draw(gfx); + mMemChkMgr->draw(gfx); } diff --git a/src/plugPikiOgawa/ogFileSelect.cpp b/src/plugPikiOgawa/ogFileSelect.cpp index 4d0df137..37243c6e 100644 --- a/src/plugPikiOgawa/ogFileSelect.cpp +++ b/src/plugPikiOgawa/ogFileSelect.cpp @@ -4231,7 +4231,7 @@ void zen::ogScrFileSelectMgr::quit() * Address: 8018AFB0 * Size: 000A20 */ -void zen::ogScrFileSelectMgr::update(Controller*, CardQuickInfo&) +int zen::ogScrFileSelectMgr::update(Controller*, CardQuickInfo&) { /* .loc_0x0: diff --git a/src/plugPikiOgawa/ogMap.cpp b/src/plugPikiOgawa/ogMap.cpp index 80d5805a..21ea94df 100644 --- a/src/plugPikiOgawa/ogMap.cpp +++ b/src/plugPikiOgawa/ogMap.cpp @@ -1,5 +1,10 @@ #include "zen/ogMap.h" +#include "zen/ogSub.h" +#include "P2D/Screen.h" +#include "P2D/TextBox.h" +#include "P2D/Graph.h" #include "std/Math.h" +#include "sysNew.h" /* * --INFO-- @@ -26,68 +31,26 @@ static void _Print(char*, ...) * Address: 80182DE0 * Size: 0000D4 */ -void zen::ogScrMapMgr::start(s16) +void zen::ogScrMapMgr::start(s16 p1) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - li r0, 0x1 - stwu r1, -0x40(r1) - stw r31, 0x3C(r1) - mr r31, r3 - sth r4, 0x14(r3) - stw r0, 0x0(r3) - lha r0, 0x14(r3) - cmpwi r0, 0x1 - bne- .loc_0xAC - lwz r0, 0xC(r31) - lis r3, 0x7069 - addi r4, r3, 0x6331 - stw r0, 0x4(r31) - li r5, 0x1 - lwz r3, 0x4(r31) - lwz r12, 0x0(r3) - lwz r12, 0x34(r12) - mtlr r12 - blrl - stw r3, 0x1C(r31) - lis r4, 0x4330 - lwz r3, 0x1C(r31) - lfd f1, -0x5080(r2) - lha r0, 0x18(r3) - xoris r0, r0, 0x8000 - stw r0, 0x34(r1) - stw r4, 0x30(r1) - lfd f0, 0x30(r1) - fsubs f0, f0, f1 - stfs f0, 0x24(r31) - lwz r3, 0x1C(r31) - lha r0, 0x1A(r3) - xoris r0, r0, 0x8000 - stw r0, 0x2C(r1) - stw r4, 0x28(r1) - lfd f0, 0x28(r1) - fsubs f0, f0, f1 - stfs f0, 0x28(r31) - lwz r3, 0x10(r31) - bl -0x2A64 - b .loc_0xB4 - - .loc_0xAC: - lwz r0, 0x8(r31) - stw r0, 0x4(r31) - - .loc_0xB4: - li r0, 0 - sth r0, 0x2C(r31) - sth r0, 0x2E(r31) - lwz r0, 0x44(r1) - lwz r31, 0x3C(r1) - addi r1, r1, 0x40 - mtlr r0 - blr - */ + u32 badCompiler[6]; + + _14 = p1; + mState = MAP_Unk1; + + if (_14 == 1) { + _04 = mTest2Screen; + mPic1 = _04->search('pic1', true); + _24 = mPic1->_18.mMin.x; + _28 = mPic1->_18.mMin.y; + mTypingTextMgr->start(); + + } else { + _04 = mTestScreen; + } + + _2C = 0; + _2E = 0; } /* @@ -97,130 +60,18 @@ void zen::ogScrMapMgr::start(s16) */ zen::ogScrMapMgr::ogScrMapMgr() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - addi r31, r3, 0 - li r3, 0xF8 - stw r30, 0x28(r1) - stw r29, 0x24(r1) - bl -0x13BED0 - addi r30, r3, 0 - mr. r0, r30 - beq- .loc_0x88 - addi r29, r30, 0 - addi r3, r1, 0x14 - li r4, 0 - li r5, 0 - li r6, 0x280 - li r7, 0x1E0 - bl 0x3072C - lis r4, 0x726F - addi r7, r4, 0x6F74 - addi r8, r1, 0x14 - addi r3, r29, 0 - li r4, 0 - li r5, 0x8 - li r6, 0x1 - bl 0x2DAB0 - lis r3, 0x802E - addi r0, r3, 0x7E0 - stw r0, 0x0(r30) - li r0, 0 - stb r0, 0xEC(r30) - stw r0, 0xF0(r30) - stw r0, 0xF4(r30) - - .loc_0x88: - stw r30, 0x8(r31) - lis r3, 0x802D - addi r4, r3, 0x4058 - lwz r3, 0x8(r31) - li r5, 0x1 - li r6, 0x1 - li r7, 0x1 - bl 0x2FCA8 - li r3, 0xF8 - bl -0x13BF5C - addi r30, r3, 0 - mr. r0, r30 - beq- .loc_0x114 - addi r29, r30, 0 - addi r3, r1, 0xC - li r4, 0 - li r5, 0 - li r6, 0x280 - li r7, 0x1E0 - bl 0x306A0 - lis r4, 0x726F - addi r7, r4, 0x6F74 - addi r8, r1, 0xC - addi r3, r29, 0 - li r4, 0 - li r5, 0x8 - li r6, 0x1 - bl 0x2DA24 - lis r3, 0x802E - addi r0, r3, 0x7E0 - stw r0, 0x0(r30) - li r0, 0 - stb r0, 0xEC(r30) - stw r0, 0xF0(r30) - stw r0, 0xF4(r30) - - .loc_0x114: - stw r30, 0xC(r31) - lis r3, 0x802D - addi r4, r3, 0x406C - lwz r3, 0xC(r31) - li r5, 0x1 - li r6, 0x1 - li r7, 0x1 - bl 0x2FC1C - lwz r3, 0xC(r31) - lis r4, 0x7478 - addi r4, r4, 0x3030 - lwz r12, 0x0(r3) - li r5, 0x1 - lwz r12, 0x34(r12) - mtlr r12 - blrl - addi r29, r3, 0 - li r3, 0x418 - bl -0x13C00C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x174 - mr r4, r29 - bl -0x2C94 - - .loc_0x174: - stw r30, 0x10(r31) - lis r3, 0x6375 - addi r4, r3, 0x7273 - lwz r3, 0xC(r31) - li r5, 0x1 - lwz r12, 0x0(r3) - lwz r12, 0x34(r12) - mtlr r12 - blrl - stw r3, 0x20(r31) - li r0, -0x1 - addi r3, r31, 0 - lfs f0, -0x5078(r2) - stfs f0, 0x18(r31) - stw r0, 0x0(r31) - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - lwz r30, 0x28(r1) - lwz r29, 0x24(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + mTestScreen = new P2DScreen(); + mTestScreen->set("screen/blo/test.blo", true, true, true); + + mTest2Screen = new P2DScreen(); + mTest2Screen->set("screen/blo/test2.blo", true, true, true); + + P2DTextBox* textBox = static_cast(mTest2Screen->search('tx00', true)); + mTypingTextMgr = new TypingTextMgr(textBox); + + mCursorPane = mTest2Screen->search('curs', true); + _18 = 0.0f; + mState = MAP_NULL; } /* @@ -228,8 +79,37 @@ zen::ogScrMapMgr::ogScrMapMgr() * Address: 80183080 * Size: 00029C */ -int zen::ogScrMapMgr::update(Controller*) +int zen::ogScrMapMgr::update(Controller* controller) { + if (mState == MAP_NULL) { + return mState; + } + + _18 += gsys->getFrameTime(); + _04->update(); + + if (mState == MAP_Unk1) { + mState = MAP_Unk0; + return mState; + } + + if (mState == MAP_Unk2) { + mState = MAP_Unk4; + return mState; + } + + if (mState == MAP_Unk4) { + mState = MAP_NULL; + return mState; + } + + if (controller->isPressed(KBBTN_B)) { + mState = MAP_Unk2; + } + + if (_14 == 1) { + mTypingTextMgr->update(); + } /* .loc_0x0: mflr r0 @@ -477,46 +357,13 @@ int zen::ogScrMapMgr::update(Controller*) * Address: 8018337C * Size: 00008C */ -void zen::ogScrMapMgr::draw(Graphics&) +void zen::ogScrMapMgr::draw(Graphics& gfx) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x100(r1) - stw r31, 0xFC(r1) - mr r31, r3 - lwz r0, 0x0(r3) - cmpwi r0, -0x1 - beq- .loc_0x78 - lfs f1, -0x5068(r2) - addi r3, r1, 0x10 - lfs f2, -0x5074(r2) - li r4, 0 - lfs f3, -0x5064(r2) - li r5, 0 - li r6, 0x280 - li r7, 0x1E0 - bl 0x2CDD4 - addi r3, r1, 0x10 - bl 0x2CEDC - lwz r3, 0x4(r31) - addi r6, r1, 0x10 - li r4, 0 - li r5, 0 - bl 0x2FAFC - lis r3, 0x802E - addi r0, r3, 0x698 - lis r3, 0x802E - stw r0, 0x10(r1) - addi r0, r3, 0x5D4 - stw r0, 0x10(r1) - - .loc_0x78: - lwz r0, 0x104(r1) - lwz r31, 0xFC(r1) - addi r1, r1, 0x100 - mtlr r0 - blr - */ + if (mState == MAP_NULL) { + return; + } + + P2DPerspGraph perspGraph(0, 0, 640, 480, 30.0f, 1.0f, 5000.0f); + perspGraph.setPort(); + _04->draw(0, 0, &perspGraph); } diff --git a/src/plugPikiOgawa/ogPause.cpp b/src/plugPikiOgawa/ogPause.cpp index e2f93f72..8230f61d 100644 --- a/src/plugPikiOgawa/ogPause.cpp +++ b/src/plugPikiOgawa/ogPause.cpp @@ -656,42 +656,3 @@ void zen::ogScrPauseMgr::draw(Graphics&) blr */ } - -/* - * --INFO-- - * Address: 80182B38 - * Size: 00005C - */ -P2DPerspGraph::~P2DPerspGraph() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr. r31, r3 - beq- .loc_0x44 - lis r3, 0x802E - addi r0, r3, 0x698 - stw r0, 0x0(r31) - beq- .loc_0x34 - lis r3, 0x802E - addi r0, r3, 0x5D4 - stw r0, 0x0(r31) - - .loc_0x34: - extsh. r0, r4 - ble- .loc_0x44 - mr r3, r31 - bl -0x13B9CC - - .loc_0x44: - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} diff --git a/src/plugPikiOgawa/ogStart.cpp b/src/plugPikiOgawa/ogStart.cpp index ea6d8241..264e535c 100644 --- a/src/plugPikiOgawa/ogStart.cpp +++ b/src/plugPikiOgawa/ogStart.cpp @@ -1,4 +1,8 @@ #include "zen/ogStart.h" +#include "zen/DrawCommon.h" +#include "P2D/Graph.h" +#include "P2D/Screen.h" +#include "sysNew.h" /* * --INFO-- @@ -27,73 +31,12 @@ static void _Print(char*, ...) */ zen::ogScrStartMgr::ogScrStartMgr() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - stw r30, 0x18(r1) - addi r30, r3, 0 - li r3, 0xF8 - bl -0x1519A0 - addi r31, r3, 0 - mr. r0, r31 - beq- .loc_0x80 - addi r3, r1, 0xC - li r4, 0 - li r5, 0 - li r6, 0x280 - li r7, 0x1E0 - bl 0x1AC60 - lis r4, 0x726F - addi r7, r4, 0x6F74 - addi r8, r1, 0xC - addi r3, r31, 0 - li r4, 0 - li r5, 0x8 - li r6, 0x1 - bl 0x17FE4 - lis r3, 0x802E - addi r0, r3, 0x7E0 - stw r0, 0x0(r31) - li r0, 0 - stb r0, 0xEC(r31) - stw r0, 0xF0(r31) - stw r0, 0xF4(r31) - - .loc_0x80: - stw r31, 0x8(r30) - lis r3, 0x802D - addi r4, r3, 0x6230 - lwz r3, 0x8(r30) - li r5, 0x1 - li r6, 0x1 - li r7, 0x1 - bl 0x1A1DC - lwz r3, 0x8(r30) - lis r4, 0x726F - addi r4, r4, 0x6F74 - lwz r12, 0x0(r3) - li r5, 0x1 - lwz r12, 0x34(r12) - mtlr r12 - blrl - stw r3, 0xC(r30) - li r4, -0x1 - li r0, 0x3 - lfs f0, -0x4D10(r2) - mr r3, r30 - stfs f0, 0x10(r30) - stw r4, 0x0(r30) - stw r0, 0x4(r30) - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + mPressStartScreen = new P2DScreen(); + mPressStartScreen->set("screen/blo/press_s.blo", true, true, true); + mRootPane = mPressStartScreen->search('root', true); + mFadeTimer = 0.0f; + mState = START_NULL; + mExitState = START_Exit; } /* @@ -103,23 +46,9 @@ zen::ogScrStartMgr::ogScrStartMgr() */ void zen::ogScrStartMgr::start() { - /* - .loc_0x0: - mflr r0 - li r4, 0 - stw r0, 0x4(r1) - li r0, 0 - stwu r1, -0x8(r1) - stw r0, 0x0(r3) - lfs f0, -0x4D10(r2) - stfs f0, 0x10(r3) - lwz r3, 0x8(r3) - bl 0x26E34 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + mState = START_Oscillate; + mFadeTimer = 0.0f; + P2DPaneLibrary::setFamilyAlpha(mPressStartScreen, 0); } /* @@ -129,19 +58,11 @@ void zen::ogScrStartMgr::start() */ void zen::ogScrStartMgr::stop() { - /* - .loc_0x0: - lwz r0, 0x0(r3) - cmpwi r0, 0 - bnelr- - li r0, 0x3 - stw r0, 0x4(r3) - li r0, 0x2 - stw r0, 0x0(r3) - lfs f0, -0x4D10(r2) - stfs f0, 0x10(r3) - blr - */ + if (mState == START_Oscillate) { + mExitState = START_Exit; + mState = START_FadeOut; + mFadeTimer = 0.0f; + } } /* @@ -149,145 +70,62 @@ void zen::ogScrStartMgr::stop() * Address: 80198AE0 * Size: 0001C0 */ -int zen::ogScrStartMgr::update(Controller*) +int zen::ogScrStartMgr::update(Controller* controller) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - addi r31, r4, 0 - stw r30, 0x28(r1) - mr r30, r3 - lwz r3, 0x0(r3) - cmpwi r3, -0x1 - bne- .loc_0x2C - b .loc_0x1A8 - - .loc_0x2C: - lwz r3, 0x8(r30) - bl 0x1A040 - lwz r3, 0x2DEC(r13) - lfs f1, 0x10(r30) - lfs f0, 0x28C(r3) - fadds f0, f1, f0 - stfs f0, 0x10(r30) - lwz r0, 0x0(r30) - cmpwi r0, 0x1 - bne- .loc_0xAC - lfs f2, 0x10(r30) - lfs f1, -0x4D0C(r2) - fcmpo cr0, f2, f1 - bge- .loc_0x88 - lfs f0, -0x4D08(r2) - lwz r3, 0x8(r30) - fmuls f0, f0, f2 - fdivs f0, f0, f1 - fctiwz f0, f0 - stfd f0, 0x20(r1) - lwz r4, 0x24(r1) - bl 0x26D78 - b .loc_0xA4 - - .loc_0x88: - lwz r3, 0x8(r30) - li r4, 0xFF - bl 0x26D68 - li r0, 0 - stw r0, 0x0(r30) - lfs f0, -0x4D10(r2) - stfs f0, 0x10(r30) - - .loc_0xA4: - lwz r3, 0x0(r30) - b .loc_0x1A8 - - .loc_0xAC: - cmpwi r0, 0x2 - bne- .loc_0x110 - lfs f2, 0x10(r30) - lfs f1, -0x4D0C(r2) - fcmpo cr0, f2, f1 - bge- .loc_0xEC - lfs f0, -0x4D08(r2) - lwz r3, 0x8(r30) - fmuls f0, f0, f2 - fdivs f0, f0, f1 - fctiwz f0, f0 - stfd f0, 0x20(r1) - lwz r0, 0x24(r1) - subfic r4, r0, 0xFF - bl 0x26D14 - b .loc_0x108 - - .loc_0xEC: - lwz r3, 0x8(r30) - li r4, 0 - bl 0x26D04 - lwz r0, 0x4(r30) - stw r0, 0x0(r30) - lfs f0, -0x4D10(r2) - stfs f0, 0x10(r30) - - .loc_0x108: - lwz r3, 0x0(r30) - b .loc_0x1A8 - - .loc_0x110: - cmpwi r0, 0x3 - bne- .loc_0x128 - li r0, -0x1 - stw r0, 0x0(r30) - lwz r3, 0x0(r30) - b .loc_0x1A8 - - .loc_0x128: - cmpwi r0, 0 - bne- .loc_0x1A4 - lfs f1, 0x10(r30) - lfs f0, -0x4D04(r2) - fcmpo cr0, f1, f0 - ble- .loc_0x148 - fsubs f0, f1, f0 - stfs f0, 0x10(r30) - - .loc_0x148: - lfs f1, -0x4CFC(r2) - lfs f0, 0x10(r30) - fmuls f1, f1, f0 - bl 0x82F20 - lfs f2, -0x4D00(r2) - lfs f0, -0x4D08(r2) - fmuls f1, f2, f1 - lwz r3, 0x8(r30) - fsubs f1, f2, f1 - fmuls f0, f0, f1 - fctiwz f0, f0 - stfd f0, 0x20(r1) - lwz r4, 0x24(r1) - bl 0x26C7C - lwz r0, 0x28(r31) - rlwinm. r0,r0,0,7,7 - beq- .loc_0x1A4 - li r0, 0x3 - stw r0, 0x4(r30) - li r0, 0x2 - stw r0, 0x0(r30) - lfs f0, -0x4D10(r2) - stfs f0, 0x10(r30) - - .loc_0x1A4: - lwz r3, 0x0(r30) - - .loc_0x1A8: - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - lwz r30, 0x28(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + // not active + if (mState == START_NULL) { + return mState; + } + + mPressStartScreen->update(); + mFadeTimer += gsys->getFrameTime(); + + // this never gets triggered + if (mState == START_FadeIn) { + if (mFadeTimer < 0.25f) { + P2DPaneLibrary::setFamilyAlpha(mPressStartScreen, (255.0f * mFadeTimer) / 0.25f); + } else { + P2DPaneLibrary::setFamilyAlpha(mPressStartScreen, 255); + mState = START_Oscillate; + mFadeTimer = 0.0f; + } + return mState; + } + + // triggered if we hit START + if (mState == START_FadeOut) { + if (mFadeTimer < 0.25f) { + P2DPaneLibrary::setFamilyAlpha(mPressStartScreen, 255 - u8(255.0f * mFadeTimer / 0.25f)); + } else { + P2DPaneLibrary::setFamilyAlpha(mPressStartScreen, 0); + mState = mExitState; + mFadeTimer = 0.0f; + } + return mState; + } + + // after fade out + if (mState == START_Exit) { + mState = START_NULL; + return mState; + } + + // normal state + if (mState == START_Oscillate) { + if (mFadeTimer > 1.0f) { + mFadeTimer -= 1.0f; + } + + P2DPaneLibrary::setFamilyAlpha(mPressStartScreen, 255.0f * (0.5f - 0.5f * cosf(TAU * mFadeTimer))); + + if (controller->isPressed(KBBTN_START)) { + mExitState = START_Exit; + mState = START_FadeOut; + mFadeTimer = 0.0f; + } + } + + return mState; } /* @@ -295,46 +133,13 @@ int zen::ogScrStartMgr::update(Controller*) * Address: 80198CA0 * Size: 00008C */ -void zen::ogScrStartMgr::draw(Graphics&) +void zen::ogScrStartMgr::draw(Graphics& gfx) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x100(r1) - stw r31, 0xFC(r1) - mr r31, r3 - lwz r0, 0x0(r3) - cmpwi r0, -0x1 - beq- .loc_0x78 - lfs f1, -0x4CF8(r2) - addi r3, r1, 0x10 - lfs f2, -0x4D04(r2) - li r4, 0 - lfs f3, -0x4CF4(r2) - li r5, 0 - li r6, 0x280 - li r7, 0x1E0 - bl 0x174B0 - addi r3, r1, 0x10 - bl 0x175B8 - lwz r3, 0x8(r31) - addi r6, r1, 0x10 - li r4, 0 - li r5, 0 - bl 0x1A1D8 - lis r3, 0x802E - addi r0, r3, 0x698 - lis r3, 0x802E - stw r0, 0x10(r1) - addi r0, r3, 0x5D4 - stw r0, 0x10(r1) + if (mState == START_NULL) { + return; + } - .loc_0x78: - lwz r0, 0x104(r1) - lwz r31, 0xFC(r1) - addi r1, r1, 0x100 - mtlr r0 - blr - */ + P2DPerspGraph perspGraph(0, 0, 640, 480, 30.0f, 1.0f, 5000.0f); + perspGraph.setPort(); + mPressStartScreen->draw(0, 0, &perspGraph); } diff --git a/src/plugPikiOgawa/ogSub.cpp b/src/plugPikiOgawa/ogSub.cpp index 6a227d97..35969891 100644 --- a/src/plugPikiOgawa/ogSub.cpp +++ b/src/plugPikiOgawa/ogSub.cpp @@ -1,87 +1,54 @@ #include "zen/ogSub.h" #include "zen/Number.h" +#include "P2D/TextBox.h" +#include "gameflow.h" +#include "DebugLog.h" +#include "sysNew.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) -{ - // UNUSED FUNCTION -} +DEFINE_ERROR(); /* * --INFO-- * Address: ........ * Size: 0000F4 */ -static void _Print(char*, ...) -{ - // UNUSED FUNCTION -} +DEFINE_PRINT("OgSubSection"); + +namespace zen { +static char workString[0x400]; + +static char wkstr[0x400] = {}; +static char numStrBuf[0x100] = {}; +static char formatStr[0x100] = {}; +static int SpecialNumber[100] = {}; /* * --INFO-- * Address: 8017E850 * Size: 00002C */ -void zen::ogCheckInsCard() -{ - /* - .loc_0x0: - mflr r0 - lis r3, 0x803A - stw r0, 0x4(r1) - subi r3, r3, 0x2848 - addi r3, r3, 0x24 - stwu r1, -0x8(r1) - bl -0x108BE0 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +bool zen::ogCheckInsCard() { return gameflow.mMemoryCard.isCardInserted(); } /* * --INFO-- * Address: 8017E87C * Size: 000068 */ -void zen::calcPuruPuruScale(f32) +f32 zen::calcPuruPuruScale(f32 p1) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stfd f31, 0x18(r1) - lfs f2, -0x50E8(r2) - lfs f0, -0x50E4(r2) - fdivs f1, f1, f2 - fcmpo cr0, f1, f0 - fmr f31, f1 - ble- .loc_0x2C - fmr f31, f0 - - .loc_0x2C: - lfs f0, -0x50E0(r2) - fmuls f1, f0, f31 - bl 0x9D2A4 - lfs f4, -0x50E4(r2) - lfs f3, -0x50DC(r2) - fsubs f2, f4, f31 - fadds f0, f4, f1 - fmuls f1, f3, f2 - fmuls f0, f1, f0 - fadds f1, f4, f0 - lwz r0, 0x24(r1) - lfd f31, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + u32 badCompiler[2]; + + f32 val = (p1 / 0.5f); + if (val > 1.0f) { + val = 1.0f; + } + f32 cosVal = cosf(2.0f * TAU * val); + return 1.0f + (0.08f * (1.0f - val) * (1.0f + cosVal)); } /* @@ -1802,8 +1769,9 @@ void zen::movePicturePos(P2DPicture*, P2DPicture*) * Address: 8017FD40 * Size: 000024 */ -void P2DPane::move(int, int) +void P2DPane::move(int x, int y) { + _18.move(x, y); /* .loc_0x0: mflr r0 @@ -2127,27 +2095,13 @@ void zen::ogTexAnimMgr::update() * Address: 8018011C * Size: 000030 */ -void zen::getSpecialNumber(int) +int zen::getSpecialNumber(int idx) { - /* - .loc_0x0: - cmpwi r3, 0 - blt- .loc_0x10 - cmpwi r3, 0x63 - ble- .loc_0x18 - - .loc_0x10: - li r3, -0x1 - blr + if (idx < 0 || idx > 99) { + return -1; + } - .loc_0x18: - lis r4, 0x802D - rlwinm r3,r3,2,0,29 - addi r0, r4, 0x2D6C - add r3, r0, r3 - lwz r3, 0x0(r3) - blr - */ + return SpecialNumber[idx]; } /* @@ -2155,24 +2109,13 @@ void zen::getSpecialNumber(int) * Address: 8018014C * Size: 00002C */ -void zen::setSpecialNumber(int, int) +void zen::setSpecialNumber(int idx, int value) { - /* - .loc_0x0: - cmpwi r3, 0 - bltlr- - cmpwi r3, 0x63 - ble- .loc_0x14 - blr + if (idx < 0 || idx > 99) { + return; + } - .loc_0x14: - lis r5, 0x802D - rlwinm r3,r3,2,0,29 - addi r0, r5, 0x2D6C - add r3, r0, r3 - stw r4, 0x0(r3) - blr - */ + SpecialNumber[idx] = value; } /* @@ -2348,49 +2291,17 @@ void zen::cnvSpecialNumber(char*) * Address: 80180390 * Size: 000090 */ -zen::TypingTextMgr::TypingTextMgr(P2DTextBox*) +zen::TypingTextMgr::TypingTextMgr(P2DTextBox* textBox) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - crclr 6, 0x6 - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - addi r31, r4, 0 - addi r4, r13, 0x960 - stw r30, 0x18(r1) - addi r30, r3, 0 - stw r31, 0x8(r3) - addi r3, r30, 0x10 - lwz r0, 0x10C(r31) - stw r0, 0xC(r30) - bl 0x961D4 - li r4, 0 - stw r4, 0x0(r30) - li r3, 0x18 - lfs f0, -0x50D8(r2) - stfs f0, 0x410(r30) - sth r4, 0x414(r30) - lbz r0, 0xC(r31) - rlwimi r0,r4,7,24,24 - stb r0, 0xC(r31) - bl -0x1393E8 - addi r31, r3, 0 - mr. r3, r31 - beq- .loc_0x70 - bl 0x98 - - .loc_0x70: - stw r31, 0x4(r30) - mr r3, r30 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + mTextBox = textBox; + mTextPtr = textBox->getText(); + sprintf(mTextBuf, ""); + _00 = 0; + _410 = 0.0f; + _414 = 0; + + textBox->setFlag(0, 7, 1); + mCtrlTagMgr = new ogMsgCtrlTagMgr(); } /* @@ -2400,38 +2311,14 @@ zen::TypingTextMgr::TypingTextMgr(P2DTextBox*) */ void zen::TypingTextMgr::start() { - /* - .loc_0x0: - mflr r0 - addi r4, r13, 0x960 - stw r0, 0x4(r1) - li r0, 0 - crclr 6, 0x6 - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - li r31, 0x1 - stw r30, 0x18(r1) - addi r30, r3, 0 - stw r31, 0x0(r3) - addi r3, r30, 0x10 - lfs f0, -0x50D8(r2) - stfs f0, 0x410(r30) - sth r0, 0x414(r30) - bl 0x9613C - lwz r4, 0x8(r30) - addi r0, r30, 0x10 - lbz r3, 0xC(r4) - rlwimi r3,r31,7,24,24 - stb r3, 0xC(r4) - lwz r3, 0x8(r30) - stw r0, 0x10C(r3) - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + u32 badCompiler; + + _00 = 1; + _410 = 0.0f; + _414 = 0; + sprintf(mTextBuf, ""); + mTextBox->setFlag(1, 7, 1); + mTextBox->setText(mTextBuf); } /* @@ -3383,3 +3270,4 @@ void zen::FigureTex::getNumber(int&) blr */ } +} // namespace zen diff --git a/src/plugPikiOgawa/ogTest.cpp b/src/plugPikiOgawa/ogTest.cpp index 887b772c..83883a16 100644 --- a/src/plugPikiOgawa/ogTest.cpp +++ b/src/plugPikiOgawa/ogTest.cpp @@ -311,11 +311,11 @@ void zen::OgTestScreen::update() mActiveMode = TESTMODE_INACTIVE; } - if (mStartMgr->update(mController) >= 3) { + if (mStartMgr->update(mController) >= START_Exit) { mActiveMode = TESTMODE_INACTIVE; } - if (mFileChkSelMgr->update(mController, CardQuickInfo()) >= 1) { + if (mFileChkSelMgr->update(mController, CardQuickInfo()) >= FILECHKSEL_Exit) { mActiveMode = TESTMODE_INACTIVE; } } diff --git a/src/plugPikiYamashita/P2DGrafContext.cpp b/src/plugPikiYamashita/P2DGrafContext.cpp index d334319d..d9a5f216 100644 --- a/src/plugPikiYamashita/P2DGrafContext.cpp +++ b/src/plugPikiYamashita/P2DGrafContext.cpp @@ -1,25 +1,22 @@ #include "P2D/Graph.h" #include "PUT/Geometry.h" +#include "Colour.h" +#include "Dolphin/gx.h" +#include "DebugLog.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) -{ - // UNUSED FUNCTION -} +DEFINE_ERROR(); /* * --INFO-- * Address: ........ * Size: 0000F4 */ -static void _Print(char*, ...) -{ - // UNUSED FUNCTION -} +DEFINE_PRINT("P2DGrafContext"); /* * --INFO-- @@ -36,56 +33,15 @@ P2DGrafContext::P2DGrafContext(const PUTRect&) * Address: 801AF7AC * Size: 0000B4 */ -P2DGrafContext::P2DGrafContext(int, int, int, int) +P2DGrafContext::P2DGrafContext(int x0, int y0, int width, int height) + : _08(x0, y0, x0 + width, y0 + height) + , _10(x0, y0, x0 + width, y0 + height) { - /* - .loc_0x0: - mflr r0 - lis r8, 0x802E - stw r0, 0x4(r1) - addi r0, r8, 0x5D4 - stwu r1, -0x38(r1) - stmw r27, 0x24(r1) - addi r28, r4, 0 - addi r29, r5, 0 - add r30, r28, r6 - add r31, r29, r7 - addi r27, r3, 0 - addi r6, r30, 0 - addi r7, r31, 0 - stw r0, 0x0(r3) - addi r3, r27, 0x8 - bl 0x3E40 - addi r4, r28, 0 - addi r5, r29, 0 - addi r6, r30, 0 - addi r7, r31, 0 - addi r3, r27, 0x10 - bl 0x3E28 - li r3, 0 - sth r3, 0x2A(r27) - addi r4, r1, 0x1C - li r0, 0xFF - sth r3, 0x2C(r27) - addi r3, r27, 0 - addi r5, r4, 0 - stb r0, 0x1C(r1) - addi r6, r4, 0 - addi r7, r4, 0 - stb r0, 0x1D(r1) - stb r0, 0x1E(r1) - stb r0, 0x1F(r1) - bl 0x340 - addi r3, r27, 0 - li r4, 0x6 - bl 0x3E0 - mr r3, r27 - lmw r27, 0x24(r1) - lwz r0, 0x3C(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ + _2A = 0; + _2C = 0; + Colour colour(255, 255, 255, 255); + setColor(colour, colour, colour, colour); + setLineWidth(6); } /* @@ -95,60 +51,9 @@ P2DGrafContext::P2DGrafContext(int, int, int, int) */ void P2DGrafContext::setPort() { - /* - .loc_0x0: - mflr r0 - lis r5, 0x4330 - stw r0, 0x4(r1) - stwu r1, -0x38(r1) - stw r31, 0x34(r1) - mr r31, r3 - lha r6, 0xA(r3) - lha r0, 0xE(r3) - xoris r4, r6, 0x8000 - lha r7, 0x8(r3) - lha r3, 0xC(r3) - sub r6, r0, r6 - xoris r0, r7, 0x8000 - stw r4, 0x24(r1) - sub r3, r3, r7 - stw r0, 0x2C(r1) - xoris r3, r3, 0x8000 - xoris r0, r6, 0x8000 - lfd f4, -0x4998(r2) - stw r3, 0x1C(r1) - lfs f5, -0x49A0(r2) - stw r0, 0x14(r1) - lfs f6, -0x499C(r2) - stw r5, 0x20(r1) - stw r5, 0x28(r1) - lfd f0, 0x20(r1) - stw r5, 0x18(r1) - lfd f1, 0x28(r1) - fsubs f2, f0, f4 - stw r5, 0x10(r1) - lfd f3, 0x18(r1) - fsubs f1, f1, f4 - lfd f0, 0x10(r1) - fsubs f3, f3, f4 - fsubs f4, f0, f4 - bl 0x64DC0 - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0x1C(r12) - mtlr r12 - blrl - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0x18(r12) - mtlr r12 - blrl - lwz r0, 0x3C(r1) - lwz r31, 0x34(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ + GXSetViewport(_08.mMin.x, _08.mMin.y, _08.getWidth(), _08.getHeight(), 0.0f, 1.0f); + setScissor(); + setup2D(); } /* @@ -158,102 +63,30 @@ void P2DGrafContext::setPort() */ void P2DGrafContext::setup2D() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x58(r1) - stw r31, 0x54(r1) - mr r31, r3 - bl 0x602BC - li r3, 0x9 - li r4, 0x1 - bl 0x5FAB4 - li r3, 0xB - li r4, 0x1 - bl 0x5FAA8 - li r3, 0xD - li r4, 0 - bl 0x5FA9C - addi r3, r31, 0x70 - li r4, 0 - bl 0x64AE4 - li r3, 0x1 - bl 0x6255C - li r3, 0 - bl 0x60DA8 - li r3, 0x1 - bl 0x63FDC - li r3, 0 - li r4, 0x4 - bl 0x63608 - li r3, 0 - li r4, 0xFF - li r5, 0xFF - li r6, 0x4 - bl 0x63E1C - li r3, 0x4 - li r4, 0 - li r5, 0 - li r6, 0x1 - li r7, 0 - li r8, 0 - li r9, 0x2 - bl 0x62558 - addi r3, r1, 0xC - bl -0x171C14 - addi r3, r1, 0xC - li r4, 0x3C - li r5, 0 - bl 0x64B2C - li r3, 0 - bl 0x64AE8 - li r3, 0 - li r4, 0x3 - li r5, 0 - bl 0x643D8 - li r3, 0 - li r4, 0x1 - li r5, 0x4 - li r6, 0x3C - li r7, 0 - li r8, 0x7D - bl 0x60A44 - li r3, 0 - li r4, 0x9 - li r5, 0x1 - li r6, 0x3 - li r7, 0 - bl 0x6021C - li r3, 0 - li r4, 0xB - li r5, 0x1 - li r6, 0x5 - li r7, 0 - bl 0x60204 - li r3, 0 - li r4, 0xD - li r5, 0x1 - li r6, 0x2 - li r7, 0xF - bl 0x601EC - li r3, 0 - li r4, 0xE - li r5, 0x1 - li r6, 0x2 - li r7, 0xF - bl 0x601D4 - lbz r3, 0x28(r31) - li r4, 0 - bl 0x612B8 - li r3, 0 - bl 0x613C0 - lwz r0, 0x5C(r1) - lwz r31, 0x54(r1) - addi r1, r1, 0x58 - mtlr r0 - blr - */ + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetVtxDesc(GX_VA_TEX0, GX_NONE); + GXLoadPosMtxImm(_70.mMtx, 0); + GXSetNumChans(1); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE); + + Matrix4f mtx; + mtx.makeIdentity(); + GXLoadTexMtxImm(mtx.mMtx, GX_IDENTITY, GX_MTX3x4); + GXSetCurrentMtx(GX_TEXMTX_NULL); + GXSetZMode(GX_FALSE, GX_LEQUAL, GX_FALSE); + GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX3X4, GX_TG_TEX0, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_POS_XYZ, GX_RGBA8, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_POS_XYZ, GX_U16, 15); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX1, GX_POS_XYZ, GX_U16, 15); + GXSetLineWidth(mLineWidth, GX_TO_ZERO); + GXSetCullMode(GX_CULL_NONE); } /* @@ -263,51 +96,14 @@ void P2DGrafContext::setup2D() */ void P2DGrafContext::setScissor() { - /* - .loc_0x0: - mflr r0 - li r4, 0 - stw r0, 0x4(r1) - li r5, 0 - li r6, 0x3E8 - stwu r1, -0x28(r1) - li r7, 0x3E8 - stw r31, 0x24(r1) - addi r31, r3, 0 - addi r3, r1, 0x14 - bl 0x3B60 - addi r3, r1, 0xC - addi r4, r31, 0x10 - bl 0x3B78 - addi r3, r31, 0x10 - addi r4, r1, 0x14 - bl 0x3BC4 - addi r3, r1, 0xC - bl 0x3C9C - addi r3, r1, 0xC - li r4, 0 - li r5, -0x1 - bl 0x3B78 - addi r3, r1, 0xC - addi r4, r1, 0x14 - bl 0x3BA0 - rlwinm. r0,r3,0,24,31 - beq- .loc_0x8C - lha r4, 0xE(r1) - lha r5, 0x12(r1) - lha r3, 0xC(r1) - lha r0, 0x10(r1) - sub r6, r5, r4 - sub r5, r0, r3 - bl 0x64BA8 - - .loc_0x8C: - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + PUTRect bounds(0, 0, 1000, 1000); + PUTRect scissor = _10; + _10.intersect(bounds); + scissor.normalize(); + scissor.add(0, -1); + if (scissor.intersect(bounds)) { + GXSetScissor(scissor.mMin.x, scissor.mMin.y, scissor.getWidth(), scissor.getHeight()); + } } /* @@ -315,37 +111,17 @@ void P2DGrafContext::setScissor() * Address: 801AFB40 * Size: 000014 */ -void P2DGrafContext::scissor(const PUTRect&) -{ - /* - .loc_0x0: - lwz r5, 0x0(r4) - lwz r0, 0x4(r4) - stw r5, 0x10(r3) - stw r0, 0x14(r3) - blr - */ -} +void P2DGrafContext::scissor(const PUTRect& rect) { _10 = rect; } /* * --INFO-- * Address: 801AFB54 * Size: 000024 */ -void P2DGrafContext::place(const PUTRect&) +void P2DGrafContext::place(const PUTRect& position) { - /* - .loc_0x0: - lwz r5, 0x0(r4) - lwz r0, 0x4(r4) - stw r5, 0x8(r3) - stw r0, 0xC(r3) - lwz r5, 0x0(r4) - lwz r0, 0x4(r4) - stw r5, 0x10(r3) - stw r0, 0x14(r3) - blr - */ + _08 = position; + _10 = position; } /* @@ -353,54 +129,45 @@ void P2DGrafContext::place(const PUTRect&) * Address: 801AFB78 * Size: 0000AC */ -void P2DGrafContext::setColor(Colour&, Colour&, Colour&, Colour&) +void P2DGrafContext::setColor(Colour& p1, Colour& p2, Colour& p3, Colour& p4) { - /* - .loc_0x0: - lwz r0, 0x0(r4) - li r8, 0x1 - li r4, 0x4 - stw r0, 0x18(r3) - li r0, 0x5 - lwz r5, 0x0(r5) - stw r5, 0x1C(r3) - lwz r5, 0x0(r6) - stw r5, 0x20(r3) - lwz r5, 0x0(r7) - stw r5, 0x24(r3) - stw r8, 0xB0(r3) - stw r4, 0xB4(r3) - stw r0, 0xB8(r3) - stw r8, 0xBC(r3) - stw r4, 0xC0(r3) - stw r0, 0xC4(r3) - stw r8, 0xC8(r3) - stw r4, 0xCC(r3) - stw r0, 0xD0(r3) - lbz r0, 0x1B(r3) - cmplwi r0, 0xFF - bnelr- - li r4, 0 - stw r4, 0xB0(r3) - stw r8, 0xB4(r3) - stw r4, 0xB8(r3) - lbz r0, 0x23(r3) - cmplwi r0, 0xFF - bnelr- - stw r4, 0xBC(r3) - stw r8, 0xC0(r3) - stw r4, 0xC4(r3) - lbz r0, 0x1F(r3) - cmplwi r0, 0xFF - bnelr- - lbz r0, 0x27(r3) - cmplwi r0, 0xFF - bnelr- - stw r4, 0xC8(r3) - stw r8, 0xCC(r3) - stw r4, 0xD0(r3) - blr - */ + _18 = p1; + _1C = p2; + _20 = p3; + _24 = p4; + + _B0 = 1; + _B4 = 4; + _B8 = 5; + + _BC = 1; + _C0 = 4; + _C4 = 5; + + _C8 = 1; + _CC = 4; + _D0 = 5; + + if (_18.a != 255) { + return; + } + _B0 = 0; + _B4 = 1; + _B8 = 0; + + if (_20.a != 255) { + return; + } + + _BC = 0; + _C0 = 1; + _C4 = 0; + + if (_1C.a == 255 && _24.a == 255) { + _C8 = 0; + _CC = 1; + _D0 = 0; + } } /* @@ -408,22 +175,10 @@ void P2DGrafContext::setColor(Colour&, Colour&, Colour&, Colour&) * Address: 801AFC24 * Size: 00002C */ -void P2DGrafContext::setLineWidth(u8) +void P2DGrafContext::setLineWidth(u8 width) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - stb r4, 0x28(r3) - li r4, 0 - lbz r3, 0x28(r3) - bl 0x610FC - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + mLineWidth = width; + GXSetLineWidth(mLineWidth, GX_TO_ZERO); } /* @@ -505,75 +260,3 @@ void P2DGrafContext::polylineTo(int*, int) { // UNUSED FUNCTION } - -/* - * --INFO-- - * Address: 801AFC50 - * Size: 00004C - */ -P2DGrafContext::~P2DGrafContext() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr. r31, r3 - beq- .loc_0x34 - lis r3, 0x802E - addi r3, r3, 0x5D4 - extsh. r0, r4 - stw r3, 0x0(r31) - ble- .loc_0x34 - mr r3, r31 - bl -0x168AD4 - - .loc_0x34: - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} - -/* - * --INFO-- - * Address: 801AFC9C - * Size: 000050 - */ -void P2DGrafContext::place(int, int, int, int) -{ - /* - .loc_0x0: - mflr r0 - add r6, r4, r6 - stw r0, 0x4(r1) - add r7, r5, r7 - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - addi r31, r3, 0 - addi r3, r1, 0x1C - bl 0x396C - lwz r12, 0x0(r31) - mr r3, r31 - addi r4, r1, 0x1C - lwz r12, 0xC(r12) - mtlr r12 - blrl - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ -} - -/* - * --INFO-- - * Address: 801AFCEC - * Size: 000004 - */ -void P2DGrafContext::setLookat() { } diff --git a/src/plugPikiYamashita/P2DPane.cpp b/src/plugPikiYamashita/P2DPane.cpp index 24c31902..12de2269 100644 --- a/src/plugPikiYamashita/P2DPane.cpp +++ b/src/plugPikiYamashita/P2DPane.cpp @@ -1,6 +1,8 @@ #include "P2D/Pane.h" #include "PSU/LinkList.h" #include "PSU/Tree.h" +#include "DebugLog.h" +#include "Dolphin/gx.h" /* * --INFO-- @@ -17,37 +19,29 @@ static void _Error(char*, ...) * Address: ........ * Size: 0000F0 */ -static void _Print(char*, ...) -{ - // UNUSED FUNCTION -} +DEFINE_PRINT("P2DPane"); /* * --INFO-- * Address: 801B069C * Size: 000008 */ -void P2DPane::setCallBack(P2DPaneCallBack* callback) -{ - // Generated from stw r4, 0x4(r3) - mCallBack = callback; -} +void P2DPane::setCallBack(P2DPaneCallBack* callback) { mCallBack = callback; } /* * --INFO-- * Address: 801B06A4 * Size: 000014 */ -void P2DPane::printTagName(bool) +void P2DPane::printTagName(bool doPrint) { - /* - .loc_0x0: - rlwinm. r0,r4,0,24,31 - beqlr- - lwz r0, 0x10(r3) - cmplwi r0, 0 - blr - */ + if (doPrint) { + if (mTagName) { + PRINT("tag[%c%c%c%c] \n", ((u8*)&mTagName)[0], ((u8*)&mTagName)[1], ((u8*)&mTagName)[2], ((u8*)&mTagName)[3]); + } else { + PRINT("tag[]\n"); + } + } } /* @@ -55,31 +49,13 @@ void P2DPane::printTagName(bool) * Address: 801B06B8 * Size: 000048 */ -void P2DPane::drawSelf(int, int, Matrix4f*) +void P2DPane::drawSelf(int, int, Matrix4f* drawMtx) { - /* - .loc_0x0: - mflr r0 - mr r4, r3 - stw r0, 0x4(r1) - stwu r1, -0x58(r1) - lwz r0, 0x4(r3) - cmplwi r0, 0 - beq- .loc_0x38 - addi r3, r6, 0 - addi r4, r4, 0x78 - addi r5, r1, 0x18 - bl -0x17260C - addi r3, r1, 0x18 - li r4, 0 - bl 0x63D68 - - .loc_0x38: - lwz r0, 0x5C(r1) - addi r1, r1, 0x58 - mtlr r0 - blr - */ + if (mCallBack) { + Matrix4f posMtx; + drawMtx->multiplyTo(_78, posMtx); + GXLoadPosMtxImm(posMtx.mMtx, 0); + } } /* @@ -87,42 +63,19 @@ void P2DPane::drawSelf(int, int, Matrix4f*) * Address: 801B0700 * Size: 000030 */ -P2DPaneCallBackBase::P2DPaneCallBackBase(P2DPane*, P2DPaneType) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr r31, r3 - bl .loc_0x30 - mr r3, r31 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - - .loc_0x30: - */ -} +P2DPaneCallBackBase::P2DPaneCallBackBase(P2DPane* pane, P2DPaneType type) { checkPaneType(pane, type); } /* * --INFO-- * Address: 801B0730 * Size: 000014 */ -void P2DPaneCallBackBase::checkPaneType(P2DPane*, P2DPaneType) +void P2DPaneCallBackBase::checkPaneType(P2DPane* pane, P2DPaneType type) { - /* - .loc_0x0: - cmplwi r4, 0 - beqlr- - lhz r0, 0x8(r4) - cmpw r5, r0 - blr - */ + if (pane && pane->getPaneType() != type) { + PRINT("This pane type is [%d]. not [%d] \n", pane->getPaneType(), type); + ERROR("Can't set Call Back class."); + } } /* @@ -142,6 +95,16 @@ void P2DPane::init() */ void P2DPane::update() { + if (mCallBack) { + mCallBack->invoke(this); + } + + PSUTree* tree = getPaneTree(); + PSUTreeIterator iterator(tree->getFirstChild()); + while (iterator != nullptr) { + iterator->update(); + iterator++; + } /* .loc_0x0: mflr r0 @@ -246,113 +209,27 @@ void P2DPane::update() */ } -/* - * --INFO-- - * Address: 801B0878 - * Size: 000008 - */ -void PSUPtrList::getFirstLink() const -{ - /* - .loc_0x0: - lwz r3, 0x0(r3) - blr - */ -} - /* * --INFO-- * Address: 801B0880 * Size: 00014C */ P2DPane::P2DPane() + : mPaneTree(this) { - /* - .loc_0x0: - mflr r0 - li r4, 0 - stw r0, 0x4(r1) - li r5, 0 - li r6, 0 - stwu r1, -0x18(r1) - li r7, 0 - stw r31, 0x14(r1) - stw r30, 0x10(r1) - stw r3, 0x8(r1) - lis r3, 0x802E - addi r0, r3, 0x6C0 - lwz r30, 0x8(r1) - stw r0, 0x0(r30) - addi r3, r30, 0x18 - bl 0x2D6C - addi r3, r30, 0x20 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2D54 - addi r3, r30, 0x28 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2D3C - addi r3, r30, 0x30 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2D24 - lfs f0, -0x4958(r2) - addi r0, r30, 0xD0 - stfs f0, 0xC8(r30) - stfs f0, 0xC4(r30) - stfs f0, 0xC0(r30) - stw r0, 0xC(r1) - lwz r31, 0xC(r1) - mr r3, r31 - bl 0x2B80 - addi r3, r31, 0xC - addi r4, r30, 0 - bl 0x2A94 - li r0, 0x10 - sth r0, 0x8(r30) - li r3, 0x1 - li r31, 0 - lbz r0, 0xC(r30) - rlwimi r0,r3,7,24,24 - addi r3, r30, 0x18 - stb r0, 0xC(r30) - li r4, 0 - li r5, 0 - stw r31, 0x10(r30) - li r6, 0 - li r7, 0 - bl 0x2CBC - sth r31, 0xB8(r30) - mr r3, r30 - sth r31, 0xBA(r30) - lbz r0, 0xC(r30) - rlwimi r0,r31,5,25,26 - stb r0, 0xC(r30) - lfs f1, -0x4958(r2) - stfs f1, 0xBC(r30) - lfs f0, 0x18D8(r13) - stfs f0, 0xC0(r30) - lfs f0, 0x18DC(r13) - stfs f0, 0xC4(r30) - lfs f0, 0x18E0(r13) - stfs f0, 0xC8(r30) - stw r31, 0xCC(r30) - stw r31, 0x4(r30) - stfs f1, 0x14(r30) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + mPaneType = PANETYPE_Unk16; + + setFlag(1, 7, 1); + mTagName = 0; + _18.set(0, 0, 0, 0); + _B8 = 0; + _BA = 0; + setFlag(0, 5, 2); + _BC = 0.0f; + _C0.set(1.0f, 1.0f, 1.0f); + mCullMode = GX_CULL_NONE; + mCallBack = nullptr; + mPaneZ = 0.0f; } /* @@ -390,105 +267,25 @@ PSUList::~PSUList() * Address: 801B09CC * Size: 000168 */ -P2DPane::P2DPane(P2DPane*, u16, bool, u32, const PUTRect&) +P2DPane::P2DPane(P2DPane* parent, u16 paneType, bool, u32 tag, const PUTRect& p5) + : mPaneTree(this) { - /* - .loc_0x0: - mflr r0 - li r6, 0 - stw r0, 0x4(r1) - stwu r1, -0x40(r1) - stmw r25, 0x24(r1) - addi r25, r4, 0 - addi r26, r5, 0 - addi r27, r7, 0 - addi r28, r8, 0 - li r4, 0 - li r5, 0 - li r7, 0 - stw r3, 0x8(r1) - lis r3, 0x802E - addi r0, r3, 0x6C0 - lwz r31, 0x8(r1) - stw r0, 0x0(r31) - addi r3, r31, 0x18 - bl 0x2C14 - addi r3, r31, 0x20 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2BFC - addi r3, r31, 0x28 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2BE4 - addi r3, r31, 0x30 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2BCC - lfs f0, -0x4958(r2) - addi r29, r31, 0xD0 - stfs f0, 0xC8(r31) - stfs f0, 0xC4(r31) - stfs f0, 0xC0(r31) - stw r29, 0x1C(r1) - lwz r30, 0x1C(r1) - mr r3, r30 - bl 0x2A28 - addi r3, r30, 0xC - addi r4, r31, 0 - bl 0x293C - sth r26, 0x8(r31) - li r3, 0x1 - cmplwi r25, 0 - lbz r0, 0xC(r31) - rlwimi r0,r3,7,24,24 - stb r0, 0xC(r31) - stw r27, 0x10(r31) - lwz r3, 0x0(r28) - lwz r0, 0x4(r28) - stw r3, 0x18(r31) - stw r0, 0x1C(r31) - beq- .loc_0x10C - cmplwi r29, 0 - beq- .loc_0x100 - addi r29, r29, 0xC - - .loc_0x100: - addi r4, r29, 0 - addi r3, r25, 0xD0 - bl 0x29E8 - - .loc_0x10C: - lwz r3, 0x8(r1) - li r4, 0 - sth r4, 0xB8(r3) - sth r4, 0xBA(r3) - lbz r0, 0xC(r3) - rlwimi r0,r4,5,25,26 - stb r0, 0xC(r3) - lfs f1, -0x4958(r2) - stfs f1, 0xBC(r3) - lfs f0, 0x18D8(r13) - stfs f0, 0xC0(r3) - lfs f0, 0x18DC(r13) - stfs f0, 0xC4(r3) - lfs f0, 0x18E0(r13) - stfs f0, 0xC8(r3) - stw r4, 0xCC(r3) - stw r4, 0x4(r3) - stfs f1, 0x14(r3) - lmw r25, 0x24(r1) - lwz r0, 0x44(r1) - addi r1, r1, 0x40 - mtlr r0 - blr - */ + mPaneType = paneType; + setFlag(1, 7, 1); + mTagName = tag; + _18 = p5; + if (parent) { + parent->mPaneTree.append(getPaneTree()); + } + + _B8 = 0; + _BA = 0; + setFlag(0, 5, 2); + _BC = 0.0f; + _C0.set(1.0f, 1.0f, 1.0f); + mCullMode = GX_CULL_NONE; + mCallBack = nullptr; + mPaneZ = 0.0f; } /* @@ -497,6 +294,7 @@ P2DPane::P2DPane(P2DPane*, u16, bool, u32, const PUTRect&) * Size: 000158 */ P2DPane::P2DPane(u32, const PUTRect&) + : mPaneTree(this) { // UNUSED FUNCTION } @@ -507,6 +305,7 @@ P2DPane::P2DPane(u32, const PUTRect&) * Size: 000140 */ P2DPane::P2DPane(u16, u32, const PUTRect&) + : mPaneTree(this) { // UNUSED FUNCTION } @@ -516,187 +315,42 @@ P2DPane::P2DPane(u16, u32, const PUTRect&) * Address: 801B0B34 * Size: 000290 */ -P2DPane::P2DPane(P2DPane*, RandomAccessStream*, u16) +P2DPane::P2DPane(P2DPane* parent, RandomAccessStream* input, u16 paneType) + : mPaneTree(this) { - /* - .loc_0x0: - mflr r0 - li r7, 0 - stw r0, 0x4(r1) - stwu r1, -0x38(r1) - stmw r27, 0x24(r1) - addi r30, r4, 0 - addi r31, r5, 0 - addi r27, r6, 0 - li r4, 0 - li r5, 0 - li r6, 0 - stw r3, 0x8(r1) - lis r3, 0x802E - addi r0, r3, 0x6C0 - lwz r29, 0x8(r1) - stw r0, 0x0(r29) - addi r3, r29, 0x18 - bl 0x2AB0 - addi r3, r29, 0x20 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2A98 - addi r3, r29, 0x28 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2A80 - addi r3, r29, 0x30 - li r4, 0 - li r5, 0 - li r6, 0 - li r7, 0 - bl 0x2A68 - lfs f0, -0x4958(r2) - addi r0, r29, 0xD0 - stfs f0, 0xC8(r29) - stfs f0, 0xC4(r29) - stfs f0, 0xC0(r29) - stw r0, 0x18(r1) - lwz r28, 0x18(r1) - mr r3, r28 - bl 0x28C4 - addi r3, r28, 0xC - addi r4, r29, 0 - bl 0x27D8 - sth r27, 0x8(r29) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - bne- .loc_0xE8 - li r0, 0 - b .loc_0xEC - - .loc_0xE8: - li r0, 0x1 - - .loc_0xEC: - cmpwi r0, 0 - beq- .loc_0x10C - lwz r3, 0x8(r1) - li r4, 0x1 - lbz r0, 0xC(r3) - rlwimi r0,r4,7,24,24 - stb r0, 0xC(r3) - b .loc_0x120 - - .loc_0x10C: - lwz r3, 0x8(r1) - li r4, 0 - lbz r0, 0xC(r3) - rlwimi r0,r4,7,24,24 - stb r0, 0xC(r3) - - .loc_0x120: - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - stb r3, 0x1C(r1) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - stb r3, 0x1D(r1) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - stb r3, 0x1E(r1) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - stb r3, 0x1F(r1) - mr r3, r31 - lwz r29, 0x8(r1) - lwz r0, 0x1C(r1) - stw r0, 0x10(r29) - lwz r12, 0x4(r31) - lwz r12, 0x10(r12) - mtlr r12 - blrl - extsh r0, r3 - sth r0, 0x18(r29) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0x10(r12) - mtlr r12 - blrl - extsh r0, r3 - sth r0, 0x1A(r29) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0x10(r12) - mtlr r12 - blrl - lha r0, 0x18(r29) - add r0, r0, r3 - sth r0, 0x1C(r29) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0x10(r12) - mtlr r12 - blrl - lha r0, 0x1A(r29) - cmplwi r30, 0 - add r0, r0, r3 - sth r0, 0x1E(r29) - beq- .loc_0x234 - addic. r4, r29, 0xD0 - beq- .loc_0x22C - addi r4, r4, 0xC - - .loc_0x22C: - addi r3, r30, 0xD0 - bl 0x2758 - - .loc_0x234: - lwz r3, 0x8(r1) - li r4, 0 - sth r4, 0xB8(r3) - sth r4, 0xBA(r3) - lbz r0, 0xC(r3) - rlwimi r0,r4,5,25,26 - stb r0, 0xC(r3) - lfs f1, -0x4958(r2) - stfs f1, 0xBC(r3) - lfs f0, 0x18D8(r13) - stfs f0, 0xC0(r3) - lfs f0, 0x18DC(r13) - stfs f0, 0xC4(r3) - lfs f0, 0x18E0(r13) - stfs f0, 0xC8(r3) - stw r4, 0xCC(r3) - stw r4, 0x4(r3) - stfs f1, 0x14(r3) - lmw r27, 0x24(r1) - lwz r0, 0x3C(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ + mPaneType = paneType; + if (input->checkInput()) { + setFlag(1, 7, 1); + } else { + setFlag(0, 7, 1); + } + + u8 tag[4]; + input->readByte(); + tag[0] = input->readByte(); + tag[1] = input->readByte(); + tag[2] = input->readByte(); + tag[3] = input->readByte(); + + mTagName = *(u32*)tag; + + _18.mMin.x = (int)input->readShort(); + _18.mMin.y = (int)input->readShort(); + _18.mMax.x = _18.mMin.x + (int)input->readShort(); + _18.mMax.y = _18.mMin.y + (int)input->readShort(); + + if (parent) { + parent->mPaneTree.append(getPaneTree()); + } + + _B8 = 0; + _BA = 0; + setFlag(0, 5, 2); + _BC = 0.0f; + _C0.set(1.0f, 1.0f, 1.0f); + mCullMode = GX_CULL_NONE; + mCallBack = nullptr; + mPaneZ = 0.0f; } /* @@ -706,77 +360,11 @@ P2DPane::P2DPane(P2DPane*, RandomAccessStream*, u16) */ P2DPane::~P2DPane() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x70(r1) - stw r31, 0x6C(r1) - stw r30, 0x68(r1) - addi r30, r4, 0 - stw r29, 0x64(r1) - mr. r29, r3 - beq- .loc_0xC0 - lis r3, 0x802E - addi r0, r3, 0x6C0 - stw r0, 0x0(r29) - lwz r31, 0xD0(r29) - cmplwi r31, 0 - beq- .loc_0x78 - subi r31, r31, 0xC - b .loc_0x78 - - .loc_0x44: - lwz r4, 0x18(r31) - cmplwi r4, 0 - beq- .loc_0x54 - subi r4, r4, 0xC - - .loc_0x54: - lwz r3, 0xC(r31) - addi r31, r4, 0 - cmplwi r3, 0 - beq- .loc_0x78 - lwz r12, 0x0(r3) - li r4, 0x1 - lwz r12, 0x10(r12) - mtlr r12 - blrl - - .loc_0x78: - cmplwi r31, 0 - bne+ .loc_0x44 - addic. r0, r29, 0xD0 - beq- .loc_0xB0 - addic. r0, r29, 0xDC - beq- .loc_0x9C - addi r3, r29, 0xDC - li r4, 0 - bl 0x2584 - - .loc_0x9C: - addic. r0, r29, 0xD0 - beq- .loc_0xB0 - addi r3, r29, 0xD0 - li r4, 0 - bl 0x25D0 - - .loc_0xB0: - extsh. r0, r30 - ble- .loc_0xC0 - mr r3, r29 - bl -0x169CD4 - - .loc_0xC0: - mr r3, r29 - lwz r0, 0x74(r1) - lwz r31, 0x6C(r1) - lwz r30, 0x68(r1) - lwz r29, 0x64(r1) - addi r1, r1, 0x70 - mtlr r0 - blr - */ + PSUTree* tree = getPaneTree(); + PSUTreeIterator iterator(tree->getFirstChild()); + while (iterator != nullptr) { + delete (iterator++).getObject(); + } } /* @@ -1115,30 +703,11 @@ void P2DPane::draw(int, int, const P2DGrafContext*, bool) * Address: 801B1348 * Size: 00004C */ -void P2DPane::clip(const PUTRect&) +bool P2DPane::clip(const PUTRect& rect) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - addi r31, r3, 0 - addi r3, r1, 0x10 - bl 0x22EC - lha r4, 0x20(r31) - addi r3, r1, 0x10 - lha r5, 0x22(r31) - bl 0x2300 - addi r3, r31, 0x28 - addi r4, r1, 0x10 - bl 0x2328 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + PUTRect newRect = rect; + newRect.add(_20.mMin.x, _20.mMin.y); + return _28.intersect(newRect); } /* @@ -1146,7 +715,7 @@ void P2DPane::clip(const PUTRect&) * Address: 801B1394 * Size: 0000A4 */ -void P2DPane::search(u32, bool) +P2DPane* P2DPane::search(u32, bool) { /* .loc_0x0: @@ -1499,36 +1068,10 @@ void P2DPane::makeResident() { } * Address: 801B17A8 * Size: 000064 */ -void P2DPane::move(Vector3f&) +void P2DPane::move(Vector3f& newPos) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - mr r31, r4 - stw r30, 0x20(r1) - mr r30, r3 - addi r3, r30, 0x18 - lfs f1, 0x0(r4) - lfs f0, 0x4(r4) - fctiwz f1, f1 - fctiwz f0, f0 - stfd f1, 0x18(r1) - stfd f0, 0x10(r1) - lwz r4, 0x1C(r1) - lwz r5, 0x14(r1) - bl 0x1F3C - lfs f0, 0x8(r31) - stfs f0, 0x14(r30) - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + _18.move(newPos.x, newPos.y); + mPaneZ = newPos.z; } /* @@ -1536,91 +1079,30 @@ void P2DPane::move(Vector3f&) * Address: 801B180C * Size: 000008 */ -void P2DPane::moveZ(f32) -{ - /* - .loc_0x0: - stfs f1, 0x14(r3) - blr - */ -} +void P2DPane::moveZ(f32 newZ) { mPaneZ = newZ; } /* * --INFO-- * Address: 801B1814 * Size: 000024 */ -void P2DPane::add(int, int) -{ - /* - .loc_0x0: - mflr r0 - addi r3, r3, 0x18 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - bl 0x1E4C - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void P2DPane::add(int x, int y) { _18.add(x, y); } /* * --INFO-- * Address: 801B1838 * Size: 000024 */ -void P2DPane::resize(int, int) -{ - /* - .loc_0x0: - mflr r0 - addi r3, r3, 0x18 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - bl 0x1F20 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void P2DPane::resize(int width, int height) { _18.resize(width, height); } /* * --INFO-- * Address: 801B185C * Size: 000068 */ -void P2DPane::drawSelf(int, int) +void P2DPane::drawSelf(int p1, int p2) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x68(r1) - stw r31, 0x64(r1) - addi r31, r5, 0 - stw r30, 0x60(r1) - addi r30, r4, 0 - stw r29, 0x5C(r1) - addi r29, r3, 0 - addi r3, r1, 0x14 - bl -0x173AC8 - mr r3, r29 - lwz r12, 0x0(r29) - addi r4, r30, 0 - addi r5, r31, 0 - lwz r12, 0x30(r12) - addi r6, r1, 0x14 - mtlr r12 - blrl - lwz r0, 0x6C(r1) - lwz r31, 0x64(r1) - lwz r30, 0x60(r1) - lwz r29, 0x5C(r1) - addi r1, r1, 0x68 - mtlr r0 - blr - */ + Matrix4f mtx; + mtx.makeIdentity(); + drawSelf(p1, p2, &mtx); } diff --git a/src/plugPikiYamashita/P2DPerspGraph.cpp b/src/plugPikiYamashita/P2DPerspGraph.cpp index e23b9385..2668a541 100644 --- a/src/plugPikiYamashita/P2DPerspGraph.cpp +++ b/src/plugPikiYamashita/P2DPerspGraph.cpp @@ -37,7 +37,7 @@ P2DPerspGraph::P2DPerspGraph() * Size: 000084 */ P2DPerspGraph::P2DPerspGraph(const PUTRect& rect, f32, f32, f32) - : P2DGrafContext(rect) // TODO: fix later + : P2DGrafContext(rect) { // UNUSED FUNCTION } @@ -47,47 +47,11 @@ P2DPerspGraph::P2DPerspGraph(const PUTRect& rect, f32, f32, f32) * Address: 801B0190 * Size: 000084 */ -P2DPerspGraph::P2DPerspGraph(int p1, int p2, int p3, int p4, f32, f32, f32) - : P2DGrafContext(p1, p2, p3, p4) // TODO: fix later +P2DPerspGraph::P2DPerspGraph(int x0, int y0, int width, int height, f32 p5, f32 p6, f32 p7) + : P2DGrafContext(x0, y0, width, height) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x48(r1) - stfd f31, 0x40(r1) - fmr f31, f3 - stfd f30, 0x38(r1) - fmr f30, f2 - stfd f29, 0x30(r1) - fmr f29, f1 - stw r31, 0x2C(r1) - stw r3, 0x8(r1) - lwz r3, 0x8(r1) - bl -0xA14 - lwz r31, 0x8(r1) - lis r3, 0x802E - addi r0, r3, 0x698 - fmr f1, f29 - fmr f2, f30 - fmr f3, f31 - stw r0, 0x0(r31) - mr r3, r31 - bl .loc_0x84 - li r0, 0x2 - stw r0, 0x4(r31) - mr r3, r31 - lwz r0, 0x4C(r1) - lfd f31, 0x40(r1) - lfd f30, 0x38(r1) - lfd f29, 0x30(r1) - lwz r31, 0x2C(r1) - addi r1, r1, 0x48 - mtlr r0 - blr - - .loc_0x84: - */ + set(p5, p6, p7); + mGrafType = P2DGRAF_Persp; } /* @@ -95,37 +59,12 @@ P2DPerspGraph::P2DPerspGraph(int p1, int p2, int p3, int p4, f32, f32, f32) * Address: 801B0214 * Size: 000060 */ -void P2DPerspGraph::set(f32, f32, f32) +void P2DPerspGraph::set(f32 fovy, f32 p2, f32 p3) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stfd f31, 0x28(r1) - fmr f31, f3 - stfd f30, 0x20(r1) - fmr f30, f2 - stw r31, 0x1C(r1) - mr r31, r3 - bl .loc_0x60 - stfs f30, 0xD8(r31) - mr r3, r31 - stfs f31, 0xDC(r31) - lwz r12, 0x0(r31) - lwz r12, 0x20(r12) - mtlr r12 - blrl - lwz r0, 0x34(r1) - lfd f31, 0x28(r1) - lfd f30, 0x20(r1) - lwz r31, 0x1C(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - - .loc_0x60: - */ + setFovy(fovy); + _D8 = p2; + _DC = p3; + setLookat(); } /* @@ -133,24 +72,14 @@ void P2DPerspGraph::set(f32, f32, f32) * Address: 801B0274 * Size: 00002C */ -void P2DPerspGraph::setFovy(f32) +void P2DPerspGraph::setFovy(f32 fovy) { - /* - .loc_0x0: - stfs f1, 0xD4(r3) - lfs f0, -0x4980(r2) - fcmpo cr0, f1, f0 - bge- .loc_0x18 - stfs f0, 0xD4(r3) - blr - - .loc_0x18: - lfs f0, -0x497C(r2) - fcmpo cr0, f1, f0 - blelr- - stfs f0, 0xD4(r3) - blr - */ + mFovy = fovy; + if (fovy < 1.0f) { + mFovy = 1.0f; + } else if (fovy > 179.0f) { + mFovy = 179.0f; + } } /* @@ -170,6 +99,7 @@ void P2DPerspGraph::getMatrix(Matrix4f&) */ void P2DPerspGraph::setPort() { + P2DGrafContext::setPort(); /* .loc_0x0: mflr r0 diff --git a/src/plugPikiYamashita/P2DScreen.cpp b/src/plugPikiYamashita/P2DScreen.cpp index 8c47e79e..5193f70e 100644 --- a/src/plugPikiYamashita/P2DScreen.cpp +++ b/src/plugPikiYamashita/P2DScreen.cpp @@ -572,7 +572,7 @@ void P2DScreen::draw(int, int, const P2DGrafContext*) * Address: 801B31FC * Size: 000030 */ -void P2DScreen::search(u32, bool) +P2DPane* P2DScreen::search(u32, bool) { /* .loc_0x0: diff --git a/src/plugPikiYamashita/P2DStream.cpp b/src/plugPikiYamashita/P2DStream.cpp index cf17b3e3..16a7770e 100644 --- a/src/plugPikiYamashita/P2DStream.cpp +++ b/src/plugPikiYamashita/P2DStream.cpp @@ -1,4 +1,5 @@ #include "P2D/Stream.h" +#include "sysNew.h" /* * --INFO-- @@ -25,8 +26,26 @@ static void _Print(char*, ...) * Address: 801B3274 * Size: 0000C4 */ -void P2DStream::getResource(int) +void* P2DStream::getResource(int) { + u8 resType = mStream->readByte(); + u8 resSize = mStream->readByte(); + u8 size = resSize; + void* res = nullptr; + if (resSize) { + res = new u8[resSize + 1]; + switch (resType) { + case 0: + case 2: + mStream->read(res, resSize); + ((u8*)res)[size & 0xFF] = 0; + break; + case 1: + break; + } + } + + return res; /* .loc_0x0: mflr r0 @@ -92,8 +111,15 @@ void P2DStream::getResource(int) * Address: 801B3338 * Size: 000090 */ -void P2DStream::align(int) +void P2DStream::align(int alignment) { + int pos = mStream->getPosition(); + int newPos = alignment + pos; + u32 realign = ~(alignment - 1 | alignment - 1); + int diff = (realign & (newPos - 1)) - pos; + for (int i = 0; i < diff; i++) { + mStream->readByte(); + } /* .loc_0x0: mflr r0 diff --git a/src/plugPikiYamashita/PSUList.cpp b/src/plugPikiYamashita/PSUList.cpp index 8aa38465..1248f9fe 100644 --- a/src/plugPikiYamashita/PSUList.cpp +++ b/src/plugPikiYamashita/PSUList.cpp @@ -5,17 +5,12 @@ * Address: 801B33C8 * Size: 000018 */ -PSUPtrLink::PSUPtrLink(void*) +PSUPtrLink::PSUPtrLink(void* value) { - /* - .loc_0x0: - li r0, 0 - stw r0, 0x4(r3) - stw r4, 0x0(r3) - stw r0, 0x8(r3) - stw r0, 0xC(r3) - blr - */ + mList = nullptr; + mObject = value; + mPrev = nullptr; + mNext = nullptr; } /* @@ -25,37 +20,9 @@ PSUPtrLink::PSUPtrLink(void*) */ PSUPtrLink::~PSUPtrLink() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r4, 0 - stw r30, 0x10(r1) - mr. r30, r3 - beq- .loc_0x44 - lwz r3, 0x4(r30) - cmplwi r3, 0 - beq- .loc_0x34 - mr r4, r30 - bl 0x168 - - .loc_0x34: - extsh. r0, r31 - ble- .loc_0x44 - mr r3, r30 - bl -0x16C274 - - .loc_0x44: - mr r3, r30 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + if (mList) { + mList->remove(this); + } } /* @@ -75,41 +42,11 @@ PSUPtrList::PSUPtrList(bool) */ PSUPtrList::~PSUPtrList() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr. r31, r3 - beq- .loc_0x50 - lwz r5, 0x0(r31) - li r6, 0 - li r3, 0 - b .loc_0x34 - - .loc_0x28: - stw r3, 0x4(r5) - addi r6, r6, 0x1 - lwz r5, 0xC(r5) - - .loc_0x34: - lwz r0, 0x8(r31) - cmplw r6, r0 - blt+ .loc_0x28 - extsh. r0, r4 - ble- .loc_0x50 - mr r3, r31 - bl -0x16C2E0 - - .loc_0x50: - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + PSUPtrLink* link = mHead; + for (int i = 0; i < mLinkCount; i++) { + link->mList = nullptr; + link = link->mNext; + } } /* @@ -119,14 +56,9 @@ PSUPtrList::~PSUPtrList() */ void PSUPtrList::initiate() { - /* - .loc_0x0: - li r0, 0 - stw r0, 0x0(r3) - stw r0, 0x4(r3) - stw r0, 0x8(r3) - blr - */ + mHead = nullptr; + mTail = nullptr; + mLinkCount = 0; } /* @@ -134,9 +66,13 @@ void PSUPtrList::initiate() * Address: ........ * Size: 000024 */ -void PSUPtrList::setFirst(PSUPtrLink*) +void PSUPtrList::setFirst(PSUPtrLink* link) { - // UNUSED FUNCTION + link->mList = this; + link->mPrev = nullptr; + link->mNext = nullptr; + mHead = mTail = link; + mLinkCount = 1; } /* @@ -144,66 +80,27 @@ void PSUPtrList::setFirst(PSUPtrLink*) * Address: 801B34BC * Size: 0000BC */ -void PSUPtrList::append(PSUPtrLink*) +bool PSUPtrList::append(PSUPtrLink* link) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r4 - stw r30, 0x10(r1) - addi r30, r3, 0 - lwz r4, 0x4(r4) - neg r0, r4 - cntlzw r0, r0 - cmplwi r4, 0 - rlwinm r3,r0,27,5,31 - beq- .loc_0x40 - addi r3, r4, 0 - addi r4, r31, 0 - bl .loc_0xBC - - .loc_0x40: - rlwinm. r0,r3,0,24,31 - beq- .loc_0xA4 - lwz r0, 0x8(r30) - cmplwi r0, 0 - bne- .loc_0x78 - stw r30, 0x4(r31) - li r4, 0 - li r0, 0x1 - stw r4, 0x8(r31) - stw r4, 0xC(r31) - stw r31, 0x4(r30) - stw r31, 0x0(r30) - stw r0, 0x8(r30) - b .loc_0xA4 - - .loc_0x78: - stw r30, 0x4(r31) - li r0, 0 - lwz r4, 0x4(r30) - stw r4, 0x8(r31) - stw r0, 0xC(r31) - lwz r4, 0x4(r30) - stw r31, 0xC(r4) - stw r31, 0x4(r30) - lwz r4, 0x8(r30) - addi r0, r4, 0x1 - stw r0, 0x8(r30) - - .loc_0xA4: - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - - .loc_0xBC: - */ + bool isEmpty = link->mList == nullptr; + if (link->mList) { + isEmpty = link->mList->remove(link); + } + + if (isEmpty) { + if (mLinkCount == 0) { + setFirst(link); + } else { + link->mList = this; + link->mPrev = mTail; + link->mNext = nullptr; + mTail->mNext = link; + mTail = link; + mLinkCount++; + } + } + + return isEmpty; } /* @@ -231,65 +128,31 @@ void PSUPtrList::insert(PSUPtrLink*, PSUPtrLink*) * Address: 801B3578 * Size: 0000B0 */ -void PSUPtrList::remove(PSUPtrLink*) +bool PSUPtrList::remove(PSUPtrLink* link) { - /* - .loc_0x0: - lwz r5, 0x4(r4) - sub r0, r3, r5 - cntlzw r0, r0 - cmplw r5, r3 - rlwinm r6,r0,27,5,31 - bne- .loc_0xA8 - lwz r0, 0x8(r3) - cmplwi r0, 0x1 - bne- .loc_0x34 - li r0, 0 - stw r0, 0x0(r3) - stw r0, 0x4(r3) - b .loc_0x94 - - .loc_0x34: - lwz r0, 0x0(r3) - cmplw r4, r0 - bne- .loc_0x58 - lwz r5, 0xC(r4) - li r0, 0 - stw r0, 0x8(r5) - lwz r0, 0xC(r4) - stw r0, 0x0(r3) - b .loc_0x94 - - .loc_0x58: - lwz r0, 0x4(r3) - cmplw r4, r0 - bne- .loc_0x7C - lwz r5, 0x8(r4) - li r0, 0 - stw r0, 0xC(r5) - lwz r0, 0x8(r4) - stw r0, 0x4(r3) - b .loc_0x94 - - .loc_0x7C: - lwz r0, 0xC(r4) - lwz r5, 0x8(r4) - stw r0, 0xC(r5) - lwz r0, 0x8(r4) - lwz r5, 0xC(r4) - stw r0, 0x8(r5) - - .loc_0x94: - li r0, 0 - stw r0, 0x4(r4) - lwz r4, 0x8(r3) - subi r0, r4, 0x1 - stw r0, 0x8(r3) - - .loc_0xA8: - mr r3, r6 - blr - */ + bool isUnlinked = link->mList == this; + if (link->mList == this) { + if (mLinkCount == 1) { + mHead = nullptr; + mTail = nullptr; + } else if (link == mHead) { + link->mNext->mPrev = nullptr; + mHead = link->mNext; + + } else if (link == mTail) { + link->mPrev->mNext = nullptr; + mTail = link->mPrev; + + } else { + link->mPrev->mNext = link->mNext; + link->mNext->mPrev = link->mPrev; + } + + link->mList = nullptr; + mLinkCount--; + } + + return isUnlinked; } /* diff --git a/src/plugPikiYamashita/PUTRect.cpp b/src/plugPikiYamashita/PUTRect.cpp index 036d7b78..f50b43b9 100644 --- a/src/plugPikiYamashita/PUTRect.cpp +++ b/src/plugPikiYamashita/PUTRect.cpp @@ -5,20 +5,13 @@ * Address: 801B3628 * Size: 000024 */ -void PUTRect::set(int, int, int, int) +void PUTRect::set(int x0, int y0, int x1, int y1) { - /* - .loc_0x0: - extsh r0, r4 - sth r0, 0x0(r3) - extsh r0, r5 - extsh r4, r6 - sth r0, 0x2(r3) - extsh r0, r7 - sth r4, 0x4(r3) - sth r0, 0x6(r3) - blr - */ + mMin.x = x0; + mMin.y = y0; + + mMax.x = x1; + mMax.y = y1; } /* @@ -26,20 +19,13 @@ void PUTRect::set(int, int, int, int) * Address: 801B364C * Size: 000024 */ -void PUTRect::copy(const PUTRect&) +void PUTRect::copy(const PUTRect& other) { - /* - .loc_0x0: - lha r0, 0x0(r4) - sth r0, 0x0(r3) - lha r0, 0x2(r4) - sth r0, 0x2(r3) - lha r0, 0x4(r4) - sth r0, 0x4(r3) - lha r0, 0x6(r4) - sth r0, 0x6(r3) - blr - */ + mMin.x = other.mMin.x; + mMin.y = other.mMin.y; + + mMax.x = other.mMax.x; + mMax.y = other.mMax.y; } /* @@ -47,9 +33,13 @@ void PUTRect::copy(const PUTRect&) * Address: ........ * Size: 000044 */ -void PUTRect::add(const PUTPoint&) +void PUTRect::add(const PUTPoint& point) { - // UNUSED FUNCTION + mMin.x += point.x; + mMax.x += point.x; + + mMin.y += point.y; + mMax.y += point.y; } /* @@ -57,24 +47,13 @@ void PUTRect::add(const PUTPoint&) * Address: 801B3670 * Size: 000034 */ -void PUTRect::add(int, int) +void PUTRect::add(int x, int y) { - /* - .loc_0x0: - lha r0, 0x0(r3) - add r0, r0, r4 - sth r0, 0x0(r3) - lha r0, 0x4(r3) - add r0, r0, r4 - sth r0, 0x4(r3) - lha r0, 0x2(r3) - add r0, r0, r5 - sth r0, 0x2(r3) - lha r0, 0x6(r3) - add r0, r0, r5 - sth r0, 0x6(r3) - blr - */ + mMin.x += x; + mMax.x += x; + + mMin.y += y; + mMax.y += y; } /* @@ -82,51 +61,27 @@ void PUTRect::add(int, int) * Address: 801B36A4 * Size: 000080 */ -void PUTRect::intersect(const PUTRect&) +bool PUTRect::intersect(const PUTRect& other) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lha r5, 0x0(r4) - lha r0, 0x0(r3) - cmpw r0, r5 - bge- .loc_0x20 - sth r5, 0x0(r3) - - .loc_0x20: - lha r0, 0x2(r3) - lha r5, 0x2(r4) - cmpw r0, r5 - bge- .loc_0x34 - sth r5, 0x2(r3) - - .loc_0x34: - lha r0, 0x4(r3) - lha r5, 0x4(r4) - cmpw r0, r5 - ble- .loc_0x48 - sth r5, 0x4(r3) - - .loc_0x48: - lha r0, 0x6(r3) - lha r4, 0x6(r4) - cmpw r0, r4 - ble- .loc_0x5C - sth r4, 0x6(r3) - - .loc_0x5C: - bl 0xC0 - rlwinm r0,r3,0,24,31 - cntlzw r0, r0 - rlwinm r0,r0,27,5,31 - mr r3, r0 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + if (mMin.x < other.mMin.x) { + mMin.x = other.mMin.x; + } + + if (mMin.y < other.mMin.y) { + mMin.y = other.mMin.y; + } + + if (mMax.x > other.mMax.x) { + mMax.x = other.mMax.x; + } + + if (mMax.y > other.mMax.y) { + mMax.y = other.mMax.y; + } + + bool res = !isEmpty(); + // probably debug things here + return res; } /* @@ -134,9 +89,16 @@ void PUTRect::intersect(const PUTRect&) * Address: ........ * Size: 000044 */ -void PUTRect::move(const PUTPoint&) +void PUTRect::move(const PUTPoint& point) { - // UNUSED FUNCTION + s16 width = getWidth(); + s16 height = getHeight(); + + mMin.x = point.x; + mMin.y = point.y; + + mMax.x = mMin.x + width; + mMax.y = mMin.y + height; } /* @@ -144,28 +106,16 @@ void PUTRect::move(const PUTPoint&) * Address: 801B3724 * Size: 000044 */ -void PUTRect::move(int, int) +void PUTRect::move(int newMinX, int newMinY) { - /* - .loc_0x0: - lha r8, 0x0(r3) - extsh r4, r4 - lha r7, 0x4(r3) - extsh r0, r5 - lha r6, 0x2(r3) - lha r5, 0x6(r3) - sub r7, r7, r8 - sth r4, 0x0(r3) - sub r4, r5, r6 - sth r0, 0x2(r3) - lha r0, 0x0(r3) - add r0, r0, r7 - sth r0, 0x4(r3) - lha r0, 0x2(r3) - add r0, r0, r4 - sth r0, 0x6(r3) - blr - */ + s16 width = getWidth(); + s16 height = getHeight(); + + mMin.x = newMinX; + mMin.y = newMinY; + + mMax.x = mMin.x + width; + mMax.y = mMin.y + height; } /* @@ -173,18 +123,10 @@ void PUTRect::move(int, int) * Address: 801B3768 * Size: 00001C */ -void PUTRect::resize(int, int) +void PUTRect::resize(int width, int height) { - /* - .loc_0x0: - lha r0, 0x0(r3) - add r0, r0, r4 - sth r0, 0x4(r3) - lha r0, 0x2(r3) - add r0, r0, r5 - sth r0, 0x6(r3) - blr - */ + mMax.x = mMin.x + width; + mMax.y = mMin.y + height; } /* @@ -204,26 +146,17 @@ void PUTRect::reform(int, int, int, int) */ void PUTRect::normalize() { - /* - .loc_0x0: - lha r4, 0x0(r3) - lha r0, 0x4(r3) - cmpw r4, r0 - ble- .loc_0x1C - sth r4, 0x4(r3) - extsh r0, r0 - sth r0, 0x0(r3) - - .loc_0x1C: - lha r4, 0x2(r3) - lha r0, 0x6(r3) - cmpw r4, r0 - blelr- - sth r4, 0x6(r3) - extsh r0, r0 - sth r0, 0x2(r3) - blr - */ + if (mMin.x > mMax.x) { + int max = mMax.x; + mMax.x = mMin.x; + mMin.x = max; + } + + if (mMin.y > mMax.y) { + int max = mMax.y; + mMax.y = mMin.y; + mMin.y = max; + } } /* @@ -231,23 +164,4 @@ void PUTRect::normalize() * Address: 801B37C0 * Size: 000030 */ -void PUTRect::isEmpty() const -{ - /* - .loc_0x0: - lha r4, 0x0(r3) - li r5, 0x1 - lha r0, 0x4(r3) - cmpw r4, r0 - bge- .loc_0x28 - lha r4, 0x2(r3) - lha r0, 0x6(r3) - cmpw r4, r0 - bge- .loc_0x28 - li r5, 0 - - .loc_0x28: - mr r3, r5 - blr - */ -} +bool PUTRect::isEmpty() const { return (mMin.x >= mMax.x) || (mMin.y >= mMax.y); } diff --git a/src/plugPikiYamashita/TAIAmove.cpp b/src/plugPikiYamashita/TAIAmove.cpp index 8890ee59..b964aa39 100644 --- a/src/plugPikiYamashita/TAIAmove.cpp +++ b/src/plugPikiYamashita/TAIAmove.cpp @@ -4567,6 +4567,29 @@ void TAIAflyingDistance::start(Teki& teki) */ bool TAIAflyingDistance::act(Teki& teki) { + f32 moveSpeed = teki.mTekiParams->getF(TPF_RunVelocity); + + Creature* tekiTarget = teki._418[0].mPtr; + if (tekiTarget) { + f32 heightDiff = teki.mPosition.y - tekiTarget->mPosition.y; + if (heightDiff < 0.0f) { + heightDiff = -heightDiff; + } + + f32 tanVal = tanf(_00); + f32 offset = getOffset(teki); + f32 div = heightDiff / tanVal; + Vector3f vec; + + f32 minDist = div + offset; + f32 dist = absVal(teki.getPosition().distance(tekiTarget->getPosition()) - (div + offset)); + if (dist < getGoalAreaRange(teki)) { + teki._490 *= 27.0f * gsys->getFrameTime(); + } else { + } + } + + return true; /* .loc_0x0: mflr r0 diff --git a/src/plugPikiYamashita/TAImar.cpp b/src/plugPikiYamashita/TAImar.cpp index 57b54ea8..05750308 100644 --- a/src/plugPikiYamashita/TAImar.cpp +++ b/src/plugPikiYamashita/TAImar.cpp @@ -1,4 +1,5 @@ #include "TAI/Mar.h" +#include "PikiMgr.h" /* * --INFO-- @@ -2165,8 +2166,44 @@ bool BreathEffect::invoke(Teki&) * Address: 801A7398 * Size: 000238 */ -bool TAIAflyingDistanceMar::act(Teki&) +bool TAIAflyingDistanceMar::act(Teki& teki) { + bool baseActResult = TAIAflyingDistance::act(teki); + + // if base flyingDistance act succeeds, check for puffy-specific act. + if (baseActResult) { + // the more pikis we find in range, the more likely this act succeeds (hyperbolic, for whatever reason, so min is 1) + int weight = 1; + + // loop through all pikis on field. + PikiMgr* mgr = pikiMgr; + TRAVERSELOOP(mgr, idx) + { + Piki* piki = static_cast(mgr->getCreatureCheck(idx)); + + // if piki is within DangerTerritoryRange, increase chance of success by a small amount + if (piki->getPosition().distance(teki.getPosition()) < teki.mTekiParams->getF(TPF_DangerTerritoryRange)) { + weight++; + } + } + + // higher weight = smaller rand range = higher chance of success + // work out the chance of this by taking the integral and finding the area under the distribution curve + // P(XY <= 1) bounded by XY = 1 => Y = 1/X. take into account max X = A, max Y = 30, where A = 100 / weight + // P(XY <= 1) = (ln(A) + ln(30) + 1) / (30 * A) + // so, for: + // - weight = 1 (no pikis in range), A = 100, chance of success is 0.3% + // - weight = 51 (50 pikis in range), A = 100/51, chance of success is 8.6% + // - weight = 101 (100 pikis in range), A = 100/101, chance of success is 14.8% + if (System::getRand(100.0f / f32(weight)) * System::getRand(30.0f) <= 1.0f) { + return true; + } + + return false; + } + + // if we're here, this always returns false. + return baseActResult; /* .loc_0x0: mflr r0 diff --git a/src/plugPikiYamashita/drawCommon.cpp b/src/plugPikiYamashita/drawCommon.cpp index c641fdd2..0630b32b 100644 --- a/src/plugPikiYamashita/drawCommon.cpp +++ b/src/plugPikiYamashita/drawCommon.cpp @@ -223,8 +223,15 @@ zen::NumberTex::NumberTex() * Address: 801BF7A4 * Size: 000118 */ -void zen::P2DPaneLibrary::makeResident(P2DPane*) +void zen::P2DPaneLibrary::makeResident(P2DPane* pane) { + pane->makeResident(); + PSUTree* tree = pane->getPaneTree(); + PSUTreeIterator iterator(tree->getFirstChild()); + while (iterator != tree->getEndChild()) { + makeResident(iterator.getObject()); + ++iterator; + } /* .loc_0x0: mflr r0 @@ -316,30 +323,6 @@ void zen::P2DPaneLibrary::makeResident(P2DPane*) */ } -/* - * --INFO-- - * Address: 801BF8BC - * Size: 000008 - */ -PSUTree* PSUTree::getEndChild() const { return nullptr; } - -/* - * --INFO-- - * Address: 801BF8C4 - * Size: 000014 - */ -PSUTree* PSUTree::getFirstChild() const -{ - /* - .loc_0x0: - lwz r3, 0x0(r3) - cmplwi r3, 0 - beqlr- - subi r3, r3, 0xC - blr - */ -} - /* * --INFO-- * Address: 801BF8D8 diff --git a/src/plugPikiYamashita/drawGameInfo.cpp b/src/plugPikiYamashita/drawGameInfo.cpp index ee4ccfc7..b8931d3e 100644 --- a/src/plugPikiYamashita/drawGameInfo.cpp +++ b/src/plugPikiYamashita/drawGameInfo.cpp @@ -2359,38 +2359,6 @@ void DateCallBack::setTex() */ } -/* - * --INFO-- - * Address: 801B8524 - * Size: 000010 - */ -s16 PUTRect::getWidth() const -{ - /* - .loc_0x0: - lha r4, 0x0(r3) - lha r0, 0x4(r3) - sub r3, r0, r4 - blr - */ -} - -/* - * --INFO-- - * Address: 801B8534 - * Size: 000010 - */ -s16 PUTRect::getHeight() const -{ - /* - .loc_0x0: - lha r4, 0x2(r3) - lha r0, 0x6(r3) - sub r3, r0, r4 - blr - */ -} - /* * --INFO-- * Address: 801B8544 diff --git a/src/sysCommon/stream.cpp b/src/sysCommon/stream.cpp index 4ad6ca97..4d7b467d 100644 --- a/src/sysCommon/stream.cpp +++ b/src/sysCommon/stream.cpp @@ -19,9 +19,9 @@ int Stream::readInt() * Address: 800250E8 * Size: 000038 */ -char Stream::readByte() +u8 Stream::readByte() { - char c; + u8 c; read(&c, sizeof(char)); return c; }