Skip to content

Commit f8d4e76

Browse files
committed
Added a cheat for changing Yoshi colors
Also cleaned up some other code, including removing unnecessary uses of semicolons, not loading SecondaryMenuOption every time in some loops, and using non-static positioning with some displays.
1 parent fd9ac3a commit f8d4e76

File tree

14 files changed

+307
-29
lines changed

14 files changed

+307
-29
lines changed

ttyd-tools/rel/include/commonfunctions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ void *getPartnerPointer();
3838
void *getFollowerPointer();
3939
void removePartnerFromOverworld();
4040
void removeFollowerFromOverworld();
41+
uint32_t getCurrentYoshiColorId();
42+
void setNewYoshiColorId(uint32_t colorId);
4143
bool checkIfBadgeEquipped(int16_t badge);
4244
void recheckJumpAndHammerLevels();
4345
uint32_t getCurrentPitFloor();
4446
void clearGSWFsRange(uint32_t lowerBound, uint32_t upperBound);
4547
void clear_DC_IC_Cache(void *ptr, uint32_t size);
4648
bool checkIfPointerIsValid(void *ptr);
47-
void *getLastPointerFromPath(void *address, int32_t *offset, uint32_t offsetAmount);;
49+
void *getLastPointerFromPath(void *address, int32_t *offset, uint32_t offsetAmount);
4850

4951
}
5052

ttyd-tools/rel/include/draw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ bool getSequenceStageAndEvent(const char **returnArray, uint32_t sequencePositio
9292
#endif
9393

9494
void drawCheatsChangeSequence();
95+
void drawCheatsCurrentYoshiColor();
96+
void drawCheatsChangeYoshiColorOptions();
9597
void drawCheatsBool(int32_t posY);
9698
void drawButtonCombo(uint16_t buttonCombo, int32_t posY, const char *description);
9799
void drawChangeButtonCombo(uint16_t &currentButtonCombo);

ttyd-tools/rel/include/global.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ enum MENU_NAMES
1919
WARPS,
2020
INVENTORY_MAIN,
2121
CHEATS_CHANGE_SEQUENCE,
22+
CHEATS_CHANGE_YOSHI_COLOR,
2223
CHEATS_STANDARD,
2324
CHEATS_NO_BUTTON_COMBO,
2425
CHEATS_NPC_FORCE_DROP,
@@ -79,6 +80,7 @@ enum CHEATS_OPTIONS
7980
LEVITATE,
8081
LOCK_MARIO_HP_TO_MAX,
8182
RUN_FROM_BATTLES,
83+
CHANGE_YOSHI_COLOR,
8284
DISABLE_DPAD_OPTIONS_DISPLAY,
8385
DISABLE_MENU_SOUNDS,
8486
BOBBERY_EARLY,
@@ -633,8 +635,8 @@ struct WarpByIndexStruct
633635
}
634636
};
635637

636-
extern Menus Menu[27];
637-
extern Cheats Cheat[22];
638+
extern Menus Menu[28];
639+
extern Cheats Cheat[23];
638640
extern bool Displays[10];
639641
extern char DisplayBuffer[256];
640642
extern char HeapBuffer[1024];
@@ -662,6 +664,8 @@ extern WarpByIndexStruct WarpByIndex;
662664
extern const char *VersionNumber;
663665
extern uint8_t CheatsOrder[];
664666
extern const char *CheatsLines[];
667+
extern const char *CheatsYoshiColorOptionsLines[];
668+
extern uint8_t CheatsYoshiColorOptionsLinesSize;
665669
extern const char *CheatsForceItemDropAreas[];
666670
extern uint8_t CheatsForceItemDropAreasSize;
667671
extern const char *CheatsForceItemDropAreasFullNames[];

ttyd-tools/rel/include/menufunctions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ uint32_t addByIconButtonControls(uint32_t currentMenu);
3636
uint32_t memoryAddressTypeButtonControls();
3737
uint32_t memoryChangeWatchPositionButtonControls();
3838
uint32_t marioSpecialMovesButtonControls();
39+
uint32_t cheatChangeYoshiColorButtonControls();
3940
uint32_t followersOptionsButtonControls();
4041
void adjustMenuItemBoundsMain(int32_t valueChangedBy, int32_t lowerBound, int32_t upperBound);
4142
void adjustMenuItemBounds(int32_t valueChangedBy, uint32_t currentMenu);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@
703703
// mario_pouch.o
704704
// 800D3BAC:pouchGetYoshiName
705705
// 800D3BF4:pouchSetYoshiName
706-
// 800D3C20:pouchSetPartyColor
707-
// 800D3C3C:pouchGetPartyColor
706+
800D3C20:pouchSetPartyColor
707+
800D3C3C:pouchGetPartyColor
708708
// 800D3C50:pouchCheckMail
709709
// 800D3CAC:pouchOpenMail
710710
// 800D3CEC:pouchReceiveMail

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@
698698
// mario_pouch.o
699699
// 800CEC68:pouchGetYoshiName
700700
// 800CECB0:pouchSetYoshiName
701-
// 800CECDC:pouchSetPartyColor
702-
// 800CECF8:pouchGetPartyColor
701+
800CECDC:pouchSetPartyColor
702+
800CECF8:pouchGetPartyColor
703703
// 800CED0C:pouchCheckMail
704704
// 800CED68:pouchOpenMail
705705
// 800CEDA8:pouchReceiveMail

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,8 @@
702702
// mario_pouch.o
703703
// 800D2DB4:pouchGetYoshiName
704704
// 800D2DFC:pouchSetYoshiName
705-
// 800D2E28:pouchSetPartyColor
706-
// 800D2E44:pouchGetPartyColor
705+
800D2E28:pouchSetPartyColor
706+
800D2E44:pouchGetPartyColor
707707
// 800D2E58:pouchCheckMail
708708
// 800D2EB4:pouchOpenMail
709709
// 800D2EF4:pouchReceiveMail

