housekeeping

This commit is contained in:
Justin Scofield
2022-06-20 14:28:04 -04:00
parent 89c5dcfec6
commit 9c7c9bc1e4
15 changed files with 84 additions and 66 deletions

View File

@@ -38,11 +38,11 @@ add_executable(
gui/editor/overworld_editor.cc gui/editor/overworld_editor.cc
app/rom.cc app/rom.cc
app/core/controller.cc app/core/controller.cc
app/zelda3/overworld.cc
app/zelda3/overworld_map.cc
app/gfx/bitmap.cc app/gfx/bitmap.cc
app/gfx/tile.cc app/gfx/tile.cc
app/gfx/palette.cc app/gfx/palette.cc
app/zelda3/overworld.cc
app/zelda3/overworld_map.cc
# GUI libraries # GUI libraries
${IMGUI_PATH}/imgui.cpp ${IMGUI_PATH}/imgui.cpp
${IMGUI_PATH}/imgui_demo.cpp ${IMGUI_PATH}/imgui_demo.cpp
@@ -67,6 +67,7 @@ target_include_directories(
/ /
Library/ Library/
app/ app/
gui/
"C:/msys64/mingw64/include/libpng16" "C:/msys64/mingw64/include/libpng16"
"C:/msys64/mingw64/include/SDL2" "C:/msys64/mingw64/include/SDL2"
"C:/msys64/mingw64/include" "C:/msys64/mingw64/include"

View File

@@ -43,7 +43,7 @@ class Controller {
}; };
bool active_; bool active_;
Editor::Editor editor_; gui::editor::Editor editor_;
std::shared_ptr<SDL_Window> sdl_window_; std::shared_ptr<SDL_Window> sdl_window_;
std::shared_ptr<SDL_Renderer> sdl_renderer_; std::shared_ptr<SDL_Renderer> sdl_renderer_;
}; };

View File

@@ -28,7 +28,7 @@ int GetPCGfxAddress(char *romData, char id) {
char gfxGamePointer3 = romData[gfxPointer3 + id]; char gfxGamePointer3 = romData[gfxPointer3 + id];
return lorom_snes_to_pc( return lorom_snes_to_pc(
Data::AddressFromBytes(gfxGamePointer1, gfxGamePointer2, gfxGamePointer3), AddressFromBytes(gfxGamePointer1, gfxGamePointer2, gfxGamePointer3),
info1); info1);
} }

View File

