Compare commits

...
11 Commits
Author SHA1 Message Date
korenkonder 7046e3cfc2 Release v0.4.10.12
A3DA, MotHead
2022-05-12 10:43:46 +03:00
korenkonder ec5f8c803e Release v0.4.10.11
A3DA, DIVAFILE, MotHead
2022-03-10 21:29:09 +03:00
korenkonder 310d637072 Release v0.4.10.10
DEX, MotHead
2022-01-13 14:44:23 +03:00
korenkonder 4d05f6a878 Release v0.4.10.9
A3DA
2021-12-22 16:37:31 +03:00
korenkonder 35d7712d8f Release v0.4.10.8
A3DA, MotHead
2021-11-09 14:34:27 +03:00
korenkonder df92e13d2c Release v0.4.10.7
A3DA, AuthDB
2021-10-03 18:32:46 +03:00
korenkonder 803f64e333 Release v0.4.10.6
A3DA
2021-09-26 19:16:56 +03:00
korenkonder a7e14e22ad Release v0.4.10.5
A3DA
2021-09-17 21:00:31 +03:00
korenkonder d94f45870d Release v0.4.10.4
A3DA
2021-05-26 22:43:16 +03:00
korenkonder 2b46e0f4bd Release v0.4.10.3
A3DA
2021-05-24 04:02:18 +03:00
korenkonder f1547f78b2 Release v0.4.10.2.1
A3DA
2021-05-23 21:11:34 +03:00
28 changed files with 1812 additions and 1419 deletions
+59 -56
View File
@@ -2,6 +2,7 @@ namespace KKdBaseLib.Auth3D
{
public struct Data
{
public string[] Auth2D;
public string[] Motion;
public string[] ObjectList;
public string[] ObjectHRCList;
@@ -9,9 +10,11 @@ namespace KKdBaseLib.Auth3D
public _ _;
public DOF? DOF;
public Fog[] Fog;
public Chara[] Chara;
public Curve[] Curve;
public Event[] Event;
public Light[] Light;
public Point[] Point;
public Object[] Object;
public Ambient[] Ambient;
public ObjectHRC[] ObjectHRC;
@@ -20,8 +23,6 @@ namespace KKdBaseLib.Auth3D
public PlayControl PlayControl;
public PostProcess? PostProcess;
public MaterialList[] MaterialList;
public ModelTransform[] Chara;
public ModelTransform[] Point;
public CameraAuxiliary? CameraAuxiliary;
}
@@ -58,17 +59,23 @@ namespace KKdBaseLib.Auth3D
public struct ViewPoint
{
public bool FOVHorizontal;
public float? Aspect;
public float? CameraApertureH;
public float? CameraApertureW;
public Key FOV;
public Key Roll;
public Key FocalLength;
public bool FOVIsHorizontal;
public float Aspect;
public float CameraApertureH;
public float CameraApertureW;
public Key? FocalLength;
public Key? FOV;
public Key? Roll;
public ModelTransform MT;
}
}
public struct Chara
{
public ModelTransform MT;
public string Name;
}
public struct Curve
{
public string Name;
@@ -77,18 +84,17 @@ namespace KKdBaseLib.Auth3D
public struct DOF
{
public string Name;
public ModelTransform MT;
}
public struct Event
{
public int? Type;
public float? End;
public float? Begin;
public float? ClipEnd;
public float? ClipBegin;
public float? TimeRefScale;
public int Type;
public float End;
public float Begin;
public float ClipEnd;
public float ClipBegin;
public float TimeRefScale;
public string Name;
public string Param1;
public string Ref;
@@ -96,11 +102,11 @@ namespace KKdBaseLib.Auth3D
public struct Fog
{
public int? Id;
public int Id;
public Key? End;
public Key? Start;
public Key? Density;
public Vec4<Key?>? Diffuse;
public Vec4<Key?>? Color;
}
public enum CompressF16 : int
@@ -135,7 +141,7 @@ namespace KKdBaseLib.Auth3D
public EPType EPTypePost;
public float? Max;
public float Value;
public RawD RawData;
public bool RawData;
public KFT3[] Keys;
public Key(A3DAKey k)
@@ -160,20 +166,11 @@ namespace KKdBaseLib.Auth3D
Value = k.Keys[0].V;
}
}
public struct RawD
{
public int KeyType;
public int ValueListSize;
public string ValueType;
public string[] ValueList;
}
}
public struct Light
{
public int? Id;
public string Name;
public int Id;
public string Type;
public Key? ConeAngle;
public Key? Constant;
@@ -185,16 +182,15 @@ namespace KKdBaseLib.Auth3D
public Vec4<Key?>? Ambient;
public Vec4<Key?>? Diffuse;
public Vec4<Key?>? Specular;
public Vec4<Key?>? Incandescence;
public Vec4<Key?>? ToneCurve;
public ModelTransform Position;
public ModelTransform SpotDirection;
}
public struct MaterialList
{
public ulong HashName;
public string Name;
public Key GlowIntensity;
public Key? GlowIntensity;
public Vec4<Key?>? BlendColor;
public Vec4<Key?>? Incandescence;
}
@@ -202,14 +198,13 @@ namespace KKdBaseLib.Auth3D
public struct MObjectHRC
{
public string Name;
public Node[] Node;
public Vec3<float?> JointOrient;
public ObjectNode[] Node;
public Instance[] Instances;
public ModelTransform MT;
public struct Instance
{
public bool? Shadow;
public bool Shadow;
public string Name;
public string UIDName;
public ModelTransform MT;
@@ -218,7 +213,6 @@ namespace KKdBaseLib.Auth3D
public struct ModelTransform
{
public bool Writed;
public int? BinOffset;
public Key Visibility;
public Vec3<Key> Rot;
@@ -226,29 +220,23 @@ namespace KKdBaseLib.Auth3D
public Vec3<Key> Trans;
}
public struct Node
{
public int? Parent;
public string Name;
public ModelTransform MT;
}
public struct Object
{
public float? PatOffset;
public float? MorphOffset;
public float PatOffset;
public float MorphOffset;
public string Name;
public string Pat;
public string Morph;
public string UIDName;
public string ParentName;
public string ParentNode;
public ModelTransform MT;
public TexturePattern[] TexPat;
public TextureTransform[] TexTrans;
public struct TexturePattern
{
public int? PatOffset;
public float PatOffset;
public string Pat;
public string Name;
}
@@ -271,20 +259,35 @@ namespace KKdBaseLib.Auth3D
public struct ObjectHRC
{
public bool? Shadow;
public bool Shadow;
public string Name;
public string UIDName;
public Node[] Node;
public Vec3<float?> JointOrient;
public string ParentName;
public string ParentNode;
public ObjectNode[] Node;
}
public struct ObjectNode
{
public Vec3? JointOrient;
public int Parent;
public string Name;
public ModelTransform MT;
}
public struct PlayControl
{
public int Begin;
public float Begin;
public int? Div;
public int FPS;
public int? Offset;
public int Size;
public float FPS;
public float? Offset;
public float Size;
}
public struct Point
{
public ModelTransform MT;
public string Name;
}
public struct PostProcess
@@ -292,8 +295,8 @@ namespace KKdBaseLib.Auth3D
public Key? LensFlare;
public Key? LensGhost;
public Key? LensShaft;
public Vec4<Key?>? Ambient;
public Vec4<Key?>? Diffuse;
public Vec4<Key?>? Specular;
public Vec4<Key?>? Intensity;
public Vec4<Key?>? Radius;
public Vec4<Key?>? SceneFade;
}
}
-99
View File
@@ -1,99 +0,0 @@
//Original research by Samyuu
namespace KKdBaseLib
{
public static class DCC //Databank Checksum Calculator
{
private static readonly ushort[] ChecksumLookupTable = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0,
};
public static ushort CalculateChecksum(byte[] data,
int offset = 0, ushort seed = 0xFFFF)
{
int length = data.Length;
ushort result = seed;
for (int i = offset; i < length; i++)
result = (ushort)(ChecksumLookupTable[(result >> 8) ^ data[i]] ^ (result << 8));
return result;
}
public static uint CalculateChecksumU32(byte[] data,
int offset = 0, uint seed = 0xFFFFFFFF)
{
int length = data.Length;
uint result = seed;
for (int i = offset; i < length; i++)
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
return result;
}
public static ulong CalculateChecksumU64(byte[] data,
int offset = 0, ulong seed = 0xFFFFFFFFFFFFFFFF)
{
int length = data.Length;
ulong result = seed;
for (int i = offset; i < length; i++)
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
return result;
}
public static unsafe ushort CalculateChecksum(byte* data,
int length, int offset = 0, ushort seed = 0xFFFF)
{
ushort result = seed;
for (int i = offset; i < length; i++)
result = (ushort)(ChecksumLookupTable[(result >> 8) ^ data[i]] ^ (result << 8));
return result;
}
public static unsafe uint CalculateChecksumU32(byte* data,
int length, int offset = 0, uint seed = 0xFFFFFFFF)
{
uint result = seed;
for (int i = offset; i < length; i++)
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
return result;
}
public static unsafe ulong CalculateChecksumU64(byte* data,
int length, int offset = 0, ulong seed = 0xFFFFFFFFFFFFFFFF)
{
ulong result = seed;
for (int i = offset; i < length; i++)
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
return result;
}
}
}
+8
View File
@@ -126,6 +126,10 @@ namespace KKdBaseLib
{ if (isBE) { for (byte i = 0; i < 8; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
for (byte i = 0; i < 8; i++) { le |= buf[i]; if (i < 7) le <<= 8; } } return le; }
public static sbyte TI8(this byte[] arr, int offset = 0)
{ sbyte val; fixed (byte* ptr = arr) val = *( sbyte*)(ptr + offset); return val; }
public static byte TU8(this byte[] arr, int offset = 0)
{ byte val; fixed (byte* ptr = arr) val = *( byte*)(ptr + offset); return val; }
public static short TI16(this byte[] arr, int offset = 0)
{ short val; fixed (byte* ptr = arr) val = *( short*)(ptr + offset); return val; }
public static ushort TU16(this byte[] arr, int offset = 0)
@@ -159,6 +163,10 @@ namespace KKdBaseLib
public static Quat TQ (this byte[] arr, int offset = 0)
{ Quat val; fixed (byte* ptr = arr) val = *( Quat*)(ptr + offset); return val; }
public static void GBy(this byte[] arr, sbyte val, int offset = 0)
{ fixed (byte* ptr = arr) *( sbyte*)(ptr + offset) = val; }
public static void GBy(this byte[] arr, byte val, int offset = 0)
{ fixed (byte* ptr = arr) *( byte*)(ptr + offset) = val; }
public static void GBy(this byte[] arr, short val, int offset = 0)
{ fixed (byte* ptr = arr) *( short*)(ptr + offset) = val; }
public static void GBy(this byte[] arr, ushort val, int offset = 0)
+4 -5
View File
@@ -223,7 +223,7 @@ namespace KKdBaseLib.F2
public int Size;
public int Repeat;
public SubENRSEntry[] Sub;
public ENRSEntry(int offset, int count, int size, int repeat)
{ Offset = offset; Count = count; Size = size; Repeat = repeat; Sub = new SubENRSEntry[count]; }
@@ -255,13 +255,12 @@ namespace KKdBaseLib.F2
public int SizeSkip => Skip + Reverse * (2 << (byte)Type);
public int Size => Reverse * (2 << (byte)Type);
public override string ToString() => "Skip: " + Skip +
"; Reverse: " + Reverse + "; Type: " + Type;
public override string ToString() =>
$"Skip: {Skip}; Reverse: {Reverse}; Type: {Type}";
}
public override string ToString() =>
"Offset: " + Offset + "; Count: " + Count + "; " +
"Size: " + Size + "; Repeat: " + Repeat;
$"Offset: {Offset}; Count: {Count}; Size: {Size}; Repeat: {Repeat}";
}
public override string ToString() =>
+3 -3
View File
@@ -4,14 +4,14 @@
<Authors>korenkonder</Authors>
<Company></Company>
<Configuration></Configuration>
<Copyright>korenkonder (C) 2019-2021</Copyright>
<Copyright>korenkonder (C) 2019-2022</Copyright>
<Description>A base library</Description>
<FileVersion>0.4.10.2</FileVersion>
<FileVersion>0.4.10.12</FileVersion>
<PackageId>KKdBaseLib</PackageId>
<Product>KKdBaseLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdBaseLib</Title>
<Version>0.4.10.2</Version>
<Version>0.4.10.12</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
+2 -3
View File
@@ -256,9 +256,8 @@ namespace KKdBaseLib
{
m /= 10;
j /= 10;
sort[i++] = ++j;
if (j * 10 >= length)
j++;
while (j % 10 == 9) j /= 10;
j++;
}
else if (j % 10 != 9)
sort[i++] = j++;
+659 -455
View File
File diff suppressed because it is too large Load Diff
-146
View File
@@ -1,146 +0,0 @@
using KKdBaseLib;
using KKdMainLib.IO;
namespace KKdMainLib
{
public unsafe struct AddParam : System.IDisposable
{
private long i;
private Stream s;
public HeaderData Header;
public void AddParamReader(string file)
{
Header = new HeaderData();
s = File.OpenReader(file + ".adp");
Header.Count = s.RI64();
Header.DataLength = s.RI64();
Header.DataOffset = s.RI64();
if (Header.Count < 1 || Header.DataOffset > s.P || Header.DataLength > s.LI64
- Header.DataOffset || Header.Count * 0x20 > s.LI64 - Header.DataOffset) { s.C(); return; }
Header.Data = new HeaderData.Sub[Header.Count];
byte[] data = s.RBy(Header.DataLength, Header.DataOffset);
s.C();
fixed (byte* ptr = data)
{
HeaderData.Sub* hPtr = (HeaderData.Sub*)ptr;
for (i = 0; i < Header.Count; i++)
Header.Data[i] = hPtr[i];
}
data = null;
}
public void AddParamWriter(string file)
{
if (Header.Data == null || Header.Data.LongLength < 1) return;
Header.Count = Header.Data.LongLength;
Header.DataLength = Header.Count * 0x20;
Header.DataOffset = 0x18L;
byte[] data = new byte[Header.DataLength];
fixed (byte* ptr = data)
{
HeaderData.Sub* hPtr = (HeaderData.Sub*)ptr;
for (i = 0; i < Header.Count; i++)
hPtr[i] = Header.Data[i];
}
s = File.OpenWriter(file + ".adp", true);
s.W(Header.Count);
s.W(Header.DataLength);
s.W(Header.DataOffset);
s.W(data);
s.C();
data = null;
}
public void MsgPackReader(string file, bool json)
{
Header = new HeaderData();
MsgPack addParam;
MsgPack msgPack = file.ReadMPAllAtOnce(json);
if ((addParam = msgPack["AddParam", true]).IsNull) return;
Header.Count = addParam.Array.LongLength;
Header.Data = new HeaderData.Sub[Header.Count];
for (i = 0; i < Header.Count; i++)
{
ref HeaderData.Sub sub = ref Header.Data[i];
sub.Time = addParam[i].RF32("Time");
sub.Flags = addParam[i].RI32("Flags");
sub.Frame = addParam[i].RI32("Frame");
sub.ID = addParam[i].RI32("ID");
sub.Value = addParam[i].RF32("Value");
sub.PVBranch = addParam[i].RnI32("PVBranch") ?? 0;
float? f = addParam[i].RnF32("Value");
if (f.HasValue)
{
if (sub.ID == 0) { float v = 0; *(uint*)&v = addParam[i].RU32("Value"); sub.Value = v; }
else sub.Value = f.Value;
}
else { float v = 0; *(uint*)&v = 0xFFFFFFFF; sub.Value = v; }
}
msgPack.Dispose();
}
public void MsgPackWriter(string file, bool json)
{
if (Header.Data == null || Header.Data.LongLength < 1) return;
MsgPack addParam = new MsgPack(Header.Data.LongLength, "AddParam");
fixed (HeaderData.Sub* ptr = Header.Data)
for (i = 0; i < Header.Count; i++)
{
ref HeaderData.Sub sub = ref Header.Data[i];
addParam[i] = MsgPack.New.Add("Time", sub.Time).Add("Flags", sub.Flags).Add("Frame", sub.Frame);
if (sub.PVBranch > 0)
addParam[i] = addParam[i].Add("PVBranch", sub.PVBranch);
addParam[i] = addParam[i].Add("ID", sub.ID);
if (sub.ID == 0)
addParam[i] = addParam[i].Add("Value", *(uint*)&ptr[i].Value);
else if (*(uint*)&ptr[i].Value != 0xFFFFFFFF)
addParam[i] = addParam[i].Add("Value", sub.Value);
}
addParam.WriteAfterAll(false, true, file, json);
}
public void Dispose()
{ if (s != null) s.D(); s = null; Header = default; }
public struct HeaderData
{
public long Count;
public long DataLength;
public long DataOffset;
public Sub[] Data;
public struct Sub
{
public float Time;
public int Flags;
public int Frame;
public int Pad0C;
public int PVBranch;
public int ID;
public float Value;
public int Pad1C;
}
}
}
}
+10 -3
View File
@@ -61,8 +61,7 @@ namespace KKdMainLib.DB
s = File.OpenWriter(file + ".bin", true);
s.W("#A3DA__________\n");
s.W("#" + DateTime.UtcNow.ToString("ddd MMM dd HH:mm:ss yyyy",
System.Globalization.CultureInfo.InvariantCulture) + "\n");
s.W("# date time was eliminated.\n");
if (Category != null)
{
@@ -75,18 +74,26 @@ namespace KKdMainLib.DB
if (UIDs != null)
{
int[] so = UIDs.Length.SW();
int max = -1;
for (i = 0; i < UIDs.Length; i++)
{
if (UIDs[so[i]].Category != null && UIDs[so[i]].Category != "")
s.W($"uid.{so[i]}.category=" + UIDs[so[i]].Category + "\n");
if (UIDs[so[i]].OrgUid != null)
s.W($"uid.{so[i]}.org_uid=" + UIDs[so[i]].OrgUid + "\n");
{
int orgUid = UIDs[so[i]].OrgUid.Value;
s.W($"uid.{so[i]}.org_uid=" + orgUid + "\n");
if (max < orgUid)
max = orgUid;
}
if (UIDs[so[i]].Size != null)
s.W($"uid.{so[i]}.size=" + UIDs[so[i]].Size + "\n");
if (UIDs[so[i]].Value != null && UIDs[so[i]].Value != "")
s.W($"uid.{so[i]}.value=" + UIDs[so[i]].Value + "\n");
}
s.W($"uid.length={UIDs.Length}\n");
if (max != -1)
s.W($"uid.max={max}\n");
}
s.C();
+64 -64
View File
@@ -32,43 +32,43 @@ namespace KKdMainLib
s.P = DEXOffset;
for (i = 0; i < Dex.Length; i++)
{
Dex[i].MainOffset = (int)s.RIX();
Dex[i].EyesOffset = (int)s.RIX();
Dex[i].FaceOffset = s.RIX();
Dex[i].FaceCLOffset = s.RIX();
}
s.P = DEXNameOffset;
for (i = 0; i < Dex.Length; i++)
Dex[i].NameOffset = (int)s.RIX();
Dex[i].NameOffset = s.RIX();
for (i = 0; i < Dex.Length; i++)
{
EXPElement element = new EXPElement();
Dex[i].Main = KKdList<EXPElement>.New;
s.P = Dex[i].MainOffset;
EXPData element = new EXPData();
Dex[i].Face = KKdList<EXPData>.New;
s.PI64 = Dex[i].FaceOffset;
while (true)
{
element.Frame = s.RF32();
element.Both = s.RU16();
element.Type = s.RU16();
element.ID = s.RU16();
element.Value = s.RF32();
element.Trans = s.RF32();
if (element.Frame == 999999 || element.Both == 0xFFFF) break;
Dex[i].Main.Add(element);
if (element.Type == 0xFFFF) break;
Dex[i].Face.Add(element);
}
Dex[i].Main.Capacity = Dex[i].Main.Count;
Dex[i].Face.Capacity = Dex[i].Face.Count;
Dex[i].Eyes = KKdList<EXPElement>.New;
s.P = Dex[i].EyesOffset;
Dex[i].FaceCL = KKdList<EXPData>.New;
s.PI64 = Dex[i].FaceCLOffset;
while(true)
{
element.Frame = s.RF32();
element.Both = s.RU16();
element.Type = s.RU16();
element.ID = s.RU16();
element.Value = s.RF32();
element.Trans = s.RF32();
if (element.Frame == 999999 || element.Both == 0xFFFF) break;
Dex[i].Eyes.Add(element);
if (element.Type == 0xFFFF) break;
Dex[i].FaceCL.Add(element);
}
Dex[i].Eyes.Capacity = Dex[i].Eyes.Count;
Dex[i].FaceCL.Capacity = Dex[i].FaceCL.Count;
Dex[i].Name = s.RSaO(Dex[i].NameOffset);
}
@@ -102,30 +102,30 @@ namespace KKdMainLib
for (i0 = 0; i0 < Dex.Length; i0++)
{
Dex[i0].MainOffset = s.P;
for (i1 = 0; i1 < Dex[i0].Main.Count; i1++)
Dex[i0].FaceOffset = s.P;
for (i1 = 0; i1 < Dex[i0].Face.Count; i1++)
{
s.W(Dex[i0].Main[i1].Frame);
s.W(Dex[i0].Main[i1].Both );
s.W(Dex[i0].Main[i1].ID );
s.W(Dex[i0].Main[i1].Value);
s.W(Dex[i0].Main[i1].Trans);
s.W(Dex[i0].Face[i1].Frame);
s.W(Dex[i0].Face[i1].Type );
s.W(Dex[i0].Face[i1].ID );
s.W(Dex[i0].Face[i1].Value);
s.W(Dex[i0].Face[i1].Trans);
}
s.W(999999f);
s.W(999999.0f);
s.W(0xFFFF);
s.W(0x0L);
s.A(0x20);
Dex[i0].EyesOffset = s.P;
for (i1 = 0; i1 < Dex[i0].Eyes.Count; i1++)
Dex[i0].FaceCLOffset = s.P;
for (i1 = 0; i1 < Dex[i0].FaceCL.Count; i1++)
{
s.W(Dex[i0].Eyes[i1].Frame);
s.W(Dex[i0].Eyes[i1].Both );
s.W(Dex[i0].Eyes[i1].ID );
s.W(Dex[i0].Eyes[i1].Value);
s.W(Dex[i0].Eyes[i1].Trans);
s.W(Dex[i0].FaceCL[i1].Frame);
s.W(Dex[i0].FaceCL[i1].Type );
s.W(Dex[i0].FaceCL[i1].ID );
s.W(Dex[i0].FaceCL[i1].Value);
s.W(Dex[i0].FaceCL[i1].Trans);
}
s.W(999999f);
s.W(999999.0f);
s.W(0xFFFF);
s.W(0x0L);
s.A(0x20);
@@ -140,8 +140,8 @@ namespace KKdMainLib
s.P = header.IsX ? 0x28 : 0x20;
for (i = 0; i < Dex.Length; i++)
{
s.WX(Dex[i].MainOffset);
s.WX(Dex[i].EyesOffset);
s.WX(Dex[i].FaceOffset);
s.WX(Dex[i].FaceCLOffset);
}
int namesPosition = s.P;
for (i = 0; i < Dex.Length; i++)
@@ -181,19 +181,19 @@ namespace KKdMainLib
Dex[i0] = new EXP { Name = dex[i0].RS("Name") };
MsgPack temp;
if ((temp = dex[i0]["Main", true]).NotNull)
if ((temp = dex[i0]["Face", true]).NotNull)
{
Dex[i0].Main = KKdList<EXPElement>.New;
Dex[i0].Main.Capacity = temp.Array.Length;
for (i1 = 0; i1 < Dex[i0].Main.Capacity; i1++)
Dex[i0].Main.Add(EXPElement.Read(temp[i1]));
Dex[i0].Face = KKdList<EXPData>.New;
Dex[i0].Face.Capacity = temp.Array.Length;
for (i1 = 0; i1 < Dex[i0].Face.Capacity; i1++)
Dex[i0].Face.Add(EXPData.Read(temp[i1]));
}
if ((temp = dex[i0]["Eyes", true]).NotNull)
if ((temp = dex[i0]["FaceCL", true]).NotNull)
{
Dex[i0].Eyes = KKdList<EXPElement>.New;
Dex[i0].Eyes.Capacity = temp.Array.Length;
for (i1 = 0; i1 < Dex[i0].Eyes.Capacity; i1++)
Dex[i0].Eyes.Add(EXPElement.Read(temp[i1]));
Dex[i0].FaceCL = KKdList<EXPData>.New;
Dex[i0].FaceCL.Capacity = temp.Array.Length;
for (i1 = 0; i1 < Dex[i0].FaceCL.Capacity; i1++)
Dex[i0].FaceCL.Add(EXPData.Read(temp[i1]));
}
temp.Dispose();
}
@@ -210,14 +210,14 @@ namespace KKdMainLib
for (i0 = 0; i0 < Dex.Length; i0++)
{
MsgPack exp = MsgPack.New.Add("Name", Dex[i0].Name);
MsgPack main = new MsgPack(Dex[i0].Main.Count, "Main");
for (i1 = 0; i1 < Dex[i0].Main.Count; i1++)
main[i1] = Dex[i0].Main[i1].Write();
MsgPack main = new MsgPack(Dex[i0].Face.Count, "Face");
for (i1 = 0; i1 < Dex[i0].Face.Count; i1++)
main[i1] = Dex[i0].Face[i1].Write();
exp.Add(main);
MsgPack eyes = new MsgPack(Dex[i0].Eyes.Count, "Eyes");
for (i1 = 0; i1 < Dex[i0].Eyes.Count; i1++)
eyes[i1] = Dex[i0].Eyes[i1].Write();
MsgPack eyes = new MsgPack(Dex[i0].FaceCL.Count, "FaceCL");
for (i1 = 0; i1 < Dex[i0].FaceCL.Count; i1++)
eyes[i1] = Dex[i0].FaceCL[i1].Write();
exp.Add(eyes);
dex[i0] = exp;
}
@@ -231,33 +231,33 @@ namespace KKdMainLib
public struct EXP
{
public int MainOffset;
public int EyesOffset;
public int NameOffset;
public long FaceOffset;
public long FaceCLOffset;
public long NameOffset;
public string Name;
public KKdList<EXPElement> Main;
public KKdList<EXPElement> Eyes;
public KKdList<EXPData> Face;
public KKdList<EXPData> FaceCL;
public override string ToString() => Name;
}
public struct EXPElement
public struct EXPData
{
public float Frame;
public ushort Both;
public ushort Type;
public ushort ID;
public float Value;
public float Trans;
public static EXPElement Read(MsgPack msg) =>
new EXPElement() { Frame = msg.RF32("F"), Both = msg.RU16("B"),
ID = msg.RU16("I"), Value = msg.RF32("V"),
Trans = msg.RF32("T"), };
public static EXPData Read(MsgPack msg) =>
new EXPData() { Frame = msg.RF32("Frame"), Type = msg.RU16("Type" ),
ID = msg.RU16("ID" ), Value = msg.RF32("Value"),
Trans = msg.RF32("Trans"), };
public MsgPack Write() =>
MsgPack.New.Add("F", Frame).Add("B", Both )
.Add("I", ID).Add("V", Value)
.Add("T", Trans);
MsgPack.New.Add("Frame", Frame).Add("Type" , Type )
.Add("ID" , ID ).Add("Value", Value)
.Add("Trans", Trans);
}
}
}
+60 -4
View File
@@ -10,13 +10,13 @@ namespace KKdMainLib
{
private static readonly byte[] Key = "file access deny".ToASCII();
public static void Decrypt(this string file)
public static void Decrypt(string file)
{
int streamLength, fileLength;
byte[] encrypted, decrypted;
using (Stream _IO = File.OpenReader(file))
{
if (_IO.RI64() != 0x454C494641564944) return;
if (_IO.RU64() != 0x454C494641564944u) return;
streamLength = _IO.RI32();
fileLength = _IO.RI32();
@@ -37,7 +37,7 @@ namespace KKdMainLib
_IO.W(decrypted, fileLength < streamLength ? fileLength : streamLength);
}
public static void Encrypt(this string file)
public static void Encrypt(string file)
{
byte[] data;
using (Stream _IO = File.OpenReader(file))
@@ -60,11 +60,67 @@ namespace KKdMainLib
using (Stream _IO = File.OpenWriter(file, dataAlign.Length))
{
_IO.W(0x454C494641564944);
_IO.W(0x454C494641564944u);
_IO.W(fileLength);
_IO.W(fileLengthOrigin);
_IO.W(encrypted);
}
}
public static byte[] Decrypt(byte[] data)
{
int streamLength, fileLength;
byte[] encrypted, decrypted;
using (Stream _IO = File.OpenReader(data))
{
if (_IO.RU64() != 0x454C494641564944u) return data;
streamLength = _IO.RI32();
fileLength = _IO.RI32();
encrypted = _IO.RBy(streamLength);
decrypted = new byte[streamLength];
}
using (AesManaged crypto = new AesManaged())
{
crypto.Key = Key; crypto.IV = new byte[16];
crypto.Mode = CipherMode.ECB; crypto.Padding = PaddingMode.Zeros;
using CryptoStream cryptoData = new CryptoStream(new MSIO.MemoryStream(encrypted),
crypto.CreateDecryptor(crypto.Key, crypto.IV), CryptoStreamMode.Read);
cryptoData.Read(decrypted, 0, streamLength);
}
data = new byte[fileLength];
Array.Copy(decrypted, data, fileLength < streamLength ? fileLength : streamLength);
return data;
}
public static byte[] Encrypt(byte[] data)
{
int fileLengthOrigin = data.Length;
int fileLength = fileLengthOrigin.A(16);
byte[] dataAlign = new byte[fileLength];
Array.Copy(data, dataAlign, data.Length);
data = null;
byte[] encrypted = new byte[fileLength];
using (AesManaged crypto = new AesManaged())
{
crypto.Key = Key; crypto.IV = new byte[16];
crypto.Mode = CipherMode.ECB; crypto.Padding = PaddingMode.Zeros;
using CryptoStream cryptoData = new CryptoStream(new MSIO.MemoryStream(dataAlign),
crypto.CreateEncryptor(crypto.Key, crypto.IV), CryptoStreamMode.Read);
cryptoData.Read(encrypted, 0, fileLength);
}
using (Stream _IO = File.OpenWriter())
{
_IO.W(0x454C494641564944u);
_IO.W(fileLength);
_IO.W(fileLengthOrigin);
_IO.W(encrypted);
data = _IO.ToArray();
}
return data;
}
}
}
+3 -3
View File
@@ -83,15 +83,15 @@ namespace KKdMainLib
return s.ToArray(true);
}
public void DBWriter(string file, uint num2)
public void DBWriter(string file, uint timestamp)
{
if (!Success) return;
byte[] data = DBWriter(file);
if (data == null) return;
ushort num = DCC.CalculateChecksum(data);
File.WriteAllBytes(file + "_" + num + "_" + num2 + ".dat", data);
ushort hash = data.HashCRC16_CCITT();
File.WriteAllBytes(file + "_" + hash + "_" + timestamp + ".dat", data);
}
public void MsgPackReader(string file, bool json)
+68 -8
View File
@@ -100,13 +100,14 @@ namespace KKdMainLib
public static Struct RSt(this byte[] data)
{
if (data == null || data.Length < 1) return default;
data = DIVAFILE.Decrypt(data);
Struct @struct;
using (Stream stream = File.OpenReader(data))
@struct = stream.RSt(stream.ReadHeader(false));
return @struct;
}
public static Struct RSt(this Stream stream, Header header)
private static Struct RSt(this Stream stream, Header header)
{
uint l = header.UseSectionSize ? header.SectionSize : header.DataSize;
Struct @struct = new Struct { Header = header, DataOffset =
@@ -163,7 +164,7 @@ namespace KKdMainLib
if (@struct.HasSubStructs)
for (int i = 0; i < @struct.SubStructs.Length; i++)
stream.W(@struct.SubStructs[i], depth + 1, shiftX, useDepth);
if (@struct.HasPOF || @struct.HasENRS || @struct.HasSubStructs)
if (@struct.HasPOF || @struct.HasENRS || @struct.HasSubStructs)
stream.WEOFC(depth + 1);
}
}
@@ -249,25 +250,38 @@ namespace KKdMainLib
public static class HashExt
{
public static ulong HashFNV1a64(this byte[] array, int length) // 0x1403B04D0 in SBZV_7.10; FNV 1a 64-bit
public static uint HashFNV1a64(this byte[] array) =>
array.HashMurmurHash(array.Length);
// FNV 1a 64-bit Modified
// 0x1403B04D0 in SBZV_7.10
public static ulong HashFNV1a64m(this byte[] array, int length)
{
int i = 0;
ulong hash = 0xCBF29CE484222325;
while (i < length)
{ hash = 0x100000001B3 * (hash ^ (ulong)array[i]); i++; }
return (hash >> 32) ^ hash;
return (hash >> 32) ^ hash; // Actual Modification
}
public static uint HashMurmurHash(this byte[] array, int length, uint seed = 0,
bool alreadyUpper = false, bool bigEndian = false) // 0x814D7A9C in PCSB00554; MurmurHash
public static uint HashMurmurHash(this byte[] array, uint salt = 0,
bool alreadyUpper = false, bool bigEndian = false) =>
array.HashMurmurHash(array.Length, salt, alreadyUpper, bigEndian);
// MurmurHash
// 0x814D7A9C in PCSB00554
// 0x8134C304 in PCSB01007
// 0x0069CEA4 in NPEB02013
public static uint HashMurmurHash(this byte[] array, int length, uint salt = 0,
bool alreadyUpper = false, bool bigEndian = false)
{
uint a, b, hash;
int i;
const uint m = 0x7FD652AD;
const int r = 16;
hash = seed + 0xDEADBEEF;
hash = salt + 0xDEADBEEF;
if (alreadyUpper)
{
if (bigEndian)
@@ -353,5 +367,51 @@ namespace KKdMainLib
hash ^= hash >> 17;
return hash;
}
private static readonly ushort[] CRC16_CCITT_Table = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0,
};
// CRC16-CCITT
// 0x140011A90 in SBZV_7.10
public static ushort HashCRC16_CCITT(this byte[] data, int offset = 0, ushort seed = 0xFFFF)
{
int length = data.Length;
ushort hash = seed;
for (int i = offset; i < length; i++)
hash = (ushort)(CRC16_CCITT_Table[(hash >> 8) ^ data[i]] ^ (hash << 8));
return hash;
}
}
}
+1 -1
View File
@@ -98,7 +98,7 @@ namespace KKdMainLib.F2
s.W(blt.Brightpass.Z);
s.W(blt.Range );
}
e.Array = new ENRS.ENRSEntry[2];
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x01, 0x10, 0x01);
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
+1 -1
View File
@@ -99,7 +99,7 @@ namespace KKdMainLib.F2
s.W(cct.Gamma.Z );
s.W(cct.Contrast );
}
e.Array = new ENRS.ENRSEntry[2];
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x01, 0x10, 0x01);
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
+1 -1
View File
@@ -91,7 +91,7 @@ namespace KKdMainLib.F2
s.W(dft.Ratio );
s.W(dft.Quality );
}
e.Array = new ENRS.ENRSEntry[2];
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x01, 0x10, 0x01);
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
+1 -1
View File
@@ -895,7 +895,7 @@ namespace KKdMainLib.F2
ToneCurve = 0b00000001000000000,
}
}
public struct LITX
{
public int C;
+4 -4
View File
@@ -4,14 +4,14 @@
<Authors>korenkonder</Authors>
<Company></Company>
<Configuration></Configuration>
<Copyright>korenkonder (C) 2018-2021</Copyright>
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files</Description>
<FileVersion>0.4.10.2</FileVersion>
<Copyright>korenkonder (C) 2018-2022</Copyright>
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/XHD/FT/VRFL/M39 files</Description>
<FileVersion>0.4.10.12</FileVersion>
<PackageId>KKdMainLib</PackageId>
<Product>KKdMainLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdMainLib</Title>
<Version>0.4.10.2</Version>
<Version>0.4.10.12</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
+800 -472
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
-1
View File
@@ -40,7 +40,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="classes\A3D.cs" />
<Compile Include="classes\ADP.cs" />
<Compile Include="classes\AET.cs" />
<Compile Include="classes\BLT.cs" />
<Compile Include="classes\CCT.cs" />
+22 -24
View File
@@ -61,7 +61,7 @@ namespace PD_Tool
ConsoleDesign("5. DB_Tools");
ConsoleDesign("6. AC/DT/F/AFT Converting Tools");
ConsoleDesign("7. F/F2/FT Converting Tools");
ConsoleDesign("8. X/XHD Converting Tools");
ConsoleDesign("8. X/XHD/VRFL Converting Tools");
ConsoleDesign("9. FT/M39 Converting Tools");
ConsoleDesign(json ? "A. MsgPack to JSON" : "A. JSON to MsgPack");
ConsoleDesign(false);
@@ -179,7 +179,7 @@ namespace PD_Tool
if (choose.Length == 1)
{
Console.Clear();
Console.Title = "X/XHD Converting Tools";
Console.Title = "X/XHD/VRFL Converting Tools";
ConsoleDesign(true);
ConsoleDesign(" Choose converter:");
ConsoleDesign(false);
@@ -218,14 +218,13 @@ namespace PD_Tool
ConsoleDesign(" Choose converter:");
ConsoleDesign(false);
ConsoleDesign("1. A3DA" );
ConsoleDesign("2. AddParam");
ConsoleDesign("3. AET" );
ConsoleDesign("4. DEX" );
ConsoleDesign("5. DIVA" );
ConsoleDesign("6. MotHead" );
ConsoleDesign("7. MOT" );
ConsoleDesign("8. STR" );
ConsoleDesign("9. Table" );
ConsoleDesign("2. AET" );
ConsoleDesign("3. DEX" );
ConsoleDesign("4. DIVA" );
ConsoleDesign("5. MotHead" );
ConsoleDesign("6. MOT" );
ConsoleDesign("7. STR" );
ConsoleDesign("8. Table" );
ConsoleDesign(false);
ConsoleDesign("R. Return to Main Menu");
ConsoleDesign(false);
@@ -235,14 +234,13 @@ namespace PD_Tool
}
else localChoose = choose[1].ToString();
if (localChoose == "1") A3D.Processor(json);
else if (localChoose == "2") ADP.Processor(json);
else if (localChoose == "3") AET.Processor(json);
else if (localChoose == "4") DEX.Processor(json);
else if (localChoose == "5") DIV.Processor();
else if (localChoose == "6") MHD.Processor(json);
else if (localChoose == "7") MOT.Processor(json);
else if (localChoose == "8") STR.Processor(json);
else if (localChoose == "9") TBL.Processor(json);
else if (localChoose == "2") AET.Processor(json);
else if (localChoose == "3") DEX.Processor(json);
else if (localChoose == "4") DIV.Processor();
else if (localChoose == "5") MHD.Processor(json);
else if (localChoose == "6") MOT.Processor(json);
else if (localChoose == "7") STR.Processor(json);
else if (localChoose == "8") TBL.Processor(json);
else choose = localChoose;
}
else if (choose[0] == 'A')
@@ -312,8 +310,6 @@ namespace PD_Tool
string Filter = GetArgs("All", false, "*");
if (filetype == "a3da") Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") +
GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + json + mp;
else if (filetype == "adp" ) Filter = GetArgs("ADP" , "adp", "json", "mp") +
GetArgs("ADP", true, "adp" ) + json + mp;
else if (filetype == "bin" ) Filter = GetArgs("BIN" , "bin", "json", "mp") +
bin + json + mp;
else if (filetype == "blt" ) Filter = GetArgs("BLT" , "blt", "json", "mp") +
@@ -338,6 +334,8 @@ namespace PD_Tool
else if (filetype == "json") Filter = GetArgs("JSON", "json");
else if (filetype == "igb" ) Filter = GetArgs("IGB", "igb");
else if (filetype == "mgftxt") Filter = GetArgs("MGF2AFT txt", "txt");
else if (filetype == "mhd" ) Filter = GetArgs("MotHead", "mhd", "bin", "json", "mp") +
GetArgs("MotHead", true, "mhd") + bin + json + mp;
else if (filetype == "mp" ) Filter = GetArgs("MessagePack", "mp");
else if (filetype == "lit") Filter = GetArgs("LIT" , "lit", "json", "mp") +
GetArgs("LIT", true, "lit") + json + mp;
@@ -350,15 +348,15 @@ namespace PD_Tool
else if (filetype == "vag" ) Filter = GetArgs("VAG" , "vag", "wav") +
GetArgs("VAG", true, "vag") + wav;
using OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = Application.StartupPath,
Filter = Filter, Multiselect = true, Title = "Choose file(s) to open:" };
using OpenFileDialog ofd = new OpenFileDialog { Filter = Filter,
Multiselect = true, Title = "Choose file(s) to open:" };
if (ofd.ShowDialog() == DialogResult.OK) FileNames = ofd.FileNames;
}
else if (code == 2)
{
string Return = "";
using (OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = Application.StartupPath,
ValidateNames = false, CheckFileExists = false, Filter = " | ", CheckPathExists = true,
using (OpenFileDialog ofd = new OpenFileDialog { ValidateNames = false,
CheckFileExists = false, Filter = " | ", CheckPathExists = true,
Title = "Choose any file in folder:", FileName = "Folder Selection." })
if (ofd.ShowDialog() == DialogResult.OK) Return = Path.GetDirectoryName(ofd.FileName);
return Return;
+4 -4
View File
@@ -2,14 +2,14 @@ using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("PD_Tool")]
[assembly: AssemblyDescription("A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files")]
[assembly: AssemblyDescription("A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/XHD/FT/VRFL/M39 files")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PD_Tool")]
[assembly: AssemblyCopyright("korenkonder (C) 2017-2021")]
[assembly: AssemblyCopyright("korenkonder (C) 2017-2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
[assembly: AssemblyVersion("0.4.10.2")]
[assembly: AssemblyFileVersion("0.4.10.2")]
[assembly: AssemblyVersion("0.4.10.12")]
[assembly: AssemblyFileVersion("0.4.10.12")]
+31 -17
View File
@@ -24,6 +24,9 @@ namespace PD_Tool
Program.ConsoleDesign(true);
Program.ConsoleDesign(" Choose type of format to export:");
Program.ConsoleDesign(false);
Program.ConsoleDesign(" Tip: A3DC Opt - A3DC Optimization");
Program.ConsoleDesign(" WARNING! CHECK RESULTS AFTER CONVERTING ");
Program.ConsoleDesign(false);
Program.ConsoleDesign("1. A3DA [DT/AC/F]");
Program.ConsoleDesign("2. A3DC [DT/AC/F]");
Program.ConsoleDesign("3. A3DA [AFT/FT/M39]");
@@ -31,23 +34,32 @@ namespace PD_Tool
Program.ConsoleDesign("5. A3DC [F2]");
Program.ConsoleDesign("6. A3DC [MGF]");
Program.ConsoleDesign("7. A3DC [X]");
Program.ConsoleDesign("8. A3DC [XHD]");
Program.ConsoleDesign("8. A3DC [XHD/VRFL]");
if (!mp) Program.ConsoleDesign($"9. {(json ? "JSON" : "MsgPack")}");
Program.ConsoleDesign(false);
Program.ConsoleDesign("X[Y] - X: option; Y: rounding in text (def. 9)");
Program.ConsoleDesign(false);
Program.ConsoleDesign(true);
Console.WriteLine();
choose = Console.ReadLine().ToUpper();
if (choose == "1") format = Format.DT ;
else if (choose == "2") format = Format.F ;
else if (choose == "3") format = Format.AFT;
else if (choose == "4") format = Format.AFT;
else if (choose == "5") format = Format.F2;
else if (choose == "6") format = Format.MGF;
else if (choose == "7") format = Format.X ;
else if (choose == "8") format = Format.XHD;
else if (choose == "9") format = Format.NULL;
if (choose == null || choose.Length < 1)
return;
else if (choose[0] == '1') format = Format.DT ;
else if (choose[0] == '2') format = Format.F ;
else if (choose[0] == '3') format = Format.AFT;
else if (choose[0] == '4') format = Format.AFT;
else if (choose[0] == '5') format = Format.F2 ;
else if (choose[0] == '6') format = Format.MGF;
else if (choose[0] == '7') format = Format.X ;
else if (choose[0] == '8') format = Format.XHD;
else if (choose[0] == '9') format = Format.NULL;
else return;
if (int.TryParse(choose.Substring(1), out int rounding))
KKdA3DA.Rounding = rounding;
else
KKdA3DA.Rounding = 9;
int state;
string filepath, ext;
KKdA3DA a3da;
@@ -66,12 +78,12 @@ namespace PD_Tool
{
state = a3da.A3DAReader(filepath);
if (state == 1)
if (choose == "9") a3da.MsgPackWriter(filepath, json);
if (choose[0] == '9') a3da.MsgPackWriter(filepath, json);
else
{
a3da.Head.Format = format;
File.WriteAllBytes(filepath + ".a3da", (choose == "1" ||
choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter());
File.WriteAllBytes(filepath + ".a3da", (choose[0] == '1' ||
choose[0] == '3') ? a3da.A3DAWriter() : a3da.A3DCWriter());
}
}
else if (ext == ".mp" || ext == ".json")
@@ -80,8 +92,8 @@ namespace PD_Tool
a3da.MsgPackReader(filepath, ext == ".json");
a3da.Head.Format = format;
File.WriteAllBytes(filepath + ".a3da", (choose == "1" ||
choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter());
File.WriteAllBytes(filepath + ".a3da", (choose[0] == '1' ||
choose[0] == '3') ? a3da.A3DAWriter() : a3da.A3DCWriter());
}
}
}
@@ -115,7 +127,8 @@ namespace PD_Tool
{
KKdFARC.FARCFile file = farc.Files[i];
a3da.Head.Format = format;
file.Data = (choose == "1"|| choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter();
file.Data = (choose[0] == '1'|| choose[0] == '4')
? a3da.A3DAWriter() : a3da.A3DCWriter();
farc.Files[i] = file;
}
}
@@ -164,7 +177,8 @@ namespace PD_Tool
KKdFARC.FARCFile file = default;
file.Name = list[i];
a3daArray[i].Head.Format = format;
file.Data = (choose == "1" || choose == "3") ? a3daArray[i].A3DAWriter() : a3daArray[i].A3DCWriter();
file.Data = (choose[0] == '1'|| choose[0] == '4')
? a3daArray[i].A3DAWriter() : a3daArray[i].A3DCWriter();
farc.Files.Add(file);
}
farc.Save();
-37
View File
@@ -1,37 +0,0 @@
using System;
using KKdMainLib;
using KKdMainLib.IO;
namespace PD_Tool
{
public class ADP
{
public static void Processor(bool json)
{
Console.Title = "Add Param Converter";
Program.Choose(1, "adp", out string[] fileNames);
if (fileNames.Length < 1) return;
string filepath, ext;
AddParam adp;
foreach (string file in fileNames)
using (adp = new AddParam())
{
filepath = Path.RemoveExtension(file);
ext = Path.GetExtension(file).ToLower();
Console.Title = "Add Param Converter: " + Path.GetFileNameWithoutExtension(file);
if (ext == ".adp")
{
adp.AddParamReader(filepath);
adp. MsgPackWriter(filepath, json);
}
else if (ext == ".mp" || ext == ".json")
{
adp. MsgPackReader(filepath, ext == ".json");
adp.AddParamWriter(filepath);
}
}
}
}
}
+2 -2
View File
@@ -16,7 +16,7 @@ namespace PD_Tool
if (file.EndsWith(".mp" )) { mp = false; break; }
else if (file.EndsWith(".json")) { mp = false; break; }
uint num2 = (uint)((DateTime.Now.Ticks - 621355968000000000) / 10000000);
uint timestamp = (uint)((DateTime.Now.Ticks - 621355968000000000) / 10000000);
string[] file_split;
string filepath, ext;
KKdMainLib.DataBank db;
@@ -48,7 +48,7 @@ namespace PD_Tool
{
Console.Title = "DataBank Converter: " + filename;
db.MsgPackReader(filepath, json);
db. DBWriter(filepath, num2);
db. DBWriter(filepath, timestamp);
}
}
}
+2 -2
View File
@@ -13,7 +13,7 @@ namespace PD_Tool
if (head != 0x454C494641564944) return;
System.Console.Title = "DIVAFILE Decrypt: " + Path.GetFileName(file);
file.Decrypt();
KKdMainLib.DIVAFILE.Decrypt(file);
}
public static void Encrypt(string file)
@@ -24,7 +24,7 @@ namespace PD_Tool
if (head == 0x454C494641564944) return;
System.Console.Title = "DIVAFILE Encrypt: " + Path.GetFileName(file);
file.Encrypt();
KKdMainLib.DIVAFILE.Encrypt(file);
}
}
}
+3 -3
View File
@@ -9,7 +9,7 @@ namespace PD_Tool
public static void Processor(bool json)
{
Console.Title = "MotHead Converter";
Program.Choose(1, "bin", out string[] fileNames);
Program.Choose(1, "mhd", out string[] fileNames);
if (fileNames.Length < 1) return;
string filepath, ext;
@@ -21,9 +21,9 @@ namespace PD_Tool
ext = Path.GetExtension(file).ToLower();
Console.Title = "MotHead Converter: " + Path.GetFileNameWithoutExtension(file);
if (ext == ".bin")
if (ext == ".bin" || ext == ".mhd")
{
mhd.MotHeadReader(filepath);
mhd.MotHeadReader(filepath, ext);
mhd.MsgPackWriter(filepath, json);
}
else if (ext == ".mp" || ext == ".json")