ROM housekeeping

This commit is contained in:
Justin Scofield
2022-07-20 18:47:23 +00:00
parent 984309b5c0
commit cd1fe3f2e4
2 changed files with 15 additions and 21 deletions

View File

@@ -1,8 +1,5 @@
#include "rom.h"
#include <compressions/alttpcompression.h>
#include <rommapping.h>
#include <cstddef>
#include <cstring>
#include <filesystem>
@@ -14,6 +11,7 @@
#include "app/core/common.h"
#include "app/core/constants.h"
#include "app/gfx/pseudo_vram.h"
#include "app/gfx/snes_tile.h"
namespace yaze {
@@ -92,6 +90,16 @@ void ROM::LoadAllGraphicsData() {
master_gfx_bin_ = buffer;
}
uint ROM::GetGraphicsAddress(uint8_t offset) const {
uint snes_address = 0;
uint pc_address = 0;
snes_address = (uint)((((current_rom_[0x4F80 + offset]) << 16) |
((current_rom_[0x505F + offset]) << 8) |
((current_rom_[0x513E + offset]))));
pc_address = core::SnesToPc(snes_address);
return pc_address;
}
uchar *ROM::DecompressGraphics(int pos, int size) {
return Decompress(pos, size, false);
}
@@ -229,16 +237,6 @@ uchar *ROM::SNES3bppTo8bppSheet(uchar *buffer_in, int sheet_id, int size) {
return sheet_buffer_out;
}
uint ROM::GetGraphicsAddress(uint8_t offset) const {
uint snes_address = 0;
uint pc_address = 0;
snes_address = (uint)((((current_rom_[0x4F80 + offset]) << 16) |
((current_rom_[0x505F + offset]) << 8) |
((current_rom_[0x513E + offset]))));
pc_address = core::SnesToPc(snes_address);
return pc_address;
}
SDL_Texture *ROM::DrawGraphicsSheet(int offset) {
SDL_Surface *surface =
SDL_CreateRGBSurfaceWithFormat(0, 128, 32, 8, SDL_PIXELFORMAT_INDEX8);

View File

@@ -1,9 +1,6 @@
#ifndef YAZE_APP_ROM_H
#define YAZE_APP_ROM_H
#include <compressions/alttpcompression.h>
#include <rommapping.h>
#include <cstddef>
#include <cstring>
#include <filesystem>
@@ -42,18 +39,19 @@ class ROM {
void LoadFromPointer(uchar* data);
void LoadAllGraphicsData();
uint GetGraphicsAddress(uint8_t id) const;
uchar* DecompressGraphics(int pos, int size);
uchar* DecompressOverworld(int pos, int size);
uchar* Decompress(int pos, int size = 0x800, bool reversed = false);
uchar* SNES3bppTo8bppSheet(uchar* buffer_in, int sheet_id = 0,
int size = 0x1000);
uint GetGraphicsAddress(uint8_t id) const;
SDL_Texture* DrawGraphicsSheet(int offset);
long getSize() const { return size_; }
uchar* data() { return current_rom_; }
const uchar* getTitle() const { return title; }
long getSize() const { return size_; }
bool isLoaded() const { return is_loaded_; }
auto Renderer() { return sdl_renderer_; }
auto GetGraphicsBin() const { return graphics_bin_; }
@@ -67,8 +65,6 @@ class ROM {
uchar* master_gfx_bin_;
uchar title[21] = "ROM Not Loaded";
bool is_loaded_ = false;
bool isbpp3[core::NumberOfSheets];
enum rom_type type_ = LoROM;
ImVec4 display_palette_[8];