Skip to content

Commit 421c55b

Browse files
committed
Added support for Pack-Ice decompression.
1 parent 61cfb2e commit 421c55b

33 files changed

Lines changed: 497 additions & 8 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*.gal5 filter=lfs diff=lfs merge=lfs -text
1717
*.gdm filter=lfs diff=lfs merge=lfs -text
1818
*.gif filter=lfs diff=lfs merge=lfs -text
19+
*.ice filter=lfs diff=lfs merge=lfs -text
1920
*.ico filter=lfs diff=lfs merge=lfs -text
2021
*.imf filter=lfs diff=lfs merge=lfs -text
2122
*.it filter=lfs diff=lfs merge=lfs -text

Source/Agents/Decrunchers/AncientDecruncher/AncientDecruncher.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class AncientDecruncher : AgentBase, IAgentMultipleFormatIdentify
3636
private static readonly Guid agent12Id = Guid.Parse("844B2EC4-E12A-4252-9362-8571E6B4801A");
3737
private static readonly Guid agent13Id = Guid.Parse("A7B3C8D1-5E2F-4A6B-9C0D-1E2F3A4B5C6D");
3838
private static readonly Guid agent14Id = Guid.Parse("B8C4D9E2-6F3A-5B7C-0D1E-2F3A4B5C6D7E");
39+
private static readonly Guid agent15Id = Guid.Parse("A83620D4-076D-4D67-B3F5-5D14E67E4D9D");
3940

4041
#region IAgent implementation
4142
/********************************************************************/
@@ -67,7 +68,8 @@ public class AncientDecruncher : AgentBase, IAgentMultipleFormatIdentify
6768
new AgentSupportInfo(Resources.IDS_ANC_NAME_AGENT11, Resources.IDS_ANC_DESCRIPTION_AGENT11, agent11Id),
6869
new AgentSupportInfo(Resources.IDS_ANC_NAME_AGENT12, Resources.IDS_ANC_DESCRIPTION_AGENT12, agent12Id),
6970
new AgentSupportInfo(Resources.IDS_ANC_NAME_AGENT13, Resources.IDS_ANC_DESCRIPTION_AGENT13, agent13Id),
70-
new AgentSupportInfo(Resources.IDS_ANC_NAME_AGENT14, Resources.IDS_ANC_DESCRIPTION_AGENT14, agent14Id)
71+
new AgentSupportInfo(Resources.IDS_ANC_NAME_AGENT14, Resources.IDS_ANC_DESCRIPTION_AGENT14, agent14Id),
72+
new AgentSupportInfo(Resources.IDS_ANC_NAME_AGENT15, Resources.IDS_ANC_DESCRIPTION_AGENT15, agent15Id)
7173
];
7274

7375

@@ -121,6 +123,9 @@ public override IAgentWorker CreateInstance(Guid typeId)
121123
if (typeId == agent14Id)
122124
return new AncientWorker(Resources.IDS_ANC_NAME_AGENT14);
123125

126+
if (typeId == agent15Id)
127+
return new AncientWorker(Resources.IDS_ANC_NAME_AGENT15);
128+
124129
return null;
125130
}
126131
#endregion
@@ -240,6 +245,13 @@ public IdentifyFormatInfo IdentifyFormat(Stream dataStream)
240245
break;
241246
}
242247

248+
case DecompressorType.PackIce:
249+
{
250+
agentName = Resources.IDS_ANC_NAME_AGENT15;
251+
typeId = agent15Id;
252+
break;
253+
}
254+
243255
default:
244256
return null;
245257
}

Source/Agents/Decrunchers/AncientDecruncher/Resources.Designer.cs

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Agents/Decrunchers/AncientDecruncher/Resources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,13 @@ The DUKE is a cruncher library for the XPK cruncher created by Christian von Roq
272272

273273
DUKE uses the same compression algorithm as NUKE, but additionally applies delta encoding, making it especially suited for sample data.</value>
274274
</data>
275+
<data name="IDS_ANC_DESCRIPTION_AGENT15" xml:space="preserve">
276+
<value>Written by Teemu Suutari (Ancient library).
277+
Converted to C# by Thomas Neumann.
278+
279+
Pack-Ice was created for the Atari ST by Axe of Delight. Digital Tracker has the packer embedded into the tracker, so it was possible to save modules packed.</value>
280+
</data>
281+
<data name="IDS_ANC_NAME_AGENT15" xml:space="preserve">
282+
<value>Pack-Ice</value>
283+
</data>
275284
</root>

Source/Ports/LibAncient/Common/BackwardInputStream.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public BackwardInputStream(Buffer buffer, size_t startOffset, size_t endOffset)
3434
}
3535