ttyd-tools/rel/include/ttyd/mario_pouch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ extern "C" {
88

99
// pouchGetYoshiName
1010
// pouchSetYoshiName
11-
// pouchSetPartyColor
12-
// pouchGetPartyColor
11+
void pouchSetPartyColor(uint32_t partnerId, uint32_t colorId);
12+
uint32_t pouchGetPartyColor(uint32_t partnerId);
1313
// pouchCheckMail
1414
// pouchOpenMail
1515
// pouchReceiveMail

ttyd-tools/rel/source/commonfunctions.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,26 @@ void removeFollowerFromOverworld()
245245
ttyd::party::partyKill2(FollowerID);
246246
}
247247

248+
uint32_t getCurrentYoshiColorId()
249+
{
250+
const uint32_t YoshiPartnerId = 4;
251+
return ttyd::mario_pouch::pouchGetPartyColor(YoshiPartnerId);
252+
}
253+
254+
void setNewYoshiColorId(uint32_t colorId)
255+
{
256+
// Make sure the desired color is valid
257+
const uint32_t ColorIdWhite = 6;
258+
if (colorId > ColorIdWhite)
259+
{
260+
// The desired color is not valid
261+
return;
262+
}
263+
264+
const uint32_t YoshiPartnerId = 4;
265+
ttyd::mario_pouch::pouchSetPartyColor(YoshiPartnerId, colorId);
266+
}
267+
248268
bool checkIfBadgeEquipped(int16_t badge)
249269
{
250270
return ttyd::mario_pouch::pouchEquipCheckBadge(badge) > 0;

ttyd-tools/rel/source/draw.cpp

Lines changed: 94 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,9 @@ void drawMarioSpecialMovesOptions()
670670
drawText(HelpText, PosX, PosY, Alpha, Color, Scale);
671671

672672
// Set the values for the text to use
673+
int32_t NewPosY = PosY - 54;
673674
PosX += 25;
674-
PosY = 90;
675+
PosY = NewPosY;
675676

676677
// Set up array to use for displaying icons
677678
int32_t IconPosition[3];
@@ -682,6 +683,7 @@ void drawMarioSpecialMovesOptions()
682683
IconPosition[IconPositionY] = PosY - 18;
683684

684685
// Draw the icons and main text
686+
uint32_t tempSecondaryMenuOption = SecondaryMenuOption;
685687
int16_t SpecialMoveIcon;
686688

687689
for (uint32_t i = 0; i < 8; i++)
@@ -700,7 +702,7 @@ void drawMarioSpecialMovesOptions()
700702
drawIconFromItem(IconPosition, SpecialMoveIcon, Scale);
701703

702704
// Draw the main text
703-
if (SecondaryMenuOption == i)
705+
if (tempSecondaryMenuOption == i)
704706
{
705707
Color = 0x5B59DEFF;
706708
}
@@ -719,7 +721,7 @@ void drawMarioSpecialMovesOptions()
719721
uint32_t PouchPtr = reinterpret_cast<uint32_t>(ttyd::mario_pouch::pouchGetPtr());
720722
int16_t SpecialMovesBits = *reinterpret_cast<int16_t *>(PouchPtr + 0x8C);
721723
PosX += 130;
722-
PosY = 90;
724+
PosY = NewPosY;
723725

724726
for (uint32_t i = 0; i < 8; i++)
725727
{
@@ -771,9 +773,11 @@ void drawFollowersOptions()
771773

772774
// Draw the main text
773775
uint32_t tempStatsFollowerOptionsLinesSize = StatsFollowerOptionsLinesSize;
776+
uint32_t tempSecondaryMenuOption = SecondaryMenuOption;
777+
774778
for (uint32_t i = 0; i < tempStatsFollowerOptionsLinesSize; i++)
775779
{
776-
if (SecondaryMenuOption == i)
780+
if (tempSecondaryMenuOption == i)
777781
{
778782
Color = 0x5B59DEFF;
779783
}
@@ -1469,9 +1473,11 @@ void drawMemoryTypeList()
14691473

14701474
// Draw the main text
14711475
uint32_t Size = MemoryTypeLinesSize;
1476+
uint32_t tempSecondaryMenuOption = SecondaryMenuOption;
1477+
14721478
for (uint32_t i = 0; i < Size; i++)
14731479
{
1474-
if (SecondaryMenuOption == i)
1480+
if (tempSecondaryMenuOption == i)
14751481
{
14761482
Color = 0x5B59DEFF;
14771483
}
@@ -2257,9 +2263,10 @@ void drawAdjustableValue(bool changingItem, uint32_t currentMenu)
22572263
}
22582264

22592265
// Draw each digit of the number
2266+
uint32_t tempSecondaryMenuOption = SecondaryMenuOption;
22602267
for (uint32_t i = 0; i < AmountOfNumbers; i++)
22612268
{
2262-
if (SecondaryMenuOption == i)
2269+
if (tempSecondaryMenuOption == i)
22632270
{
22642271
color = 0x5B59DEFF;
22652272
}
@@ -2396,9 +2403,10 @@ void drawMemoryWatchAdjustableValue(uint32_t currentMenu)
23962403
drawText("0x", (x - 30), y, alpha, color, scale);
23972404

23982405
// Draw each digit of the number
2406+
uint32_t tempSecondaryMenuOption = SecondaryMenuOption;
23992407
for (uint32_t i = 0; i < AmountOfNumbers; i++)
24002408
{
2401-
if (SecondaryMenuOption == i)
2409+
if (tempSecondaryMenuOption == i)
24022410
{
24032411
color = 0x5B59DEFF;
24042412
}
@@ -2748,6 +2756,85 @@ void drawCheatsChangeSequence()
27482756
drawText(String, PosX, PosY, Alpha, Color, Scale);
27492757
}
27502758

2759+
void drawCheatsCurrentYoshiColor()
2760+
{
2761+
uint32_t Color = 0xFFFFFFFF;
2762+
uint8_t Alpha = 0xFF;
2763+
int32_t PosX = -232;
2764+
int32_t PosY = 120;
2765+
float Scale = 0.6;
2766+
2767+
// Get the current Yoshi color
2768+
uint32_t CurrentColorId = getCurrentYoshiColorId();
2769+
const char *CurrentColorString = "";
2770+
2771+
// Make sure the current color is valid
2772+
const uint32_t ColorIdWhite = 6;
2773+
if (CurrentColorId <= ColorIdWhite)
2774+
{
2775+
CurrentColorString = CheatsYoshiColorOptionsLines[CurrentColorId];
2776+
}
2777+
2778+
char *tempDisplayBuffer = DisplayBuffer;
2779+
sprintf(tempDisplayBuffer,
2780+
"Current Color: %s",
2781+
CurrentColorString);
2782+
2783+
drawText(tempDisplayBuffer, PosX, PosY, Alpha, Color, Scale);
2784+
2785+
// Draw the text stating that the player must change partners for the new color to take effect
2786+
const char *String = "You must swap partners for the new color to\ntake effect";
2787+
drawText(String, PosX, PosY - 40, Alpha, Color, Scale);
2788+
}
2789+
2790+
void drawCheatsChangeYoshiColorOptions()
2791+
{
2792+
// Check for button inputs
2793+
cheatChangeYoshiColorButtonControls();
2794+
2795+
// Draw the window
2796+
uint32_t Color = 0x151515F6;
2797+
int32_t PosX = -106;
2798+
int32_t PosY = 123;
2799+
int32_t Width = 212;
2800+
int32_t Height = 239;
2801+
int32_t Curve = 20;
2802+
2803+
drawWindow(Color, PosX, PosY, Width, Height, Curve);
2804+
2805+
// Draw the help text
2806+
const char *HelpText = "Press A to confirm\nPress B to cancel";
2807+
uint8_t Alpha = 0xFF;
2808+
float Scale = 0.6;
2809+
Color = 0xFFFFFFFF;
2810+
PosX += 30;
2811+
PosY -= 25;
2812+
2813+
drawText(HelpText, PosX, PosY, Alpha, Color, Scale);
2814+
2815+
// Set the values for the text to use
2816+
uint32_t tempSecondaryMenuOption = SecondaryMenuOption;
2817+
PosX += 47;
2818+
PosY -= 54;
2819+
2820+
uint32_t Size = CheatsYoshiColorOptionsLinesSize;
2821+
for (uint32_t i = 0; i < Size; i++)
2822+
{
2823+
// Draw the main text
2824+
if (tempSecondaryMenuOption == i)
2825+
{
2826+
Color = 0x5B59DEFF;
2827+
}
2828+
else
2829+
{
2830+
Color = 0xFFFFFFFF;
2831+
}
2832+
2833+
drawText(CheatsYoshiColorOptionsLines[i], PosX, PosY, Alpha, Color, Scale);
2834+
PosY -= 20;
2835+
}
2836+
}
2837+
27512838
void drawCheatsBool(int32_t posY)
27522839
{
27532840
uint32_t tempMenuSelectedOption = MenuSelectedOption;

0 commit comments

Comments
 (0)