yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
offsets.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_FORMATS_OFFSETS_H
2#define YAZE_APP_ZELDA3_FORMATS_OFFSETS_H
3
4#include <cstddef>
5#include <cstdint>
6#include <optional>
7
8// Zelda 3 offsets extracted from hmagic (US ROM) with added safety checks.
9// Intended for parsing text/dungeon structures in yaze without pulling in
10// hmagic's unsafe global state.
11namespace yaze::zelda3::formats {
12
13enum class Region {
14 kUs = 0,
15 kEu,
16 kJp,
17};
18
20 uint32_t torches = 0;
21 uint32_t torch_count = 0;
22};
23
24struct TextCodes {
25 uint8_t zchar_base = 0;
26 uint8_t zchar_bound = 0;
27 uint8_t command_base = 0;
28 uint8_t command_bound = 0;
29 uint8_t msg_terminator = 0;
30 uint8_t region_switch = 0;
31 uint8_t dict_base = 0;
32 uint8_t dict_bound = 0;
33 uint8_t abs_terminator = 0;
34};
35
37 uint8_t bank = 0;
38 uint32_t dictionary = 0;
39 uint32_t dictionary_bound = 0;
40 uint32_t param_counts = 0;
41 uint32_t region1 = 0;
42 uint32_t region1_bound = 0;
43 uint32_t region2 = 0;
44 uint32_t region2_bound = 0;
45 uint32_t max_message_length = 0;
47};
48
50 // Placeholder for future additions; kept for parity with hmagic structs.
51 uint32_t dummy = 0;
52};
53
59
60// Returns offsets for a region if known; currently populated for US only.
61std::optional<RegionOffsets> GetRegionOffsets(Region region);
62
63// Simple bounds validation to avoid reading outside the ROM buffer.
64bool ValidateOffsets(const RegionOffsets& offsets, size_t rom_size_bytes);
65
66} // namespace yaze::zelda3::formats
67
68#endif // YAZE_APP_ZELDA3_FORMATS_OFFSETS_H
std::optional< RegionOffsets > GetRegionOffsets(Region region)
Definition offsets.cc:41
bool ValidateOffsets(const RegionOffsets &offsets, size_t rom_size_bytes)
Definition offsets.cc:50