Skip to content

Commit e94a7ac

Browse files
committed
Small Bug Fixes and Changes
Fixed the adjustable value menu being shown for a frame after pressing A or B. This would also cause it to draw an incorrect amount of digits to be changed. Changed several misnamed variables. Added additional enums for values used in the adjustable menu. Modified the Change By Id and Change By Icon menu options to automatically set the value/position to the currently-selected item.
1 parent c031c3e commit e94a7ac

File tree

5 files changed

+84
-34
lines changed

5 files changed

+84
-34
lines changed

ttyd-tools/rel/include/global.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ enum CHEATS_CLEAR_AREA_FLAGS_AREAS
124124
AREA_JON,
125125
};
126126

127+
enum ADJUSTABLE_MENU_VALUES
128+
{
129+
NO_NUMBERS_TO_DISPLAY = 0x1000,
130+
ADDING_BY_ID = 0x1008,
131+
};
132+
127133
enum CHEATS_SPAWN_ITEM_MENU_VALUE
128134
{
129135
SPAWN_ITEM_MENU_VALUE = 0x7000,

ttyd-tools/rel/source/codes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ void spawnItem()
601601
lowerSystemLevel();
602602
return;
603603
}
604-
case 0x1000:
604+
case NO_NUMBERS_TO_DISPLAY:
605605
{
606606
// There are no digits of the number to display
607607
SpawnItem.InAdjustableValueMenu = false;

ttyd-tools/rel/source/draw.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,10 +1639,18 @@ void drawAdjustableValue(bool changingItem, uint32_t currentMenu)
16391639
if (currentMenu != SPAWN_ITEM_MENU_VALUE)
16401640
{
16411641
uint32_t ReturnCode = adjustableValueButtonControls(currentMenu);
1642-
if (ReturnCode == 0x1000)
1642+
switch (ReturnCode)
16431643
{
1644-
// There are no numbers to display, so exit
1645-
return;
1644+
case A: // Confirmed a value, so close the menu; Don't close if currently adding multiple items/badges
1645+
case B: // Canceled, so close the menu
1646+
case NO_NUMBERS_TO_DISPLAY: // There are no numbers to display, so close the menu
1647+
{
1648+
return;
1649+
}
1650+
default:
1651+
{
1652+
break;
1653+
}
16461654
}
16471655
}
16481656

@@ -1792,14 +1800,8 @@ void drawAddByIconMain(uint32_t currentMenu)
17921800
addByIconButtonControls(currentMenu);
17931801

17941802
// Draw the main window
1795-
int32_t Address_and_Size[2];
1796-
int32_t *tempArray = getUpperAndLowerBounds(Address_and_Size, MenuSelectedOption);
1797-
1798-
if (tempArray == nullptr)
1799-
{
1800-
return;
1801-
}
1802-
1803+
int32_t UpperAndLowerBounds[2];
1804+
int32_t *tempArray = getUpperAndLowerBounds(UpperAndLowerBounds, MenuSelectedOption);
18031805
int32_t LowerBound = tempArray[0];
18041806
int32_t UpperBound = tempArray[1];
18051807

@@ -2740,7 +2742,7 @@ void drawTitleScreenInfo()
27402742
PosX += 113;
27412743
PosY -= 14;
27422744

2743-
const char *String = "Practice Codes v3.0.7\nCreated by Zephiles";
2745+
const char *String = "Practice Codes v3.0.8\nCreated by Zephiles";
27442746
drawText(String, PosX, PosY, Alpha, TextColor, Scale);
27452747
}
27462748

