Remove unnecessary file and add subscript operator

This commit is contained in:
Justin Scofield
2022-07-24 01:33:27 -04:00
parent 0a6db683f6
commit 12f896e31e
2 changed files with 8 additions and 29 deletions

View File

@@ -413,32 +413,5 @@ uchar *ROM::SNES3bppTo8bppSheet(uchar *buffer_in, int sheet_id, int size) {
return sheet_buffer_out;
}
SDL_Texture *ROM::DrawGraphicsSheet(int offset) {
SDL_Surface *surface =
SDL_CreateRGBSurfaceWithFormat(0, 128, 32, 8, SDL_PIXELFORMAT_INDEX8);
std::cout << "Drawing surface #" << offset << std::endl;
uchar *sheet_buffer = nullptr;
for (int i = 0; i < 8; i++) {
surface->format->palette->colors[i].r = i * 31;
surface->format->palette->colors[i].g = i * 31;
surface->format->palette->colors[i].b = i * 31;
}
uint graphics_address = GetGraphicsAddress(offset);
std::cout << "Decompressing..." << std::endl;
auto decomp = Decompress(graphics_address);
std::cout << "Converting to 8bpp sheet..." << std::endl;
sheet_buffer = SNES3bppTo8bppSheet(decomp);
std::cout << "Assigning pixel data..." << std::endl;
surface->pixels = sheet_buffer;
std::cout << "Creating texture from surface..." << std::endl;
SDL_Texture *sheet_texture = nullptr;
sheet_texture = SDL_CreateTextureFromSurface(renderer_.get(), surface);
if (sheet_texture == nullptr) {
std::cout << "Error: " << SDL_GetError() << std::endl;
}
return sheet_texture;
}
} // namespace app
} // namespace yaze

View File

@@ -64,8 +64,6 @@ class ROM {
uchar* SNES3bppTo8bppSheet(uchar* buffer_in, int sheet_id = 0,
int size = 0x1000);
SDL_Texture* DrawGraphicsSheet(int offset);
auto data() { return rom_data_.data(); }
auto isLoaded() const { return is_loaded_; }
auto GetSize() const { return size_; }
@@ -77,6 +75,14 @@ class ROM {
auto GetVRAM() const { return pseudo_vram_; }
auto GetBytes() const { return rom_data_; }
uchar& operator[](int i) {
if (i > size_) {
std::cout << "Index out of bounds" << std::endl;
return rom_data_[0];
}
return rom_data_[i];
}
private:
int num_sheets_ = 0;
long size_ = 0;