implemented ShiinaRio resources.

WARC archives;
S25 images;
OGV sound files.
This commit is contained in:
morkt 2015-04-20 20:57:01 +04:00
parent a51d15cd12
commit 1a8add3ab9
9 changed files with 1484 additions and 7 deletions

View File

@ -66,11 +66,13 @@
<Compile Include="ArcAMI.cs" />
<Compile Include="ArcAVC.cs" />
<Compile Include="ArcBGI.cs" />
<Compile Include="ArcBlackPackage.cs" />
<Compile Include="ArcCommon.cs" />
<Compile Include="ArcDRS.cs" />
<Compile Include="ArcEGO.cs" />
<Compile Include="ArcFVP.cs" />
<Compile Include="ArcGSP.cs" />
<Compile Include="ArcGsPack.cs" />
<Compile Include="ArcInnGrey.cs" />
<Compile Include="ArcINT.cs" />
<Compile Include="ArcISA.cs" />
@ -91,10 +93,12 @@
<Compile Include="ArcPD.cs" />
<Compile Include="ArcRPA.cs" />
<Compile Include="ArcSteinsGate.cs" />
<Compile Include="ArcWARC.cs" />
<Compile Include="ArcWILL.cs" />
<Compile Include="ArcXFL.cs" />
<Compile Include="ArcXP3.cs" />
<Compile Include="ArcYPF.cs" />
<Compile Include="AudioOGV.cs" />
<Compile Include="AudioWADY.cs" />
<Compile Include="Blowfish.cs" />
<Compile Include="CreateAMIWidget.xaml.cs">
@ -118,8 +122,8 @@
<Compile Include="CreateSGWidget.xaml.cs">
<DependentUpon>CreateSGWidget.xaml</DependentUpon>
</Compile>
<Compile Include="CreateWARCWidget.xaml.cs">
<DependentUpon>CreateWARCWidget.xaml</DependentUpon>
<Compile Include="CreateARCWidget.xaml.cs">
<DependentUpon>CreateARCWidget.xaml</DependentUpon>
</Compile>
<Compile Include="CreateXP3Widget.xaml.cs">
<DependentUpon>CreateXP3Widget.xaml</DependentUpon>
@ -140,8 +144,10 @@
<Compile Include="ImageKAAS.cs" />
<Compile Include="ImageMNV.cs" />
<Compile Include="ImagePRS.cs" />
<Compile Include="ImagePT1.cs" />
<Compile Include="ImageQNT.cs" />
<Compile Include="ImageRCT.cs" />
<Compile Include="ImageS25.cs" />
<Compile Include="ImageTGF.cs" />
<Compile Include="ImageTLG.cs" />
<Compile Include="ImageWCG.cs" />
@ -170,6 +176,9 @@
<Compile Include="WidgetNPA.xaml.cs">
<DependentUpon>WidgetNPA.xaml</DependentUpon>
</Compile>
<Compile Include="WidgetWARC.xaml.cs">
<DependentUpon>WidgetWARC.xaml</DependentUpon>
</Compile>
<Compile Include="WidgetXP3.xaml.cs">
<DependentUpon>WidgetXP3.xaml</DependentUpon>
</Compile>
@ -192,6 +201,9 @@
<Link>zlib64.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="Resources\ShiinaRio1.png" />
<EmbeddedResource Include="Resources\ShiinaRio2.png" />
<EmbeddedResource Include="Resources\ShiinaRio3.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@ -200,6 +212,8 @@
<Generator>PublicSettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<EmbeddedResource Include="Resources\DecodeV1.bin" />
<EmbeddedResource Include="Resources\DecodeV241.bin" />
</ItemGroup>
<ItemGroup>
<Page Include="CreateAMIWidget.xaml">
@ -230,7 +244,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateWARCWidget.xaml">
<Page Include="CreateARCWidget.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@ -254,6 +268,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WidgetWARC.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WidgetXP3.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

83
ArcFormats/ArcS25.cs Normal file
View File

