yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
water_fill_zone.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_DUNGEON_WATER_FILL_ZONE_H
2#define YAZE_APP_ZELDA3_DUNGEON_WATER_FILL_ZONE_H
3
4#include <cstdint>
5#include <string>
6#include <vector>
7
8#include "absl/status/status.h"
9#include "absl/status/statusor.h"
10
11namespace yaze {
12class Rom;
13}
14
15namespace yaze::zelda3 {
16
18 int room_id = -1;
19 uint8_t sram_bit_mask = 0; // Bit in $7EF411 (e.g. 0x01)
20 std::vector<uint16_t> fill_offsets; // Each offset = Y*64 + X (0..4095)
21};
22
23// Load the editor-authored water fill table from the reserved ROM region.
24// Returns an empty list if the table is not present.
25absl::StatusOr<std::vector<WaterFillZoneEntry>> LoadWaterFillTable(Rom* rom);
26
27// Write the editor-authored water fill table into the reserved ROM region.
28// This overwrites the reserved region (kWaterFillTableStart..kWaterFillTableEnd)
29// and leaves collision data untouched.
30absl::Status WriteWaterFillTable(Rom* rom,
31 const std::vector<WaterFillZoneEntry>& zones);
32
33// Best-effort import of legacy WaterGate_* tables from an asar-generated .sym
34// file (WLA symbol format). This is intended as a one-time migration aid.
35//
36// Returns an empty list if the symbol file cannot be read or the symbols are
37// not present.
38absl::StatusOr<std::vector<WaterFillZoneEntry>> LoadLegacyWaterGateZones(
39 Rom* rom, const std::string& symbol_path);
40
41// JSON import/export helpers for authoring workflows.
42//
43// Format (v1):
44// {
45// "version": 1,
46// "zones": [
47// { "room_id": "0x25", "mask": "0x02", "offsets": [ 0, 1, 2 ] }
48// ]
49// }
50//
51// `mask` may be 0x00 ("Auto") or a single bit (0x01..0x80). Room IDs and masks
52// may also be provided as integers.
53absl::StatusOr<std::string> DumpWaterFillZonesToJsonString(
54 const std::vector<WaterFillZoneEntry>& zones);
55
56absl::StatusOr<std::vector<WaterFillZoneEntry>> LoadWaterFillZonesFromJsonString(
57 const std::string& json_content);
58
59// Assigns deterministic, unique SRAM bit masks (0x01..0x80) to all zones.
60//
61// Any zone with a mask of 0x00, an invalid (non-single-bit) mask, or a mask
62// duplicated by an earlier room will be treated as "unassigned" and receive
63// the next available free bit. Zones are processed in ascending room_id order
64// to keep results stable.
65//
66// Returns InvalidArgument if there are more than 8 zones. Returns
67// ResourceExhausted if no free bits are available.
69 std::vector<WaterFillZoneEntry>* zones);
70
71} // namespace yaze::zelda3
72
73#endif // YAZE_APP_ZELDA3_DUNGEON_WATER_FILL_ZONE_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Zelda 3 specific classes and functions.
absl::StatusOr< std::string > DumpWaterFillZonesToJsonString(const std::vector< WaterFillZoneEntry > &zones)
absl::Status NormalizeWaterFillZoneMasks(std::vector< WaterFillZoneEntry > *zones)
absl::StatusOr< std::vector< WaterFillZoneEntry > > LoadLegacyWaterGateZones(Rom *rom, const std::string &symbol_path)
absl::StatusOr< std::vector< WaterFillZoneEntry > > LoadWaterFillZonesFromJsonString(const std::string &json_content)
absl::StatusOr< std::vector< WaterFillZoneEntry > > LoadWaterFillTable(Rom *rom)
absl::Status WriteWaterFillTable(Rom *rom, const std::vector< WaterFillZoneEntry > &zones)
std::vector< uint16_t > fill_offsets