From aa1a5a36ada8a07e3e5517762086f703fcf853a3 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 11 Sep 2022 15:53:02 -0500 Subject: [PATCH] housekeeping --- src/app/editor/master_editor.cc | 4 +-- src/app/gfx/bitmap.cc | 57 --------------------------------- src/app/gfx/bitmap.h | 6 ---- src/app/zelda3/overworld_map.cc | 33 ++++++++++--------- 4 files changed, 20 insertions(+), 80 deletions(-) diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index 07b853de..59a8a363 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -119,10 +119,10 @@ void MasterEditor::DrawAboutPopup() { if (about_) ImGui::OpenPopup("About"); if (ImGui::BeginPopupModal("About", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::Text("Yet Another Zelda3 Editor - v0.01"); + ImGui::Text("Yet Another Zelda3 Editor - v0.02"); ImGui::Text("Written by: scawful"); ImGui::Spacing(); - ImGui::Text("Special Thanks: Zarby89"); + ImGui::Text("Special Thanks: Zarby89, JaredBrian"); ImGui::Separator(); if (ImGui::Button("Close", ImVec2(200, 0))) { diff --git a/src/app/gfx/bitmap.cc b/src/app/gfx/bitmap.cc index 0b5f7989..201e890b 100644 --- a/src/app/gfx/bitmap.cc +++ b/src/app/gfx/bitmap.cc @@ -120,63 +120,6 @@ void Bitmap::ApplyPalette(const SNESPalette &palette) { } } -void Bitmap::SetPaletteColor(int id, gfx::SNESColor color) { - surface_->format->palette->colors[id].r = color.rgb.x; - surface_->format->palette->colors[id].g = color.rgb.y; - surface_->format->palette->colors[id].b = color.rgb.z; -} - -// Creates a vector of bitmaps which are individual 8x8 tiles. -absl::StatusOr> Bitmap::CreateTiles() { - std::vector tiles; - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 4; ++j) { - Bitmap bmp; - bmp.Create(8, 8, 8, 32); - auto surface = bmp.GetSurface(); - SDL_Rect src_rect = {i, j, 8, 8}; - if (SDL_BlitSurface(surface_.get(), &src_rect, surface, nullptr) != 0) - return absl::InternalError( - absl::StrCat("Failed to blit surface: ", SDL_GetError())); - tiles.push_back(bmp); - } - } - return tiles; -} - -// Converts a vector of 8x8 tiles into a tilesheet. -absl::Status Bitmap::CreateFromTiles(const std::vector &tiles) { - if (tiles.empty()) - return absl::InvalidArgumentError( - "Failed to create bitmap: `tiles` is empty."); - - SDL_Rect tile_rect = {0, 0, 8, 8}; - SDL_Rect dest_rect = {0, 0, 8, 8}; - for (const auto &tile : tiles) { - auto src = tile.GetSurface(); - if (SDL_BlitSurface(src, &tile_rect, surface_.get(), &dest_rect) != 0) - return absl::InternalError( - absl::StrCat("Failed to blit surface: ", SDL_GetError())); - - dest_rect.x++; - if (dest_rect.x == 15) { - dest_rect.x = 0; - dest_rect.y++; - } - } - - return absl::OkStatus(); -} - -absl::Status Bitmap::WritePixel(int pos, uchar pixel) { - if (!surface_) { - return absl::InternalError("Surface not loaded"); - } - auto pixels = (char *)surface_->pixels; - pixels[pos] = pixel; - return absl::OkStatus(); -} - } // namespace gfx } // namespace app } // namespace yaze diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index 43588e65..84dfa5d0 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -31,12 +31,6 @@ class Bitmap { void CreateTexture(std::shared_ptr renderer); void ApplyPalette(const SNESPalette &palette); - void SetPaletteColor(int id, gfx::SNESColor color); - - absl::StatusOr> CreateTiles(); - absl::Status CreateFromTiles(const std::vector &tiles); - - absl::Status WritePixel(int pos, uchar pixel); int GetWidth() const { return width_; } int GetHeight() const { return height_; } diff --git a/src/app/zelda3/overworld_map.cc b/src/app/zelda3/overworld_map.cc index 4bd94c8c..35ce1d22 100644 --- a/src/app/zelda3/overworld_map.cc +++ b/src/app/zelda3/overworld_map.cc @@ -46,7 +46,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current, int k = 0; for (int y = 2; y < 7; y++) { for (int x = 1; x < 8; x++) { - new_palette[x + (16 * y)] = main[k++]; + new_palette[x + (16 * y)] = main[k]; + k++; } } @@ -61,7 +62,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current, k = 0; for (int y = 2; y < 5; y++) { for (int x = 9; x < 16; x++) { - new_palette[x + (16 * y)] = aux1[k++]; + new_palette[x + (16 * y)] = aux1[k]; + k++; } } @@ -69,7 +71,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current, k = 0; for (int y = 5; y < 8; y++) { for (int x = 9; x < 16; x++) { - new_palette[x + (16 * y)] = aux2[k++]; + new_palette[x + (16 * y)] = aux2[k]; + k++; } } @@ -88,7 +91,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current, k = 0; for (int y = 8; y < 9; y++) { for (int x = 1; x < 8; x++) { - new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux1")[1][k++]; + new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux1")[1][k]; + k++; } } @@ -96,7 +100,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current, k = 0; for (int y = 8; y < 9; y++) { for (int x = 9; x < 16; x++) { - new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux3")[0][k++]; + new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux3")[0][k]; + k++; } } @@ -104,7 +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++]; + new_palette[x + (16 * y)] = rom.GetPaletteGroup("global_sprites")[0][k]; + k++; } } @@ -112,7 +118,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current, k = 0; for (int y = 13; y < 14; y++) { for (int x = 1; x < 8; x++) { - new_palette[x + (16 * y)] = spr[k++]; + new_palette[x + (16 * y)] = spr[k]; + k++; } } @@ -120,7 +127,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current, k = 0; for (int y = 14; y < 15; y++) { for (int x = 1; x < 8; x++) { - new_palette[x + (16 * y)] = spr2[k++]; + new_palette[x + (16 * y)] = spr2[k]; + k++; } } @@ -128,20 +136,15 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current, k = 0; for (int y = 15; y < 16; y++) { for (int x = 1; x < 16; x++) { - new_palette[x + (16 * y)] = rom.GetPaletteGroup("armors")[0][k++]; + new_palette[x + (16 * y)] = rom.GetPaletteGroup("armors")[0][k]; + k++; } } current.Create(new_palette); - // ColorPalette pal = GFX.editort16Bitmap.Palette; for (int i = 0; i < 256; i++) { current[(i / 16) * 16].setTransparent(true); } - - // GFX.mapgfx16Bitmap.Palette = pal; - // GFX.mapblockset16Bitmap.Palette = pal; - - // gfxBitmap.Palette = pal; } } // namespace