From 45efe714d5278beb9c5e1488a9986be820d15086 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 1 Jul 2024 11:38:30 -0400 Subject: [PATCH] Finish decompress function. --- .../EarthboundBattleBackgrounds/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp b/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp index b96d369..8e834cb 100644 --- a/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp +++ b/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp @@ -115,6 +115,7 @@ struct Rom{ std::vectorblockOutput; blockOutput.resize(size); decompressBlock(ptr,blockOutput); + return blockOutput; } private: void decompressBlock(uint32_t ptrStart,std::vector&block){ @@ -167,10 +168,11 @@ struct Rom{ while(len--!=0)block[bpos++]=Rom::reversedBytes[block[bpos2++]&0xFF]; }break; case UNKNOWN_1:{ - + if(bpos+2*len>maxLength||bpos<0)return; + while(len--!=0)block[bpos++]=block[bpos2--]; }break; case UNKNOWN_2:{ - + return; }break; } } @@ -232,8 +234,9 @@ struct Rom{ std::vectorgraphicsData; std::vectortiles; BackgroundGraphics(std::string_view data,uint16_t index,byte bpp){ - DataBlock graphicsPointer{data,0xD7A1U+index*4U}; - graphicsPointer.decompress(); + DataBlock graphicsPtr{data,0xD7A1U+index*4U}; + DataBlock loadGraphicsPtr{data,snesToHex(graphicsPtr.readInt32())}; + graphicsData=loadGraphicsPtr.decompress(); } }; std::string data;