5#include <unordered_map>
18 : index_(index), parent_(index), rom_(rom) {
21 if (load_custom_data) {
25 if (asm_version == 0x00) {
34 std::vector<gfx::Tile16>& tiles16,
43 }
else if (
index_ == 0x88) {
61 return absl::OkStatus();
92 }
else if (
index_ < 0x80) {
107 }
else if (
index_ == 0x95) {
109 }
else if (
index_ == 0x96) {
111 }
else if (
index_ == 0x97) {
113 }
else if (
index_ == 0x9C) {
115 }
else if (
index_ == 0x9D) {
117 }
else if (
index_ == 0x9E) {
119 }
else if (
index_ == 0x9F) {
121 }
else if (
index_ == 0x88) {
133 }
else if (
index_ == 0x88) {
166 }
else if (
index_ == 0x88) {
174 int indexWorld = 0x20;
184 const auto overworld_gfx_groups2 =
189 for (
int i = 0; i < 8; i++) {
191 (uint8_t)
rom_[overworld_gfx_groups2 + (indexWorld * 8) + i];
248 }
else if (
index_ == 0x5B)
252 }
else if (
index_ == 0x80)
268 if (asm_version >= 0x01 && asm_version != 0xFF) {
269 for (
int i = 0; i < 8; i++) {
276 int indexWorld = 0x20;
288 for (
int i = 0; i < 8; i++) {
291 (indexWorld * 8) + i];
294 const auto overworldgfxGroups =
354 int static_graphics_base = 0x73;
360 for (
int i = 0; i < 4; i++) {
364 static_graphics_base);
369 for (
int i = 0; i < 8; i++) {
382 std::cout <<
"static_graphics_[6] = "
384 std::cout <<
"static_graphics_[7] = "
386 std::cout <<
"static_graphics_[8] = "
399 for (
int i = 0; i < 4; i++) {
430namespace palette_internal {
441 std::vector<gfx::SnesColor> new_palette(256);
445 for (
int y = 2; y < 7; y++) {
446 for (
int x = 1; x < 8; x++) {
447 new_palette[x + (16 * y)] =
main[k];
453 for (
int x = 1; x < 8; x++) {
454 new_palette[(16 * 7) + (x)] = animated[(x - 1)];
461 for (
int y = 2; y < 5; y++) {
462 for (
int x = 9; x < 16; x++) {
463 new_palette[x + (16 * y)] = aux1[k];
470 for (
int y = 5; y < 8; y++) {
471 for (
int x = 9; x < 16; x++) {
472 new_palette[x + (16 * y)] = aux2[k];
478 for (
int i = 0; i < 32; i++) {
479 new_palette[i] = hud[i];
483 for (
int i = 0; i < 8; i++) {
484 new_palette[(i * 16)] = bgrcolor;
485 new_palette[(i * 16) + 8] = bgrcolor;
490 for (
int y = 8; y < 9; y++) {
491 for (
int x = 1; x < 8; x++) {
493 new_palette[x + (16 * y)] = pal_group[1][k];
500 for (
int y = 8; y < 9; y++) {
501 for (
int x = 9; x < 16; x++) {
503 new_palette[x + (16 * y)] = pal_group[0][k];
510 for (
int y = 9; y < 13; y++) {
511 for (
int x = 1; x < 16; x++) {
513 new_palette[x + (16 * y)] = pal_group[0][k];
520 for (
int y = 13; y < 14; y++) {
521 for (
int x = 1; x < 8; x++) {
522 new_palette[x + (16 * y)] = spr[k];
529 for (
int y = 14; y < 15; y++) {
530 for (
int x = 1; x < 8; x++) {
531 new_palette[x + (16 * y)] = spr2[k];
538 for (
int y = 15; y < 16; y++) {
539 for (
int x = 1; x < 16; x++) {
541 new_palette[x + (16 * y)] = pal_group[0][k];
546 current.
Create(new_palette);
547 for (
int i = 0; i < 256; i++) {
548 current[(i / 16) * 16].set_transparent(
true);
551 return absl::OkStatus();
561 (previous_index * 4)];
563 if (index >= limit) {
566 return palette_group[index];
572 int previousSprPalId =
594 GetPalette(ow_aux_pal_group, pal1, previousPalId, 20));
596 GetPalette(ow_aux_pal_group, pal2, previousPalId, 20));
601 (previousPalId * 4) + 2];
621 GetPalette(ow_main_pal_group, pal0, previousPalId, 255));
624 GetPalette(ow_animated_pal_group, std::min((
int)pal3, 13),
632 previousSprPalId, 24));
635 previousSprPalId, 24));
646 return absl::OkStatus();
652 for (
int i = 0; i < size; i++) {
653 auto byte =
all_gfx_[i + (static_graphics_offset * size)];
670 for (
int i = 0; i < 0x10; i++) {
674 return absl::OkStatus();
681 const int offsets[] = {0x00, 0x08, 0x400, 0x408};
685 for (
auto i = 0; i < count; i++) {
686 for (
auto tile = 0; tile < 0x04; tile++) {
688 int offset = offsets[tile];
689 for (
auto y = 0; y < 0x08; ++y) {
690 for (
auto x = 0; x < 0x08; ++x) {
702 int xpos = ((info.
id_ % 0x10) * 0x08);
703 int ypos = (((info.
id_ / 0x10)) * 0x400);
704 int source = ypos + xpos + (x + (y * 0x80));
706 auto destination = xx + yy + offset + (mx + (my * 0x80));
720 return absl::OkStatus();
728 for (
int i = 0; i < 0x40000; i++) {
733 int superX =
index_ - (
world_ * 0x40) - (superY * 0x08);
735 for (
int y = 0; y < 0x20; y++) {
736 for (
int x = 0; x < 0x20; x++) {
737 auto xt = x + (superX * 0x20);
738 auto yt = y + (superY * 0x20);
743 return absl::OkStatus();
static std::unordered_map< uint8_t, gfx::Paletteset > palettesets_
The Rom class is used to load, save, and modify Rom data.
VersionConstants version_constants() const
std::vector< uint8_t > graphics_buffer() const
uint16_t toint16(int offset)
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.
absl::Status BuildTiles16Gfx(std::vector< gfx::Tile16 > &tiles16, int count)
void LoadDeathMountainGFX()
uchar static_graphics_[16]
absl::Status BuildTileset()
void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size)
absl::Status LoadPalette()
std::vector< uint8_t > current_gfx_
uint8_t custom_gfx_ids_[8]
std::vector< uint8_t > bitmap_data_
uchar sprite_graphics_[3]
void SetupCustomTileset(uint8_t asm_version)
void LoadAreaGraphicsBlocksets()
uint16_t subscreen_overlay_
absl::StatusOr< gfx::SnesPalette > GetPalette(const gfx::PaletteGroup &group, int index, int previous_index, int limit)
absl::Status BuildBitmap(OWBlockset &world_blockset)
void LoadSpritesBlocksets()
std::vector< uint8_t > all_gfx_
gfx::SnesPalette current_palette_
absl::Status BuildMap(int count, int game_state, int world, std::vector< gfx::Tile16 > &tiles16, OWBlockset &world_blockset)
std::vector< uint8_t > current_blockset_
void LoadCustomOverworldData()
void LoadMainBlocksetId()
#define RETURN_IF_ERROR(expression)
#define ASSIGN_OR_RETURN(type_variable_name, expression)
int main(int argc, char **argv)
Main entry point for the application.
std::string UppercaseHexByte(uint8_t byte, bool leading)
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 overworldSpritePaletteGroup
constexpr int overworldSpriteset
constexpr int kAreaGfxIdPtr
constexpr int OverworldCustomAnimatedGFXArray
constexpr int OverworldCustomASMHasBeenApplied
constexpr int kOverworldMapPaletteIds
constexpr int kNumOverworldMaps
constexpr int overworldMapSize
constexpr int overworldMusicDW
constexpr int overworldMusicMasterSword
constexpr int overworldMusicBegining
constexpr int kOverworldSpritePaletteIds
constexpr int overworldMusicZelda
constexpr int overworldSpecialGFXGroup
constexpr int OverworldCustomTileGFXGroupArray
constexpr int overworldMusicAgahim
constexpr int overworldSpecialPALGroup
constexpr int OverworldCustomMosaicArray
constexpr int OverworldCustomMainPaletteArray
constexpr int OverworldCustomSubscreenOverlayArray
constexpr int kOverworldMessageIds
std::vector< std::vector< uint16_t > > OWBlockset
Represents tile32 data for the overworld.
uint32_t kOverworldGfxGroups2
uint32_t kOverworldGfxGroups1
uint32_t overworldMapPaletteGroup
Represents a group of palettes.
Represents a set of palettes used in a SNES graphics system.