Skip to content

Commit

Permalink
Changes from spm-decomp (#16)
Browse files Browse the repository at this point in the history
Breaking:
- MarioMotionId enum changed to defines
- Item ids in PouchCharOrPixlInfo, MarioPouchWork, pouchAddItem, pouchGetCurPixl, changed to unsigned
- MarioPouchWork2 0x0-0x10 changed to OSTimes

Other:
- Added pouch *_ITEM_MAX defines
- PouchUnk added
- pouch2Init, pouchSetXp added
- gp.timePlayed added
- OSSecondsToTicks added

Co-authored-by: Aiden <vabold@mkw.re>
  • Loading branch information
SeekyCt and vabold authored Dec 7, 2023
1 parent fd1d361 commit 5e94ea0
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 99 deletions.
3 changes: 2 additions & 1 deletion include/spm/item_data_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ CPP_WRAPPER(spm::item_data)

enum ItemType
{
/* 0x000 */ ITEM_ID_NULL,

// In-world items
/* 0x000 */ ITEM_ID_WORLD_NULL,
/* 0x001 */ ITEM_ID_WORLD_COIN,
/* 0x002 */ ITEM_ID_WORLD_COIN_x3,
/* 0x003 */ ITEM_ID_WORLD_SPEED_FLOWER,
Expand Down
159 changes: 78 additions & 81 deletions include/spm/mario.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,87 +140,84 @@ SIZE_ASSERT(MarioPaneBoundary, 0x8)
*/
typedef bool (MarioPaneChangeFunc)(s32 newPane);

enum MarioMotionId
{
/* 0x00 */ MOT_STAY, // Standing still
/* 0x01 */ MOT_WALK, // Walking slowly
/* 0x02 */ MOT_DASH, // Walking at full speed
/* 0x03 */ MOT_JUMP, // Jumping normally
/* 0x04 */ MOT_CROUCH, // Crouching
/* 0x05 */ MOT_5,
/* 0x06 */ MOT_SPRING, // Jumping off spring object
/* 0x07 */ MOT_7,
/* 0x08 */ MOT_8,
/* 0x09 */ MOT_BOUNCE, // Jumping off of an NPC
/* 0x0A */ MOT_FALL, // Falling in the air
/* 0x0B */ MOT_11,
/* 0x0C */ MOT_12,
/* 0x0D */ MOT_13,
/* 0x0E */ MOT_THUDLEY_AIR, // In the air while using thudley
/* 0x0F */ MOT_THUDLEY_LAND, // Landing whlie using thudley
/* 0x10 */ MOT_HAMMER, // Using cudge
/* 0x11 */ MOT_JABARA, // Luigi spring jump(?)
/* 0x12 */ MOT_SLIT, // Thin with slim
/* 0x13 */ MOT_TALK, // Talking to an NPC
/* 0x14 */ MOT_20,
/* 0x15 */ MOT_21,
/* 0x16 */ MOT_22,
/* 0x17 */ MOT_FORCE_RESET, // ? TTYD name
/* 0x18 */ MOT_24,
/* 0x19 */ MOT_BOTTOMLESS, // Respawning from falling
/* 0x1A */ MOT_FLIP_AIR, // Flip into midair
/* 0x1B */ MOT_DAMAGE, // Taking damage
/* 0x1C */ MOT_28,
/* 0x1D */ MOT_29,
/* 0x1E */ MOT_30,
/* 0x1F */ MOT_31,
/* 0x20 */ MOT_32,
/* 0x21 */ MOT_33,
/* 0x22 */ MOT_34,
/* 0x23 */ MOT_35,
/* 0x24 */ MOT_GRAB, // Throwing thoreau
/* 0x25 */ MOT_BOMB, // Placing boomer
/* 0x26 */ MOT_FLEEP, // Using fleep
/* 0x27 */ MOT_SHRINK, // Shrinking with dottie
/* 0x28 */ MOT_GROW, // Growing with dottie
/* 0x29 */ MOT_PICCOLO, // Using piccolo
/* 0x2A */ MOT_BARRY, // Using barry
/* 0x2B */ MOT_43,
/* 0x2C */ MOT_CARRIE_MOUNT, // Mounting carrie
/* 0x2D */ MOT_CARRIE_DISMOUNT, // Dismounting carrie
/* 0x2E */ MOT_46,
/* 0x2F */ MOT_47,
/* 0x30 */ MOT_48,
/* 0x31 */ MOT_49,
/* 0x32 */ MOT_50,
/* 0x33 */ MOT_51,
/* 0x34 */ MOT_52,
/* 0x35 */ MOT_53,
/* 0x36 */ MOT_54,
/* 0x37 */ MOT_55,
/* 0x38 */ MOT_56,
/* 0x39 */ MOT_57,
/* 0x3A */ MOT_58,
/* 0x3B */ MOT_59,
/* 0x3C */ MOT_60,
/* 0x3D */ MOT_61,
/* 0x3E */ MOT_62,
/* 0x3F */ MOT_63,
/* 0x40 */ MOT_64,
/* 0x41 */ MOT_65,
/* 0x42 */ MOT_66,
/* 0x43 */ MOT_67,
/* 0x44 */ MOT_68,
/* 0x45 */ MOT_SWIM, // Off-ground underwater
/* 0x46 */ MOT_70,
/* 0x47 */ MOT_CHAR_CHANGE, // Changing character
/* 0x48 */ MOT_FAIRY_CHANGE, // Changing pixl
/* 0x49 */ MOT_FLIP, // Flipping to 2d/3d
/* 0x4A */ MOT_GLIDE, // Peach parasol glide
/* 0x4B */ MOT_GUARD, // Peach parasol guard
/* 0x4C */ MOT_FIRE, // Bowser fire
/* 0x4D */ MOT_77
};
#define MOT_STAY 0x00 // Standing still
#define MOT_WALK 0x01 // Walking slowly
#define MOT_DASH 0x02 // Walking at full speed
#define MOT_JUMP 0x03 // Jumping normally
#define MOT_CROUCH 0x04 // Crouching
#define MOT_5 0x05
#define MOT_SPRING 0x06 // Jumping off spring object
#define MOT_7 0x07
#define MOT_8 0x08
#define MOT_BOUNCE 0x09 // Jumping off of an NPC
#define MOT_FALL 0x0A // Falling in the air
#define MOT_11 0x0B
#define MOT_12 0x0C
#define MOT_13 0x0D
#define MOT_THUDLEY_AIR 0x0E // In the air while using thudley
#define MOT_THUDLEY_LAND 0x0F // Landing whlie using thudley
#define MOT_HAMMER 0x10 // Using cudge
#define MOT_JABARA 0x11 // Luigi spring jump(?)
#define MOT_SLIT 0x12 // Thin with slim
#define MOT_TALK 0x13 // Talking to an NPC
#define MOT_20 0x14
#define MOT_21 0x15
#define MOT_22 0x16
#define MOT_FORCE_RESET 0x17 // ? TTYD name
#define MOT_24 0x18
#define MOT_BOTTOMLESS 0x19 // Respawning from falling
#define MOT_FLIP_AIR 0x1A // Flip into midair
#define MOT_DAMAGE 0x1B // Taking damage
#define MOT_28 0x1C
#define MOT_29 0x1D
#define MOT_30 0x1E
#define MOT_31 0x1F
#define MOT_32 0x20
#define MOT_33 0x21
#define MOT_34 0x22
#define MOT_35 0x23
#define MOT_GRAB 0x24 // Throwing thoreau
#define MOT_BOMB 0x25 // Placing boomer
#define MOT_FLEEP 0x26 // Using fleep
#define MOT_SHRINK 0x27 // Shrinking with dottie
#define MOT_GROW 0x28 // Growing with dottie
#define MOT_PICCOLO 0x29 // Using piccolo
#define MOT_BARRY 0x2A // Using barry
#define MOT_43 0x2B
#define MOT_CARRIE_MOUNT 0x2C // Mounting carrie
#define MOT_CARRIE_DISMOUNT 0x2D // Dismounting carrie
#define MOT_46 0x2E
#define MOT_47 0x2F
#define MOT_48 0x30
#define MOT_49 0x31
#define MOT_50 0x32
#define MOT_51 0x33
#define MOT_52 0x34
#define MOT_53 0x35
#define MOT_54 0x36
#define MOT_55 0x37
#define MOT_56 0x38
#define MOT_57 0x39
#define MOT_58 0x3A
#define MOT_59 0x3B
#define MOT_60 0x3C
#define MOT_61 0x3D
#define MOT_62 0x3E
#define MOT_63 0x3F
#define MOT_64 0x40
#define MOT_65 0x41
#define MOT_66 0x42
#define MOT_67 0x43
#define MOT_68 0x44
#define MOT_SWIM 0x45 // Off-ground underwater
#define MOT_70 0x46
#define MOT_CHAR_CHANGE 0x47 // Changing character
#define MOT_FAIRY_CHANGE 0x48 // Changing pixl
#define MOT_FLIP 0x49 // Flipping to 2d/3d
#define MOT_GLIDE 0x4A // Peach parasol glide
#define MOT_GUARD 0x4B // Peach parasol guard
#define MOT_FIRE 0x4C // Bowser fire
#define MOT_77 0x4D

// Off ground, in water
#define MARIO_MISC_FLAG_SWIM 0x20000000
Expand Down
55 changes: 39 additions & 16 deletions include/spm/mario_pouch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,46 @@

CPP_WRAPPER(spm::mario_pouch)

#define POUCH_KEY_ITEM_MAX 32
#define POUCH_USE_ITEM_MAX 10
#define POUCH_SHOP_ITEM_MAX 32
#define POUCH_CHAR_ITEM_MAX 4
#define POUCH_FAIRY_ITEM_MAX 16

USING(wii::os::OSTime)
USING(wii::mtx::Vec3)

typedef struct
{
/* 0x0 */ bool selectable;
/* 0x1 */ bool selected;
/* 0x2 */ s16 itemType;
/* 0x2 */ u16 itemType;
} PouchCharOrPixlInfo;
SIZE_ASSERT(PouchCharOrPixlInfo, 0x4)

typedef struct
{
/* 0x00 */ s32 characterId;
/* 0x04 */ s32 score;
/* 0x08 */ u8 unknown_0x8[0x18 - 0x8];
/* 0x08 */ Unk32 unknown_0x8;
/* 0x0C */ Unk32 unknown_0xc;
/* 0x10 */ u8 unknown_0x10;
/* 0x11 */ u8 unknown_0x11[0x18 - 0x11];
} PouchMinigameScore;
SIZE_ASSERT(PouchMinigameScore, 0x18)

typedef struct
{
/* 0x00 */ Unk32 unknown_0x0;
/* 0x04 */ s32 unknown_0x4;
/* 0x08 */ OSTime unknown_0x8;
/* 0x10 */ Unk32 unknown_0x10;
/* 0x14 */ Unk32 unknown_0x14;
/* 0x18 */ u8 unknown_0x18;
/* 0x19 */ u8 unknown_0x19[0x20 - 0x19];
} PouchUnk;
SIZE_ASSERT(PouchUnk, 0x20)

/*
This struct is copied in full to & from the save file
*/
Expand All @@ -41,14 +63,14 @@ typedef struct
/* 0x014 */ s32 flipTimer;
/* 0x018 */ s32 xp;
/* 0x01C */ s32 coins;
/* 0x020 */ s16 keyItem[32]; // key items
/* 0x060 */ s16 useItem[10]; // usable items
/* 0x074 */ s16 shopItem[32]; // items stored by the player at a shop
/* 0x0B4 */ PouchCharOrPixlInfo characters[4];
/* 0x0C4 */ PouchCharOrPixlInfo pixls[16];
/* 0x020 */ u16 keyItem[POUCH_KEY_ITEM_MAX]; // key items
/* 0x060 */ u16 useItem[POUCH_USE_ITEM_MAX]; // usable items
/* 0x074 */ u16 shopItem[POUCH_SHOP_ITEM_MAX]; // items stored by the player at a shop
/* 0x0B4 */ PouchCharOrPixlInfo characters[POUCH_CHAR_ITEM_MAX];
/* 0x0C4 */ PouchCharOrPixlInfo pixls[POUCH_FAIRY_ITEM_MAX];
/* 0x104 */ s32 shopPoints;
/* 0x108 */ u32 shopPointRewardsCollected; // bit mask, index 1 << i
/* 0x10C */ s8 catchCards[256]; // value is the amount currently owned, index is item id
/* 0x10C */ u8 catchCards[256]; // value is the amount currently owned, index is item id
// minus the first card item id (282)
/* 0x20C */ u8 unknown_0x20c[0x30c - 0x20c];

Expand All @@ -66,9 +88,10 @@ typedef struct

/* 0x348 */ s32 charmsRemaining; // Merlee charms remaining from current purchase
/* 0x34C */ s32 killsBeforeNextCharm; // kills before the next Merlee charm triggers
/* 0x350 */ u8 unknown_0x350[0x368 - 0x350];
/* 0x350 */ Vec3 unknown_0x350;
/* 0x35C */ Vec3 unknown_0x35c;
/* 0x368 */ PouchMinigameScore minigameScores[4][5];
/* 0x548 */ u8 unknown_0x548[0x688 - 0x548];
/* 0x548 */ PouchUnk unknown_0x548[2][5];
/* 0x688 */ s32 arcadeTokens;
/* 0x68C */ s32 totalCoinsCollected; // all-time coins collected
/* 0x690 */ s32 maxJumpCombo;
Expand All @@ -80,10 +103,8 @@ SIZE_ASSERT(MarioPouchWork, 0x6a0)

typedef struct
{
/* 0x00 */ s32 unknown_0x0;
/* 0x04 */ s32 unknown_0x4;
/* 0x08 */ s32 unknown_0x8;
/* 0x0C */ s32 unknown_0xc;
/* 0x00 */ OSTime unknown_0x0;
/* 0x08 */ OSTime unknown_0x8;
/* 0x10 */ s32 unknown_0x10;
/* 0x14 */ s32 unknown_0x14;
/* 0x18 */ OSTime unknown_0x18;
Expand All @@ -104,6 +125,7 @@ MarioPouchWork2 * pouch2GetPtr(); // inlined
Overwritten later once a save is loaded
*/
void pouchInit();
void pouch2Init(); // inlined
void pouchReInit();

/*
Expand Down Expand Up @@ -147,6 +169,7 @@ s32 pouchGetMaxHp();
/*
Get/add to the player's xp
*/
void pouchSetXp(s32 xp); // inlined
s32 pouchGetXp();
void pouchAddXp(s32 increase);

Expand All @@ -162,7 +185,7 @@ void pouchAddCoin(s32 increase); // increases totalCoinsCollected
Adds the specified item to its corresponding inventory (can't be used for shop items)
Returns whether it was successfully added
*/
bool pouchAddItem(s16 itemId);
bool pouchAddItem(s32 itemId);

/*
Checks whether the specified item id is in its corresponding inventory
Expand Down Expand Up @@ -230,7 +253,7 @@ bool pouchCheckPixlSelected(s16 itemId);
/*
Returns the id of the currently selected pixl
*/
s16 pouchGetCurPixl();
u16 pouchGetCurPixl();

/*
Makes a pixl selected by id, if it exists in a slot
Expand Down
3 changes: 2 additions & 1 deletion include/spm/spmario.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ typedef struct
/* 0x00E0 */ u32 unknown_0xe0; // not read from save file
/* 0x00E4 */ u8 unknown_0xe4[0xf8 - 0xe4];
/* 0x00F8 */ OSTime time;
/* 0x0100 */ u8 unknown_0x100[0x110 - 0x100];
/* 0x0100 */ OSTime timePlayed;
/* 0x0108 */ u8 unknown_0x108[0x110 - 0x108];
/* 0x0110 */ OSTime lastSaveLoadTime;
/* 0x0118 */ u8 unknown_0x118[0x138 - 0x118];
/* 0x0138 */ OSTime lastButtonPressTime; // uncertain
Expand Down
1 change: 1 addition & 0 deletions include/wii/os/OSTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CPP_WRAPPER(wii::os)
#define OSClockSpeed ((*(u32 *) 0x800000F8) / 4)
#define OSTicksToMilliseconds(ticks) ((ticks) / (OSClockSpeed / 1000))
#define OSMillisecondsToTicks(ms) ((ms) * (OSClockSpeed / 1000))
#define OSSecondsToTicks(s) ((s) * (OSClockSpeed))

typedef s64 OSTime;
typedef u32 OSTick;
Expand Down

0 comments on commit 5e94ea0

Please sign in to comment.