@ -0,0 +1,83 @@
//! \file ArcS25.cs
//! \date Sat Apr 18 15:56:57 2015
//! \brief ShiinaRio image resource.
//
// Copyright (C) 2015 by morkt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using GameRes.Utility;
namespace GameRes.Formats.ShiinaRio
{
[Export(typeof(ArchiveFormat))]
public class S25Opener : ArchiveFormat
{
public override string Tag { get { return "S25"; } }
public override string Description { get { return "ShiinaRio engine multi-image"; } }
public override uint Signature { get { return 0x00353253; } } // 'S25'
public override bool IsHierarchic { get { return false; } }
public override bool CanCreate { get { return false; } }
public override ArcFile TryOpen (ArcView file)
{
int count = file.View.ReadInt32 (4);
if (count <= 0 || count > 0xfffff)
return null;
var base_name = Path.GetFileNameWithoutExtension (file.Name);
var dir = new List<Entry> (count);
uint index_offset = 8;
for (int i = 0; i < count; ++i)
{
uint offset = file.View.ReadUInt32 (index_offset);
index_offset += 4;
if (offset > 0 && offset <= file.MaxOffset)
{
var entry = new Entry
{
Name = string.Format ("{0}@{1:D4}.s25img", base_name, i),
Type = "image",
Offset = offset,
};
dir.Add (entry);
}
}
for (int i = 0; i < dir.Count; ++i)
{
long next_offset;
if (i+1 == dir.Count)
next_offset = file.MaxOffset;
else
next_offset = dir[i+1].Offset;
if (next_offset < dir[i].Offset)
return null;
dir[i].Size = (uint)(next_offset - dir[i].Offset);
}
return new ArcFile (file, this, dir);
}
}
}

1040
ArcFormats/ArcWARC.cs Normal file

File diff suppressed because it is too large Load Diff

58
ArcFormats/AudioOGV.cs Normal file
View File

@ -0,0 +1,58 @@
//! \file AudioOGV.cs
//! \date Sat Apr 18 14:18:47 2015
//! \brief ShiinaRio Ogg/Vorbis audio format.
//
// Copyright (C) 2015 by morkt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
using System.ComponentModel.Composition;
using System.IO;
namespace GameRes.Formats.ShiinaRio
{
[Export(typeof(AudioFormat))]
public class OgvAudio : OggAudio
{
public override string Tag { get { return "OGV"; } }
public override string Description { get { return "ShiinaRio audio format (Ogg/Vorbis)"; } }
public override uint Signature { get { return 0x0056474f; } } // 'OGV'
public override SoundInput TryOpen (Stream file)
{
var input = file as MemoryStream;
if (null == input || !input.CanWrite)
{
input = new MemoryStream();
file.CopyTo (input);
}
// FIXME: doesn't work for memory streams with non-zero origin
var buf = input.GetBuffer();
buf[1] = (byte)'g';
buf[2] = (byte)'g';
buf[3] = (byte)'S';
input.Position = 0;
var ogg = new OggInput (input);
if (file != input)
file.Dispose();
return ogg;
}
}
}

236
ArcFormats/ImageS25.cs Normal file
View File

