Finish decompress function.

master
sigonasr2 5 months ago
parent 65a4872b06
commit 45efe714d5
  1. 11
      EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp

@ -115,6 +115,7 @@ struct Rom{
std::vector<uint16_t>blockOutput; std::vector<uint16_t>blockOutput;
blockOutput.resize(size); blockOutput.resize(size);
decompressBlock(ptr,blockOutput); decompressBlock(ptr,blockOutput);
return blockOutput;
} }
private: private:
void decompressBlock(uint32_t ptrStart,std::vector<uint16_t>&block){ void decompressBlock(uint32_t ptrStart,std::vector<uint16_t>&block){
@ -167,10 +168,11 @@ struct Rom{
while(len--!=0)block[bpos++]=Rom::reversedBytes[block[bpos2++]&0xFF]; while(len--!=0)block[bpos++]=Rom::reversedBytes[block[bpos2++]&0xFF];
}break; }break;
case UNKNOWN_1:{ case UNKNOWN_1:{
if(bpos+2*len>maxLength||bpos<0)return;
while(len--!=0)block[bpos++]=block[bpos2--];
}break; }break;
case UNKNOWN_2:{ case UNKNOWN_2:{
return;
}break; }break;
} }
} }
@ -232,8 +234,9 @@ struct Rom{
std::vector<uint16_t>graphicsData; std::vector<uint16_t>graphicsData;
std::vector<Tile>tiles; std::vector<Tile>tiles;
BackgroundGraphics(std::string_view data,uint16_t index,byte bpp){ BackgroundGraphics(std::string_view data,uint16_t index,byte bpp){
DataBlock graphicsPointer{data,0xD7A1U+index*4U}; DataBlock graphicsPtr{data,0xD7A1U+index*4U};
graphicsPointer.decompress(); DataBlock loadGraphicsPtr{data,snesToHex(graphicsPtr.readInt32())};
graphicsData=loadGraphicsPtr.decompress();
} }
}; };
std::string data; std::string data;

Loading…
Cancel
Save