1+ /*
2+ * This file is part of Sim2Editor-CPPCore
3+ * Copyright (C) 2020-2021 SuperSaiyajinStackZ, Universal-Team
4+ *
5+ * This program is free software: you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License as published by
7+ * the Free Software Foundation, either version 3 of the License, or
8+ * (at your option) any later version.
9+ *
10+ * This program is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU General Public License
16+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17+ *
18+ * Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19+ * * Requiring preservation of specified reasonable legal notices or
20+ * author attributions in that material or in the Appropriate Legal
21+ * Notices displayed by works containing it.
22+ * * Prohibiting misrepresentation of the origin of that material,
23+ * or requiring that modified versions of such material be marked in
24+ * reasonable ways as different from the original version.
25+ */
26+
27+ #include " GBASettings.hpp"
28+ #include " ../shared/Checksum.hpp"
29+ #include " ../shared/SAVUtils.hpp"
30+
31+ /* Get and Set the Sound Effect Volume. */
32+ uint8_t GBASettings::SFX () const { return GBASAVUtils::Read<uint8_t >(0x8 ); };
33+ void GBASettings::SFX (const uint8_t V) {
34+ if (V > 10 ) return ; // 0 - 10 only valid.
35+ GBASAVUtils::Write<uint8_t >(0x8 , this ->SFXLevels [V]);
36+ };
37+
38+ /* Get and Set the Music Volume. */
39+ uint8_t GBASettings::Music () const { return GBASAVUtils::Read<uint8_t >(0x9 ); };
40+ void GBASettings::Music (const uint8_t V) {
41+ if (V > 10 ) return ; // 0 - 10 only valid.
42+ GBASAVUtils::Write<uint8_t >(0x9 , this ->MusicLevels [V]);
43+ };
44+
45+ /* Get and Set the Language. */
46+ GBALanguage GBASettings::Language () const {
47+ if (GBASAVUtils::Read<uint8_t >(0xA ) > 5 ) return GBALanguage::EN; // Technically, that would be a "blank" Language in game, but ehh that's not good.
48+ return (GBALanguage)GBASAVUtils::Read<uint8_t >(0xA );
49+ };
50+ void GBASettings::Language (const GBALanguage V) {
51+ GBASAVUtils::Write<uint8_t >(0xA , (uint8_t )V);
52+ };
53+
54+ /* Update the Checksum of the GBA Settings. */
55+ void GBASettings::UpdateChecksum () {
56+ if (!Checksum::GBASettingsValid (GBASAVUtils::SAV->GetData (), GBASAVUtils::Read<uint16_t >(0xE ))) { // Update if not valid.
57+ GBASAVUtils::Write<uint16_t >(0xE , Checksum::CalcGBASettings (GBASAVUtils::SAV->GetData ()));
58+ }
59+ };
0 commit comments