Add BitmapCanvasPipeline, more CgxViewer updates
This commit is contained in:
@@ -9,11 +9,47 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "app/core/common.h"
|
||||||
|
#include "app/gfx/bitmap.h"
|
||||||
|
#include "app/gfx/snes_palette.h"
|
||||||
|
#include "app/gui/canvas.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
|
void ButtonPipe(absl::string_view button_text, std::function<void()> callback) {
|
||||||
|
if (ImGui::Button(button_text.data())) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitmapCanvasPipeline(int width, int height, int tile_size, int canvas_id,
|
||||||
|
bool is_loaded, gfx::Bitmap& bitmap) {
|
||||||
|
gui::Canvas canvas;
|
||||||
|
|
||||||
|
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)canvas_id);
|
||||||
|
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||||
|
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||||
|
canvas.DrawBackground(ImVec2(width + 1, height + 1));
|
||||||
|
canvas.DrawContextMenu();
|
||||||
|
canvas.DrawBitmap(bitmap, 2, is_loaded);
|
||||||
|
canvas.DrawTileSelector(tile_size);
|
||||||
|
canvas.DrawGrid(tile_size);
|
||||||
|
canvas.DrawOverlay();
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BuildAndRenderBitmapPipeline(int width, int height, int depth, Bytes data,
|
||||||
|
ROM& z3_rom, gfx::Bitmap& bitmap,
|
||||||
|
gfx::SNESPalette& palette) {
|
||||||
|
bitmap.Create(width, height, depth, data);
|
||||||
|
bitmap.ApplyPalette(palette);
|
||||||
|
z3_rom.RenderBitmap(&bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
void FileDialogPipeline(absl::string_view display_key,
|
void FileDialogPipeline(absl::string_view display_key,
|
||||||
absl::string_view file_extensions,
|
absl::string_view file_extensions,
|
||||||
std::optional<absl::string_view> button_text,
|
std::optional<absl::string_view> button_text,
|
||||||
|
|||||||
@@ -10,11 +10,24 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "app/core/constants.h"
|
||||||
|
#include "app/gfx/bitmap.h"
|
||||||
|
#include "app/gfx/snes_palette.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
|
void ButtonPipe(absl::string_view button_text, std::function<void()> callback);
|
||||||
|
|
||||||
|
void BitmapCanvasPipeline(int width, int height, int tile_size, int canvas_id,
|
||||||
|
bool is_loaded, gfx::Bitmap& bitmap);
|
||||||
|
|
||||||
|
void BuildAndRenderBitmapPipeline(int width, int height, int depth, Bytes data,
|
||||||
|
ROM& z3_rom, gfx::Bitmap& bitmap,
|
||||||
|
gfx::SNESPalette& palette);
|
||||||
|
|
||||||
void FileDialogPipeline(absl::string_view display_key,
|
void FileDialogPipeline(absl::string_view display_key,
|
||||||
absl::string_view file_extensions,
|
absl::string_view file_extensions,
|
||||||
std::optional<absl::string_view> button_text,
|
std::optional<absl::string_view> button_text,
|
||||||
|
|||||||
@@ -30,9 +30,10 @@ absl::Status GraphicsEditor::Update() {
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_TABLE("#gfxEditTable", 3, kGfxEditFlags)
|
BEGIN_TABLE("#gfxEditTable", 4, kGfxEditFlags)
|
||||||
SETUP_COLUMN("Graphics (BIN, CGX, SCR)")
|
SETUP_COLUMN("Graphics (BIN, CGX, SCR)")
|
||||||
SETUP_COLUMN("Palette (COL)")
|
SETUP_COLUMN("Palette (COL)")
|
||||||
|
SETUP_COLUMN("Maps and Animations (SCR, PNL)")
|
||||||
SETUP_COLUMN("Preview")
|
SETUP_COLUMN("Preview")
|
||||||
TABLE_HEADERS()
|
TABLE_HEADERS()
|
||||||
NEXT_COLUMN()
|
NEXT_COLUMN()
|
||||||
@@ -44,13 +45,16 @@ absl::Status GraphicsEditor::Update() {
|
|||||||
NEXT_COLUMN()
|
NEXT_COLUMN()
|
||||||
status_ = DrawPaletteControls();
|
status_ = DrawPaletteControls();
|
||||||
|
|
||||||
|
NEXT_COLUMN()
|
||||||
|
core::BitmapCanvasPipeline(0x200, 0x200, 0x20, 6, scr_loaded_, cgx_bitmap_);
|
||||||
|
|
||||||
NEXT_COLUMN()
|
NEXT_COLUMN()
|
||||||
if (super_donkey_) {
|
if (super_donkey_) {
|
||||||
status_ = DrawGraphicsBin();
|
status_ = DrawGraphicsBin();
|
||||||
} else if (cgx_loaded_ && col_file_) {
|
} else if (cgx_loaded_ && col_file_) {
|
||||||
status_ = DrawCgxViewer();
|
core::BitmapCanvasPipeline(0x100, 16384, 0x20, 5, cgx_loaded_, cgx_bitmap_);
|
||||||
} else {
|
} else {
|
||||||
status_ = DrawDecompressedData();
|
core::BitmapCanvasPipeline(0x100, 16384, 0x20, 2, gfx_loaded_, bitmap_);
|
||||||
}
|
}
|
||||||
END_TABLE()
|
END_TABLE()
|
||||||
|
|
||||||
@@ -66,7 +70,11 @@ absl::Status GraphicsEditor::DrawToolset() {
|
|||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (ImGui::Button(ICON_MD_MEMORY)) {
|
if (ImGui::Button(ICON_MD_MEMORY)) {
|
||||||
open_memory_editor_ = true;
|
if (!open_memory_editor_) {
|
||||||
|
open_memory_editor_ = true;
|
||||||
|
} else {
|
||||||
|
open_memory_editor_ = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEXT_COLUMN("Open Memory Editor") // Separator
|
TEXT_COLUMN("Open Memory Editor") // Separator
|
||||||
@@ -81,21 +89,31 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
|||||||
|
|
||||||
ImGui::InputText("##CGXFile", cgx_file_name_, sizeof(cgx_file_name_));
|
ImGui::InputText("##CGXFile", cgx_file_name_, sizeof(cgx_file_name_));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
core::FileDialogPipeline("ImportCgxKey", ".CGX,.cgx\0", "Open CGX", [&]() {
|
|
||||||
strncpy(cgx_file_path_,
|
core::FileDialogPipeline(
|
||||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
"ImportCgxKey", ".CGX,.cgx\0", "Open CGX", [&]() -> auto {
|
||||||
sizeof(cgx_file_path_));
|
strncpy(cgx_file_path_,
|
||||||
strncpy(cgx_file_name_,
|
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
sizeof(cgx_file_path_));
|
||||||
sizeof(cgx_file_name_));
|
strncpy(cgx_file_name_,
|
||||||
RETURN_IF_ERROR(temp_rom_.LoadFromFile(cgx_file_path_, /*z3_load=*/false))
|
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||||
cgx_viewer_.LoadCgx(temp_rom_);
|
sizeof(cgx_file_name_));
|
||||||
auto all_tiles_data = cgx_viewer_.GetCgxData();
|
status_ = temp_rom_.LoadFromFile(cgx_file_path_, /*z3_load=*/false);
|
||||||
cgx_bitmap_.Create(core::kTilesheetWidth, 8192, core::kTilesheetDepth,
|
cgx_viewer_.LoadCgx(temp_rom_);
|
||||||
all_tiles_data.data(), all_tiles_data.size());
|
auto all_tiles_data = cgx_viewer_.GetCgxData();
|
||||||
is_open_ = true;
|
cgx_bitmap_.Create(core::kTilesheetWidth, 8192, core::kTilesheetDepth,
|
||||||
cgx_loaded_ = true;
|
all_tiles_data.data(), all_tiles_data.size());
|
||||||
});
|
if (col_file_) {
|
||||||
|
cgx_bitmap_.ApplyPalette(col_file_palette_);
|
||||||
|
rom_.RenderBitmap(&cgx_bitmap_);
|
||||||
|
}
|
||||||
|
is_open_ = true;
|
||||||
|
cgx_loaded_ = true;
|
||||||
|
});
|
||||||
|
core::ButtonPipe("Copy File Path",
|
||||||
|
[&]() -> auto { ImGui::SetClipboardText(cgx_file_path_); });
|
||||||
|
|
||||||
|
CLEAR_AND_RETURN_STATUS(status_)
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,26 +127,18 @@ absl::Status GraphicsEditor::DrawFileImport() {
|
|||||||
|
|
||||||
ImGui::InputText("##ROMFile", file_path_, sizeof(file_path_));
|
ImGui::InputText("##ROMFile", file_path_, sizeof(file_path_));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
// Open the file dialog when the user clicks the "Browse" button
|
|
||||||
if (ImGui::Button("Open BIN")) {
|
|
||||||
ImGuiFileDialog::Instance()->OpenDialog("ImportDlgKey", "Choose File",
|
|
||||||
".bin,.hex\0", ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the file dialog
|
core::FileDialogPipeline(
|
||||||
if (ImGuiFileDialog::Instance()->Display("ImportDlgKey")) {
|
"ImportDlgKey", ".bin,.hex\0", "Open BIN", [&]() -> auto {
|
||||||
// If the user made a selection, copy the filename to the file_path_ buffer
|
strncpy(file_path_,
|
||||||
if (ImGuiFileDialog::Instance()->IsOk()) {
|
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||||
strncpy(file_path_,
|
sizeof(file_path_));
|
||||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
status_ = temp_rom_.LoadFromFile(file_path_);
|
||||||
sizeof(file_path_));
|
is_open_ = true;
|
||||||
RETURN_IF_ERROR(temp_rom_.LoadFromFile(file_path_))
|
});
|
||||||
is_open_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the modal
|
core::ButtonPipe("Copy File Path",
|
||||||
ImGuiFileDialog::Instance()->Close();
|
[&]() -> auto { ImGui::SetClipboardText(file_path_); });
|
||||||
}
|
|
||||||
|
|
||||||
gui::InputHex("Offset", ¤t_offset_);
|
gui::InputHex("Offset", ¤t_offset_);
|
||||||
gui::InputHex("Size ", &size);
|
gui::InputHex("Size ", &size);
|
||||||
@@ -150,32 +160,23 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
|
|||||||
ImGui::InputText("##ColFile", col_file_name_, sizeof(col_file_name_));
|
ImGui::InputText("##ColFile", col_file_name_, sizeof(col_file_name_));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::Button("Open COL")) {
|
core::FileDialogPipeline(
|
||||||
ImGuiFileDialog::Instance()->OpenDialog("ImportColKey", "Choose File",
|
"ImportColKey", ".COL,.col,.BAK,.bak\0", "Open COL", [&]() -> auto {
|
||||||
".COL,.col", ".");
|
strncpy(col_file_path_,
|
||||||
}
|
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||||
|
sizeof(col_file_path_));
|
||||||
|
strncpy(col_file_name_,
|
||||||
|
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||||
|
sizeof(col_file_name_));
|
||||||
|
status_ = temp_rom_.LoadFromFile(col_file_path_, /*z3_load=*/false);
|
||||||
|
auto col_data_ = gfx::GetColFileData(temp_rom_.data());
|
||||||
|
col_file_palette_ = gfx::SNESPalette(col_data_);
|
||||||
|
col_file_ = true;
|
||||||
|
is_open_ = true;
|
||||||
|
});
|
||||||
|
|
||||||
if (ImGuiFileDialog::Instance()->Display("ImportColKey")) {
|
core::ButtonPipe("Copy File Path",
|
||||||
if (ImGuiFileDialog::Instance()->IsOk()) {
|
[&]() -> auto { ImGui::SetClipboardText(col_file_path_); });
|
||||||
strncpy(col_file_path_,
|
|
||||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
|
||||||
sizeof(col_file_path_));
|
|
||||||
strncpy(col_file_name_,
|
|
||||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
|
||||||
sizeof(col_file_name_));
|
|
||||||
RETURN_IF_ERROR(temp_rom_.LoadFromFile(col_file_path_, /*z3_load=*/false))
|
|
||||||
auto col_data_ = gfx::GetColFileData(temp_rom_.data());
|
|
||||||
col_file_palette_ = gfx::SNESPalette(col_data_);
|
|
||||||
col_file_ = true;
|
|
||||||
is_open_ = true;
|
|
||||||
|
|
||||||
if (cgx_loaded_) {
|
|
||||||
cgx_bitmap_.ApplyPalette(col_file_palette_);
|
|
||||||
rom_.RenderBitmap(&cgx_bitmap_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGuiFileDialog::Instance()->Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rom_.isLoaded()) {
|
if (rom_.isLoaded()) {
|
||||||
gui::TextWithSeparators("ROM Palette");
|
gui::TextWithSeparators("ROM Palette");
|
||||||
@@ -185,7 +186,6 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (col_file_palette_.size() != 0) {
|
if (col_file_palette_.size() != 0) {
|
||||||
ImGuiFileDialog::Instance()->prDrawFileListView(ImVec2(0, 200));
|
|
||||||
palette_editor_.DrawPortablePalette(col_file_palette_);
|
palette_editor_.DrawPortablePalette(col_file_palette_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,36 +231,6 @@ absl::Status GraphicsEditor::DrawMemoryEditor() {
|
|||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status GraphicsEditor::DrawCgxViewer() {
|
|
||||||
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)5);
|
|
||||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
|
||||||
import_canvas_.DrawBackground(ImVec2(0x100 + 1, (8192 * 2) + 1));
|
|
||||||
import_canvas_.DrawContextMenu();
|
|
||||||
import_canvas_.DrawBitmap(cgx_bitmap_, 2, cgx_loaded_);
|
|
||||||
import_canvas_.DrawTileSelector(32);
|
|
||||||
import_canvas_.DrawGrid(32.0f);
|
|
||||||
import_canvas_.DrawOverlay();
|
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
|
||||||
return absl::OkStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
absl::Status GraphicsEditor::DrawDecompressedData() {
|
|
||||||
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)2);
|
|
||||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
|
||||||
import_canvas_.DrawBackground(ImVec2(0x100 + 1, (8192 * 2) + 1));
|
|
||||||
import_canvas_.DrawContextMenu();
|
|
||||||
import_canvas_.DrawBitmap(bitmap_, 2, gfx_loaded_);
|
|
||||||
import_canvas_.DrawTileSelector(32);
|
|
||||||
import_canvas_.DrawGrid(32.0f);
|
|
||||||
import_canvas_.DrawOverlay();
|
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
|
||||||
return absl::OkStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
absl::Status GraphicsEditor::DrawGraphicsBin() {
|
absl::Status GraphicsEditor::DrawGraphicsBin() {
|
||||||
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)3);
|
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)3);
|
||||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||||
@@ -276,7 +246,7 @@ absl::Status GraphicsEditor::DrawGraphicsBin() {
|
|||||||
top_left_y = super_donkey_canvas_.GetZeroPoint().y + 0x40 * key;
|
top_left_y = super_donkey_canvas_.GetZeroPoint().y + 0x40 * key;
|
||||||
}
|
}
|
||||||
super_donkey_canvas_.GetDrawList()->AddImage(
|
super_donkey_canvas_.GetDrawList()->AddImage(
|
||||||
(void*)value.GetTexture(),
|
(void*)value.texture(),
|
||||||
ImVec2(super_donkey_canvas_.GetZeroPoint().x + 2, top_left_y),
|
ImVec2(super_donkey_canvas_.GetZeroPoint().x + 2, top_left_y),
|
||||||
ImVec2(super_donkey_canvas_.GetZeroPoint().x + 0x100,
|
ImVec2(super_donkey_canvas_.GetZeroPoint().x + 0x100,
|
||||||
super_donkey_canvas_.GetZeroPoint().y + offset));
|
super_donkey_canvas_.GetZeroPoint().y + offset));
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
|
#include "app/core/pipeline.h"
|
||||||
#include "app/editor/palette_editor.h"
|
#include "app/editor/palette_editor.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
@@ -70,8 +71,6 @@ class GraphicsEditor {
|
|||||||
absl::Status DrawClipboardImport();
|
absl::Status DrawClipboardImport();
|
||||||
absl::Status DrawExperimentalFeatures();
|
absl::Status DrawExperimentalFeatures();
|
||||||
absl::Status DrawMemoryEditor();
|
absl::Status DrawMemoryEditor();
|
||||||
absl::Status DrawCgxViewer();
|
|
||||||
absl::Status DrawDecompressedData();
|
|
||||||
absl::Status DrawGraphicsBin();
|
absl::Status DrawGraphicsBin();
|
||||||
|
|
||||||
absl::Status DecompressImportData(int size);
|
absl::Status DecompressImportData(int size);
|
||||||
@@ -89,6 +88,7 @@ class GraphicsEditor {
|
|||||||
bool super_donkey_ = false;
|
bool super_donkey_ = false;
|
||||||
bool col_file_ = false;
|
bool col_file_ = false;
|
||||||
bool cgx_loaded_ = false;
|
bool cgx_loaded_ = false;
|
||||||
|
bool scr_loaded_ = false;
|
||||||
|
|
||||||
char file_path_[256] = "";
|
char file_path_[256] = "";
|
||||||
char col_file_path_[256] = "";
|
char col_file_path_[256] = "";
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
|
#include "app/core/pipeline.h"
|
||||||
#include "app/editor/assembly_editor.h"
|
#include "app/editor/assembly_editor.h"
|
||||||
#include "app/editor/dungeon_editor.h"
|
#include "app/editor/dungeon_editor.h"
|
||||||
#include "app/editor/graphics_editor.h"
|
#include "app/editor/graphics_editor.h"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
|
#include "app/core/pipeline.h"
|
||||||
#include "app/editor/palette_editor.h"
|
#include "app/editor/palette_editor.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
@@ -210,7 +211,7 @@ void OverworldEditor::DrawOverworldCanvas() {
|
|||||||
if (overworld_.isLoaded()) {
|
if (overworld_.isLoaded()) {
|
||||||
DrawOverworldMaps();
|
DrawOverworldMaps();
|
||||||
DrawOverworldEntrances();
|
DrawOverworldEntrances();
|
||||||
DrawOverworldSprites();
|
// DrawOverworldSprites();
|
||||||
// User has selected a tile they want to draw from the blockset.
|
// User has selected a tile they want to draw from the blockset.
|
||||||
if (!blockset_canvas_.Points().empty()) {
|
if (!blockset_canvas_.Points().empty()) {
|
||||||
int x = blockset_canvas_.Points().front().x / 32;
|
int x = blockset_canvas_.Points().front().x / 32;
|
||||||
@@ -232,19 +233,6 @@ void OverworldEditor::DrawOverworldCanvas() {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Tile 16 Selector
|
|
||||||
// Displays all the tiles in the game.
|
|
||||||
void OverworldEditor::DrawTile16Selector() {
|
|
||||||
blockset_canvas_.DrawBackground(ImVec2(0x100 + 1, (8192 * 2) + 1));
|
|
||||||
blockset_canvas_.DrawContextMenu();
|
|
||||||
blockset_canvas_.DrawBitmap(tile16_blockset_bmp_, 2, map_blockset_loaded_);
|
|
||||||
blockset_canvas_.DrawTileSelector(32);
|
|
||||||
blockset_canvas_.DrawGrid(32.0f);
|
|
||||||
blockset_canvas_.DrawOverlay();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Tile 8 Selector
|
// Tile 8 Selector
|
||||||
// Displays all the individual tiles that make up a tile16.
|
// Displays all the individual tiles that make up a tile16.
|
||||||
void OverworldEditor::DrawTile8Selector() {
|
void OverworldEditor::DrawTile8Selector() {
|
||||||
@@ -259,7 +247,7 @@ void OverworldEditor::DrawTile8Selector() {
|
|||||||
top_left_y = graphics_bin_canvas_.GetZeroPoint().y + 0x40 * key;
|
top_left_y = graphics_bin_canvas_.GetZeroPoint().y + 0x40 * key;
|
||||||
}
|
}
|
||||||
graphics_bin_canvas_.GetDrawList()->AddImage(
|
graphics_bin_canvas_.GetDrawList()->AddImage(
|
||||||
(void *)value.GetTexture(),
|
(void *)value.texture(),
|
||||||
ImVec2(graphics_bin_canvas_.GetZeroPoint().x + 2, top_left_y),
|
ImVec2(graphics_bin_canvas_.GetZeroPoint().x + 2, top_left_y),
|
||||||
ImVec2(graphics_bin_canvas_.GetZeroPoint().x + 0x100,
|
ImVec2(graphics_bin_canvas_.GetZeroPoint().x + 0x100,
|
||||||
graphics_bin_canvas_.GetZeroPoint().y + offset));
|
graphics_bin_canvas_.GetZeroPoint().y + offset));
|
||||||
@@ -271,29 +259,12 @@ void OverworldEditor::DrawTile8Selector() {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Displays the graphics tilesheets that are available on the current selected
|
|
||||||
// overworld map.
|
|
||||||
void OverworldEditor::DrawAreaGraphics() {
|
|
||||||
current_gfx_canvas_.DrawBackground(ImVec2(256 + 1, 0x10 * 0x40 + 1));
|
|
||||||
current_gfx_canvas_.DrawContextMenu();
|
|
||||||
current_gfx_canvas_.DrawTileSelector(32);
|
|
||||||
current_gfx_canvas_.DrawBitmap(current_gfx_bmp_, 2, overworld_.isLoaded());
|
|
||||||
current_gfx_canvas_.DrawGrid(32.0f);
|
|
||||||
current_gfx_canvas_.DrawOverlay();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void OverworldEditor::DrawTileSelector() {
|
void OverworldEditor::DrawTileSelector() {
|
||||||
if (ImGui::BeginTabBar(kTileSelectorTab.data(),
|
if (ImGui::BeginTabBar(kTileSelectorTab.data(),
|
||||||
ImGuiTabBarFlags_FittingPolicyScroll)) {
|
ImGuiTabBarFlags_FittingPolicyScroll)) {
|
||||||
if (ImGui::BeginTabItem("Tile16")) {
|
if (ImGui::BeginTabItem("Tile16")) {
|
||||||
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)2);
|
core::BitmapCanvasPipeline(0x100, (8192 * 2), 0x20, 1,
|
||||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
map_blockset_loaded_, tile16_blockset_bmp_);
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
|
||||||
DrawTile16Selector();
|
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginTabItem("Tile8")) {
|
if (ImGui::BeginTabItem("Tile8")) {
|
||||||
@@ -306,12 +277,8 @@ void OverworldEditor::DrawTileSelector() {
|
|||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginTabItem("Area Graphics")) {
|
if (ImGui::BeginTabItem("Area Graphics")) {
|
||||||
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)3);
|
core::BitmapCanvasPipeline(256, 0x10 * 0x40, 0x20, 3,
|
||||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
overworld_.isLoaded(), current_gfx_bmp_);
|
||||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
|
||||||
DrawAreaGraphics();
|
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
@@ -328,14 +295,16 @@ absl::Status OverworldEditor::LoadGraphics() {
|
|||||||
// 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_))
|
||||||
palette_ = overworld_.AreaPalette();
|
palette_ = overworld_.AreaPalette();
|
||||||
current_gfx_bmp_.Create(0x80, 0x200, 0x40, overworld_.AreaGraphics());
|
|
||||||
current_gfx_bmp_.ApplyPalette(palette_);
|
// Create the area graphics image
|
||||||
rom_.RenderBitmap(¤t_gfx_bmp_);
|
core::BuildAndRenderBitmapPipeline(0x80, 0x200, 0x40,
|
||||||
|
overworld_.AreaGraphics(), rom_,
|
||||||
|
current_gfx_bmp_, palette_);
|
||||||
|
|
||||||
// Create the tile16 blockset image
|
// Create the tile16 blockset image
|
||||||
tile16_blockset_bmp_.Create(0x80, 0x2000, 0x80, overworld_.Tile16Blockset());
|
core::BuildAndRenderBitmapPipeline(0x80, 0x2000, 0x80,
|
||||||
tile16_blockset_bmp_.ApplyPalette(palette_);
|
overworld_.Tile16Blockset(), rom_,
|
||||||
rom_.RenderBitmap(&tile16_blockset_bmp_);
|
tile16_blockset_bmp_, palette_);
|
||||||
map_blockset_loaded_ = true;
|
map_blockset_loaded_ = true;
|
||||||
|
|
||||||
// Copy the tile16 data into individual tiles.
|
// Copy the tile16 data into individual tiles.
|
||||||
@@ -363,19 +332,18 @@ absl::Status OverworldEditor::LoadGraphics() {
|
|||||||
// Render the bitmaps of each tile.
|
// Render the bitmaps of each tile.
|
||||||
for (int id = 0; id < 4096; id++) {
|
for (int id = 0; id < 4096; id++) {
|
||||||
tile16_individual_.emplace_back();
|
tile16_individual_.emplace_back();
|
||||||
tile16_individual_[id].Create(0x10, 0x10, 0x80,
|
core::BuildAndRenderBitmapPipeline(0x10, 0x10, 0x80,
|
||||||
tile16_individual_data_[id]);
|
tile16_individual_data_[id], rom_,
|
||||||
tile16_individual_[id].ApplyPalette(palette_);
|
tile16_individual_[id], palette_);
|
||||||
rom_.RenderBitmap(&tile16_individual_[id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the overworld maps loaded from the ROM.
|
// Render the overworld maps loaded from the ROM.
|
||||||
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
||||||
overworld_.SetCurrentMap(i);
|
overworld_.SetCurrentMap(i);
|
||||||
auto palette = overworld_.AreaPalette();
|
auto palette = overworld_.AreaPalette();
|
||||||
maps_bmp_[i].Create(0x200, 0x200, 0x200, overworld_.BitmapData());
|
core::BuildAndRenderBitmapPipeline(0x200, 0x200, 0x200,
|
||||||
maps_bmp_[i].ApplyPalette(palette);
|
overworld_.BitmapData(), rom_,
|
||||||
rom_.RenderBitmap(&(maps_bmp_[i]));
|
maps_bmp_[i], palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
|
#include "app/core/pipeline.h"
|
||||||
#include "app/editor/palette_editor.h"
|
#include "app/editor/palette_editor.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
@@ -75,9 +76,7 @@ class OverworldEditor : public SharedROM {
|
|||||||
void DrawOverworldEdits() const;
|
void DrawOverworldEdits() const;
|
||||||
void DrawOverworldCanvas();
|
void DrawOverworldCanvas();
|
||||||
|
|
||||||
void DrawTile16Selector();
|
|
||||||
void DrawTile8Selector();
|
void DrawTile8Selector();
|
||||||
void DrawAreaGraphics();
|
|
||||||
void DrawTileSelector();
|
void DrawTileSelector();
|
||||||
absl::Status LoadGraphics();
|
absl::Status LoadGraphics();
|
||||||
absl::Status LoadSpriteGraphics();
|
absl::Status LoadSpriteGraphics();
|
||||||
|
|||||||
@@ -38,13 +38,12 @@ class Bitmap {
|
|||||||
this->pixel_data_[position] = value;
|
this->pixel_data_[position] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetWidth() const { return width_; }
|
int width() const { return width_; }
|
||||||
int GetHeight() const { return height_; }
|
int height() const { return height_; }
|
||||||
auto GetSize() const { return data_size_; }
|
auto size() const { return data_size_; }
|
||||||
auto GetData() const { return pixel_data_; }
|
auto data() const { return pixel_data_; }
|
||||||
auto GetByte(int i) const { return pixel_data_[i]; }
|
auto at(int i) const { return pixel_data_[i]; }
|
||||||
auto GetTexture() const { return texture_.get(); }
|
auto texture() const { return texture_.get(); }
|
||||||
auto GetSurface() const { return surface_.get(); }
|
|
||||||
auto IsActive() const { return active_; }
|
auto IsActive() const { return active_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -153,6 +153,23 @@ Bytes BPP8SNESToIndexed(Bytes data, uint64_t bpp) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ushort TileInfoToShort(TileInfo tile_info) {
|
||||||
|
ushort result = 0;
|
||||||
|
|
||||||
|
// Copy the id_ value
|
||||||
|
result |= tile_info.id_ & 0x3FF; // ids are 10 bits
|
||||||
|
|
||||||
|
// Set the vertical_mirror_, horizontal_mirror_, and over_ flags
|
||||||
|
result |= (tile_info.vertical_mirror_ ? 1 : 0) << 10;
|
||||||
|
result |= (tile_info.horizontal_mirror_ ? 1 : 0) << 11;
|
||||||
|
result |= (tile_info.over_ ? 1 : 0) << 12;
|
||||||
|
|
||||||
|
// Set the palette_
|
||||||
|
result |= (tile_info.palette_ & 0x07) << 13; // palettes are 3 bits
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
TileInfo GetTilesInfo(ushort tile) {
|
TileInfo GetTilesInfo(ushort tile) {
|
||||||
// vhopppcc cccccccc
|
// vhopppcc cccccccc
|
||||||
bool o = false;
|
bool o = false;
|
||||||
|
|||||||
@@ -40,25 +40,10 @@ class TileInfo {
|
|||||||
vertical_mirror_(v),
|
vertical_mirror_(v),
|
||||||
horizontal_mirror_(h),
|
horizontal_mirror_(h),
|
||||||
palette_(palette) {}
|
palette_(palette) {}
|
||||||
|
|
||||||
ushort ToShort() const {
|
|
||||||
ushort result = 0;
|
|
||||||
|
|
||||||
// Copy the id_ value
|
|
||||||
result |= id_ & 0x3FF; // ids are 10 bits
|
|
||||||
|
|
||||||
// Set the vertical_mirror_, horizontal_mirror_, and over_ flags
|
|
||||||
result |= (vertical_mirror_ ? 1 : 0) << 10;
|
|
||||||
result |= (horizontal_mirror_ ? 1 : 0) << 11;
|
|
||||||
result |= (over_ ? 1 : 0) << 12;
|
|
||||||
|
|
||||||
// Set the palette_
|
|
||||||
result |= (palette_ & 0x07) << 13; // palettes are 3 bits
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ushort TileInfoToShort(TileInfo tile_info);
|
||||||
|
|
||||||
TileInfo GetTilesInfo(ushort tile);
|
TileInfo GetTilesInfo(ushort tile);
|
||||||
|
|
||||||
class Tile32 {
|
class Tile32 {
|
||||||
|
|||||||
@@ -96,11 +96,11 @@ bool Canvas::DrawTilePainter(const Bitmap &bitmap, int size) {
|
|||||||
|
|
||||||
if (bitmap.IsActive()) {
|
if (bitmap.IsActive()) {
|
||||||
draw_list_->AddImage(
|
draw_list_->AddImage(
|
||||||
(void *)bitmap.GetTexture(),
|
(void *)bitmap.texture(),
|
||||||
ImVec2(origin.x + draw_tile_outline_pos.x,
|
ImVec2(origin.x + draw_tile_outline_pos.x,
|
||||||
origin.y + draw_tile_outline_pos.y),
|
origin.y + draw_tile_outline_pos.y),
|
||||||
ImVec2(origin.x + draw_tile_outline_pos.x + bitmap.GetWidth(),
|
ImVec2(origin.x + draw_tile_outline_pos.x + bitmap.width(),
|
||||||
origin.y + draw_tile_outline_pos.y + bitmap.GetHeight()));
|
origin.y + draw_tile_outline_pos.y + bitmap.height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||||
@@ -147,20 +147,20 @@ void Canvas::DrawTileSelector(int size) {
|
|||||||
void Canvas::DrawBitmap(const Bitmap &bitmap, int border_offset, bool ready) {
|
void Canvas::DrawBitmap(const Bitmap &bitmap, int border_offset, bool ready) {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
draw_list_->AddImage(
|
draw_list_->AddImage(
|
||||||
(void *)bitmap.GetTexture(),
|
(void *)bitmap.texture(),
|
||||||
ImVec2(canvas_p0_.x + border_offset, canvas_p0_.y + border_offset),
|
ImVec2(canvas_p0_.x + border_offset, canvas_p0_.y + border_offset),
|
||||||
ImVec2(canvas_p0_.x + (bitmap.GetWidth() * 2),
|
ImVec2(canvas_p0_.x + (bitmap.width() * 2),
|
||||||
canvas_p0_.y + (bitmap.GetHeight() * 2)));
|
canvas_p0_.y + (bitmap.height() * 2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::DrawBitmap(const Bitmap &bitmap, int x_offset, int y_offset) {
|
void Canvas::DrawBitmap(const Bitmap &bitmap, int x_offset, int y_offset) {
|
||||||
draw_list_->AddImage(
|
draw_list_->AddImage(
|
||||||
(void *)bitmap.GetTexture(),
|
(void *)bitmap.texture(),
|
||||||
ImVec2(canvas_p0_.x + x_offset + scrolling_.x,
|
ImVec2(canvas_p0_.x + x_offset + scrolling_.x,
|
||||||
canvas_p0_.y + y_offset + scrolling_.y),
|
canvas_p0_.y + y_offset + scrolling_.y),
|
||||||
ImVec2(canvas_p0_.x + x_offset + scrolling_.x + (bitmap.GetWidth()),
|
ImVec2(canvas_p0_.x + x_offset + scrolling_.x + (bitmap.width()),
|
||||||
canvas_p0_.y + y_offset + scrolling_.y + (bitmap.GetHeight())));
|
canvas_p0_.y + y_offset + scrolling_.y + (bitmap.height())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add parameters for sizing and positioning
|
// TODO: Add parameters for sizing and positioning
|
||||||
@@ -171,7 +171,7 @@ void Canvas::DrawBitmapTable(const BitmapTable &gfx_bin) {
|
|||||||
if (key >= 1) {
|
if (key >= 1) {
|
||||||
top_left_y = canvas_p0_.y + 0x40 * key;
|
top_left_y = canvas_p0_.y + 0x40 * key;
|
||||||
}
|
}
|
||||||
draw_list_->AddImage((void *)value.GetTexture(),
|
draw_list_->AddImage((void *)value.texture(),
|
||||||
ImVec2(canvas_p0_.x + 2, top_left_y),
|
ImVec2(canvas_p0_.x + 2, top_left_y),
|
||||||
ImVec2(canvas_p0_.x + 0x100, canvas_p0_.y + offset));
|
ImVec2(canvas_p0_.x + 0x100, canvas_p0_.y + offset));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,11 +284,11 @@ absl::Status ROM::LoadAllGraphicsData() {
|
|||||||
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
|
core::kTilesheetDepth, converted_sheet.data(), 0x1000);
|
||||||
graphics_bin_.at(i).CreateTexture(renderer_);
|
graphics_bin_.at(i).CreateTexture(renderer_);
|
||||||
|
|
||||||
for (int j = 0; j < graphics_bin_.at(i).GetSize(); ++j) {
|
for (int j = 0; j < graphics_bin_.at(i).size(); ++j) {
|
||||||
graphics_buffer_.push_back(graphics_bin_.at(i).GetByte(j));
|
graphics_buffer_.push_back(graphics_bin_.at(i).at(j));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int j = 0; j < graphics_bin_.at(0).GetSize(); ++j) {
|
for (int j = 0; j < graphics_bin_.at(0).size(); ++j) {
|
||||||
graphics_buffer_.push_back(0xFF);
|
graphics_buffer_.push_back(0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,11 +315,10 @@ absl::Status ROM::LoadFromFile(const absl::string_view& filename,
|
|||||||
rom_data_[i] = byte_to_read;
|
rom_data_[i] = byte_to_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy ROM title
|
|
||||||
memcpy(title_, rom_data_.data() + kTitleStringOffset, kTitleStringLength);
|
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
if (z3_load) {
|
if (z3_load) {
|
||||||
|
// copy ROM title
|
||||||
|
memcpy(title_, rom_data_.data() + kTitleStringOffset, kTitleStringLength);
|
||||||
LoadAllPalettes();
|
LoadAllPalettes();
|
||||||
}
|
}
|
||||||
is_loaded_ = true;
|
is_loaded_ = true;
|
||||||
|
|||||||
@@ -138,14 +138,16 @@ class ROM {
|
|||||||
|
|
||||||
uchar& operator[](int i) {
|
uchar& operator[](int i) {
|
||||||
if (i > size_) {
|
if (i > size_) {
|
||||||
std::cout << "ROM: Index out of bounds" << std::endl;
|
std::cout << "ROM: Index " << i << " out of bounds, size: " << size_
|
||||||
|
<< std::endl;
|
||||||
return rom_data_[0];
|
return rom_data_[0];
|
||||||
}
|
}
|
||||||
return rom_data_[i];
|
return rom_data_[i];
|
||||||
}
|
}
|
||||||
uchar& operator+(int i) {
|
uchar& operator+(int i) {
|
||||||
if (i > size_) {
|
if (i > size_) {
|
||||||
std::cout << "ROM: Index out of bounds" << std::endl;
|
std::cout << "ROM: Index " << i << " out of bounds, size: " << size_
|
||||||
|
<< std::endl;
|
||||||
return rom_data_[0];
|
return rom_data_[0];
|
||||||
}
|
}
|
||||||
return rom_data_[i];
|
return rom_data_[i];
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "app/core/pipeline.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
@@ -12,14 +13,8 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace viewer {
|
namespace viewer {
|
||||||
|
|
||||||
void CgxViewer::Update() {
|
void CgxViewer::LoadCgx(ROM &cgx_rom) {
|
||||||
static int current_bpp = 1;
|
std::cout << "Loading CGX" << std::endl;
|
||||||
// ImGui::Combo("BPP", current_bpp, "0\0 1\0 2\0 3\0", 4, 4);
|
|
||||||
LoadGfx(current_bpp);
|
|
||||||
LoadScr();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CgxViewer::LoadCgx(ROM& cgx_rom) {
|
|
||||||
raw_data_.malloc(0x40000);
|
raw_data_.malloc(0x40000);
|
||||||
all_tiles_data_.malloc(0x40000);
|
all_tiles_data_.malloc(0x40000);
|
||||||
|
|
||||||
@@ -50,6 +45,43 @@ void CgxViewer::LoadCgx(ROM& cgx_rom) {
|
|||||||
LoadGfx(current_selection_);
|
LoadGfx(current_selection_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CgxViewer::DrawBG1(int p, int bpp) {
|
||||||
|
auto *ptr = (uchar *)screen_bitmap_.data();
|
||||||
|
// for each tile on the tile buffer
|
||||||
|
for (int i = 0; i < 0x400; i++) {
|
||||||
|
if (room_bg1_bitmap_.data()[i + p] != 0xFFFF) {
|
||||||
|
gfx::TileInfo t = gfx::GetTilesInfo(room_bg1_bitmap_.data()[i + p]);
|
||||||
|
|
||||||
|
for (uint16_t yl = 0; yl < 8; yl++) {
|
||||||
|
for (uint16_t xl = 0; xl < 8; xl++) {
|
||||||
|
int mx = xl * (1 - t.horizontal_mirror_) +
|
||||||
|
(7 - xl) * (t.horizontal_mirror_);
|
||||||
|
int my =
|
||||||
|
yl * (1 - t.vertical_mirror_) + (7 - yl) * (t.vertical_mirror_);
|
||||||
|
|
||||||
|
int ty = (t.id_ / 16) * 1024;
|
||||||
|
int tx = (t.id_ % 16) * 8;
|
||||||
|
uchar pixel = all_tiles_data_[(tx + ty) + (yl * 128) + xl];
|
||||||
|
|
||||||
|
int index =
|
||||||
|
(((i % 32) * 8) + ((i / 32) * 2048) + ((mx) + (my * 256)));
|
||||||
|
|
||||||
|
if (bpp != 8) {
|
||||||
|
ptr[index] = (uchar)((((pixel)&0xFF) + t.palette_ * 16));
|
||||||
|
} else {
|
||||||
|
ptr[index] = (uchar)((((pixel)&0xFF)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply data to Bitmap
|
||||||
|
}
|
||||||
|
void CgxViewer::DrawBG2() {}
|
||||||
|
|
||||||
|
void CgxViewer::DrawOAM(int bpp, int drawmode, gfx::OAMTile data, int frame) {}
|
||||||
|
|
||||||
void CgxViewer::LoadGfx(int combo_bpp) {
|
void CgxViewer::LoadGfx(int combo_bpp) {
|
||||||
if (combo_bpp == 0) {
|
if (combo_bpp == 0) {
|
||||||
bpp_ = 4;
|
bpp_ = 4;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "app/core/pipeline.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
@@ -15,9 +16,12 @@ namespace viewer {
|
|||||||
|
|
||||||
class CgxViewer {
|
class CgxViewer {
|
||||||
public:
|
public:
|
||||||
void Update();
|
|
||||||
auto GetCgxData() const { return all_tiles_data_; }
|
|
||||||
void LoadCgx(ROM&);
|
void LoadCgx(ROM&);
|
||||||
|
auto GetCgxData() const { return all_tiles_data_; }
|
||||||
|
|
||||||
|
void DrawBG1(int p, int bpp);
|
||||||
|
void DrawBG2();
|
||||||
|
void DrawOAM(int bpp, int drawmode, gfx::OAMTile data, int frame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadGfx(int comboBpp);
|
void LoadGfx(int comboBpp);
|
||||||
@@ -25,10 +29,16 @@ class CgxViewer {
|
|||||||
|
|
||||||
void RefreshPalettes();
|
void RefreshPalettes();
|
||||||
|
|
||||||
|
gfx::Bitmap screen_bitmap_;
|
||||||
|
gfx::Bitmap room_bg1_bitmap_;
|
||||||
|
gfx::Bitmap room_bg2_bitmap_;
|
||||||
|
gfx::Bitmap indexed_bitmap_;
|
||||||
|
|
||||||
std::string label1_text;
|
std::string label1_text;
|
||||||
|
|
||||||
int bpp_;
|
int bpp_;
|
||||||
int current_selection_;
|
int current_selection_;
|
||||||
|
|
||||||
ROM all_tiles_data_;
|
ROM all_tiles_data_;
|
||||||
ROM raw_data_;
|
ROM raw_data_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ void Room::LoadRoomGraphics(uchar entrance_blockset) {
|
|||||||
|
|
||||||
auto newPdata = rom_.GetGraphicsBuffer();
|
auto newPdata = rom_.GetGraphicsBuffer();
|
||||||
|
|
||||||
uchar* sheetsData = current_graphics_.GetData();
|
uchar* sheetsData = current_graphics_.data();
|
||||||
// Into "room gfx16" 16 of them
|
// Into "room gfx16" 16 of them
|
||||||
|
|
||||||
int sheetPos = 0;
|
int sheetPos = 0;
|
||||||
@@ -159,7 +159,7 @@ void Room::LoadAnimatedGraphics() {
|
|||||||
|
|
||||||
auto newPdata = rom_.GetGraphicsBuffer();
|
auto newPdata = rom_.GetGraphicsBuffer();
|
||||||
|
|
||||||
uchar* sheetsData = current_graphics_.GetData();
|
uchar* sheetsData = current_graphics_.data();
|
||||||
int data = 0;
|
int data = 0;
|
||||||
while (data < 512) {
|
while (data < 512) {
|
||||||
uchar mapByte = newPdata[data + (92 * 2048) + (512 * animated_frame)];
|
uchar mapByte = newPdata[data + (92 * 2048) + (512 * animated_frame)];
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void TitleScreen::BuildTileset() {
|
|||||||
staticgfx[15] = 112;
|
staticgfx[15] = 112;
|
||||||
|
|
||||||
// Loaded gfx for the current screen (empty at this point)
|
// Loaded gfx for the current screen (empty at this point)
|
||||||
uchar* currentmapgfx8Data = tiles8Bitmap.GetData();
|
uchar* currentmapgfx8Data = tiles8Bitmap.data();
|
||||||
|
|
||||||
// All gfx of the game pack of 2048 bytes (4bpp)
|
// All gfx of the game pack of 2048 bytes (4bpp)
|
||||||
uchar* allgfxData = nullptr; // rom_.GetMasterGraphicsBin();
|
uchar* allgfxData = nullptr; // rom_.GetMasterGraphicsBin();
|
||||||
|
|||||||
Reference in New Issue
Block a user