From 05eb1400faaa957905fbbe8fa284df4ab1472a58 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 20 Sep 2012 15:30:05 +0200 Subject: cleaning up in preparation for the new HUD, plus a few other changes --- include/game.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/newer.h | 1 + 2 files changed, 52 insertions(+) (limited to 'include') diff --git a/include/game.h b/include/game.h index 169b01d..7e8456d 100755 --- a/include/game.h +++ b/include/game.h @@ -3067,6 +3067,57 @@ namespace mHeap { }; void WriteNumberToTextBox(int *number, const int *fieldLength, nw4r::lyt::TextBox *textBox, bool unk); // 800B3B60 + +namespace EGG { + class MsgRes { + private: + const u8 *bmg, *INF1, *DAT1, *STR1, *MID1, *FLW1, *FLI1; + public: + MsgRes(const u8 *bmgFile, u32 unusedParam); // 802D7970 + virtual ~MsgRes(); + + static void parseFormatCode(wchar_t initialTag, const wchar_t *string, u8 *outArgsSize, u32 *outCmd, const wchar_t **args); // 802D7B10 + + const wchar_t *findStringForMessageID(int category, int message) const; // 0x802D7B50 + + private: + void setBMG(const u8 *ptr); // 802D7B90 + void setINF(const u8 *ptr); // 802D7BA0 + void setDAT(const u8 *ptr); // 802D7BB0 + void setSTR(const u8 *ptr); // 802D7BC0 + void setMID(const u8 *ptr); // 802D7BD0 + void setFLW(const u8 *ptr); // 802D7BE0 + void setFLI(const u8 *ptr); // 802D7BF0 + int identifySectionByMagic(u32 magic) const; // 802D7C00 + + protected: + struct INFEntry { + u32 stringOffset; + }; + const INFEntry *findINFForMessageID(int category, int message) const; // 802D7C90 + u32 getEntryFromMID(int index) const; // 802D7D70 + }; +} +namespace dScript { + class Res_c : public EGG::MsgRes { + public: + Res_c(const u8 *bmgFile, u32 unusedParam); // 800CE7F0 + ~Res_c(); + + u16 getCharScaleForMessageID(int category, int message) const; // 800CE890 + u8 getFontIDForMessageID(int category, int message) const; // 800CE8C0 + }; +} +class MessageClass { + public: + dDvdLoader_c loader; + void *rawBmgPointer; + dScript::Res_c *msgRes; +}; + +dScript::Res_c *GetBMG(); // 800CDD50 +void WriteBMGToTextBox(nw4r::lyt::TextBox *textBox, dScript::Res_c *res, int category, int message, int argCount, ...); // 0x800C9B50 + extern "C" dAc_Py_c* GetSpecificPlayerActor(int number); extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer); extern "C" dStageActor_c *Actor_SearchByID(u32 actorID); diff --git a/include/newer.h b/include/newer.h index 4f34f81..d98f290 100644 --- a/include/newer.h +++ b/include/newer.h @@ -27,5 +27,6 @@ enum NWRWorld { NWRWorld NewerWorldForLevelID(int world, int level); const wchar_t *NewerWorldName(NWRWorld world); +int getStarCoinCount(); #endif /* NEWER_H */ -- cgit v1.2.3 From badb2bf6bc25f47e711fc483e0c551b4fc18759f Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 21 Sep 2012 00:08:14 +0200 Subject: fixes, header cleanups, and part of the code for the new HUD --- include/game.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/game.h b/include/game.h index 7e8456d..2dc64a6 100755 --- a/include/game.h +++ b/include/game.h @@ -505,6 +505,20 @@ namespace lyt { class Group; class GroupContainer; + namespace detail { + class TexCoordAry { + public: + TexCoordAry(); + void Free(); + void Reserve(u8 count); + void SetSize(u8 count); + void Copy(const void *source, u8 count); + + u8 reservedSize, usedSize; + void *data; + }; + } + class Layout { public: Layout(); @@ -636,11 +650,17 @@ namespace lyt { u8 flag; char name[0x11]; - char userdata[8]; + char userdata[9]; - u8 _D5; u8 paneIsOwnedBySomeoneElse; u8 _D7; + + void SetVisible(bool value) { + if (value) + flag |= 1; + else + flag &= ~1; + } }; class TextBox : public Pane { @@ -657,7 +677,7 @@ namespace lyt { uchar GetVtxColorElement(ulong id) const; void SetVtxColorElement(ulong id, uchar value); - virtual void LoadMtx(const DrawInfo &info); + void LoadMtx(const DrawInfo &info); virtual void AllocStringBuffer(u16 size); virtual void FreeStringBuffer(); @@ -681,6 +701,26 @@ namespace lyt { u8 alignment; u8 flags; }; + + class Picture : public Pane { + public: + Picture(void *, void *); // todo: Picture((res::Picture const *,ResBlockSet const &)) + ~Picture(); + + void *GetRuntimeTypeInfo() const; + + void DrawSelf(const DrawInfo &info); + + ut::Color GetVtxColor(ulong id) const; + void SetVtxColor(ulong id, ut::Color color); + uchar GetVtxColorElement(ulong id) const; + void SetVtxColorElement(ulong id, uchar value); + + virtual void Append(const GXTexObj &obj); + + ut::Color colours[4]; + detail::TexCoordAry texCoords; + }; } @@ -2482,7 +2522,10 @@ namespace nw4r { void SetupGXWithColorMapping(Color c1, Color c2); public: - Color colors[8]; // todo: document + Color minColMapping, maxColMapping; + Color vtxColours[4]; + Color topColour, bottomColour; + u32 modeOfSomeKind; float scaleX; float scaleY; @@ -2517,12 +2560,12 @@ namespace nw4r { bool IsDrawFlagSet(ulong, ulong) const; - float _4C; + float widthLimit; float charSpace; - float somethingRelatedToLineHeight; - u32 _58; + float lineSpace; + u32 tabWidth; u32 drawFlag; - void *tagProcessorMaybe; + void *tagProcessor; }; } } @@ -2662,7 +2705,7 @@ namespace m2d { nw4r::lyt::Pane *getRootPane(); nw4r::lyt::Pane *findPaneByName(const char *name) const; nw4r::lyt::TextBox *findTextBoxByName(const char *name) const; - nw4r::lyt::Pane *findPictureByName(const char *name) const; // TODO: change to others + nw4r::lyt::Picture *findPictureByName(const char *name) const; nw4r::lyt::Pane *findWindowByName(const char *name) const; void animate(); @@ -2700,10 +2743,10 @@ namespace m2d { // does NSMBW even use consts? I have no idea. maybe not - void getPanes(const char **names, nw4r::lyt::Pane *output, int count) const; - void getWindows(const char **names, nw4r::lyt::Pane *output, int count) const; // TODO: change to others - void getPictures(const char **names, nw4r::lyt::Pane *output, int count) const; - void getTextBoxes(const char **names, nw4r::lyt::TextBox *output, int count) const; + void getPanes(const char **names, nw4r::lyt::Pane **output, int count) const; + void getWindows(const char **names, nw4r::lyt::Pane **output, int count) const; // TODO: change to others + void getPictures(const char **names, nw4r::lyt::Picture **output, int count) const; + void getTextBoxes(const char **names, nw4r::lyt::TextBox **output, int count) const; void setLangStrings(const char **names, const int *msgIDs, int category, int count); -- cgit v1.2.3 From 46b65dfd76411bec6f8356c581f337f8a1944013 Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 25 Sep 2012 23:03:30 +0200 Subject: added Remocon and GameMgr definitions, and made map HUD buttons work --- include/game.h | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/game.h b/include/game.h index 7911880..e31e675 100755 --- a/include/game.h +++ b/include/game.h @@ -80,9 +80,60 @@ struct StartLevelInfo { unsigned char level2; // 0x0F }; -extern void *GameMgr; +class GMgr8 { + public: + virtual ~GMgr8(); + + int _4; + float _8, _C; + u32 _10, _14; + u8 _18, _19, _1A, _1B, _1C; + u32 _20, _24, _28, _2C, _30; +}; + +struct GMgrA0 { + u32 _0, _4, _8; + u8 _C; +}; + +class GameMgr { + public: + virtual ~GameMgr(); + + u32 _4; + GMgr8 eight; + u32 _3C, _40, _44, _48, _4C, _50, _54, _58; + u32 _5C, _60, _64, _68, _6C; + u32 _70[10]; + u8 _98; + u32 _9C; + GMgrA0 _A0[40]; + u32 _320[10], _348[10]; + u32 _370, _374, _378, _37C; + u8 switchPalaceFlag; + u32 CharIDs[4]; + u8 _394; + u8 _395[10]; + u8 _39F[10]; + u8 _3A9[10]; + u8 _3B3; + u32 numberToInsertInThing[7]; + u32 msgCategory, msgID; + u8 _3D8; + u8 currentControllerType, layoutShadowFlag; + u32 numberToInsertInThing10, numberToInsertInThing11; + u32 _3E4, _3E8, _3EC, _3F0, _3F4, _3F8; + // unmapped data from 3FC..AEC (0x6F0) + u8 _3FC[0x6F0]; + u32 _AEC, _AF0, _AF4, _AF8; + u8 _AFC, _AFD, _AFE[88]; + u8 _B56[4]; + u8 _B5A, _B5B; +}; + +extern GameMgr *GameMgrP; inline void *GetGameMgr() { - return GameMgr; + return GameMgrP; } bool QueryPlayerAvailability(int id); @@ -219,9 +270,31 @@ inline SaveHandler *GetSaveHandler() { #define WPAD_MINUS 0x1000 #define WPAD_HOME 0x8000 +struct Remocon { + virtual ~Remocon(); + int id; + int controllerType; + u32 untouchedButtons; + u32 lastUntouchedButtons; + u32 heldButtons; + u32 lastHeldButtons; + u32 nowPressed; + u32 _20, _24, _28, _2C, _30; + Vec acc, lastAcc; + Vec2 accVertical, lastAccVertical; + Vec2 vec_5C, lastVec_5C; + Vec2 vec_6C; + Vec2 vec_74, lastVec_74; + float wiimoteMoveDistanceOrSomething; + float lastWiimoteMoveDistanceOrSomething; + u8 isShaking, _8D; + u16 tiltAmount; + u8 _90, _91, _92; +}; + struct RemoconMngClass { void *vtable; - void *controllers[4]; + Remocon *controllers[4]; }; /* @@ -246,7 +319,7 @@ inline int GetActiveWiimoteID() { return ActiveWiimoteID; } -inline void *GetActiveRemocon() { +inline Remocon *GetActiveRemocon() { return GetRemoconMng()->controllers[GetActiveWiimoteID()]; } @@ -254,11 +327,11 @@ inline void *GetActiveWiimote() { return ActiveWiimote; } -inline unsigned int Remocon_GetButtons(void *self) { +inline unsigned int Remocon_GetButtons(Remocon *self) { return *((unsigned int*)((u32)self+0x18)); } -inline unsigned int Remocon_GetPressed(void *self) { +inline unsigned int Remocon_GetPressed(Remocon *self) { return *((unsigned int*)((u32)self+0x1C)); } -- cgit v1.2.3 From 014f3668eb47b1576bdc182b1db00417f9938cf1 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 00:51:43 +0200 Subject: added untested support for world change nodes --- include/game.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/game.h b/include/game.h index e31e675..41b925f 100755 --- a/include/game.h +++ b/include/game.h @@ -26,6 +26,7 @@ extern "C" { int wcslen(const wchar_t *str); int strlen(const char *str); char *strcpy(char *dest, const char *src); +char *strncpy(char *dest, const char *src, int num); int strncmp(const char *str1, const char *str2, int num); float atan(float x); @@ -200,7 +201,13 @@ public: struct { // ALL Newer additions should go here // This array has been verified as safe to replace - u8 currentNewerWorld; // 0x6FC + char newerWorldName[36]; // 0x6FC + GXColor fsTextColours[2]; // 0x720 + GXColor fsHintColours[2]; // 0x728 + GXColor hudTextColours[2]; // 0x730 + s16 hudHintH, hudHintS, hudHintL; // 0x738 + u8 currentMapMusic; // 0x73E + u8 _padding; // 0x73F }; }; u8 toad_location[10]; // 0x742 -- cgit v1.2.3 From 411c5a8e210b5cbca330a5438e2406dbe1ffecab Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 04:40:34 +0200 Subject: made world changes work, and HUD colourising and other fun things --- include/game.h | 36 ++++++++++++++++++++++++++++++++++-- include/newer.h | 26 -------------------------- 2 files changed, 34 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/include/game.h b/include/game.h index 41b925f..32b3a1d 100755 --- a/include/game.h +++ b/include/game.h @@ -560,7 +560,13 @@ namespace ut { LinkListNode initialNode; }; - class Color : public GXColor { }; + class Color : public GXColor { + public: + GXColor& operator=(const GXColor &other) { + *((u32*)this) = *((u32*)&other); + return *this; + } + }; class Rect { public: @@ -651,9 +657,35 @@ namespace lyt { }; + class TexMap { + public: + void *image, *palette; + u16 width, height; + f32 minLOD, magLOD; + u16 lodBias, palEntryNum; + struct + { + u32 textureFormat: 4; + u32 mipmap: 1; + u32 wrapS: 2; + u32 wrapT: 2; + u32 minFilter: 3; + u32 magFilter: 1; + u32 biasClampEnable: 1; + u32 edgeLODEnable: 1; + u32 anisotropy: 2; + u32 paletteFormat: 2; + } mBits; + }; + class Material { public: - // ... + virtual ~Material(); + + // cheating a bit here + u8 _[0x3C]; + // this is actually a pointer to more stuff, not just texmaps + TexMap *texMaps; }; class Pane { diff --git a/include/newer.h b/include/newer.h index d98f290..cf21cbb 100644 --- a/include/newer.h +++ b/include/newer.h @@ -1,32 +1,6 @@ #ifndef NEWER_H #define NEWER_H -enum NWRWorld { - ISLAND = 0, YOSHI_ISLAND = 0, - DESERT = 1, RUBBLE_RUINS = 1, - SEWER = 2, SOGGY_SEWERS = 2, - MOUNTAIN = 3, MUSHROOM_PEAKS = 3, - SAKURA = 4, SAKURA_VILLAGE = 4, - FREEZEFLAME = 5, FREEZEFLAME_GLACIER = 5, - VOLCANO = 6, FREEZEFLAME_VOLCANO = 6, - PUMPKIN = 7, PUMPKIN_BONEYARD = 7, - SKY_MOUNTAIN = 8, - SKY = 9, STARRY_SKIES = 9, - PLANET = 10, KOOPA_PLANET = 10, - CORE = 11, KOOPA_CORE = 11, - BONUS_LAND = 12, - GOLDWOOD = 13, GOLDWOOD_FOREST = 13, - MINIMEGA = 14, MINIMEGA_ISLAND = 14, - CRYSTAL = 15, CRYSTAL_CAVES = 15, - BOMBARD = 16, BOMBARD_CLIFFS = 16, - SKY_CITY = 17, - WORLD_COUNT = 18, - UNKNOWN_WORLD = 255 -}; - -NWRWorld NewerWorldForLevelID(int world, int level); - -const wchar_t *NewerWorldName(NWRWorld world); int getStarCoinCount(); #endif /* NEWER_H */ -- cgit v1.2.3 From 87cb3ef8451f6e6dc0f642d22f5335c1c4f4b064 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 06:08:02 +0200 Subject: a tiny bit of savefile RE, and default world stuff in the savefile --- include/game.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/game.h b/include/game.h index 32b3a1d..071d93e 100755 --- a/include/game.h +++ b/include/game.h @@ -153,6 +153,31 @@ bool IsWideScreen(); #define COND_SGNORMAL 0x80 #define COND_SGSECRET 0x100 + +// All of these are set by "SetWorldCompleteionBitfield" (I didn't name it) +// at 801028D0. It's called by ScStage so it doesn't depend on Nintendo maps. + +#define SAVE_BIT_EXISTS_MAYBE 1 + +// Controls whether you can QUICK SAVE or not. +// Set if 8-Castle is complete. +#define SAVE_BIT_GAME_COMPLETE 2 + +// Set when all exits are complete. +// This is defined by "ReturnWhetherConditionMaskIsValid" / "SetSomeConditionShit" +// TODO: Need to RE and fix this for Newer... +#define SAVE_BIT_ALL_EXITS 4 + +// Set when all star coins in worlds 1-8 are obtained. +// Valid levels are chosen by the condition crap as above. +#define SAVE_BIT_ALL_STAR_COINS 8 + +#define SAVE_BIT_ALL_STAR_COINS_W9 0x10 + +// Set when, well... EVERYTHING is done. +#define SAVE_BIT_EVERYTHING_TRULY_DONE 0x20 + + class SaveFirstBlock { public: char titleID[4]; // 0x00 -- cgit v1.2.3