Skip to content

Commit eb53666

Browse files
committed
Add Weather for ORAS
1 parent bdd0c82 commit eb53666

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Includes/Folders/Miscellaneous.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
using namespace CTRPluginFramework;
77

88
namespace Misc {
9+
void Weather(MenuEntry *entry);
10+
void WeatherKB(MenuEntry *entry);
11+
912
void IsRenamable(MenuEntry *entry);
1013
void LearnAnyTeachables(MenuEntry *entry);
1114
void GetDayCareEgg(MenuEntry *entry);

Sources/Folders/Miscellaneous.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@
55
using namespace CTRPluginFramework;
66

77
namespace Misc {
8+
static int weatherLocation, weatherToggle;
9+
10+
void WeatherKB(MenuEntry *entry) {
11+
static const vector<string> options = {"Route 113", "Route 119", "Route 120", "Jagged Pass", "East Hoenn"};
12+
static const vector<string> conditions = {"Snow", "Rain", "Rain", "Snow", Helpers::PickGame("Extremely Harsh Sunlight", "Heavy Rain")};
13+
KeyboardPlus keyboard;
14+
15+
if (keyboard.SetKeyboard(entry->Name() + ":", true, options, weatherLocation) != -1) {
16+
if (keyboard.SetKeyboard(conditions[weatherLocation] + ":", true, {"On", "Off"}, weatherToggle) != -1)
17+
Message::Completed();
18+
}
19+
}
20+
21+
static const vector<int> weatherFlags = {1, 4, 1, 1, Helpers::PickGame(2, 4)};
22+
23+
void Weather(MenuEntry *entry) {
24+
static const vector<vector<u32>> address = {{Helpers::PickGame<u32>(0x3FE54C, 0x3FE544)}, {0x8C81B56, 0x8C81B5E, 0x8C81B58, 0x8C81F37, 0x8C81B5A}};
25+
static u32 original;
26+
static bool saved = false;
27+
28+
if (ProcessPlus::Write32(address[0][0], 0xE320F000, original, entry, saved)) {
29+
if (Bit::Read8(address[1][weatherLocation], data8, true) && data8 != (weatherToggle == 0 ? weatherFlags[weatherLocation] : 0))
30+
if (!Bit::Write8(address[1][weatherLocation], (weatherToggle == 0 ? weatherFlags[weatherLocation] : 0), true))
31+
return;
32+
}
33+
}
34+
835
void IsRenamable(MenuEntry *entry) {
936
static const u32 address = Helpers::AutoRegion(Helpers::GetVersion(0x4B1680, Helpers::PickGame(0x4EA990, 0x4EA998)), Helpers::GetVersion(0x4AA2C0, 0x4C6F64));
1037
static u32 original;

0 commit comments

Comments
 (0)