Skip to content

Commit e211e3f

Browse files
committed
Added new display + Some optimizations
Added a display for the Stick Angle. Made some optimizations to the memcard functions. Added some extra text to the user manual.
1 parent 5f57cb4 commit e211e3f

File tree

11 files changed

+192
-123
lines changed

11 files changed

+192
-123
lines changed

USER_MANUAL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ This menu allows you to modify your entire inventory, including standard items,
6060
This menu allows you to modify Mario's stats, all of your partner's stats, whether or not partners are enabled or not, whether a partner is out or not, and whether or not a follower is out or not.
6161

6262
### Settings
63-
This menu allows you to save and load various settings. The current settings included are as follows:
63+
This menu allows you to save and load various settings. The settings are stored on a separate save file on the memory card. The current settings included are as follows:
6464
* Which cheats are active
6565
* Cheats button combos
6666
* Which displays are active

ttyd-tools/rel/include/codes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ void lockMarioHPToMax();
1919
void bobberyEarly();
2020
void spawnItem();
2121
void checkIfAreaFlagsShouldBeCleared();
22+
double getStickAngle();
2223

2324
void displaySequenceInPauseMenu();
2425
void displayOnScreenTimer();
2526
void displayMarioCoordinatesBoolCheck();
2627
void displayJumpStorageDetails();
2728
void displayButtonInputs();
29+
void displayStickAngle();
2830
void displayYoshiSkipDetails();
2931
void displayPalaceSkipDetails();
3032
void actionCommandsTimingsInit();

ttyd-tools/rel/include/draw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void drawSequenceInPauseMenu();
8989
void drawMarioCoordinates();
9090
void drawJumpStorageDetails();
9191
void drawButtonInputs();
92+
void drawStickAngle();
9293
void drawYoshiSkipDetails();
9394
void drawPalaceSkipDetails();
9495
void drawActionCommandsTiming();

ttyd-tools/rel/include/global.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ enum DISPLAYS_OPTIONS
239239
MARIO_COORDINATES,
240240
JUMP_STORAGE,
241241
BUTTON_INPUT_DISPLAY,
242+
STICK_ANGLE,
242243
GUARD_SUPERGUARD_TIMINGS,
243244
ART_ATTACK_HITBOXES,
244245
YOSHI_SKIP,
@@ -502,7 +503,7 @@ struct SettingsStruct
502503

503504
extern Menus Menu[21];
504505
extern Cheats Cheat[19];
505-
extern bool Displays[8];
506+
extern bool Displays[9];
506507
extern char DisplayBuffer[256];
507508

508509
extern AutoIncrement AdjustableValueMenu;
@@ -541,6 +542,7 @@ extern uint8_t BattlesCurrentActorStatsSize;
541542
extern const char *BattlesStatusesLines[];
542543
extern uint8_t BattlesStatusesLinesSize;
543544
extern uint16_t BattlesStatusesIcons[];
545+
extern uint8_t DisplaysOrder[];
544546
extern const char *DisplaysLines[];
545547
extern const char *OnScreenTimerOptions[];
546548
extern uint8_t OnScreenTimerOptionsSize;

ttyd-tools/rel/include/memcard.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ int32_t setFileStatus(int32_t chn, int32_t fileNo, gc::card::card_stat *stats,
2222
gc::card::cardcallback callback);
2323

2424
int32_t loopUntilSynced();
25-
int32_t openFile(const char *description, gc::card::card_file *fileInfo, uint8_t *workArea);
26-
bool loadSettings(gc::card::card_file *fileInfo);
27-
bool writeSettings(const char *description, gc::card::card_file *fileInfo);
28-
bool createSettingsFile(const char *fileName, const char *description, gc::card::card_file *fileInfo);
25+
26+
int32_t loadSettings(const char *fileName, gc::card::card_file *fileInfo, uint8_t *workArea);
27+
28+
int32_t writeSettings(const char *description, const char *fileName,
29+
gc::card::card_file *fileInfo, uint8_t *workArea);
30+
31+
int32_t createSettingsFile(const char *fileName, const char *description, gc::card::card_file *fileInfo);
2932

3033
}

