5#include <unordered_map>
26 if (asm_version == 0x00) {
35 std::vector<gfx::Tile16> &tiles16,
46 }
else if (
index_ == 0x88) {
64 return absl::OkStatus();
82 util::logf(
"Error reading message id for map %d",
parent_);
126 }
else if (
index_ == 0x95) {
128 }
else if (
index_ == 0x96) {
130 }
else if (
index_ == 0x97) {
132 }
else if (
index_ == 0x9C) {
134 }
else if (
index_ == 0x9D) {
136 }
else if (
index_ == 0x9E) {
138 }
else if (
index_ == 0x9F) {
140 }
else if (
index_ == 0x88) {
155 }
else if (
index_ == 0x88) {
195 }
else if (
index_ == 0x88) {
204 int index_world = 0x20;
215 const auto overworld_gfx_groups2 =
216 rom_.version_constants().kOverworldGfxGroups2;
219 for (
int i = 0; i < 8; i++) {
221 (uint8_t)
rom_[overworld_gfx_groups2 + (index_world * 8) + i];
224 const auto overworldgfxGroups =
rom_.version_constants().kOverworldGfxGroups1;
278 }
else if (
index_ == 0x5B)
282 }
else if (
index_ == 0x80)
298 if (asm_version >= 0x01 && asm_version != 0xFF) {
299 for (
int i = 0; i < 8; i++) {
306 int index_world = 0x20;
318 for (
int i = 0; i < 8; i++) {
320 (uint8_t)
rom_[
rom_.version_constants().kOverworldGfxGroups2 +
321 (index_world * 8) + i];
324 const auto overworldgfxGroups =
325 rom_.version_constants().kOverworldGfxGroups1;
383 int static_graphics_base = 0x73;
389 for (
int i = 0; i < 4; i++) {
391 (
rom_[
rom_.version_constants().kSpriteBlocksetPointer +
393 static_graphics_base);
398 for (
int i = 0; i < 8; i++) {
428 for (
int i = 0; i < 4; i++) {
429 uint8_t value =
rom_[
rom_.version_constants().kOverworldGfxGroups1 +
470 std::array<gfx::SnesColor, 256> new_palette = {};
474 for (
int y = 2; y < 7; y++) {
475 for (
int x = 1; x < 8; x++) {
476 new_palette[x + (16 * y)] =
main[k];
482 for (
int x = 1; x < 8; x++) {
483 new_palette[(16 * 7) + (x)] = animated[(x - 1)];
490 for (
int y = 2; y < 5; y++) {
491 for (
int x = 9; x < 16; x++) {
492 new_palette[x + (16 * y)] = aux1[k];
499 for (
int y = 5; y < 8; y++) {
500 for (
int x = 9; x < 16; x++) {
501 new_palette[x + (16 * y)] = aux2[k];
507 for (
int i = 0; i < 32; i++) {
508 new_palette[i] = hud[i];
512 for (
int i = 0; i < 8; i++) {
513 new_palette[(i * 16)] = bgrcolor;
514 new_palette[(i * 16) + 8] = bgrcolor;
519 for (
int y = 8; y < 9; y++) {
520 for (
int x = 1; x < 8; x++) {
521 new_palette[x + (16 * y)] = rom.
palette_group().sprites_aux1[1][k];
528 for (
int y = 8; y < 9; y++) {
529 for (
int x = 9; x < 16; x++) {
530 new_palette[x + (16 * y)] = rom.
palette_group().sprites_aux3[0][k];
537 for (
int y = 9; y < 13; y++) {
538 for (
int x = 1; x < 16; x++) {
539 new_palette[x + (16 * y)] = rom.
palette_group().global_sprites[0][k];
546 for (
int y = 13; y < 14; y++) {
547 for (
int x = 1; x < 8; x++) {
548 new_palette[x + (16 * y)] = spr[k];
555 for (
int y = 14; y < 15; y++) {
556 for (
int x = 1; x < 8; x++) {
557 new_palette[x + (16 * y)] = spr2[k];
564 for (
int y = 15; y < 16; y++) {
565 for (
int x = 1; x < 16; x++) {
566 new_palette[x + (16 * y)] = rom.
palette_group().armors[0][k];
571 current.
Create(new_palette);
572 for (
int i = 0; i < 256; i++) {
573 current[(i / 16) * 16].set_transparent(
true);
576 return absl::OkStatus();
584 index =
rom_[
rom_.version_constants().kOverworldMapPaletteGroup +
585 (previous_index * 4)];
587 if (index >= limit) {
590 return palette_group[index];
594 int previous_pal_id =
596 int previous_spr_pal_id =
602 uint8_t pal1 =
rom_[
rom_.version_constants().kOverworldMapPaletteGroup +
604 uint8_t pal2 =
rom_[
rom_.version_constants().kOverworldMapPaletteGroup +
606 uint8_t pal3 =
rom_[
rom_.version_constants().kOverworldMapPaletteGroup +
613 auto grass_pal_group =
rom_.palette_group().grass;
616 auto ow_aux_pal_group =
rom_.palette_group().overworld_aux;
618 GetPalette(ow_aux_pal_group, pal1, previous_pal_id, 20));
620 GetPalette(ow_aux_pal_group, pal2, previous_pal_id, 20));
624 pal3 =
rom_[
rom_.version_constants().kOverworldMapPaletteGroup +
625 (previous_pal_id * 4) + 2];
644 auto ow_main_pal_group =
rom_.palette_group().overworld_main;
646 GetPalette(ow_main_pal_group, pal0, previous_pal_id, 255));
647 auto ow_animated_pal_group =
rom_.palette_group().overworld_animated;
649 GetPalette(ow_animated_pal_group, std::min((
int)pal3, 13),
650 previous_pal_id, 14));
652 auto hud_pal_group =
rom_.palette_group().hud;
657 previous_spr_pal_id, 24));
660 previous_spr_pal_id, 24));
671 return absl::OkStatus();
676 for (
int i = 0; i < size; i++) {
677 auto byte =
all_gfx_[i + (static_graphics_offset * size)];
694 for (
int i = 0; i < 0x10; i++) {
698 return absl::OkStatus();
705 const int offsets[] = {0x00, 0x08, 0x400, 0x408};
709 for (
auto i = 0; i < count; i++) {
710 for (
auto tile = 0; tile < 0x04; tile++) {
712 int offset = offsets[tile];
713 for (
auto y = 0; y < 0x08; ++y) {
714 for (
auto x = 0; x < 0x08; ++x) {
726 int xpos = ((info.
id_ % 0x10) * 0x08);
727 int ypos = (((info.
id_ / 0x10)) * 0x400);
728 int source = ypos + xpos + (x + (y * 0x80));
730 auto destination = xx + yy + offset + (mx + (my * 0x80));
744 return absl::OkStatus();
752 for (
int i = 0; i < 0x40000; i++) {
757 int superX =
index_ - (
world_ * 0x40) - (superY * 0x08);
759 for (
int y = 0; y < 0x20; y++) {
760 for (
int x = 0; x < 0x20; x++) {
761 auto xt = x + (superX * 0x20);
762 auto yt = y + (superY * 0x20);
767 return absl::OkStatus();
The Rom class is used to load, save, and modify Rom data.
auto palette_group() const
static std::unordered_map< uint8_t, gfx::Paletteset > palettesets_
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
void Create(const std::vector< SnesColor > &cols)
SNES 16-bit tile metadata container.
std::vector< uint8_t > current_gfx_
std::vector< uint8_t > current_blockset_
std::vector< uint8_t > bitmap_data_
std::vector< uint8_t > all_gfx_
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()
void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size)
gfx::SnesPalette current_palette_
void LoadCustomOverworldData()
void LoadSpritesBlocksets()
int main(int argc, char **argv)
#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)
std::string HexByte(uint8_t byte, HexStringParams params)
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)
Zelda 3 specific classes and functions.
constexpr int kAreaGfxIdPtr
constexpr int kOverworldSpritePaletteGroup
constexpr int kOverworldSpriteset
constexpr int kSpecialWorldMapIdStart
constexpr int OverworldCustomMosaicArray
constexpr int kNumOverworldMaps
constexpr int OverworldCustomMainPaletteArray
constexpr int kOverworldMusicBeginning
std::vector< std::vector< uint16_t > > OverworldBlockset
Represents tile32 data for the overworld.
constexpr int kOverworldMusicDarkWorld
constexpr int kOverworldSpecialPalGroup
constexpr int kOverworldSpritePaletteIds
constexpr int OverworldCustomASMHasBeenApplied
constexpr int kOverworldMusicAgahnim
constexpr int kOverworldMusicMasterSword
constexpr int kOverworldMusicZelda
constexpr int kOverworldMessageIds
constexpr int kOverworldMapSize
constexpr int OverworldCustomAnimatedGFXArray
constexpr int kDarkWorldMapIdStart
constexpr int OverworldCustomTileGFXGroupArray
constexpr int kOverworldMapPaletteIds
constexpr int kOverworldSpecialGfxGroup
constexpr int OverworldCustomSubscreenOverlayArray
Main namespace for the application.
Represents a group of palettes.
Represents a set of palettes used in a SNES graphics system.