6#include <unordered_map>
14#include "imgui/imgui.h"
22 : index_(index), parent_(index), rom_(rom) {
25 if (load_custom_data) {
29 if (asm_version == 0x00) {
38 std::vector<gfx::Tile16>& tiles16,
47 }
else if (
index_ == 0x88) {
65 return absl::OkStatus();
96 }
else if (
index_ < 0x80) {
111 }
else if (
index_ == 0x95) {
113 }
else if (
index_ == 0x96) {
115 }
else if (
index_ == 0x97) {
117 }
else if (
index_ == 0x9C) {
119 }
else if (
index_ == 0x9D) {
121 }
else if (
index_ == 0x9E) {
123 }
else if (
index_ == 0x9F) {
125 }
else if (
index_ == 0x88) {
137 }
else if (
index_ == 0x88) {
170 }
else if (
index_ == 0x88) {
178 int indexWorld = 0x20;
188 const auto overworld_gfx_groups2 =
193 for (
int i = 0; i < 8; i++) {
195 (uint8_t)
rom_[overworld_gfx_groups2 + (indexWorld * 8) + i];
252 }
else if (
index_ == 0x5B)
256 }
else if (
index_ == 0x80)
272 if (asm_version >= 0x01 && asm_version != 0xFF) {
273 for (
int i = 0; i < 8; i++) {
280 int indexWorld = 0x20;
292 for (
int i = 0; i < 8; i++) {
295 (indexWorld * 8) + i];
298 const auto overworldgfxGroups =
358 int static_graphics_base = 0x73;
364 for (
int i = 0; i < 4; i++) {
368 static_graphics_base);
373 for (
int i = 0; i < 8; i++) {
386 std::cout <<
"static_graphics_[6] = "
388 std::cout <<
"static_graphics_[7] = "
390 std::cout <<
"static_graphics_[8] = "
403 for (
int i = 0; i < 4; i++) {
434namespace palette_internal {
445 std::vector<gfx::SnesColor> new_palette(256);
449 for (
int y = 2; y < 7; y++) {
450 for (
int x = 1; x < 8; x++) {
451 new_palette[x + (16 * y)] =
main[k];
457 for (
int x = 1; x < 8; x++) {
458 new_palette[(16 * 7) + (x)] = animated[(x - 1)];
465 for (
int y = 2; y < 5; y++) {
466 for (
int x = 9; x < 16; x++) {
467 new_palette[x + (16 * y)] = aux1[k];
474 for (
int y = 5; y < 8; y++) {
475 for (
int x = 9; x < 16; x++) {
476 new_palette[x + (16 * y)] = aux2[k];
482 for (
int i = 0; i < 32; i++) {
483 new_palette[i] = hud[i];
487 for (
int i = 0; i < 8; i++) {
488 new_palette[(i * 16)] = bgrcolor;
489 new_palette[(i * 16) + 8] = bgrcolor;
494 for (
int y = 8; y < 9; y++) {
495 for (
int x = 1; x < 8; x++) {
497 new_palette[x + (16 * y)] = pal_group[1][k];
504 for (
int y = 8; y < 9; y++) {
505 for (
int x = 9; x < 16; x++) {
507 new_palette[x + (16 * y)] = pal_group[0][k];
514 for (
int y = 9; y < 13; y++) {
515 for (
int x = 1; x < 16; x++) {
517 new_palette[x + (16 * y)] = pal_group[0][k];
524 for (
int y = 13; y < 14; y++) {
525 for (
int x = 1; x < 8; x++) {
526 new_palette[x + (16 * y)] = spr[k];
533 for (
int y = 14; y < 15; y++) {
534 for (
int x = 1; x < 8; x++) {
535 new_palette[x + (16 * y)] = spr2[k];
542 for (
int y = 15; y < 16; y++) {
543 for (
int x = 1; x < 16; x++) {
545 new_palette[x + (16 * y)] = pal_group[0][k];
550 current.
Create(new_palette);
551 for (
int i = 0; i < 256; i++) {
552 current[(i / 16) * 16].set_transparent(
true);
555 return absl::OkStatus();
565 (previous_index * 4)];
567 if (index >= limit) {
570 return palette_group[index];
575 int previousSprPalId =
597 GetPalette(ow_aux_pal_group, pal1, previousPalId, 20));
599 GetPalette(ow_aux_pal_group, pal2, previousPalId, 20));
604 (previousPalId * 4) + 2];
624 GetPalette(ow_main_pal_group, pal0, previousPalId, 255));
627 GetPalette(ow_animated_pal_group, std::min((
int)pal3, 13),
635 previousSprPalId, 24));
638 previousSprPalId, 24));
649 return absl::OkStatus();
655 for (
int i = 0; i < size; i++) {
656 auto byte =
all_gfx_[i + (static_graphics_offset * size)];
673 for (
int i = 0; i < 0x10; i++) {
677 return absl::OkStatus();
684 const int offsets[] = {0x00, 0x08, 0x400, 0x408};
688 for (
auto i = 0; i < count; i++) {
689 for (
auto tile = 0; tile < 0x04; tile++) {
691 int offset = offsets[tile];
692 for (
auto y = 0; y < 0x08; ++y) {
693 for (
auto x = 0; x < 0x08; ++x) {
705 int xpos = ((info.
id_ % 0x10) * 0x08);
706 int ypos = (((info.
id_ / 0x10)) * 0x400);
707 int source = ypos + xpos + (x + (y * 0x80));
709 auto destination = xx + yy + offset + (mx + (my * 0x80));
723 return absl::OkStatus();
729 std::vector<uint8_t>& blockset) {
731 ((tile - ((tile / 0x08) * 0x08)) * 0x10) + ((tile / 0x08) * 2048);
732 int dest_pos = (x + (y * 0x200));
733 for (
int yy = 0; yy < 0x10; yy++) {
734 for (
int xx = 0; xx < 0x10; xx++) {
735 bitmap[dest_pos + xx + (yy * 0x200)] =
736 blockset[src_pos + xx + (yy * 0x80)];
748 for (
int i = 0; i < 0x40000; i++) {
753 int superX =
index_ - (
world_ * 0x40) - (superY * 0x08);
755 for (
int y = 0; y < 0x20; y++) {
756 for (
int x = 0; x < 0x20; x++) {
757 auto xt = x + (superX * 0x20);
758 auto yt = y + (superY * 0x20);
759 CopyTile8bpp16((x * 0x10), (y * 0x10), world_blockset[xt][yt],
763 return absl::OkStatus();
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)
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.
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.