ttyd-tools/rel/source/menu.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,21 @@ void menuCheckButton()
379379
{
380380
if (getTotalItems() > 0)
381381
{
382+
uint32_t Address_and_Size[2];
383+
uint32_t *tempArray = getPouchAddressAndSize(Address_and_Size);
384+
385+
if (tempArray != nullptr)
386+
{
387+
uint32_t tempAddress = tempArray[0];
388+
uint32_t CurrentItemAddress = tempAddress + (tempCurrentMenuOption * 0x2);
389+
int16_t CurrentItem = *reinterpret_cast<int16_t *>(CurrentItemAddress);
390+
MenuSecondaryValue = CurrentItem;
391+
}
392+
else
393+
{
394+
MenuSecondaryValue = 0;
395+
}
396+
382397
Timer = 0;
383398
if (tempMenuSelectionStates == 0)
384399
{
@@ -399,11 +414,38 @@ void menuCheckButton()
399414
{
400415
if (getTotalItems() > 0)
401416
{
417+
uint32_t Address_and_Size[2];
418+
uint32_t *tempArray = getPouchAddressAndSize(Address_and_Size);
419+
420+
if (tempArray != nullptr)
421+
{
422+
uint32_t tempAddress = tempArray[0];
423+
uint32_t CurrentItemAddress = tempAddress + (tempCurrentMenuOption * 0x2);
424+
int16_t CurrentItem = *reinterpret_cast<int16_t *>(CurrentItemAddress);
425+
426+
if (CurrentItem != 0)
427+
{
428+
int32_t UpperAndLowerBounds[2];
429+
int32_t *tempArray2 = getUpperAndLowerBounds(
430+
UpperAndLowerBounds, tempMenuSelectedOption);
431+
432+
int32_t LowerBound = tempArray2[0];
433+
SecondaryMenuOption = CurrentItem - LowerBound;
434+
}
435+
else
436+
{
437+
SecondaryMenuOption = 0;
438+
}
439+
}
440+
else
441+
{
442+
SecondaryMenuOption = 0;
443+
}
444+
402445
Timer = 0;
403446
if (tempMenuSelectionStates == 0)
404447
{
405448
MenuSelectionStates = tempSelectedOption;
406-
SecondaryMenuOption = 0;
407449
}
408450
}
409451
else

ttyd-tools/rel/source/menufunctions.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ void correctInventoryCurrentMenuOptionAndPage(uint32_t maxOptionsPerPage)
607607

608608
uint32_t getHighestAdjustableValueDigit(uint32_t currentMenu)
609609
{
610-
int32_t Address_and_Size[2];
611-
int32_t *tempArray = getUpperAndLowerBounds(Address_and_Size, currentMenu);
610+
int32_t UpperAndLowerBounds[2];
611+
int32_t *tempArray = getUpperAndLowerBounds(UpperAndLowerBounds, currentMenu);
612612
int32_t LowerBound = tempArray[0];
613613
int32_t UpperBound = tempArray[1];
614614

@@ -666,17 +666,17 @@ int32_t getDigitBeingChanged(int32_t number, int32_t valueChangedBy)
666666

667667
void setAdjustableValueToMax(uint32_t currentMenu)
668668
{
669-
int32_t Address_and_Size[2];
670-
int32_t *tempArray = getUpperAndLowerBounds(Address_and_Size, currentMenu);
669+
int32_t UpperAndLowerBounds[2];
670+
int32_t *tempArray = getUpperAndLowerBounds(UpperAndLowerBounds, currentMenu);
671671
int32_t UpperBound = tempArray[1];
672672

673673
MenuSecondaryValue = UpperBound;
674674
}
675675

676676
void setAdjustableValueToMin(uint32_t currentMenu)
677677
{
678-
int32_t Address_and_Size[2];
679-
int32_t *tempArray = getUpperAndLowerBounds(Address_and_Size, currentMenu);
678+
int32_t UpperAndLowerBounds[2];
679+
int32_t *tempArray = getUpperAndLowerBounds(UpperAndLowerBounds, currentMenu);
680680
int32_t LowerBound = tempArray[0];
681681

682682
MenuSecondaryValue = LowerBound;
@@ -844,7 +844,7 @@ uint32_t adjustableValueButtonControls(uint32_t currentMenu)
844844
setAddByIdValue(tempAddress);
845845

846846
FrameCounter = 1;
847-
return Button;
847+
return ADDING_BY_ID;
848848
}
849849
else
850850
{
@@ -993,7 +993,7 @@ uint32_t adjustableValueButtonControls(uint32_t currentMenu)
993993
}
994994
else
995995
{
996-
return 0x1000;
996+
return NO_NUMBERS_TO_DISPLAY;
997997
}
998998
}
999999
case CHEATS_CHANGE_SEQUENCE:
@@ -1009,7 +1009,7 @@ uint32_t adjustableValueButtonControls(uint32_t currentMenu)
10091009
}
10101010
else
10111011
{
1012-
return 0x1000;
1012+
return NO_NUMBERS_TO_DISPLAY;
10131013
}
10141014
}
10151015
case STATS_MARIO:
@@ -1026,7 +1026,7 @@ uint32_t adjustableValueButtonControls(uint32_t currentMenu)
10261026
}
10271027
else
10281028
{
1029-
return 0x1000;
1029+
return NO_NUMBERS_TO_DISPLAY;
10301030
}
10311031
}
10321032
case BATTLES_CURRENT_ACTOR:
@@ -1042,7 +1042,7 @@ uint32_t adjustableValueButtonControls(uint32_t currentMenu)
10421042
}
10431043
else
10441044
{
1045-
return 0x1000;
1045+
return NO_NUMBERS_TO_DISPLAY;
10461046
}
10471047
}
10481048
default:
@@ -1085,8 +1085,8 @@ uint32_t addByIconButtonControls(uint32_t currentMenu)
10851085
case DPADDOWN:
10861086
case DPADUP:
10871087
{
1088-
int32_t Address_and_Size[2];
1089-
int32_t *tempArray = getUpperAndLowerBounds(Address_and_Size, currentMenu);
1088+
int32_t UpperAndLowerBounds[2];
1089+
int32_t *tempArray = getUpperAndLowerBounds(UpperAndLowerBounds, currentMenu);
10901090
int32_t LowerBound = tempArray[0];
10911091
int32_t UpperBound = tempArray[1];
10921092

@@ -1494,8 +1494,8 @@ void adjustMenuItemBounds(int32_t valueChangedBy, uint32_t currentMenu)
14941494
}
14951495
}
14961496

