yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
object_dimensions.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_DUNGEON_OBJECT_DIMENSIONS_H
2#define YAZE_ZELDA3_DUNGEON_OBJECT_DIMENSIONS_H
3
4#include <cstdint>
5#include <tuple>
6#include <unordered_map>
7#include <utility>
8
9#include "absl/status/status.h"
10#include "rom/rom.h"
11
12namespace yaze {
13namespace zelda3 {
14
15struct RoomObject;
16
30 public:
31 static ObjectDimensionTable& Get();
32
33 // Load dimension data from ROM
34 absl::Status LoadFromRom(Rom* rom);
35
36 // Get base dimensions for an object (without size extension)
37 std::pair<int, int> GetBaseDimensions(int object_id) const;
38
39 // Get full dimensions accounting for size parameter
40 std::pair<int, int> GetDimensions(int object_id, int size) const;
41
42 // Get dimensions for selection bounds (without size=0 inflation)
43 // This version caps the size and doesn't use 32-when-zero for display
44 std::pair<int, int> GetSelectionDimensions(int object_id, int size) const;
45
46 // Get hit-test bounds in tile coordinates (x, y, width, height)
47 std::tuple<int, int, int, int> GetHitTestBounds(const RoomObject& obj) const;
48
49 // Check if loaded
50 bool IsLoaded() const { return loaded_; }
51
52 // Reset state (for testing)
53 void Reset() {
54 dimensions_.clear();
55 loaded_ = false;
56 }
57
58 private:
60
61 // Dimension entry: base width/height and extension direction
63 int base_width = 1; // Base width in tiles
64 int base_height = 1; // Base height in tiles
66 int extend_multiplier = 1; // Tiles added per size unit
67 bool use_32_when_zero = false; // ASM: GetSize_1to15or32 uses 32 when size=0
68 };
69
70 // Object ID -> dimension entry
71 std::unordered_map<int, DimensionEntry> dimensions_;
72 bool loaded_ = false;
73
74 // Initialize default dimensions based on draw routine patterns
75 void InitializeDefaults();
76
77 // Parse ROM tables for more accurate dimensions
78 void ParseSubtype1Tables(Rom* rom);
79 void ParseSubtype2Tables(Rom* rom);
80 void ParseSubtype3Tables(Rom* rom);
81};
82
83} // namespace zelda3
84} // namespace yaze
85
86#endif // YAZE_ZELDA3_DUNGEON_OBJECT_DIMENSIONS_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:24
ROM-based object dimension lookup table.
std::pair< int, int > GetBaseDimensions(int object_id) const
std::tuple< int, int, int, int > GetHitTestBounds(const RoomObject &obj) const
std::pair< int, int > GetDimensions(int object_id, int size) const
std::unordered_map< int, DimensionEntry > dimensions_
static ObjectDimensionTable & Get()
std::pair< int, int > GetSelectionDimensions(int object_id, int size) const
enum yaze::zelda3::ObjectDimensionTable::DimensionEntry::ExtendDir extend_dir