yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
object_parser.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_DUNGEON_OBJECT_PARSER_H
2#define YAZE_APP_ZELDA3_DUNGEON_OBJECT_PARSER_H
3
4#include <cstdint>
5#include <vector>
6
7#include "absl/status/status.h"
8#include "absl/status/statusor.h"
10#include "rom/rom.h"
11
12namespace yaze {
13namespace zelda3 {
14
32
45
63
68 int draw_routine_id; // Which drawing pattern to use (0-24)
69 int tile_count; // How many tiles this object has
70 bool is_horizontal; // Orientation
72 bool both_layers; // Draw to both BG1 and BG2
73 std::string routine_name; // Human-readable routine name
74
76 : draw_routine_id(0),
77 tile_count(1),
78 is_horizontal(true),
79 is_vertical(false),
80 both_layers(false),
81 routine_name("Unknown") {}
82};
83
92 uint32_t begin = 0;
93 uint32_t end = 0;
94
95 bool operator==(const ObjectTileReadRange&) const = default;
96};
97
105 public:
106 explicit ObjectParser(Rom* rom) : rom_(rom) {}
107
114 absl::StatusOr<std::vector<gfx::TileInfo>> ParseObject(int16_t object_id);
115
123 absl::StatusOr<std::vector<ObjectTileReadRange>> ResolveTileReadRanges(
124 int16_t object_id);
125
132 absl::StatusOr<ObjectRoutineInfo> ParseObjectRoutine(int16_t object_id);
133
140 absl::StatusOr<ObjectSubtypeInfo> GetObjectSubtype(int16_t object_id);
141
149 absl::StatusOr<ObjectSizeInfo> ParseObjectSize(int16_t object_id,
150 uint8_t size_byte);
151
155 int DetermineSubtype(int16_t object_id) const;
156
162 ObjectDrawInfo GetObjectDrawInfo(int16_t object_id) const;
163
164 private:
168 absl::StatusOr<std::vector<gfx::TileInfo>> ParseSubtype1(int16_t object_id);
169
173 absl::StatusOr<std::vector<gfx::TileInfo>> ParseSubtype2(int16_t object_id);
174
178 absl::StatusOr<std::vector<gfx::TileInfo>> ParseSubtype3(int16_t object_id);
179
187 absl::StatusOr<std::vector<gfx::TileInfo>> ReadTileData(int address,
188 int tile_count);
189
201 int GetSubtype2TileCount(int16_t object_id) const;
202
221 int GetSubtype3TileCount(int16_t object_id) const;
222
223 // Resolve tile count for any object ID using subtype-specific tables.
224 int ResolveTileCountForObject(int16_t object_id) const;
225
227 std::vector<ObjectTileReadRange>* tile_read_range_collector_ = nullptr;
228};
229
230} // namespace zelda3
231} // namespace yaze
232
233#endif // YAZE_APP_ZELDA3_DUNGEON_OBJECT_PARSER_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
Direct ROM parser for dungeon objects.
absl::StatusOr< ObjectSubtypeInfo > GetObjectSubtype(int16_t object_id)
Get object subtype information.
absl::StatusOr< ObjectRoutineInfo > ParseObjectRoutine(int16_t object_id)
Parse object routine data.
absl::StatusOr< ObjectSizeInfo > ParseObjectSize(int16_t object_id, uint8_t size_byte)
Parse object size and orientation.
absl::StatusOr< std::vector< ObjectTileReadRange > > ResolveTileReadRanges(int16_t object_id)
Resolve every tile-data range consumed by ParseObject.
int GetSubtype3TileCount(int16_t object_id) const
Get tile count for subtype 3 objects.
std::vector< ObjectTileReadRange > * tile_read_range_collector_
absl::StatusOr< std::vector< gfx::TileInfo > > ParseSubtype2(int16_t object_id)
Parse subtype 2 objects (0x100-0x1FF)
absl::StatusOr< std::vector< gfx::TileInfo > > ParseObject(int16_t object_id)
Parse object data directly from ROM.
int GetSubtype2TileCount(int16_t object_id) const
Get tile count for subtype 2 objects.
absl::StatusOr< std::vector< gfx::TileInfo > > ParseSubtype1(int16_t object_id)
Parse subtype 1 objects (0x00-0xFF)
absl::StatusOr< std::vector< gfx::TileInfo > > ParseSubtype3(int16_t object_id)
Parse subtype 3 objects (0x200+)
absl::StatusOr< std::vector< gfx::TileInfo > > ReadTileData(int address, int tile_count)
Read tile data from ROM.
ObjectDrawInfo GetObjectDrawInfo(int16_t object_id) const
Get draw routine information for an object.
int ResolveTileCountForObject(int16_t object_id) const
int DetermineSubtype(int16_t object_id) const
Determine object subtype from ID.
Draw routine information for object rendering.
Object routine information.
Object size and orientation information.
Object subtype information.
One half-open PC range consumed while parsing an object's tile data.
bool operator==(const ObjectTileReadRange &) const =default