aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Loaders/Compression/Lz4.cs
diff options
context:
space:
mode:
authorElise <elisezerotwo@gmail.com>2020-04-08 00:41:02 +0200
committerGitHub <noreply@github.com>2020-04-07 19:41:02 -0300
commitdc144d2e190e03729b16e402da9c36eec5aaf53f (patch)
tree00728f4639cc9642c25031aff6ae9a6d465f4fe7 /Ryujinx.HLE/Loaders/Compression/Lz4.cs
parent468d8f841ffcbebf4130371eb64ab04165bce3e9 (diff)
Use libhac for loading NSO and KIP (#1047)
* Use libhac for loading NSOs and KIPs * Fix formatting * Refactor KIP and NSO executables for libhac * Fix up formatting * Remove Ryujinx.HLE.Loaders.Compression * Remove reference to Ryujinx.HLE.Loaders.Compression in NxStaticObject.cs * Remove reference to Ryujinx.HLE.Loaders.Compression in KernelInitialProcess.cs * Rename classes in Ryujinx.HLE.Loaders.Executables * Fix space alignment * Fix up formatting
Diffstat (limited to 'Ryujinx.HLE/Loaders/Compression/Lz4.cs')
-rw-r--r--Ryujinx.HLE/Loaders/Compression/Lz4.cs78
1 files changed, 0 insertions, 78 deletions
diff --git a/Ryujinx.HLE/Loaders/Compression/Lz4.cs b/Ryujinx.HLE/Loaders/Compression/Lz4.cs
deleted file mode 100644
index 2001a8dc..00000000
--- a/Ryujinx.HLE/Loaders/Compression/Lz4.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-
-namespace Ryujinx.HLE.Loaders.Compression
-{
- static class Lz4
- {
- public static byte[] Decompress(byte[] cmp, int decLength)
- {
- byte[] dec = new byte[decLength];
-
- int cmpPos = 0;
- int decPos = 0;
-
- int GetLength(int length)
- {
- byte sum;
-
- if (length == 0xf)
- {
- do
- {
- length += (sum = cmp[cmpPos++]);
- }
- while (sum == 0xff);
- }
-
- return length;
- }
-
- do
- {
- byte token = cmp[cmpPos++];
-
- int encCount = (token >> 0) & 0xf;
- int litCount = (token >> 4) & 0xf;
-
- // Copy literal chunk
- litCount = GetLength(litCount);
-
- Buffer.BlockCopy(cmp, cmpPos, dec, decPos, litCount);
-
- cmpPos += litCount;
- decPos += litCount;
-
- if (cmpPos >= cmp.Length)
- {
- break;
- }
-
- // Copy compressed chunk
- int back = cmp[cmpPos++] << 0 |
- cmp[cmpPos++] << 8;
-
- encCount = GetLength(encCount) + 4;
-
- int encPos = decPos - back;
-
- if (encCount <= back)
- {
- Buffer.BlockCopy(dec, encPos, dec, decPos, encCount);
-
- decPos += encCount;
- }
- else
- {
- while (encCount-- > 0)
- {
- dec[decPos++] = dec[encPos++];
- }
- }
- }
- while (cmpPos < cmp.Length &&
- decPos < dec.Length);
-
- return dec;
- }
- }
-} \ No newline at end of file