diff --git a/src/app/rom.cc b/src/app/rom.cc index b87dd178..2e65226c 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -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 \ No newline at end of file diff --git a/src/app/rom.h b/src/app/rom.h index 909485d4..29b4b122 100644 --- a/src/app/rom.h +++ b/src/app/rom.h @@ -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;