6
6
#include < gc/pad.h>
7
7
#include < gc/DEMOPad.h>
8
8
#include < ttyd/item_data.h>
9
+ #include < ttyd/mario_pouch.h>
10
+ #include < ttyd/party.h>
9
11
#include < ttyd/mapdata.h>
10
- #include < ttyd/msgdrv.h>
11
12
12
13
#include < cstdint>
13
- #include < cstring>
14
14
15
15
namespace mod {
16
16
@@ -39,6 +39,7 @@ enum MENU_NAMES
39
39
CHEATS_MANAGE_FLAGS,
40
40
CHEATS_MANAGE_FLAGS_MAIN,
41
41
CHEATS_CLEAR_AREA_FLAGS,
42
+ CHEATS_MANAGE_CUSTOM_STATES,
42
43
STATS_MARIO,
43
44
STATS_PARTNERS,
44
45
STATS_FOLLOWERS,
@@ -108,6 +109,7 @@ enum CHEATS_OPTIONS
108
109
LOCK_FLAGS,
109
110
MANAGE_FLAGS,
110
111
CLEAR_AREA_FLAGS,
112
+ MANAGE_CUSTOM_STATES,
111
113
};
112
114
113
115
enum CHEATS_CHANGE_SEQUENCE_SELECTION
@@ -238,6 +240,22 @@ enum CHEATS_CLEAR_AREA_FLAGS_AREAS
238
240
AREA_JON,
239
241
};
240
242
243
+ enum CHEATS_MANAGE_CUSTOM_STATES_SELECTION
244
+ {
245
+ LOAD_CUSTOM_STATE = 1 ,
246
+ CREATE_CUSTOM_STATE,
247
+ DELETE_CUSTOM_STATE,
248
+ RENAME_CUSTOM_STATE,
249
+ };
250
+
251
+ enum CHEATS_MANAGE_CUSTOM_STATES_RETURN_VALUES
252
+ {
253
+ NO_STATES_EXIST = -4 ,
254
+ MAX_STATES_EXIST,
255
+ STATES_CREATE_NOT_IN_GAME,
256
+ STATES_WARP_NOT_IN_GAME,
257
+ };
258
+
241
259
// Various menu values
242
260
#define NO_NUMBERS_TO_DISPLAY 0x2000
243
261
#define ADDING_BY_ID 0x2008
@@ -688,8 +706,8 @@ struct ReloadRoomStruct
688
706
{
689
707
bool ManuallyReloadingRoom;
690
708
bool SystemLevelShouldBeLowered;
691
- char NewBero[32 ]; // 31 bytes for NextBero, 1 byte for NULL
692
- char NewMap[9 ]; // 8 bytes for NextMap, 1 byte for NULL
709
+ char NewBero[16 ]; // Not null terminated
710
+ char NewMap[8 ]; // Not null terminated
693
711
};
694
712
695
713
struct SpawnItems
@@ -991,6 +1009,65 @@ struct FrameAdvanceStruct
991
1009
}
992
1010
};
993
1011
1012
+ struct CustomStateMarioVars
1013
+ {
1014
+ int16_t currentHP;
1015
+ int16_t maxHP;
1016
+ int16_t currentFP;
1017
+ int16_t maxFP;
1018
+ int16_t maxHPEnteringBattle;
1019
+ int16_t maxFPEnteringBattle;
1020
+ int16_t currentSP;
1021
+ int16_t maxSP;
1022
+ int16_t availableBP;
1023
+ int16_t maxBP;
1024
+ int16_t rank;
1025
+ int16_t level;
1026
+ uint16_t starPowersObtained;
1027
+ int16_t starPoints;
1028
+ int16_t coins;
1029
+ } __attribute__((__packed__));
1030
+
1031
+ struct CustomStateStruct
1032
+ {
1033
+ int16_t StandardItems[20 ];
1034
+ int16_t ImportantItems[121 ];
1035
+ int16_t Badges[200 ];
1036
+ int16_t EquippedBadges[200 ];
1037
+ int16_t StoredItems[32 ];
1038
+ uint16_t SequencePosition;
1039
+ CustomStateMarioVars MarioVars;
1040
+ ttyd::mario_pouch::PouchPartyData PartyData[7 ];
1041
+ ttyd::party::PartyMembers PartnerOut;
1042
+ ttyd::party::PartyMembers FollowerOut;
1043
+ bool MarioIsShip;
1044
+ char StateName[16 ]; // Does not include null terminator
1045
+ char CurrentMap[8 ]; // Does not include null terminator
1046
+ char CurrentBero[16 ]; // Does not include null terminator
1047
+ uint8_t padding;
1048
+ } __attribute__((__packed__));
1049
+
1050
+ struct ManageCustomStates
1051
+ {
1052
+ #define CUSTOM_STATES_MAX_COUNT 10
1053
+ #define CUSTOM_STATES_MAX_NAMES_PER_PAGE 18
1054
+
1055
+ CustomStateStruct *State;
1056
+ uint8_t TotalEntries;
1057
+ bool StateWasSelected;
1058
+ uint8_t SelectedState;
1059
+
1060
+ // Do not inline createCustomState nor deleteCustomState
1061
+ char *createCustomState ();
1062
+ uint32_t deleteCustomState (uint32_t stateIndex);
1063
+ };
1064
+
1065
+ struct CustomStateSettingsStruct
1066
+ {
1067
+ uint32_t CustomStateCount;
1068
+ uint32_t OffsetToCustomStates;
1069
+ } __attribute__((__packed__));
1070
+
994
1071
struct SettingsStruct
995
1072
{
996
1073
bool CheatsActive[100 ];
@@ -1000,6 +1077,7 @@ struct SettingsStruct
1000
1077
MemoryWatchStruct MemoryWatchSettings[60 ];
1001
1078
MemoryEditorSaveStruct MemoryEditorSave;
1002
1079
FrameAdvanceButtonCombosStruct FrameAdvanceButtonCombos;
1080
+ CustomStateSettingsStruct CustomStateSettings;
1003
1081
} __attribute__((__packed__));
1004
1082
1005
1083
struct SaveFileDecriptionInfo
@@ -1117,6 +1195,10 @@ struct SetCustomText
1117
1195
#define CUSTOM_TEXT_CANCEL 0x1100
1118
1196
#define CUSTOM_TEXT_DONE 0x1200
1119
1197
1198
+ #define CUSTOM_TEXT_RETURN_CANCEL -1
1199
+ #define CUSTOM_TEXT_RETURN_BUSY 0
1200
+ #define CUSTOM_TEXT_RETURN_DONE 1
1201
+
1120
1202
char *Buffer;
1121
1203
const char *CharsToChooseFrom;
1122
1204
uint8_t CharsLength;
@@ -1131,51 +1213,21 @@ struct SetCustomText
1131
1213
CharsPerRow = 1 + ((CharsLength - 1 ) / CUSTOM_TEXT_TOTAL_CHARS_ROWS); // Round up
1132
1214
}
1133
1215
1134
- void customTextInit ( const char *initialText, uint32_t maxTextSize )
1216
+ ~SetCustomText ( )
1135
1217
{
1136
- char *tempBuffer = reinterpret_cast <char *>(
1137
- clearMemory (Buffer, CUSTOM_TEXT_BUFFER_SIZE));
1138
-
1139
- if (initialText)
1218
+ if (Buffer)
1140
1219
{
1141
- #ifdef TTYD_JP
1142
- // Custom text doesn't currently support Japanese characters
1143
- if (ttyd::msgdrv::_ismbblead (initialText[0 ]))
1144
- {
1145
- // Text starts with a Japanese character
1146
- CurrentIndex = 0 ;
1147
- }
1148
- else
1149
- {
1150
- #endif
1151
- uint32_t MaxIndex = maxTextSize - 1 ;
1152
- if (MaxIndex > (CUSTOM_TEXT_BUFFER_SIZE - 1 ))
1153
- {
1154
- MaxIndex = (CUSTOM_TEXT_BUFFER_SIZE - 1 );
1155
- }
1156
-
1157
- uint32_t Length = strlen (initialText);
1158
- if (Length > MaxIndex)
1159
- {
1160
- Length = MaxIndex;
1161
- }
1162
-
1163
- CurrentIndex = static_cast <uint8_t >(Length);
1164
- strncpy (tempBuffer, initialText, Length);
1165
- #ifdef TTYD_JP
1166
- }
1167
- #endif
1168
- }
1169
- else
1170
- {
1171
- CurrentIndex = 0 ;
1220
+ delete[] (Buffer);
1172
1221
}
1173
1222
}
1223
+
1224
+ // Do not inline customTextInit
1225
+ void customTextInit (const char *initialText, uint32_t maxTextSize);
1174
1226
};
1175
1227
1176
1228
extern MenuVars MenuVar;
1177
- extern Menus Menu[38 ];
1178
- extern Cheats Cheat[28 ];
1229
+ extern Menus Menu[39 ];
1230
+ extern Cheats Cheat[29 ];
1179
1231
extern bool Displays[19 ];
1180
1232
extern char DisplayBuffer[256 ];
1181
1233
extern MemoryWatchStruct MemoryWatch[60 ];
@@ -1212,6 +1264,7 @@ extern EnemyEncounterNotifierStruct EnemyEncounterNotifier;
1212
1264
extern FrameAdvanceStruct FrameAdvance;
1213
1265
extern UnusedMapStruct UnusedMap;
1214
1266
extern SetCustomText CustomText;
1267
+ extern ManageCustomStates CustomState;
1215
1268
1216
1269
extern uint8_t CheatsOrder[];
1217
1270
extern uint16_t StatsMarioIcons[];
0 commit comments