5#include <unordered_map>
18 : index_(index), parent_(index), rom_(rom) {
22 if (asm_version != 0xFF && asm_version >= 0x03) {
27 if (asm_version != 0xFF) {
28 if (asm_version == 0x03) {
41 std::vector<gfx::Tile16>& tiles16,
57 }
else if (
index_ == 0x88) {
78 return absl::OkStatus();
90 if (asm_version < 3 || asm_version == 0xFF) {
160 if (asm_version < 3 || asm_version == 0xFF) {
186 if (asm_version < 3 || asm_version == 0xFF) {
194 if (asm_version >= 3 && asm_version != 0xFF) {
233 if (asm_version < 3 || asm_version == 0xFF) {
241 }
else if (
index_ == 0x80) {
257 }
else if (
index_ == 0x94) {
262 }
else if (
index_ == 0x95) {
266 }
else if (
index_ == 0x96) {
270 }
else if (
index_ == 0x9C) {
334 int index_world = 0x20;
342 const auto overworld_gfx_groups2 =
346 for (
int i = 0; i < 8; i++) {
348 (uint8_t)(*
rom_)[overworld_gfx_groups2 + (index_world * 8) + i];
351 const auto overworldgfxGroups =
355 uint8_t temp = (*rom_)[overworldgfxGroups + (
area_graphics_ * 4)];
412 }
else if (
index_ == 0x80) {
426 mosaic_expanded_ = {(mosaicByte & 0x08) != 0x00, (mosaicByte & 0x04) != 0x00,
427 (mosaicByte & 0x02) != 0x00, (mosaicByte & 0x01) != 0x00};
430 if (asm_version >= 3 && asm_version != 0xFF) {
437 if (asm_version >= 0x01 && asm_version != 0xFF) {
439 for (
int i = 0; i < 8; i++) {
446 int index_world = 0x20;
455 for (
int i = 0; i < 8; i++) {
458 (index_world * 8) + i];
461 const auto overworldgfxGroups =
467 uint8_t temp = (*rom_)[overworldgfxGroups + (
area_graphics_ * 4)];
527 int static_graphics_base = 0x73;
533 for (
int i = 0; i < 4; i++) {
537 static_graphics_base);
542 for (
int i = 0; i < 8; i++) {
567 for (
int i = 0; i < 4; i++) {
598namespace palette_internal {
609 std::array<gfx::SnesColor, 256> new_palette = {};
613 for (
int y = 2; y < 7; y++) {
614 for (
int x = 1; x < 8; x++) {
615 new_palette[x + (16 * y)] =
main[k];
621 for (
int x = 1; x < 8; x++) {
622 new_palette[(16 * 7) + (x)] = animated[(x - 1)];
629 for (
int y = 2; y < 5; y++) {
630 for (
int x = 9; x < 16; x++) {
631 new_palette[x + (16 * y)] = aux1[k];
638 for (
int y = 5; y < 8; y++) {
639 for (
int x = 9; x < 16; x++) {
640 new_palette[x + (16 * y)] = aux2[k];
646 for (
int i = 0; i < 32; i++) {
647 new_palette[i] = hud[i];
651 for (
int i = 0; i < 8; i++) {
652 new_palette[(i * 16)] = bgrcolor;
653 new_palette[(i * 16) + 8] = bgrcolor;
658 for (
int y = 8; y < 9; y++) {
659 for (
int x = 1; x < 8; x++) {
660 new_palette[x + (16 * y)] = rom.
palette_group().sprites_aux1[1][k];
667 for (
int y = 8; y < 9; y++) {
668 for (
int x = 9; x < 16; x++) {
669 new_palette[x + (16 * y)] = rom.
palette_group().sprites_aux3[0][k];
676 for (
int y = 9; y < 13; y++) {
677 for (
int x = 1; x < 16; x++) {
678 new_palette[x + (16 * y)] = rom.
palette_group().global_sprites[0][k];
685 for (
int y = 13; y < 14; y++) {
686 for (
int x = 1; x < 8; x++) {
687 new_palette[x + (16 * y)] = spr[k];
694 for (
int y = 14; y < 15; y++) {
695 for (
int x = 1; x < 8; x++) {
696 new_palette[x + (16 * y)] = spr2[k];
703 for (
int y = 15; y < 16; y++) {
704 for (
int x = 1; x < 16; x++) {
705 new_palette[x + (16 * y)] = rom.
palette_group().armors[0][k];
710 for (
int i = 0; i < 256; i++) {
711 current[i] = new_palette[i];
712 current[(i / 16) * 16].set_transparent(
true);
716 return absl::OkStatus();
725 (previous_index * 4)];
727 if (index >= limit) {
730 return palette_group[index];
736 int previous_pal_id = 0;
737 int previous_spr_pal_id = 0;
741 if (asm_version < 3 || asm_version == 0xFF) {
766 auto bgr = grass_pal_group[0][0];
771 (previous_pal_id * 4)];
776 (previous_pal_id * 4) + 1];
781 (previous_pal_id * 4) + 2];
786 GetPalette(ow_aux_pal_group, pal1, previous_pal_id, 20));
788 GetPalette(ow_aux_pal_group, pal2, previous_pal_id, 20));
791 bool use_area_specific_bg =
793 if (use_area_specific_bg) {
804 bgr = grass_pal_group[0][0];
807 bgr = grass_pal_group[0][1];
809 bgr = grass_pal_group[0][2];
818 GetPalette(ow_main_pal_group, pal0, previous_pal_id, 255));
821 GetPalette(ow_animated_pal_group, std::min((
int)pal3, 13),
822 previous_pal_id, 14));
847 previous_spr_pal_id, 24));
850 previous_spr_pal_id, 24));
861 return absl::OkStatus();
868 if (asm_version == 0xFF) {
876 return absl::OkStatus();
888 address = ((address & 0x7F0000) >> 1) | (address & 0x7FFF);
896 address = ((address & 0x7F0000) >> 1) | (address & 0x7FFF);
904 return absl::OkStatus();
909 uint8_t b = (*rom_)[address];
912 while (b != 0x60 && address < rom_->size()) {
984 if (address < rom_->size()) {
985 b = (*rom_)[address];
1000 return absl::OkStatus();
1004 int size, uint8_t* all_gfx) {
1006 int max_offset = static_graphics_offset * size + size;
1009 for (
int i = 0; i < size; i++) {
1015 for (
int i = 0; i < size; i++) {
1016 auto byte = all_gfx[i + (static_graphics_offset * size)];
1034 for (
int i = 0; i < 8; i++) {
1042 for (
int i = 8; i < 16; i++) {
1055 return absl::OkStatus();
1063 const int offsets[] = {0x00, 0x08, 0x400, 0x408};
1067 for (
auto i = 0; i < count; i++) {
1068 for (
auto tile = 0; tile < 0x04; tile++) {
1070 int offset = offsets[tile];
1071 for (
auto y = 0; y < 0x08; ++y) {
1072 for (
auto x = 0; x < 0x08; ++x) {
1084 int xpos = ((info.
id_ % 0x10) * 0x08);
1085 int ypos = (((info.
id_ / 0x10)) * 0x400);
1086 int source = ypos + xpos + (x + (y * 0x80));
1088 auto destination = xx + yy + offset + (mx + (my * 0x80));
1102 return absl::OkStatus();
1110 for (
int i = 0; i < 0x40000; i++) {
1115 int superX =
index_ - (
world_ * 0x40) - (superY * 0x08);
1117 for (
int y = 0; y < 0x20; y++) {
1118 for (
int x = 0; x < 0x20; x++) {
1119 auto xt = x + (superX * 0x20);
1120 auto yt = y + (superY * 0x20);
1125 return absl::OkStatus();
The Rom class is used to load, save, and modify Rom data.
auto palette_group() const
zelda3_version_pointers version_constants() const
auto graphics_buffer() const
static std::unordered_map< uint8_t, gfx::Paletteset > palettesets_
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
void set_size(size_t size)
SNES 16-bit tile metadata container.
std::vector< uint8_t > current_gfx_
std::vector< uint8_t > current_blockset_
std::array< bool, 4 > mosaic_expanded_
absl::Status LoadVanillaOverlayData()
std::vector< uint8_t > bitmap_data_
absl::Status LoadOverlay()
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_
void LoadAreaGraphicsBlocksets()
absl::Status BuildTileset()
void LoadDeathMountainGFX()
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_
uint16_t subscreen_overlay_
std::array< uint8_t, 8 > custom_gfx_ids_
absl::Status LoadPalette()
void LoadMainBlocksetId()
std::vector< uint8_t > overlay_data_
gfx::SnesPalette current_palette_
void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size, uint8_t *all_gfx)
void LoadCustomOverworldData()
void LoadSpritesBlocksets()
uint16_t area_specific_bg_color_
#define RETURN_IF_ERROR(expression)
#define ASSIGN_OR_RETURN(type_variable_name, expression)
void CopyTile8bpp16(int x, int y, int tile, std::vector< uint8_t > &bitmap, std::vector< uint8_t > &blockset)
absl::Status SetColorsPalette(Rom &rom, int index, gfx::SnesPalette ¤t, gfx::SnesPalette main, gfx::SnesPalette animated, gfx::SnesPalette aux1, gfx::SnesPalette aux2, gfx::SnesPalette hud, gfx::SnesColor bgrcolor, gfx::SnesPalette spr, gfx::SnesPalette spr2)
constexpr int kAreaGfxIdPtr
constexpr int OverworldCustomAreaSpecificBGEnabled
constexpr int kOverworldSpritePaletteGroup
constexpr int kOverworldSpriteset
constexpr int kOverworldScreenSize
constexpr int kOverlayData1
constexpr int kSpecialWorldMapIdStart
constexpr int OverworldCustomMosaicArray
constexpr int kNumOverworldMaps
constexpr int OverworldCustomMainPaletteArray
constexpr int kOverworldSpecialSpritePaletteExpandedTemp
constexpr int kOverworldMapParentIdExpanded
constexpr int kOverworldSpecialSpriteGfxGroupExpandedTemp
constexpr int kOverworldMusicBeginning
constexpr int kOverworldMusicDarkWorld
constexpr int kOverlayPointersBank
constexpr int kOverworldSpecialPalGroup
constexpr int kOverworldSpritePaletteIds
constexpr int OverworldCustomASMHasBeenApplied
constexpr int kOverworldMusicAgahnim
constexpr int kOverworldPalettesScreenToSetNew
constexpr int kOverworldMessagesExpanded
constexpr int kOverworldMusicMasterSword
constexpr int kOverworldMusicZelda
constexpr int kOverworldMessageIds
constexpr int kOverlayData2
constexpr int OverworldCustomAnimatedGFXArray
constexpr int kDarkWorldMapIdStart
std::vector< std::vector< uint16_t > > OverworldBlockset
Represents tile32 data for the overworld.
constexpr int OverworldCustomTileGFXGroupArray
constexpr int OverworldCustomAreaSpecificBGPalette
constexpr int kOverlayPointers
constexpr int kOverworldMapPaletteIds
constexpr int kOverworldSpecialGfxGroup
constexpr int OverworldCustomSubscreenOverlayArray
Main namespace for the application.
Room transition destination.
Represents a group of palettes.
Represents a set of palettes used in a SNES graphics system.
uint32_t kOverworldMapPaletteGroup
uint32_t kOverworldGfxGroups1
uint32_t kSpriteBlocksetPointer
uint32_t kOverworldGfxGroups2