Skip to content

Commit 443d6f3

Browse files
[GBA]: The Chopper aka Bike Color editing.
Also remove useless `Slot` checks on the FixChecksum function.
1 parent 1786298 commit 443d6f3

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

include/gba/GBASlot.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ namespace S2Editor {
141141
bool WeirdnessPlot() const;
142142
void WeirdnessPlot(const bool V);
143143

144+
uint8_t TheChopperColor() const;
145+
void TheChopperColor(const uint8_t V);
146+
144147
/* Some class pointers. */
145148
std::unique_ptr<GBAEpisode> Episode(const uint8_t EP) const;
146149
std::unique_ptr<GBASocialMove> SocialMove(const uint8_t Move) const;

source/gba/GBASlot.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ namespace S2Editor {
258258
bool GBASlot::WeirdnessPlot() const { return GBASAVUtils::ReadBit(this->Offset(0x1CF), 0x5); };
259259
void GBASlot::WeirdnessPlot(const bool V) { GBASAVUtils::WriteBit(this->Offset(0x1CF), 0x5, V); };
260260

261+
/* Get and Set the Motorbike aka "The Chopper" color. */
262+
uint8_t GBASlot::TheChopperColor() const { return GBASAVUtils::ReadBits(this->Offset(0x1F2), true); };
263+
void GBASlot::TheChopperColor(const uint8_t V) { GBASAVUtils::WriteBits(this->Offset(0x1F2), true, std::min<uint8_t>(9, V)); };
264+
261265
/* Get an Episode class. */
262266
std::unique_ptr<GBAEpisode> GBASlot::Episode(const uint8_t EP) const {
263267
return std::make_unique<GBAEpisode>(this->Slot, EP, GBASAVUtils::Read<uint8_t>(this->Offs + 0xD6));
@@ -276,11 +280,9 @@ namespace S2Editor {
276280
/*
277281
Fix the Checksum of the current Slot, if invalid.
278282
279-
Returns false if Slot < 0 or > 4 or already valid, true if got fixed.
283+
Returns false if already valid, true if got fixed.
280284
*/
281285
bool GBASlot::FixChecksum() {
282-
if (this->Slot < 1 || this->Slot > 4) return false;
283-
284286
const uint16_t CurCHKS = GBASAVUtils::Read<uint16_t>(this->Offs + 0xFFE);
285287
const uint16_t Calced = Checksum::Calc(GBASAVUtils::SAV->GetData(), this->Offs / 2, (this->Offs + 0xFFE) / 2);
286288

source/nds/NDSSlot.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@ namespace S2Editor {
9393
/*
9494
Fix the Checksum of the current Slot, if invalid.
9595
96-
Returns false if Slot > 4 or already valid, true if got fixed.
96+
Returns false if already valid, true if got fixed.
9797
*/
9898
bool NDSSlot::FixChecksum() {
99-
if (this->Slot > 4) return false;
100-
10199
const uint16_t CurCHKS = NDSSAVUtils::Read<uint16_t>(this->Offs + 0x28);
102100
const std::vector<int> Offs = { ((int)this->Offs + 0x12) / 2, ((int)this->Offs + 0x28) / 2 };
103101
const uint16_t Calced = Checksum::Calc(NDSSAVUtils::SAV->GetData(), (this->Offs + 0x10) / 2, (this->Offs + 0x1000) / 2, Offs);

0 commit comments

Comments
 (0)