pull in decompiled decompressor
I need to figure out how decompressed sizes are done before fully making this work.
This commit is contained in:
parent
f1f081c114
commit
582b2a1933
68
src/main.cpp
68
src/main.cpp
|
@ -5,6 +5,67 @@
|
|||
#include <structs/BoltStructs.hpp>
|
||||
#include <vector>
|
||||
|
||||
std::vector<u8> BoltDecompress(std::span<u8> data) {
|
||||
u8* inptr = data.data();
|
||||
std::vector<u8> res;
|
||||
|
||||
i32 iVar3;
|
||||
i32 iVar6;
|
||||
u32 uVar5;
|
||||
u32 pbVar4; // outrun
|
||||
|
||||
for(u32 i = 0; i < data.size(); ++i) {
|
||||
auto uVar7 = inptr[i];
|
||||
|
||||
if(uVar7 < 128) {
|
||||
iVar3 = iVar3 + uVar5 * 8 + ((int)(uVar7 & 0x70) >> 4);
|
||||
pbVar4 = -(iVar6 * 0x10 + (uVar7 & 0xf) + 1);
|
||||
iVar6 = iVar3 + 1;
|
||||
|
||||
|
||||
|
||||
if(iVar3 != -2) {
|
||||
do {
|
||||
//*pOut = *pbVar4;
|
||||
pbVar4 = pbVar4 + 1;
|
||||
//bVar1 = iVar6 != 0;
|
||||
// pOut = pOut + 1;
|
||||
iVar6 = iVar6 + -1;
|
||||
} while(iVar6 != 0);
|
||||
}
|
||||
iVar6 = 0;
|
||||
iVar3 = 0;
|
||||
uVar5 = 0;
|
||||
} else if(uVar7 < 144) {
|
||||
iVar3 = uVar5 * 0x10 + (uVar7 & 0xf) + 1;
|
||||
while(iVar3 != 0) {
|
||||
iVar3 = iVar3 + -1;
|
||||
//*pOut = *pbRam00590aa8;
|
||||
// pOut = pOut + 1;
|
||||
// pbRam00590aa8 = pbRam00590aa8 + 1;
|
||||
// iRam00590ab0 = iRam00590ab0 + -1;
|
||||
// if(iRam00590ab0 == 0) {
|
||||
// NextBlock();
|
||||
//}
|
||||
}
|
||||
iVar3 = 0;
|
||||
uVar5 = 0;
|
||||
} else if(uVar7 < 160) {
|
||||
uVar5 = uVar7 & 3;
|
||||
iVar3 = iVar3 + 1;
|
||||
iVar6 = (int)(uVar7 & 0xc) >> 2;
|
||||
} else if(uVar7 < 192) {
|
||||
uVar5 = uVar5 * 0x20 + (uVar7 & 0x1f);
|
||||
iVar3 = iVar3 + 1;
|
||||
} else {
|
||||
iVar3 = iVar3 + 1;
|
||||
iVar6 = iVar6 * 0x40 + (uVar7 & 0x3f);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct BoltReader {
|
||||
struct ParsedTableEntry {
|
||||
std::string_view filename;
|
||||
|
@ -64,17 +125,10 @@ struct BoltReader {
|
|||
if(file.uncompressedData.empty()) {
|
||||
auto gid = (file.gid >> 8);
|
||||
auto entries = lib->GroupDescriptors()[gid].Entries(boltFile.GetMapping());
|
||||
|
||||
// std::cout << std::format("ptr: {} {:08x}\n", (void*)entries.data(), (u32)(std::bit_cast<usize>(entries.data()) - (usize)lib));
|
||||
|
||||
auto size = entries[file.index & 0x00ff].fileSize;
|
||||
auto offset = entries[file.index & 0x00ff].fileOffset;
|
||||
|
||||
file.uncompressedData = { std::bit_cast<u8*>(boltFile.GetMapping() + offset), size };
|
||||
|
||||
// for(i32 i = 0; i < entries.size(); ++i) {
|
||||
// std::cout << std::format("dick {}: {:08x}\n", i, entries[i].fileOffset);
|
||||
// }
|
||||
}
|
||||
|
||||
if(!f(file))
|
||||
|
|
Loading…
Reference in New Issue