diff --git a/src/app/core/controller.h b/src/app/core/controller.h index 98fd27c6..63360c74 100644 --- a/src/app/core/controller.h +++ b/src/app/core/controller.h @@ -57,6 +57,7 @@ class Controller : public ExperimentFlags { } auto window() -> SDL_Window * { return window_.get(); } void init_test_editor(editor::Editor *editor) { test_editor_ = editor; } + void set_active(bool active) { active_ = active; } private: friend int ::main(int argc, char **argv); diff --git a/src/app/editor/graphics/tile16_editor.cc b/src/app/editor/graphics/tile16_editor.cc index 37af4157..14235564 100644 --- a/src/app/editor/graphics/tile16_editor.cc +++ b/src/app/editor/graphics/tile16_editor.cc @@ -367,7 +367,6 @@ absl::Status Tile16Editor::UpdateTransferTileCanvas() { // TODO: Implement tile16 transfer if (transfer_started_ && !transfer_blockset_loaded_) { PRINT_IF_ERROR(transfer_rom_.LoadAllGraphicsData()) - graphics_bin_ = transfer_rom_.graphics_bin(); // Load the Link to the Past overworld. PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_)) diff --git a/src/app/rom.cc b/src/app/rom.cc index 653835c6..062c25b7 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -123,20 +123,19 @@ absl::Status Rom::LoadAllGraphicsData() { graphics_manager_.LoadBitmap(i, converted_sheet, core::kTilesheetWidth, core::kTilesheetHeight, core::kTilesheetDepth); - if (i > 115) { - // Apply sprites palette - RETURN_IF_ERROR(graphics_manager_[i].ApplyPaletteWithTransparent( - palette_groups_.global_sprites[0], 0)); - } else { - RETURN_IF_ERROR(graphics_manager_[i].ApplyPaletteWithTransparent( - palette_groups_.dungeon_main[0], 0)); + if (graphics_manager_[i].is_active()) { + if (i > 115) { + // Apply sprites palette + RETURN_IF_ERROR(graphics_manager_[i].ApplyPaletteWithTransparent( + palette_groups_.global_sprites[0], 0)); + } else { + RETURN_IF_ERROR(graphics_manager_[i].ApplyPaletteWithTransparent( + palette_groups_.dungeon_main[0], 0)); + } + graphics_manager_[i].CreateTexture(Renderer::GetInstance().renderer()); } - graphics_manager_[i].CreateTexture(Renderer::GetInstance().renderer()); + } - graphics_bin_[i] = - gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight, - core::kTilesheetDepth, converted_sheet); - graphics_bin_.at(i).CreateTexture(Renderer::GetInstance().renderer()); if (flags()->kUseBitmapManager) { for (int j = 0; j < graphics_manager_[i].size(); ++j) { @@ -144,7 +143,7 @@ absl::Status Rom::LoadAllGraphicsData() { } } } else { - for (int j = 0; j < graphics_bin_[0].size(); ++j) { + for (int j = 0; j < graphics_manager_[0].size(); ++j) { graphics_buffer_.push_back(0xFF); } } diff --git a/src/app/rom.h b/src/app/rom.h index 3c6f0c22..02cd7ab6 100644 --- a/src/app/rom.h +++ b/src/app/rom.h @@ -409,10 +409,6 @@ class Rom : public core::ExperimentFlags { // Full graphical data for the game Bytes graphics_buffer() const { return graphics_buffer_; } - [[deprecated]] gfx::BitmapTable graphics_bin() const { return graphics_bin_; } - [[deprecated]] gfx::Bitmap* mutable_graphics_sheet(int index) { - return &graphics_bin_.at(index); - } [[deprecated]] auto bitmap_manager() { return graphics_manager_; } [[deprecated]] auto mutable_bitmap_manager() { return &graphics_manager_; } @@ -524,7 +520,6 @@ class Rom : public core::ExperimentFlags { std::array graphics_sheets_; Z3_Version version_ = Z3_Version::US; - gfx::BitmapTable graphics_bin_; [[deprecated("BitmapManager has unpredictable destructor behavior.")]] gfx:: BitmapManager graphics_manager_; diff --git a/src/app/zelda3/dungeon/object_renderer.cc b/src/app/zelda3/dungeon/object_renderer.cc index 5e030162..3478fda1 100644 --- a/src/app/zelda3/dungeon/object_renderer.cc +++ b/src/app/zelda3/dungeon/object_renderer.cc @@ -106,7 +106,6 @@ void DungeonObjectRenderer::RenderObject(const SubtypeInfo& info) { uint8_t opcode = cpu.ReadByte(cpu.PB << 16 | cpu.PC); cpu.ExecuteInstruction(opcode); - i++; } @@ -138,10 +137,11 @@ void DungeonObjectRenderer::UpdateObjectBitmap() { int x = column * 8; int y = row * 8; - auto sheet = rom()->mutable_graphics_sheet(vram_.sheets[sheet_number]); + auto sheet = + rom()->mutable_bitmap_manager()->at(vram_.sheets[sheet_number]); // Copy the tile from VRAM using the read tile_id - sheet->Get8x8Tile(tile_id, x, y, tilemap_, tilemap_offset); + sheet.Get8x8Tile(tile_id, x, y, tilemap_, tilemap_offset); } bitmap_.Create(256, 256, 8, tilemap_); diff --git a/src/cli/command_handler.h b/src/cli/command_handler.h index 4bd0a677..89ba2a2c 100644 --- a/src/cli/command_handler.h +++ b/src/cli/command_handler.h @@ -191,21 +191,9 @@ class Decompress : public CommandHandler { std::string sheet_input; std::cin >> sheet_input; - // Batch Mode - // if (arg_vec.size() == 1) { - // auto rom_filename = arg_vec[1]; - // RETURN_IF_ERROR(rom_.LoadFromFile(arg, true)) - // RETURN_IF_ERROR(rom_.LoadAllGraphicsData()) - // for (auto& graphic_sheet : rom_.graphics_bin()) { - // const auto filename = - // absl::StrCat(rom_.filename(), graphic_sheet.first); - // graphic_sheet.second.SaveSurfaceToFile(filename); - // } - // } - std::cout << "Decompress selected with argument: " << arg_vec[0] << std::endl; - return absl::OkStatus(); + return absl::UnimplementedError("Decompress not implemented"); } };