yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
overworld_map.cc
Go to the documentation of this file.
1#include "overworld_map.h"
2
3#include <cstddef>
4#include <cstdint>
5#include <unordered_map>
6#include <vector>
7
8#include "app/core/features.h"
9#include "app/gfx/snes_tile.h"
10#include "app/rom.h"
12#include "util/log.h"
13
14namespace yaze {
15namespace zelda3 {
16
18 : index_(index), parent_(index), rom_(rom) {
20
21 if (core::FeatureFlags::get().overworld.kLoadCustomOverworld) {
22 // If the custom overworld ASM has NOT already been applied, manually set
23 // the vanilla values.
24 uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied];
25 if (asm_version == 0x00) {
27 } else {
28 SetupCustomTileset(asm_version);
29 }
30 }
31}
32
33absl::Status OverworldMap::BuildMap(int count, int game_state, int world,
34 std::vector<gfx::Tile16> &tiles16,
35 OverworldBlockset &world_blockset) {
36 game_state_ = game_state;
37 world_ = world;
38 if (large_map_) {
39 if (parent_ != index_ && !initialized_) {
40 if (index_ >= kSpecialWorldMapIdStart && index_ <= 0x8A &&
41 index_ != 0x88) {
45 } else if (index_ == 0x88) {
46 area_graphics_ = 0x51;
47 area_palette_ = 0x00;
48 } else {
51 }
52
53 initialized_ = true;
54 }
55 }
56
59 RETURN_IF_ERROR(BuildTiles16Gfx(tiles16, count))
61 RETURN_IF_ERROR(BuildBitmap(world_blockset))
62 built_ = true;
63 return absl::OkStatus();
64}
65
68 if (index_ <= 128)
69 large_map_ = ((*rom_)[kOverworldMapSize + (index_ & 0x3F)] != 0);
70 else {
72 index_ == 129 || index_ == 130 || index_ == 137 || index_ == 138;
73 }
74 }
75
76 auto message_id = rom_->ReadWord(kOverworldMessageIds + (parent_ * 2));
77 if (message_id.ok()) {
78 message_id_ = message_id.value();
79 } else {
80 message_id_ = 0;
81 util::logf("Error reading message id for map %d", parent_);
82 }
83
87
92
98
100 sprite_palette_[1] =
102 sprite_palette_[2] =
104 } else if (index_ < kSpecialWorldMapIdStart) {
107 area_music_[0] = (*rom_)[kOverworldMusicDarkWorld + (parent_ - 64)];
108
115
116 sprite_palette_[0] =
118 sprite_palette_[1] =
120 sprite_palette_[2] =
122 } else {
123 if (index_ == 0x94) {
124 parent_ = 0x80;
125 } else if (index_ == 0x95) {
126 parent_ = 0x03;
127 } else if (index_ == 0x96) {
128 parent_ = 0x5B; // pyramid bg use 0x5B map
129 } else if (index_ == 0x97) {
130 parent_ = 0x00; // pyramid bg use 0x5B map
131 } else if (index_ == 0x9C) {
132 parent_ = 0x43;
133 } else if (index_ == 0x9D) {
134 parent_ = 0x00;
135 } else if (index_ == 0x9E) {
136 parent_ = 0x00;
137 } else if (index_ == 0x9F) {
138 parent_ = 0x2C;
139 } else if (index_ == 0x88) {
140 parent_ = 0x88;
141 } else if (index_ == 129 || index_ == 130 || index_ == 137 ||
142 index_ == 138) {
143 parent_ = 129;
144 }
145
148 if ((index_ >= kSpecialWorldMapIdStart && index_ <= 0x8A &&
149 index_ != 0x88) ||
150 index_ == 0x94) {
154 } else if (index_ == 0x88) {
155 area_graphics_ = 0x51;
156 area_palette_ = 0x00;
157 } else {
158 // pyramid bg use 0x5B map
161 }
162
169
170 sprite_palette_[0] =
172 sprite_palette_[1] =
174 sprite_palette_[2] =
176 }
177}
178
180 // Set the main palette values.
182 area_palette_ = 0;
183 } else if (index_ >= kDarkWorldMapIdStart &&
185 area_palette_ = 1;
186 } else if (index_ >= kSpecialWorldMapIdStart && index_ < 0xA0) {
187 area_palette_ = 0;
188 }
189
190 if (index_ == 0x03 || index_ == 0x05 || index_ == 0x07) {
191 area_palette_ = 2;
192 } else if (index_ == 0x43 || index_ == 0x45 || index_ == 0x47) {
193 area_palette_ = 3;
194 } else if (index_ == 0x88) {
195 area_palette_ = 4;
196 }
197
198 // Set the mosaic values.
199 mosaic_ = index_ == 0x00 || index_ == kDarkWorldMapIdStart ||
200 index_ == kSpecialWorldMapIdStart || index_ == 0x81 ||
201 index_ == 0x88;
202
203 int index_world = 0x20;
204
207 {
208 index_world = 0x21;
209 } else if (parent_ == 0x88) // Triforce room
210 {
211 index_world = 0x24;
212 }
213
214 const auto overworld_gfx_groups2 =
215 rom_->version_constants().kOverworldGfxGroups2;
216
217 // Main Blocksets
218 for (int i = 0; i < 8; i++) {
219 custom_gfx_ids_[i] =
220 (uint8_t)(*rom_)[overworld_gfx_groups2 + (index_world * 8) + i];
221 }
222
223 const auto overworldgfxGroups =
224 rom_->version_constants().kOverworldGfxGroups1;
225 // Replace the variable tiles with the variable ones.
226 uint8_t temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4)];
227 if (temp != 0) {
228 custom_gfx_ids_[3] = temp;
229 } else {
230 custom_gfx_ids_[3] = 0xFF;
231 }
232
233 temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 1];
234 if (temp != 0) {
235 custom_gfx_ids_[4] = temp;
236 } else {
237 custom_gfx_ids_[4] = 0xFF;
238 }
239
240 temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 2];
241 if (temp != 0) {
242 custom_gfx_ids_[5] = temp;
243 } else {
244 custom_gfx_ids_[5] = 0xFF;
245 }
246
247 temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 3];
248 if (temp != 0) {
249 custom_gfx_ids_[6] = temp;
250 } else {
251 custom_gfx_ids_[6] = 0xFF;
252 }
253
254 // Set the animated GFX values.
255 if (index_ == 0x03 || index_ == 0x05 || index_ == 0x07 || index_ == 0x43 ||
256 index_ == 0x45 || index_ == 0x47) {
257 animated_gfx_ = 0x59;
258 } else {
259 animated_gfx_ = 0x5B;
260 }
261
262 // Set the subscreen overlay values.
263 subscreen_overlay_ = 0x00FF;
264
265 if (index_ == 0x00 ||
266 index_ ==
267 kDarkWorldMapIdStart) // Add fog 2 to the lost woods and skull woods.
268 {
269 subscreen_overlay_ = 0x009D;
270 } else if (index_ == 0x03 || index_ == 0x05 ||
271 index_ == 0x07) // Add the sky BG to LW death mountain.
272 {
273 subscreen_overlay_ = 0x0095;
274 } else if (index_ == 0x43 || index_ == 0x45 ||
275 index_ == 0x47) // Add the lava to DW death mountain.
276 {
277 subscreen_overlay_ = 0x009C;
278 } else if (index_ == 0x5B) // TODO: Might need this one too "index == 0x1B"
279 // but for now I don't think so.
280 {
281 subscreen_overlay_ = 0x0096;
282 } else if (index_ == 0x80) // Add fog 1 to the master sword area.
283 {
284 subscreen_overlay_ = 0x0097;
285 } else if (index_ ==
286 0x88) // Add the triforce room curtains to the triforce room.
287 {
288 subscreen_overlay_ = 0x0093;
289 }
290
291 // Set the main palette values.
292 if (index_ < 0x40) // LW
293 {
294 area_palette_ = 0;
295 } else if (index_ >= 0x40 && index_ < 0x80) // DW
296 {
297 area_palette_ = 1;
298 } else if (index_ >= 0x80 && index_ < 0xA0) // SW
299 {
300 area_palette_ = 0;
301 }
302
303 if (index_ == 0x03 || index_ == 0x05 || index_ == 0x07) // LW Death Mountain
304 {
305 area_palette_ = 2;
306 } else if (index_ == 0x43 || index_ == 0x45 ||
307 index_ == 0x47) // DW Death Mountain
308 {
309 area_palette_ = 3;
310 } else if (index_ == 0x88) // Triforce room
311 {
312 area_palette_ = 4;
313 }
314
315 // Set the mosaic values.
316 switch (index_) {
317 case 0x00: // Leaving Skull Woods / Lost Woods
318 case 0x40:
319 mosaic_expanded_ = {false, true, false, true};
320 break;
321 case 0x02: // Going into Skull woods / Lost Woods west
322 case 0x0A:
323 case 0x42:
324 case 0x4A:
325 mosaic_expanded_ = {false, false, true, false};
326 break;
327 case 0x0F: // Going into Zora's Domain North
328 case 0x10: // Going into Skull Woods / Lost Woods North
329 case 0x11:
330 case 0x50:
331 case 0x51:
332 mosaic_expanded_ = {true, false, false, false};
333 break;
334 case 0x80: // Leaving Zora's Domain, the Master Sword area, and the
335 // Triforce area
336 case 0x81:
337 case 0x88:
338 mosaic_expanded_ = {false, true, false, false};
339 break;
340 }
341}
342
343void OverworldMap::SetupCustomTileset(uint8_t asm_version) {
345 mosaic_ = (*rom_)[OverworldCustomMosaicArray + index_] != 0x00;
346
347 uint8_t mosaicByte = (*rom_)[OverworldCustomMosaicArray + index_];
348 mosaic_expanded_ = {(mosaicByte & 0x08) != 0x00, (mosaicByte & 0x04) != 0x00,
349 (mosaicByte & 0x02) != 0x00, (mosaicByte & 0x01) != 0x00};
350
351 // This is just to load the GFX groups for ROMs that have an older version
352 // of the Overworld ASM already applied.
353 if (asm_version >= 0x01 && asm_version != 0xFF) {
354 for (int i = 0; i < 8; i++) {
355 custom_gfx_ids_[i] =
356 (*rom_)[OverworldCustomTileGFXGroupArray + (index_ * 8) + i];
357 }
358
360 } else {
361 int index_world = 0x20;
362
365 {
366 index_world = 0x21;
367 } else if (parent_ == 0x88) // Triforce room
368 {
369 index_world = 0x24;
370 }
371
372 // Main Blocksets
373 for (int i = 0; i < 8; i++) {
374 custom_gfx_ids_[i] =
375 (uint8_t)(*rom_)[rom_->version_constants().kOverworldGfxGroups2 +
376 (index_world * 8) + i];
377 }
378
379 const auto overworldgfxGroups =
380 rom_->version_constants().kOverworldGfxGroups1;
381
382 // Replace the variable tiles with the variable ones.
383 // If the variable is 00 set it to 0xFF which is the new "don't load
384 // anything" value.
385 uint8_t temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4)];
386 if (temp != 0x00) {
387 custom_gfx_ids_[3] = temp;
388 } else {
389 custom_gfx_ids_[3] = 0xFF;
390 }
391
392 temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 1];
393 if (temp != 0x00) {
394 custom_gfx_ids_[4] = temp;
395 } else {
396 custom_gfx_ids_[4] = 0xFF;
397 }
398
399 temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 2];
400 if (temp != 0x00) {
401 custom_gfx_ids_[5] = temp;
402 } else {
403 custom_gfx_ids_[5] = 0xFF;
404 }
405
406 temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 3];
407 if (temp != 0x00) {
408 custom_gfx_ids_[6] = temp;
409 } else {
410 custom_gfx_ids_[6] = 0xFF;
411 }
412
413 // Set the animated GFX values.
414 if (index_ == 0x03 || index_ == 0x05 || index_ == 0x07 || index_ == 0x43 ||
415 index_ == 0x45 || index_ == 0x47) {
416 animated_gfx_ = 0x59;
417 } else {
418 animated_gfx_ = 0x5B;
419 }
420 }
421
424}
425
428 main_gfx_id_ = 0x20;
429 } else if (parent_ >= kDarkWorldMapIdStart &&
431 main_gfx_id_ = 0x21;
432 } else if (parent_ == 0x88) {
433 main_gfx_id_ = 0x24;
434 }
435}
436
438 int static_graphics_base = 0x73;
439 static_graphics_[8] = static_graphics_base + 0x00;
440 static_graphics_[9] = static_graphics_base + 0x01;
441 static_graphics_[10] = static_graphics_base + 0x06;
442 static_graphics_[11] = static_graphics_base + 0x07;
443
444 for (int i = 0; i < 4; i++) {
445 static_graphics_[12 + i] =
446 ((*rom_)[rom_->version_constants().kSpriteBlocksetPointer +
447 (sprite_graphics_[game_state_] * 4) + i] +
448 static_graphics_base);
449 }
450}
451
453 for (int i = 0; i < 8; i++) {
455 (*rom_)[rom_->version_constants().kOverworldGfxGroups2 +
456 (main_gfx_id_ * 8) + i];
457 }
458}
459
460// For animating water tiles on the overworld map.
461// We want to swap out static_graphics_[07] with the next sheet
462// Usually it is 5A, so we make it 5B instead.
463// There is a middle frame which contains tiles from the bottom half
464// of the 5A sheet, so this will need some special manipulation to make work
465// during the BuildBitmap step (or a new one specifically for animating).
467 if (static_graphics_[7] == 0x5B) {
468 static_graphics_[7] = 0x5A;
469 } else {
470 if (static_graphics_[7] == 0x59) {
471 static_graphics_[7] = 0x58;
472 }
473 static_graphics_[7] = 0x5B;
474 }
475}
476
478 for (int i = 0; i < 4; i++) {
479 uint8_t value = (*rom_)[rom_->version_constants().kOverworldGfxGroups1 +
480 (area_graphics_ * 4) + i];
481 if (value != 0) {
482 static_graphics_[3 + i] = value;
483 }
484 }
485}
486
487// TODO: Change the conditions for death mountain gfx
488// JaredBrian: This is how ZS did it, but in 3.0.4 I changed it to just check
489// for 03, 05, 07, and the DW ones as that's how it would appear in-game if
490// you were to make area 03 not a large area anymore for example, so you might
491// want to do the same.
493 static_graphics_[7] = (((parent_ >= 0x03 && parent_ <= 0x07) ||
494 (parent_ >= 0x0B && parent_ <= 0x0E)) ||
495 ((parent_ >= 0x43 && parent_ <= 0x47) ||
496 (parent_ >= 0x4B && parent_ <= 0x4E)))
497 ? 0x59
498 : 0x5B;
499}
500
508
510
511absl::Status SetColorsPalette(Rom &rom, int index, gfx::SnesPalette &current,
514 gfx::SnesPalette hud, gfx::SnesColor bgrcolor,
516 // Palettes infos, color 0 of a palette is always transparent (the arrays
517 // contains 7 colors width wide) There is 16 color per line so 16*Y
518
519 // Left side of the palette - Main, Animated
520 std::array<gfx::SnesColor, 256> new_palette = {};
521
522 // Main Palette, Location 0,2 : 35 colors [7x5]
523 int k = 0;
524 for (int y = 2; y < 7; y++) {
525 for (int x = 1; x < 8; x++) {
526 new_palette[x + (16 * y)] = main[k];
527 k++;
528 }
529 }
530
531 // Animated Palette, Location 0,7 : 7colors
532 for (int x = 1; x < 8; x++) {
533 new_palette[(16 * 7) + (x)] = animated[(x - 1)];
534 }
535
536 // Right side of the palette - Aux1, Aux2
537
538 // Aux1 Palette, Location 8,2 : 21 colors [7x3]
539 k = 0;
540 for (int y = 2; y < 5; y++) {
541 for (int x = 9; x < 16; x++) {
542 new_palette[x + (16 * y)] = aux1[k];
543 k++;
544 }
545 }
546
547 // Aux2 Palette, Location 8,5 : 21 colors [7x3]
548 k = 0;
549 for (int y = 5; y < 8; y++) {
550 for (int x = 9; x < 16; x++) {
551 new_palette[x + (16 * y)] = aux2[k];
552 k++;
553 }
554 }
555
556 // Hud Palette, Location 0,0 : 32 colors [16x2]
557 for (int i = 0; i < 32; i++) {
558 new_palette[i] = hud[i];
559 }
560
561 // Hardcoded grass color (that might change to become invisible instead)
562 for (int i = 0; i < 8; i++) {
563 new_palette[(i * 16)] = bgrcolor;
564 new_palette[(i * 16) + 8] = bgrcolor;
565 }
566
567 // Sprite Palettes
568 k = 0;
569 for (int y = 8; y < 9; y++) {
570 for (int x = 1; x < 8; x++) {
571 new_palette[x + (16 * y)] = rom.palette_group().sprites_aux1[1][k];
572 k++;
573 }
574 }
575
576 // Sprite Palettes
577 k = 0;
578 for (int y = 8; y < 9; y++) {
579 for (int x = 9; x < 16; x++) {
580 new_palette[x + (16 * y)] = rom.palette_group().sprites_aux3[0][k];
581 k++;
582 }
583 }
584
585 // Sprite Palettes
586 k = 0;
587 for (int y = 9; y < 13; y++) {
588 for (int x = 1; x < 16; x++) {
589 new_palette[x + (16 * y)] = rom.palette_group().global_sprites[0][k];
590 k++;
591 }
592 }
593
594 // Sprite Palettes
595 k = 0;
596 for (int y = 13; y < 14; y++) {
597 for (int x = 1; x < 8; x++) {
598 new_palette[x + (16 * y)] = spr[k];
599 k++;
600 }
601 }
602
603 // Sprite Palettes
604 k = 0;
605 for (int y = 14; y < 15; y++) {
606 for (int x = 1; x < 8; x++) {
607 new_palette[x + (16 * y)] = spr2[k];
608 k++;
609 }
610 }
611
612 // Sprite Palettes
613 k = 0;
614 for (int y = 15; y < 16; y++) {
615 for (int x = 1; x < 16; x++) {
616 new_palette[x + (16 * y)] = rom.palette_group().armors[0][k];
617 k++;
618 }
619 }
620
621 for (int i = 0; i < 256; i++) {
622 current[i] = new_palette[i];
623 current[(i / 16) * 16].set_transparent(true);
624 }
625
626 return absl::OkStatus();
627}
628} // namespace palette_internal
629
630absl::StatusOr<gfx::SnesPalette> OverworldMap::GetPalette(
631 const gfx::PaletteGroup &palette_group, int index, int previous_index,
632 int limit) {
633 if (index == 255) {
634 index = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup +
635 (previous_index * 4)];
636 }
637 if (index >= limit) {
638 index = limit - 1;
639 }
640 return palette_group[index];
641}
642
644 int previous_pal_id =
645 index_ > 0 ? (*rom_)[kOverworldMapPaletteIds + parent_ - 1] : 0;
646 int previous_spr_pal_id =
647 index_ > 0 ? (*rom_)[kOverworldSpritePaletteIds + parent_ - 1] : 0;
648
649 area_palette_ = std::min((int)area_palette_, 0xA3);
650
651 uint8_t pal0 = 0;
652 uint8_t pal1 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup +
653 (area_palette_ * 4)];
654 uint8_t pal2 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup +
655 (area_palette_ * 4) + 1];
656 uint8_t pal3 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup +
657 (area_palette_ * 4) + 2];
658 uint8_t pal4 = (*rom_)[kOverworldSpritePaletteGroup +
660 uint8_t pal5 = (*rom_)[kOverworldSpritePaletteGroup +
661 (sprite_palette_[game_state_] * 2) + 1];
662
663 auto grass_pal_group = rom_->palette_group().grass;
664 auto bgr = grass_pal_group[0][0];
665
666 auto ow_aux_pal_group = rom_->palette_group().overworld_aux;
668 GetPalette(ow_aux_pal_group, pal1, previous_pal_id, 20));
670 GetPalette(ow_aux_pal_group, pal2, previous_pal_id, 20));
671
672 // Additional handling of `pal3` and `parent_`
673 if (pal3 == 255) {
674 pal3 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup +
675 (previous_pal_id * 4) + 2];
676 }
677
679 pal0 = parent_ == 0x03 || parent_ == 0x05 || parent_ == 0x07 ? 2 : 0;
680 bgr = grass_pal_group[0][0];
681 } else if (parent_ >= kDarkWorldMapIdStart &&
683 pal0 = parent_ == 0x43 || parent_ == 0x45 || parent_ == 0x47 ? 3 : 1;
684 bgr = grass_pal_group[0][1];
685 } else if (parent_ >= 128 && parent_ < kNumOverworldMaps) {
686 pal0 = 0;
687 bgr = grass_pal_group[0][2];
688 }
689
690 if (parent_ == 0x88) {
691 pal0 = 4;
692 }
693
694 auto ow_main_pal_group = rom_->palette_group().overworld_main;
696 GetPalette(ow_main_pal_group, pal0, previous_pal_id, 255));
697 auto ow_animated_pal_group = rom_->palette_group().overworld_animated;
699 GetPalette(ow_animated_pal_group, std::min((int)pal3, 13),
700 previous_pal_id, 14));
701
702 auto hud_pal_group = rom_->palette_group().hud;
703 gfx::SnesPalette hud = hud_pal_group[0];
704
706 GetPalette(rom_->palette_group().sprites_aux3, pal4,
707 previous_spr_pal_id, 24));
709 GetPalette(rom_->palette_group().sprites_aux3, pal5,
710 previous_spr_pal_id, 24));
711
713 *rom_, parent_, current_palette_, main, animated, aux1, aux2, hud, bgr,
714 spr, spr2));
715
716 if (palettesets_.count(area_palette_) == 0) {
718 main, animated, aux1, aux2, bgr, hud, spr, spr2, current_palette_};
719 }
720
721 return absl::OkStatus();
722}
723
724void OverworldMap::ProcessGraphicsBuffer(int index, int static_graphics_offset,
725 int size, uint8_t *all_gfx) {
726 for (int i = 0; i < size; i++) {
727 auto byte = all_gfx[i + (static_graphics_offset * size)];
728 switch (index) {
729 case 0:
730 case 3:
731 case 4:
732 case 5:
733 byte += 0x88;
734 break;
735 }
736 current_gfx_[(index * size) + i] = byte;
737 }
738}
739
741 if (current_gfx_.size() == 0) current_gfx_.resize(0x10000, 0x00);
742 for (int i = 0; i < 0x10; i++) {
744 rom_->graphics_buffer().data());
745 }
746 return absl::OkStatus();
747}
748
749absl::Status OverworldMap::BuildTiles16Gfx(std::vector<gfx::Tile16> &tiles16,
750 int count) {
751 if (current_blockset_.size() == 0) current_blockset_.resize(0x100000, 0x00);
752
753 const int offsets[] = {0x00, 0x08, 0x400, 0x408};
754 auto yy = 0;
755 auto xx = 0;
756
757 for (auto i = 0; i < count; i++) {
758 for (auto tile = 0; tile < 0x04; tile++) {
759 gfx::TileInfo info = tiles16[i].tiles_info[tile];
760 int offset = offsets[tile];
761 for (auto y = 0; y < 0x08; ++y) {
762 for (auto x = 0; x < 0x08; ++x) {
763 int mx = x;
764 int my = y;
765
766 if (info.horizontal_mirror_ != 0) {
767 mx = 0x07 - x;
768 }
769
770 if (info.vertical_mirror_ != 0) {
771 my = 0x07 - y;
772 }
773
774 int xpos = ((info.id_ % 0x10) * 0x08);
775 int ypos = (((info.id_ / 0x10)) * 0x400);
776 int source = ypos + xpos + (x + (y * 0x80));
777
778 auto destination = xx + yy + offset + (mx + (my * 0x80));
780 (current_gfx_[source] & 0x0F) + (info.palette_ * 0x10);
781 }
782 }
783 }
784
785 xx += 0x10;
786 if (xx >= 0x80) {
787 yy += 0x800;
788 xx = 0;
789 }
790 }
791
792 return absl::OkStatus();
793}
794
795absl::Status OverworldMap::BuildBitmap(OverworldBlockset &world_blockset) {
796 if (bitmap_data_.size() != 0) {
797 bitmap_data_.clear();
798 }
799 bitmap_data_.reserve(0x40000);
800 for (int i = 0; i < 0x40000; i++) {
801 bitmap_data_.push_back(0x00);
802 }
803
804 int superY = ((index_ - (world_ * 0x40)) / 0x08);
805 int superX = index_ - (world_ * 0x40) - (superY * 0x08);
806
807 for (int y = 0; y < 0x20; y++) {
808 for (int x = 0; x < 0x20; x++) {
809 auto xt = x + (superX * 0x20);
810 auto yt = y + (superY * 0x20);
811 gfx::CopyTile8bpp16((x * 0x10), (y * 0x10), world_blockset[xt][yt],
813 }
814 }
815 return absl::OkStatus();
816}
817
818} // namespace zelda3
819} // namespace yaze
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:59
auto palette_group() const
Definition rom.h:174
static Flags & get()
Definition features.h:69
static std::unordered_map< uint8_t, gfx::Paletteset > palettesets_
SNES Color container.
Definition snes_color.h:38
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
SNES 16-bit tile metadata container.
Definition snes_tile.h:49
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 SetupCustomTileset(uint8_t asm_version)
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)
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_
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_
gfx::SnesPalette current_palette_
void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size, uint8_t *all_gfx)
int main(int argc, char **argv)
Definition emu.cc:20
#define RETURN_IF_ERROR(expression)
Definition macro.h:51
#define ASSIGN_OR_RETURN(type_variable_name, expression)
Definition macro.h:59
void CopyTile8bpp16(int x, int y, int tile, std::vector< uint8_t > &bitmap, std::vector< uint8_t > &blockset)
Definition snes_tile.cc:376
absl::Status SetColorsPalette(Rom &rom, int index, gfx::SnesPalette &current, gfx::SnesPalette main, gfx::SnesPalette animated, gfx::SnesPalette aux1, gfx::SnesPalette aux2, gfx::SnesPalette hud, gfx::SnesColor bgrcolor, gfx::SnesPalette spr, gfx::SnesPalette spr2)
Zelda 3 specific classes and functions.
constexpr int kAreaGfxIdPtr
Definition overworld.h:40
constexpr int kOverworldSpritePaletteGroup
Definition overworld.h:32
constexpr int kOverworldSpriteset
Definition overworld.h:33
constexpr int kSpecialWorldMapIdStart
constexpr int OverworldCustomMosaicArray
constexpr int kNumOverworldMaps
Definition overworld.h:96
constexpr int OverworldCustomMainPaletteArray
constexpr int kOverworldMusicBeginning
Definition overworld.h:43
std::vector< std::vector< uint16_t > > OverworldBlockset
Represents tile32 data for the overworld.
constexpr int kOverworldMusicDarkWorld
Definition overworld.h:47
constexpr int kOverworldSpecialPalGroup
Definition overworld.h:35
constexpr int kOverworldSpritePaletteIds
Definition overworld.h:31
constexpr int OverworldCustomASMHasBeenApplied
constexpr int kOverworldMusicAgahnim
Definition overworld.h:46
constexpr int kOverworldMusicMasterSword
Definition overworld.h:45
constexpr int kOverworldMusicZelda
Definition overworld.h:44
constexpr int kOverworldMessageIds
Definition overworld.h:41
constexpr int kOverworldMapSize
Definition overworld.h:52
constexpr int OverworldCustomAnimatedGFXArray
constexpr int kDarkWorldMapIdStart
constexpr int OverworldCustomTileGFXGroupArray
constexpr int kOverworldMapPaletteIds
Definition overworld.h:30
constexpr int kOverworldSpecialGfxGroup
Definition overworld.h:34
constexpr int OverworldCustomSubscreenOverlayArray
Main namespace for the application.
Definition controller.cc:18
Represents a group of palettes.
Represents a set of palettes used in a SNES graphics system.