cleanup and some type definitions for windows not having the types header i guess
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
|
#include "Core/constants.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace Application {
|
namespace Application {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
@@ -9,31 +11,25 @@ namespace Data {
|
|||||||
ROM::~ROM() {
|
ROM::~ROM() {
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
delete[] current_rom_;
|
delete[] current_rom_;
|
||||||
delete[] data_;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check if the rom has a header on load
|
// TODO: check if the rom has a header on load
|
||||||
void ROM::LoadFromFile(const std::string &path) {
|
void ROM::LoadFromFile(const std::string &path) {
|
||||||
type_ = LoROM;
|
|
||||||
size_ = std::filesystem::file_size(path.c_str());
|
size_ = std::filesystem::file_size(path.c_str());
|
||||||
std::ifstream file(path.c_str(), std::ios::binary);
|
std::ifstream file(path.c_str(), std::ios::binary);
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
std::cout << "Error: Could not open ROM file " << path << std::endl;
|
std::cout << "Error: Could not open ROM file " << path << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_rom_ = new unsigned char[size_];
|
current_rom_ = new unsigned char[size_];
|
||||||
data_ = new char[size_];
|
|
||||||
for (unsigned int i = 0; i < size_; i++) {
|
for (unsigned int i = 0; i < size_; i++) {
|
||||||
char byte_read_ = ' ';
|
char byte_read_ = ' ';
|
||||||
file.read(&byte_read_, sizeof(char));
|
file.read(&byte_read_, sizeof(char));
|
||||||
current_rom_[i] = byte_read_;
|
current_rom_[i] = byte_read_;
|
||||||
data_[i] = byte_read_;
|
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
memcpy(title, current_rom_ + 32704, 21);
|
||||||
memcpy(title, data_ + 32704, 21);
|
|
||||||
version_ = current_rom_[27];
|
version_ = current_rom_[27];
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
@@ -51,7 +47,7 @@ std::vector<tile8> ROM::ExtractTiles(Graphics::TilePreset &preset) {
|
|||||||
|
|
||||||
// decompress the graphics
|
// decompress the graphics
|
||||||
char *data = (char *)malloc(sizeof(char) * size);
|
char *data = (char *)malloc(sizeof(char) * size);
|
||||||
memcpy(data, (data_ + filePos), size);
|
memcpy(data, (current_rom_ + filePos), size);
|
||||||
data = alttp_decompress_gfx(data, 0, size, &size_out, &compressed_size_);
|
data = alttp_decompress_gfx(data, 0, size, &size_out, &compressed_size_);
|
||||||
std::cout << "size: " << size << std::endl;
|
std::cout << "size: " << size << std::endl;
|
||||||
std::cout << "lastCompressedSize: " << compressed_size_ << std::endl;
|
std::cout << "lastCompressedSize: " << compressed_size_ << std::endl;
|
||||||
@@ -81,7 +77,7 @@ Graphics::SNESPalette ROM::ExtractPalette(Graphics::TilePreset &preset) {
|
|||||||
std::cout << "Palette pos : " << filePos << std::endl; // TODO: make this hex
|
std::cout << "Palette pos : " << filePos << std::endl; // TODO: make this hex
|
||||||
unsigned int palette_size = pow(2, preset.bpp); // - 1;
|
unsigned int palette_size = pow(2, preset.bpp); // - 1;
|
||||||
char *ab = (char *)malloc(sizeof(char) * (palette_size * 2));
|
char *ab = (char *)malloc(sizeof(char) * (palette_size * 2));
|
||||||
memcpy(ab, data_ + filePos, palette_size * 2);
|
memcpy(ab, current_rom_ + filePos, palette_size * 2);
|
||||||
|
|
||||||
for (int i = 0; i < palette_size; i++) {
|
for (int i = 0; i < palette_size; i++) {
|
||||||
std::cout << ab[i];
|
std::cout << ab[i];
|
||||||
@@ -104,13 +100,12 @@ Graphics::SNESPalette ROM::ExtractPalette(Graphics::TilePreset &preset) {
|
|||||||
uint32_t ROM::GetRomPosition(const Graphics::TilePreset &preset, int directAddr,
|
uint32_t ROM::GetRomPosition(const Graphics::TilePreset &preset, int directAddr,
|
||||||
unsigned int snesAddr) const {
|
unsigned int snesAddr) const {
|
||||||
unsigned int filePos = -1;
|
unsigned int filePos = -1;
|
||||||
enum rom_type rType = LoROM;
|
|
||||||
std::cout << "directAddr:" << directAddr << std::endl;
|
std::cout << "directAddr:" << directAddr << std::endl;
|
||||||
if (directAddr == -1) {
|
if (directAddr == -1) {
|
||||||
filePos = rommapping_snes_to_pc(snesAddr, rType, rom_has_header_);
|
filePos = rommapping_snes_to_pc(snesAddr, type_, has_header_);
|
||||||
} else {
|
} else {
|
||||||
filePos = directAddr;
|
filePos = directAddr;
|
||||||
if (rom_has_header_) filePos += 0x200;
|
if (has_header_) filePos += 0x200;
|
||||||
}
|
}
|
||||||
std::cout << "filePos:" << filePos << std::endl;
|
std::cout << "filePos:" << filePos << std::endl;
|
||||||
return filePos;
|
return filePos;
|
||||||
|
|||||||
@@ -32,26 +32,22 @@ class ROM {
|
|||||||
uint32_t GetRomPosition(const Graphics::TilePreset& preset, int directAddr,
|
uint32_t GetRomPosition(const Graphics::TilePreset& preset, int directAddr,
|
||||||
unsigned int snesAddr) const;
|
unsigned int snesAddr) const;
|
||||||
inline uchar* GetRawData() { return current_rom_; }
|
inline uchar* GetRawData() { return current_rom_; }
|
||||||
const unsigned char* getTitle() const { return title; }
|
const uchar* getTitle() const { return title; }
|
||||||
long int getSize() const { return size_; }
|
long int getSize() const { return size_; }
|
||||||
char getVersion() const { return version_; }
|
char getVersion() const { return version_; }
|
||||||
bool isLoaded() const { return loaded; }
|
bool isLoaded() const { return loaded; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
bool rom_has_header_ = false;
|
bool has_header_ = false;
|
||||||
|
|
||||||
uchar* current_rom_;
|
uchar* current_rom_;
|
||||||
char* data_;
|
uchar version_;
|
||||||
|
uchar title[21] = "ROM Not Loaded";
|
||||||
|
uint uncompressed_size_;
|
||||||
|
uint compressed_size_;
|
||||||
|
uint compress_size_;
|
||||||
long int size_;
|
long int size_;
|
||||||
enum rom_type type_;
|
enum rom_type type_ = LoROM;
|
||||||
|
|
||||||
unsigned int uncompressed_size_;
|
|
||||||
unsigned int compressed_size_;
|
|
||||||
unsigned int compress_size_;
|
|
||||||
unsigned char version_;
|
|
||||||
unsigned char title[21] = "ROM Not Loaded";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|||||||
@@ -77,10 +77,8 @@ char *CreateAllGfxDataRaw(char *romData) {
|
|||||||
|
|
||||||
void CreateAllGfxData(char *romData, char *allgfx16Ptr) {
|
void CreateAllGfxData(char *romData, char *allgfx16Ptr) {
|
||||||
char *data = CreateAllGfxDataRaw(romData);
|
char *data = CreateAllGfxDataRaw(romData);
|
||||||
char *newData =
|
char *newData = new char[0x6F800];
|
||||||
new char[0x6F800]; // NEED TO GET THE APPROPRIATE SIZE FOR THAT
|
uchar *mask = new uchar[]{0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
||||||
unsigned char *mask =
|
|
||||||
new unsigned char[]{0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
|
||||||
int sheetPosition = 0;
|
int sheetPosition = 0;
|
||||||
|
|
||||||
// 8x8 tile
|
// 8x8 tile
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Core/constants.h"
|
||||||
#include "Graphics/palette.h"
|
#include "Graphics/palette.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|||||||
Reference in New Issue
Block a user