From 8d6d73108bd55be0aad9f1c1c1b8c286ecce9d2f Mon Sep 17 00:00:00 2001 From: Ozero4 Date: Mon, 24 Feb 2025 20:22:07 +0100 Subject: [PATCH 1/3] Partial decompilation of TouchControl --- include/Player/TouchControl.hpp | 6 ++++- src/00_Core/Player/TouchControl.cpp | 34 ++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/include/Player/TouchControl.hpp b/include/Player/TouchControl.hpp index 1301e144..8970c032 100644 --- a/include/Player/TouchControl.hpp +++ b/include/Player/TouchControl.hpp @@ -5,6 +5,8 @@ #include "nds/math.h" #include "types.h" +extern u16 *data_0207aecc; + typedef u16 TouchFlags; enum TouchFlag_ { TouchFlag_TouchedNow = 0x0001, @@ -42,9 +44,11 @@ public: void Update(TouchState *state, u16 speed); bool func_ov00_0207aeac(); void UpdateConditionally(TouchState *state, u16 speed); - void func_ov00_0207af38(u16 speed, bool param2); + void func_ov00_0207af38(u16 speedIncrease, bool shouldIncrease); ~TouchControl(); static bool func_0202b864(Vec3p *param1, s32 size, unk8 param3); static bool func_0202b894(Vec3p *param1, s32 size, unk8 param3); }; + +void Fill16(int value, unsigned short *dst, int size); // TODO: Replace with header file diff --git a/src/00_Core/Player/TouchControl.cpp b/src/00_Core/Player/TouchControl.cpp index 5cae75a5..9630de1a 100644 --- a/src/00_Core/Player/TouchControl.cpp +++ b/src/00_Core/Player/TouchControl.cpp @@ -1,11 +1,39 @@ #include "Player/TouchControl.hpp" TouchControl::TouchControl() {} -void TouchControl::IncreaseSpeed(s16 increase) {} + +void TouchControl::IncreaseSpeed(s16 increase) { + this->mFlags = 0; + this->mSpeed += increase; +} + void TouchControl::UpdateFlags(u16 speed) {} void TouchControl::UpdateWithStateFlags(TouchStateFlags *state, u16 speed) {} void TouchControl::Update(TouchState *state, u16 speed) {} -bool TouchControl::func_ov00_0207aeac() {} +bool TouchControl::func_ov00_0207aeac() { + return ((*data_0207aecc & 0x8000) >> 15) == 1; +} void TouchControl::UpdateConditionally(TouchState *state, u16 speed) {} -void TouchControl::func_ov00_0207af38(u16 speed, bool param2) {} + +void TouchControl::func_ov00_0207af38(u16 speedIncrease, bool shouldIncrease) { + TouchStateFlags touchState; + + if (shouldIncrease) { + IncreaseSpeed(speedIncrease); /* TODO: IncreaseSpeed expects an s16 variable, + while speedIncrease is a u16. As a result, the function + performs a conversion that is not present in the binary. */ + return; + } + + u32 result = TouchControl::func_ov00_0207aeac(); + if (result != 0) { + Fill16(0, &touchState.touchX, 8); + } else { + + GetTouchStateFlags(&touchState); + } + + UpdateWithStateFlags(&touchState, speedIncrease); +} + TouchControl::~TouchControl() {} From 18af19e0ac0fa5975db45c9eadc7c2ffae1ff9ee Mon Sep 17 00:00:00 2001 From: SammygoodTunes <56520787+SammygoodTunes@users.noreply.github.com> Date: Sat, 12 Apr 2025 18:04:36 +0200 Subject: [PATCH 2/3] Add stdio.h to c libs --- libs/c/include/stdio.h | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 libs/c/include/stdio.h diff --git a/libs/c/include/stdio.h b/libs/c/include/stdio.h new file mode 100644 index 00000000..3eb4cf94 --- /dev/null +++ b/libs/c/include/stdio.h @@ -0,0 +1,6 @@ +#ifndef _C_STDIO_H +#define _C_STDIO_H + +extern int sprintf(char *__restrict s, const char *__restrict format, ...); + +#endif From 16054a3b11cea7eb2d4cf74dbd84d8ac68e25de0 Mon Sep 17 00:00:00 2001 From: SammygoodTunes <56520787+SammygoodTunes@users.noreply.github.com> Date: Sun, 13 Apr 2025 12:20:33 +0200 Subject: [PATCH 3/3] Update stdio.h --- libs/c/include/stdio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/c/include/stdio.h b/libs/c/include/stdio.h index 3eb4cf94..3b49b3aa 100644 --- a/libs/c/include/stdio.h +++ b/libs/c/include/stdio.h @@ -1,6 +1,6 @@ #ifndef _C_STDIO_H #define _C_STDIO_H -extern int sprintf(char *__restrict s, const char *__restrict format, ...); +int sprintf(char *__restrict s, const char *__restrict format, ...); #endif