ttyd-tools/rel/source/codes.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <ttyd/swdrv.h>
2020
#include <ttyd/win_main.h>
2121
#include <ttyd/itemdrv.h>
22+
#include <ttyd/w_atan2.h>
2223
#include <ttyd/battle_ac.h>
2324

2425
#include <cstdio>
@@ -751,6 +752,31 @@ void checkIfAreaFlagsShouldBeCleared()
751752
}
752753
}
753754

755+
double getStickAngle()
756+
{
757+
double StickX = static_cast<double>(ttyd::system::keyGetStickX(0));
758+
if (StickX > 127)
759+
{
760+
StickX -= 256;
761+
}
762+
763+
double StickY = static_cast<double>(ttyd::system::keyGetStickY(0));
764+
if (StickY > 127)
765+
{
766+
StickY -= 256;
767+
}
768+
769+
const double PI = 3.14159265358979323846;
770+
double StickAngle = (ttyd::w_atan2::atan2(StickX, StickY)) * (180 / PI);
771+
772+
if (StickAngle < 0)
773+
{
774+
StickAngle += 360;
775+
}
776+
777+
return StickAngle;
778+
}
779+
754780
void displaySequenceInPauseMenu()
755781
{
756782
uint32_t PauseMenuAddress = *reinterpret_cast<uint32_t *>(PauseMenuStartAddress);
@@ -835,6 +861,28 @@ void displayButtonInputs()
835861
drawFunctionOnDebugLayer(drawButtonInputs);
836862
}
837863

864+
void displayStickAngle()
865+
{
866+
if (!Displays[STICK_ANGLE])
867+
{
868+
return;
869+
}
870+
871+
// Don't display if the Yoshi Skip display is active
872+
if (Displays[YOSHI_SKIP])
873+
{
874+
return;
875+
}
876+
877+
// Don't display if the Guard/Superguard timings display is active
878+
if (DisplayActionCommands.DisplayTimer > 0)
879+
{
880+
return;
881+
}
882+
883+
drawFunctionOnDebugLayer(drawStickAngle);
884+
}
885+
838886
void displayYoshiSkipDetails()
839887
{
840888
if (!Displays[YOSHI_SKIP])

ttyd-tools/rel/source/draw.cpp

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "items.h"
55
#include "menufunctions.h"
66
#include "commonfunctions.h"
7+
#include "codes.h"
78

89
#include <ttyd/dispdrv.h>
910
#include <ttyd/windowdrv.h>
@@ -13,7 +14,6 @@
1314
#include <ttyd/mario_pouch.h>
1415
#include <ttyd/system.h>
1516
#include <ttyd/mario.h>
16-
#include <ttyd/w_atan2.h>
1717
#include <ttyd/battle_ac.h>
1818

1919
#include <cstdio>
@@ -2381,28 +2381,36 @@ void drawButtonInputs()
23812381
}
23822382
}
23832383

2384-
void drawYoshiSkipDetails()
2384+
void drawStickAngle()
23852385
{
2386-
double StickX = static_cast<double>(ttyd::system::keyGetStickX(0));
2387-
if (StickX > 127)
2388-
{
2389-
StickX -= 256;
2390-
}
2386+
uint32_t TextColor = 0xFFFFFFFF;
2387+
uint8_t Alpha = 0xFF;
2388+
int32_t PosX = -232;
2389+
int32_t PosY = -162;
2390+
float Scale = 0.75;
23912391

2392-
double StickY = static_cast<double>(ttyd::system::keyGetStickY(0));
2393-
if (StickY > 127)
2392+
// Move the text up if the input display is active
2393+
if (Displays[BUTTON_INPUT_DISPLAY])
23942394
{
2395-
StickY -= 256;
2395+
PosY += 20;
23962396
}
23972397

2398-
double PI = 3.14159265358979323846;
2399-
double StickAngle = (ttyd::w_atan2::atan2(StickX, StickY)) * (180 / PI);
2400-
2401-
if (StickAngle < 0)
2398+
// Move the text up if Mario's Coordinates are displayed, or if the Palace Skip display is active
2399+
if (Displays[MARIO_COORDINATES] || Displays[PALACE_SKIP])
24022400
{
2403-
StickAngle += 360;
2401+
PosY += 20;
24042402
}
24052403

2404+
char *tempDisplayBuffer = DisplayBuffer;
2405+
sprintf(tempDisplayBuffer,
2406+
"StickAngle: %.2f",
2407+
getStickAngle());
2408+
2409+
drawText(tempDisplayBuffer, PosX, PosY, Alpha, TextColor, Scale);
2410+
}
2411+
2412+
void drawYoshiSkipDetails()
2413+
{
24062414
uint32_t TextColor = 0xFFFFFFFF;
24072415
uint8_t Alpha = 0xFF;
24082416
int32_t PosX = -232;
@@ -2420,7 +2428,7 @@ void drawYoshiSkipDetails()
24202428
sprintf(tempDisplayBuffer,
24212429
"YST: %lu\nStickAngle: %.2f",
24222430
YoshiSkip.MainTimer,
2423-
StickAngle);
2431+
getStickAngle());
24242432

