turned zarby 3bpp to 8bpp code into a routine

This commit is contained in:
Justin Scofield
2022-06-17 23:46:18 -04:00
parent 320b1a5e8b
commit 192a05c041
2 changed files with 49 additions and 45 deletions

View File

@@ -116,51 +116,52 @@ uint32_t ROM::GetRomPosition(int direct_addr, uint snes_addr) const {
return filePos; return filePos;
} }
// unsigned char *sheetBuffer = (unsigned char *)malloc(0x1000); // char *buffer = new char[0x800] AKA sheet_buffer_in 3bpp
// unsigned char bitmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; uchar* ROM::SNES3bppTo8bppSheet(uchar *sheet_buffer_in) // 128x32
// void SNES3bppTo8bppSheet() // 128x32 {
// { // 8bpp sheet out
// char *buffer = new char[0x800]; uchar *sheet_buffer_out = (unsigned char *)malloc(0x1000);
// int xx = 0; // positions where we are at on the sheet int xx = 0; // positions where we are at on the sheet
// int yy = 0; int yy = 0;
// int pos = 0; int pos = 0;
// int ypos = 0; int ypos = 0;
// for (int i = 0; i < 64; i++) // for each tiles //16 per lines for (int i = 0; i < 64; i++) // for each tiles //16 per lines
// { {
// for (int y = 0; y < 8; y++) // for each lines for (int y = 0; y < 8; y++) // for each lines
// { {
// //[0] + [1] + [16] //[0] + [1] + [16]
// for (int x = 0; x < 8; x++) { for (int x = 0; x < 8; x++) {
// unsigned char b1 = unsigned char b1 =
// (unsigned char)((buffer[(y * 2) + (24 * pos)] & (bitmask[x]))); (unsigned char)((sheet_buffer_in[(y * 2) + (24 * pos)] & (bitmask[x])));
// unsigned char b2 = unsigned char b2 =
// (unsigned char)(buffer[((y * 2) + (24 * pos)) + 1] & (unsigned char)(sheet_buffer_in[((y * 2) + (24 * pos)) + 1] &
// (bitmask[x])); (bitmask[x]));
// unsigned char b3 = unsigned char b3 =
// (unsigned char)(buffer[(16 + y) + (24 * pos)] & (bitmask[x])); (unsigned char)(sheet_buffer_in[(16 + y) + (24 * pos)] & (bitmask[x]));
// unsigned char b = 0; unsigned char b = 0;
// if (b1 != 0) { if (b1 != 0) {
// b |= 1; b |= 1;
// }; };
// if (b2 != 0) { if (b2 != 0) {
// b |= 2; b |= 2;
// }; };
// if (b3 != 0) { if (b3 != 0) {
// b |= 4; b |= 4;
// }; };
// sheetBuffer[x + (xx) + (y * 128) + (yy * 1024)] = b; sheet_buffer_out[x + (xx) + (y * 128) + (yy * 1024)] = b;
// } }
// } }
// pos++; pos++;
// ypos++; ypos++;
// xx += 8; xx += 8;
// if (ypos >= 16) { if (ypos >= 16) {
// yy++; yy++;
// xx = 0; xx = 0;
// ypos = 0; ypos = 0;
// } }
// } }
// } return sheet_buffer_out;
}
char *ROM::Decompress(int pos, bool reversed) { char *ROM::Decompress(int pos, bool reversed) {
char *buffer = new char[0x800]; char *buffer = new char[0x800];

View File

@@ -30,6 +30,7 @@ class ROM {
void LoadFromFile(const std::string& path); void LoadFromFile(const std::string& path);
std::vector<tile8> ExtractTiles(Graphics::TilePreset& preset); std::vector<tile8> ExtractTiles(Graphics::TilePreset& preset);
Graphics::SNESPalette ExtractPalette(Graphics::TilePreset& preset); Graphics::SNESPalette ExtractPalette(Graphics::TilePreset& preset);
uchar* SNES3bppTo8bppSheet(uchar *sheet_buffer_in);
uint32_t GetRomPosition(int direct_addr, uint snes_addr) const; uint32_t GetRomPosition(int direct_addr, uint snes_addr) const;
inline uchar* GetRawData() { return current_rom_; } inline uchar* GetRawData() { return current_rom_; }
@@ -54,6 +55,8 @@ class ROM {
std::shared_ptr<uchar> rom_ptr_; std::shared_ptr<uchar> rom_ptr_;
std::unordered_map<unsigned int, std::shared_ptr<uchar[2048]>> std::unordered_map<unsigned int, std::shared_ptr<uchar[2048]>>
decompressed_sheets; decompressed_sheets;
const uchar bitmmask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
}; };
} // namespace Data } // namespace Data