1497-
int32_t Address_and_Size[2];
1498-
int32_t *tempArray = getUpperAndLowerBounds(Address_and_Size, currentMenu);
1497+
int32_t UpperAndLowerBounds[2];
1498+
int32_t *tempArray = getUpperAndLowerBounds(UpperAndLowerBounds, currentMenu);
14991499
int32_t LowerBound = tempArray[0];
15001500
int32_t UpperBound = tempArray[1];
15011501

@@ -1965,11 +1965,11 @@ void setAddByIdValue(void *address)
19651965

19661966
void setAddByIconValue(void *address)
19671967
{
1968-
int32_t Address_and_Size[2];
1969-
int32_t *tempArray = getUpperAndLowerBounds(Address_and_Size, MenuSelectedOption);
1968+
int32_t UpperAndLowerBounds[2];
1969+
int32_t *tempArray = getUpperAndLowerBounds(UpperAndLowerBounds, MenuSelectedOption);
19701970
int32_t LowerBound = tempArray[0];
19711971
uint32_t tempSecondaryMenuOption = SecondaryMenuOption;
1972-
int32_t NewItem = LowerBound + tempSecondaryMenuOption;
1972+
int32_t NewItem = LowerBound + tempSecondaryMenuOption;
19731973

19741974
*reinterpret_cast<int16_t *>(
19751975
reinterpret_cast<uint32_t>(address)) = NewItem;
@@ -2825,8 +2825,8 @@ void adjustMenuSelectionInventory(uint32_t button)
28252825

28262826
/*void adjustAddByIconCurrentOption(uint32_t button)
28272827
{
2828-
int32_t Address_and_Size[2];
2829-
int32_t *tempArray = getUpperAndLowerBounds(Address_and_Size, MenuSelectedOption);
2828+
int32_t UpperAndLowerBounds[2];
2829+
int32_t *tempArray = getUpperAndLowerBounds(UpperAndLowerBounds, MenuSelectedOption);
28302830
int32_t LowerBound = tempArray[0];
28312831
int32_t UpperBound = tempArray[1];
28322832

0 commit comments

Comments
 (0)