Skip to content

Commit ab21631

Browse files
committed
Stats - Added an option to change Yoshi's name
Also cleaned up some of the Stat's menu code revolving around the partners, as well as a few other stuff.
1 parent 73529ba commit ab21631

File tree

12 files changed

+510
-65
lines changed

12 files changed

+510
-65
lines changed

ttyd-tools/rel/include/draw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ void drawMultipleColumnsVertical(int32_t posX, int32_t posY, uint32_t currentMen
5959
uint32_t maxOptionsPerRow, bool showCurrentOption,
6060
uint32_t posXIncrementAmount, const char **lines);
6161

62+
bool setCustomText(char *textOut, uint32_t textSize);
63+
6264
void drawInventoryIconAndTextColumns();
6365

6466
void drawItemIconsColumn(uint32_t indexStart, uint32_t indexIncrement, uint32_t size,

ttyd-tools/rel/include/global.h

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#pragma once
22

3+
#include "commonfunctions.h"
4+
35
#include <gc/OSAlloc.h>
46
#include <gc/pad.h>
57
#include <gc/DEMOPad.h>
68
#include <ttyd/item_data.h>
79
#include <ttyd/mapdata.h>
10+
#include <ttyd/msgdrv.h>
811

912
#include <cstdint>
13+
#include <cstring>
1014

1115
namespace mod {
1216

@@ -240,6 +244,7 @@ enum CHEATS_CLEAR_AREA_FLAGS_AREAS
240244
#define ADDING_BY_ICON 0x2108
241245
#define SPAWN_ITEM_MENU_VALUE 0x3000
242246
#define STATS_PARTNER_DISPLAY_YOSHI_COLORS 100
247+
#define STATS_PARTNER_DISPLAY_YOSHI_NAME 101
243248

244249
enum STATS_MARIO_SELECTION_OPTIONS
245250
{
@@ -268,6 +273,8 @@ enum STATS_PARTNER_SELECTION_OPTIONS
268273
PARTNER_MAX_HP,
269274
PARTNER_RANK,
270275
TOGGLE,
276+
CHANGE_YOSHI_COLOR,
277+
CHANGE_YOSHI_NAME,
271278
};
272279

273280
enum STATS_FOLLOWER_SELECTION_OPTIONS
@@ -595,8 +602,8 @@ struct MenuVars
595602

596603
MenuVars()
597604
{
598-
ForcedNPCItemDrop = ttyd::item_data::Item::SleepySheep;
599605
LagSpikeDuration = 468;
606+
ForcedNPCItemDrop = ttyd::item_data::Item::SleepySheep;
600607
}
601608
};
602609

@@ -1103,6 +1110,69 @@ struct UnusedMapStruct
11031110
}
11041111
};
11051112

1113+
struct SetCustomText
1114+
{
1115+
#define CUSTOM_TEXT_BUFFER_SIZE 32
1116+
#define CUSTOM_TEXT_TOTAL_CHARS_ROWS 5
1117+
#define CUSTOM_TEXT_CANCEL 0x1100
1118+
#define CUSTOM_TEXT_DONE 0x1200
1119+
1120+
char *Buffer;
1121+
const char *CharsToChooseFrom;
1122+
uint8_t CharsLength;
1123+
uint8_t CurrentIndex;
1124+
uint8_t CharsPerRow;
1125+
1126+
SetCustomText()
1127+
{
1128+
Buffer = new char[CUSTOM_TEXT_BUFFER_SIZE];
1129+
CharsToChooseFrom = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890/. ";
1130+
CharsLength = static_cast<uint8_t>(strlen(CharsToChooseFrom));
1131+
CharsPerRow = 1 + ((CharsLength - 1) / CUSTOM_TEXT_TOTAL_CHARS_ROWS); // Round up
1132+
}
1133+
1134+
void customTextInit(const char *initialText, uint32_t maxTextSize)
1135+
{
1136+
char *tempBuffer = reinterpret_cast<char *>(
1137+
clearMemory(Buffer, CUSTOM_TEXT_BUFFER_SIZE));
1138+
1139+
if (initialText)
1140+
{
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;
1172+
}
1173+
}
1174+
};
1175+
11061176
extern MenuVars MenuVar;
11071177
extern Menus Menu[38];
11081178
extern Cheats Cheat[28];
@@ -1141,6 +1211,7 @@ extern NpcNameToPtrErrorStruct NpcNameToPtrError;
11411211
extern EnemyEncounterNotifierStruct EnemyEncounterNotifier;
11421212
extern FrameAdvanceStruct FrameAdvance;
11431213
extern UnusedMapStruct UnusedMap;
1214+
extern SetCustomText CustomText;
11441215

