Match the single-counter TUs

This commit is contained in:
robojumper
2024-05-02 13:48:08 +02:00
parent 1ecdfe9a4d
commit cf42625664
11 changed files with 278 additions and 42 deletions
+43
View File
@@ -127,6 +127,49 @@ toBeSorted/skipflag_manager.cpp:
.sbss start:0x80575408 end:0x8057540C
.bss start:0x805A9C68 end:0x805A9C88
toBeSorted/counters/rupee_counter.cpp:
.text start:0x8016DE10 end:0x8016DF98
.ctors start:0x804DB7BC end:0x804DB7C0
.rodata start:0x804E91B0 end:0x804E91D0
.data start:0x80527FF0 end:0x80528010
.sbss start:0x80575610 end:0x80575618
toBeSorted/counters/arrow_counter.cpp:
.text start:0x8016DFA0 end:0x8016E018
.ctors start:0x804DB7C0 end:0x804DB7C4
.data start:0x80528010 end:0x80528030
.sbss start:0x80575618 end:0x80575620
toBeSorted/counters/bomb_counter.cpp:
.text start:0x8016E020 end:0x8016E098
.ctors start:0x804DB7C4 end:0x804DB7C8
.data start:0x80528030 end:0x80528050
.sbss start:0x80575620 end:0x80575628
toBeSorted/counters/tear_counter.cpp:
.text start:0x8016E0A0 end:0x8016E118
.ctors start:0x804DB7C8 end:0x804DB7CC
.data start:0x80528050 end:0x80528070
.sbss start:0x80575628 end:0x80575630
toBeSorted/counters/slingshot_seed_counter.cpp:
.text start:0x8016E120 end:0x8016E198
.ctors start:0x804DB7CC end:0x804DB7D0
.data start:0x80528070 end:0x80528090
.sbss start:0x80575630 end:0x80575638
toBeSorted/counters/key_piece_counter.cpp:
.text start:0x8016E1A0 end:0x8016E218
.ctors start:0x804DB7D0 end:0x804DB7D4
.data start:0x80528090 end:0x805280B0
.sbss start:0x80575638 end:0x80575640
toBeSorted/counters/extra_wallet_counter.cpp:
.text start:0x8016E220 end:0x8016E298
.ctors start:0x804DB7D4 end:0x804DB7D8
.data start:0x805280B0 end:0x805280D0
.sbss start:0x80575640 end:0x80575648
c/c_list.cpp:
.text start:0x802E08C0 end:0x802E0A10
+42 -42
View File
@@ -9354,10 +9354,10 @@ fn_8016CB40 = .text:0x8016CB40; // type:function size:0x1C
fn_8016CB60 = .text:0x8016CB60; // type:function size:0x78
fn_8016CBE0 = .text:0x8016CBE0; // type:function size:0x3C
fn_8016CC20 = .text:0x8016CC20; // type:function size:0x14
fn_8016CC40 = .text:0x8016CC40; // type:function size:0xF0
fn_8016CD30 = .text:0x8016CD30; // type:function size:0x20
fn_8016CD50 = .text:0x8016CD50; // type:function size:0x20
fn_8016CD70 = .text:0x8016CD70; // type:function size:0x24
checkedAdd__7CounterFi = .text:0x8016CC40; // type:function size:0xF0
getCommittedValue__7CounterFv = .text:0x8016CD30; // type:function size:0x20
getUncommittedValue__7CounterFv = .text:0x8016CD50; // type:function size:0x20
setValue__7CounterFUs = .text:0x8016CD70; // type:function size:0x24
fn_8016CDA0 = .text:0x8016CDA0; // type:function size:0x64
fn_8016CE10 = .text:0x8016CE10; // type:function size:0x10
fn_8016CE20 = .text:0x8016CE20; // type:function size:0x14
@@ -9432,36 +9432,36 @@ fn_8016D990 = .text:0x8016D990; // type:function size:0x8
fn_8016D9A0 = .text:0x8016D9A0; // type:function size:0x8
fn_8016D9B0 = .text:0x8016D9B0; // type:function size:0x8
fn_8016D9C0 = .text:0x8016D9C0; // type:function size:0x448
fn_8016DE10 = .text:0x8016DE10; // type:function size:0xAC
fn_8016DEC0 = .text:0x8016DEC0; // type:function size:0x2C
fn_8016DEF0 = .text:0x8016DEF0; // type:function size:0x40
fn_8016DF30 = .text:0x8016DF30; // type:function size:0x18
fn_8016DF50 = .text:0x8016DF50; // type:function size:0x38
fn_8016DF90 = .text:0x8016DF90; // type:function size:0x8
fn_8016DFA0 = .text:0x8016DFA0; // type:function size:0x40
fn_8016DFE0 = .text:0x8016DFE0; // type:function size:0x18
fn_8016E000 = .text:0x8016E000; // type:function size:0x8
fn_8016E010 = .text:0x8016E010; // type:function size:0x8
fn_8016E020 = .text:0x8016E020; // type:function size:0x40
fn_8016E060 = .text:0x8016E060; // type:function size:0x18
fn_8016E080 = .text:0x8016E080; // type:function size:0x8
fn_8016E090 = .text:0x8016E090; // type:function size:0x8
fn_8016E0A0 = .text:0x8016E0A0; // type:function size:0x40
fn_8016E0E0 = .text:0x8016E0E0; // type:function size:0x18
fn_8016E100 = .text:0x8016E100; // type:function size:0x8
fn_8016E110 = .text:0x8016E110; // type:function size:0x8
fn_8016E120 = .text:0x8016E120; // type:function size:0x40
fn_8016E160 = .text:0x8016E160; // type:function size:0x18
fn_8016E180 = .text:0x8016E180; // type:function size:0x8
fn_8016E190 = .text:0x8016E190; // type:function size:0x8
fn_8016E1A0 = .text:0x8016E1A0; // type:function size:0x40
fn_8016E1E0 = .text:0x8016E1E0; // type:function size:0x18
fn_8016E200 = .text:0x8016E200; // type:function size:0x8
fn_8016E210 = .text:0x8016E210; // type:function size:0x8
fn_8016E220 = .text:0x8016E220; // type:function size:0x40
fn_8016E260 = .text:0x8016E260; // type:function size:0x18
fn_8016E280 = .text:0x8016E280; // type:function size:0x8
fn_8016E290 = .text:0x8016E290; // type:function size:0x8
getBaseCapacity__Fv = .text:0x8016DE10; // type:function size:0xAC
getExtraWalletCapacity__Fv = .text:0x8016DEC0; // type:function size:0x2C
__dt__12RupeeCounterFv = .text:0x8016DEF0; // type:function size:0x40
__ct__12RupeeCounterFv = .text:0x8016DF30; // type:function size:0x18
getMax__12RupeeCounterFv = .text:0x8016DF50; // type:function size:0x38
__sinit_\rupee_counter_cpp = .text:0x8016DF90; // type:function size:0x8 scope:local
__dt__12ArrowCounterFv = .text:0x8016DFA0; // type:function size:0x40
__ct__12ArrowCounterFv = .text:0x8016DFE0; // type:function size:0x18
getMax__12ArrowCounterFv = .text:0x8016E000; // type:function size:0x8
__sinit_\arrow_counter_cpp = .text:0x8016E010; // type:function size:0x8 scope:local
__dt__11BombCounterFv = .text:0x8016E020; // type:function size:0x40
__ct__11BombCounterFv = .text:0x8016E060; // type:function size:0x18
getMax__11BombCounterFv = .text:0x8016E080; // type:function size:0x8
__sinit_\bomb_counter_cpp = .text:0x8016E090; // type:function size:0x8 scope:local
__dt__11TearCounterFv = .text:0x8016E0A0; // type:function size:0x40
__ct__11TearCounterFv = .text:0x8016E0E0; // type:function size:0x18
getMax__11TearCounterFv = .text:0x8016E100; // type:function size:0x8
__sinit_\tear_counter_cpp = .text:0x8016E110; // type:function size:0x8 scope:local
__dt__20SlingshotSeedCounterFv = .text:0x8016E120; // type:function size:0x40
__ct__20SlingshotSeedCounterFv = .text:0x8016E160; // type:function size:0x18
getMax__20SlingshotSeedCounterFv = .text:0x8016E180; // type:function size:0x8
__sinit_\slingshot_seed_counter_cpp = .text:0x8016E190; // type:function size:0x8 scope:local
__dt__15KeyPieceCounterFv = .text:0x8016E1A0; // type:function size:0x40
__ct__15KeyPieceCounterFv = .text:0x8016E1E0; // type:function size:0x18
getMax__15KeyPieceCounterFv = .text:0x8016E200; // type:function size:0x8
__sinit_\key_piece_counter_cpp = .text:0x8016E210; // type:function size:0x8 scope:local
__dt__18ExtraWalletCounterFv = .text:0x8016E220; // type:function size:0x40
__ct__18ExtraWalletCounterFv = .text:0x8016E260; // type:function size:0x18
getMax__18ExtraWalletCounterFv = .text:0x8016E280; // type:function size:0x8
__sinit_\extra_wallet_counter_cpp = .text:0x8016E290; // type:function size:0x8 scope:local
fn_8016E2A0 = .text:0x8016E2A0; // type:function size:0x6C
fn_8016E310 = .text:0x8016E310; // type:function size:0x194
fn_8016E4B0 = .text:0x8016E4B0; // type:function size:0x1C
@@ -28352,7 +28352,7 @@ lbl_804E8D18 = .rodata:0x804E8D18; // type:object size:0x10
lbl_804E8D28 = .rodata:0x804E8D28; // type:object size:0x48 data:4byte
lbl_804E8D70 = .rodata:0x804E8D70; // type:object size:0x40 data:4byte
lbl_804E8DB0 = .rodata:0x804E8DB0; // type:object size:0x400
lbl_804E91B0 = .rodata:0x804E91B0; // type:object size:0x20 data:4byte
wallet_definitions = .rodata:0x804E91B0; // type:object size:0x20 scope:local data:4byte
lbl_804E91D0 = .rodata:0x804E91D0; // type:object size:0xA8
lbl_804E9278 = .rodata:0x804E9278; // type:object size:0xA0
lbl_804E9318 = .rodata:0x804E9318; // type:object size:0xA8
@@ -33327,13 +33327,13 @@ lbl_80527F70 = .data:0x80527F70; // type:object size:0x20
lbl_80527F90 = .data:0x80527F90; // type:object size:0x20
lbl_80527FB0 = .data:0x80527FB0; // type:object size:0x20
lbl_80527FD0 = .data:0x80527FD0; // type:object size:0x20
lbl_80527FF0 = .data:0x80527FF0; // type:object size:0x20
lbl_80528010 = .data:0x80528010; // type:object size:0x20
lbl_80528030 = .data:0x80528030; // type:object size:0x20
lbl_80528050 = .data:0x80528050; // type:object size:0x20
lbl_80528070 = .data:0x80528070; // type:object size:0x20
lbl_80528090 = .data:0x80528090; // type:object size:0x20
lbl_805280B0 = .data:0x805280B0; // type:object size:0x20
__vt__12RupeeCounter = .data:0x80527FF0; // type:object size:0x20
__vt__12ArrowCounter = .data:0x80528010; // type:object size:0x20
__vt__11BombCounter = .data:0x80528030; // type:object size:0x20
__vt__11TearCounter = .data:0x80528050; // type:object size:0x20
__vt__20SlingshotSeedCounter = .data:0x80528070; // type:object size:0x20
__vt__15KeyPieceCounter = .data:0x80528090; // type:object size:0x20
__vt__18ExtraWalletCounter = .data:0x805280B0; // type:object size:0x20
lbl_805280D0 = .data:0x805280D0; // type:object size:0xC
lbl_805280DC = .data:0x805280DC; // type:object size:0xC
lbl_805280E8 = .data:0x805280E8; // type:object size:0x10
+7
View File
@@ -285,6 +285,13 @@ config.libs = [
Object(NonMatching, "d/a/d_a_base.cpp"),
Object(NonMatching, "d/a/obj/d_a_obj_base.cpp"),
Object(Matching, "toBeSorted/save_file.cpp"),
Object(Matching, "toBeSorted/counters/rupee_counter.cpp"),
Object(Matching, "toBeSorted/counters/arrow_counter.cpp"),
Object(Matching, "toBeSorted/counters/bomb_counter.cpp"),
Object(Matching, "toBeSorted/counters/tear_counter.cpp"),
Object(Matching, "toBeSorted/counters/slingshot_seed_counter.cpp"),
Object(Matching, "toBeSorted/counters/key_piece_counter.cpp"),
Object(Matching, "toBeSorted/counters/extra_wallet_counter.cpp"),
Object(NonMatching, "toBeSorted/file_manager.cpp"),
Object(NonMatching, "toBeSorted/save_manager.cpp"),
Object(NonMatching, "f/f_base.cpp"),
+43
View File
@@ -0,0 +1,43 @@
#ifndef COUNTER_H
#define COUNTER_H
#include <common.h>
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 u16 getMax() = 0;
virtual u16 getUncommittedValue() {
return 0;
}
virtual void setValue(u16 num) {
return;
}
u16 counterId;
};
#endif COUNTER_H
+15
View File
@@ -0,0 +1,15 @@
#include <toBeSorted/counters/counter.h>
class ArrowCounter : public Counter {
public:
ArrowCounter();
/* 8016DFA0 */ ~ArrowCounter() {}
virtual u16 getMax() override;
};
/* 80575618 */ ArrowCounter lbl_80575618;
/* 8016DFE0 */ ArrowCounter::ArrowCounter() : Counter(0x1f2) {}
/* 8016E000 */ u16 ArrowCounter::getMax() {
return 20;
}
+15
View File
@@ -0,0 +1,15 @@
#include <toBeSorted/counters/counter.h>
class BombCounter : public Counter {
public:
BombCounter();
/* 8016E020 */ ~BombCounter() {}
virtual u16 getMax() override;
};
/* 80575620 */ BombCounter lbl_80575620;
/* 8016E060 */ BombCounter::BombCounter(): Counter(0x1f3) { }
/* 8016E080 */ u16 BombCounter::getMax() {
return 10;
}
@@ -0,0 +1,16 @@
#include <toBeSorted/counters/counter.h>
class ExtraWalletCounter : public Counter {
public:
ExtraWalletCounter();
/* 8016E220 */ ~ExtraWalletCounter() {}
virtual u16 getMax() override;
};
/* 80575640 */ ExtraWalletCounter lbl_80575640;
/* 8016E260 */ ExtraWalletCounter::ExtraWalletCounter(): Counter(0x1fc) { }
/* 8016E280 */ u16 ExtraWalletCounter::getMax() {
return 3;
}
@@ -0,0 +1,15 @@
#include <toBeSorted/counters/counter.h>
class KeyPieceCounter : public Counter {
public:
KeyPieceCounter();
/* 8016E1A0 */ ~KeyPieceCounter() {}
virtual u16 getMax() override;
};
/* 80575638 */ KeyPieceCounter lbl_80575638;
/* 8016E1E0 */ KeyPieceCounter::KeyPieceCounter() : Counter(0x1f9) {}
/* 8016E200 */ u16 KeyPieceCounter::getMax() {
return 5;
}
+52
View File
@@ -0,0 +1,52 @@
#include <toBeSorted/counters/counter.h>
class RupeeCounter : public Counter {
public:
RupeeCounter();
/* 8016DEF0 */ ~RupeeCounter() {}
virtual u16 getMax() override;
};
struct WalletStruct {
u32 flag;
u16 capacity;
};
/* 804E91B0 */
const struct WalletStruct wallet_definitions[4] = {
{0x6c, 500},
{0x6d, 1000},
{0x6e, 5000},
{0x6f, 9000},
};
// TODO set up item flag manager
extern "C" void *lbl_80575400;
extern "C" u16 fn_800BF5E0(void *data, u16 flag);
/* 8016DE10 */ u16 getBaseCapacity() {
int i = 0;
WalletStruct tmp[4] = {wallet_definitions[0], wallet_definitions[1], wallet_definitions[2], wallet_definitions[3]};
const WalletStruct *wallet = &tmp[3];
for (; i < 4; i++, wallet--) {
if (fn_800BF5E0(lbl_80575400, wallet->flag)) {
return wallet->capacity;
}
}
return 300;
}
// TODO main counters class
extern "C" u16 fn_8016D730(u16);
/* 8016DEC0 */ u16 getExtraWalletCapacity() {
return 300 * fn_8016D730(0x27);
}
/* 80575610 */ RupeeCounter lbl_80575610;
/* 8016DF30 */ RupeeCounter::RupeeCounter() : Counter(0x1f5) {}
/* 8016DF50 */ u16 RupeeCounter::getMax() {
return (getBaseCapacity() + getExtraWalletCapacity());
}
@@ -0,0 +1,15 @@
#include <toBeSorted/counters/counter.h>
class SlingshotSeedCounter : public Counter {
public:
SlingshotSeedCounter();
/* 8016E120 */ ~SlingshotSeedCounter() {}
virtual u16 getMax() override;
};
/* 80575630 */ SlingshotSeedCounter lbl_80575630;
/* 8016E160 */ SlingshotSeedCounter::SlingshotSeedCounter() : Counter(0x1ed) {}
/* 8016E180 */ u16 SlingshotSeedCounter::getMax() {
return 20;
}
+15
View File
@@ -0,0 +1,15 @@
#include <toBeSorted/counters/counter.h>
class TearCounter : public Counter {
public:
TearCounter();
/* 8016E0A0 */ ~TearCounter() {}
virtual u16 getMax() override;
};
/* 80575628 */ TearCounter lbl_80575628;
/* 8016E0E0 */ TearCounter::TearCounter(): Counter(0x1f4) { }
/* 8016E100 */ u16 TearCounter::getMax() {
return 15;
}