@ -0,0 +1,236 @@
//! \file ImageS25.cs
//! \date Sat Apr 18 17:00:54 2015
//! \brief ShiinaRio S25 multi-image format.
//
// Copyright (C) 2015 by morkt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using GameRes.Utility;
namespace GameRes.Formats.ShiinaRio
{
internal class S25MetaData : ImageMetaData
{
public uint FirstOffset;
}
[Export(typeof(ImageFormat))]
public class S25Format : ImageFormat
{
public override string Tag { get { return "S25"; } }
public override string Description { get { return "ShiinaRio image format"; } }
public override uint Signature { get { return 0x00353253; } } // 'S25'
/* FIXME: in current implementation, only the first frame is returned */
public override ImageMetaData ReadMetaData (Stream stream)
{
using (var input = new ArcView.Reader (stream))
{
input.ReadUInt32();
int count = input.ReadInt32();
if (count < 0 || count > 0xfffff)
return null;
uint first_offset = input.ReadUInt32();
if (0 == first_offset)
return null;
input.BaseStream.Position = first_offset;
var info = new S25MetaData();
info.Width = input.ReadUInt32();
info.Height = input.ReadUInt32();
info.OffsetX = input.ReadInt32();
info.OffsetY = input.ReadInt32();
info.FirstOffset = first_offset+0x14;
info.BPP = 32;
return info;
}
}
public override ImageData Read (Stream stream, ImageMetaData info)
{
var meta = info as S25MetaData;
if (null == meta)
throw new ArgumentException ("S25Format.Read should be supplied with S25MetaData", "info");
using (var reader = new Reader (stream, meta))
{
var pixels = reader.Unpack();
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
PixelFormats.Bgra32, null, pixels, (int)info.Width*4);
bitmap.Freeze();
return new ImageData (bitmap, info);
}
}
public override void Write (Stream file, ImageData image)
{
throw new NotImplementedException ("S25Format.Write not implemented");
}
internal class Reader : IDisposable
{
ArcView.Reader m_input;
int m_width;
int m_height;
uint m_origin;
uint[] m_rows;
byte[] m_output;
public byte[] Data { get { return m_output; } }
public Reader (Stream file, S25MetaData info)
{
m_width = (int)info.Width;
m_height = (int)info.Height;
m_rows = new uint[m_height];
m_output = new byte[m_width * m_height * 4];
m_input = new ArcView.Reader (file);
m_origin = info.FirstOffset;
}
public byte[] Unpack ()
{
m_input.BaseStream.Position = m_origin;
for (int i = 0; i < m_rows.Length; ++i)
m_rows[i] = m_input.ReadUInt32();
int dst = 0;
int stride = m_width * 4;
for (int y = 0; y < m_height && dst != m_output.Length; ++y)
{
byte b, g, r, a;
uint row_pos = m_rows[y];
m_input.BaseStream.Position = row_pos;
m_input.ReadUInt16();
for (int x = m_width; x > 0 && dst != m_output.Length; )
{
if (0 != (row_pos & 1))
{
m_input.ReadByte();
++row_pos;
}
int count = m_input.ReadUInt16();
row_pos += 2;
int method = count >> 13;
int skip = (count & 0x1800) >> 11;
if (0 != skip)
{
m_input.BaseStream.Seek (skip, SeekOrigin.Current);
row_pos += (uint)skip;
}
count &= 0x7ff;
if (count > x) count = x;
x -= count;
if (0 == method || 1 == method)
{
dst += count * 4;
}
else if (2 == method)
{
for (int i = 0; i < count; ++i)
{
m_output[dst++] = m_input.ReadByte();
m_output[dst++] = m_input.ReadByte();
m_output[dst++] = m_input.ReadByte();
m_output[dst++] = 0xff;
row_pos += 3;
}
}
else if (3 == method)
{
b = m_input.ReadByte();
g = m_input.ReadByte();
r = m_input.ReadByte();
row_pos += 3;
for (int i = 0; i < count; ++i)
{
m_output[dst++] = b;
m_output[dst++] = g;
m_output[dst++] = r;
m_output[dst++] = 0xff;
}
}
else if (4 == method)
{
for (int i = 0; i < count; ++i)
{
a = m_input.ReadByte();
m_output[dst] += (byte)((m_input.ReadByte() - m_output[dst]) * a / 256);
++dst;
m_output[dst] += (byte)((m_input.ReadByte() - m_output[dst]) * a / 256);
++dst;
m_output[dst] += (byte)((m_input.ReadByte() - m_output[dst]) * a / 256);
++dst;
m_output[dst++] = a;
row_pos += 4;
}
}
else
{
row_pos += 4;
a = m_input.ReadByte();
b = m_input.ReadByte();
g = m_input.ReadByte();
r = m_input.ReadByte();
for (int i = 0; i < count; ++i)
{
m_output[dst] += (byte)((b - m_output[dst]) * a / 256);
++dst;
m_output[dst] += (byte)((g - m_output[dst]) * a / 256);
++dst;
m_output[dst] += (byte)((r - m_output[dst]) * a / 256);
++dst;
m_output[dst++] = a;
}
}
}
}
return m_output;
}
#region IDisposable Members
bool disposed = false;
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (!disposed)
{
if (disposing)
m_input.Dispose();
disposed = true;
}
}
#endregion
}
}
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.0.4.38")]
[assembly: AssemblyFileVersion ("1.0.4.38")]
[assembly: AssemblyVersion ("1.0.4.39")]
[assembly: AssemblyFileVersion ("1.0.4.39")]