24252433
drawText(tempDisplayBuffer, PosX, PosY, Alpha, TextColor, Scale);
24262434

@@ -2553,6 +2561,12 @@ void drawPalaceSkipDetails()
25532561
PosY += 20;
25542562
}
25552563

2564+
// Move the text up if the stick angle display is active
2565+
if (Displays[STICK_ANGLE])
2566+
{
2567+
PosY += 20;
2568+
}
2569+
25562570
// Draw the text
25572571
char *tempDisplayBuffer = DisplayBuffer;
25582572
sprintf(tempDisplayBuffer,

ttyd-tools/rel/source/global.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace mod {
88

9-
const char *VersionNumber = "v3.0.12";
9+
const char *VersionNumber = "v3.0.13";
1010

1111
const char *RootLines[] =
1212
{
@@ -659,13 +659,27 @@ uint16_t BattlesStatusesIcons[] =
659659
#endif
660660
};
661661

662+
uint8_t DisplaysOrder[] =
663+
{
664+
ONSCREEN_TIMER,
665+
MARIO_COORDINATES,
666+
JUMP_STORAGE,
667+
BUTTON_INPUT_DISPLAY,
668+
GUARD_SUPERGUARD_TIMINGS,
669+
ART_ATTACK_HITBOXES,
670+
YOSHI_SKIP,
671+
PALACE_SKIP,
672+
STICK_ANGLE,
673+
};
674+
662675
const char *DisplaysLines[] =
663676
{
664677
"Return",
665678
"On-Screen Timer",
666679
"Mario's Coordinates",
667680
"Jump Storage",
668681
"Button Input Display",
682+
"Stick Angle",
669683
"Guard/Superguard Timings",
670684
"Art Attack Hitboxes",
671685
"Yoshi Skip",
@@ -805,7 +819,7 @@ const char *ButtonInputDisplay[] =
805819

806820
struct Menus Menu[21];
807821
struct Cheats Cheat[19];
808-
bool Displays[8];
822+
bool Displays[9];
809823
char DisplayBuffer[256];
810824

811825
struct AutoIncrement AdjustableValueMenu;
@@ -1022,15 +1036,12 @@ void initMenuVars()
10221036
MenuSettings.FileName = "rel_settings";
10231037

10241038
// Try to open the settings file
1025-
int32_t ReturnCode = openFile(MenuSettings.FileName,
1039+
int32_t ReturnCode = loadSettings(MenuSettings.FileName,
10261040
MenuSettings.FileInfo, MenuSettings.WorkArea);
10271041

1028-
if ((ReturnCode != CARD_ERROR_READY) ||
1029-
!loadSettings(MenuSettings.FileInfo))
1042+
if (ReturnCode != CARD_ERROR_READY)
10301043
{
10311044
// Settings file couldn't be opened, so set the default values
1032-
gc::card::CARDUnmount(CARD_SLOTA);
1033-
10341045
Cheat[WALK_THROUGH_WALLS].Active = false;
10351046
// Cheat[SAVE_COORDINATES].Active = false;
10361047
// Cheat[LOAD_COORDINATES].Active = false;

ttyd-tools/rel/source/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ void Mod::run()
601601
displaySequenceInPauseMenu();
602602
displayMarioCoordinatesBoolCheck();
603603
displayActionCommandsTiming();
604+
displayStickAngle();
604605
}
605606

606607
uint32_t tempFrameCounter = FrameCounter;

0 commit comments

Comments
 (0)