Added the ROM class to manage the state of the users ROMs

This commit is contained in:
scawful
2022-06-09 18:00:02 -04:00
parent d11d7c8ef7
commit b800c6721b
2 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
#include "ROM.h"
namespace yaze {
namespace Application {
namespace Utils {
void ROM::LoadFromFile(const std::string & path) {
std::cout << "filename: " << path << std::endl;
std::ifstream stream(path, std::ios::in | std::ios::binary);
if (!stream.good()) {
std::cout << "failure reading file" << std::endl;
return;
}
std::vector<char> contents((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
for(auto i: contents) {
int value = i;
std::cout << "data: " << value << std::endl;
}
std::cout << "file size: " << contents.size() << std::endl;
unsigned int uncompressed_data_size = 0;
unsigned int compressed_length = 0;
auto gfx_decompressed_data = alttp_compressor_.DecompressGfx(contents.data(), 0, contents.size(), &uncompressed_data_size, &compressed_length);
auto overworld_decompressed = alttp_compressor_.DecompressOverworld(contents.data(), 0, contents.size(), &uncompressed_data_size, &compressed_length);
}
}
}
}

View File

@@ -0,0 +1,34 @@
#ifndef YAZE_APPLICATION_UTILS_ROM_H
#define YAZE_APPLICATION_UTILS_ROM_H
#include <string>
#include <vector>
#include <bits/postypes.h>
#include <memory>
#include <iostream>
#include <fstream>
#include <cstddef>
#include "Compression.h"
#include "Core/Constants.h"
namespace yaze {
namespace Application {
namespace Utils {
class ROM {
public:
void LoadFromFile(const std::string & path);
private:
std::vector<char*> original_rom_;
std::vector<std::unique_ptr<char>> working_rom_;
ALTTPCompression alttp_compressor_;
};
}
}
}
#endif