yaze 0.2.2
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 <array>
5#include <cstddef>
6#include <cstdint>
7#include <vector>
8
9#include "absl/status/status.h"
11#include "app/gfx/snes_tile.h"
12#include "app/rom.h"
13
14namespace yaze {
15namespace zelda3 {
16
17static constexpr int kTileOffsets[] = {0, 8, 4096, 4104};
18
19// 1 byte, not 0 if enabled
20constexpr int OverworldCustomASMHasBeenApplied = 0x140145;
21
22// 2 bytes for each overworld area (0x140)
23constexpr int OverworldCustomAreaSpecificBGPalette = 0x140000;
24
25// 1 byte, not 0 if enabled
26constexpr int OverworldCustomAreaSpecificBGEnabled = 0x140140;
27
28// 1 byte for each overworld area (0xA0)
29constexpr int OverworldCustomMainPaletteArray = 0x140160;
30// 1 byte, not 0 if enabled
31constexpr int OverworldCustomMainPaletteEnabled = 0x140141;
32
33// 1 byte for each overworld area (0xA0)
34constexpr int OverworldCustomMosaicArray = 0x140200;
35
36// 1 byte, not 0 if enabled
37constexpr int OverworldCustomMosaicEnabled = 0x140142;
38
39// 1 byte for each overworld area (0xA0)
40constexpr int OverworldCustomAnimatedGFXArray = 0x1402A0;
41
42// 1 byte, not 0 if enabled
43constexpr int OverworldCustomAnimatedGFXEnabled = 0x140143;
44
45// 2 bytes for each overworld area (0x140)
46constexpr int OverworldCustomSubscreenOverlayArray = 0x140340;
47
48// 1 byte, not 0 if enabled
50
51// 8 bytes for each overworld area (0x500)
52constexpr int OverworldCustomTileGFXGroupArray = 0x140480;
53
54// 1 byte, not 0 if enabled
55constexpr int OverworldCustomTileGFXGroupEnabled = 0x140148;
56
57constexpr int kDarkWorldMapIdStart = 0x40;
58constexpr int kSpecialWorldMapIdStart = 0x80;
59
63using OverworldBlockset = std::vector<std::vector<uint16_t>>;
64
73
78 public:
79 OverworldMap() = default;
80 OverworldMap(int index, Rom* rom);
81
82 absl::Status BuildMap(int count, int game_state, int world,
83 std::vector<gfx::Tile16>& tiles16,
84 OverworldBlockset& world_blockset);
85
86 void LoadAreaGraphics();
87 absl::Status LoadPalette();
88 absl::Status BuildTileset();
89 absl::Status BuildTiles16Gfx(std::vector<gfx::Tile16>& tiles16, int count);
90 absl::Status BuildBitmap(OverworldBlockset& world_blockset);
91
92 void DrawAnimatedTiles();
93
95 auto current_graphics() const { return current_gfx_; }
96 auto current_palette() const { return current_palette_; }
97 auto bitmap_data() const { return bitmap_data_; }
98 auto is_large_map() const { return large_map_; }
99 auto is_initialized() const { return initialized_; }
100 auto parent() const { return parent_; }
101 auto mutable_mosaic() { return &mosaic_; }
103
104 auto area_graphics() const { return area_graphics_; }
105 auto area_palette() const { return area_palette_; }
106 auto sprite_graphics(int i) const { return sprite_graphics_[i]; }
107 auto sprite_palette(int i) const { return sprite_palette_[i]; }
108 auto message_id() const { return message_id_; }
109 auto area_music(int i) const { return area_music_[i]; }
110 auto static_graphics(int i) const { return static_graphics_[i]; }
111 auto large_index() const { return large_index_; }
112
116 auto mutable_sprite_graphics(int i) { return &sprite_graphics_[i]; }
117 auto mutable_sprite_palette(int i) { return &sprite_palette_[i]; }
118 auto mutable_message_id() { return &message_id_; }
119 auto mutable_area_music(int i) { return &area_music_[i]; }
120 auto mutable_static_graphics(int i) { return &static_graphics_[i]; }
121
122 auto set_area_graphics(uint8_t value) { area_graphics_ = value; }
123 auto set_area_palette(uint8_t value) { area_palette_ = value; }
124 auto set_sprite_graphics(int i, uint8_t value) {
125 sprite_graphics_[i] = value;
126 }
127 auto set_sprite_palette(int i, uint8_t value) { sprite_palette_[i] = value; }
128 auto set_message_id(uint16_t value) { message_id_ = value; }
129
130 uint8_t* mutable_custom_tileset(int index) { return &custom_gfx_ids_[index]; }
131
132 void SetAsLargeMap(int parent_index, int quadrant) {
133 parent_ = parent_index;
134 large_index_ = quadrant;
135 large_map_ = true;
136 }
137
138 void SetAsSmallMap(int index = -1) {
139 if (index != -1)
140 parent_ = index;
141 else
142 parent_ = index_;
143 large_index_ = 0;
144 large_map_ = false;
145 }
146
147 void Destroy() {
148 current_blockset_.clear();
149 current_gfx_.clear();
150 bitmap_data_.clear();
151 map_tiles_.light_world.clear();
152 map_tiles_.dark_world.clear();
153 map_tiles_.special_world.clear();
154 built_ = false;
155 initialized_ = false;
156 large_map_ = false;
157 mosaic_ = false;
158 index_ = 0;
159 parent_ = 0;
160 large_index_ = 0;
161 world_ = 0;
162 game_state_ = 0;
163 main_gfx_id_ = 0;
164 message_id_ = 0;
165 area_graphics_ = 0;
166 area_palette_ = 0;
167 animated_gfx_ = 0;
169 }
170
171 private:
172 void LoadAreaInfo();
174 void SetupCustomTileset(uint8_t asm_version);
175
176 void LoadMainBlocksetId();
178 void LoadMainBlocksets();
181
182 void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size,
183 uint8_t* all_gfx);
184 absl::StatusOr<gfx::SnesPalette> GetPalette(const gfx::PaletteGroup& group,
185 int index, int previous_index,
186 int limit);
187
189
190 bool built_ = false;
191 bool large_map_ = false;
192 bool initialized_ = false;
193 bool mosaic_ = false;
194
195 int index_ = 0; // Map index
196 int parent_ = 0; // Parent map index
197 int large_index_ = 0; // Quadrant ID [0-3]
198 int world_ = 0; // World ID [0-2]
199 int game_state_ = 0; // Game state [0-2]
200 int main_gfx_id_ = 0; // Main Gfx ID
201
202 uint16_t message_id_ = 0;
203 uint8_t area_graphics_ = 0;
204 uint8_t area_palette_ = 0;
205 uint8_t animated_gfx_ = 0; // Custom Overworld Animated ID
206 uint16_t subscreen_overlay_ = 0; // Custom Overworld Subscreen Overlay ID
207
208 std::array<uint8_t, 8> custom_gfx_ids_;
209 std::array<uint8_t, 3> sprite_graphics_;
210 std::array<uint8_t, 3> sprite_palette_;
211 std::array<uint8_t, 4> area_music_;
212 std::array<uint8_t, 16> static_graphics_;
213
214 std::array<bool, 4> mosaic_expanded_;
215
216 std::vector<uint8_t> current_blockset_;
217 std::vector<uint8_t> current_gfx_;
218 std::vector<uint8_t> bitmap_data_;
219
222};
223
224} // namespace zelda3
225} // namespace yaze
226
227#endif
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:59
Shared graphical context across editors.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
auto set_area_palette(uint8_t value)
void SetAsLargeMap(int parent_index, int quadrant)
std::vector< uint8_t > current_gfx_
std::vector< uint8_t > current_blockset_
std::array< bool, 4 > mosaic_expanded_
std::vector< uint8_t > bitmap_data_
void SetAsSmallMap(int index=-1)
auto set_message_id(uint16_t value)
auto set_sprite_palette(int i, uint8_t value)
void SetupCustomTileset(uint8_t asm_version)
auto sprite_graphics(int i) const
absl::StatusOr< gfx::SnesPalette > GetPalette(const gfx::PaletteGroup &group, int index, int previous_index, int limit)
absl::Status BuildTiles16Gfx(std::vector< gfx::Tile16 > &tiles16, int count)
OverworldMapTiles map_tiles_
absl::Status BuildMap(int count, int game_state, int world, std::vector< gfx::Tile16 > &tiles16, OverworldBlockset &world_blockset)
std::array< uint8_t, 3 > sprite_graphics_
auto current_tile16_blockset() const
auto static_graphics(int i) const
auto area_music(int i) const
absl::Status BuildBitmap(OverworldBlockset &world_blockset)
std::array< uint8_t, 3 > sprite_palette_
std::array< uint8_t, 4 > area_music_
std::array< uint8_t, 16 > static_graphics_
std::array< uint8_t, 8 > custom_gfx_ids_
auto set_area_graphics(uint8_t value)
auto sprite_palette(int i) const
gfx::SnesPalette current_palette_
void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size, uint8_t *all_gfx)
uint8_t * mutable_custom_tileset(int index)
auto set_sprite_graphics(int i, uint8_t value)
Zelda 3 specific classes and functions.
constexpr int OverworldCustomTileGFXGroupEnabled
constexpr int OverworldCustomAreaSpecificBGEnabled
constexpr int kSpecialWorldMapIdStart
constexpr int OverworldCustomMosaicArray
constexpr int OverworldCustomAnimatedGFXEnabled
constexpr int OverworldCustomMainPaletteEnabled
constexpr int OverworldCustomMainPaletteArray
std::vector< std::vector< uint16_t > > OverworldBlockset
Represents tile32 data for the overworld.
constexpr int OverworldCustomASMHasBeenApplied
struct yaze::zelda3::OverworldMapTiles OverworldMapTiles
Overworld map tile32 data.
constexpr int OverworldCustomAnimatedGFXArray
constexpr int kDarkWorldMapIdStart
constexpr int OverworldCustomMosaicEnabled
constexpr int OverworldCustomTileGFXGroupArray
constexpr int OverworldCustomSubscreenOverlayEnabled
constexpr int OverworldCustomAreaSpecificBGPalette
constexpr int OverworldCustomSubscreenOverlayArray
Main namespace for the application.
Definition controller.cc:18
Represents a group of palettes.
Overworld map tile32 data.