3636
#region IInputStream implementation
37+
/********************************************************************/
38+
/// <summary>
39+
/// Indicate if the buffer has been read or not
40+
/// </summary>
41+
/********************************************************************/
42+
public bool Eof => currentOffset == endOffset;
43+
44+
45+
3746
/********************************************************************/
3847
/// <summary>
3948
/// Return the current position
@@ -124,6 +133,15 @@ public uint32_t ReadLE32()
124133

125134
return (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
126135
}
136+
137+
138+
139+
/********************************************************************/
140+
/// <summary>
141+
///
142+
/// </summary>
143+
/********************************************************************/
144+
public size_t Available => currentOffset - endOffset;
127145
#endregion
128146
}
129147
}

Source/Ports/LibAncient/Common/ForwardInputStream.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ public ForwardInputStream(Buffer buffer, size_t startOffset, size_t endOffset, s
3636
}
3737

3838
#region IInputStream implementation
39+
/********************************************************************/
40+
/// <summary>
41+
/// Indicate if the buffer has been read or not
42+
/// </summary>
43+
/********************************************************************/
44+
public bool Eof => currentOffset == endOffset;
45+
46+
47+
3948
/********************************************************************/
4049
/// <summary>
4150
/// Return the current position
@@ -134,6 +143,15 @@ public uint32_t ReadLE32()
134143

135144
return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
136145
}
146+
147+
148+
149+
/********************************************************************/
150+
/// <summary>
151+
///
152+
/// </summary>
153+
/********************************************************************/
154+
public size_t Available => endOffset - currentOffset;
137155
#endregion
138156
}
139157
}

Source/Ports/LibAncient/Common/IInputStream.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace Polycode.NostalgicPlayer.Ports.LibAncient.Common
1010
/// </summary>
1111
internal interface IInputStream
1212
{
13+
/// <summary>
14+
/// Indicate if the buffer has been read or not
15+
/// </summary>
16+
bool Eof { get; }
17+
1318
/// <summary>
1419
/// Return the current position
1520
/// </summary>
@@ -39,5 +44,10 @@ internal interface IInputStream
3944
/// Read a 32-bit integer in little-endian format
4045
/// </summary>
4146
uint32_t ReadLE32();
47+
48+
/// <summary>
49+
///
50+
/// </summary>
51+
size_t Available { get; }
4252
}
4353
}

Source/Ports/LibAncient/Common/MsbBitReader.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,14 @@ public uint32_t ReadBitsGeneric(uint32_t count, ReadWord readWord)
106106

107107
return ret;
108108
}
109+
110+
111+
112+
/********************************************************************/
113+
/// <summary>
114+
///
115+
/// </summary>
116+
/********************************************************************/
117+
public size_t Available => (inputStream.Available * 8U) + bufLength;
109118
}
110119
}

Source/Ports/LibAncient/Common/VariableLengthCodeDecoder.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,29 @@ public uint32_t Decode(BitReader bitReader, uint32_t @base)
6868
return offsets[@base] + bitReader(bitLengths[@base]);
6969
}
7070

71+
72+
73+
/********************************************************************/
74+
/// <summary>
75+
///
76+
/// </summary>
77+
/********************************************************************/
78+
public uint32_t DecodeCascade(BitReader bitReader)
79+
{
80+
for (uint32_t i = 0; i < offsets.Length; i++)
81+
{
82+
if (bitLengths[i] == 0) // Not valid in this context
83+
throw new DecompressionException();
84+
85+
uint32_t tmp = bitReader(bitLengths[i]);
86+
87+
if ((i == (offsets.Length - 1)) || (tmp != ((1 << bitLengths[i]) - 1)))
88+
return offsets[i] - i + tmp;
89+
}
90+
91+
throw new DecompressionException();
92+
}
93+
7194
#region Private methods
7295
/********************************************************************/
7396
/// <summary>

Source/Ports/LibAncient/DecompressorType.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public enum DecompressorType
1717
/// <summary></summary>
1818
Mmcmp,
1919
/// <summary></summary>
20+
PackIce,
21+
/// <summary></summary>
2022
PowerPacker,
2123
/// <summary></summary>
2224
StoneCracker,
@@ -25,14 +27,14 @@ public enum DecompressorType
2527
/// <summary></summary>
2628
Xpk_Bzp2,
2729
/// <summary></summary>
30+
Xpk_Duke,
31+
/// <summary></summary>
2832
Xpk_Lhlb,
2933
/// <summary></summary>
3034
Xpk_Mash,
3135
/// <summary></summary>
3236
Xpk_Nuke,
3337
/// <summary></summary>
34-
Xpk_Duke,
35-
/// <summary></summary>
3638
Xpk_Rake,
3739
/// <summary></summary>
3840
Xpk_Shri,

0 commit comments

Comments
 (0)