View File

@ -0,0 +1,12 @@
<Grid x:Class="GameRes.Formats.GUI.WidgetWARC"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fmt="clr-namespace:GameRes.Formats.ShiinaRio"
xmlns:p="clr-namespace:GameRes.Formats.Properties"
MaxWidth="250">
<ComboBox Name="Scheme" ItemsSource="{Binding Source={x:Static fmt:Decoder.KnownSchemes}, Mode=OneWay}"
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=WARCScheme, Mode=TwoWay}"
SelectedValuePath="Name"
DisplayMemberPath="Name"
Width="180"/>
</Grid>

View File

@ -0,0 +1,28 @@
using System.Windows;
using System.Windows.Controls;
using System.Linq;
using GameRes.Formats.KiriKiri;
using GameRes.Formats.Properties;
using GameRes.Formats.Strings;
namespace GameRes.Formats.GUI
{
/// <summary>
/// Interaction logic for WidgetWARC.xaml
/// </summary>
public partial class WidgetWARC : Grid
{
public WidgetWARC ()
{
InitializeComponent();
// select the most recent scheme as default
if (-1 == Scheme.SelectedIndex)
Scheme.SelectedIndex = Scheme.ItemsSource.Cast<object>().Count()-1;
}
public ICrypt GetScheme ()
{
return Xp3Opener.GetScheme (Scheme.SelectedItem as string);
}
}
}

View File

@ -26,8 +26,8 @@ Kana ~Imouto~<br/>
Private Nurse<br/>
Sensei 2<br/>
</td></tr>
<tr class="odd"><td>*.ggd</td><td><tt>\xB9\xAA\xB3\xB3</tt><br/><tt>\xAB\xAD\xAA\xBA</tt><br/><tt>\xB7\xB6\xB8\xB7</td><td>Yes</td></tr>
<tr class="odd"><td>*.gg2</td><td><tt>GGA00000</tt></td><td>No</td></tr>
<tr class="odd"><td>*.ggd</td><td><tt>\xB9\xAA\xB3\xB3</tt><br/><tt>\xAB\xAD\xAA\xBA</tt><br/><tt>\xB7\xB6\xB8\xB7</tt><br/><tt>\xCD\xCA\xC9\xB8</tt></td><td>Yes</td></tr>
<tr class="odd"><td>*.gg1<br/>*.gg2<br/>*.gg3</td><td><tt>GGA00000</tt></td><td>No</td></tr>
<tr><td>*.bin</td><td><tt>ACPXPK01</tt></td><td>No</td><td>Unison Shift</td><td>Wasurenagusa ~Forget-me-Not~</td></tr>
<tr class="odd"><td>*.gsp</td><td>-</td><td>No</td><td rowspan="2">Black Rainbow</td><td rowspan="2">Saimin Gakuen</td></tr>
<tr class="odd"><td>*.bmz</td><td><tt>ZLC3</tt></td><td>Yes</td></tr>
@ -128,6 +128,8 @@ Nikutai Ten'i<br/>
<tr><td>*.pt1</td><td>-</td><td>No</td></tr>
<tr class="odd"><td>*.pak</td><td><tt>DataPack5</tt><br/><tt>GsPack4</tt></td><td>No</td><td rowspan="2">Root</td><td rowspan="2">Para-Sol</td></tr>
<tr class="odd"><td>*</td><td><tt>\x00\x00\x04\x00</tt></td><td>No</td></tr>
<tr><td>*.war</td><td><tt>WARC 1.7</tt></td><td>No</td><td rowspan="2">Shiina Rio</td><td rowspan="2">Helter Skelter</td></tr>
<tr><td>*.s25</td><td><tt>S25</tt></td><td>No</td></tr>
</table>
<p><a name="note-1">[1]</a> Non-encrypted only</p>
</body>