Update ExperimentFlags interface
This commit is contained in:
@@ -7,6 +7,8 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace core {
|
||||
|
||||
std::shared_ptr<ExperimentFlags::Flags> ExperimentFlags::flags_;
|
||||
|
||||
uint32_t SnesToPc(uint32_t addr) {
|
||||
if (addr >= 0x808000) {
|
||||
addr -= 0x808000;
|
||||
|
||||
@@ -10,15 +10,30 @@ namespace app {
|
||||
namespace core {
|
||||
|
||||
class ExperimentFlags {
|
||||
private:
|
||||
public:
|
||||
struct Flags {
|
||||
bool kDrawOverworldSprites = false;
|
||||
bool kUseBitmapManager = false;
|
||||
};
|
||||
Flags flags_;
|
||||
|
||||
public:
|
||||
auto flags() const { return flags_; }
|
||||
Flags *mutable_flags() { return &flags_; }
|
||||
ExperimentFlags() = default;
|
||||
virtual ~ExperimentFlags() = default;
|
||||
auto flags() const {
|
||||
if (!flags_) {
|
||||
flags_ = std::make_shared<Flags>();
|
||||
}
|
||||
Flags *flags = flags_.get();
|
||||
return flags;
|
||||
}
|
||||
Flags *mutable_flags() {
|
||||
if (!flags_) {
|
||||
flags_ = std::make_shared<Flags>();
|
||||
}
|
||||
return flags_.get();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Flags> flags_;
|
||||
};
|
||||
|
||||
uint32_t SnesToPc(uint32_t addr);
|
||||
|
||||
@@ -199,8 +199,11 @@ void MasterEditor::DrawFileMenu() {
|
||||
|
||||
if (ImGui::BeginMenu("Options")) {
|
||||
ImGui::MenuItem("Backup ROM", "", &backup_rom_);
|
||||
ImGui::Separator();
|
||||
ImGui::Checkbox("Enable Overworld Sprites",
|
||||
&mutable_flags()->kDrawOverworldSprites);
|
||||
ImGui::Checkbox("Use Bitmap Manager",
|
||||
&mutable_flags()->kUseBitmapManager);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
|
||||
@@ -390,7 +390,7 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
DrawOverworldMaps();
|
||||
DrawOverworldEntrances(ow_map_canvas_.GetZeroPoint(),
|
||||
ow_map_canvas_.Scrolling());
|
||||
if (flags().kDrawOverworldSprites) {
|
||||
if (flags()->kDrawOverworldSprites) {
|
||||
DrawOverworldSprites();
|
||||
}
|
||||
CheckForOverworldEdits();
|
||||
@@ -520,7 +520,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
maps_bmp_[i], palette);
|
||||
}
|
||||
|
||||
if (flags().kDrawOverworldSprites) {
|
||||
if (flags()->kDrawOverworldSprites) {
|
||||
LoadSpriteGraphics();
|
||||
}
|
||||
|
||||
|
||||
@@ -244,17 +244,37 @@ absl::Status ROM::LoadAllGraphicsData() {
|
||||
|
||||
if (bpp3) {
|
||||
auto converted_sheet = gfx::SnesTo8bppSheet(sheet, 3);
|
||||
graphics_bin_[i] =
|
||||
gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight,
|
||||
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
|
||||
graphics_bin_.at(i).CreateTexture(renderer_);
|
||||
if (flags()->kUseBitmapManager) {
|
||||
graphics_manager_.LoadBitmap(i, converted_sheet, core::kTilesheetWidth,
|
||||
core::kTilesheetHeight,
|
||||
core::kTilesheetDepth);
|
||||
graphics_manager_[i]->CreateTexture(renderer_);
|
||||
|
||||
for (int j = 0; j < graphics_bin_.at(i).size(); ++j) {
|
||||
graphics_buffer_.push_back(graphics_bin_.at(i).at(j));
|
||||
} else {
|
||||
graphics_bin_[i] =
|
||||
gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight,
|
||||
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
|
||||
graphics_bin_.at(i).CreateTexture(renderer_);
|
||||
}
|
||||
|
||||
if (flags()->kUseBitmapManager) {
|
||||
for (int j = 0; j < graphics_manager_[i].get()->size(); ++j) {
|
||||
graphics_buffer_.push_back(graphics_manager_[i]->at(j));
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < graphics_bin_[i].size(); ++j) {
|
||||
graphics_buffer_.push_back(graphics_bin_.at(i).at(j));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < graphics_bin_.at(0).size(); ++j) {
|
||||
graphics_buffer_.push_back(0xFF);
|
||||
if (flags()->kUseBitmapManager) {
|
||||
for (int j = 0; j < graphics_manager_[i].get()->size(); ++j) {
|
||||
graphics_buffer_.push_back(0xFF);
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < graphics_bin_[0].size(); ++j) {
|
||||
graphics_buffer_.push_back(0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/string_view.h" // for string_view
|
||||
#include "app/core/common.h" // for SnesToPc
|
||||
#include "app/core/constants.h" // for Bytes, uchar, armorPalettes
|
||||
#include "app/gfx/bitmap.h" // for Bitmap, BitmapTable
|
||||
#include "app/core/common.h"
|
||||
#include "app/core/constants.h" // for Bytes, uchar, armorPalettes
|
||||
#include "app/gfx/bitmap.h" // for Bitmap, BitmapTable
|
||||
#include "app/gfx/compression.h"
|
||||
#include "app/gfx/snes_palette.h" // for PaletteGroup, SNESColor
|
||||
#include "app/gfx/snes_tile.h"
|
||||
@@ -132,7 +132,7 @@ struct WriteAction {
|
||||
value;
|
||||
};
|
||||
|
||||
class ROM {
|
||||
class ROM : public core::ExperimentFlags {
|
||||
public:
|
||||
template <typename... Args>
|
||||
absl::Status RunTransaction(Args... args) {
|
||||
@@ -464,6 +464,8 @@ class ROM {
|
||||
bitmap->UpdateTexture(renderer_);
|
||||
}
|
||||
|
||||
auto BitmapManager() const { return graphics_manager_; }
|
||||
|
||||
std::vector<std::vector<uint8_t>> main_blockset_ids;
|
||||
std::vector<std::vector<uint8_t>> room_blockset_ids;
|
||||
std::vector<std::vector<uint8_t>> spriteset_ids;
|
||||
@@ -555,6 +557,7 @@ class ROM {
|
||||
|
||||
Z3_Version version_ = Z3_Version::US;
|
||||
gfx::BitmapTable graphics_bin_;
|
||||
gfx::BitmapManager graphics_manager_;
|
||||
gfx::BitmapTable link_graphics_;
|
||||
gfx::SNESPalette link_palette_;
|
||||
PaletteGroupMap palette_groups_;
|
||||
|
||||
@@ -140,7 +140,7 @@ absl::Status Overworld::Load(ROM &rom) {
|
||||
FetchLargeMaps();
|
||||
LoadEntrances();
|
||||
RETURN_IF_ERROR(LoadOverworldMaps())
|
||||
if (flags().kDrawOverworldSprites) {
|
||||
if (flags()->kDrawOverworldSprites) {
|
||||
LoadSprites();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user