palettes and overworld drawing
This commit is contained in:
@@ -23,6 +23,7 @@ namespace {
|
|||||||
void InitializeKeymap() {
|
void InitializeKeymap() {
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
io.KeyMap[ImGuiKey_Backspace] = SDL_GetScancodeFromKey(SDLK_BACKSPACE);
|
io.KeyMap[ImGuiKey_Backspace] = SDL_GetScancodeFromKey(SDLK_BACKSPACE);
|
||||||
|
io.KeyMap[ImGuiKey_LeftShift] = SDL_GetScancodeFromKey(SDLK_LSHIFT);
|
||||||
io.KeyMap[ImGuiKey_Enter] = SDL_GetScancodeFromKey(SDLK_RETURN);
|
io.KeyMap[ImGuiKey_Enter] = SDL_GetScancodeFromKey(SDLK_RETURN);
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = SDL_GetScancodeFromKey(SDLK_UP);
|
io.KeyMap[ImGuiKey_UpArrow] = SDL_GetScancodeFromKey(SDLK_UP);
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = SDL_GetScancodeFromKey(SDLK_DOWN);
|
io.KeyMap[ImGuiKey_DownArrow] = SDL_GetScancodeFromKey(SDLK_DOWN);
|
||||||
@@ -37,6 +38,8 @@ void HandleKeyDown(SDL_Event &event) {
|
|||||||
case SDLK_DOWN:
|
case SDLK_DOWN:
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
case SDLK_BACKSPACE:
|
case SDLK_BACKSPACE:
|
||||||
|
case SDLK_LSHIFT:
|
||||||
|
case SDLK_LCTRL:
|
||||||
case SDLK_TAB:
|
case SDLK_TAB:
|
||||||
io.KeysDown[event.key.keysym.scancode] = (event.type == SDL_KEYDOWN);
|
io.KeysDown[event.key.keysym.scancode] = (event.type == SDL_KEYDOWN);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -16,25 +16,26 @@
|
|||||||
#include "gui/canvas.h"
|
#include "gui/canvas.h"
|
||||||
#include "gui/icons.h"
|
#include "gui/icons.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* Drawing the Overworld
|
|
||||||
* Tips by Zarby
|
|
||||||
*
|
|
||||||
* 1) Find the graphics pointers (constants.h)
|
|
||||||
* 2) Convert the 3bpp SNES data into PC 4bpp (Hard)
|
|
||||||
* 3) Get the tiles32 data
|
|
||||||
* 4) Get the tiles16 data
|
|
||||||
* 5) Get the map32 data using lz2 variant decompression
|
|
||||||
* 6) Get the graphics data of the map
|
|
||||||
* 7) Load 4bpp into Pseudo VRAM for rendering tiles to screen
|
|
||||||
* 8) Render the tiles to a bitmap with a B&W palette to start
|
|
||||||
* 9) Get the palette data and find how it's loaded in game
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void UpdateSelectedTile16(int selected, gfx::Bitmap &tile16_blockset,
|
||||||
|
gfx::Bitmap &selected_tile) {
|
||||||
|
auto blockset = tile16_blockset.GetData();
|
||||||
|
auto bitmap = selected_tile.GetData();
|
||||||
|
|
||||||
|
int src_pos = ((selected - ((selected / 0x08) * 0x08)) * 0x10) +
|
||||||
|
((selected / 0x08) * 2048);
|
||||||
|
for (int yy = 0; yy < 0x10; yy++) {
|
||||||
|
for (int xx = 0; xx < 0x10; xx++) {
|
||||||
|
bitmap[xx + (yy * 0x10)] = blockset[src_pos + xx + (yy * 0x80)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void OverworldEditor::SetupROM(ROM &rom) { rom_ = rom; }
|
void OverworldEditor::SetupROM(ROM &rom) { rom_ = rom; }
|
||||||
|
|
||||||
absl::Status OverworldEditor::Update() {
|
absl::Status OverworldEditor::Update() {
|
||||||
@@ -46,8 +47,12 @@ absl::Status OverworldEditor::Update() {
|
|||||||
current_gfx_bmp_.Create(128, 512, 64, overworld_.GetCurrentGraphics());
|
current_gfx_bmp_.Create(128, 512, 64, overworld_.GetCurrentGraphics());
|
||||||
rom_.RenderBitmap(¤t_gfx_bmp_);
|
rom_.RenderBitmap(¤t_gfx_bmp_);
|
||||||
|
|
||||||
|
auto tile16_palette = overworld_.GetCurrentPalette();
|
||||||
tile16_blockset_bmp_.Create(128, 8192, 128,
|
tile16_blockset_bmp_.Create(128, 8192, 128,
|
||||||
overworld_.GetCurrentBlockset());
|
overworld_.GetCurrentBlockset());
|
||||||
|
for (int j = 0; j < tile16_palette.colors.size(); j++) {
|
||||||
|
tile16_blockset_bmp_.SetPaletteColor(j, tile16_palette.GetColor(j));
|
||||||
|
}
|
||||||
rom_.RenderBitmap(&tile16_blockset_bmp_);
|
rom_.RenderBitmap(&tile16_blockset_bmp_);
|
||||||
map_blockset_loaded_ = true;
|
map_blockset_loaded_ = true;
|
||||||
|
|
||||||
@@ -55,11 +60,27 @@ absl::Status OverworldEditor::Update() {
|
|||||||
overworld_.SetCurrentMap(i);
|
overworld_.SetCurrentMap(i);
|
||||||
auto palette = overworld_.GetCurrentPalette();
|
auto palette = overworld_.GetCurrentPalette();
|
||||||
maps_bmp_[i].Create(512, 512, 512, overworld_.GetCurrentBitmapData());
|
maps_bmp_[i].Create(512, 512, 512, overworld_.GetCurrentBitmapData());
|
||||||
maps_bmp_[i].ApplyPalette(palette);
|
for (int j = 0; j < palette.colors.size(); j++) {
|
||||||
|
maps_bmp_[i].SetPaletteColor(j, palette.GetColor(j));
|
||||||
|
}
|
||||||
rom_.RenderBitmap(&(maps_bmp_[i]));
|
rom_.RenderBitmap(&(maps_bmp_[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (update_selected_tile_ && all_gfx_loaded_) {
|
||||||
|
if (!selected_tile_loaded_) {
|
||||||
|
selected_tile_bmp_.Create(16, 16, 64, 256);
|
||||||
|
}
|
||||||
|
UpdateSelectedTile16(selected_tile_, tile16_blockset_bmp_,
|
||||||
|
selected_tile_bmp_);
|
||||||
|
auto palette = overworld_.GetCurrentPalette();
|
||||||
|
for (int j = 0; j < palette.colors.size(); j++) {
|
||||||
|
selected_tile_bmp_.SetPaletteColor(j, palette.GetColor(j));
|
||||||
|
}
|
||||||
|
rom_.RenderBitmap(&selected_tile_bmp_);
|
||||||
|
update_selected_tile_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
auto toolset_status = DrawToolset();
|
auto toolset_status = DrawToolset();
|
||||||
RETURN_IF_ERROR(toolset_status)
|
RETURN_IF_ERROR(toolset_status)
|
||||||
|
|
||||||
@@ -81,7 +102,7 @@ absl::Status OverworldEditor::Update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status OverworldEditor::DrawToolset() {
|
absl::Status OverworldEditor::DrawToolset() {
|
||||||
if (ImGui::BeginTable("OWToolset", 17, toolset_table_flags, ImVec2(0, 0))) {
|
if (ImGui::BeginTable("OWToolset", 15, toolset_table_flags, ImVec2(0, 0))) {
|
||||||
for (const auto &name : kToolsetColumnNames)
|
for (const auto &name : kToolsetColumnNames)
|
||||||
ImGui::TableSetupColumn(name.data());
|
ImGui::TableSetupColumn(name.data());
|
||||||
|
|
||||||
@@ -119,19 +140,6 @@ absl::Status OverworldEditor::DrawToolset() {
|
|||||||
// Music
|
// Music
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_MUSIC_NOTE);
|
ImGui::Button(ICON_MD_MUSIC_NOTE);
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text(ICON_MD_MORE_VERT);
|
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
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(), ¤t_palette_[i].x,
|
|
||||||
ImGuiColorEditFlags_NoInputs |
|
|
||||||
ImGuiColorEditFlags_DisplayRGB |
|
|
||||||
ImGuiColorEditFlags_DisplayHex);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ static constexpr absl::string_view kToolsetColumnNames[] = {
|
|||||||
"#undoTool", "#redoTool", "#drawTool", "#separator2",
|
"#undoTool", "#redoTool", "#drawTool", "#separator2",
|
||||||
"#zoomOutTool", "#zoomInTool", "#separator", "#history",
|
"#zoomOutTool", "#zoomInTool", "#separator", "#history",
|
||||||
"#entranceTool", "#exitTool", "#itemTool", "#spriteTool",
|
"#entranceTool", "#exitTool", "#itemTool", "#spriteTool",
|
||||||
"#transportTool", "#musicTool", "#separator3", "#reloadTool"};
|
"#transportTool", "#musicTool" };
|
||||||
|
|
||||||
static constexpr absl::string_view kOverworldSettingsColumnNames[] = {
|
static constexpr absl::string_view kOverworldSettingsColumnNames[] = {
|
||||||
"##1stCol", "##gfxCol", "##palCol", "##sprgfxCol",
|
"##1stCol", "##gfxCol", "##palCol", "##sprgfxCol",
|
||||||
@@ -60,6 +60,7 @@ class OverworldEditor {
|
|||||||
|
|
||||||
int current_world_ = 0;
|
int current_world_ = 0;
|
||||||
int current_map_ = 0;
|
int current_map_ = 0;
|
||||||
|
int selected_tile_ = 0;
|
||||||
char map_gfx_[3] = "";
|
char map_gfx_[3] = "";
|
||||||
char map_palette_[3] = "";
|
char map_palette_[3] = "";
|
||||||
char spr_gfx_[3] = "";
|
char spr_gfx_[3] = "";
|
||||||
@@ -70,6 +71,8 @@ class OverworldEditor {
|
|||||||
bool opt_enable_grid = true;
|
bool opt_enable_grid = true;
|
||||||
bool all_gfx_loaded_ = false;
|
bool all_gfx_loaded_ = false;
|
||||||
bool map_blockset_loaded_ = false;
|
bool map_blockset_loaded_ = false;
|
||||||
|
bool selected_tile_loaded_ = false;
|
||||||
|
bool update_selected_tile_ = true;
|
||||||
|
|
||||||
ImVec4 current_palette_[8];
|
ImVec4 current_palette_[8];
|
||||||
|
|
||||||
@@ -90,6 +93,7 @@ class OverworldEditor {
|
|||||||
gfx::Bitmap tile16_blockset_bmp_; // pointer size 1048576
|
gfx::Bitmap tile16_blockset_bmp_; // pointer size 1048576
|
||||||
gfx::Bitmap current_gfx_bmp_; // pointer size 32768
|
gfx::Bitmap current_gfx_bmp_; // pointer size 32768
|
||||||
gfx::Bitmap all_gfx_bmp; // pointer size 456704
|
gfx::Bitmap all_gfx_bmp; // pointer size 456704
|
||||||
|
gfx::Bitmap selected_tile_bmp_;
|
||||||
|
|
||||||
gui::Canvas overworld_map_canvas_;
|
gui::Canvas overworld_map_canvas_;
|
||||||
gui::Canvas current_gfx_canvas_;
|
gui::Canvas current_gfx_canvas_;
|
||||||
|
|||||||
@@ -103,15 +103,17 @@ void Bitmap::CreateTexture(std::shared_ptr<SDL_Renderer> renderer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert SNESPalette to SDL_Palette for surface.
|
// Convert SNESPalette to SDL_Palette for surface.
|
||||||
void Bitmap::ApplyPalette(SNESPalette palette) {
|
void Bitmap::ApplyPalette(const SNESPalette & palette) {
|
||||||
palette_ = palette;
|
palette_ = palette;
|
||||||
surface_->format->palette = palette_.GetSDL_Palette();
|
SDL_SetPaletteColors(surface_->format->palette,
|
||||||
|
palette_.GetSDL_Palette()->colors,
|
||||||
|
0, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bitmap::SetPaletteColor(int id, gfx::snes_color color) {
|
void Bitmap::SetPaletteColor(int id, gfx::SNESColor color) {
|
||||||
surface_->format->palette->colors[id].r = color.red;
|
surface_->format->palette->colors[id].r = color.rgb.x;
|
||||||
surface_->format->palette->colors[id].b = color.blue;
|
surface_->format->palette->colors[id].g = color.rgb.y;
|
||||||
surface_->format->palette->colors[id].g = color.green;
|
surface_->format->palette->colors[id].b = color.rgb.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a vector of bitmaps which are individual 8x8 tiles.
|
// Creates a vector of bitmaps which are individual 8x8 tiles.
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class Bitmap {
|
|||||||
|
|
||||||
void CreateTexture(std::shared_ptr<SDL_Renderer> renderer);
|
void CreateTexture(std::shared_ptr<SDL_Renderer> renderer);
|
||||||
|
|
||||||
void ApplyPalette(SNESPalette palette);
|
void ApplyPalette(const SNESPalette &palette);
|
||||||
void SetPaletteColor(int id, gfx::snes_color color);
|
void SetPaletteColor(int id, gfx::SNESColor color);
|
||||||
|
|
||||||
absl::StatusOr<std::vector<Bitmap>> CreateTiles();
|
absl::StatusOr<std::vector<Bitmap>> CreateTiles();
|
||||||
absl::Status CreateFromTiles(const std::vector<Bitmap> &tiles);
|
absl::Status CreateFromTiles(const std::vector<Bitmap> &tiles);
|
||||||
|
|||||||
@@ -64,7 +64,11 @@ char* Convert(const snes_palette pal) {
|
|||||||
|
|
||||||
SNESColor::SNESColor() : rgb(ImVec4(0.f, 0.f, 0.f, 0.f)) {}
|
SNESColor::SNESColor() : rgb(ImVec4(0.f, 0.f, 0.f, 0.f)) {}
|
||||||
|
|
||||||
SNESColor::SNESColor(snes_color val) { snes = ConvertRGBtoSNES(val); }
|
SNESColor::SNESColor(snes_color val) {
|
||||||
|
rgb.x = val.red;
|
||||||
|
rgb.y = val.blue;
|
||||||
|
rgb.z = val.green;
|
||||||
|
}
|
||||||
|
|
||||||
SNESColor::SNESColor(ImVec4 val) : rgb(val) {
|
SNESColor::SNESColor(ImVec4 val) : rgb(val) {
|
||||||
snes_color col;
|
snes_color col;
|
||||||
@@ -83,7 +87,9 @@ void SNESColor::setRgb(ImVec4 val) {
|
|||||||
snes = ConvertRGBtoSNES(col);
|
snes = ConvertRGBtoSNES(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SNESColor::setRgb(snes_color val) { snes = ConvertRGBtoSNES(val); }
|
void SNESColor::setSNES(snes_color val) {
|
||||||
|
rgb = ImVec4(val.red, val.green, val.blue, 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
void SNESColor::setSNES(uint16_t val) {
|
void SNESColor::setSNES(uint16_t val) {
|
||||||
snes = val;
|
snes = val;
|
||||||
@@ -137,7 +143,7 @@ SNESPalette::SNESPalette(const std::vector<ImVec4>& cols) {
|
|||||||
SNESPalette::SNESPalette(const std::vector<snes_color>& cols) {
|
SNESPalette::SNESPalette(const std::vector<snes_color>& cols) {
|
||||||
for (const auto& each : cols) {
|
for (const auto& each : cols) {
|
||||||
SNESColor scol;
|
SNESColor scol;
|
||||||
scol.setRgb(each);
|
scol.setSNES(each);
|
||||||
colors.push_back(scol);
|
colors.push_back(scol);
|
||||||
}
|
}
|
||||||
size_ = cols.size();
|
size_ = cols.size();
|
||||||
@@ -151,7 +157,7 @@ SNESPalette::SNESPalette(const std::vector<SNESColor>& cols) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SNESPalette::Create(const std::vector<SNESColor>& cols) {
|
void SNESPalette::Create(const std::vector<SNESColor>& cols) {
|
||||||
for (const auto& each : cols) {
|
for (const auto each : cols) {
|
||||||
colors.push_back(each);
|
colors.push_back(each);
|
||||||
}
|
}
|
||||||
size_ = cols.size();
|
size_ = cols.size();
|
||||||
@@ -176,6 +182,7 @@ SDL_Palette* SNESPalette::GetSDL_Palette() {
|
|||||||
color[i].r = (uint8_t)colors[i].rgb.x * 100;
|
color[i].r = (uint8_t)colors[i].rgb.x * 100;
|
||||||
color[i].g = (uint8_t)colors[i].rgb.y * 100;
|
color[i].g = (uint8_t)colors[i].rgb.y * 100;
|
||||||
color[i].b = (uint8_t)colors[i].rgb.z * 100;
|
color[i].b = (uint8_t)colors[i].rgb.z * 100;
|
||||||
|
color[i].a = 0;
|
||||||
std::cout << "Color " << i << " added (R:" << color[i].r
|
std::cout << "Color " << i << " added (R:" << color[i].r
|
||||||
<< " G:" << color[i].g << " B:" << color[i].b << ")" << std::endl;
|
<< " G:" << color[i].g << " B:" << color[i].b << ")" << std::endl;
|
||||||
}
|
}
|
||||||
@@ -183,10 +190,7 @@ SDL_Palette* SNESPalette::GetSDL_Palette() {
|
|||||||
return sdl_palette.get();
|
return sdl_palette.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
PaletteGroup::PaletteGroup(uint8_t mSize) {
|
PaletteGroup::PaletteGroup(uint8_t mSize) : size(mSize) {}
|
||||||
size = mSize;
|
|
||||||
palettes.reserve(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|||||||
@@ -41,11 +41,13 @@ struct SNESColor {
|
|||||||
SNESColor();
|
SNESColor();
|
||||||
explicit SNESColor(ImVec4);
|
explicit SNESColor(ImVec4);
|
||||||
explicit SNESColor(snes_color);
|
explicit SNESColor(snes_color);
|
||||||
|
|
||||||
|
void setRgb(ImVec4);
|
||||||
|
void setSNES(snes_color);
|
||||||
|
void setSNES(uint16_t);
|
||||||
|
|
||||||
uint16_t snes = 0;
|
uint16_t snes = 0;
|
||||||
ImVec4 rgb;
|
ImVec4 rgb;
|
||||||
void setRgb(ImVec4);
|
|
||||||
void setRgb(snes_color);
|
|
||||||
void setSNES(uint16_t);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SNESPalette {
|
class SNESPalette {
|
||||||
@@ -59,7 +61,7 @@ class SNESPalette {
|
|||||||
explicit SNESPalette(const std::vector<SNESColor>&);
|
explicit SNESPalette(const std::vector<SNESColor>&);
|
||||||
|
|
||||||
void Create(const std::vector<SNESColor>&);
|
void Create(const std::vector<SNESColor>&);
|
||||||
|
void AddColor(SNESColor color) { colors.push_back(color); }
|
||||||
auto GetColor(int i) const { return colors[i]; }
|
auto GetColor(int i) const { return colors[i]; }
|
||||||
|
|
||||||
SNESColor operator[](int i) {
|
SNESColor operator[](int i) {
|
||||||
@@ -80,6 +82,17 @@ class SNESPalette {
|
|||||||
struct PaletteGroup {
|
struct PaletteGroup {
|
||||||
PaletteGroup() = default;
|
PaletteGroup() = default;
|
||||||
explicit PaletteGroup(uint8_t mSize);
|
explicit PaletteGroup(uint8_t mSize);
|
||||||
|
void AddPalette(SNESPalette pal) {
|
||||||
|
palettes.emplace_back(pal);
|
||||||
|
size = palettes.size();
|
||||||
|
}
|
||||||
|
void AddColor(SNESColor color) {
|
||||||
|
if (size == 0) {
|
||||||
|
SNESPalette empty_pal;
|
||||||
|
palettes.emplace_back(empty_pal);
|
||||||
|
}
|
||||||
|
palettes[0].AddColor(color);
|
||||||
|
}
|
||||||
SNESPalette operator[](int i) {
|
SNESPalette operator[](int i) {
|
||||||
if (i > size) {
|
if (i > size) {
|
||||||
std::cout << "PaletteGroup: Index out of bounds" << std::endl;
|
std::cout << "PaletteGroup: Index out of bounds" << std::endl;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/zelda3/palettes.h"
|
|
||||||
|
|
||||||
#define COMPRESSION_STRING_MOD 7 << 5
|
#define COMPRESSION_STRING_MOD 7 << 5
|
||||||
|
|
||||||
@@ -535,8 +534,8 @@ absl::StatusOr<Bytes> ROM::Decompress(int offset, int size, int mode) {
|
|||||||
|
|
||||||
if (mode == kNintendoMode1) { // Reversed byte order for overworld maps
|
if (mode == kNintendoMode1) { // Reversed byte order for overworld maps
|
||||||
// addr = (s2 | s1);
|
// addr = (s2 | s1);
|
||||||
addr = (rom_data_[offset + 2]) | ((rom_data_[offset + 1]) << 8);
|
addr = (rom_data_[offset + 1]) | ((rom_data_[offset]) << 8);
|
||||||
memcpy(buffer.data() + buffer_pos, rom_data_.data() + offset, length);
|
memcpy(buffer.data() + buffer_pos, buffer.data() + addr, length);
|
||||||
buffer_pos += length;
|
buffer_pos += length;
|
||||||
offset += 2;
|
offset += 2;
|
||||||
break;
|
break;
|
||||||
@@ -699,7 +698,7 @@ gfx::SNESColor ROM::ReadColor(int offset) {
|
|||||||
|
|
||||||
gfx::SNESPalette ROM::ReadPalette(int offset, int num_colors) {
|
gfx::SNESPalette ROM::ReadPalette(int offset, int num_colors) {
|
||||||
int color_offset = 0;
|
int color_offset = 0;
|
||||||
std::vector<gfx::snes_color> colors(num_colors);
|
std::vector<gfx::SNESColor> colors(num_colors);
|
||||||
|
|
||||||
while (color_offset < num_colors) {
|
while (color_offset < num_colors) {
|
||||||
short color = (short)((rom_data_[offset + 1] << 8) + rom_data_[offset]);
|
short color = (short)((rom_data_[offset + 1] << 8) + rom_data_[offset]);
|
||||||
@@ -707,7 +706,7 @@ gfx::SNESPalette ROM::ReadPalette(int offset, int num_colors) {
|
|||||||
new_color.red = (color & 0x1F) * 8;
|
new_color.red = (color & 0x1F) * 8;
|
||||||
new_color.green = ((color >> 5) & 0x1F) * 8;
|
new_color.green = ((color >> 5) & 0x1F) * 8;
|
||||||
new_color.blue = ((color >> 10) & 0x1F) * 8;
|
new_color.blue = ((color >> 10) & 0x1F) * 8;
|
||||||
colors[color_offset] = new_color;
|
colors[color_offset].setSNES(new_color);
|
||||||
color_offset++;
|
color_offset++;
|
||||||
offset += 2;
|
offset += 2;
|
||||||
}
|
}
|
||||||
@@ -719,66 +718,70 @@ gfx::SNESPalette ROM::ReadPalette(int offset, int num_colors) {
|
|||||||
void ROM::LoadAllPalettes() {
|
void ROM::LoadAllPalettes() {
|
||||||
// 35 colors each, 7x5 (0,2 on grid)
|
// 35 colors each, 7x5 (0,2 on grid)
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
zelda3::overworld_MainPalettes[i] =
|
palette_groups_["ow_main"].AddPalette(
|
||||||
ReadPalette(core::overworldPaletteMain + (i * (35 * 2)), 35);
|
ReadPalette(core::overworldPaletteMain + (i * (35 * 2)), 35));
|
||||||
}
|
}
|
||||||
// 21 colors each, 7x3 (8,2 and 8,5 on grid)
|
// 21 colors each, 7x3 (8,2 and 8,5 on grid)
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
zelda3::overworld_AuxPalettes[i] =
|
palette_groups_["ow_aux"].AddPalette(
|
||||||
ReadPalette(core::overworldPaletteAuxialiary + (i * (21 * 2)), 21);
|
ReadPalette(core::overworldPaletteAuxialiary + (i * (21 * 2)), 21));
|
||||||
}
|
}
|
||||||
// 7 colors each 7x1 (0,7 on grid)
|
// 7 colors each 7x1 (0,7 on grid)
|
||||||
for (int i = 0; i < 14; i++) {
|
for (int i = 0; i < 14; i++) {
|
||||||
zelda3::overworld_AnimatedPalettes[i] =
|
palette_groups_["ow_animated"].AddPalette(
|
||||||
ReadPalette(core::overworldPaletteAnimated + (i * (7 * 2)), 7);
|
ReadPalette(core::overworldPaletteAnimated + (i * (7 * 2)), 7));
|
||||||
}
|
}
|
||||||
// 32 colors each 16x2 (0,0 on grid)
|
// 32 colors each 16x2 (0,0 on grid)
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
zelda3::HudPalettes[i] = ReadPalette(core::hudPalettes + (i * 64), 32);
|
palette_groups_["hud"].AddPalette(
|
||||||
|
ReadPalette(core::hudPalettes + (i * 64), 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
zelda3::globalSprite_Palettes[0] =
|
palette_groups_["global_sprites"].AddPalette(
|
||||||
ReadPalette(core::globalSpritePalettesLW, 60);
|
ReadPalette(core::globalSpritePalettesLW, 60));
|
||||||
zelda3::globalSprite_Palettes[1] =
|
palette_groups_["global_sprites"].AddPalette(
|
||||||
ReadPalette(core::globalSpritePalettesDW, 60);
|
ReadPalette(core::globalSpritePalettesDW, 60));
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
zelda3::armors_Palettes[i] =
|
palette_groups_["armors"].AddPalette(
|
||||||
ReadPalette(core::armorPalettes + (i * 30), 15);
|
ReadPalette(core::armorPalettes + (i * 30), 15));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
zelda3::swords_Palettes[i] = ReadPalette(core::swordPalettes + (i * 6), 3);
|
palette_groups_["swords"].AddPalette(
|
||||||
|
ReadPalette(core::swordPalettes + (i * 6), 3));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
zelda3::shields_Palettes[i] =
|
palette_groups_["shields"].AddPalette(
|
||||||
ReadPalette(core::shieldPalettes + (i * 8), 4);
|
ReadPalette(core::shieldPalettes + (i * 8), 4));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
zelda3::spritesAux1_Palettes[i] =
|
palette_groups_["sprites_aux1"].AddPalette(
|
||||||
ReadPalette(core::spritePalettesAux1 + (i * 14), 7);
|
ReadPalette(core::spritePalettesAux1 + (i * 14), 7));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 11; i++) {
|
for (int i = 0; i < 11; i++) {
|
||||||
zelda3::spritesAux2_Palettes[i] =
|
palette_groups_["sprites_aux2"].AddPalette(
|
||||||
ReadPalette(core::spritePalettesAux2 + (i * 14), 7);
|
ReadPalette(core::spritePalettesAux2 + (i * 14), 7));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int i = 0; i < 24; i++) {
|
||||||
zelda3::spritesAux3_Palettes[i] =
|
palette_groups_["sprites_aux3"].AddPalette(
|
||||||
ReadPalette(core::spritePalettesAux3 + (i * 14), 7);
|
ReadPalette(core::spritePalettesAux3 + (i * 14), 7));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
zelda3::dungeonsMain_Palettes[i] =
|
palette_groups_["dungeon_main"].AddPalette(
|
||||||
ReadPalette(core::dungeonMainPalettes + (i * 180), 90);
|
ReadPalette(core::dungeonMainPalettes + (i * 180), 90));
|
||||||
}
|
}
|
||||||
|
|
||||||
zelda3::overworld_GrassPalettes[0] = ReadColor(core::hardcodedGrassLW);
|
palette_groups_["grass"].AddColor(ReadColor(core::hardcodedGrassLW));
|
||||||
zelda3::overworld_GrassPalettes[1] = ReadColor(core::hardcodedGrassDW);
|
palette_groups_["grass"].AddColor(ReadColor(core::hardcodedGrassDW));
|
||||||
zelda3::overworld_GrassPalettes[2] = ReadColor(core::hardcodedGrassSpecial);
|
palette_groups_["grass"].AddColor(ReadColor(core::hardcodedGrassSpecial));
|
||||||
|
|
||||||
zelda3::object3D_Palettes[0] = ReadPalette(core::triforcePalette, 8);
|
palette_groups_["3d_object"].AddPalette(
|
||||||
zelda3::object3D_Palettes[1] = ReadPalette(core::crystalPalette, 8);
|
ReadPalette(core::triforcePalette, 8));
|
||||||
|
palette_groups_["3d_object"].AddPalette(ReadPalette(core::crystalPalette, 8));
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
zelda3::overworld_Mini_Map_Palettes[i] =
|
palette_groups_["ow_mini_map"].AddPalette(
|
||||||
ReadPalette(core::overworldMiniMapPalettes + (i * 256), 128);
|
ReadPalette(core::overworldMiniMapPalettes + (i * 256), 128));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check for the paletts in the empty bank space that kan will allocate
|
// TODO: check for the paletts in the empty bank space that kan will allocate
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/zelda3/palettes.h"
|
|
||||||
|
|
||||||
#define BUILD_HEADER(command, length) (command << 5) + (length - 1)
|
#define BUILD_HEADER(command, length) (command << 5) + (length - 1)
|
||||||
|
|
||||||
@@ -94,6 +93,7 @@ class ROM {
|
|||||||
auto GetTitle() const { return title; }
|
auto GetTitle() const { return title; }
|
||||||
auto GetGraphicsBin() const { return graphics_bin_; }
|
auto GetGraphicsBin() const { return graphics_bin_; }
|
||||||
auto GetGraphicsBuffer() const { return graphics_buffer_; }
|
auto GetGraphicsBuffer() const { return graphics_buffer_; }
|
||||||
|
auto GetPaletteGroup(std::string group) { return palette_groups_[group]; }
|
||||||
void SetupRenderer(std::shared_ptr<SDL_Renderer> renderer) {
|
void SetupRenderer(std::shared_ptr<SDL_Renderer> renderer) {
|
||||||
renderer_ = renderer;
|
renderer_ = renderer;
|
||||||
}
|
}
|
||||||
@@ -133,6 +133,7 @@ class ROM {
|
|||||||
Bytes graphics_buffer_;
|
Bytes graphics_buffer_;
|
||||||
std::shared_ptr<SDL_Renderer> renderer_;
|
std::shared_ptr<SDL_Renderer> renderer_;
|
||||||
std::unordered_map<int, gfx::Bitmap> graphics_bin_;
|
std::unordered_map<int, gfx::Bitmap> graphics_bin_;
|
||||||
|
std::unordered_map<std::string, gfx::PaletteGroup> palette_groups_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ void CopyTile8bpp16(int x, int y, int tile, Bytes& bitmap, Bytes& blockset) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetColorsPalette(int index, gfx::SNESPalette& current, gfx::SNESPalette main,
|
void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||||
gfx::SNESPalette animated, gfx::SNESPalette aux1,
|
gfx::SNESPalette main, gfx::SNESPalette animated,
|
||||||
gfx::SNESPalette aux2, gfx::SNESPalette hud,
|
gfx::SNESPalette aux1, gfx::SNESPalette aux2,
|
||||||
gfx::SNESColor bgrcolor, gfx::SNESPalette spr,
|
gfx::SNESPalette hud, gfx::SNESColor bgrcolor,
|
||||||
gfx::SNESPalette spr2) {
|
gfx::SNESPalette spr, gfx::SNESPalette spr2) {
|
||||||
// Palettes infos, color 0 of a palette is always transparent (the arrays
|
// Palettes infos, color 0 of a palette is always transparent (the arrays
|
||||||
// contains 7 colors width wide) There is 16 color per line so 16*Y
|
// contains 7 colors width wide) There is 16 color per line so 16*Y
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ void SetColorsPalette(int index, gfx::SNESPalette& current, gfx::SNESPalette mai
|
|||||||
k = 0;
|
k = 0;
|
||||||
for (int y = 8; y < 9; y++) {
|
for (int y = 8; y < 9; y++) {
|
||||||
for (int x = 1; x < 8; x++) {
|
for (int x = 1; x < 8; x++) {
|
||||||
new_palette[x + (16 * y)] = spritesAux1_Palettes[1][k++];
|
new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux1")[1][k++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ void SetColorsPalette(int index, gfx::SNESPalette& current, gfx::SNESPalette mai
|
|||||||
k = 0;
|
k = 0;
|
||||||
for (int y = 8; y < 9; y++) {
|
for (int y = 8; y < 9; y++) {
|
||||||
for (int x = 9; x < 16; x++) {
|
for (int x = 9; x < 16; x++) {
|
||||||
new_palette[x + (16 * y)] = spritesAux3_Palettes[0][k++];
|
new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux3")[0][k++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ void SetColorsPalette(int index, gfx::SNESPalette& current, gfx::SNESPalette mai
|
|||||||
k = 0;
|
k = 0;
|
||||||
for (int y = 9; y < 13; y++) {
|
for (int y = 9; y < 13; y++) {
|
||||||
for (int x = 1; x < 16; x++) {
|
for (int x = 1; x < 16; x++) {
|
||||||
new_palette[x + (16 * y)] = globalSprite_Palettes[0][k++];
|
new_palette[x + (16 * y)] = rom.GetPaletteGroup("global_sprites")[0][k++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ void SetColorsPalette(int index, gfx::SNESPalette& current, gfx::SNESPalette mai
|
|||||||
k = 0;
|
k = 0;
|
||||||
for (int y = 15; y < 16; y++) {
|
for (int y = 15; y < 16; y++) {
|
||||||
for (int x = 1; x < 16; x++) {
|
for (int x = 1; x < 16; x++) {
|
||||||
new_palette[x + (16 * y)] = armors_Palettes[0][k++];
|
new_palette[x + (16 * y)] = rom.GetPaletteGroup("armors")[0][k++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,8 +345,14 @@ void OverworldMap::LoadPalette() {
|
|||||||
uchar pal5 = rom_[core::overworldSpritePaletteGroup +
|
uchar pal5 = rom_[core::overworldSpritePaletteGroup +
|
||||||
(sprite_palette_[game_state_] * 2) + 1]; // spr4
|
(sprite_palette_[game_state_] * 2) + 1]; // spr4
|
||||||
|
|
||||||
gfx::SNESPalette aux1, aux2, main, animated, hud, spr, spr2;
|
gfx::SNESPalette aux1;
|
||||||
gfx::SNESColor bgr = overworld_GrassPalettes[0];
|
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) {
|
if (pal1 == 255) {
|
||||||
pal1 = rom_[core::overworldMapPaletteGroup + (previousPalId * 4)];
|
pal1 = rom_[core::overworldMapPaletteGroup + (previousPalId * 4)];
|
||||||
@@ -356,9 +362,9 @@ void OverworldMap::LoadPalette() {
|
|||||||
pal1 = 19;
|
pal1 = 19;
|
||||||
}
|
}
|
||||||
|
|
||||||
aux1 = overworld_AuxPalettes[pal1];
|
aux1 = rom_.GetPaletteGroup("ow_aux")[pal1];
|
||||||
} else {
|
} else {
|
||||||
aux1 = overworld_AuxPalettes[0];
|
aux1 = rom_.GetPaletteGroup("ow_aux")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pal2 == 255) {
|
if (pal2 == 255) {
|
||||||
@@ -369,9 +375,9 @@ void OverworldMap::LoadPalette() {
|
|||||||
pal2 = 19;
|
pal2 = 19;
|
||||||
}
|
}
|
||||||
|
|
||||||
aux2 = overworld_AuxPalettes[pal2];
|
aux2 = rom_.GetPaletteGroup("ow_aux")[pal2];
|
||||||
} else {
|
} else {
|
||||||
aux2 = overworld_AuxPalettes[0];
|
aux2 = rom_.GetPaletteGroup("ow_aux")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pal3 == 255) {
|
if (pal3 == 255) {
|
||||||
@@ -382,37 +388,20 @@ void OverworldMap::LoadPalette() {
|
|||||||
// Default LW Palette
|
// Default LW Palette
|
||||||
pal0 = 0;
|
pal0 = 0;
|
||||||
|
|
||||||
// TODO CHECK ME FOR NECESSITY
|
|
||||||
// if (OverworldEditor.UseAreaSpecificBgColor) {
|
|
||||||
// bgr = overworld_BackgroundPalette[parent_];
|
|
||||||
// } else {
|
|
||||||
// bgr = overworld_GrassPalettes[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (parent_ == 0x03 || parent_ == 0x05 || parent_ == 0x07) {
|
if (parent_ == 0x03 || parent_ == 0x05 || parent_ == 0x07) {
|
||||||
pal0 = 2;
|
pal0 = 2;
|
||||||
}
|
}
|
||||||
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
||||||
// Default DW Palette
|
// Default DW Palette
|
||||||
pal0 = 1;
|
pal0 = 1;
|
||||||
// if (OverworldEditor.UseAreaSpecificBgColor) {
|
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(1);
|
||||||
// bgr = Palettes.overworld_BackgroundPalette[parent_];
|
|
||||||
// } else {
|
|
||||||
// bgr = Palettes.overworld_GrassPalettes[1];
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (parent_ == 0x43 || parent_ == 0x45 || parent_ == 0x47) {
|
if (parent_ == 0x43 || parent_ == 0x45 || parent_ == 0x47) {
|
||||||
pal0 = 3;
|
pal0 = 3;
|
||||||
}
|
}
|
||||||
} else if (parent_ >= 128 && parent_ < core::kNumOverworldMaps) {
|
} else if (parent_ >= 128 && parent_ < core::kNumOverworldMaps) {
|
||||||
// Default SP Palette
|
// Default SP Palette
|
||||||
pal0 = 0;
|
pal0 = 0;
|
||||||
|
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(2);
|
||||||
// if (OverworldEditor.UseAreaSpecificBgColor) {
|
|
||||||
// bgr = overworld_BackgroundPalette[parent_];
|
|
||||||
// } else {
|
|
||||||
// bgr = overworld_GrassPalettes[2];
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent_ == 0x88) {
|
if (parent_ == 0x88) {
|
||||||
@@ -420,17 +409,17 @@ void OverworldMap::LoadPalette() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pal0 != 255) {
|
if (pal0 != 255) {
|
||||||
main = overworld_MainPalettes[pal0];
|
main = rom_.GetPaletteGroup("ow_main")[pal0];
|
||||||
} else {
|
} else {
|
||||||
main = overworld_MainPalettes[0];
|
main = rom_.GetPaletteGroup("ow_main")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pal3 >= 14) {
|
if (pal3 >= 14) {
|
||||||
pal3 = 13;
|
pal3 = 13;
|
||||||
}
|
}
|
||||||
animated = overworld_AnimatedPalettes[(pal3)];
|
animated = rom_.GetPaletteGroup("ow_animated")[(pal3)];
|
||||||
|
|
||||||
hud = HudPalettes[0];
|
hud = rom_.GetPaletteGroup("hud")[0];
|
||||||
if (pal4 == 255) {
|
if (pal4 == 255) {
|
||||||
pal4 = rom_[core::overworldSpritePaletteGroup +
|
pal4 = rom_[core::overworldSpritePaletteGroup +
|
||||||
(previousSprPalId * 2)]; // spr3
|
(previousSprPalId * 2)]; // spr3
|
||||||
@@ -441,7 +430,7 @@ void OverworldMap::LoadPalette() {
|
|||||||
if (pal4 >= 24) {
|
if (pal4 >= 24) {
|
||||||
pal4 = 23;
|
pal4 = 23;
|
||||||
}
|
}
|
||||||
spr = spritesAux3_Palettes[pal4];
|
spr = rom_.GetPaletteGroup("sprites_aux3")[pal4];
|
||||||
|
|
||||||
if (pal5 == 255) {
|
if (pal5 == 255) {
|
||||||
pal5 = rom_[core::overworldSpritePaletteGroup + (previousSprPalId * 2) +
|
pal5 = rom_[core::overworldSpritePaletteGroup + (previousSprPalId * 2) +
|
||||||
@@ -453,9 +442,10 @@ void OverworldMap::LoadPalette() {
|
|||||||
if (pal5 >= 24) {
|
if (pal5 >= 24) {
|
||||||
pal5 = 23;
|
pal5 = 23;
|
||||||
}
|
}
|
||||||
spr2 = spritesAux3_Palettes[pal5];
|
spr2 = rom_.GetPaletteGroup("sprites_aux3")[pal5];
|
||||||
|
|
||||||
SetColorsPalette(parent_, current_palette_, main, animated, aux1, aux2, hud, bgr, spr, spr2);
|
SetColorsPalette(rom_, parent_, current_palette_, main, animated, aux1, aux2,
|
||||||
|
hud, bgr, spr, spr2);
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status OverworldMap::BuildTileset() {
|
absl::Status OverworldMap::BuildTileset() {
|
||||||
@@ -505,7 +495,8 @@ absl::Status OverworldMap::BuildTiles16Gfx(int count) {
|
|||||||
int source = ypos + xpos + (x + (y * 0x80));
|
int source = ypos + xpos + (x + (y * 0x80));
|
||||||
|
|
||||||
auto destination = xx + yy + offset + (mx + (my * 0x80));
|
auto destination = xx + yy + offset + (mx + (my * 0x80));
|
||||||
current_blockset_[destination] = current_gfx_[source];
|
current_blockset_[destination] =
|
||||||
|
current_gfx_[source] + (info.palette_ * 0x10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/zelda3/palettes.h"
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
#ifndef YAZE_APP_ZELDA3_PALETTES_H
|
|
||||||
#define YAZE_APP_ZELDA3_PALETTES_H
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include "app/core/common.h"
|
|
||||||
#include "app/gfx/bitmap.h"
|
|
||||||
#include "app/gfx/snes_tile.h"
|
|
||||||
#include "app/rom.h"
|
|
||||||
|
|
||||||
namespace yaze {
|
|
||||||
namespace app {
|
|
||||||
namespace zelda3 {
|
|
||||||
// 32 (0,0)
|
|
||||||
static gfx::PaletteGroup HudPalettes(2);
|
|
||||||
|
|
||||||
// 35 colors each, 7x5 (0,2 on grid)
|
|
||||||
static gfx::PaletteGroup overworld_MainPalettes(6);
|
|
||||||
|
|
||||||
// 21 colors each, 7x3 (8,2 and 8,5 on grid)
|
|
||||||
static gfx::PaletteGroup overworld_AuxPalettes(20);
|
|
||||||
|
|
||||||
// 7 colors each 7x1 (0,7 on grid)
|
|
||||||
static gfx::PaletteGroup overworld_AnimatedPalettes(14);
|
|
||||||
static gfx::PaletteGroup globalSprite_Palettes(2); // 60 (1,9)
|
|
||||||
static gfx::PaletteGroup armors_Palettes(5); // 15
|
|
||||||
static gfx::PaletteGroup swords_Palettes(4); // 3
|
|
||||||
static gfx::PaletteGroup spritesAux1_Palettes(12); // 7
|
|
||||||
static gfx::PaletteGroup spritesAux2_Palettes(11); // 7
|
|
||||||
static gfx::PaletteGroup spritesAux3_Palettes(24); // 7
|
|
||||||
static gfx::PaletteGroup shields_Palettes(3); // 4
|
|
||||||
static gfx::PaletteGroup dungeonsMain_Palettes(20); // 15*6
|
|
||||||
|
|
||||||
// 8*20
|
|
||||||
static gfx::PaletteGroup overworld_BackgroundPalette(core::kNumOverworldMaps);
|
|
||||||
|
|
||||||
// 3 hardcoded grass colors
|
|
||||||
static gfx::SNESPalette overworld_GrassPalettes(3);
|
|
||||||
static gfx::PaletteGroup object3D_Palettes(2); // 15*6
|
|
||||||
static gfx::PaletteGroup overworld_Mini_Map_Palettes(2); // 16*8
|
|
||||||
} // namespace zelda3
|
|
||||||
} // namespace app
|
|
||||||
} // namespace yaze
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -37,15 +37,14 @@ void Canvas::DrawContextMenu() {
|
|||||||
io.MousePos.y - origin.y);
|
io.MousePos.y - origin.y);
|
||||||
|
|
||||||
// Add first and second point
|
// Add first and second point
|
||||||
if (is_hovered && !dragging_select_ &&
|
if (is_hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||||
ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
ImVec2 draw_tile_outline_pos;
|
||||||
points_.push_back(mouse_pos_in_canvas);
|
draw_tile_outline_pos.x = std::round((double)mouse_pos_in_canvas.x / 32) * 32;
|
||||||
points_.push_back(mouse_pos_in_canvas);
|
draw_tile_outline_pos.y = std::round((double)mouse_pos_in_canvas.y / 32) * 32;
|
||||||
dragging_select_ = true;
|
|
||||||
}
|
points_.push_back(draw_tile_outline_pos);
|
||||||
if (dragging_select_) {
|
points_.push_back(
|
||||||
points_.back() = mouse_pos_in_canvas;
|
ImVec2(draw_tile_outline_pos.x + 32, draw_tile_outline_pos.y + 32));
|
||||||
if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) dragging_select_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pan (we use a zero mouse threshold when there's no context menu)
|
// Pan (we use a zero mouse threshold when there's no context menu)
|
||||||
@@ -62,8 +61,6 @@ void Canvas::DrawContextMenu() {
|
|||||||
ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
|
|
||||||
if (ImGui::BeginPopup("context")) {
|
if (ImGui::BeginPopup("context")) {
|
||||||
if (dragging_select_) points_.resize(points_.size() - 2);
|
|
||||||
dragging_select_ = false;
|
|
||||||
if (ImGui::MenuItem("Remove all", nullptr, false, points_.Size > 0)) {
|
if (ImGui::MenuItem("Remove all", nullptr, false, points_.Size > 0)) {
|
||||||
points_.clear();
|
points_.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class Canvas {
|
|||||||
void DrawContextMenu();
|
void DrawContextMenu();
|
||||||
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0);
|
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0);
|
||||||
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
|
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
|
||||||
// void DrawLargeBitmap(const Bitmap& tl, const Bitmap& tr, const Bitmap& bl, const Bitmap& br);
|
|
||||||
void DrawOutline(int x, int y, int w, int h);
|
void DrawOutline(int x, int y, int w, int h);
|
||||||
void DrawGrid(float grid_step = 64.0f);
|
void DrawGrid(float grid_step = 64.0f);
|
||||||
void DrawOverlay(); // last
|
void DrawOverlay(); // last
|
||||||
@@ -38,7 +37,6 @@ class Canvas {
|
|||||||
private:
|
private:
|
||||||
bool enable_grid_ = true;
|
bool enable_grid_ = true;
|
||||||
bool enable_context_menu_ = true;
|
bool enable_context_menu_ = true;
|
||||||
bool dragging_select_ = false;
|
|
||||||
bool custom_canvas_size_ = false;
|
bool custom_canvas_size_ = false;
|
||||||
|
|
||||||
ImDrawList* draw_list_;
|
ImDrawList* draw_list_;
|
||||||
|
|||||||
Reference in New Issue
Block a user