housekeeping, accessors, gui, etc

This commit is contained in:
scawful
2023-11-20 21:12:02 -05:00
parent 4ef2540d15
commit bbe76ac83c
12 changed files with 99 additions and 83 deletions

View File

@@ -14,6 +14,11 @@ namespace yaze {
namespace app { namespace app {
namespace editor { namespace editor {
using ImGui::TableHeadersRow;
using ImGui::TableNextColumn;
using ImGui::TableNextRow;
using ImGui::TableSetupColumn;
absl::Status DungeonEditor::Update() { absl::Status DungeonEditor::Update() {
if (!is_loaded_ && rom()->isLoaded()) { if (!is_loaded_ && rom()->isLoaded()) {
for (int i = 0; i < 0x100; i++) { for (int i = 0; i < 0x100; i++) {
@@ -29,14 +34,14 @@ absl::Status DungeonEditor::Update() {
ImGui::Separator(); ImGui::Separator();
if (ImGui::BeginTable("#DungeonEditTable", 3, toolset_table_flags_, if (ImGui::BeginTable("#DungeonEditTable", 3, toolset_table_flags_,
ImVec2(0, 0))) { ImVec2(0, 0))) {
ImGui::TableSetupColumn("Room Selector"); TableSetupColumn("Room Selector");
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch, TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x); ImGui::GetContentRegionAvail().x);
ImGui::TableSetupColumn("Object Selector"); TableSetupColumn("Object Selector");
ImGui::TableHeadersRow(); TableHeadersRow();
ImGui::TableNextRow(); TableNextRow();
ImGui::TableNextColumn(); TableNextColumn();
if (rom()->isLoaded()) { if (rom()->isLoaded()) {
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)9); if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)9);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true, ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
@@ -53,9 +58,9 @@ absl::Status DungeonEditor::Update() {
ImGui::EndChild(); ImGui::EndChild();
} }
ImGui::TableNextColumn(); TableNextColumn();
DrawDungeonTabView(); DrawDungeonTabView();
ImGui::TableNextColumn(); TableNextColumn();
DrawTileSelector(); DrawTileSelector();
ImGui::EndTable(); ImGui::EndTable();
} }

View File

@@ -59,7 +59,7 @@ absl::Status GfxGroupEditor::Update() {
ImGui::BeginGroup(); ImGui::BeginGroup();
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
int sheet_id = rom()->main_blockset_ids[selected_blockset_][i]; int sheet_id = rom()->main_blockset_ids[selected_blockset_][i];
auto &sheet = *rom()->BitmapManager()[sheet_id]; auto &sheet = *rom()->bitmap_manager()[sheet_id];
if (sheet_id != last_sheet_id_) { if (sheet_id != last_sheet_id_) {
last_sheet_id_ = sheet_id; last_sheet_id_ = sheet_id;
auto palette_group = rom()->GetPaletteGroup("ow_main"); auto palette_group = rom()->GetPaletteGroup("ow_main");
@@ -109,7 +109,7 @@ absl::Status GfxGroupEditor::Update() {
ImGui::BeginGroup(); ImGui::BeginGroup();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int sheet_id = rom()->room_blockset_ids[selected_roomset_][i]; int sheet_id = rom()->room_blockset_ids[selected_roomset_][i];
auto &sheet = *rom()->BitmapManager()[sheet_id]; auto &sheet = *rom()->bitmap_manager()[sheet_id];
core::BitmapCanvasPipeline(roomset_canvas_, sheet, 256, 0x10 * 0x04, core::BitmapCanvasPipeline(roomset_canvas_, sheet, 256, 0x10 * 0x04,
0x20, true, false, 23); 0x20, true, false, 23);
} }
@@ -152,7 +152,7 @@ absl::Status GfxGroupEditor::Update() {
ImGui::BeginGroup(); ImGui::BeginGroup();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int sheet_id = rom()->spriteset_ids[selected_spriteset_][i]; int sheet_id = rom()->spriteset_ids[selected_spriteset_][i];
auto sheet = *rom()->BitmapManager()[sheet_id]; auto sheet = *rom()->bitmap_manager()[sheet_id];
core::BitmapCanvasPipeline(spriteset_canvas_, sheet, 256, core::BitmapCanvasPipeline(spriteset_canvas_, sheet, 256,
0x10 * 0x04, 0x20, true, false, 24); 0x10 * 0x04, 0x20, true, false, 24);
} }

View File

@@ -120,7 +120,7 @@ absl::Status Tile16Editor::Update() {
if (transfer_started_ && !transfer_blockset_loaded_) { if (transfer_started_ && !transfer_blockset_loaded_) {
PRINT_IF_ERROR(transfer_rom_.LoadAllGraphicsData()) PRINT_IF_ERROR(transfer_rom_.LoadAllGraphicsData())
graphics_bin_ = transfer_rom_.GetGraphicsBin(); graphics_bin_ = transfer_rom_.graphics_bin();
// Load the Link to the Past overworld. // Load the Link to the Past overworld.
PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_)) PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_))

View File

@@ -27,6 +27,11 @@ namespace app {
namespace editor { namespace editor {
using ImGui::Separator; using ImGui::Separator;
using ImGui::TableHeadersRow;
using ImGui::TableNextColumn;
using ImGui::TableNextRow;
using ImGui::TableSetupColumn;
using ImGui::Text;
absl::Status OverworldEditor::Update() { absl::Status OverworldEditor::Update() {
// Initialize overworld graphics, maps, and palettes // Initialize overworld graphics, maps, and palettes
@@ -43,14 +48,14 @@ absl::Status OverworldEditor::Update() {
Separator(); Separator();
if (ImGui::BeginTable(kOWEditTable.data(), 2, kOWEditFlags, ImVec2(0, 0))) { if (ImGui::BeginTable(kOWEditTable.data(), 2, kOWEditFlags, ImVec2(0, 0))) {
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch, TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x); ImGui::GetContentRegionAvail().x);
ImGui::TableSetupColumn("Tile Selector"); TableSetupColumn("Tile Selector");
ImGui::TableHeadersRow(); TableHeadersRow();
ImGui::TableNextRow(); TableNextRow();
ImGui::TableNextColumn(); TableNextColumn();
DrawOverworldCanvas(); DrawOverworldCanvas();
ImGui::TableNextColumn(); TableNextColumn();
DrawTileSelector(); DrawTileSelector();
ImGui::EndTable(); ImGui::EndTable();
} }
@@ -103,22 +108,22 @@ absl::Status OverworldEditor::DrawToolset() {
BUTTON_COLUMN(ICON_MD_ADD_LOCATION) // Transports BUTTON_COLUMN(ICON_MD_ADD_LOCATION) // Transports
BUTTON_COLUMN(ICON_MD_MUSIC_NOTE) // Music BUTTON_COLUMN(ICON_MD_MUSIC_NOTE) // Music
ImGui::TableNextColumn(); TableNextColumn();
if (ImGui::Button(ICON_MD_GRID_VIEW)) { if (ImGui::Button(ICON_MD_GRID_VIEW)) {
show_tile16 = !show_tile16; show_tile16 = !show_tile16;
} }
ImGui::TableNextColumn(); TableNextColumn();
if (ImGui::Button(ICON_MD_TABLE_CHART)) { if (ImGui::Button(ICON_MD_TABLE_CHART)) {
show_gfx_group = !show_gfx_group; show_gfx_group = !show_gfx_group;
} }
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
ImGui::TableNextColumn(); // Palette TableNextColumn(); // Palette
palette_editor_.DisplayPalette(palette_, overworld_.isLoaded()); palette_editor_.DisplayPalette(palette_, overworld_.isLoaded());
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
ImGui::TableNextColumn(); // Experimental TableNextColumn(); // Experimental
ImGui::Checkbox("Experimental", &show_experimental); ImGui::Checkbox("Experimental", &show_experimental);
ImGui::EndTable(); ImGui::EndTable();
@@ -150,45 +155,46 @@ void OverworldEditor::DrawOverworldMapSettings() {
for (const auto &name : kOverworldSettingsColumnNames) for (const auto &name : kOverworldSettingsColumnNames)
ImGui::TableSetupColumn(name.data()); ImGui::TableSetupColumn(name.data());
ImGui::TableNextColumn(); TableNextColumn();
ImGui::SetNextItemWidth(100.f); ImGui::SetNextItemWidth(100.f);
ImGui::Combo("##world", &current_world_, kWorldList.data(), 3); ImGui::Combo("##world", &current_world_, kWorldList.data(), 3);
ImGui::TableNextColumn(); TableNextColumn();
ImGui::Text("GFX"); Text("GFX");
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(kInputFieldSize); ImGui::SetNextItemWidth(kInputFieldSize);
ImGui::InputText("##mapGFX", map_gfx_, kByteSize); ImGui::InputText("##mapGFX", map_gfx_, kByteSize);
ImGui::TableNextColumn(); TableNextColumn();
ImGui::Text("Palette"); Text("Palette");
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(kInputFieldSize); ImGui::SetNextItemWidth(kInputFieldSize);
ImGui::InputText("##mapPal", map_palette_, kByteSize); ImGui::InputText("##mapPal", map_palette_, kByteSize);
ImGui::TableNextColumn(); TableNextColumn();
ImGui::Text("Spr GFX"); Text("Spr GFX");
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(kInputFieldSize); ImGui::SetNextItemWidth(kInputFieldSize);
ImGui::InputText("##sprGFX", spr_gfx_, kByteSize); ImGui::InputText("##sprGFX", spr_gfx_, kByteSize);
ImGui::TableNextColumn(); TableNextColumn();
ImGui::Text("Spr Palette"); Text("Spr Palette");
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(kInputFieldSize); ImGui::SetNextItemWidth(kInputFieldSize);
ImGui::InputText("##sprPal", spr_palette_, kByteSize); ImGui::InputText("##sprPal", spr_palette_, kByteSize);
ImGui::TableNextColumn(); TableNextColumn();
ImGui::Text("Msg ID"); Text("Msg ID");
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(50.f); ImGui::SetNextItemWidth(50.f);
ImGui::InputText("##msgid", spr_palette_, kMessageIdSize); ImGui::InputText("##msgid", spr_palette_, kMessageIdSize);
ImGui::TableNextColumn(); TableNextColumn();
ImGui::SetNextItemWidth(100.f); ImGui::SetNextItemWidth(100.f);
ImGui::Combo("##world", &game_state_, "Part 0\0Part 1\0Part 2\0", 3); // ImGui::Combo("##world", &game_state_, "Part 0\0Part 1\0Part 2\0", 3);
ImGui::Combo("##World", &game_state_, kGamePartComboString, 3);
ImGui::TableNextColumn(); TableNextColumn();
ImGui::Checkbox("Show grid", &opt_enable_grid); // TODO ImGui::Checkbox("Show grid", &opt_enable_grid); // TODO
ImGui::EndTable(); ImGui::EndTable();
} }
@@ -214,7 +220,7 @@ void OverworldEditor::DrawOverworldEntrances(ImVec2 canvas_p0,
if (ImGui::BeginDragDropSource()) { if (ImGui::BeginDragDropSource()) {
ImGui::SetDragDropPayload("ENTRANCE_PAYLOAD", &each, ImGui::SetDragDropPayload("ENTRANCE_PAYLOAD", &each,
sizeof(zelda3::OverworldEntrance)); sizeof(zelda3::OverworldEntrance));
ImGui::Text("Moving Entrance ID: %s", str.c_str()); Text("Moving Entrance ID: %s", str.c_str());
ImGui::EndDragDropSource(); ImGui::EndDragDropSource();
} }
} else if (is_dragging_entrance_ && dragged_entrance_ == &each && } else if (is_dragging_entrance_ && dragged_entrance_ == &each &&
@@ -412,7 +418,7 @@ void OverworldEditor::DrawTile8Selector() {
graphics_bin_canvas_.DrawContextMenu(); graphics_bin_canvas_.DrawContextMenu();
if (all_gfx_loaded_) { if (all_gfx_loaded_) {
// for (const auto &[key, value] : graphics_bin_) { // for (const auto &[key, value] : graphics_bin_) {
for (auto &[key, value] : rom()->BitmapManager()) { for (auto &[key, value] : rom()->bitmap_manager()) {
int offset = 0x40 * (key + 1); int offset = 0x40 * (key + 1);
int top_left_y = graphics_bin_canvas_.GetZeroPoint().y + 2; int top_left_y = graphics_bin_canvas_.GetZeroPoint().y + 2;
if (key >= 1) { if (key >= 1) {
@@ -465,7 +471,7 @@ void OverworldEditor::DrawTileSelector() {
absl::Status OverworldEditor::LoadGraphics() { absl::Status OverworldEditor::LoadGraphics() {
// Load all of the graphics data from the game. // Load all of the graphics data from the game.
PRINT_IF_ERROR(rom()->LoadAllGraphicsData()) PRINT_IF_ERROR(rom()->LoadAllGraphicsData())
graphics_bin_ = rom()->GetGraphicsBin(); graphics_bin_ = rom()->graphics_bin();
// Load the Link to the Past overworld. // Load the Link to the Past overworld.
RETURN_IF_ERROR(overworld_.Load(*rom())) RETURN_IF_ERROR(overworld_.Load(*rom()))
@@ -549,12 +555,12 @@ absl::Status OverworldEditor::DrawExperimentalModal() {
ImGui::Begin("Experimental", &show_experimental); ImGui::Begin("Experimental", &show_experimental);
gui::TextWithSeparators("PROTOTYPE OVERWORLD TILEMAP LOADER"); gui::TextWithSeparators("PROTOTYPE OVERWORLD TILEMAP LOADER");
ImGui::Text("Please provide two files:"); Text("Please provide two files:");
ImGui::Text("One based on MAPn.DAT, which represents the overworld tilemap"); Text("One based on MAPn.DAT, which represents the overworld tilemap");
ImGui::Text("One based on MAPDATn.DAT, which is the tile32 configurations."); Text("One based on MAPDATn.DAT, which is the tile32 configurations.");
ImGui::Text("Currently, loading CGX for this component is NOT supported. "); Text("Currently, loading CGX for this component is NOT supported. ");
ImGui::Text("Please load a US ROM of LTTP (JP ROM support coming soon)."); Text("Please load a US ROM of LTTP (JP ROM support coming soon).");
ImGui::Text( Text(
"Once you've loaded the files, you can click the button below to load " "Once you've loaded the files, you can click the button below to load "
"the tilemap into the editor"); "the tilemap into the editor");

View File

@@ -51,7 +51,10 @@ constexpr ImGuiTableFlags kOWEditFlags = ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Resizable | ImGuiTableFlags_Resizable |
ImGuiTableFlags_SizingStretchSame; ImGuiTableFlags_SizingStretchSame;
constexpr absl::string_view kWorldList = "Light World\0Dark World\0Extra World"; constexpr absl::string_view kWorldList =
"Light World\0Dark World\0Extra World\0";
constexpr char *const kGamePartComboString[] = {"Part 0", "Part 1", "Part 2"};
constexpr absl::string_view kTileSelectorTab = "##TileSelectorTabBar"; constexpr absl::string_view kTileSelectorTab = "##TileSelectorTabBar";
constexpr absl::string_view kOWEditTable = "##OWEditTable"; constexpr absl::string_view kOWEditTable = "##OWEditTable";

View File

@@ -399,14 +399,14 @@ class ROM : public core::ExperimentFlags {
changes_.push(function); changes_.push(function);
} }
VersionConstants GetVersionConstants() const { VersionConstants version_constants() const {
return kVersionConstantsMap.at(version_); return kVersionConstantsMap.at(version_);
} }
int GetGraphicsAddress(const uchar* data, uint8_t addr) const { int GetGraphicsAddress(const uchar* data, uint8_t addr) const {
auto part_one = data[GetVersionConstants().kOverworldGfxPtr1 + addr] << 16; auto part_one = data[version_constants().kOverworldGfxPtr1 + addr] << 16;
auto part_two = data[GetVersionConstants().kOverworldGfxPtr2 + addr] << 8; auto part_two = data[version_constants().kOverworldGfxPtr2 + addr] << 8;
auto part_three = data[GetVersionConstants().kOverworldGfxPtr3 + addr]; auto part_three = data[version_constants().kOverworldGfxPtr3 + addr];
auto snes_addr = (part_one | part_two | part_three); auto snes_addr = (part_one | part_two | part_three);
return core::SnesToPc(snes_addr); return core::SnesToPc(snes_addr);
} }
@@ -414,8 +414,10 @@ class ROM : public core::ExperimentFlags {
gfx::PaletteGroup GetPaletteGroup(const std::string& group) { gfx::PaletteGroup GetPaletteGroup(const std::string& group) {
return palette_groups_[group]; return palette_groups_[group];
} }
Bytes GetGraphicsBuffer() const { return graphics_buffer_; }
gfx::BitmapTable GetGraphicsBin() const { return graphics_bin_; } Bytes graphics_buffer() const { return graphics_buffer_; }
gfx::BitmapTable graphics_bin() const { return graphics_bin_; }
auto title() const { return title_; } auto title() const { return title_; }
auto size() const { return size_; } auto size() const { return size_; }
@@ -477,7 +479,7 @@ class ROM : public core::ExperimentFlags {
bitmap->UpdateTexture(renderer_); bitmap->UpdateTexture(renderer_);
} }
auto BitmapManager() { return graphics_manager_; } auto bitmap_manager() { return graphics_manager_; }
std::vector<std::vector<uint8_t>> main_blockset_ids; std::vector<std::vector<uint8_t>> main_blockset_ids;
std::vector<std::vector<uint8_t>> room_blockset_ids; std::vector<std::vector<uint8_t>> room_blockset_ids;
@@ -510,16 +512,14 @@ class ROM : public core::ExperimentFlags {
for (int i = 0; i < 144; i++) { for (int i = 0; i < 144; i++) {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
spriteset_ids[i][j] = spriteset_ids[i][j] =
rom_data_[GetVersionConstants().kSpriteBlocksetPointer + (i * 4) + rom_data_[version_constants().kSpriteBlocksetPointer + (i * 4) + j];
j];
} }
} }
for (int i = 0; i < 72; i++) { for (int i = 0; i < 72; i++) {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
paletteset_ids[i][j] = paletteset_ids[i][j] =
rom_data_[GetVersionConstants().kDungeonPalettesGroups + (i * 4) + rom_data_[version_constants().kDungeonPalettesGroups + (i * 4) + j];
j];
} }
} }
} }
@@ -544,14 +544,14 @@ class ROM : public core::ExperimentFlags {
for (int i = 0; i < 144; i++) { for (int i = 0; i < 144; i++) {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
rom_data_[GetVersionConstants().kSpriteBlocksetPointer + (i * 4) + j] = rom_data_[version_constants().kSpriteBlocksetPointer + (i * 4) + j] =
spriteset_ids[i][j]; spriteset_ids[i][j];
} }
} }
for (int i = 0; i < 72; i++) { for (int i = 0; i < 72; i++) {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
rom_data_[GetVersionConstants().kDungeonPalettesGroups + (i * 4) + j] = rom_data_[version_constants().kDungeonPalettesGroups + (i * 4) + j] =
paletteset_ids[i][j]; paletteset_ids[i][j];
} }
} }

View File

@@ -165,7 +165,7 @@ void Room::LoadRoomGraphics(uchar entrance_blockset) {
blocks[12 + i] = (uchar)(spriteGfx[SpriteTileset + 64][i] + 115); blocks[12 + i] = (uchar)(spriteGfx[SpriteTileset + 64][i] + 115);
} // 12-16 sprites } // 12-16 sprites
auto gfx_buffer_data = rom()->GetGraphicsBuffer(); auto gfx_buffer_data = rom()->graphics_buffer();
// Into "room gfx16" 16 of them // Into "room gfx16" 16 of them
int sheetPos = 0; int sheetPos = 0;
@@ -173,7 +173,6 @@ void Room::LoadRoomGraphics(uchar entrance_blockset) {
int d = 0; int d = 0;
int ioff = blocks[i] * 2048; int ioff = blocks[i] * 2048;
while (d < 2048) { while (d < 2048) {
// NOTE LOAD BLOCKSETS SOMEWHERE FIRST
uchar mapByte = gfx_buffer_data[d + ioff]; uchar mapByte = gfx_buffer_data[d + ioff];
if (i < 4) { if (i < 4) {
mapByte += 0x88; mapByte += 0x88;
@@ -191,9 +190,9 @@ void Room::LoadRoomGraphics(uchar entrance_blockset) {
void Room::LoadAnimatedGraphics() { void Room::LoadAnimatedGraphics() {
int gfx_ptr = int gfx_ptr =
core::SnesToPc(rom()->GetVersionConstants().kGfxAnimatedPointer); core::SnesToPc(rom()->version_constants().kGfxAnimatedPointer);
auto gfx_buffer_data = rom()->GetGraphicsBuffer(); auto gfx_buffer_data = rom()->graphics_buffer();
auto rom_data = rom()->vector(); auto rom_data = rom()->vector();
int data = 0; int data = 0;
while (data < 512) { while (data < 512) {

View File

@@ -26,7 +26,7 @@ class DungeonObjectRenderer {
}; };
void CreateVramFromRoomBlockset() { void CreateVramFromRoomBlockset() {
// auto bitmap_manager = rom()->BitmapManager(); // auto bitmap_manager = rom()->bitmap_manager();
// uint16_t room_id = 0; // uint16_t room_id = 0;
// auto room_blockset = rom()->room_blockset_ids[room_id]; // auto room_blockset = rom()->room_blockset_ids[room_id];

View File

@@ -588,7 +588,7 @@ absl::Status Overworld::SaveMap32Tiles() {
for (int i = 0; i < num_32x32_tiles; ++i) { for (int i = 0; i < num_32x32_tiles; ++i) {
int base_addr = int base_addr =
rom()->GetVersionConstants().kMap32TileTL + i * kQuadrantsPer32x32Tile; rom()->version_constants().kMap32TileTL + i * kQuadrantsPer32x32Tile;
auto write_quadrant_to_rom = [&](int quadrant, auto write_quadrant_to_rom = [&](int quadrant,
auto get_tile) -> absl::Status { auto get_tile) -> absl::Status {
@@ -630,10 +630,10 @@ absl::Status Overworld::SaveMap32Tiles() {
uint16_t Overworld::GenerateTile32(int index, int quadrant, int dimension) { uint16_t Overworld::GenerateTile32(int index, int quadrant, int dimension) {
// The addresses of the four 32x32 pixel tiles in the ROM. // The addresses of the four 32x32 pixel tiles in the ROM.
const uint32_t map32address[4] = {rom()->GetVersionConstants().kMap32TileTL, const uint32_t map32address[4] = {rom()->version_constants().kMap32TileTL,
rom()->GetVersionConstants().kMap32TileTR, rom()->version_constants().kMap32TileTR,
rom()->GetVersionConstants().kMap32TileBL, rom()->version_constants().kMap32TileBL,
rom()->GetVersionConstants().kMap32TileBR}; rom()->version_constants().kMap32TileBR};
return (ushort)(rom_[map32address[dimension] + quadrant + (index)] + return (ushort)(rom_[map32address[dimension] + quadrant + (index)] +
(((rom_[map32address[dimension] + (index) + (((rom_[map32address[dimension] + (index) +
@@ -727,10 +727,10 @@ absl::Status Overworld::DecompressAllMapTiles() {
for (int i = 0; i < 160; i++) { for (int i = 0; i < 160; i++) {
auto p1 = GetOwMapGfxHighPtr( auto p1 = GetOwMapGfxHighPtr(
rom()->data(), i, rom()->data(), i,
rom()->GetVersionConstants().kCompressedAllMap32PointersHigh); rom()->version_constants().kCompressedAllMap32PointersHigh);
auto p2 = GetOwMapGfxLowPtr( auto p2 = GetOwMapGfxLowPtr(
rom()->data(), i, rom()->data(), i,
rom()->GetVersionConstants().kCompressedAllMap32PointersLow); rom()->version_constants().kCompressedAllMap32PointersLow);
int ttpos = 0; int ttpos = 0;
if (p1 >= highest) { if (p1 >= highest) {

View File

@@ -209,6 +209,9 @@ class Overworld : public SharedROM, public core::ExperimentFlags {
auto isLoaded() const { return is_loaded_; } auto isLoaded() const { return is_loaded_; }
void SetCurrentMap(int i) { current_map_ = i; } void SetCurrentMap(int i) { current_map_ = i; }
auto MapTiles() const { return map_tiles_; }
auto mutable_map_tiles() { return &map_tiles_; }
absl::Status LoadPrototype(ROM &rom_, const std::string &tilemap_filename); absl::Status LoadPrototype(ROM &rom_, const std::string &tilemap_filename);
private: private:

View File

@@ -286,7 +286,7 @@ void OverworldMap::LoadSpritesBlocksets() {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
static_graphics_[12 + i] = static_graphics_[12 + i] =
(rom_[rom_.GetVersionConstants().kSpriteBlocksetPointer + (rom_[rom_.version_constants().kSpriteBlocksetPointer +
(sprite_graphics_[game_state_] * 4) + i] + (sprite_graphics_[game_state_] * 4) + i] +
static_graphics_base); static_graphics_base);
} }
@@ -294,14 +294,14 @@ void OverworldMap::LoadSpritesBlocksets() {
void OverworldMap::LoadMainBlocksets() { void OverworldMap::LoadMainBlocksets() {
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
static_graphics_[i] = rom_[rom_.GetVersionConstants().kOverworldGfxGroups2 + static_graphics_[i] = rom_[rom_.version_constants().kOverworldGfxGroups2 +
(world_index_ * 8) + i]; (world_index_ * 8) + i];
} }
} }
void OverworldMap::LoadAreaGraphicsBlocksets() { void OverworldMap::LoadAreaGraphicsBlocksets() {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
uchar value = rom_[rom_.GetVersionConstants().kOverworldGfxGroups1 + uchar value = rom_[rom_.version_constants().kOverworldGfxGroups1 +
(area_graphics_ * 4) + i]; (area_graphics_ * 4) + i];
if (value != 0) { if (value != 0) {
static_graphics_[3 + i] = value; static_graphics_[3 + i] = value;
@@ -330,7 +330,7 @@ void OverworldMap::LoadAreaGraphics() {
gfx::SNESPalette OverworldMap::GetPalette(const std::string& group, int index, gfx::SNESPalette OverworldMap::GetPalette(const std::string& group, int index,
int previousIndex, int limit) { int previousIndex, int limit) {
if (index == 255) { if (index == 255) {
index = rom_[rom_.GetVersionConstants().overworldMapPaletteGroup + index = rom_[rom_.version_constants().overworldMapPaletteGroup +
(previousIndex * 4)]; (previousIndex * 4)];
} }
if (index != 255) { if (index != 255) {
@@ -351,11 +351,11 @@ void OverworldMap::LoadPalette() {
area_palette_ = std::min(area_palette_, 0xA3); area_palette_ = std::min(area_palette_, 0xA3);
uchar pal0 = 0; uchar pal0 = 0;
uchar pal1 = rom_[rom_.GetVersionConstants().overworldMapPaletteGroup + uchar pal1 = rom_[rom_.version_constants().overworldMapPaletteGroup +
(area_palette_ * 4)]; (area_palette_ * 4)];
uchar pal2 = rom_[rom_.GetVersionConstants().overworldMapPaletteGroup + uchar pal2 = rom_[rom_.version_constants().overworldMapPaletteGroup +
(area_palette_ * 4) + 1]; (area_palette_ * 4) + 1];
uchar pal3 = rom_[rom_.GetVersionConstants().overworldMapPaletteGroup + uchar pal3 = rom_[rom_.version_constants().overworldMapPaletteGroup +
(area_palette_ * 4) + 2]; (area_palette_ * 4) + 2];
uchar pal4 = uchar pal4 =
rom_[overworldSpritePaletteGroup + (sprite_palette_[game_state_] * 2)]; rom_[overworldSpritePaletteGroup + (sprite_palette_[game_state_] * 2)];
@@ -369,7 +369,7 @@ void OverworldMap::LoadPalette() {
// Additional handling of `pal3` and `parent_` // Additional handling of `pal3` and `parent_`
if (pal3 == 255) { if (pal3 == 255) {
pal3 = rom_[rom_.GetVersionConstants().overworldMapPaletteGroup + pal3 = rom_[rom_.version_constants().overworldMapPaletteGroup +
(previousPalId * 4) + 2]; (previousPalId * 4) + 2];
} }
if (parent_ < 0x40) { if (parent_ < 0x40) {
@@ -416,7 +416,7 @@ void OverworldMap::ProcessGraphicsBuffer(int index, int static_graphics_offset,
} }
absl::Status OverworldMap::BuildTileset() { absl::Status OverworldMap::BuildTileset() {
all_gfx_ = rom_.GetGraphicsBuffer(); all_gfx_ = rom_.graphics_buffer();
current_gfx_.resize(0x10000, 0x00); current_gfx_.resize(0x10000, 0x00);
for (int i = 0; i < 0x10; i++) { for (int i = 0; i < 0x10; i++) {

View File

@@ -171,7 +171,7 @@ class Decompress : public CommandHandler {
// auto rom_filename = arg_vec[1]; // auto rom_filename = arg_vec[1];
// RETURN_IF_ERROR(rom_.LoadFromFile(arg, true)) // RETURN_IF_ERROR(rom_.LoadFromFile(arg, true))
// RETURN_IF_ERROR(rom_.LoadAllGraphicsData()) // RETURN_IF_ERROR(rom_.LoadAllGraphicsData())
// for (auto& graphic_sheet : rom_.GetGraphicsBin()) { // for (auto& graphic_sheet : rom_.graphics_bin()) {
// const auto filename = // const auto filename =
// absl::StrCat(rom_.filename(), graphic_sheet.first); // absl::StrCat(rom_.filename(), graphic_sheet.first);
// graphic_sheet.second.SaveSurfaceToFile(filename); // graphic_sheet.second.SaveSurfaceToFile(filename);