yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
zelda3_labels.cc
Go to the documentation of this file.
2
3#include <cstddef>
4#include <string>
5#include <unordered_map>
6#include <vector>
7
8#include "zelda3/common.h"
13
14namespace yaze::zelda3 {
15
16// Room names - reuse existing kRoomNames array
17const std::vector<std::string>& Zelda3Labels::GetRoomNames() {
18 static std::vector<std::string> room_names;
19 if (room_names.empty()) {
20 for (const auto& name : kRoomNames) {
21 room_names.emplace_back(name);
22 }
23 }
24 return room_names;
25}
26
27// Entrance names - reuse existing kEntranceNames array
28const std::vector<std::string>& Zelda3Labels::GetEntranceNames() {
29 static std::vector<std::string> entrance_names;
30 if (entrance_names.empty()) {
31 for (const auto& name : kEntranceNames) {
32 entrance_names.emplace_back(name);
33 }
34 }
35 return entrance_names;
36}
37
38// Sprite names - reuse existing kSpriteDefaultNames array
39const std::vector<std::string>& Zelda3Labels::GetSpriteNames() {
40 static std::vector<std::string> sprite_names;
41 if (sprite_names.empty()) {
42 for (const auto& name : kSpriteDefaultNames) {
43 sprite_names.push_back(name);
44 }
45 }
46 return sprite_names;
47}
48
49// Overlord names - reuse existing kOverlordNames array
50const std::vector<std::string>& Zelda3Labels::GetOverlordNames() {
51 static std::vector<std::string> overlord_names;
52 if (overlord_names.empty()) {
53 for (const auto& name : kOverlordNames) {
54 overlord_names.push_back(name);
55 }
56 }
57 return overlord_names;
58}
59
60// Overworld map names (64 Light World + 64 Dark World + 32 Special Areas)
61const std::vector<std::string>& Zelda3Labels::GetOverworldMapNames() {
62 static const std::vector<std::string> map_names = {
63 // Light World (0x00-0x3F)
64 "Lost Woods", "Master Sword Pedestal", "Castle Courtyard", "Link's House",
65 "Eastern Palace", "Desert Palace", "Hyrule Castle", "Witch's Hut",
66 "Kakariko Village", "Death Mountain", "Tower of Hera", "Spectacle Rock",
67 "Graveyard", "Sanctuary", "Lake Hylia", "Desert of Mystery",
68 "Eastern Ruins", "Zora's Domain", "Catfish", "Dam", "Potion Shop",
69 "Kakariko Well", "Blacksmith", "Sick Kid", "Library", "Mushroom",
70 "Magic Bat", "Fairy Fountain", "Fortune Teller", "Lake Shop", "Bomb Shop",
71 "Cave 45", "Checkerboard Cave", "Mini Moldorm Cave", "Ice Rod Cave",
72 "Bonk Rocks", "Bottle Merchant", "Sahasrahla's Hut", "Chicken House",
73 "Aginah's Cave", "Dam Exterior", "Mimic Cave Exterior", "Waterfall Fairy",
74 "Pyramid", "Fat Fairy", "Spike Cave", "Hookshot Cave", "Graveyard Ledge",
75 "Dark Lumberjacks", "Bumper Cave", "Skull Woods 1", "Skull Woods 2",
76 "Skull Woods 3", "Skull Woods 4", "Skull Woods 5", "Skull Woods 6",
77 "Skull Woods 7", "Skull Woods 8", "Ice Palace Exterior",
78 "Misery Mire Exterior", "Palace of Darkness Exterior",
79 "Swamp Palace Exterior", "Turtle Rock Exterior", "Thieves' Town Exterior",
80
81 // Dark World (0x40-0x7F)
82 "Dark Woods", "Dark Chapel", "Dark Castle", "Dark Shields", "Dark Palace",
83 "Dark Desert", "Dark Castle Gate", "Dark Witch", "Dark Village",
84 "Dark Mountain", "Dark Tower", "Dark Rocks", "Dark Graveyard",
85 "Dark Sanctuary", "Dark Lake", "Dark Desert South", "Dark Eastern",
86 "Dark Zora", "Dark Catfish", "Dark Dam", "Dark Shop", "Dark Well",
87 "Dark Blacksmith", "Dark Sick Kid", "Dark Library", "Dark Mushroom",
88 "Dark Bat", "Dark Fountain", "Dark Fortune", "Dark Lake Shop",
89 "Dark Bomb Shop", "Dark Cave 45", "Dark Checker", "Dark Mini Moldorm",
90 "Dark Ice Rod", "Dark Bonk", "Dark Bottle", "Dark Sahasrahla",
91 "Dark Chicken", "Dark Aginah", "Dark Dam Exit", "Dark Mimic Exit",
92 "Dark Waterfall", "Pyramid Top", "Dark Fat Fairy", "Dark Spike Cave",
93 "Dark Hookshot", "Dark Graveyard Ledge", "Lumberjack House",
94 "Dark Bumper", "Skull Woods A", "Skull Woods B", "Skull Woods C",
95 "Skull Woods D", "Skull Woods E", "Skull Woods F", "Skull Woods G",
96 "Skull Woods H", "Ice Palace Entry", "Misery Mire Entry",
97 "Palace of Darkness Entry", "Swamp Palace Entry", "Turtle Rock Entry",
98 "Thieves' Town Entry",
99
100 // Special Areas (0x80-0x9F)
101 "Special Area 1", "Special Area 2", "Special Area 3", "Special Area 4",
102 "Special Area 5", "Special Area 6", "Special Area 7", "Special Area 8",
103 "Special Area 9", "Special Area 10", "Special Area 11", "Special Area 12",
104 "Special Area 13", "Special Area 14", "Special Area 15",
105 "Special Area 16", "Special Area 17", "Special Area 18",
106 "Special Area 19", "Special Area 20", "Special Area 21",
107 "Special Area 22", "Special Area 23", "Special Area 24",
108 "Special Area 25", "Special Area 26", "Special Area 27",
109 "Special Area 28", "Special Area 29", "Special Area 30",
110 "Special Area 31", "Special Area 32"};
111 return map_names;
112}
113
114// Item names (complete item list)
115const std::vector<std::string>& Zelda3Labels::GetItemNames() {
116 static const std::vector<std::string> item_names = {
117 "None",
118 "Fighter Sword",
119 "Master Sword",
120 "Tempered Sword",
121 "Golden Sword",
122 "Fighter Shield",
123 "Fire Shield",
124 "Mirror Shield",
125 "Fire Rod",
126 "Ice Rod",
127 "Hammer",
128 "Hookshot",
129 "Bow",
130 "Boomerang",
131 "Powder",
132 "Bee Badge",
133 "Bombos Medallion",
134 "Ether Medallion",
135 "Quake Medallion",
136 "Lamp",
137 "Shovel",
138 "Flute",
139 "Somaria Cane",
140 "Bottle",
141 "Heart Piece",
142 "Byrna Cane",
143 "Cape",
144 "Mirror",
145 "Power Glove",
146 "Titan Mitt",
147 "Book of Mudora",
148 "Zora Flippers",
149 "Moon Pearl",
150 "Crystal",
151 "Bug Net",
152 "Blue Mail",
153 "Red Mail",
154 "Key",
155 "Compass",
156 "Heart Container",
157 "Bomb",
158 "3 Bombs",
159 "Mushroom",
160 "Red Boomerang",
161 "Red Potion",
162 "Green Potion",
163 "Blue Potion",
164 "Red Potion (Refill)",
165 "Green Potion (Refill)",
166 "Blue Potion (Refill)",
167 "10 Bombs",
168 "Big Key",
169 "Map",
170 "1 Rupee",
171 "5 Rupees",
172 "20 Rupees",
173 "Pendant of Courage",
174 "Pendant of Wisdom",
175 "Pendant of Power",
176 "Bow and Arrows",
177 "Silver Arrows Upgrade",
178 "Bee",
179 "Fairy",
180 "Heart Container (Boss)",
181 "Heart",
182 "1 Arrow",
183 "10 Arrows",
184 "Magic",
185 "Small Magic",
186 "300 Rupees",
187 "20 Rupees (Green)",
188 "100 Rupees",
189 "50 Rupees",
190 "Heart Container (Sanctuary)",
191 "Arrow Refill (5)",
192 "Arrow Refill (10)",
193 "Bomb Refill (1)",
194 "Bomb Refill (4)",
195 "Bomb Refill (8)",
196 "Blue Shield (Refill)",
197 "Magic Upgrade (1/2)",
198 "Magic Upgrade (1/4)",
199 "Programmable Item 1",
200 "Programmable Item 2",
201 "Programmable Item 3",
202 "Silvers",
203 "Rupoor",
204 "Null Item",
205 "Red Clock",
206 "Blue Clock",
207 "Green Clock",
208 "Progressive Sword",
209 "Progressive Shield",
210 "Progressive Armor",
211 "Progressive Lifting Glove",
212 "RNG Item (Single)",
213 "RNG Item (Multi)",
214 "Progressive Bow",
215 "Progressive Bow (Alt)",
216 "Aga Pendant",
217 "Pendant (Green)",
218 "Blue Pendant",
219 "Good Bee",
220 "Tossed Key"};
221 return item_names;
222}
223
224// Music track names
225const std::vector<std::string>& Zelda3Labels::GetMusicTrackNames() {
226 static const std::vector<std::string> music_names = {
227 "Nothing",
228 "Light World",
229 "Beginning",
230 "Rabbit",
231 "Forest",
232 "Intro",
233 "Town",
234 "Warp",
235 "Dark World",
236 "Master Sword",
237 "File Select",
238 "Soldier",
239 "Boss",
240 "Dark World Death Mountain",
241 "Minigame",
242 "Skull Woods",
243 "Indoor",
244 "Cave 1",
245 "Zelda's Rescue",
246 "Crystal",
247 "Shop",
248 "Cave 2",
249 "Game Over",
250 "Boss Victory",
251 "Sanctuary",
252 "Boss Victory (Short)",
253 "Dark World Woods",
254 "Pendant",
255 "Ganon's Message",
256 "Hyrule Castle",
257 "Light World Death Mountain",
258 "Eastern Palace",
259 "Desert Palace",
260 "Agahnim's Theme",
261 "Damp Dungeon",
262 "Ganon Reveals",
263 "Confrontation",
264 "Ganon's Theme",
265 "Triforce",
266 "Credits",
267 "Unused",
268 "Unused",
269 "Unused",
270 "Unused",
271 "Unused",
272 "Unused",
273 "Unused",
274 "Unused"};
275 return music_names;
276}
277
278// Graphics sheet names
279const std::vector<std::string>& Zelda3Labels::GetGraphicsSheetNames() {
280 static const std::vector<std::string> gfx_names = {"Sprite Sheet 0",
281 "Sprite Sheet 1",
282 "Sprite Sheet 2",
283 "Sprite Sheet 3",
284 "Sprite Sheet 4",
285 "Sprite Sheet 5",
286 "Sprite Sheet 6",
287 "Sprite Sheet 7",
288 "Sprite Sheet 8",
289 "Sprite Sheet 9",
290 "Sprite Sheet A",
291 "Sprite Sheet B",
292 "Sprite Sheet C",
293 "Sprite Sheet D",
294 "Sprite Sheet E",
295 "Sprite Sheet F",
296 "Link's Sprites",
297 "Sword Sprites",
298 "Shield Sprites",
299 "Common Sprites",
300 "Boss Sprites",
301 "NPC Sprites",
302 "Enemy Sprites 1",
303 "Enemy Sprites 2",
304 "Item Sprites",
305 "Dungeon Objects",
306 "Overworld Objects",
307 "Interface",
308 "Font",
309 "Credits",
310 "Unused",
311 "Unused"};
312 return gfx_names;
313}
314
315// Room object names - these are large, so we'll delegate to a helper
316namespace {
317template <size_t N>
318std::vector<std::string> ConvertArrayToVector(const char* const (&array)[N]) {
319 std::vector<std::string> result;
320 result.reserve(N);
321 for (const char* name : array) {
322 result.emplace_back(name);
323 }
324 return result;
325}
326} // namespace
327
328const std::vector<std::string>& Zelda3Labels::GetType1RoomObjectNames() {
329 static const std::vector<std::string> names =
330 ConvertArrayToVector(Type1RoomObjectNames);
331 return names;
332}
333
334const std::vector<std::string>& Zelda3Labels::GetType2RoomObjectNames() {
335 static const std::vector<std::string> names =
336 ConvertArrayToVector(Type2RoomObjectNames);
337 return names;
338}
339
340const std::vector<std::string>& Zelda3Labels::GetType3RoomObjectNames() {
341 static const std::vector<std::string> names =
342 ConvertArrayToVector(Type3RoomObjectNames);
343 return names;
344}
345
346// Room effect names - reuse existing RoomEffect array
347const std::vector<std::string>& Zelda3Labels::GetRoomEffectNames() {
348 static std::vector<std::string> effect_names;
349 if (effect_names.empty()) {
350 for (const auto& name : RoomEffect) {
351 effect_names.push_back(name);
352 }
353 }
354 return effect_names;
355}
356
357// Room tag names
358const std::vector<std::string>& Zelda3Labels::GetRoomTagNames() {
359 static const std::vector<std::string> tag_names = {
360 "Nothing", // 0
361 "NW Kill Enemy to Open", // 1
362 "NE Kill Enemy to Open", // 2
363 "SW Kill Enemy to Open", // 3
364 "SE Kill Enemy to Open", // 4
365 "W Kill Enemy to Open", // 5
366 "E Kill Enemy to Open", // 6
367 "N Kill Enemy to Open", // 7
368 "S Kill Enemy to Open", // 8
369 "Clear Quadrant to Open", // 9
370 "Clear Room to Open", // 10
371 "NW Push Block to Open", // 11
372 "NE Push Block to Open", // 12
373 "SW Push Block to Open", // 13
374 "SE Push Block to Open", // 14
375 "W Push Block to Open", // 15
376 "E Push Block to Open", // 16
377 "N Push Block to Open", // 17
378 "S Push Block to Open", // 18
379 "Push Block to Open", // 19
380 "Pull Lever to Open", // 20
381 "Collect Prize to Open", // 21
382 "Hold Switch Open Door", // 22
383 "Toggle Switch to Open Door", // 23
384 "Turn off Water", // 24
385 "Turn on Water", // 25
386 "Water Gate", // 26
387 "Water Twin", // 27
388 "Moving Wall Right", // 28
389 "Moving Wall Left", // 29
390 "Crash1", // 30
391 "Crash2", // 31
392 "Push Switch Exploding Wall", // 32
393 "Holes 0", // 33
394 "Open Chest for Holes 0", // 34
395 "Holes 1", // 35
396 "Holes 2", // 36
397 "Defeat Boss for Prize", // 37
398 "SE Kill Enemy for Push Blk", // 38
399 "Trigger Switch Chest", // 39
400 "Pull Lever Exploding Wall", // 40
401 "NW Kill Enemy for Chest", // 41
402 "NE Kill Enemy for Chest", // 42
403 "SW Kill Enemy for Chest", // 43
404 "SE Kill Enemy for Chest", // 44
405 "W Kill Enemy for Chest", // 45
406 "E Kill Enemy for Chest", // 46
407 "N Kill Enemy for Chest", // 47
408 "S Kill Enemy for Chest", // 48
409 "Clear Quadrant for Chest", // 49
410 "Clear Room for Chest", // 50
411 "Light Torches to Open", // 51
412 "Holes 3", // 52
413 "Holes 4", // 53
414 "Holes 5", // 54
415 "Holes 6", // 55
416 "Agahnim Room", // 56
417 "Holes 7", // 57
418 "Holes 8", // 58
419 "Open Chest for Holes 8", // 59
420 "Push Block for Chest", // 60
421 "Clear Room for Triforce", // 61
422 "Light Torches for Chest", // 62
423 "Kill Boss Again", // 63
424 "64 (Unused)" // 64
425 };
426 return tag_names;
427}
428
429// Tile type names
430const std::vector<std::string>& Zelda3Labels::GetTileTypeNames() {
431 static const std::vector<std::string> tile_names = {
432 "Nothing (standard floor)",
433 "Nothing (unused?)",
434 "Collision",
435 "Collision (unknown types)",
436 "Collision",
437 "Collision (unused?)",
438 "Collision",
439 "Collision",
440 "Deep water",
441 "Shallow water",
442 "Unknown (near water/pit edges)",
443 "Collision (water/pit edges)",
444 "Overlay mask",
445 "Spike floor",
446 "GT ice",
447 "Ice palace ice",
448 "Slope ◤",
449 "Slope ◥",
450 "Slope ◣",
451 "Slope ◢",
452 "Nothing (unused?)",
453 "Nothing (unused?)",
454 "Nothing (unused?)",
455 "Slope ◤",
456 "Slope ◥",
457 "Slope ◣",
458 "Slope ◢",
459 "Layer swap",
460 "Pit",
461 "Manual stairs",
462 "Pot switch",
463 "Pressure switch",
464 "Blocks switch (chest, PoD, walls)",
465 "Layer toggle",
466 "Layer 2 overlay",
467 "North single-layer auto stairs",
468 "North layer swap auto stairs",
469 "South single-layer auto stairs",
470 "South layer swap auto stairs",
471 "North/south layer swap auto stairs",
472 "North/south single-layer auto stairs",
473 "West single-layer auto stairs",
474 "West layer swap auto stairs",
475 "East single-layer auto stairs",
476 "East layer swap auto stairs",
477 "East/west layer swap auto stairs",
478 "East/west single-layer auto stairs",
479 "Nothing (stairs edge)",
480 "Straight inter-room stairs south/up",
481 "Straight inter-room stairs north/down",
482 "Straight inter-room stairs south/down 2",
483 "Straight inter-room stairs north/up 2",
484 "Star tile (inactive on GBA)",
485 "Collision (near stairs)",
486 "Warp tile",
487 "Square corners ⌜⌝⌞⌟",
488 "Thick corner ⌜",
489 "Thick corner ⌝",
490 "Thick corner ⌞",
491 "Thick corner ⌟",
492 "Roof/grass tiles?",
493 "Spike floor"};
494 return tile_names;
495}
496
497// Convert all labels to structured map for project embedding
498std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
500 std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
501 labels;
502
503 // Rooms
504 const auto& rooms = GetRoomNames();
505 for (size_t i = 0; i < rooms.size(); ++i) {
506 labels["room"][std::to_string(i)] = rooms[i];
507 }
508
509 // Entrances
510 const auto& entrances = GetEntranceNames();
511 for (size_t i = 0; i < entrances.size(); ++i) {
512 labels["entrance"][std::to_string(i)] = entrances[i];
513 }
514
515 // Sprites
516 const auto& sprites = GetSpriteNames();
517 for (size_t i = 0; i < sprites.size(); ++i) {
518 labels["sprite"][std::to_string(i)] = sprites[i];
519 }
520
521 // Overlords
522 const auto& overlords = GetOverlordNames();
523 for (size_t i = 0; i < overlords.size(); ++i) {
524 labels["overlord"][std::to_string(i)] = overlords[i];
525 }
526
527 // Overworld maps
528 const auto& maps = GetOverworldMapNames();
529 for (size_t i = 0; i < maps.size(); ++i) {
530 labels["overworld_map"][std::to_string(i)] = maps[i];
531 }
532
533 // Items
534 const auto& items = GetItemNames();
535 for (size_t i = 0; i < items.size(); ++i) {
536 labels["item"][std::to_string(i)] = items[i];
537 }
538
539 // Music tracks
540 const auto& music = GetMusicTrackNames();
541 for (size_t i = 0; i < music.size(); ++i) {
542 labels["music"][std::to_string(i)] = music[i];
543 }
544
545 // Graphics sheets
546 const auto& gfx = GetGraphicsSheetNames();
547 for (size_t i = 0; i < gfx.size(); ++i) {
548 labels["graphics"][std::to_string(i)] = gfx[i];
549 }
550
551 // Room effects
552 const auto& effects = GetRoomEffectNames();
553 for (size_t i = 0; i < effects.size(); ++i) {
554 labels["room_effect"][std::to_string(i)] = effects[i];
555 }
556
557 // Room tags
558 const auto& tags = GetRoomTagNames();
559 for (size_t i = 0; i < tags.size(); ++i) {
560 labels["room_tag"][std::to_string(i)] = tags[i];
561 }
562
563 // Tile types
564 const auto& tiles = GetTileTypeNames();
565 for (size_t i = 0; i < tiles.size(); ++i) {
566 labels["tile_type"][std::to_string(i)] = tiles[i];
567 }
568
569 // Dungeon room objects
570 const auto& type1_objects = GetType1RoomObjectNames();
571 for (size_t i = 0; i < type1_objects.size(); ++i) {
572 labels["room_object_type1"][std::to_string(i)] = type1_objects[i];
573 labels["room_object"][std::to_string(i)] = type1_objects[i];
574 }
575
576 const auto& type2_objects = GetType2RoomObjectNames();
577 for (size_t i = 0; i < type2_objects.size(); ++i) {
578 const int object_id = 0x100 + static_cast<int>(i);
579 labels["room_object_type2"][std::to_string(i)] = type2_objects[i];
580 labels["room_object"][std::to_string(object_id)] = type2_objects[i];
581 }
582
583 const auto& type3_objects = GetType3RoomObjectNames();
584 for (size_t i = 0; i < type3_objects.size(); ++i) {
585 const int object_id = 0xF80 + static_cast<int>(i);
586 labels["room_object_type3"][std::to_string(i)] = type3_objects[i];
587 labels["room_object"][std::to_string(object_id)] = type3_objects[i];
588 }
589
590 return labels;
591}
592
593// Get a label by resource type and ID
594std::string Zelda3Labels::GetLabel(const std::string& resource_type, int id,
595 const std::string& default_value) {
596 static auto labels = ToResourceLabels();
597
598 auto type_it = labels.find(resource_type);
599 if (type_it == labels.end()) {
600 return default_value.empty() ? resource_type + "_" + std::to_string(id)
601 : default_value;
602 }
603
604 auto label_it = type_it->second.find(std::to_string(id));
605 if (label_it == type_it->second.end()) {
606 return default_value.empty() ? resource_type + "_" + std::to_string(id)
607 : default_value;
608 }
609
610 return label_it->second;
611}
612
613} // namespace yaze::zelda3
std::vector< std::string > ConvertArrayToVector(const char *const (&array)[N])
Zelda 3 specific classes and functions.
const std::string kOverlordNames[26]
Definition sprite.cc:296
const std::string kSpriteDefaultNames[256]
Definition sprite.cc:13
constexpr std::array< std::string_view, 297 > kRoomNames
Definition room.h:1204
const std::string RoomEffect[8]
Definition room.cc:132
constexpr const char * kEntranceNames[]
Definition common.h:91
static const std::vector< std::string > & GetRoomNames()
static const std::vector< std::string > & GetItemNames()
static std::unordered_map< std::string, std::unordered_map< std::string, std::string > > ToResourceLabels()
Convert all labels to a structured map for project embedding.
static const std::vector< std::string > & GetEntranceNames()
static const std::vector< std::string > & GetType2RoomObjectNames()
static const std::vector< std::string > & GetType1RoomObjectNames()
static const std::vector< std::string > & GetGraphicsSheetNames()
static const std::vector< std::string > & GetMusicTrackNames()
static const std::vector< std::string > & GetTileTypeNames()
static const std::vector< std::string > & GetOverlordNames()
static const std::vector< std::string > & GetSpriteNames()
static const std::vector< std::string > & GetOverworldMapNames()
static const std::vector< std::string > & GetType3RoomObjectNames()
static std::string GetLabel(const std::string &resource_type, int id, const std::string &default_value="")
Get a label by resource type and ID.
static const std::vector< std::string > & GetRoomEffectNames()
static const std::vector< std::string > & GetRoomTagNames()