namespace housekeeping

This commit is contained in:
Justin Scofield
2022-06-20 13:21:17 -04:00
parent 122d92f121
commit 2654a08dff
19 changed files with 89 additions and 87 deletions

View File

@@ -38,9 +38,9 @@ add_executable(
application/Data/rom.cc
application/Data/OW/overworld.cc
application/Data/OW/overworld_map.cc
application/Graphics/bitmap.cc
application/Graphics/tile.cc
application/Graphics/palette.cc
application/gfx/bitmap.cc
application/gfx/tile.cc
application/gfx/palette.cc
application/Editor/editor.cc
application/Editor/overworld_editor.cc
# GUI libraries

View File

@@ -1,13 +1,13 @@
#include "overworld.h"
#include "Graphics/tile.h"
#include "gfx/tile.h"
namespace yaze {
namespace application {
namespace Data {
using namespace core;
using namespace Graphics;
using namespace gfx;
Overworld::~Overworld() {
if (isLoaded) {

View File

@@ -8,8 +8,8 @@
#include "Core/constants.h"
#include "Data/rom.h"
#include "Graphics/bitmap.h"
#include "Graphics/tile.h"
#include "gfx/bitmap.h"
#include "gfx/tile.h"
#include "overworld_map.h"
namespace yaze {
@@ -24,10 +24,10 @@ class Overworld {
void Load(Data::ROM & rom);
char* overworldMapPointer = new char[0x40000];
Graphics::Bitmap* overworldMapBitmap;
gfx::Bitmap* overworldMapBitmap;
char* owactualMapPointer = new char[0x40000];
Graphics::Bitmap* owactualMapBitmap;
gfx::Bitmap* owactualMapBitmap;
private:
Data::ROM rom_;
@@ -39,9 +39,9 @@ class Overworld {
ushort** allmapsTilesDW; // 64 maps * (32*32 tiles)
ushort** allmapsTilesSP; // 32 maps * (32*32 tiles)
std::vector<Graphics::Tile16> tiles16;
std::vector<Graphics::Tile32> tiles32;
std::vector<Graphics::Tile32> map16tiles;
std::vector<gfx::Tile16> tiles16;
std::vector<gfx::Tile32> tiles32;
std::vector<gfx::Tile32> map16tiles;
std::vector<OverworldMap> allmaps;

View File

@@ -1,17 +1,17 @@
#include "overworld_map.h"
#include "Data/rom.h"
#include "Graphics/tile.h"
#include "gfx/tile.h"
namespace yaze {
namespace application {
namespace Data {
using namespace Core;
using namespace Graphics;
using namespace core;
using namespace gfx;
OverworldMap::OverworldMap(Data::ROM & rom,
const std::vector<Graphics::Tile16> tiles16,
const std::vector<gfx::Tile16> tiles16,
uchar index)
: rom_(rom), index(index), tiles16_(tiles16), parent(index) {
if (index != 0x80) {

View File

@@ -4,8 +4,8 @@
#include <memory>
#include "Data/rom.h"
#include "Graphics/bitmap.h"
#include "Graphics/tile.h"
#include "gfx/bitmap.h"
#include "gfx/tile.h"
namespace yaze {
namespace application {
@@ -29,8 +29,8 @@ class OverworldMap {
int* gfxPtr = new int[512 * 512];
int* mapblockset16 = new int[1048576];
Graphics::Bitmap mapblockset16Bitmap;
Graphics::Bitmap gfxBitmap;
gfx::Bitmap mapblockset16Bitmap;
gfx::Bitmap gfxBitmap;
uchar* staticgfx =
new uchar[16]; // Need to be used to display map and not pre render it!
@@ -40,9 +40,9 @@ class OverworldMap {
Data::ROM rom_;
uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2];
std::vector<Graphics::Tile16> tiles16_;
std::vector<gfx::Tile16> tiles16_;
OverworldMap(Data::ROM & rom, const std::vector<Graphics::Tile16> tiles16,
OverworldMap(Data::ROM & rom, const std::vector<gfx::Tile16> tiles16,
uchar index);
void BuildMap(uchar* mapParent, int count, int gameState,
ushort** allmapsTilesLW, ushort** allmapsTilesDW,
@@ -57,10 +57,10 @@ class OverworldMap {
// void ReloadPalettes() { LoadPalette(); }
void CopyTile(int x, int y, int xx, int yy, int offset,
Graphics::TileInfo tile, uchar* gfx16Pointer,
gfx::TileInfo tile, uchar* gfx16Pointer,
uchar* gfx8Pointer);
void CopyTileToMap(int x, int y, int xx, int yy, int offset,
Graphics::TileInfo tile, uchar* gfx16Pointer,
gfx::TileInfo tile, uchar* gfx16Pointer,
uchar* gfx8Pointer);
void LoadPalette();

View File

@@ -44,7 +44,7 @@ void ROM::LoadFromFile(const std::string &path) {
loaded = true;
}
std::vector<tile8> ROM::ExtractTiles(Graphics::TilePreset &preset) {
std::vector<tile8> ROM::ExtractTiles(gfx::TilePreset &preset) {
std::cout << "Extracting tiles..." << std::endl;
uint filePos = 0;
uint size_out = 0;
@@ -55,7 +55,7 @@ std::vector<tile8> ROM::ExtractTiles(Graphics::TilePreset &preset) {
std::cout << "ROM Position: " << filePos << " from "
<< preset.SNESTilesLocation << std::endl;
// decompress the graphics
// decompress the gfx
auto data = (char *)malloc(sizeof(char) * size);
memcpy(data, (current_rom_ + filePos), size);
data = alttp_decompress_gfx(data, 0, size, &size_out, &compressed_size_);
@@ -82,7 +82,7 @@ std::vector<tile8> ROM::ExtractTiles(Graphics::TilePreset &preset) {
return rawTiles;
}
Graphics::SNESPalette ROM::ExtractPalette(Graphics::TilePreset &preset) {
gfx::SNESPalette ROM::ExtractPalette(gfx::TilePreset &preset) {
uint filePos =
GetRomPosition(preset.pc_palette_location_, preset.SNESPaletteLocation);
std::cout << "Palette pos : " << filePos << std::endl; // TODO: make this hex
@@ -100,9 +100,9 @@ Graphics::SNESPalette ROM::ExtractPalette(Graphics::TilePreset &preset) {
std::cout << std::endl;
const unsigned char *data = palette_data.get();
Graphics::SNESPalette pal(data);
gfx::SNESPalette pal(data);
if (preset.no_zero_color_) {
Graphics::SNESColor col;
gfx::SNESColor col;
col.setRgb(ImVec4(153, 153, 153, 255));
pal.colors.push_back(col);
@@ -255,7 +255,7 @@ uchar *ROM::SNES3bppTo8bppSheet(uchar *buffer_in,
return sheet_buffer_out;
}
SDL_Texture *ROM::DrawGraphicsSheet(int offset) {
SDL_Texture *ROM::DrawgfxSheet(int offset) {
SDL_Surface *surface =
SDL_CreateRGBSurfaceWithFormat(0, 128, 32, 8, SDL_PIXELFORMAT_INDEX8);
std::cout << "Drawing surface #" << offset << std::endl;

View File

@@ -14,7 +14,7 @@
#include <vector>
#include "Core/constants.h"
#include "Graphics/tile.h"
#include "gfx/tile.h"
namespace yaze {
namespace application {
@@ -28,12 +28,12 @@ class ROM {
void SetupRenderer(std::shared_ptr<SDL_Renderer> renderer);
void LoadFromFile(const std::string& path);
std::vector<tile8> ExtractTiles(Graphics::TilePreset& preset);
Graphics::SNESPalette ExtractPalette(Graphics::TilePreset& preset);
std::vector<tile8> ExtractTiles(gfx::TilePreset& preset);
gfx::SNESPalette ExtractPalette(gfx::TilePreset& preset);
uint32_t GetRomPosition(int direct_addr, uint snes_addr) const;
char* Decompress(int pos, int size = 0x800, bool reversed = false);
uchar* SNES3bppTo8bppSheet(uchar* buffer_in, int sheet_id = 0);
SDL_Texture* DrawGraphicsSheet(int offset);
SDL_Texture* DrawgfxSheet(int offset);
inline uchar* GetRawData() { return current_rom_; }
const uchar* getTitle() const { return title; }

View File

@@ -9,8 +9,8 @@
#include "Core/constants.h"
#include "Data/rom.h"
#include "Editor/overworld_editor.h"
#include "Graphics/palette.h"
#include "Graphics/tile.h"
#include "gfx/palette.h"
#include "gfx/tile.h"
#include "gui/icons.h"
#include "gui/input.h"
@@ -117,7 +117,7 @@ void Editor::UpdateScreen() {
DrawProjectEditor();
DrawOverworldEditor();
DrawDungeonEditor();
DrawGraphicsEditor();
DrawgfxEditor();
DrawSpriteEditor();
DrawScreenEditor();
DrawHUDEditor();
@@ -280,7 +280,7 @@ void Editor::DrawHelpMenu() const {
}
}
void Editor::DrawGraphicsSheet(int offset) {
void Editor::DrawgfxSheet(int offset) {
SDL_Surface *surface =
SDL_CreateRGBSurfaceWithFormat(0, 128, 32, 8, SDL_PIXELFORMAT_INDEX8);
std::cout << "Drawing surface" << std::endl;
@@ -345,9 +345,9 @@ void Editor::DrawProjectEditor() {
}
ImGui::SetNextItemWidth(100.f);
ImGui::InputInt("Tilesheet Offset", &tilesheet_offset);
BASIC_BUTTON("Retrieve Graphics") {
BASIC_BUTTON("Retrieve gfx") {
if (rom_.isLoaded()) {
DrawGraphicsSheet(tilesheet_offset);
DrawgfxSheet(tilesheet_offset);
loaded_image = true;
}
}
@@ -496,8 +496,8 @@ void Editor::DrawDungeonEditor() {
}
}
void Editor::DrawGraphicsEditor() {
if (ImGui::BeginTabItem("Graphics")) {
void Editor::DrawgfxEditor() {
if (ImGui::BeginTabItem("gfx")) {
ImGui::EndTabItem();
}
}

View File

@@ -10,7 +10,7 @@
#include "Core/constants.h"
#include "Data/rom.h"
#include "Editor/overworld_editor.h"
#include "Graphics/tile.h"
#include "gfx/tile.h"
#include "gui/icons.h"
#include "gui/input.h"
@@ -32,12 +32,12 @@ class Editor {
void DrawViewMenu();
void DrawHelpMenu() const;
void DrawGraphicsSheet(int offset = 0);
void DrawgfxSheet(int offset = 0);
void DrawProjectEditor();
void DrawOverworldEditor();
void DrawDungeonEditor();
void DrawGraphicsEditor();
void DrawgfxEditor();
void DrawSpriteEditor();
void DrawScreenEditor();
void DrawHUDEditor();
@@ -58,7 +58,7 @@ class Editor {
OverworldEditor overworld_editor_;
ImVec4 current_palette_[8];
Graphics::TilePreset current_set_;
gfx::TilePreset current_set_;
ImGuiWindowFlags main_editor_flags_ =
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse |

View File

@@ -4,11 +4,12 @@
#include <cmath>
#include "Graphics/bitmap.h"
#include "Graphics/icons.h"
#include "Graphics/tile.h"
#include "gfx/bitmap.h"
#include "gfx/tile.h"
#include "gui/icons.h"
// first step would be to decompress all graphics data from the game
// first step would be to decompress all gfx data from the game
// (in alttp that's easy they're all located in the same location all the
// same sheet size 128x32) have a code that convert PC address to SNES and
// vice-versa
@@ -34,10 +35,10 @@ void OverworldEditor::SetupROM(Data::ROM &rom) { rom_ = rom; }
void OverworldEditor::Update() {
if (rom_.isLoaded()) {
if (!all_graphics_loaded_) {
LoadGraphics();
//overworld_.Load(rom_);
all_graphics_loaded_ = true;
if (!all_gfx_loaded_) {
Loadgfx();
// overworld_.Load(rom_);
all_gfx_loaded_ = true;
}
}
@@ -275,8 +276,9 @@ void OverworldEditor::DrawTileSelector() {
if (ImGui::BeginTabItem("Tile8")) {
ImGuiStyle &style = ImGui::GetStyle();
ImGuiID child_id = ImGui::GetID((void *)(intptr_t)1);
bool child_is_visible = ImGui::BeginChild(
child_id, ImGui::GetContentRegionAvail(), true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
bool child_is_visible =
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar);
if (child_is_visible) // Avoid calling SetScrollHereY when running with
// culled items
{
@@ -328,7 +330,7 @@ void OverworldEditor::DrawTile8Selector() {
ImGui::EndPopup();
}
if (all_graphics_loaded_) {
if (all_gfx_loaded_) {
for (const auto &[key, value] : all_texture_sheet_) {
int offset = 64 * (key + 1);
int top_left_y = canvas_p0.y + 2;
@@ -369,9 +371,9 @@ void OverworldEditor::DrawChangelist() {
ImGui::End();
}
void OverworldEditor::LoadGraphics() {
void OverworldEditor::Loadgfx() {
for (int i = 0; i < kNumSheetsToLoad; i++) {
all_texture_sheet_[i] = rom_.DrawGraphicsSheet(i);
all_texture_sheet_[i] = rom_.DrawgfxSheet(i);
}
}

View File

@@ -4,8 +4,8 @@
#include <imgui/imgui.h>
#include "Data/OW/overworld.h"
#include "Graphics/palette.h"
#include "Graphics/tile.h"
#include "gfx/palette.h"
#include "gfx/tile.h"
#include "gui/icons.h"
@@ -28,13 +28,13 @@ class OverworldEditor {
void DrawTile8Selector();
void DrawChangelist();
void LoadGraphics();
void Loadgfx();
Data::ROM rom_;
Data::Overworld overworld_;
Graphics::Bitmap allgfxBitmap;
Graphics::SNESPalette palette_;
Graphics::TilePreset current_set_;
gfx::Bitmap allgfxBitmap;
gfx::SNESPalette palette_;
gfx::TilePreset current_set_;
std::unordered_map<unsigned int, SDL_Texture *> all_texture_sheet_;
SDL_Texture *gfx_texture = nullptr;
@@ -58,7 +58,7 @@ class OverworldEditor {
bool doneLoaded = false;
bool opt_enable_grid = true;
bool show_changelist_ = false;
bool all_graphics_loaded_ = false;
bool all_gfx_loaded_ = false;
constexpr static int kByteSize = 3;
constexpr static int kMessageIdSize = 5;

View File

@@ -82,7 +82,7 @@ constexpr int NumberOfOWSprites = 352;
constexpr int NumberOfColors = 3143;
// ===========================================================================================
// Graphics
// gfx
// ===========================================================================================
constexpr int tile_address = 0x1B52; // JP = Same
@@ -934,7 +934,7 @@ static const std::string Type3RoomObjectNames[] = {
"Bar bottles",
"Arrow game hole (west)",
"Arrow game hole (east)",
"Vitreous goo graphics",
"Vitreous goo gfx",
"Fake pressure plate",
"Medusa head",
"4-way shooter block",

View File

@@ -6,7 +6,7 @@
namespace yaze {
namespace application {
namespace Graphics {
namespace gfx {
int GetPCGfxAddress(char *romData, char id) {
char **info1 = new char *[255];
@@ -173,6 +173,6 @@ void CreateAllGfxData(char *romData, char *allgfx16Ptr) {
}
}
} // namespace Graphics
} // namespace gfx
} // namespace application
} // namespace yaze

View File

@@ -7,7 +7,7 @@
namespace yaze {
namespace application {
namespace Graphics {
namespace gfx {
class Bitmap {
public:
@@ -30,7 +30,7 @@ int GetPCGfxAddress(char *romData, char id);
char *CreateAllGfxDataRaw(char *romData);
void CreateAllGfxData(char *romData, char *allgfx16Ptr);
} // namespace Graphics
} // namespace gfx
} // namespace application
} // namespace yaze

View File

@@ -5,7 +5,7 @@
namespace yaze {
namespace application {
namespace Graphics {
namespace gfx {
SNESColor::SNESColor() : rgb(ImVec4(0.f, 0.f, 0.f, 0.f)) {}
@@ -108,6 +108,6 @@ SDL_Palette* SNESPalette::GetSDL_Palette() {
return sdl_palette.get();
}
} // namespace Graphics
} // namespace gfx
} // namespace application
} // namespace yaze

View File

@@ -1,5 +1,5 @@
#ifndef YAZE_APPLICATION_GRAPHICS_PALETTE_H
#define YAZE_APPLICATION_GRAPHICS_PALETTE_H
#ifndef YAZE_APPLICATION_gfx_PALETTE_H
#define YAZE_APPLICATION_gfx_PALETTE_H
#include <SDL2/SDL.h>
#include <imgui/imgui.h>
@@ -13,7 +13,7 @@
namespace yaze {
namespace application {
namespace Graphics {
namespace gfx {
struct SNESColor {
SNESColor();
@@ -43,8 +43,8 @@ class SNESPalette {
std::vector<SDL_Color*> colors_arrays_;
};
} // namespace Graphics
} // namespace gfx
} // namespace application
} // namespace yaze
#endif // YAZE_APPLICATION_GRAPHICS_PALETTE_H
#endif // YAZE_APPLICATION_gfx_PALETTE_H

View File

@@ -10,7 +10,7 @@
namespace yaze {
namespace application {
namespace Graphics {
namespace gfx {
TilesPattern::TilesPattern() {
tiles_per_row_ = 16;
@@ -108,6 +108,6 @@ std::vector<std::vector<tile8> > TilesPattern::transform(
return pattern.transform(tiles);
}
} // namespace Graphics
} // namespace gfx
} // namespace application
} // namespace yaze

View File

@@ -9,11 +9,11 @@
#include <vector>
#include "Core/constants.h"
#include "Graphics/palette.h"
#include "gfx/palette.h"
namespace yaze {
namespace application {
namespace Graphics {
namespace gfx {
// vhopppcc cccccccc
// [0, 1]
@@ -96,7 +96,7 @@ class TilePreset {
int SNESPaletteLocation = 0;
};
} // namespace Graphics
} // namespace gfx
} // namespace application
} // namespace yaze

View File

@@ -17,9 +17,9 @@ add_executable(
yaze_test
yaze_test.cc
../src/application/Data/rom.cc
../src/application/Graphics/tile.cc
../src/application/Graphics/tile.cc
../src/application/Graphics/palette.cc
../src/application/gfx/tile.cc
../src/application/gfx/tile.cc
../src/application/gfx/palette.cc
${SNESHACKING_PATH}/compressions/alttpcompression.c
${SNESHACKING_PATH}/compressions/stdnintendo.c
${SNESHACKING_PATH}/tile.c