Add LoadFromPointer routine

This commit is contained in:
scawful
2022-07-12 23:23:29 -04:00
parent 53f7f0bb40
commit 2c9eb5132d
2 changed files with 9 additions and 9 deletions

View File

@@ -52,6 +52,8 @@ void ROM::LoadFromFile(const std::string &path) {
is_loaded_ = true; is_loaded_ = true;
} }
void ROM::LoadFromPointer(uchar *data) { current_rom_ = data; }
uchar *ROM::DecompressGraphics(int pos, int size) { uchar *ROM::DecompressGraphics(int pos, int size) {
return Decompress(pos, size, false); return Decompress(pos, size, false);
} }
@@ -152,12 +154,10 @@ uchar *ROM::SNES3bppTo8bppSheet(uchar *buffer_in, int sheet_id, int size) {
for (int y = 0; y < 8; y++) { for (int y = 0; y < 8; y++) {
//[0] + [1] + [16] //[0] + [1] + [16]
for (int x = 0; x < 8; x++) { for (int x = 0; x < 8; x++) {
auto b1 = auto b1 = ((buffer_in[(y * 2) + (24 * pos)] & (kGraphicsBitmap[x])));
(uchar)((buffer_in[(y * 2) + (24 * pos)] & (kGraphicsBitmap[x]))); auto b2 =
auto b2 = (uchar)(buffer_in[((y * 2) + (24 * pos)) + 1] & (buffer_in[((y * 2) + (24 * pos)) + 1] & (kGraphicsBitmap[x]));
(kGraphicsBitmap[x])); auto b3 = (buffer_in[(16 + y) + (24 * pos)] & (kGraphicsBitmap[x]));
auto b3 =
(uchar)(buffer_in[(16 + y) + (24 * pos)] & (kGraphicsBitmap[x]));
unsigned char b = 0; unsigned char b = 0;
if (b1 != 0) { if (b1 != 0) {
b |= 1; b |= 1;

View File

@@ -28,10 +28,12 @@ class ROM {
void Close(); void Close();
void SetupRenderer(std::shared_ptr<SDL_Renderer> renderer); void SetupRenderer(std::shared_ptr<SDL_Renderer> renderer);
void LoadFromFile(const std::string& path); void LoadFromFile(const std::string& path);
void LoadFromPointer(uchar *data);
uchar* DecompressGraphics(int pos, int size); uchar* DecompressGraphics(int pos, int size);
uchar* DecompressOverworld(int pos, int size); uchar* DecompressOverworld(int pos, int size);
uchar* Decompress(int pos, int size = 0x800, bool reversed = false); uchar* Decompress(int pos, int size = 0x800, bool reversed = false);
uchar* SNES3bppTo8bppSheet(uchar* buffer_in, int sheet_id = 0, uchar* SNES3bppTo8bppSheet(uchar* buffer_in, int sheet_id = 0,
int size = 0x1000); int size = 0x1000);
uint GetGraphicsAddress(uint8_t id) const; uint GetGraphicsAddress(uint8_t id) const;
@@ -48,10 +50,8 @@ class ROM {
private: private:
bool is_loaded_ = false; bool is_loaded_ = false;
bool has_header_ = false;
long size_ = 0;
int num_sheets_ = 0; int num_sheets_ = 0;
uint compressed_size_; long size_ = 0;
uchar* current_rom_; uchar* current_rom_;
uchar title[21] = "ROM Not Loaded"; uchar title[21] = "ROM Not Loaded";
enum rom_type type_ = LoROM; enum rom_type type_ = LoROM;