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"
12
13namespace yaze {
14namespace zelda3 {
15
33
46
64
69 int draw_routine_id; // Which drawing pattern to use (0-24)
70 int tile_count; // How many tiles this object has
71 bool is_horizontal; // Orientation
73 bool both_layers; // Draw to both BG1 and BG2
74 std::string routine_name; // Human-readable routine name
75
77 : draw_routine_id(0),
78 tile_count(1),
79 is_horizontal(true),
80 is_vertical(false),
81 both_layers(false),
82 routine_name("Unknown") {}
83};
84
93 uint32_t begin = 0;
94 uint32_t end = 0;
95
96 bool operator==(const ObjectTileReadRange&) const = default;
97};
98
106 public:
107 explicit ObjectParser(Rom* rom, const DungeonTilePatterns* patterns = nullptr)
108 : rom_(rom), patterns_(patterns) {}
109
116 absl::StatusOr<std::vector<gfx::TileInfo>> ParseObject(int16_t object_id);
117
125 absl::StatusOr<std::vector<ObjectTileReadRange>> ResolveTileReadRanges(
126 int16_t object_id);
127
134 absl::StatusOr<ObjectRoutineInfo> ParseObjectRoutine(int16_t object_id);
135
142 absl::StatusOr<ObjectSubtypeInfo> GetObjectSubtype(int16_t object_id);
143
151 absl::StatusOr<ObjectSizeInfo> ParseObjectSize(int16_t object_id,
152 uint8_t size_byte);
153
157 int DetermineSubtype(int16_t object_id) const;
158
164 ObjectDrawInfo GetObjectDrawInfo(int16_t object_id) const;
165
166 private:
170 absl::StatusOr<std::vector<gfx::TileInfo>> ParseSubtype1(int16_t object_id);
171
175 absl::StatusOr<std::vector<gfx::TileInfo>> ParseSubtype2(int16_t object_id);
176
180 absl::StatusOr<std::vector<gfx::TileInfo>> ParseSubtype3(int16_t object_id);
181
189 absl::StatusOr<std::vector<gfx::TileInfo>> ReadTileData(int address,
190 int tile_count);
191
203 int GetSubtype2TileCount(int16_t object_id) const;
204
223 int GetSubtype3TileCount(int16_t object_id) const;
224
225 // Resolve tile count for any object ID using subtype-specific tables.
226 int ResolveTileCountForObject(int16_t object_id) const;
227
230 std::vector<ObjectTileReadRange>* tile_read_range_collector_ = nullptr;
231};
232
233} // namespace zelda3
234} // namespace yaze
235
236#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:49
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)
const DungeonTilePatterns * patterns_
ObjectParser(Rom *rom, const DungeonTilePatterns *patterns=nullptr)
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