Main counters file

This commit is contained in:
robojumper
2024-05-03 09:50:23 +02:00
parent cf42625664
commit 5f621162a2
4 changed files with 63 additions and 28 deletions
+4 -28
View File
@@ -6,36 +6,12 @@
class Counter {
public:
Counter(u16 id): counterId(id) {}
// No vtable, this class appears to be header-only
virtual ~Counter() {};
/* 8016cc40 */ virtual s32 checkedAdd(s32 num) {
s32 uncommitted = getUncommittedValue();
s32 max = getMax();
s32 result = uncommitted + num;
if (result < 0) {
setValue(0);
} else if (result < max) {
setValue(result);
} else {
setValue(max);
}
if (result < 0) {
return result;
}
return result <= max ? 0 : (result - max);
}
virtual u16 getCommittedValue() {
return 0;
}
virtual s32 checkedAdd(s32 num);
virtual u16 getCommittedValue();
virtual u16 getMax() = 0;
virtual u16 getUncommittedValue() {
return 0;
}
virtual void setValue(u16 num) {
return;
}
virtual u16 getUncommittedValue();
virtual void setValue(u16 num);
u16 counterId;
};