Files
botw/lib/sead/include/resource/seadSZSDecompressor.h
T
Léo Lam 18c60323a9 Switch to subrepos
git subrepo clone https://github.com/open-ead/sead lib/sead

subrepo:
  subdir:   "lib/sead"
  merged:   "1b66e825d"
upstream:
  origin:   "https://github.com/open-ead/sead"
  branch:   "master"
  commit:   "1b66e825d"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

git subrepo clone (merge) https://github.com/open-ead/nnheaders lib/NintendoSDK

subrepo:
  subdir:   "lib/NintendoSDK"
  merged:   "9ee21399f"
upstream:
  origin:   "https://github.com/open-ead/nnheaders"
  branch:   "master"
  commit:   "9ee21399f"
git-subrepo:
  version:  "0.4.3"
  origin:   "ssh://git@github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

git subrepo clone https://github.com/open-ead/agl lib/agl

subrepo:
  subdir:   "lib/agl"
  merged:   "7c063271b"
upstream:
  origin:   "https://github.com/open-ead/agl"
  branch:   "master"
  commit:   "7c063271b"
git-subrepo:
  version:  "0.4.3"
  origin:   "ssh://git@github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

git subrepo clone https://github.com/open-ead/EventFlow lib/EventFlow

subrepo:
  subdir:   "lib/EventFlow"
  merged:   "c35d21b34"
upstream:
  origin:   "https://github.com/open-ead/EventFlow"
  branch:   "master"
  commit:   "c35d21b34"
git-subrepo:
  version:  "0.4.3"
  origin:   "ssh://git@github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"
2022-03-21 21:31:42 +01:00

81 lines
1.9 KiB
C++

#ifndef SEAD_SZS_DECOMPRESSOR_H_
#define SEAD_SZS_DECOMPRESSOR_H_
#include <basis/seadTypes.h>
#include <resource/seadDecompressor.h>
#include <resource/seadResource.h>
#include <resource/seadResourceMgr.h>
namespace sead
{
class SZSDecompressor : public Decompressor
{
public:
enum Step
{
cStepNormal = 0,
cStepShort = 1,
cStepLong = 2,
};
struct DecompContext
{
DecompContext();
DecompContext(void* dst);
void initialize(void* dst);
__attribute__((always_inline)) bool doCopy(u32 n)
{
if (u32(this->destCount) < n)
{
if (this->forceDestCount == 0)
return false;
n = this->destCount & 0xFFFF;
}
this->destCount -= n;
do
{
*this->destp = *(this->destp - this->lzOffset);
this->destp += 1;
} while (--n != 0);
this->step = SZSDecompressor::cStepNormal;
return true;
}
u8* destp;
s32 destCount;
s32 forceDestCount;
u8 flagMask;
u8 flags;
u8 packHigh;
Step step;
u16 lzOffset;
u8 headerSize;
};
public:
SZSDecompressor(u32 workSize, u8* workBuffer);
virtual ~SZSDecompressor() {}
virtual u8* tryDecompFromDevice(const ResourceMgr::LoadArg& loadArg, Resource* resource,
u32* outSize, u32* outAllocSize, bool* outAllocated);
static u32 getDecompAlignment(const void* src);
static u32 getDecompSize(const void* src);
static s32 readHeader_(DecompContext* context, const u8* src, u32 srcSize);
static s32 streamDecomp(DecompContext* context, const void* src, u32 srcSize);
static s32 decomp(void* dst, u32 dstSize, const void* src, u32 srcSize);
u32 mWorkSize;
u8* mWorkBuffer;
};
} // namespace sead
#endif // SEAD_SZS_DECOMPRESSOR_H_