Popout PaletteEditor, general housekeeping
This commit is contained in:
@@ -25,22 +25,22 @@ set(
|
||||
|
||||
set(
|
||||
YAZE_APP_ZELDA3_SRC
|
||||
app/zelda3/inventory.cc
|
||||
app/zelda3/overworld_map.cc
|
||||
app/zelda3/overworld.cc
|
||||
app/zelda3/title_screen.cc
|
||||
app/zelda3/sprite.cc
|
||||
app/zelda3/tracker.cc
|
||||
app/zelda3/screen/inventory.cc
|
||||
app/zelda3/screen/title_screen.cc
|
||||
app/zelda3/sprite/sprite.cc
|
||||
app/zelda3/music/tracker.cc
|
||||
app/zelda3/dungeon/room.cc
|
||||
)
|
||||
|
||||
set(
|
||||
YAZE_GUI_SRC
|
||||
gui/canvas.cc
|
||||
gui/input.cc
|
||||
gui/style.cc
|
||||
gui/widgets.cc
|
||||
gui/color.cc
|
||||
app/gui/canvas.cc
|
||||
app/gui/input.cc
|
||||
app/gui/style.cc
|
||||
app/gui/widgets.cc
|
||||
app/gui/color.cc
|
||||
)
|
||||
|
||||
# executable creation ---------------------------------------------------------
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/editor/master_editor.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/style.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/style.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/editor/master_editor.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/style.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/style.h"
|
||||
|
||||
int main(int argc, char **argv);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "assembly_editor.h"
|
||||
|
||||
#include "core/constants.h"
|
||||
#include "gui/widgets.h"
|
||||
#include "app/gui/widgets.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -12,8 +12,8 @@ AssemblyEditor::AssemblyEditor() {
|
||||
text_editor_.SetPalette(TextEditor::GetDarkPalette());
|
||||
}
|
||||
|
||||
void AssemblyEditor::Update() {
|
||||
ImGui::Begin("Assembly Editor", &file_is_loaded_);
|
||||
void AssemblyEditor::Update(bool &is_loaded) {
|
||||
ImGui::Begin("Assembly Editor", &is_loaded);
|
||||
MENU_BAR()
|
||||
DrawFileMenu();
|
||||
DrawEditMenu();
|
||||
|
||||
@@ -16,7 +16,7 @@ class AssemblyEditor {
|
||||
public:
|
||||
AssemblyEditor();
|
||||
|
||||
void Update();
|
||||
void Update(bool &is_loaded);
|
||||
void InlineUpdate();
|
||||
void ChangeActiveFile(const std::string &);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "dungeon_editor.h"
|
||||
|
||||
#include "gui/icons.h"
|
||||
#include "app/gui/icons.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "rom.h"
|
||||
#include "zelda3/dungeon/room.h"
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
#include "gui/widgets.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/input.h"
|
||||
#include "app/gui/widgets.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -213,6 +213,7 @@ void MasterEditor::DrawViewMenu() {
|
||||
static bool show_asm_editor = false;
|
||||
static bool show_imgui_demo = false;
|
||||
static bool show_memory_viewer = false;
|
||||
static bool show_palette_editor = false;
|
||||
|
||||
if (show_imgui_metrics) {
|
||||
ImGui::ShowMetricsWindow(&show_imgui_metrics);
|
||||
@@ -228,7 +229,13 @@ void MasterEditor::DrawViewMenu() {
|
||||
}
|
||||
|
||||
if (show_asm_editor) {
|
||||
assembly_editor_.Update();
|
||||
assembly_editor_.Update(show_asm_editor);
|
||||
}
|
||||
|
||||
if (show_palette_editor) {
|
||||
ImGui::Begin("Palette Editor", &show_palette_editor);
|
||||
palette_editor_.Update();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
if (show_imgui_style_editor) {
|
||||
@@ -263,6 +270,7 @@ void MasterEditor::DrawViewMenu() {
|
||||
if (ImGui::BeginMenu("View")) {
|
||||
ImGui::MenuItem("HEX Editor", nullptr, &show_memory_editor);
|
||||
ImGui::MenuItem("ASM Editor", nullptr, &show_asm_editor);
|
||||
ImGui::MenuItem("Palette Editor", nullptr, &show_palette_editor);
|
||||
ImGui::MenuItem("Memory Viewer", nullptr, &show_memory_viewer);
|
||||
ImGui::MenuItem("ImGui Demo", nullptr, &show_imgui_demo);
|
||||
ImGui::Separator();
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/input.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/editor/assembly_editor.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/input.h"
|
||||
#include "snes_spc/demo/demo_util.h"
|
||||
#include "snes_spc/demo/wave_writer.h"
|
||||
#include "snes_spc/snes_spc/spc.h"
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/editor/assembly_editor.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/input.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/tracker.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
#include "app/zelda3/music/tracker.h"
|
||||
#include "snes_spc/demo/demo_util.h"
|
||||
#include "snes_spc/demo/wave_writer.h"
|
||||
#include "snes_spc/snes_spc/spc.h"
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/overworld.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -196,9 +196,8 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
if (!blockset_canvas_.Points().empty()) {
|
||||
int x = blockset_canvas_.Points().front().x / 32;
|
||||
int y = blockset_canvas_.Points().front().y / 32;
|
||||
// std::cout << x << " " << y << std::endl;
|
||||
current_tile16_ = x + (y * 8);
|
||||
// std::cout << current_tile16_ << std::endl;
|
||||
current_tile16_ = x + (y * 0x10);
|
||||
|
||||
if (ow_map_canvas_.DrawTilePainter(tile16_individual_[current_tile16_],
|
||||
16)) {
|
||||
// Update the overworld map.
|
||||
@@ -326,12 +325,12 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
// Create a new vector for the pixel data of the current tile
|
||||
Bytes tile_data;
|
||||
for (int j = 0; j < 32 * 32; j++) tile_data.push_back(0x00);
|
||||
for (int j = 0; j < 16 * 16; j++) tile_data.push_back(0x00);
|
||||
|
||||
// Copy the pixel data for the current tile into the vector
|
||||
for (int ty = 0; ty < 32; ty++) {
|
||||
for (int tx = 0; tx < 32; tx++) {
|
||||
int position = (tx + (ty * 0x20));
|
||||
for (int ty = 0; ty < 16; ty++) {
|
||||
for (int tx = 0; tx < 16; tx++) {
|
||||
int position = (tx + (ty * 0x10));
|
||||
uchar value = tile16_data[i + tx + (ty * 0x80)];
|
||||
tile_data[position] = value;
|
||||
}
|
||||
@@ -343,8 +342,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
|
||||
// Render the bitmaps of each tile.
|
||||
for (int id = 0; id < 4096; id++) {
|
||||
gfx::Bitmap new_tile16;
|
||||
tile16_individual_.emplace_back(new_tile16);
|
||||
tile16_individual_.emplace_back();
|
||||
tile16_individual_[id].Create(0x10, 0x10, 0x80,
|
||||
tile16_individual_data_[id]);
|
||||
tile16_individual_[id].ApplyPalette(palette_);
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/overworld.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
|
||||
static inline float ImSaturate(float f) {
|
||||
return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f;
|
||||
@@ -41,17 +41,9 @@ using namespace ImGui;
|
||||
} // namespace
|
||||
|
||||
void PaletteEditor::DrawPaletteGroup(int i) {
|
||||
const int palettesPerRow = 4;
|
||||
ImGui::BeginTable("palette_table", palettesPerRow,
|
||||
ImGuiTableFlags_BordersOuter | ImGuiTableFlags_Resizable);
|
||||
|
||||
auto size = rom_.GetPaletteGroup(kPaletteGroupNames[i].data()).size();
|
||||
auto palettes = rom_.GetPaletteGroup(kPaletteGroupNames[i].data());
|
||||
for (int j = 0; j < size; j++) {
|
||||
if (j % palettesPerRow == 0) {
|
||||
ImGui::TableNextRow();
|
||||
}
|
||||
ImGui::TableSetColumnIndex(j % palettesPerRow);
|
||||
ImGui::Text("%d", j);
|
||||
|
||||
auto palette = palettes[j];
|
||||
@@ -106,8 +98,6 @@ void PaletteEditor::DrawPaletteGroup(int i) {
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
absl::Status PaletteEditor::Update() {
|
||||
@@ -159,6 +149,10 @@ void PaletteEditor::DisplayPalette(gfx::SNESPalette& palette, bool loaded) {
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Previous");
|
||||
|
||||
if (ImGui::Button("Update Map Palette")) {
|
||||
|
||||
}
|
||||
|
||||
ImGui::ColorButton(
|
||||
"##current", color,
|
||||
ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf,
|
||||
@@ -170,6 +164,8 @@ void PaletteEditor::DisplayPalette(gfx::SNESPalette& palette, bool loaded) {
|
||||
ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf,
|
||||
ImVec2(60, 40)))
|
||||
color = backup_color;
|
||||
|
||||
// List of Colors in Overworld Palette
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Palette");
|
||||
for (int n = 0; n < IM_ARRAYSIZE(saved_palette_); n++) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/input.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/color.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/inventory.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/color.h"
|
||||
#include "gui/icons.h"
|
||||
#include "app/zelda3/screen/inventory.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -34,8 +34,23 @@ class TileInfo {
|
||||
vertical_mirror_(v),
|
||||
horizontal_mirror_(h),
|
||||
palette_(palette) {}
|
||||
// TODO(scawful): This is not the actual value yet.
|
||||
ushort ToShort() const { return id_; }
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
TileInfo GetTilesInfo(ushort tile);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "app/gui/canvas.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "app/gui/canvas.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -46,20 +46,20 @@ absl::Status Overworld::Load(ROM &rom) {
|
||||
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
||||
futures.push_back(std::async(std::launch::async, [this, i, size]() {
|
||||
if (i < 64) {
|
||||
return overworld_maps_[i].BuildMap(
|
||||
size, game_state_, 0, map_parent_, map_tiles_.light_world);
|
||||
return overworld_maps_[i].BuildMap(size, game_state_, 0, map_parent_,
|
||||
map_tiles_.light_world);
|
||||
} else if (i < 0x80 && i >= 0x40) {
|
||||
return overworld_maps_[i].BuildMap(
|
||||
size, game_state_, 1, map_parent_, map_tiles_.dark_world);
|
||||
return overworld_maps_[i].BuildMap(size, game_state_, 1, map_parent_,
|
||||
map_tiles_.dark_world);
|
||||
} else {
|
||||
return overworld_maps_[i].BuildMap(
|
||||
size, game_state_, 2, map_parent_, map_tiles_.special_world);
|
||||
return overworld_maps_[i].BuildMap(size, game_state_, 2, map_parent_,
|
||||
map_tiles_.special_world);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// Wait for all tasks to complete and check their results
|
||||
for (auto& future : futures) {
|
||||
for (auto &future : futures) {
|
||||
absl::Status status = future.get();
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
@@ -275,110 +275,52 @@ absl::Status Overworld::SaveOverworldMaps() {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
void Overworld::SaveMap16Tiles() {
|
||||
int tpos = core::map16Tiles;
|
||||
// 3760
|
||||
for (int i = 0; i < core::NumberOfMap16; i += 1) {
|
||||
rom_.WriteShort(tpos, tiles16[i].tile0_);
|
||||
rom_.WriteShort(tpos, tiles16[i].tile0_.ToShort());
|
||||
tpos += 2;
|
||||
rom_.WriteShort(tpos, tiles16[i].tile1_);
|
||||
rom_.WriteShort(tpos, tiles16[i].tile1_.ToShort());
|
||||
tpos += 2;
|
||||
rom_.WriteShort(tpos, tiles16[i].tile2_);
|
||||
rom_.WriteShort(tpos, tiles16[i].tile2_.ToShort());
|
||||
tpos += 2;
|
||||
rom_.WriteShort(tpos, tiles16[i].tile3_);
|
||||
rom_.WriteShort(tpos, tiles16[i].tile3_.ToShort());
|
||||
tpos += 2;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
void Overworld::SaveMap32Tiles() {
|
||||
int index = 0;
|
||||
int c = tiles32_unique_.size();
|
||||
for (int i = 0; i < c; i += 6) {
|
||||
if (index >= 0x4540) // 3C87??
|
||||
{
|
||||
std::cout << "Too many unique tiles!" << std::endl;
|
||||
const int max_tiles = 0x4540;
|
||||
const int unique_size = tiles32_unique_.size();
|
||||
|
||||
break;
|
||||
auto write_tiles = [&](int address, auto get_tile) {
|
||||
for (int i = 0; i < unique_size && i < max_tiles; i += 4) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
rom_.Write(address + i + j, (uchar)(get_tile(i + j) & 0xFF));
|
||||
}
|
||||
rom_.Write(address + i + 4, (uchar)(((get_tile(i) >> 4) & 0xF0) |
|
||||
((get_tile(i + 1) >> 8) & 0x0F)));
|
||||
rom_.Write(address + i + 5, (uchar)(((get_tile(i + 2) >> 4) & 0xF0) |
|
||||
((get_tile(i + 3) >> 8) & 0x0F)));
|
||||
}
|
||||
};
|
||||
|
||||
// Top Left
|
||||
rom_.Write(core::map32TilesTL + (i),
|
||||
(uchar)(tiles32_unique_[index].tile0 & 0xFF));
|
||||
rom_.Write(core::map32TilesTL + (i + 1),
|
||||
(uchar)(tiles32_unique_[index + 1].tile0 & 0xFF));
|
||||
rom_.Write(core::map32TilesTL + (i + 2),
|
||||
(uchar)(tiles32_unique_[index + 2].tile0 & 0xFF));
|
||||
rom_.Write(core::map32TilesTL + (i + 3),
|
||||
(uchar)(tiles32_unique_[index + 3].tile0 & 0xFF));
|
||||
write_tiles(core::map32TilesTL,
|
||||
[&](int i) { return tiles32_unique_[i].tile0_; });
|
||||
write_tiles(core::map32TilesTR,
|
||||
[&](int i) { return tiles32_unique_[i].tile1_; });
|
||||
write_tiles(core::map32TilesBL,
|
||||
[&](int i) { return tiles32_unique_[i].tile2_; });
|
||||
write_tiles(core::map32TilesBR,
|
||||
[&](int i) { return tiles32_unique_[i].tile3_; });
|
||||
|
||||
rom_.Write(core::map32TilesTL + (i + 4),
|
||||
(uchar)(((tiles32_unique_[index].tile0 >> 4) & 0xF0) +
|
||||
((tiles32_unique_[index + 1].tile0 >> 8) & 0x0F)));
|
||||
rom_.Write(core::map32TilesTL + (i + 5),
|
||||
(uchar)(((tiles32_unique_[index + 2].tile0 >> 4) & 0xF0) +
|
||||
((tiles32_unique_[index + 3].tile0 >> 8) & 0x0F)));
|
||||
|
||||
// Top Right
|
||||
rom_.Write(core::map32TilesTR + (i),
|
||||
(uchar)(tiles32_unique_[index].tile1 & 0xFF));
|
||||
rom_.Write(core::map32TilesTR + (i + 1),
|
||||
(uchar)(tiles32_unique_[index + 1].tile1 & 0xFF));
|
||||
rom_.Write(core::map32TilesTR + (i + 2),
|
||||
(uchar)(tiles32_unique_[index + 2].tile1 & 0xFF));
|
||||
rom_.Write(core::map32TilesTR + (i + 3),
|
||||
(uchar)(tiles32_unique_[index + 3].tile1 & 0xFF));
|
||||
|
||||
rom_.Write(core::map32TilesTR + (i + 4),
|
||||
(uchar)(((tiles32_unique_[index].tile1 >> 4) & 0xF0) |
|
||||
((tiles32_unique_[index + 1].tile1 >> 8) & 0x0F)));
|
||||
rom_.Write(core::map32TilesTR + (i + 5),
|
||||
(uchar)(((tiles32_unique_[index + 2].tile1 >> 4) & 0xF0) |
|
||||
((tiles32_unique_[index + 3].tile1 >> 8) & 0x0F)));
|
||||
|
||||
// Bottom Left
|
||||
rom_.Write(core::map32TilesBL + (i),
|
||||
(uchar)(tiles32_unique_[index].tile2 & 0xFF));
|
||||
rom_.Write(core::map32TilesBL + (i + 1),
|
||||
(uchar)(tiles32_unique_[index + 1].tile2 & 0xFF));
|
||||
rom_.Write(core::map32TilesBL + (i + 2),
|
||||
(uchar)(tiles32_unique_[index + 2].tile2 & 0xFF));
|
||||
rom_.Write(core::map32TilesBL + (i + 3),
|
||||
(uchar)(tiles32_unique_[index + 3].tile2 & 0xFF));
|
||||
|
||||
rom_.Write(core::map32TilesBL + (i + 4),
|
||||
(uchar)(((tiles32_unique_[index].tile2 >> 4) & 0xF0) |
|
||||
((tiles32_unique_[index + 1].tile2 >> 8) & 0x0F)));
|
||||
rom_.Write(core::map32TilesBL + (i + 5),
|
||||
(uchar)(((tiles32_unique_[index + 2].tile2 >> 4) & 0xF0) |
|
||||
((tiles32_unique_[index + 3].tile2 >> 8) & 0x0F)));
|
||||
|
||||
// Bottom Right
|
||||
rom_.Write(core::map32TilesBR + (i),
|
||||
(uchar)(tiles32_unique_[index].tile3 & 0xFF));
|
||||
rom_.Write(core::map32TilesBR + (i + 1),
|
||||
(uchar)(tiles32_unique_[index + 1].tile3 & 0xFF));
|
||||
rom_.Write(core::map32TilesBR + (i + 2),
|
||||
(uchar)(tiles32_unique_[index + 2].tile3 & 0xFF));
|
||||
rom_.Write(core::map32TilesBR + (i + 3),
|
||||
(uchar)(tiles32_unique_[index + 3].tile3 & 0xFF));
|
||||
|
||||
rom_.Write(core::map32TilesBR + (i + 4),
|
||||
(uchar)(((tiles32_unique_[index].tile3 >> 4) & 0xF0) |
|
||||
((tiles32_unique_[index + 1].tile3 >> 8) & 0x0F)));
|
||||
rom_.Write(core::map32TilesBR + (i + 5),
|
||||
(uchar)(((tiles32_unique_[index + 2].tile3 >> 4) & 0xF0) |
|
||||
((tiles32_unique_[index + 3].tile3 >> 8) & 0x0F)));
|
||||
|
||||
index += 4;
|
||||
c += 2;
|
||||
if (unique_size > max_tiles) {
|
||||
std::cout << "Too many unique tiles!" << std::endl;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/overworld_map.h"
|
||||
#include "app/zelda3/sprite.h"
|
||||
#include "app/zelda3/sprite/sprite.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -109,8 +109,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 9; y < 13; y++) {
|
||||
for (int x = 1; x < 16; x++) {
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("global_sprites")[0][k];
|
||||
k++;
|
||||
new_palette[x + (16 * y)] =
|
||||
rom.GetPaletteGroup("global_sprites")[0][k]; k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,210 +267,156 @@ void OverworldMap::LoadAreaInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldMap::LoadAreaGraphics() {
|
||||
int world_index = 0x20;
|
||||
void OverworldMap::LoadWorldIndex() {
|
||||
if (parent_ < 0x40) {
|
||||
world_index = 0x20;
|
||||
world_index_ = 0x20;
|
||||
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
||||
world_index = 0x21;
|
||||
world_index_ = 0x21;
|
||||
} else if (parent_ == 0x88) {
|
||||
world_index = 0x24;
|
||||
world_index_ = 0x24;
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldMap::LoadSpritesBlocksets() {
|
||||
int static_graphics_base = 0x73;
|
||||
static_graphics_[8] = static_graphics_base + 0x00;
|
||||
static_graphics_[9] = static_graphics_base + 0x01;
|
||||
static_graphics_[10] = static_graphics_base + 0x06;
|
||||
static_graphics_[11] = static_graphics_base + 0x07;
|
||||
|
||||
// Sprites Blocksets
|
||||
static_graphics_[8] = 0x73 + 0x00;
|
||||
static_graphics_[9] = 0x73 + 0x01;
|
||||
static_graphics_[10] = 0x73 + 0x06;
|
||||
static_graphics_[11] = 0x73 + 0x07;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
static_graphics_[12 + i] = (rom_[core::kSpriteBlocksetPointer +
|
||||
(sprite_graphics_[game_state_] * 4) + i] +
|
||||
0x73);
|
||||
static_graphics_base);
|
||||
}
|
||||
}
|
||||
|
||||
// Main Blocksets
|
||||
void OverworldMap::LoadMainBlocksets() {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
static_graphics_[i] =
|
||||
rom_[core::overworldgfxGroups2 + (world_index * 8) + i];
|
||||
rom_[core::overworldgfxGroups2 + (world_index_ * 8) + i];
|
||||
}
|
||||
}
|
||||
|
||||
if (rom_[core::overworldgfxGroups + (area_graphics_ * 4)] != 0) {
|
||||
static_graphics_[3] = rom_[core::overworldgfxGroups + (area_graphics_ * 4)];
|
||||
}
|
||||
if (rom_[core::overworldgfxGroups + (area_graphics_ * 4) + 1] != 0) {
|
||||
static_graphics_[4] =
|
||||
rom_[core::overworldgfxGroups + (area_graphics_ * 4) + 1];
|
||||
}
|
||||
if (rom_[core::overworldgfxGroups + (area_graphics_ * 4) + 2] != 0) {
|
||||
static_graphics_[5] =
|
||||
rom_[core::overworldgfxGroups + (area_graphics_ * 4) + 2];
|
||||
}
|
||||
if (rom_[core::overworldgfxGroups + (area_graphics_ * 4) + 3] != 0) {
|
||||
static_graphics_[6] =
|
||||
rom_[core::overworldgfxGroups + (area_graphics_ * 4) + 3];
|
||||
void OverworldMap::LoadAreaGraphicsBlocksets() {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
uchar value = rom_[core::overworldgfxGroups + (area_graphics_ * 4) + i];
|
||||
if (value != 0) {
|
||||
static_graphics_[3 + i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hardcoded overworld GFX Values, for death mountain
|
||||
if ((parent_ >= 0x03 && parent_ <= 0x07) ||
|
||||
(parent_ >= 0x0B && parent_ <= 0x0E)) {
|
||||
static_graphics_[7] = 0x59;
|
||||
} else if ((parent_ >= 0x43 && parent_ <= 0x47) ||
|
||||
(parent_ >= 0x4B && parent_ <= 0x4E)) {
|
||||
static_graphics_[7] = 0x59;
|
||||
void OverworldMap::LoadDeathMountainGFX() {
|
||||
static_graphics_[7] = (((parent_ >= 0x03 && parent_ <= 0x07) ||
|
||||
(parent_ >= 0x0B && parent_ <= 0x0E)) ||
|
||||
((parent_ >= 0x43 && parent_ <= 0x47) ||
|
||||
(parent_ >= 0x4B && parent_ <= 0x4E)))
|
||||
? 0x59
|
||||
: 0x5B;
|
||||
}
|
||||
|
||||
void OverworldMap::LoadAreaGraphics() {
|
||||
LoadWorldIndex();
|
||||
LoadSpritesBlocksets();
|
||||
LoadMainBlocksets();
|
||||
LoadAreaGraphicsBlocksets();
|
||||
LoadDeathMountainGFX();
|
||||
}
|
||||
|
||||
// New helper function to get a palette from the ROM.
|
||||
gfx::SNESPalette OverworldMap::GetPalette(const std::string& group, int index,
|
||||
int previousIndex, int limit) {
|
||||
if (index == 255) {
|
||||
index = rom_[core::overworldMapPaletteGroup + (previousIndex * 4)];
|
||||
}
|
||||
if (index != 255) {
|
||||
if (index >= limit) {
|
||||
index = limit - 1;
|
||||
}
|
||||
return rom_.GetPaletteGroup(group)[index];
|
||||
} else {
|
||||
static_graphics_[7] = 0x5B;
|
||||
return rom_.GetPaletteGroup(group)[0];
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldMap::LoadPalette() {
|
||||
int previousPalId = 0;
|
||||
int previousSprPalId = 0;
|
||||
if (index_ > 0) {
|
||||
previousPalId = rom_[core::overworldMapPalette + parent_ - 1];
|
||||
previousSprPalId = rom_[core::overworldSpritePalette + parent_ - 1];
|
||||
}
|
||||
int previousPalId =
|
||||
index_ > 0 ? rom_[core::overworldMapPalette + parent_ - 1] : 0;
|
||||
int previousSprPalId =
|
||||
index_ > 0 ? rom_[core::overworldSpritePalette + parent_ - 1] : 0;
|
||||
|
||||
if (area_palette_ >= 0xA3) {
|
||||
area_palette_ = 0xA3;
|
||||
}
|
||||
area_palette_ = std::min(area_palette_, 0xA3);
|
||||
|
||||
uchar pal0 = 0;
|
||||
|
||||
uchar pal1 = rom_[core::overworldMapPaletteGroup + (area_palette_ * 4)];
|
||||
uchar pal2 =
|
||||
rom_[core::overworldMapPaletteGroup + (area_palette_ * 4) + 1]; // aux2
|
||||
uchar pal3 = rom_[core::overworldMapPaletteGroup + (area_palette_ * 4) +
|
||||
2]; // animated
|
||||
|
||||
uchar pal2 = rom_[core::overworldMapPaletteGroup + (area_palette_ * 4) + 1];
|
||||
uchar pal3 = rom_[core::overworldMapPaletteGroup + (area_palette_ * 4) + 2];
|
||||
uchar pal4 = rom_[core::overworldSpritePaletteGroup +
|
||||
(sprite_palette_[game_state_] * 2)]; // spr3
|
||||
(sprite_palette_[game_state_] * 2)];
|
||||
uchar pal5 = rom_[core::overworldSpritePaletteGroup +
|
||||
(sprite_palette_[game_state_] * 2) + 1]; // spr4
|
||||
(sprite_palette_[game_state_] * 2) + 1];
|
||||
|
||||
gfx::SNESPalette aux1;
|
||||
gfx::SNESPalette aux2;
|
||||
gfx::SNESPalette main;
|
||||
gfx::SNESPalette animated;
|
||||
gfx::SNESPalette hud;
|
||||
gfx::SNESPalette spr;
|
||||
gfx::SNESPalette spr2;
|
||||
gfx::SNESColor bgr = rom_.GetPaletteGroup("grass")[0].GetColor(0);
|
||||
|
||||
if (pal1 == 255) {
|
||||
pal1 = rom_[core::overworldMapPaletteGroup + (previousPalId * 4)];
|
||||
}
|
||||
if (pal1 != 255) {
|
||||
if (pal1 >= 20) {
|
||||
pal1 = 19;
|
||||
}
|
||||
|
||||
aux1 = rom_.GetPaletteGroup("ow_aux")[pal1];
|
||||
} else {
|
||||
aux1 = rom_.GetPaletteGroup("ow_aux")[0];
|
||||
}
|
||||
|
||||
if (pal2 == 255) {
|
||||
pal2 = rom_[core::overworldMapPaletteGroup + (previousPalId * 4) + 1];
|
||||
}
|
||||
if (pal2 != 255) {
|
||||
if (pal2 >= 20) {
|
||||
pal2 = 19;
|
||||
}
|
||||
|
||||
aux2 = rom_.GetPaletteGroup("ow_aux")[pal2];
|
||||
} else {
|
||||
aux2 = rom_.GetPaletteGroup("ow_aux")[0];
|
||||
}
|
||||
gfx::SNESPalette aux1 = GetPalette("ow_aux", pal1, previousPalId, 20);
|
||||
gfx::SNESPalette aux2 = GetPalette("ow_aux", pal2, previousPalId, 20);
|
||||
|
||||
// Additional handling of `pal3` and `parent_`
|
||||
if (pal3 == 255) {
|
||||
pal3 = rom_[core::overworldMapPaletteGroup + (previousPalId * 4) + 2];
|
||||
}
|
||||
|
||||
if (parent_ < 0x40) {
|
||||
// Default LW Palette
|
||||
pal0 = 0;
|
||||
pal0 = parent_ == 0x03 || parent_ == 0x05 || parent_ == 0x07 ? 2 : 0;
|
||||
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(0);
|
||||
if (parent_ == 0x03 || parent_ == 0x05 || parent_ == 0x07) {
|
||||
pal0 = 2;
|
||||
}
|
||||
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
||||
// Default DW Palette
|
||||
pal0 = 1;
|
||||
pal0 = parent_ == 0x43 || parent_ == 0x45 || parent_ == 0x47 ? 3 : 1;
|
||||
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(1);
|
||||
if (parent_ == 0x43 || parent_ == 0x45 || parent_ == 0x47) {
|
||||
pal0 = 3;
|
||||
}
|
||||
} else if (parent_ >= 128 && parent_ < core::kNumOverworldMaps) {
|
||||
// Default SP Palette
|
||||
pal0 = 0;
|
||||
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(2);
|
||||
}
|
||||
|
||||
if (parent_ == 0x88) {
|
||||
pal0 = 4;
|
||||
}
|
||||
gfx::SNESPalette main = GetPalette("ow_main", pal0, previousPalId, 255);
|
||||
gfx::SNESPalette animated =
|
||||
GetPalette("ow_animated", std::min((int)pal3, 13), previousPalId, 14);
|
||||
gfx::SNESPalette hud = rom_.GetPaletteGroup("hud")[0];
|
||||
|
||||
if (pal0 != 255) {
|
||||
main = rom_.GetPaletteGroup("ow_main")[pal0];
|
||||
} else {
|
||||
main = rom_.GetPaletteGroup("ow_main")[0];
|
||||
}
|
||||
|
||||
if (pal3 >= 14) {
|
||||
pal3 = 13;
|
||||
}
|
||||
animated = rom_.GetPaletteGroup("ow_animated")[(pal3)];
|
||||
|
||||
hud = rom_.GetPaletteGroup("hud")[0];
|
||||
if (pal4 == 255) {
|
||||
pal4 = rom_[core::overworldSpritePaletteGroup +
|
||||
(previousSprPalId * 2)]; // spr3
|
||||
}
|
||||
if (pal4 == 255) {
|
||||
pal4 = 0;
|
||||
}
|
||||
if (pal4 >= 24) {
|
||||
pal4 = 23;
|
||||
}
|
||||
spr = rom_.GetPaletteGroup("sprites_aux3")[pal4];
|
||||
|
||||
if (pal5 == 255) {
|
||||
pal5 = rom_[core::overworldSpritePaletteGroup + (previousSprPalId * 2) +
|
||||
1]; // spr3
|
||||
}
|
||||
if (pal5 == 255) {
|
||||
pal5 = 0;
|
||||
}
|
||||
if (pal5 >= 24) {
|
||||
pal5 = 23;
|
||||
}
|
||||
spr2 = rom_.GetPaletteGroup("sprites_aux3")[pal5];
|
||||
gfx::SNESPalette spr = GetPalette("sprites_aux3", pal4, previousSprPalId, 24);
|
||||
gfx::SNESPalette spr2 =
|
||||
GetPalette("sprites_aux3", pal5, previousSprPalId, 24);
|
||||
|
||||
SetColorsPalette(rom_, parent_, current_palette_, main, animated, aux1, aux2,
|
||||
hud, bgr, spr, spr2);
|
||||
}
|
||||
|
||||
// New helper function to process graphics buffer.
|
||||
void OverworldMap::ProcessGraphicsBuffer(int index, int static_graphics_offset,
|
||||
int size) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
auto byte = all_gfx_[i + (static_graphics_offset * size)];
|
||||
switch (index) {
|
||||
case 0:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
byte += 0x88;
|
||||
break;
|
||||
}
|
||||
current_gfx_[(index * size) + i] = byte;
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status OverworldMap::BuildTileset() {
|
||||
all_gfx_ = rom_.GetGraphicsBuffer();
|
||||
current_gfx_.reserve(0x10000);
|
||||
for (int i = 0; i < 0x10000; i++) {
|
||||
current_gfx_.push_back(0x00);
|
||||
}
|
||||
current_gfx_.resize(0x10000, 0x00);
|
||||
|
||||
for (int i = 0; i < 0x10; i++) {
|
||||
for (int j = 0; j < 0x1000; j++) {
|
||||
auto byte = all_gfx_[j + (static_graphics_[i] * 0x1000)];
|
||||
switch (i) {
|
||||
case 0:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
byte += 0x88;
|
||||
break;
|
||||
}
|
||||
current_gfx_[(i * 0x1000) + j] = byte;
|
||||
}
|
||||
ProcessGraphicsBuffer(i, static_graphics_[i], 0x1000);
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "app/core/common.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/rom.h"
|
||||
|
||||
namespace yaze {
|
||||
@@ -39,9 +40,21 @@ class OverworldMap {
|
||||
|
||||
private:
|
||||
void LoadAreaInfo();
|
||||
|
||||
void LoadWorldIndex();
|
||||
void LoadSpritesBlocksets();
|
||||
void LoadMainBlocksets();
|
||||
void LoadAreaGraphicsBlocksets();
|
||||
void LoadDeathMountainGFX();
|
||||
void LoadAreaGraphics();
|
||||
|
||||
void LoadPalette();
|
||||
|
||||
|
||||
|
||||
void ProcessGraphicsBuffer(int index, int static_graphics_offset, int size);
|
||||
gfx::SNESPalette GetPalette(const std::string& group, int index, int previousIndex, int limit);
|
||||
|
||||
absl::Status BuildTileset();
|
||||
absl::Status BuildTiles16Gfx(int count);
|
||||
absl::Status BuildBitmap(OWBlockset& world_blockset);
|
||||
@@ -54,6 +67,8 @@ class OverworldMap {
|
||||
int area_palette_ = 0;
|
||||
int game_state_ = 0;
|
||||
|
||||
int world_index_ = 0;
|
||||
|
||||
uchar sprite_graphics_[3];
|
||||
uchar sprite_palette_[3];
|
||||
uchar area_music_[4];
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "app/gui/canvas.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "app/gui/canvas.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
Reference in New Issue
Block a user