Skip to content

Commit b5a857c

Browse files
committed
Added the Memory menu
1 parent 62b09ad commit b5a857c

19 files changed

+2337
-29
lines changed

USER_MANUAL.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Cheats](#cheats)
88
- [Stats](#stats)
99
- [Settings](#settings)
10+
- [Memory](#memory)
1011
- [Battles](#battles)
1112
- [Displays](#displays)
1213
- [Warps](#warps)
@@ -65,6 +66,10 @@ This menu allows you to save and load various settings. The settings are stored
6566
* Cheats button combos
6667
* Which displays are active
6768
* Displays button combos
69+
* Memory watches (See below)
70+
71+
### Memory
72+
This menu allows you to watch the values of up to 30 memory addresses, with support for up to 10 pointer levels each. Each of these watches can also be displayed on the screen at will.
6873

6974
### Battles
7075
This menu allows you to change the HP, Max HP, FP, Max FP, held items, and statuses of anyone in a battle (refered to as Actors).

ttyd-tools/rel/include/codes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ void displayMarioCoordinatesBoolCheck();
2727
void displayJumpStorageDetails();
2828
void displayButtonInputs();
2929
void displayStickAngle();
30+
void displayMemoryWatches();
31+
3032
void displayYoshiSkipDetails();
3133
void displayPalaceSkipDetails();
3234
void actionCommandsTimingsInit();

ttyd-tools/rel/include/commonfunctions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ bool checkIfBadgeEquipped(int16_t badge);
3737
void recheckJumpAndHammerLevels();
3838
uint32_t getCurrentPitFloor();
3939
void clearGSWFsRange(uint32_t lowerBound, uint32_t upperBound);
40+
void *getLastPointerFromPath(void *address, int32_t *offset, uint32_t offsetAmount);;
4041

4142
}

ttyd-tools/rel/include/draw.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ void drawPartnerStats();
4646
void drawBattlesActorStats();
4747
void drawBattlesActorsHeldItem();
4848
void drawCurrentFollowerOut();
49+
void drawMemoryWatches();
50+
void drawMemoryModifyList();
51+
void drawMemoryTypeList();
52+
void drawMemoryChangeWatchPosition();
53+
void drawMemoryChangeAddressList();
4954
void drawBattlesActorsList();
5055
void drawBattlesStatusesList();
5156

@@ -55,6 +60,7 @@ void drawWarpsErrorMessage();
5560
void drawPartnerFollowerMessage(const char *message);
5661
void drawPartnerErrorMessage();
5762
void drawFollowersErrorMessage();
63+
void drawMemoryErrorMessage(const char *message);
5864
void drawNotInBattleErrorMessage();
5965
void drawConfirmationWindow(const char *message);
6066

@@ -69,6 +75,7 @@ void drawSingleLineFromStringAndArray(int32_t posX, int32_t posY,
6975

7076
void drawAdjustableValueSpawnItem();
7177
void drawAdjustableValue(bool changingItem, uint32_t currentMenu);
78+
void drawMemoryWatchAdjustableValue(uint32_t currentMenu);
7279
void drawAddByIconMain(uint32_t currentMenu);
7380
void drawAddByIcon(uint32_t currentMenu);
7481
void drawAddById(uint32_t currentMenu);
@@ -90,6 +97,8 @@ void drawMarioCoordinates();
9097
void drawJumpStorageDetails();
9198
void drawButtonInputs();
9299
void drawStickAngle();
100+
void drawMemoryWatchesOnOverworld();
101+
93102
void drawYoshiSkipDetails();
94103
void drawPalaceSkipDetails();
95104
void drawActionCommandsTiming();

ttyd-tools/rel/include/global.h

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum MENU_NAMES
1313
CHEATS,
1414
STATS,
1515
SETTINGS,
16+
MEMORY,
1617
BATTLES,
1718
DISPLAYS,
1819
WARPS,
@@ -25,6 +26,8 @@ enum MENU_NAMES
2526
STATS_MARIO,
2627
STATS_PARTNERS,
2728
STATS_FOLLOWERS,
29+
MEMORY_MODIFY,
30+
MEMORY_CHANGE_ADDRESS,
2831
BATTLES_CURRENT_ACTOR,
2932
BATTLES_STATUSES,
3033
DISPLAYS_ONSCREEN_TIMER,
@@ -191,6 +194,51 @@ enum SETTINGS_RETURN_CODES
191194
SAVE_SUCCESSFUL,
192195
};
193196

197+
enum MEMORY_TYPES
198+
{
199+
string = 0,
200+
time,
201+
s8,
202+
s16,
203+
s32,
204+
s64,
205+
u8,
206+
u16,
207+
u32,
208+
u64,
209+
f32,
210+
f64,
211+
};
212+
213+
enum MEMORY_OPTIONS
214+
{
215+
ADD_WATCH = 1,
216+
MODIFY_WATCH,
217+
DELETE_WATCH,
218+
};
219+
220+
enum MEMORY_MODIFY_OPTIONS
221+
{
222+
CHANGE_ADDRESS = 1,
223+
CHANGE_TYPE,
224+
SHOW_AS_HEX,
225+
CHANGE_WATCH_POSITION,
226+
DISPLAY_OUT_OF_MENU,
227+
};
228+
229+
enum MEMORY_MODIFY_ADDRESS_OPTIONS
230+
{
231+
CHANGE_ADDRESS_OR_POINTERS = 1,
232+
ADD_POINTER_LEVEL,
233+
REMOVE_POINTER_LEVEL,
234+
};
235+
236+
enum MEMORY_ERRORS
237+
{
238+
ALL_SLOTS_EMPTY = -2,
239+
NO_SLOTS_LEFT,
240+
};
241+
194242
enum BATTLES_CURRENT_ACTOR_STATS_SELECTION
195243
{
196244
CHANGE_ACTOR_HP = 1,
@@ -398,6 +446,14 @@ struct AutoIncrement
398446
uint16_t WaitFramesToPerformIncrement;
399447
};
400448

449+
struct AutoIncrementCoordinates
450+
{
451+
uint16_t WaitFramesToBeginIncrement;
452+
uint16_t WaitFramesToPerformIncrement;
453+
int32_t PosX;
454+
int32_t PosY;
455+
};
456+
401457
struct CheatsHandleDisplayButtons
402458
{
403459
uint8_t CheatsBButtonCounter;
@@ -493,20 +549,36 @@ struct MemoryCardStruct
493549
char *Description;
494550
};
495551

552+
struct MemoryWatchStruct
553+
{
554+
uint32_t Address;
555+
int32_t AddressOffset[10];
556+
uint8_t AddressOffsetAmount;
557+
uint8_t Type;
558+
bool ShowAsHex;
559+
bool Display;
560+
int32_t PosX;
561+
int32_t PosY;
562+
};
563+
496564
struct SettingsStruct
497565
{
498566
bool CheatsActive[100];
499567
uint16_t CheatButtonCombos[100];
500568
bool DisplaysActive[100];
501569
uint16_t DisplaysButtonCombos[100];
570+
MemoryWatchStruct MemoryWatchSettings[30];
502571
};
503572

504-
extern Menus Menu[21];
573+
extern Menus Menu[24];
505574
extern Cheats Cheat[19];
506575
extern bool Displays[9];
507576
extern char DisplayBuffer[256];
577+
extern MemoryWatchStruct MemoryWatch[30];
508578

509579
extern AutoIncrement AdjustableValueMenu;
580+
extern AutoIncrement MemoryWatchAdjustableValueMenu;
581+
extern AutoIncrementCoordinates MemoryWatchPosition;
510582
extern CheatsHandleDisplayButtons CheatsDisplayButtons;
511583
extern MarioPartnerPositionsStruct MarioPartnerPositions;
512584
extern SaveAnywhereStruct SaveAnywhere;
@@ -536,6 +608,10 @@ extern const char *StatsPartnerOptionsLines[];
536608
extern uint8_t StatsPartnerOptionsLinesSize;
537609
extern const char *StatsFollowerOptionsLines[];
538610
extern uint8_t StatsFollowerOptionsLinesSize;
611+
extern const char *MemoryModifyLines[];
612+
extern uint8_t MemoryModifyLinesSize;
613+
extern const char *MemoryTypeLines[];
614+
extern uint8_t MemoryTypeLinesSize;
539615
extern const char *BattlesActorsLines[];
540616
extern const char *BattlesCurrentActorStats[];
541617
extern uint8_t BattlesCurrentActorStatsSize;
@@ -554,8 +630,10 @@ extern const char *WarpDescriptions[];
554630
extern const char ButtonInputDisplay[];
555631
#else
556632
extern const char *ButtonInputDisplay[];
633+
extern const char *PointerText;
557634
#endif
558635

636+
extern bool HideMenu;
559637
extern bool MenuIsDisplayed;
560638
extern bool PreventClosingMenu;
561639
extern bool ChangingCheatButtonCombo;
@@ -570,6 +648,7 @@ extern int8_t FunctionReturnCode;
570648
extern uint32_t Timer;
571649
extern uint8_t MenuSelectionStates;
572650
extern int32_t MenuSecondaryValue;
651+
extern uint32_t MemoryWatchSecondaryValue;
573652
extern uint8_t FrameCounter;
574653

575654
extern uint32_t r13;
@@ -591,6 +670,7 @@ extern uint32_t FieldItemsAddressesStart;
591670

592671
extern uint32_t GlobalWorkPointer;
593672
extern uint32_t titleMainAddress;
673+
extern uint32_t ConsoleBusSpeedAddress;
594674

595675
extern bool ResetMarioProperties;
596676
extern int16_t ForcedNPCItemDrop;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
5+
namespace mod {
6+
7+
int32_t getEmptyWatchSlot();
8+
const char *getAddressStringNoLetterP(int32_t slot);
9+
const char *getAddressString(int32_t slot);
10+
const char *getAddressStringFromOffsets(int32_t slot, uint32_t maxOffset);
11+
const char *getValueString(int32_t slot);
12+
void addMemoryWatch(int32_t slot);
13+
void deleteWatch(int32_t slot);
14+
uint32_t adjustWatchValueControls(int32_t slot);
15+
void adjustWatchTempValueAndBounds(int32_t slot, uint32_t highestDigit, int32_t valueChangedBy);
16+
17+
}

ttyd-tools/rel/include/menufunctions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ bool checkForClosingErrorMessage();
2727
void correctInventoryCurrentMenuOptionAndPage(uint32_t maxOptionsPerPage);
2828
uint32_t getHighestAdjustableValueDigit(uint32_t currentMenu);
2929
int32_t getDigitBeingChanged(int32_t number, int32_t valueChangedBy);
30+
int32_t getDigitBeingChangedUnsignedHex(uint32_t number, int32_t valueChangedBy);
3031
void setAdjustableValueToMax(uint32_t currentMenu);
3132
void setAdjustableValueToMin(uint32_t currentMenu);
3233
uint32_t adjustableValueButtonControls(uint32_t currentMenu);
3334
uint32_t addByIconButtonControls(uint32_t currentMenu);
35+
uint32_t memoryAddressTypeButtonControls();
36+
uint32_t memoryChangeWatchPositionButtonControls();
3437
uint32_t marioSpecialMovesButtonControls();
3538
uint32_t followersOptionsButtonControls();
3639
void adjustMenuItemBoundsMain(int32_t valueChangedBy, int32_t lowerBound, int32_t upperBound);
@@ -66,6 +69,8 @@ void adjustMenuSelectionInventory(uint32_t button);
6669
void adjustCheatClearAreaFlagSelection(uint32_t button);
6770
void adjustMarioStatsSelection(uint32_t button);
6871
void adjustPartnerStatsSelection(uint32_t button);
72+
void adjustMemoryWatchSelection(uint32_t button);
73+
void adjustMemoryChangeAddressOrPointerSelection(uint32_t button);
6974
void adjustBattlesActorSelection(uint32_t button);
7075
void adjustBattlesStatusSelection(uint32_t button);
7176
void adjustWarpsSelection(uint32_t button);

ttyd-tools/rel/include/ttyd.eu.lst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,8 @@
12221222
80268570:_savegpr_29
12231223
80268574:_savegpr_30
12241224
80268578:_savegpr_31
1225+
802685CC:__udivdi3
1226+
802687F0:__umoddi3
12251227

12261228
// printf.c
12271229
8026DEAC:sprintf

ttyd-tools/rel/include/ttyd.jp.lst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,8 @@
12141214
8025E9E0:_savegpr_29
12151215
8025E9E4:_savegpr_30
12161216
8025E9E8:_savegpr_31
1217+
8025EA3C:__udivdi3
1218+
8025EC60:__umoddi3
12171219

12181220
// printf.c
12191221
80264108:sprintf

ttyd-tools/rel/include/ttyd.us.lst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,8 @@
12201220
80264990:_savegpr_29
12211221
80264994:_savegpr_30
12221222
80264998:_savegpr_31
1223+
802649EC:__udivdi3
1224+
80264C10:__umoddi3
12231225

12241226
// printf.c
12251227
8026A0B8:sprintf

0 commit comments

Comments
 (0)