11451216
extern uint8_t CheatsOrder[];
11461217
extern uint16_t StatsMarioIcons[];

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@
750750
// 80082944:msgWindow_Entry
751751
// 80082CD8:msgIconStr2ID
752752
// 80082D5C:msgGetCommand
753-
// 80082DFC:_ismbblead
753+
80082DFC:_ismbblead
754754
80082E48:msgSearch
755755
// 80082F28:msg_compare
756756
// 80082F70:L_msgGetWork
@@ -965,8 +965,8 @@
965965
800BFEE8:partyGetPtr
966966

967967
// mario_pouch.o
968-
// 800D3BAC:pouchGetYoshiName
969-
// 800D3BF4:pouchSetYoshiName
968+
800D3BAC:pouchGetYoshiName
969+
800D3BF4:pouchSetYoshiName
970970
800D3C20:pouchSetPartyColor
971971
800D3C3C:pouchGetPartyColor
972972
// 800D3C50:pouchCheckMail

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@
750750
// 80080B04:msgWindow_Entry
751751
// 80080E70:msgIconStr2ID
752752
// 80080EF4:msgGetCommand
753-
// 80080F94:_ismbblead
753+
80080F94:_ismbblead
754754
80080FC8:msgSearch
755755
// 800810A8:msg_compare
756756
// 800810F0:L_msgGetWork
@@ -965,8 +965,8 @@
965965
800BCE30:partyGetPtr
966966

967967
// mario_pouch.o
968-
// 800CEC68:pouchGetYoshiName
969-
// 800CECB0:pouchSetYoshiName
968+
800CEC68:pouchGetYoshiName
969+
800CECB0:pouchSetYoshiName
970970
800CECDC:pouchSetPartyColor
971971
800CECF8:pouchGetPartyColor
972972
// 800CED0C:pouchCheckMail

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@
750750
// 80081688:msgWindow_Entry
751751
// 80081A1C:msgIconStr2ID
752752
// 80081AA0:msgGetCommand
753-
// 80081B40:_ismbblead
753+
80081B40:_ismbblead
754754
80081B8C:msgSearch
755755
// 80081C6C:msg_compare
756756
// 80081CB4:L_msgGetWork
@@ -964,8 +964,8 @@
964964
800BF1B4:partyGetPtr
965965

966966
// mario_pouch.o
967-
// 800D2DB4:pouchGetYoshiName
968-
// 800D2DFC:pouchSetYoshiName
967+
800D2DB4:pouchGetYoshiName
968+
800D2DFC:pouchSetYoshiName
969969
800D2E28:pouchSetPartyColor
970970
800D2E44:pouchGetPartyColor
971971
// 800D2E58:pouchCheckMail

ttyd-tools/rel/include/menufunctions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ uint32_t marioSpecialMovesButtonControls();
4949
uint32_t partnerChangeYoshiColorButtonControls();
5050
uint32_t followersOptionsButtonControls();
5151

52+
uint32_t setCustomTextButtonControls(char *textOut, uint32_t textSize);
53+
5254
void adjustMenuItemBoundsMain(int32_t valueChangedBy, int32_t lowerBound, int32_t upperBound);
5355
void adjustMenuItemBoundsMainUnsigned(int32_t valueChangedBy, uint32_t lowerBound, uint32_t upperBound);
5456
void adjustMenuItemBounds(int32_t valueChangedBy, uint32_t currentMenu);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace ttyd::mario_pouch {
66

77
extern "C" {
88

9-
// pouchGetYoshiName
10-
// pouchSetYoshiName
9+
const char *pouchGetYoshiName();
10+
void pouchSetYoshiName(const char *name);
1111
void pouchSetPartyColor(uint32_t partnerId, uint32_t colorId);
1212
uint32_t pouchGetPartyColor(uint32_t partnerId);
1313
// pouchCheckMail

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern "C" {
1919
// msgWindow_Entry
2020
// msgIconStr2ID
2121
// msgGetCommand
22-
// _ismbblead
22+
bool _ismbblead(const char chr); // Checks if chr is the start of a Japanese character
2323
const char *msgSearch(const char *key);
2424
// msg_compare
2525
// L_msgGetWork

0 commit comments

Comments
 (0)