housekeeping

This commit is contained in:
scawful
2022-07-08 23:52:11 -04:00
parent 260f9d5166
commit e9c8152453
10 changed files with 77 additions and 99 deletions

View File

@@ -138,7 +138,6 @@ void Editor::DrawYazeMenu() {
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
rom_.LoadFromFile(filePathName);
rom_data_ = (void *)rom_.data();
overworld_editor_.SetupROM(rom_);
}
ImGuiFileDialog::Instance()->Close();
@@ -217,7 +216,7 @@ void Editor::DrawViewMenu() {
if (show_memory_editor) {
static MemoryEditor mem_edit;
mem_edit.DrawWindow("Memory Editor", rom_data_, rom_.getSize());
mem_edit.DrawWindow("Memory Editor", (void *)rom_.data(), rom_.getSize());
}
if (show_imgui_demo) {
@@ -294,14 +293,14 @@ void Editor::DrawGraphicsSheet(int offset) {
surface->format->palette->colors[i].b = current_palette_[i].z * 255;
}
unsigned int snesAddr = 0;
unsigned int pcAddr = 0;
snesAddr = (unsigned int)((((rom_.data()[0x4F80 + offset]) << 16) |
unsigned int snes_addr = 0;
unsigned int pc_addr = 0;
snes_addr = (unsigned int)((((rom_.data()[0x4F80 + offset]) << 16) |
((rom_.data()[0x505F + offset]) << 8) |
((rom_.data()[0x513E + offset]))));
pcAddr = core::SnesToPc(snesAddr);
pc_addr = core::SnesToPc(snes_addr);
std::cout << "Decompressing..." << std::endl;
char *decomp = rom_.Decompress(pcAddr);
char *decomp = rom_.Decompress(pc_addr);
std::cout << "Converting to 8bpp sheet..." << std::endl;
sheet_buffer = rom_.SNES3bppTo8bppSheet((uchar *)decomp);
std::cout << "Assigning pixel data..." << std::endl;
@@ -360,10 +359,9 @@ void Editor::DrawProjectEditor() {
static bool opt_enable_context_menu = true;
static bool opt_enable_grid = true;
ImVec2 canvas_p0 = ImGui::GetCursorScreenPos();
// ImVec2 canvas_sz = ImGui::GetContentRegionAvail();
ImVec2 canvas_sz = ImVec2(
auto canvas_sz = ImVec2(
512 + 1, ImGui::GetContentRegionAvail().y + (tilesheet_offset * 256));
ImVec2 canvas_p1 =
auto canvas_p1 =
ImVec2(canvas_p0.x + canvas_sz.x, canvas_p0.y + canvas_sz.y);
// Draw border and background color
@@ -376,7 +374,6 @@ void Editor::DrawProjectEditor() {
ImGui::InvisibleButton(
"canvas", canvas_sz,
ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight);
const bool is_hovered = ImGui::IsItemHovered(); // Hovered
const bool is_active = ImGui::IsItemActive(); // Held
const ImVec2 origin(canvas_p0.x + scrolling.x,
canvas_p0.y + scrolling.y); // Lock scrolled origin

View File

@@ -42,7 +42,6 @@ class Editor {
void DrawScreenEditor();
void DrawHUDEditor();
void *rom_data_;
bool is_loaded_ = true;
app::rom::ROM rom_;

View File

@@ -10,11 +10,6 @@
#include "app/zelda3/overworld.h"
#include "gui/icons.h"
// first step would be to decompress all gfx data from the game
// (in alttp that's easy they're all located in the same location all the
// same sheet size 128x32) have a code that convert PC address to SNES and
// vice-versa
// 1) find the gfx pointers (you could use ZS constant file)
// 2) decompress all the gfx with your lz2 decompressor
// 3) convert the 3bpp snes data into PC 4bpp (probably the hardest part)
@@ -132,7 +127,6 @@ void OverworldEditor::DrawToolset() {
ImGui::TableNextColumn();
if (ImGui::Button(ICON_MD_UPDATE)) {
overworld_.Load(rom_, allGfx16Ptr);
LoadBlockset();
}
ImGui::EndTable();
@@ -280,6 +274,16 @@ void OverworldEditor::DrawOverworldCanvas() {
}
void OverworldEditor::DrawTileSelector() {
ImGui::Text("Palette:");
for (int i = 0; i < 8; i++) {
std::string id = "##PaletteColor" + std::to_string(i);
ImGui::SameLine();
ImGui::ColorEdit4(id.c_str(), &current_palette_[i].x,
ImGuiColorEditFlags_NoInputs |
ImGuiColorEditFlags_DisplayRGB |
ImGuiColorEditFlags_DisplayHex);
}
if (ImGui::BeginTabBar("##TabBar", ImGuiTabBarFlags_FittingPolicyScroll)) {
if (ImGui::BeginTabItem("Tile16")) {
bool child_is_visible =
@@ -399,8 +403,7 @@ void OverworldEditor::DrawTile8Selector() {
if (key >= 1) {
top_left_y = canvas_p0.y + 64 * key;
}
draw_list->AddImage((void *)value,
ImVec2(canvas_p0.x + 2, top_left_y),
draw_list->AddImage((void *)value, ImVec2(canvas_p0.x + 2, top_left_y),
ImVec2(canvas_p0.x + 256, canvas_p0.y + offset));
}
}
@@ -433,41 +436,6 @@ void OverworldEditor::DrawChangelist() {
ImGui::End();
}
void OverworldEditor::LoadBlockset() {
rom_.CreateAllGraphicsData(allGfx16Ptr);
for (int i = 0; i < 16; i++) {
staticgfx[i] = i;
}
// Update gfx to be on selected map
auto currentmapgfx8Data = current_gfx_ptr_;
auto allgfxData = allGfx16Ptr;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 2048; j++) {
auto mapByte = allgfxData[j + (staticgfx[i] * 2048)];
switch (i) {
case 0:
case 3:
case 4:
case 5:
mapByte += 0x88;
break;
}
currentmapgfx8Data[(i * 2048) + j] = mapByte; // Upload used gfx data
}
}
auto tiles = overworld_.GetTiles16();
app::gfx::BuildTiles16Gfx(tile16_blockset_ptr_, current_gfx_ptr_, tiles);
current_gfx_bmp_.Create(128, 512, 64, current_gfx_ptr_);
current_gfx_bmp_.CreateTexture(rom_.Renderer());
tile16_blockset_bmp_.Create(128, 8192, 8, tile16_blockset_ptr_);
tile16_blockset_bmp_.CreateTexture(rom_.Renderer());
map_blockset_loaded_ = true;
}
void OverworldEditor::LoadGraphics() {
for (int i = 0; i < kNumSheetsToLoad; i++) {
all_texture_sheet_[i] = rom_.DrawGraphicsSheet(i);
@@ -475,5 +443,5 @@ void OverworldEditor::LoadGraphics() {
}
} // namespace editor
} // namespace gui
} // namespace app
} // namespace yaze

View File

@@ -66,6 +66,8 @@ class OverworldEditor {
bool all_gfx_loaded_ = false;
bool map_blockset_loaded_ = false;
ImVec4 current_palette_[8];
constexpr static int kByteSize = 3;
constexpr static int kMessageIdSize = 5;
constexpr static int kNumSheetsToLoad = 100;