Library/Screen: Implement ScreenPointCheckGroup (#786)

This commit is contained in:
Narr the Reg 2025-11-23 08:07:01 -06:00 committed by GitHub
parent 64aa34a491
commit 0b6d26020c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 73 additions and 5 deletions

View file

@ -278201,23 +278201,23 @@ Library/Screen/ScreenPointerCheckGroup.o:
label:
- _ZN2al21ScreenPointCheckGroupC1Ei
- _ZN2al21ScreenPointCheckGroupC2Ei
status: NotDecompiled
status: Matching
- offset: 0x9d4774
size: 92
label: _ZN2al21ScreenPointCheckGroup8setValidEPNS_17ScreenPointTargetE
status: NotDecompiled
status: Matching
- offset: 0x9d47d0
size: 100
label: _ZN2al21ScreenPointCheckGroup10setInvalidEPNS_17ScreenPointTargetE
status: NotDecompiled
status: Matching
- offset: 0x9d4834
size: 12
label: _ZNK2al21ScreenPointCheckGroup9getTargetEi
status: NotDecompiled
status: Matching
- offset: 0x9d4840
size: 28
label: _ZN2al21ScreenPointCheckGroup9setTargetEPNS_17ScreenPointTargetE
status: NotDecompiled
status: Matching
Library/Screen/ScreenPointKeeper.o:
'.text':
- offset: 0x9d485c

View file

@ -0,0 +1,43 @@
#include "Library/Screen/ScreenPointCheckGroup.h"
namespace al {
ScreenPointCheckGroup::ScreenPointCheckGroup(s32 size) : mSize(size) {
mScreenPointTargets = new ScreenPointTarget*[mSize];
for (s32 i = 0; i < mSize; i++)
mScreenPointTargets[i] = nullptr;
}
void ScreenPointCheckGroup::setValid(ScreenPointTarget* target) {
for (s32 i = mValidCount; i < mCount; i++) {
if (mScreenPointTargets[i] == target) {
mScreenPointTargets[i] = mScreenPointTargets[mValidCount];
mScreenPointTargets[mValidCount] = target;
mValidCount++;
break;
}
}
}
void ScreenPointCheckGroup::setInvalid(ScreenPointTarget* target) {
for (s32 i = 0; i < mValidCount; i++) {
if (mScreenPointTargets[i] == target) {
mScreenPointTargets[i] = mScreenPointTargets[mValidCount - 1];
mScreenPointTargets[mValidCount - 1] = target;
mValidCount--;
break;
}
}
}
ScreenPointTarget* ScreenPointCheckGroup::getTarget(s32 index) const {
return mScreenPointTargets[index];
}
void ScreenPointCheckGroup::setTarget(ScreenPointTarget* target) {
mScreenPointTargets[mCount] = target;
mCount++;
}
} // namespace al

View file

@ -0,0 +1,25 @@
#pragma once
#include <basis/seadTypes.h>
namespace al {
class ScreenPointTarget;
class ScreenPointCheckGroup {
public:
ScreenPointCheckGroup(s32 size);
void setValid(ScreenPointTarget* target);
void setInvalid(ScreenPointTarget* target);
ScreenPointTarget* getTarget(s32 index) const;
void setTarget(ScreenPointTarget* target);
private:
s32 mSize = 0;
s32 mCount = 0;
s32 mValidCount = 0;
// `mValidCount` valid targets first, followed by invalid ones up to `mCount`
ScreenPointTarget** mScreenPointTargets = nullptr;
};
static_assert(sizeof(ScreenPointCheckGroup) == 0x18);
} // namespace al