yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
overworld_map.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_OVERWORLD_MAP_H
2#define YAZE_APP_ZELDA3_OVERWORLD_MAP_H
3
4#include <cstddef>
5#include <cstdint>
6#include <memory>
7#include <unordered_map>
8#include <vector>
9
10#include "absl/status/status.h"
12#include "app/gfx/bitmap.h"
14#include "app/gfx/snes_tile.h"
15#include "app/rom.h"
16#include "app/zelda3/common.h"
17#include "imgui/imgui.h"
18
19namespace yaze {
20namespace app {
21namespace zelda3 {
22namespace overworld {
23
24static constexpr int kTileOffsets[] = {0, 8, 4096, 4104};
25
26// 1 byte, not 0 if enabled
27constexpr int OverworldCustomASMHasBeenApplied = 0x140145;
28
29// 2 bytes for each overworld area (0x140)
30constexpr int OverworldCustomAreaSpecificBGPalette = 0x140000;
31
32// 1 byte, not 0 if enabled
33constexpr int OverworldCustomAreaSpecificBGEnabled = 0x140140;
34
35// 1 byte for each overworld area (0xA0)
36constexpr int OverworldCustomMainPaletteArray = 0x140160;
37// 1 byte, not 0 if enabled
38constexpr int OverworldCustomMainPaletteEnabled = 0x140141;
39
40// 1 byte for each overworld area (0xA0)
41constexpr int OverworldCustomMosaicArray = 0x140200;
42
43// 1 byte, not 0 if enabled
44constexpr int OverworldCustomMosaicEnabled = 0x140142;
45
46// 1 byte for each overworld area (0xA0)
47constexpr int OverworldCustomAnimatedGFXArray = 0x1402A0;
48
49// 1 byte, not 0 if enabled
50constexpr int OverworldCustomAnimatedGFXEnabled = 0x140143;
51
52// 2 bytes for each overworld area (0x140)
53constexpr int OverworldCustomSubscreenOverlayArray = 0x140340;
54
55// 1 byte, not 0 if enabled
57
58// 8 bytes for each overworld area (0x500)
59constexpr int OverworldCustomTileGFXGroupArray = 0x140480;
60
61// 1 byte, not 0 if enabled
62constexpr int OverworldCustomTileGFXGroupEnabled = 0x140148;
63
68 public:
69 OverworldMap() = default;
70 OverworldMap(int index, Rom& rom, bool load_custom_data = false);
71
72 absl::Status BuildMap(int count, int game_state, int world,
73 std::vector<gfx::Tile16>& tiles16,
74 OWBlockset& world_blockset);
75
76 void LoadAreaGraphics();
77 absl::Status LoadPalette();
78 absl::Status BuildTileset();
79 absl::Status BuildTiles16Gfx(std::vector<gfx::Tile16>& tiles16, int count);
80 absl::Status BuildBitmap(OWBlockset& world_blockset);
81
82 void DrawAnimatedTiles();
83
85 auto current_graphics() const { return current_gfx_; }
86 auto current_palette() const { return current_palette_; }
87 auto bitmap_data() const { return bitmap_data_; }
88 auto is_large_map() const { return large_map_; }
89 auto is_initialized() const { return initialized_; }
90 auto parent() const { return parent_; }
91
92 auto mutable_mosaic() { return &mosaic_; }
93
95
96 auto area_graphics() const { return area_graphics_; }
97 auto area_palette() const { return area_palette_; }
98 auto sprite_graphics(int i) const { return sprite_graphics_[i]; }
99 auto sprite_palette(int i) const { return sprite_palette_[i]; }
100 auto message_id() const { return message_id_; }
101 auto area_music(int i) const { return area_music_[i]; }
102 auto static_graphics(int i) const { return static_graphics_[i]; }
103 auto large_index() const { return large_index_; }
104
107 auto mutable_sprite_graphics(int i) { return &sprite_graphics_[i]; }
108 auto mutable_sprite_palette(int i) { return &sprite_palette_[i]; }
109 auto mutable_message_id() { return &message_id_; }
110 auto mutable_area_music(int i) { return &area_music_[i]; }
111 auto mutable_static_graphics(int i) { return &static_graphics_[i]; }
112
113 auto set_area_graphics(uint8_t value) { area_graphics_ = value; }
114 auto set_area_palette(uint8_t value) { area_palette_ = value; }
115 auto set_sprite_graphics(int i, uint8_t value) {
116 sprite_graphics_[i] = value;
117 }
118 auto set_sprite_palette(int i, uint8_t value) { sprite_palette_[i] = value; }
119 auto set_message_id(uint16_t value) { message_id_ = value; }
120
121 uint8_t* mutable_custom_tileset(int index) { return &custom_gfx_ids_[index]; }
122
123 void SetAsLargeMap(int parent_index, int quadrant) {
124 parent_ = parent_index;
125 large_index_ = quadrant;
126 large_map_ = true;
127 }
128
129 void SetAsSmallMap(int index = -1) {
130 if (index != -1)
131 parent_ = index;
132 else
133 parent_ = index_;
134 large_index_ = 0;
135 large_map_ = false;
136 }
137
138 void Destroy() {
139 current_blockset_.clear();
140 current_gfx_.clear();
141 bitmap_data_.clear();
142 }
143
144 private:
145 void LoadAreaInfo();
147 void SetupCustomTileset(uint8_t asm_version);
148
149 void LoadMainBlocksetId();
151 void LoadMainBlocksets();
154
155 void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size);
156 absl::StatusOr<gfx::SnesPalette> GetPalette(const gfx::PaletteGroup& group,
157 int index, int previous_index,
158 int limit);
159
160 bool built_ = false;
161 bool large_map_ = false;
162 bool initialized_ = false;
163
164 bool mosaic_ = false;
165
166 int index_ = 0; // Map index
167 int parent_ = 0; // Parent map index
168 int large_index_ = 0; // Quadrant ID [0-3]
169 int world_ = 0; // World ID [0-2]
170 int game_state_ = 0; // Game state [0-2]
171 int main_gfx_id_ = 0; // Main Gfx ID
172
173 uint16_t message_id_ = 0;
174 uint8_t area_graphics_ = 0;
175 uint8_t area_palette_ = 0;
176 uint8_t animated_gfx_ = 0; // Custom Overworld Animated ID
177 uint16_t subscreen_overlay_ = 0; // Custom Overworld Subscreen Overlay ID
178
179 uint8_t custom_gfx_ids_[8];
184
186 std::vector<uint8_t> all_gfx_;
187 std::vector<uint8_t> current_blockset_;
188 std::vector<uint8_t> current_gfx_;
189 std::vector<uint8_t> bitmap_data_;
191
193};
194
195} // namespace overworld
196} // namespace zelda3
197} // namespace app
198} // namespace yaze
199
200#endif
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:145
Shared graphical context across editors.
Definition gfx_context.h:25
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Represents a single Overworld map screen.
absl::Status BuildTiles16Gfx(std::vector< gfx::Tile16 > &tiles16, int count)
void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size)
void SetupCustomTileset(uint8_t asm_version)
void SetAsLargeMap(int parent_index, int quadrant)
absl::StatusOr< gfx::SnesPalette > GetPalette(const gfx::PaletteGroup &group, int index, int previous_index, int limit)
auto set_sprite_graphics(int i, uint8_t value)
absl::Status BuildBitmap(OWBlockset &world_blockset)
absl::Status BuildMap(int count, int game_state, int world, std::vector< gfx::Tile16 > &tiles16, OWBlockset &world_blockset)
auto set_sprite_palette(int i, uint8_t value)
unsigned char uchar
Definition constants.h:121
constexpr int OverworldCustomAnimatedGFXArray
constexpr int OverworldCustomAreaSpecificBGEnabled
constexpr int OverworldCustomASMHasBeenApplied
constexpr int OverworldCustomMosaicEnabled
constexpr int OverworldCustomAnimatedGFXEnabled
constexpr int OverworldCustomAreaSpecificBGPalette
constexpr int OverworldCustomMainPaletteEnabled
constexpr int OverworldCustomSubscreenOverlayEnabled
constexpr int OverworldCustomTileGFXGroupArray
constexpr int OverworldCustomMosaicArray
constexpr int OverworldCustomTileGFXGroupEnabled
constexpr int OverworldCustomMainPaletteArray
constexpr int OverworldCustomSubscreenOverlayArray
std::vector< std::vector< uint16_t > > OWBlockset
Represents tile32 data for the overworld.
Definition common.h:15
Definition common.cc:21
Represents a group of palettes.
Overworld map tile32 data.
Definition common.h:20