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