added formal ui test code for zarby decompression, surface building not supported yet
This commit is contained in:
@@ -55,7 +55,6 @@ std::vector<tile8> ROM::ExtractTiles(Graphics::TilePreset &preset) {
|
||||
std::cout << alttp_decompression_error << std::endl;
|
||||
return rawTiles;
|
||||
}
|
||||
// data = Decompress(filePos);
|
||||
|
||||
// unpack the tiles based on their depth
|
||||
unsigned tileCpt = 0;
|
||||
@@ -116,11 +115,18 @@ uint32_t ROM::GetRomPosition(int direct_addr, uint snes_addr) const {
|
||||
return filePos;
|
||||
}
|
||||
|
||||
// char *buffer = new char[0x800] AKA sheet_buffer_in 3bpp
|
||||
uchar* ROM::SNES3bppTo8bppSheet(uchar *sheet_buffer_in) // 128x32
|
||||
uchar* ROM::LoadGraphicsSheet(int offset) {
|
||||
auto tilesheet_position = Core::Constants::gfx_1_pointer +
|
||||
(offset * Core::Constants::UncompressedSheetSize);
|
||||
auto data = Decompress(tilesheet_position);
|
||||
return SNES3bppTo8bppSheet(data);
|
||||
}
|
||||
|
||||
// char *buffer = new char[0x800] AKA sheet_buffer_in 3bpp
|
||||
uchar *ROM::SNES3bppTo8bppSheet(uchar *sheet_buffer_in) // 128x32
|
||||
{
|
||||
// 8bpp sheet out
|
||||
const uchar bitmask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
||||
// 8bpp sheet out
|
||||
const uchar bitmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
||||
uchar *sheet_buffer_out = (unsigned char *)malloc(0x1000);
|
||||
int xx = 0; // positions where we are at on the sheet
|
||||
int yy = 0;
|
||||
@@ -132,13 +138,14 @@ uchar* ROM::SNES3bppTo8bppSheet(uchar *sheet_buffer_in) // 128x32
|
||||
{
|
||||
//[0] + [1] + [16]
|
||||
for (int x = 0; x < 8; x++) {
|
||||
unsigned char b1 =
|
||||
(unsigned char)((sheet_buffer_in[(y * 2) + (24 * pos)] & (bitmask[x])));
|
||||
unsigned char b1 = (unsigned char)((
|
||||
sheet_buffer_in[(y * 2) + (24 * pos)] & (bitmask[x])));
|
||||
unsigned char b2 =
|
||||
(unsigned char)(sheet_buffer_in[((y * 2) + (24 * pos)) + 1] &
|
||||
(bitmask[x]));
|
||||
(bitmask[x]));
|
||||
unsigned char b3 =
|
||||
(unsigned char)(sheet_buffer_in[(16 + y) + (24 * pos)] & (bitmask[x]));
|
||||
(unsigned char)(sheet_buffer_in[(16 + y) + (24 * pos)] &
|
||||
(bitmask[x]));
|
||||
unsigned char b = 0;
|
||||
if (b1 != 0) {
|
||||
b |= 1;
|
||||
|
||||
@@ -29,14 +29,16 @@ class ROM {
|
||||
void LoadFromFile(const std::string& path);
|
||||
std::vector<tile8> ExtractTiles(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;
|
||||
inline uchar* GetRawData() { return current_rom_; }
|
||||
const uchar* getTitle() const { return title; }
|
||||
long int getSize() const { return size_; }
|
||||
char getVersion() const { return version_; }
|
||||
bool isLoaded() const { return loaded; }
|
||||
bool isLoaded() const { return loaded; }
|
||||
|
||||
uchar* LoadGraphicsSheet(int offset);
|
||||
uchar* SNES3bppTo8bppSheet(uchar *sheet_buffer_in);
|
||||
char* Decompress(int pos, bool reversed = false);
|
||||
|
||||
private:
|
||||
|
||||
@@ -317,6 +317,23 @@ void Editor::DrawProjectEditor() {
|
||||
yaze::Gui::InputHex("SNES Palette Location",
|
||||
¤t_set_.SNESPaletteLocation);
|
||||
|
||||
static bool loaded_image = false;
|
||||
static uchar* image_data = nullptr;
|
||||
ImGui::Text("Zarby Retrieval Code");
|
||||
BASIC_BUTTON("Retrieve Graphics") {
|
||||
if (rom_.isLoaded()) {
|
||||
if (!loaded_image) {
|
||||
image_data = rom_.LoadGraphicsSheet(current_set.pc_tiles_location_);
|
||||
loaded_image = true;
|
||||
} else {
|
||||
// TODO: build the sdl surface from the tilesheet data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Skarsnik Retrieval Code");
|
||||
BASIC_BUTTON("ExtractTiles") {
|
||||
if (rom_.isLoaded()) {
|
||||
tiles_ = rom_.ExtractTiles(current_set_);
|
||||
|
||||
Reference in New Issue
Block a user