yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
oracle_progression.cc
Go to the documentation of this file.
2
3namespace yaze::core {
4
6 const uint8_t* data, size_t len) {
8 if (!data) return state;
9
10 auto read = [&](uint16_t offset) -> uint8_t {
11 return (offset < len) ? data[offset] : 0;
12 };
13
14 state.crystal_bitfield = read(kCrystalOffset);
15 state.game_state = read(kGameStateOffset);
16 state.oosprog = read(kOosProgOffset);
17 state.oosprog2 = read(kOosProg2Offset);
18 state.side_quest = read(kSideQuestOffset);
19 state.pendants = read(kPendantOffset);
20
21 return state;
22}
23
25 // Only count the 7 valid crystal bits (mask off bit 7)
26 uint8_t valid = crystal_bitfield & 0x7F;
27 int count = 0;
28 while (valid) {
29 count += (valid & 1);
30 valid >>= 1;
31 }
32 return count;
33}
34
35bool OracleProgressionState::IsDungeonComplete(int dungeon_number) const {
36 uint8_t mask = GetCrystalMask(dungeon_number);
37 return mask != 0 && (crystal_bitfield & mask) != 0;
38}
39
41 switch (game_state) {
42 case 0:
43 return "Start";
44 case 1:
45 return "Loom Beach";
46 case 2:
47 return "Kydrog Complete";
48 case 3:
49 return "Farore Rescued";
50 default:
51 return "Unknown (" + std::to_string(game_state) + ")";
52 }
53}
54
55std::string OracleProgressionState::GetDungeonName(int dungeon_number) {
56 switch (dungeon_number) {
57 case 1:
58 return "D1 Mushroom Grotto";
59 case 2:
60 return "D2 Tail Palace";
61 case 3:
62 return "D3 Kalyxo Castle";
63 case 4:
64 return "D4 Zora Temple";
65 case 5:
66 return "D5 Glacia Estate";
67 case 6:
68 return "D6 Goron Mines";
69 case 7:
70 return "D7 Dragon Ship";
71 default:
72 return "Unknown Dungeon";
73 }
74}
75
76uint8_t OracleProgressionState::GetCrystalMask(int dungeon_number) {
77 // Non-sequential mapping (intentional for non-linear design)
78 switch (dungeon_number) {
79 case 1:
80 return kCrystalD1; // 0x01
81 case 2:
82 return kCrystalD2; // 0x10
83 case 3:
84 return kCrystalD3; // 0x40
85 case 4:
86 return kCrystalD4; // 0x20
87 case 5:
88 return kCrystalD5; // 0x04
89 case 6:
90 return kCrystalD6; // 0x02
91 case 7:
92 return kCrystalD7; // 0x08
93 default:
94 return 0;
95 }
96}
97
98} // namespace yaze::core
Oracle of Secrets game progression state parsed from SRAM.
static constexpr uint8_t kCrystalD3
static constexpr uint8_t kCrystalD5
static constexpr uint16_t kSideQuestOffset
static uint8_t GetCrystalMask(int dungeon_number)
Get the crystal bitmask for a dungeon number (1-7).
static constexpr uint16_t kPendantOffset
static OracleProgressionState ParseFromSRAM(const uint8_t *data, size_t len)
Parse progression state from raw SRAM data.
static constexpr uint16_t kGameStateOffset
int GetCrystalCount() const
Count completed dungeons using popcount on crystal bitfield.
static constexpr uint8_t kCrystalD1
static constexpr uint16_t kOosProgOffset
bool IsDungeonComplete(int dungeon_number) const
Check if a specific dungeon is complete.
static constexpr uint8_t kCrystalD6
static constexpr uint8_t kCrystalD2
static std::string GetDungeonName(int dungeon_number)
Get the dungeon name for a dungeon number (1-7).
static constexpr uint16_t kOosProg2Offset
std::string GetGameStateName() const
Get human-readable name for the current game state.
static constexpr uint16_t kCrystalOffset
static constexpr uint8_t kCrystalD7
static constexpr uint8_t kCrystalD4