@@ -1,5 +1,7 @@
#include "tile.h" #include "tile.h"
#include <tile.h>
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
#include <cstdio> #include <cstdio>
@@ -7,6 +9,12 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <regex> #include <regex>
#include <string>
#include <unordered_map>
#include <vector>
#include "app/core/constants.h"
#include "app/gfx/palette.h"
namespace yaze { namespace yaze {
namespace app { namespace app {

View File

@@ -1,15 +1,21 @@
#ifndef YAZE_APP_DATA_TILE_H #ifndef YAZE_APP_GFX_TILE_H
#define YAZE_APP_DATA_TILE_H #define YAZE_APP_GFX_TILE_H
#include <tile.h> #include <tile.h>
#include <cassert>
#include <cstdint> #include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <regex>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "Core/constants.h" #include "app/core/constants.h"
#include "gfx/palette.h" #include "app/gfx/palette.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
@@ -100,4 +106,4 @@ class TilePreset {
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze
#endif #endif // YAZE_APP_GFX_TILE_H

View File

@@ -1,12 +1,27 @@
#include "rom.h" #include "rom.h"
#include <filesystem> #include <compressions/alttpcompression.h>
#include <rommapping.h>
#include <tile.h>
#include "Core/constants.h" #include <cstddef>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "app/core/constants.h"
#include "app/gfx/tile.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace Data {
int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3) {
return (addr1 << 16) | (addr2 << 8) | addr3;
}
ROM::~ROM() { ROM::~ROM() {
if (loaded) { if (loaded) {
@@ -287,10 +302,5 @@ SDL_Texture *ROM::DrawgfxSheet(int offset) {
return sheet_texture; return sheet_texture;
} }
int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3) {
return (addr1 << 16) | (addr2 << 8) | addr3;
}
} // namespace Data
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -7,18 +7,18 @@
#include <cstddef> #include <cstddef>
#include <cstring> #include <cstring>
#include <filesystem>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include "Core/constants.h" #include "app/core/constants.h"
#include "gfx/tile.h" #include "app/gfx/tile.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace Data {
int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3); int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3);
@@ -52,13 +52,13 @@ class ROM {
private: private:
bool loaded = false; bool loaded = false;
bool has_header_ = false; bool has_header_ = false;
uchar* current_rom_; long int size_;
uchar version_;
uchar title[21] = "ROM Not Loaded";
uint uncompressed_size_; uint uncompressed_size_;
uint compressed_size_; uint compressed_size_;
uint compress_size_; uint compress_size_;
long int size_; uchar* current_rom_;
uchar version_;
uchar title[21] = "ROM Not Loaded";
enum rom_type type_ = LoROM; enum rom_type type_ = LoROM;
std::shared_ptr<uchar> rom_ptr_; std::shared_ptr<uchar> rom_ptr_;
@@ -68,7 +68,6 @@ class ROM {
std::shared_ptr<SDL_Renderer> sdl_renderer_; std::shared_ptr<SDL_Renderer> sdl_renderer_;
}; };
} // namespace Data
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -41,7 +41,7 @@ static TileInfo GetTilesInfo(ushort tile) {
return TileInfo(tid, p, v, h, o); return TileInfo(tid, p, v, h, o);
} }
void Overworld::Load(Data::ROM& rom) { void Overworld::Load(ROM& rom) {
rom_ = rom; rom_ = rom;
for (int i = 0; i < 0x2B; i++) { for (int i = 0; i < 0x2B; i++) {
tileLeftEntrance.push_back(constants::overworldEntranceAllowedTilesLeft + tileLeftEntrance.push_back(constants::overworldEntranceAllowedTilesLeft +

View File

@@ -21,7 +21,7 @@ class Overworld {
Overworld() = default; Overworld() = default;
~Overworld(); ~Overworld();
void Load(Data::ROM& rom); void Load(ROM& rom);
char* overworldMapPointer = new char[0x40000]; char* overworldMapPointer = new char[0x40000];
gfx::Bitmap* overworldMapBitmap; gfx::Bitmap* overworldMapBitmap;
@@ -30,7 +30,7 @@ class Overworld {
gfx::Bitmap* owactualMapBitmap; gfx::Bitmap* owactualMapBitmap;
private: private:
Data::ROM rom_; ROM rom_;
int gameState = 1; int gameState = 1;
bool isLoaded = false; bool isLoaded = false;
uchar mapParent[160]; uchar mapParent[160];

View File

@@ -10,8 +10,8 @@ namespace zelda3 {
using namespace core; using namespace core;
using namespace gfx; using namespace gfx;
OverworldMap::OverworldMap(Data::ROM& rom, OverworldMap::OverworldMap(ROM& rom, const std::vector<gfx::Tile16> tiles16,
const std::vector<gfx::Tile16> tiles16, uchar index) uchar index)
: rom_(rom), index(index), tiles16_(tiles16), parent(index) { : rom_(rom), index(index), tiles16_(tiles16), parent(index) {
if (index != 0x80) { if (index != 0x80) {
if (index <= 150) { if (index <= 150) {

View File

@@ -37,13 +37,12 @@ class OverworldMap {
ushort** tilesUsed; ushort** tilesUsed;
bool needRefresh = false; bool needRefresh = false;
Data::ROM rom_; ROM rom_;
uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2]; uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2];
std::vector<gfx::Tile16> tiles16_; std::vector<gfx::Tile16> tiles16_;
OverworldMap(Data::ROM& rom, const std::vector<gfx::Tile16> tiles16, OverworldMap(ROM& rom, const std::vector<gfx::Tile16> tiles16, uchar index);
uchar index);
void BuildMap(uchar* mapParent, int count, int gameState, void BuildMap(uchar* mapParent, int count, int gameState,
ushort** allmapsTilesLW, ushort** allmapsTilesDW, ushort** allmapsTilesLW, ushort** allmapsTilesDW,
ushort** allmapsTilesSP); ushort** allmapsTilesSP);

View File

@@ -15,16 +15,14 @@
#include "rom.h" #include "rom.h"
namespace yaze { namespace yaze {
namespace app { namespace gui {
namespace Editor { namespace editor {
using namespace core;
Editor::Editor() { Editor::Editor() {
for (auto &k : core::constants::kKeywords) for (auto &k : app::core::constants::kKeywords)
language_65816_.mKeywords.emplace(k); language_65816_.mKeywords.emplace(k);
for (auto &k : core::constants::kIdentifiers) { for (auto &k : app::core::constants::kIdentifiers) {
TextEditor::Identifier id; TextEditor::Identifier id;
id.mDeclaration = "Built-in function"; id.mDeclaration = "Built-in function";
language_65816_.mIdentifiers.insert(std::make_pair(std::string(k), id)); language_65816_.mIdentifiers.insert(std::make_pair(std::string(k), id));

View File

@@ -15,8 +15,8 @@
#include "rom.h" #include "rom.h"
namespace yaze { namespace yaze {
namespace app { namespace gui {
namespace Editor { namespace editor {
class Editor { class Editor {
public: public:
@@ -45,20 +45,18 @@ class Editor {
void *rom_data_; void *rom_data_;
bool is_loaded_ = true; bool is_loaded_ = true;
std::vector<tile8> tiles_; app::ROM rom_;
std::vector<std::vector<tile8>> arranged_tiles_;
std::unordered_map<unsigned int, std::shared_ptr<SDL_Texture>> texture_cache_;
std::unordered_map<unsigned int, SDL_Texture *> imagesCache;
std::shared_ptr<SDL_Renderer> sdl_renderer_;
Data::ROM rom_;
TextEditor asm_editor_; TextEditor asm_editor_;
TextEditor::LanguageDefinition language_65816_; TextEditor::LanguageDefinition language_65816_;
OverworldEditor overworld_editor_; OverworldEditor overworld_editor_;
std::vector<tile8> tiles_;
std::vector<std::vector<tile8>> arranged_tiles_;
std::unordered_map<uint, SDL_Texture *> imagesCache;
std::shared_ptr<SDL_Renderer> sdl_renderer_;
ImVec4 current_palette_[8]; ImVec4 current_palette_[8];
gfx::TilePreset current_set_; app::gfx::TilePreset current_set_;
ImGuiWindowFlags main_editor_flags_ = ImGuiWindowFlags main_editor_flags_ =
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse |
@@ -67,7 +65,7 @@ class Editor {
ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit; ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit;
}; };
} // namespace Editor } // namespace editor
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -28,10 +28,10 @@
// have an overworld map viewer, in less than few hours if are able to // have an overworld map viewer, in less than few hours if are able to
// understand the data quickly // understand the data quickly
namespace yaze { namespace yaze {
namespace app { namespace gui {
namespace Editor { namespace editor {
void OverworldEditor::SetupROM(Data::ROM &rom) { rom_ = rom; } void OverworldEditor::SetupROM(app::ROM &rom) { rom_ = rom; }
void OverworldEditor::Update() { void OverworldEditor::Update() {
if (rom_.isLoaded()) { if (rom_.isLoaded()) {

View File

@@ -3,21 +3,20 @@
#include <imgui/imgui.h> #include <imgui/imgui.h>
#include "zelda3/overworld.h"
#include "gfx/palette.h" #include "gfx/palette.h"
#include "gfx/tile.h" #include "gfx/tile.h"
#include "gui/icons.h" #include "gui/icons.h"
#include "zelda3/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace gui {
namespace Editor { namespace editor {
static constexpr unsigned int k4BPP = 4; static constexpr unsigned int k4BPP = 4;
class OverworldEditor { class OverworldEditor {
public: public:
void SetupROM(Data::ROM &rom); void SetupROM(app::ROM &rom);
void Update(); void Update();
private: private:
@@ -30,11 +29,11 @@ class OverworldEditor {
void Loadgfx(); void Loadgfx();
Data::ROM rom_; app::ROM rom_;
Data::Overworld overworld_; app::zelda3::Overworld overworld_;
gfx::Bitmap allgfxBitmap; app::gfx::Bitmap allgfxBitmap;
gfx::SNESPalette palette_; app::gfx::SNESPalette palette_;
gfx::TilePreset current_set_; app::gfx::TilePreset current_set_;
std::unordered_map<unsigned int, SDL_Texture *> all_texture_sheet_; std::unordered_map<unsigned int, SDL_Texture *> all_texture_sheet_;
SDL_Texture *gfx_texture = nullptr; SDL_Texture *gfx_texture = nullptr;
@@ -72,8 +71,8 @@ class OverworldEditor {
ImGuiTableFlags_Resizable | ImGuiTableFlags_Resizable |
ImGuiTableFlags_SizingStretchSame; ImGuiTableFlags_SizingStretchSame;
}; };
} // namespace Editor } // namespace editor
} // namespace app } // namespace gui
} // namespace yaze } // namespace yaze
#endif #endif