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;