From 93cc80b6638a984abef236ca6800a27ea5dfbcc2 Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Mon, 22 Jan 2024 05:26:56 -0800 Subject: [PATCH] JASInstSense --- include/JSystem/JAudio/JASInstSense.h | 25 ++++++++++++++++++++ src/JSystem/JAudio/JASInstSense.cpp | 33 +++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 include/JSystem/JAudio/JASInstSense.h diff --git a/include/JSystem/JAudio/JASInstSense.h b/include/JSystem/JAudio/JASInstSense.h new file mode 100644 index 000000000..e7d34cf47 --- /dev/null +++ b/include/JSystem/JAudio/JASInstSense.h @@ -0,0 +1,25 @@ +#ifndef JASINSTSENSE_H +#define JASINSTSENSE_H + +#include "JSystem/JAudio/JASInstEffect.h" + +namespace JASystem { + class TInstSense : public TInstEffect { + public: + TInstSense() { + field_0x8 = 0; + field_0x9 = 60; + field_0xc = 1.0f; + field_0x10 = 1.0f; + } + virtual f32 getY(int, int) const; + void setParams(int, int, f32, f32); + + u8 field_0x8; + u8 field_0x9; + f32 field_0xc; + f32 field_0x10; + }; +} + +#endif /* JASINSTSENSE_H */ diff --git a/src/JSystem/JAudio/JASInstSense.cpp b/src/JSystem/JAudio/JASInstSense.cpp index a93974d69..35a934da6 100644 --- a/src/JSystem/JAudio/JASInstSense.cpp +++ b/src/JSystem/JAudio/JASInstSense.cpp @@ -3,15 +3,38 @@ // Translation Unit: JASInstSense.cpp // -#include "JASInstSense.h" -#include "dolphin/types.h" +#include "JSystem/JAudio/JASInstSense.h" +#include "JSystem/JUtility/JUTAssert.h" /* 802868F0-80286A1C .text getY__Q28JASystem10TInstSenseCFii */ -void JASystem::TInstSense::getY(int, int) const { +f32 JASystem::TInstSense::getY(int param_1, int param_2) const { /* Nonmatching */ + int r6 = 0; + switch (field_0x8) { + case 1: + r6 = param_2; + break; + case 2: + r6 = param_1; + break; + } + if (field_0x9 == 0x7f || field_0x9 == 0) { + return field_0xc + r6 * (field_0x10 - field_0xc) / 127.0f; + } + if (r6 < field_0x9) { + return field_0xc + (1.0f - field_0xc) * r6 / field_0x9; + } + return field_0x10 - 1.0f * (r6 - field_0x9) / (0x7f - field_0x9) + 1.0f; } /* 80286A1C-80286B58 .text setParams__Q28JASystem10TInstSenseFiiff */ -void JASystem::TInstSense::setParams(int trigger, int centerkey, float, float) { - /* Nonmatching */ +void JASystem::TInstSense::setParams(int trigger, int centerkey, f32 param_3, f32 param_4) { + JUT_ASSERT(43, trigger >= 0); + JUT_ASSERT(44, trigger < 256); + field_0x8 = trigger; + JUT_ASSERT(47, centerkey >= 0); + JUT_ASSERT(48, centerkey < 256); + field_0x9 = centerkey; + field_0xc = param_3; + field_0x10 = param_4; }