Skip to content

Commit 92debb1

Browse files
committed
Merge branch 'master' of https://github.com/morkt/GARbro
2 parents ee62ee6 + b09ee45 commit 92debb1

90 files changed

Lines changed: 10585 additions & 788 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ArcFormats/Ankh/ArcGRP.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ internal void DetectFileTypes (ArcView file, List<Entry> dir)
118118
entry.UnpackedSize = header.ToUInt32 (0);
119119
entry.IsPacked = true;
120120
}
121+
else if (header.AsciiEqual (0, "zfd "))
122+
{
123+
entry.ChangeType (ImageFormat.Tga);
124+
entry.UnpackedSize = header.ToUInt32 (4);
125+
entry.IsPacked = true;
126+
}
121127
else if (header.AsciiEqual (4, "OggS"))
122128
{
123129
entry.ChangeType (OggAudio.Instance);
@@ -177,6 +183,8 @@ public override Stream OpenEntry (ArcFile arc, Entry entry)
177183
return OpenTpw (arc, pent);
178184
if (arc.File.View.AsciiEqual (entry.Offset+4, "HDJ\0"))
179185
return OpenImage (arc, pent);
186+
if (arc.File.View.AsciiEqual (entry.Offset, "zfd "))
187+
return OpenZfd (arc, pent);
180188
if (entry.Size > 12)
181189
{
182190
byte type = arc.File.View.ReadByte (entry.Offset+4);
@@ -243,6 +251,12 @@ Stream OpenTpw (ArcFile arc, PackedEntry entry)
243251
}
244252
}
245253

254+
Stream OpenZfd (ArcFile arc, PackedEntry entry)
255+
{
256+
var input = arc.File.CreateStream (entry.Offset+8, entry.Size-8);
257+
return new ZLibStream (input, CompressionMode.Decompress);
258+
}
259+
246260
internal static void UnpackTpw (IBinaryStream input, byte[] output)
247261
{
248262
input.Position = 8;

ArcFormats/ArcFormats.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123
<Compile Include="AdvSys\ImageGWD.cs" />
124124
<Compile Include="Ail\ArcLNK2.cs" />
125125
<Compile Include="AIRNovel\ArcAIR.cs" />
126+
<Compile Include="CsWare\AudioWAV.cs" />
127+
<Compile Include="CsWare\ImageGDT.cs" />
126128
<Compile Include="FC01\ArcBDT.cs" />
127129
<Compile Include="FC01\BdtTables.cs" />
128130
<Compile Include="GScripter\ArcDATA.cs" />
@@ -170,9 +172,13 @@
170172
<Compile Include="NScripter\Script.cs" />
171173
<Compile Include="Psp\ArcQPK.cs" />
172174
<Compile Include="ScrPlayer\ImageIMG.cs" />
175+
<Compile Include="SingleFileArchive.cs" />
176+
<Compile Include="Software House Parsley\ArcCG3.cs" />
173177
<Compile Include="Software House Parsley\ArcScn.cs" />
174178
<Compile Include="TechGian\ArcBIN.cs" />
175179
<Compile Include="Unity\ScriptDSM.cs" />
180+
<Compile Include="Xuse\ArcNT.cs" />
181+
<Compile Include="Xuse\ArcWVB.cs" />
176182
<Compile Include="Zyx\ImageXMG.cs" />
177183
<Compile Include="AudioAIFF.cs" />
178184
<Compile Include="Basil\ArcMIF.cs" />
@@ -751,7 +757,6 @@
751757
<Compile Include="AZSys\ArcAZSys.cs" />
752758
<Compile Include="Ethornell\ArcBGI.cs" />
753759
<Compile Include="Ffa\ArcBlackPackage.cs" />
754-
<None Include="Macromedia\ArcCCT.cs" />
755760
<Compile Include="Cherry\ArcCherry.cs" />
756761
<Compile Include="Circus\ArcCircus.cs" />
757762
<Compile Include="ArcCommon.cs" />

ArcFormats/CsWare/AudioWAV.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//! \file AudioWAV.cs
2+
//! \date 2023 Oct 26
3+
//! \brief Obscure C's ware WAVE file encoding.
4+
//
5+
// Copyright (C) 2023 by morkt
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to
9+
// deal in the Software without restriction, including without limitation the
10+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11+
// sell copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23+
// IN THE SOFTWARE.
24+
//
25+
26+
using GameRes.Utility;
27+
using System;
28+
using System.ComponentModel.Composition;
29+
using System.IO;
30+
31+
// [960405][C's Ware] GLO-RI-A ~Kindan no Ketsuzoku~
32+
33+
namespace GameRes.Formats.CsWare
34+
{
35+
[Export(typeof(AudioFormat))]
36+
[ExportMetadata("Priority", 1)] // should be tried before generic WAVE format
37+
public class WavAudio : AudioFormat
38+
{
39+
public override string Tag => "WAV/CSWARE";
40+
public override string Description => "C's ware encoded audio";
41+
public override uint Signature => 0x46464952; // 'RIFF'
42+
public override bool CanWrite => false;
43+
44+
public override SoundInput TryOpen (IBinaryStream file)
45+
{
46+
var header = file.ReadHeader (0x2E);
47+
if (header[0x14] != 1 || header[0x15] != 0xFF
48+
|| !header.AsciiEqual (8, "WAVEfmt ")
49+
|| !header.AsciiEqual (0x26, "data"))
50+
return null;
51+
var format = new WaveFormat {
52+
FormatTag = 1,
53+
Channels = header.ToUInt16 (0x16),
54+
SamplesPerSecond = header.ToUInt32 (0x18),
55+
AverageBytesPerSecond = header.ToUInt32 (0x1C) * 2,
56+
BlockAlign = (ushort)(header.ToUInt16 (0x20) * 2),
57+
BitsPerSample = 16,
58+
};
59+
uint input_size = header.ToUInt32 (0x2A);
60+
var samples = new byte[input_size * 2];
61+
Decode (file, samples);
62+
var decoded = new BinMemoryStream (samples, file.Name);
63+
file.Dispose();
64+
return new RawPcmInput (decoded, format);
65+
}
66+
67+
void Decode (IBinaryStream input, byte[] output)
68+
{
69+
int dst = 0;
70+
while (input.PeekByte() != -1)
71+
{
72+
sbyte sample = input.ReadInt8();
73+
LittleEndian.Pack (SampleMap[sample + 128], output, dst);
74+
dst += 2;
75+
}
76+
}
77+
78+
static readonly short[] SampleMap = InitSampleMap();
79+
80+
static short[] InitSampleMap ()
81+
{
82+
var map = new short[256];
83+
for (int i = 1; i <= 127; ++i)
84+
{
85+
map[128 + i] = (short)(Math.Pow (10.0, ((double)i + 44.8637) / 38.0597) - 14.5342);
86+
map[128 - i] = (short)-map[i + 128];
87+
}
88+
map[0] = -0x8000;
89+
return map;
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)