yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
object_drawer.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_DUNGEON_OBJECT_DRAWER_H
2#define YAZE_APP_ZELDA3_DUNGEON_OBJECT_DRAWER_H
3
4#include <vector>
5#include <unordered_map>
6#include <functional>
7
8#include "absl/status/status.h"
10#include "app/gfx/snes_tile.h"
12#include "app/rom.h"
14
15namespace yaze {
16namespace zelda3 {
17
33 public:
34 explicit ObjectDrawer(Rom* rom, const uint8_t* room_gfx_buffer = nullptr);
35
44 absl::Status DrawObject(const RoomObject& object,
47 const gfx::PaletteGroup& palette_group);
48
57 absl::Status DrawObjectList(const std::vector<RoomObject>& objects,
60 const gfx::PaletteGroup& palette_group);
61
67 int GetDrawRoutineId(int16_t object_id) const;
68
74
83 void DrawTileToBitmap(gfx::Bitmap& bitmap, const gfx::TileInfo& tile_info,
84 int pixel_x, int pixel_y, const uint8_t* tiledata);
85
86 private:
87 // Draw routine function type
88 using DrawRoutine = std::function<void(ObjectDrawer*, const RoomObject&, gfx::BackgroundBuffer&,
89 std::span<const gfx::TileInfo>)>;
90
91 // Core draw routines (based on ZScream's subtype1_routines table)
93 std::span<const gfx::TileInfo> tiles);
95 std::span<const gfx::TileInfo> tiles);
97 std::span<const gfx::TileInfo> tiles);
99 std::span<const gfx::TileInfo> tiles);
101 std::span<const gfx::TileInfo> tiles);
103 std::span<const gfx::TileInfo> tiles);
105 std::span<const gfx::TileInfo> tiles);
107 std::span<const gfx::TileInfo> tiles);
109 std::span<const gfx::TileInfo> tiles);
111 std::span<const gfx::TileInfo> tiles);
113 std::span<const gfx::TileInfo> tiles);
115 std::span<const gfx::TileInfo> tiles);
117 std::span<const gfx::TileInfo> tiles);
119 std::span<const gfx::TileInfo> tiles);
120 void CustomDraw(const RoomObject& obj, gfx::BackgroundBuffer& bg,
121 std::span<const gfx::TileInfo> tiles);
123 std::span<const gfx::TileInfo> tiles);
125 std::span<const gfx::TileInfo> tiles);
127 std::span<const gfx::TileInfo> tiles);
129 std::span<const gfx::TileInfo> tiles);
131 std::span<const gfx::TileInfo> tiles);
133 std::span<const gfx::TileInfo> tiles);
135 std::span<const gfx::TileInfo> tiles);
137 std::span<const gfx::TileInfo> tiles);
139 std::span<const gfx::TileInfo> tiles);
140
141 // Downwards draw routines (missing implementation)
143 std::span<const gfx::TileInfo> tiles);
145 std::span<const gfx::TileInfo> tiles);
147 std::span<const gfx::TileInfo> tiles);
149 std::span<const gfx::TileInfo> tiles);
151 std::span<const gfx::TileInfo> tiles);
153 std::span<const gfx::TileInfo> tiles);
155 std::span<const gfx::TileInfo> tiles);
157 std::span<const gfx::TileInfo> tiles);
159 std::span<const gfx::TileInfo> tiles);
160
161 // Utility methods
162 void WriteTile8(gfx::BackgroundBuffer& bg, int tile_x, int tile_y,
163 const gfx::TileInfo& tile_info);
164 bool IsValidTilePosition(int tile_x, int tile_y) const;
165
166 // Draw routine registry
167 std::unordered_map<int16_t, int> object_to_routine_map_;
168 std::vector<DrawRoutine> draw_routines_;
170
172 const uint8_t* room_gfx_buffer_; // Room-specific graphics buffer (current_gfx16_)
173
174 // Canvas dimensions in tiles (64x64 = 512x512 pixels)
175 static constexpr int kMaxTilesX = 64;
176 static constexpr int kMaxTilesY = 64;
177};
178
179} // namespace zelda3
180} // namespace yaze
181
182#endif // YAZE_APP_ZELDA3_DUNGEON_OBJECT_DRAWER_H
183
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:66
SNES 16-bit tile metadata container.
Definition snes_tile.h:50
Draws dungeon objects to background buffers using game patterns.
int GetDrawRoutineId(int16_t object_id) const
Get draw routine ID for an object.
void WriteTile8(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, const gfx::TileInfo &tile_info)
void DrawRightwardsPillar2x4spaced4_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawTileToBitmap(gfx::Bitmap &bitmap, const gfx::TileInfo &tile_info, int pixel_x, int pixel_y, const uint8_t *tiledata)
Draw a single tile directly to bitmap.
void InitializeDrawRoutines()
Initialize draw routine registry Must be called before drawing objects.
void DrawDiagonalAcute_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwards2x4spaced4_1to16_BothBG(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
std::vector< DrawRoutine > draw_routines_
void DrawDownwardsRightCorners2x1_1to16_plus12(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDownwardsLeftCorners2x1_1to16_plus12(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwards2x4_1to15or26(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwards4x4_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDiagonalGrave_1to16_BothBG(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwardsHasEdge1x1_1to16_plus2(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwardsHasEdge1x1_1to16_plus3(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
absl::Status DrawObjectList(const std::vector< RoomObject > &objects, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, const gfx::PaletteGroup &palette_group)
Draw all objects in a room.
const uint8_t * room_gfx_buffer_
void DrawRightwards1x2_1to16_plus2(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDownwardsDecor4x2spaced4_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDownwardsEdge1x1_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
absl::Status DrawObject(const RoomObject &object, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, const gfx::PaletteGroup &palette_group)
Draw a room object to background buffers.
void DrawRightwards2x2_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDiagonalAcute_1to16_BothBG(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwards1x1Solid_1to16_plus3(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwards2x2_1to15or32(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDownwardsHasEdge1x1_1to16_plus3(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
std::unordered_map< int16_t, int > object_to_routine_map_
void DrawDoorSwitcherer(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
static constexpr int kMaxTilesX
void DrawRightwardsStatue2x3spaced2_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDownwards4x2_1to16_BothBG(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwardsBottomCorners1x2_1to16_plus13(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDiagonalGrave_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwards2x4spaced4_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwardsDecor4x4spaced2_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwardsDecor2x2spaced12_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawDownwards2x2_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
static constexpr int kMaxTilesY
void DrawDownwards2x2_1to15or32(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwardsDecor4x3spaced4_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void CustomDraw(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
bool IsValidTilePosition(int tile_x, int tile_y) const
void DrawDownwards4x2_1to15or26(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
void DrawRightwardsTopCorners1x2_1to16_plus13(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
std::function< void(ObjectDrawer *, const RoomObject &, gfx::BackgroundBuffer &, std::span< const gfx::TileInfo >)> DrawRoutine
void DrawRightwardsDoubled2x2spaced2_1to16(const RoomObject &obj, gfx::BackgroundBuffer &bg, std::span< const gfx::TileInfo > tiles)
Main namespace for the application.
Represents a group of palettes.