Skip to content

Commit 95f7e84

Browse files
committed
Memory - Added an option to duplicate watches
1 parent 288585d commit 95f7e84

File tree

7 files changed

+75
-4
lines changed

7 files changed

+75
-4
lines changed

ttyd-tools/rel/include/global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ enum MEMORY_OPTIONS
214214
{
215215
ADD_WATCH = 1,
216216
MODIFY_WATCH,
217+
DUPLICATE_WATCH,
217218
DELETE_WATCH,
218219
};
219220

ttyd-tools/rel/include/memorywatch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const char *getAddressStringFromOffsets(int32_t slot, uint32_t maxOffset);
1111
const char *getValueString(int32_t slot);
1212
void addMemoryWatch(int32_t slot);
1313
void deleteWatch(int32_t slot);
14+
void duplicateWatch(int32_t currentSlot, int32_t emptySlot);
1415
uint32_t adjustWatchValueControls(int32_t slot);
1516
void adjustWatchTempValueAndBounds(int32_t slot, uint32_t highestDigit, int32_t valueChangedBy);
1617
void *fixBaseAddress(int32_t slot, void *address);

ttyd-tools/rel/source/draw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,13 +1220,13 @@ void drawMemoryWatches()
12201220

12211221
uint32_t tempCurrentPage = CurrentPage;
12221222
int32_t TotalMenuOptions = sizeof(MemoryWatch) / sizeof(MemoryWatch[0]);
1223-
int32_t MaxOptionsPerPage = 10;
1223+
int32_t MaxOptionsPerPage = 9;
12241224
int32_t IndexStart = tempCurrentPage * MaxOptionsPerPage;
12251225

12261226
uint32_t Color = 0xFFFFFFFF;
12271227
uint8_t Alpha = 0xFF;
12281228
int32_t PosX = -232;
1229-
int32_t PosY = 80;
1229+
int32_t PosY = 60;
12301230
float Scale = 0.6;
12311231

12321232
const int32_t TypeOffset = 150;

ttyd-tools/rel/source/global.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace mod {
88

9-
const char *VersionNumber = "v3.0.16";
9+
const char *VersionNumber = "v3.0.17";
1010

1111
const char *RootLines[] =
1212
{
@@ -318,6 +318,7 @@ const char *MemoryLines[] =
318318
"Return",
319319
"Add Watch",
320320
"Modify Watch",
321+
"Duplicate Watch",
321322
"Delete Watch",
322323
};
323324

ttyd-tools/rel/source/memorywatch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ void deleteWatch(int32_t slot)
371371
}
372372
}
373373

374+
void duplicateWatch(int32_t currentSlot, int32_t emptySlot)
375+
{
376+
uint32_t Size = sizeof(MemoryWatch[0]);
377+
ttyd::__mem::memcpy(&MemoryWatch[emptySlot], &MemoryWatch[currentSlot], Size);
378+
}
379+
374380
uint32_t adjustWatchValueControls(int32_t slot)
375381
{
376382
uint32_t tempCurrentMenu = CurrentMenu;

ttyd-tools/rel/source/menu.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,32 @@ void menuCheckButton()
15621562
}
15631563
break;
15641564
}
1565+
case DUPLICATE_WATCH:
1566+
{
1567+
uint32_t tempAddress = MemoryWatch[0].Address;
1568+
if (tempAddress)
1569+
{
1570+
int32_t EmptyWatchSlot = getEmptyWatchSlot();
1571+
if (EmptyWatchSlot >= 0)
1572+
{
1573+
SelectedOption = tempCurrentMenuOption;
1574+
CurrentMenuOption = tempCurrentPage * 10;
1575+
}
1576+
else
1577+
{
1578+
// There are no more free slots
1579+
FunctionReturnCode = NO_SLOTS_LEFT;
1580+
Timer = secondsToFrames(3);
1581+
}
1582+
}
1583+
else
1584+
{
1585+
// All slots are empty
1586+
FunctionReturnCode = ALL_SLOTS_EMPTY;
1587+
Timer = secondsToFrames(3);
1588+
}
1589+
break;
1590+
}
15651591
case MODIFY_WATCH:
15661592
{
15671593
uint32_t tempAddress = MemoryWatch[0].Address;
@@ -1601,6 +1627,40 @@ void menuCheckButton()
16011627
}
16021628
break;
16031629
}
1630+
case DUPLICATE_WATCH:
1631+
{
1632+
uint32_t tempAddress = MemoryWatch[0].Address;
1633+
if (tempAddress)
1634+
{
1635+
int32_t EmptyWatchSlot = getEmptyWatchSlot();
1636+
if (EmptyWatchSlot >= 0)
1637+
{
1638+
duplicateWatch(static_cast<int32_t>(tempCurrentMenuOption), EmptyWatchSlot);
1639+
1640+
// Recheck to see if there are any empty slots left
1641+
if (getEmptyWatchSlot() < 0)
1642+
{
1643+
// There are no more free slots
1644+
closeSecondaryMenu();
1645+
}
1646+
}
1647+
else
1648+
{
1649+
// There are no more free slots
1650+
closeSecondaryMenu();
1651+
FunctionReturnCode = NO_SLOTS_LEFT;
1652+
Timer = secondsToFrames(3);
1653+
}
1654+
}
1655+
else
1656+
{
1657+
// All slots are empty
1658+
closeSecondaryMenu();
1659+
FunctionReturnCode = NO_SLOTS_LEFT;
1660+
Timer = secondsToFrames(3);
1661+
}
1662+
break;
1663+
}
16041664
case MODIFY_WATCH:
16051665
{
16061666
uint32_t tempAddress = MemoryWatch[0].Address;
@@ -1614,6 +1674,7 @@ void menuCheckButton()
16141674
else
16151675
{
16161676
// All slots are empty
1677+
closeSecondaryMenu();
16171678
FunctionReturnCode = NO_SLOTS_LEFT;
16181679
Timer = secondsToFrames(3);
16191680
}
@@ -1629,6 +1690,7 @@ void menuCheckButton()
16291690
else
16301691
{
16311692
// All slots are empty
1693+
closeSecondaryMenu();
16321694
FunctionReturnCode = NO_SLOTS_LEFT;
16331695
Timer = secondsToFrames(3);
16341696
}

ttyd-tools/rel/source/menufunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3327,7 +3327,7 @@ void adjustMemoryWatchSelection(uint32_t button)
33273327
}
33283328

33293329
uint32_t MaxOptionsPerRow = 1;
3330-
uint32_t MaxOptionsPerPage = 10;
3330+
uint32_t MaxOptionsPerPage = 9;
33313331

33323332
adjustMenuSelectionVertical(button, CurrentMenuOption,
33333333
CurrentPage, TotalMenuOptions, MaxOptionsPerPage,

0 commit comments

Comments
 (0)