Skip to content

Commit b58151e

Browse files
committed
Moved getStickAngle and getStickAngleString to menufunctions.cpp
1 parent 0eab926 commit b58151e

File tree

5 files changed

+71
-71
lines changed

5 files changed

+71
-71
lines changed

ttyd-tools/rel/include/codes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ void lockMarioHPToMax();
1919
void bobberyEarly();
2020
void spawnItem();
2121
void checkIfAreaFlagsShouldBeCleared();
22-
double getStickAngle(int32_t stickXYOut[2]); // If the X and Y values are not wanted, then pass in nullptr
23-
void getStickAngleString(char *stringOut);
2422

2523
void displaySequenceInPauseMenu();
2624
void displayOnScreenTimer();

ttyd-tools/rel/include/menufunctions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ bool getSequenceStageAndEvent(const char *arrayOut[2], char *stageNameBuffer, ui
9292
bool getSequenceStageAndEvent(const char *arrayOut[2], uint32_t sequencePosition);
9393
#endif
9494

95+
double getStickAngle(int32_t stickXYOut[2]); // If the X and Y values are not wanted, then pass in nullptr
96+
void getStickAngleString(char *stringOut);
97+
9598
// void getButtonsPressedDynamic(uint8_t *buttonArrayOut, uint32_t currentButtonCombo);
9699
void getButtonsPressed(uint8_t *buttonArrayOut, uint32_t currentButtonCombo);
97100
void createButtonStringArray(uint8_t *buttonArray, char *stringOut, uint32_t stringOutSize);

ttyd-tools/rel/source/codes.cpp

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <cstring>
3030
#include <cstdio>
3131
#include <cinttypes>
32-
#include <cmath>
3332

3433
namespace mod {
3534

@@ -832,73 +831,6 @@ void checkIfAreaFlagsShouldBeCleared()
832831
}
833832
}
834833

835-
double getStickAngle(int32_t stickXYOut[2])
836-
{
837-
int32_t StickXInt = static_cast<int32_t>(ttyd::system::keyGetStickX(0));
838-
int32_t StickYInt = static_cast<int32_t>(ttyd::system::keyGetStickY(0));
839-
840-
// Check if the stick is at the neutral position
841-
if ((StickXInt == 0) && (StickYInt == 0))
842-
{
843-
// The stick is currently at the neutral position
844-
if (stickXYOut)
845-
{
846-
stickXYOut[0] = 0;
847-
stickXYOut[1] = 0;
848-
}
849-
return -1000;
850-
}
851-
852-
if (StickXInt > 127)
853-
{
854-
StickXInt -= 256;
855-
}
856-
857-
if (StickYInt > 127)
858-
{
859-
StickYInt -= 256;
860-
}
861-
862-
// Store the individual stick values if desired
863-
if (stickXYOut)
864-
{
865-
stickXYOut[0] = StickXInt;
866-
stickXYOut[1] = StickYInt;
867-
}
868-
869-
double StickX = static_cast<double>(StickXInt);
870-
double StickY = static_cast<double>(StickYInt);
871-
const double PI = 3.14159265358979323846;
872-
873-
double StickAngle = (atan2(StickX, StickY)) * (180 / PI);
874-
if (StickAngle < 0)
875-
{
876-
StickAngle += 360;
877-
}
878-
879-
return StickAngle;
880-
}
881-
882-
void getStickAngleString(char *stringOut)
883-
{
884-
int32_t StickXYAngles[2];
885-
double StickAngle = getStickAngle(StickXYAngles);
886-
887-
// Check if the stick is at the neutral position
888-
if (StickAngle == -1000)
889-
{
890-
// The stick is currently at the neutral position
891-
strcpy(stringOut, "Neutral");
892-
return;
893-
}
894-
895-
sprintf(stringOut,
896-
"%.2f %" PRId32 " %" PRId32,
897-
StickAngle,
898-
StickXYAngles[0],
899-
StickXYAngles[1]);
900-
}
901-
902834
void displaySequenceInPauseMenu()
903835
{
904836
uint32_t SystemLevel = ttyd::mariost::marioStGetSystemLevel();

ttyd-tools/rel/source/draw.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "commonfunctions.h"
44
#include "menufunctions.h"
55
#include "memorywatch.h"
6-
#include "codes.h"
76
#include "mod.h"
87
#include "assembly.h"
98

ttyd-tools/rel/source/menufunctions.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <cstdio>
2929
#include <cstring>
3030
#include <cinttypes>
31+
#include <cmath>
3132

3233
namespace mod {
3334

@@ -3782,6 +3783,73 @@ bool getSequenceStageAndEvent(const char *arrayOut[2], uint32_t sequencePosition
37823783
return true;
37833784
}
37843785

3786+
double getStickAngle(int32_t stickXYOut[2])
3787+
{
3788+
int32_t StickXInt = static_cast<int32_t>(ttyd::system::keyGetStickX(0));
3789+
int32_t StickYInt = static_cast<int32_t>(ttyd::system::keyGetStickY(0));
3790+
3791+
// Check if the stick is at the neutral position
3792+
if ((StickXInt == 0) && (StickYInt == 0))
3793+
{
3794+
// The stick is currently at the neutral position
3795+
if (stickXYOut)
3796+
{
3797+
stickXYOut[0] = 0;
3798+
stickXYOut[1] = 0;
3799+
}
3800+
return -1000;
3801+
}
3802+
3803+
if (StickXInt > 127)
3804+
{
3805+
StickXInt -= 256;
3806+
}
3807+
3808+
if (StickYInt > 127)
3809+
{
3810+
StickYInt -= 256;
3811+
}
3812+
3813+
// Store the individual stick values if desired
3814+
if (stickXYOut)
3815+
{
3816+
stickXYOut[0] = StickXInt;
3817+
stickXYOut[1] = StickYInt;
3818+
}
3819+
3820+
double StickX = static_cast<double>(StickXInt);
3821+
double StickY = static_cast<double>(StickYInt);
3822+
const double PI = 3.14159265358979323846;
3823+
3824+
double StickAngle = (atan2(StickX, StickY)) * (180 / PI);
3825+
if (StickAngle < 0)
3826+
{
3827+
StickAngle += 360;
3828+
}
3829+
3830+
return StickAngle;
3831+
}
3832+
3833+
void getStickAngleString(char *stringOut)
3834+
{
3835+
int32_t StickXYAngles[2];
3836+
double StickAngle = getStickAngle(StickXYAngles);
3837+
3838+
// Check if the stick is at the neutral position
3839+
if (StickAngle == -1000)
3840+
{
3841+
// The stick is currently at the neutral position
3842+
strcpy(stringOut, "Neutral");
3843+
return;
3844+
}
3845+
3846+
sprintf(stringOut,
3847+
"%.2f %" PRId32 " %" PRId32,
3848+
StickAngle,
3849+
StickXYAngles[0],
3850+
StickXYAngles[1]);
3851+
}
3852+
37853853
/*void getButtonsPressedDynamic(uint8_t *buttonArrayOut, uint32_t currentButtonCombo)
37863854
{
37873855
uint32_t Counter = 0;

0 commit comments

Comments
 (0)