rewrite TargetInspector to directly access memory, and add experimental ShouldVibrate bool
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
enum TargetHitStates
|
||||
enum TargetHitStates : int32_t
|
||||
{
|
||||
COOL,
|
||||
FINE,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace TLAC::Components
|
||||
{
|
||||
bool TargetInspector::repressTbl[maxTargetSlots];
|
||||
bool TargetInspector::ShouldVibrate;
|
||||
|
||||
TargetInspector::TargetInspector()
|
||||
{
|
||||
@@ -14,15 +15,13 @@ namespace TLAC::Components
|
||||
|
||||
void TargetInspector::Initialize(ComponentsManager*)
|
||||
{
|
||||
tgtTypePtr = (int*)TGT_TYPE_BASE_ADDRESS;
|
||||
tgtHitStatePtr = (int*)TGT_HIT_STATE_BASE_ADDRESS;
|
||||
tgtRemainingTimePtr = (float*)TGT_REMAINING_DURATION_BASE_ADDRESS;
|
||||
tgtStates = (TargetState*)TGT_STATES_BASE_ADDRESS;
|
||||
}
|
||||
|
||||
void TargetInspector::Update()
|
||||
{
|
||||
GetTargetStates();
|
||||
UpdateRepressTbl();
|
||||
UpdateShouldVibrate();
|
||||
}
|
||||
|
||||
const char* TargetInspector::GetDisplayName()
|
||||
@@ -30,16 +29,6 @@ namespace TLAC::Components
|
||||
return "target_inspector";
|
||||
}
|
||||
|
||||
void TargetInspector::GetTargetStates()
|
||||
{
|
||||
for (int i = 0; i < maxTargetSlots; ++i)
|
||||
{
|
||||
tgtStates[i].tgtType = *((int*)((char*)tgtTypePtr + (i * offset)));
|
||||
tgtStates[i].tgtHitState = *((int*)((char*)tgtHitStatePtr + (i * offset)));
|
||||
tgtStates[i].tgtRemainingTime = *((float*)((char*)tgtRemainingTimePtr + (i * offset)));
|
||||
}
|
||||
}
|
||||
|
||||
void TargetInspector::UpdateRepressTbl()
|
||||
{
|
||||
for (int i = 0; i < maxTargetSlots; ++i)
|
||||
@@ -50,6 +39,22 @@ namespace TLAC::Components
|
||||
}
|
||||
}
|
||||
|
||||
void TargetInspector::UpdateShouldVibrate()
|
||||
{
|
||||
for (int i = 0; i < maxTargetSlots; ++i)
|
||||
{
|
||||
if (IsWithinRange(tgtStates[i].tgtRemainingTime)
|
||||
&& (tgtStates[i].tgtType == SLIDE_LONG_L || tgtStates[i].tgtType == SLIDE_LONG_R)
|
||||
&& tgtStates[i].tgtHitState == NONE)
|
||||
{
|
||||
//printf("%d\n", tgtStates[i].tgtHitState);
|
||||
ShouldVibrate = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ShouldVibrate = false;
|
||||
}
|
||||
|
||||
bool TargetInspector::IsWithinRange(float time)
|
||||
{
|
||||
return time < timingThreshold && time > -timingThreshold && time != 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
const int maxTargetSlots = 32;
|
||||
const int maxTargetSlots = 64;
|
||||
|
||||
class TargetInspector : public EmulatorComponent
|
||||
{
|
||||
@@ -21,23 +21,20 @@ namespace TLAC::Components
|
||||
virtual void Update() override;
|
||||
virtual const char* GetDisplayName() override;
|
||||
|
||||
void GetTargetStates();
|
||||
static bool IsAnyRepress();
|
||||
|
||||
static bool ShouldVibrate;
|
||||
|
||||
private:
|
||||
const uint64_t offset = 0x4A8;
|
||||
//const uint64_t offset = 0x4A8;
|
||||
const float timingThreshold = 0.13f; // PS4 estimate
|
||||
|
||||
TargetState tgtStates[maxTargetSlots];
|
||||
|
||||
int* tgtTypePtr;
|
||||
int* tgtHitStatePtr;
|
||||
float* tgtRemainingTimePtr;
|
||||
TargetState* tgtStates;
|
||||
|
||||
bool IsSlide(int);
|
||||
bool IsWithinRange(float);
|
||||
bool HasNotBeenHit(int);
|
||||
void UpdateRepressTbl();
|
||||
|
||||
void UpdateShouldVibrate();
|
||||
};
|
||||
}
|
||||
@@ -4,8 +4,17 @@ namespace TLAC::Components
|
||||
{
|
||||
struct TargetState
|
||||
{
|
||||
int tgtType;
|
||||
int tgtHitState;
|
||||
// seems to be some kind of linked list..
|
||||
// not sure if these are for all active targets or just used in some functions
|
||||
TargetState* prev;
|
||||
TargetState* next;
|
||||
byte padding10[0x4];
|
||||
TargetTypes tgtType;
|
||||
float tgtRemainingTime;
|
||||
byte padding1C[0x434];
|
||||
byte ToBeRemoved; // FromList
|
||||
byte padding451[0xB];
|
||||
TargetHitStates tgtHitState;
|
||||
byte padding460[0x48];
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
enum TargetTypes
|
||||
enum TargetTypes : int32_t
|
||||
{
|
||||
SANKAKU,
|
||||
MARU,
|
||||
|
||||
Reference in New Issue
Block a user