cleaning up the mess i've made

This commit is contained in:
scawful
2022-06-13 22:17:44 -04:00
parent 855152f19b
commit c6904fb0c7
7 changed files with 33 additions and 56 deletions

View File

@@ -48,6 +48,8 @@ class ROM {
uint compress_size_;
long int size_;
enum rom_type type_ = LoROM;
std::shared_ptr<uchar> rom_ptr_;
};
} // namespace Data

View File

@@ -63,8 +63,8 @@ Editor::Editor() {
current_set_.pcTilesLocation = 0x80000;
current_set_.SNESTilesLocation = 0x0000;
current_set_.length = 28672;
current_set_.pcPaletteLocation = 0xDD326;
current_set_.SNESPaletteLocation = 0x0000;
current_set_.pcPaletteLocation = 906022;
current_set_.SNESPaletteLocation = 0;
}
void Editor::UpdateScreen() {
@@ -263,22 +263,21 @@ void Editor::DrawProjectEditor() {
ImGui::Text("Version: %d", rom_.getVersion());
ImGui::Text("ROM Size: %ld", rom_.getSize());
ImGui::InputScalar("Bits per Pixel", ImGuiDataType_U32,
(void *)&current_set_.bpp);
ImGui::InputInt("PC Tile Location", &current_set_.pcTilesLocation);
// 1, 100, ImGuiInputTextFlags_CharsHexadecimal
ImGui::InputScalar("SNES Tile Location", ImGuiDataType_U32,
ImGui::InputScalar("SNES Tile Location", ImGuiDataType_U16,
(void *)&current_set_.SNESTilesLocation);
ImGui::InputScalar("Tile Preset Length", ImGuiDataType_U32,
(void *)&current_set_.length);
ImGui::InputScalar("Bits per Pixel", ImGuiDataType_U32,
(void *)&current_set_.bpp);
ImGui::InputInt("PC Palette Location", &current_set_.pcPaletteLocation);
ImGui::InputScalar("PC Palette Location", ImGuiDataType_U32,
(void *)&current_set_.pcPaletteLocation);
ImGui::InputScalar("SNES Palette Location", ImGuiDataType_U32,
ImGui::InputScalar("SNES Palette Location", ImGuiDataType_U16,
(void *)&current_set_.SNESPaletteLocation);
BASIC_BUTTON("ExtractTiles") {

View File

@@ -32,7 +32,7 @@ void SNESColor::setSNES(uint16_t val) {
rgb = ImVec4(col.red, col.green, col.blue, 1.f);
}
SNESPalette::SNESPalette(uint8_t mSize) : size(mSize) {
SNESPalette::SNESPalette(uint8_t mSize) : size_(mSize) {
for (unsigned int i = 0; i < mSize; i++) {
SNESColor col;
colors.push_back(col);
@@ -41,7 +41,7 @@ SNESPalette::SNESPalette(uint8_t mSize) : size(mSize) {
SNESPalette::SNESPalette(char* data) {
assert((sizeof(data) % 4 == 0) && (sizeof(data) <= 32));
size = sizeof(data) / 2;
size_ = sizeof(data) / 2;
for (unsigned i = 0; i < sizeof(data); i += 2) {
SNESColor col;
col.snes = static_cast<uchar>(data[i + 1]) << 8;
@@ -58,13 +58,13 @@ SNESPalette::SNESPalette(std::vector<ImVec4> cols) {
scol.setRgb(each);
colors.push_back(scol);
}
size = cols.size();
size_ = cols.size();
}
char* SNESPalette::encode() {
// char* data(size * 2, 0);
char* data = new char[size * 2];
for (unsigned int i = 0; i < size; i++) {
char* data = new char[size_ * 2];
for (unsigned int i = 0; i < size_; i++) {
// std::cout << QString::number(colors[i].snes, 16);
data[i * 2] = (char)(colors[i].snes & 0xFF);
data[i * 2 + 1] = (char)(colors[i].snes >> 8);
@@ -73,21 +73,22 @@ char* SNESPalette::encode() {
}
SDL_Palette* SNESPalette::GetSDL_Palette() {
SDL_Palette* result = new SDL_Palette;
result->ncolors = size;
SDL_Color* sdl_colors = new SDL_Color[size];
for (int i = 0; i < size; i++) {
auto sdl_palette = std::make_shared<SDL_Palette>();
sdl_palette->ncolors = size_;
auto* sdl_colors = new SDL_Color[size_];
for (int i = 0; i < size_; i++) {
sdl_colors[i].r = (uint8_t)colors[i].rgb.x * 100;
sdl_colors[i].g = (uint8_t)colors[i].rgb.y * 100;
sdl_colors[i].b = (uint8_t)colors[i].rgb.z * 100;
}
result->colors = sdl_colors;
sdl_palette->colors = sdl_colors;
// store the pointers to free them later
sdl_palettes_.push_back(result);
sdl_palettes_.push_back(sdl_palette);
colors_arrays_.push_back(sdl_colors);
return result;
return sdl_palette.get();
}
} // namespace Graphics

View File

@@ -36,9 +36,9 @@ class SNESPalette {
char* encode();
SDL_Palette* GetSDL_Palette();
int size = 0;
int size_ = 0;
std::vector<SNESColor> colors;
std::vector<SDL_Palette*> sdl_palettes_;
std::vector<std::shared_ptr<SDL_Palette>> sdl_palettes_;
std::vector<SDL_Color*> colors_arrays_;
};

View File

@@ -145,16 +145,6 @@ std::vector<std::vector<tile8> > TilesPattern::transform(
return pattern.transform(tiles);
}
TilePreset::TilePreset() {
bpp = 0;
length = 0;
pcTilesLocation = -1;
SNESTilesLocation = 0;
pcPaletteLocation = 0;
SNESPaletteLocation = 0;
paletteNoZeroColor = false;
}
} // namespace Graphics
} // namespace Application
} // namespace yaze

View File

@@ -88,17 +88,15 @@ class TilesPattern {
class TilePreset {
public:
TilePreset();
bool paletteNoZeroColor;
int pcTilesLocation;
uint16_t SNESTilesLocation;
uint16_t SNESPaletteLocation;
uint32_t pcPaletteLocation;
uint32_t length;
uint32_t bpp;
TilePreset() = default;
TilesPattern tilesPattern;
bool no_zero_color_ = false;
int pc_tiles_location_ = -1;
int pc_palette_location_ = 0;
uint32_t length_ = 0;
uint32_t bits_per_pixel_ = 0;
uint16_t SNESTilesLocation = 0;
uint16_t SNESPaletteLocation = 0;
};
} // namespace Graphics

View File

@@ -1,19 +1,6 @@
#ifndef YAZE_YAZE_H
#define YAZE_YAZE_H
#include <iostream>
#include <memory>
#include <utility>
#include <algorithm>
#include <functional>
#include <string>
#include <sstream>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include "Application/Core/controller.h"
#include "Application/Core/entry_point.h"