Skip to content

Commit a7cee9f

Browse files
Handle the Movement thing a bit different.
1 parent 5670c66 commit a7cee9f

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

include/gba/GBASlot.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
class GBASlot {
3838
public:
39-
GBASlot(const uint8_t Slot, const uint8_t AddOffs = 0) : Move(AddOffs), Slot(Slot), Offs(Slot * 0x1000) { };
39+
GBASlot(const uint8_t Slot) : Slot(Slot), Offs(Slot * 0x1000) { };
4040

4141
uint16_t Time() const;
4242
void Time(const uint16_t V);
@@ -108,12 +108,10 @@ class GBASlot {
108108

109109
bool FixChecksum();
110110
private:
111-
uint8_t Move = 0;
112111
uint8_t Slot = 0;
113112
uint32_t Offs = 0;
114113

115-
/* The House Item Amount seems to affect some stuff and move things around for 0x6 per Item. */
116-
uint32_t Offset(const uint32_t DefaultOffs = 0x0) const { return this->Offs + DefaultOffs + (this->Move * 0x6); };
114+
uint32_t Offset(const uint32_t DefaultOffs = 0x0) const;
117115

118116
/* This contains all official Episode Values found at offset (Slot * 0x1000) + 0x1A9. */
119117
static constexpr uint8_t EPVals[12] = {

source/gba/GBAHouseItem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ void GBAHouseItem::Direction(const uint8_t Index, const GBAHouseItemDirection V)
142142
/*
143143
Add an Item to the House.
144144
This needs to be handled like this, because things move 0x6 bytes up when an Item is being added.
145+
146+
NOTE: The game seems to handle it the other way than this, by doing an insert or something at the 0xD7'th byte, but this way works too.
145147
*/
146148
bool GBAHouseItem::AddItem(const uint8_t ID, const uint8_t Flag, const uint8_t UseCount, const uint8_t XPos, const uint8_t YPos, const GBAHouseItemDirection Direction) {
147149
if (this->Count() == 0xC) return false; // Not allowed to add more than 0xC / 12 Items.

source/gba/GBASav.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ bool GBASAV::SlotExist(const uint8_t Slot) {
7575
std::unique_ptr<GBASlot> GBASAV::Slot(const uint8_t Slot) {
7676
if (!this->SlotExist(Slot)) return nullptr;
7777

78-
/*
79-
The second parameter are the Item count inside the House.
80-
This seems to affect things after the House Items to move for 0x6 per House Item.
81-
Max Count seems to be 0xC, sooo.. `DefaultOffs + (0xC * 0x6)` which is 0x48 / 72.
82-
*/
83-
return std::make_unique<GBASlot>(Slot, this->SAVData.get()[(Slot * 0x1000) + 0xD6]);
78+
return std::make_unique<GBASlot>(Slot);
8479
};
8580

8681
/* Get a Settings class. */

source/gba/GBASlot.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
#include "../shared/Checksum.hpp"
2929
#include "../shared/SAVUtils.hpp"
3030

31+
/*
32+
The House Item Amount seems to affect some stuff and move things around for 0x6 per Item.
33+
So, we get the Item Count of the House from the 0xD6'th Byte from the GBASlot.
34+
35+
const uint32_t DefaultOffs: The Default Offset, for things without an Item in your house.
36+
*/
37+
uint32_t GBASlot::Offset(const uint32_t DefaultOffs) const { return this->Offs + DefaultOffs + (GBASAVUtils::Read<uint8_t>(this->Offs + 0xD6) * 0x6); };
38+
39+
3140
/* Get and Set Time. */
3241
uint16_t GBASlot::Time() const { return GBASAVUtils::Read<uint16_t>(this->Offs + 0x2); };
3342
void GBASlot::Time(const uint16_t V) { GBASAVUtils::Write<uint16_t>(this->Offs + 0x2, V); };
@@ -142,7 +151,7 @@ void GBASlot::CurrentEpisode(const uint8_t V, const bool ValidCheck) {
142151
};
143152

144153
/* Get an Episode class. */
145-
std::unique_ptr<GBAEpisode> GBASlot::Episode(const uint8_t EP) const { return std::make_unique<GBAEpisode>(this->Slot, EP, this->Move); };
154+
std::unique_ptr<GBAEpisode> GBASlot::Episode(const uint8_t EP) const { return std::make_unique<GBAEpisode>(this->Slot, EP, GBASAVUtils::Read<uint8_t>(this->Offs + 0xD6)); };
146155

147156
/* Get a Cast class. */
148157
std::unique_ptr<GBACast> GBASlot::Cast(const uint8_t CST) const {

0 commit comments

Comments
 (0)