Release v0.4.8.1
A3DA, AET, DEX, DIVA, FARC, STR, VAG
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
.vs
|
||||
build
|
||||
packages
|
||||
KKdBaseLib/bin
|
||||
KKdBaseLib/obj
|
||||
KKdMainLib/bin
|
||||
|
||||
+9
-4
@@ -101,7 +101,7 @@
|
||||
public Key Density;
|
||||
public Vector4<Key> Diffuse;
|
||||
}
|
||||
|
||||
|
||||
public enum KeyType : int
|
||||
{
|
||||
Null = 0,
|
||||
@@ -110,7 +110,7 @@
|
||||
Hermite = 3,
|
||||
Hold = 4,
|
||||
}
|
||||
|
||||
|
||||
public enum EPType : int
|
||||
{
|
||||
EP_1 = 1,
|
||||
@@ -174,8 +174,8 @@
|
||||
key.Type = k.Type.Value;
|
||||
key.Length = k.Length;
|
||||
key.Keys = k.Keys;
|
||||
key.FDBSaE = k.Keys[k.Length - 1].F - k.Keys[0].F;
|
||||
key.VDBSaE = k.Keys[k.Length - 1].V - k.Keys[0].V;
|
||||
key.FrameDelta = k.Keys[k.Length - 1].F - k.Keys[0].F;
|
||||
key.ValueDelta = k.Keys[k.Length - 1].V - k.Keys[0].V;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -186,6 +186,11 @@
|
||||
key.Type = KeyType.Value;
|
||||
key.Keys[0].V = k.Value ?? 0;
|
||||
}
|
||||
else if (k.Type.HasValue && k.Value.HasValue)
|
||||
{
|
||||
key.Type = k.Type.Value;
|
||||
key.Keys[0].V = k.Value.Value;
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace KKdBaseLib
|
||||
public float MaxFrames;
|
||||
public EPType EPTypePre;
|
||||
public EPType EPTypePost;
|
||||
public float FDBSaE; //Frame Difference Between Start and End
|
||||
public float VDBSaE; //Value Difference Between Start and End
|
||||
public float FrameDelta;
|
||||
public float ValueDelta;
|
||||
public int Unk1C;
|
||||
public int Unk20;
|
||||
public int Unk24;
|
||||
|
||||
+7
-5
@@ -28,7 +28,7 @@
|
||||
|
||||
public int O;
|
||||
public AetLayer[] E;
|
||||
|
||||
|
||||
public override string ToString() => "Count: " + C;
|
||||
}
|
||||
|
||||
@@ -45,12 +45,14 @@
|
||||
public AetLayerFlags Flags;
|
||||
public byte Pad;
|
||||
public AetLayerType Type;
|
||||
public int DataID;
|
||||
public int DataOffset;
|
||||
public int ParentLayer;
|
||||
public CountPointer<AetMarker> Marker;
|
||||
public Pointer<AnimationData> Data;
|
||||
public Pointer<AudioData> ExtraData;
|
||||
|
||||
public int DataID;
|
||||
|
||||
public enum AetLayerFlags : ushort
|
||||
{
|
||||
Visible = 0b0000000000000001,
|
||||
@@ -80,10 +82,10 @@
|
||||
}
|
||||
|
||||
public override string ToString() => $"ID: {ID}; Name: {Name.V}; Type: {Type}" +
|
||||
( DataID > -1 ? $"; Data ID: " + $"{ DataID}" : "") +
|
||||
( DataID > -1 ? $"; " + $"Data ID: { DataID}" : "") +
|
||||
(ParentLayer > -1 ? $"; Parent Object ID: {ParentLayer}" : "");
|
||||
}
|
||||
|
||||
|
||||
public struct AetMarker
|
||||
{
|
||||
public float Frame;
|
||||
@@ -114,7 +116,7 @@
|
||||
SrcAlphaOneMinusSrcColor = 7,
|
||||
Transparent = 8,
|
||||
}
|
||||
|
||||
|
||||
public struct Perspective
|
||||
{
|
||||
public CountPointer<KFT2> Unk1 ;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace KKdBaseLib
|
||||
public static float Pow (this float x , float y ) => (float)Math.Pow (x , y );
|
||||
public static float Round(this float val , int d ) => (float)Math.Round(val , d );
|
||||
|
||||
public static void FC( ref double Value) =>
|
||||
public static void FC( ref double Value) =>
|
||||
Value = Value % 1 >= 0.5 ? (long)(Value + 0.5) : (long)Value;
|
||||
|
||||
public static long FC(this double Value) =>
|
||||
@@ -89,7 +89,7 @@ namespace KKdBaseLib
|
||||
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
|
||||
|
||||
private static byte[] buf = new byte[8];
|
||||
|
||||
|
||||
public static byte[] E(this byte[] le, byte len)
|
||||
{ for (byte i = 0; i < len; i++) buf[i] = le[i];
|
||||
for (byte i = 0; i < len; i++) le[len - i - 1] = buf[i]; return le; }
|
||||
@@ -206,48 +206,6 @@ namespace KKdBaseLib
|
||||
public static string ToString(this int d, bool BE) =>
|
||||
BitConverter.GetBytes(d.E(BE)).ToASCII();
|
||||
|
||||
public static sbyte* GetPtr(this sbyte[] array)
|
||||
{ fixed ( sbyte* tempPtr = array) return tempPtr; }
|
||||
public static byte* GetPtr(this byte[] array)
|
||||
{ fixed ( byte* tempPtr = array) return tempPtr; }
|
||||
public static short* GetPtr(this short[] array)
|
||||
{ fixed ( short* tempPtr = array) return tempPtr; }
|
||||
public static ushort* GetPtr(this ushort[] array)
|
||||
{ fixed (ushort* tempPtr = array) return tempPtr; }
|
||||
public static int* GetPtr(this int[] array)
|
||||
{ fixed ( int* tempPtr = array) return tempPtr; }
|
||||
public static uint* GetPtr(this uint[] array)
|
||||
{ fixed ( uint* tempPtr = array) return tempPtr; }
|
||||
public static long* GetPtr(this long[] array)
|
||||
{ fixed ( long* tempPtr = array) return tempPtr; }
|
||||
public static ulong* GetPtr(this ulong[] array)
|
||||
{ fixed ( ulong* tempPtr = array) return tempPtr; }
|
||||
public static float* GetPtr(this float[] array)
|
||||
{ fixed ( float* tempPtr = array) return tempPtr; }
|
||||
public static double* GetPtr(this double[] array)
|
||||
{ fixed (double* tempPtr = array) return tempPtr; }
|
||||
|
||||
public static IntPtr GetIntPtr(this sbyte[] array)
|
||||
{ fixed ( sbyte* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this byte[] array)
|
||||
{ fixed ( byte* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this short[] array)
|
||||
{ fixed ( short* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this ushort[] array)
|
||||
{ fixed (ushort* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this int[] array)
|
||||
{ fixed ( int* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this uint[] array)
|
||||
{ fixed ( uint* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this long[] array)
|
||||
{ fixed ( long* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this ulong[] array)
|
||||
{ fixed ( ulong* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this float[] array)
|
||||
{ fixed ( float* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
public static IntPtr GetIntPtr(this double[] array)
|
||||
{ fixed (double* tempPtr = array) return (IntPtr)tempPtr; }
|
||||
|
||||
public static string ToS(this object d)
|
||||
{
|
||||
if (d == null ) return "Null";
|
||||
@@ -286,7 +244,7 @@ namespace KKdBaseLib
|
||||
Math.Round(d, 15).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
public static string ToS(this double? d, int round) => (d ?? default).ToS(round);
|
||||
public static string ToS(this double? d) => (d ?? default).ToString();
|
||||
public static string ToS(this double d, int round) =>
|
||||
public static string ToS(this double d, int round) =>
|
||||
Math.Round(d, round).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
public static string ToS(this double d) =>
|
||||
Math.Round(d, 15).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
|
||||
+91
-89
@@ -1,88 +1,90 @@
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct ENRSList : INull
|
||||
public struct ENRS : INull
|
||||
{
|
||||
public KKdList<ENRS> List;
|
||||
public ENRSEntry[] Array;
|
||||
|
||||
public int Length => length();
|
||||
|
||||
public bool IsNull => List. IsNull;
|
||||
public bool NotNull => List.NotNull;
|
||||
public bool IsNull => Array == null;
|
||||
public bool NotNull => Array != null;
|
||||
|
||||
public unsafe static ENRSList Read(byte[] data)
|
||||
public unsafe void Read(byte[] data)
|
||||
{
|
||||
if (data == null || data.Length < 0x10) return default;
|
||||
byte* ptr = data.GetPtr();
|
||||
int i, i0;
|
||||
int ENRSCount = ((int*)ptr)[1];
|
||||
KKdList<ENRS> list = KKdList<ENRS>.New;
|
||||
ptr += 0x10;
|
||||
ENRS enrs;
|
||||
ENRS.SubENRS sub;
|
||||
|
||||
for (i = 0; i < ENRSCount; i++)
|
||||
if (data == null || data.Length < 0x10) return;
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
enrs = default;
|
||||
enrs.Offset = ReadENRSValue(ref ptr);
|
||||
enrs.Count = ReadENRSValue(ref ptr);
|
||||
enrs.Size = ReadENRSValue(ref ptr);
|
||||
enrs.Repeat = ReadENRSValue(ref ptr);
|
||||
int i, i0;
|
||||
int ENRSCount = ((int*)ptr)[1];
|
||||
ENRSEntry enrsEntry;
|
||||
ENRSEntry.SubENRSEntry sub;
|
||||
Array = new ENRSEntry[ENRSCount];
|
||||
|
||||
if (i > 0) enrs.Offset += list[list.Count - 1].Offset;
|
||||
|
||||
if (enrs.Repeat < 1) { enrs.Sub = null; list.Add(enrs); continue; }
|
||||
|
||||
enrs.Sub = new KKdList<ENRS.SubENRS> { Capacity = enrs.Count };
|
||||
for (i0 = 0; i0 < enrs.Count; i0++)
|
||||
byte* localPtr = ptr + 0x10;
|
||||
for (i = 0; i < ENRSCount; i++)
|
||||
{
|
||||
sub = default;
|
||||
sub.Skip = ReadENRSValue(ref ptr, out sub.Type);
|
||||
sub.Reverse = ReadENRSValue(ref ptr);
|
||||
if (i0 > 0) sub.Skip += enrs.Sub[i0 - 1].SizeSkip;
|
||||
enrs.Sub.Add(sub);
|
||||
enrsEntry = default;
|
||||
enrsEntry.Offset = ReadENRSValue(ref localPtr);
|
||||
enrsEntry.Count = ReadENRSValue(ref localPtr);
|
||||
enrsEntry.Size = ReadENRSValue(ref localPtr);
|
||||
enrsEntry.Repeat = ReadENRSValue(ref localPtr);
|
||||
|
||||
if (enrs.Sub[i0].Type == ENRS.Type.Invalid) return default;
|
||||
if (i > 0) enrsEntry.Offset += Array[i - 1].Offset;
|
||||
|
||||
if (enrsEntry.Repeat < 1) { enrsEntry.Sub = null; Array[i] = enrsEntry; continue; }
|
||||
|
||||
enrsEntry.Sub = new ENRSEntry.SubENRSEntry[enrsEntry.Count];
|
||||
for (i0 = 0; i0 < enrsEntry.Count; i0++)
|
||||
{
|
||||
sub = default;
|
||||
sub.Skip = ReadENRSValue(ref localPtr, out sub.Type);
|
||||
sub.Reverse = ReadENRSValue(ref localPtr);
|
||||
if (i0 > 0) sub.Skip += enrsEntry.Sub[i0 - 1].SizeSkip;
|
||||
enrsEntry.Sub[i0] = sub;
|
||||
|
||||
if (enrsEntry.Sub[i0].Type == ENRSEntry.Type.Invalid) { Array = null; return; }
|
||||
}
|
||||
Array[i] = enrsEntry;
|
||||
}
|
||||
list.Add(enrs);
|
||||
}
|
||||
return new ENRSList { List = list };
|
||||
}
|
||||
|
||||
public unsafe static byte[] Write(ENRSList enrsList)
|
||||
public unsafe byte[] Write()
|
||||
{
|
||||
int i, i0;
|
||||
byte[] data;
|
||||
byte* ptr;
|
||||
|
||||
KKdList<ENRS> list = (System.Collections.Generic.List<ENRS>)enrsList.List;
|
||||
if (enrsList.IsNull || enrsList.List.Count < 1) return new byte[0x20];
|
||||
if (IsNull || Array.Length < 1) return new byte[0x20];
|
||||
|
||||
data = new byte[enrsList.Length];
|
||||
ptr = data.GetPtr();
|
||||
((int*)ptr)[1] = enrsList.List.Count;
|
||||
ptr += 0x10;
|
||||
|
||||
for (i = 0; i < enrsList.List.Count; i++)
|
||||
data = new byte[Length];
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
ENRS enrs = enrsList.List[i];
|
||||
WriteENRSValue(ref ptr, i > 0 ? enrs.Offset - enrsList.List[i - 1].Offset : enrs.Offset);
|
||||
WriteENRSValue(ref ptr, enrs.Count );
|
||||
WriteENRSValue(ref ptr, enrs.Size );
|
||||
WriteENRSValue(ref ptr, enrs.Repeat);
|
||||
((int*)ptr)[1] = Array.Length;
|
||||
|
||||
if (enrs.Repeat < 1) continue;
|
||||
|
||||
for (i0 = 0; i0 < enrs.Count; i0++)
|
||||
byte* localPtr = ptr + 0x10;
|
||||
for (i = 0; i < Array.Length; i++)
|
||||
{
|
||||
if (enrs.Sub[i0].Type < ENRS.Type. WORD ||
|
||||
enrs.Sub[i0].Type > ENRS.Type.QWORD)
|
||||
return data;
|
||||
ENRSEntry enrsEntry = Array[i];
|
||||
WriteENRSValue(ref localPtr, i > 0 ? enrsEntry.Offset -
|
||||
Array[i - 1].Offset : enrsEntry.Offset);
|
||||
WriteENRSValue(ref localPtr, enrsEntry.Count > enrsEntry.Sub.Length ?
|
||||
enrsEntry.Sub.Length : enrsEntry.Count);
|
||||
WriteENRSValue(ref localPtr, enrsEntry.Size );
|
||||
WriteENRSValue(ref localPtr, enrsEntry.Repeat);
|
||||
|
||||
WriteENRSValue(ref ptr, i0 > 0 ? enrs.Sub[i0].Skip -
|
||||
enrs.Sub[i0 - 1].SizeSkip : enrs.Sub[i0].Skip, enrs.Sub[i0].Type);
|
||||
WriteENRSValue(ref ptr, enrs.Sub[i0].Reverse);
|
||||
if (enrsEntry.Repeat < 1) continue;
|
||||
|
||||
for (i0 = 0; i0 < enrsEntry.Count && i0 < enrsEntry.Sub.Length; i0++)
|
||||
{
|
||||
if (enrsEntry.Sub[i0].Type < ENRSEntry.Type. WORD ||
|
||||
enrsEntry.Sub[i0].Type > ENRSEntry.Type.QWORD)
|
||||
return data;
|
||||
|
||||
WriteENRSValue(ref localPtr, i0 > 0 ? enrsEntry.Sub[i0].Skip -
|
||||
enrsEntry.Sub[i0 - 1].SizeSkip : enrsEntry.Sub[i0].Skip, enrsEntry.Sub[i0].Type);
|
||||
WriteENRSValue(ref localPtr, enrsEntry.Sub[i0].Reverse);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -91,10 +93,10 @@
|
||||
{
|
||||
int i, i0;
|
||||
int length = 0x10;
|
||||
for (i = 0; i < List.Count; i++)
|
||||
for (i = 0; i < Array.Length; i++)
|
||||
{
|
||||
ENRS enrs = List[i];
|
||||
length += GetSize(i > 0 ? enrs.Offset - List[i - 1].Offset : enrs.Offset);
|
||||
ENRSEntry enrs = Array[i];
|
||||
length += GetSize(i > 0 ? enrs.Offset - Array[i - 1].Offset : enrs.Offset);
|
||||
length += GetSize(enrs.Count );
|
||||
length += GetSize(enrs.Size );
|
||||
length += GetSize(enrs.Repeat);
|
||||
@@ -103,8 +105,8 @@
|
||||
|
||||
for (i0 = 0; i0 < enrs.Count; i0++)
|
||||
{
|
||||
if (enrs.Sub[i0].Type < ENRS.Type. WORD ||
|
||||
enrs.Sub[i0].Type > ENRS.Type.QWORD) return length.A(0x10);
|
||||
if (enrs.Sub[i0].Type < ENRSEntry.Type. WORD ||
|
||||
enrs.Sub[i0].Type > ENRSEntry.Type.QWORD) return length.A(0x10);
|
||||
|
||||
length += GetSizeType(i0 > 0 ? enrs.Sub[i0].Skip -
|
||||
enrs.Sub[i0 - 1].SizeSkip : enrs.Sub[i0].Skip);
|
||||
@@ -114,7 +116,7 @@
|
||||
return length.A(0x10);
|
||||
|
||||
static int GetSizeType(int val) => val < 0x00000010 ? 1 : val < 0x00001000 ? 2 : 4;
|
||||
static int GetSize (int val) => val < 0x00000040 ? 1 : val < 0x00004000 ? 2 : 4;
|
||||
static int GetSize (int val) => val < 0x00000040 ? 1 : val < 0x00004000 ? 2 : 4;
|
||||
}
|
||||
|
||||
/*private static KKdList<ENRS.SubENRS> Optimize(KKdList<ENRS.SubENRS> Sub)
|
||||
@@ -134,41 +136,41 @@
|
||||
return Sub;
|
||||
}*/
|
||||
|
||||
[System.ThreadStatic] private static ENRS.Value value;
|
||||
[System.ThreadStatic] private static ENRSEntry.Value value;
|
||||
|
||||
private unsafe static int ReadENRSValue(ref byte* ptr, out ENRS.Type type)
|
||||
private unsafe static int ReadENRSValue(ref byte* ptr, out ENRSEntry.Type type)
|
||||
{
|
||||
int V = *ptr & 0xF;
|
||||
type = (ENRS. Type)((*ptr & 0x30) >> 4);
|
||||
value = (ENRS.Value)((*ptr & 0xC0) >> 6);
|
||||
type = (ENRSEntry. Type)((*ptr & 0x30) >> 4);
|
||||
value = (ENRSEntry.Value)((*ptr & 0xC0) >> 6);
|
||||
ptr++;
|
||||
if (value == ENRS.Value.Int32 )
|
||||
if (value == ENRSEntry.Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; }
|
||||
else if (value == ENRS.Value.Int16 )
|
||||
else if (value == ENRSEntry.Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; }
|
||||
else if (value == ENRS.Value.Invalid) V = 0;
|
||||
else if (value == ENRSEntry.Value.Invalid) V = 0;
|
||||
return V;
|
||||
}
|
||||
|
||||
private unsafe static int ReadENRSValue(ref byte* ptr)
|
||||
{
|
||||
int V = *ptr & 0x3F;
|
||||
value = (ENRS.Value)((*ptr & 0xC0) >> 6);
|
||||
value = (ENRSEntry.Value)((*ptr & 0xC0) >> 6);
|
||||
ptr++;
|
||||
if (value == ENRS.Value.Int32 )
|
||||
if (value == ENRSEntry.Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; }
|
||||
else if (value == ENRS.Value.Int16 )
|
||||
else if (value == ENRSEntry.Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; }
|
||||
else if (value == ENRS.Value.Invalid) V = 0;
|
||||
else if (value == ENRSEntry.Value.Invalid) V = 0;
|
||||
return V;
|
||||
}
|
||||
|
||||
private unsafe static void WriteENRSValue(ref byte* ptr, int val, ENRS.Type type)
|
||||
private unsafe static void WriteENRSValue(ref byte* ptr, int val, ENRSEntry.Type type)
|
||||
{
|
||||
value = ENRS.Value.Invalid;
|
||||
if (val < 0x00000040) value = ENRS.Value.Int8 ;
|
||||
else if (val < 0x00004000) value = ENRS.Value.Int16;
|
||||
else if (val < 0x40000000) value = ENRS.Value.Int32;
|
||||
value = ENRSEntry.Value.Invalid;
|
||||
if (val < 0x00000040) value = ENRSEntry.Value.Int8 ;
|
||||
else if (val < 0x00004000) value = ENRSEntry.Value.Int16;
|
||||
else if (val < 0x40000000) value = ENRSEntry.Value.Int32;
|
||||
*ptr = (byte)((((byte)value << 6) & 0xC0) | (((byte)type << 4) & 0x30));
|
||||
|
||||
if (val < 0x00000010)
|
||||
@@ -186,10 +188,10 @@
|
||||
|
||||
private unsafe static void WriteENRSValue(ref byte* ptr, int val)
|
||||
{
|
||||
value = ENRS.Value.Invalid;
|
||||
if (val < 0x00000040) value = ENRS.Value.Int8 ;
|
||||
else if (val < 0x00004000) value = ENRS.Value.Int16;
|
||||
else if (val < 0x40000000) value = ENRS.Value.Int32;
|
||||
value = ENRSEntry.Value.Invalid;
|
||||
if (val < 0x00000040) value = ENRSEntry.Value.Int8 ;
|
||||
else if (val < 0x00004000) value = ENRSEntry.Value.Int16;
|
||||
else if (val < 0x40000000) value = ENRSEntry.Value.Int32;
|
||||
*ptr = (byte)(((byte)value << 6) & 0xC0);
|
||||
|
||||
if (val < 0x00000040)
|
||||
@@ -205,13 +207,13 @@
|
||||
ptr++;
|
||||
}
|
||||
|
||||
public struct ENRS
|
||||
public struct ENRSEntry
|
||||
{
|
||||
public int Offset;
|
||||
public int Count;
|
||||
public int Size;
|
||||
public int Repeat;
|
||||
public KKdList<SubENRS> Sub;
|
||||
public SubENRSEntry[] Sub;
|
||||
|
||||
public enum Type : byte
|
||||
{
|
||||
@@ -229,7 +231,7 @@
|
||||
Invalid = 0b11,
|
||||
}
|
||||
|
||||
public struct SubENRS
|
||||
public struct SubENRSEntry
|
||||
{
|
||||
public int Skip;
|
||||
public int Reverse;
|
||||
@@ -248,6 +250,6 @@
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
$"{(NotNull ? $"ENRS Count: {List.Count}" : "No ENRS")}";
|
||||
$"{(NotNull ? $"ENRS Count: {Array.Length}" : "No ENRS")}";
|
||||
}
|
||||
}
|
||||
|
||||
+44
-40
@@ -10,59 +10,63 @@
|
||||
public int Length => length(false).A(0x10);
|
||||
public int LengthX => length( true).A(0x10);
|
||||
|
||||
public unsafe static POF Read(byte[] data, bool shiftX)
|
||||
public unsafe void Read(byte[] data, bool shiftX)
|
||||
{
|
||||
Value Val = 0;
|
||||
KKdList<long> offsets = KKdList<long>.New;
|
||||
byte* ptr = data.GetPtr();
|
||||
int i = 0, offset = 0, v = 0;
|
||||
byte bitShift = (byte)(shiftX ? 3 : 2);
|
||||
|
||||
int length = *(int*)ptr - 4; ptr += 4;
|
||||
while (length > i)
|
||||
Offsets = KKdList<long>.New;
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
v = *ptr & 0x3F;
|
||||
Val = (Value)(*ptr & 0xC0);
|
||||
ptr++; i++;
|
||||
if (Val == Value.Int32 )
|
||||
{ v = (v << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; i += 3; }
|
||||
else if (Val == Value.Int16 )
|
||||
{ v = (v << 8) | ptr[0]; ptr += 1; i += 3; }
|
||||
else if (Val == Value.Invalid) break;
|
||||
offset += v;
|
||||
offsets.Add(offset << bitShift);
|
||||
int i = 0, offset = 0, v = 0;
|
||||
byte bitShift = (byte)(shiftX ? 3 : 2);
|
||||
|
||||
int length = *(int*)ptr - 4;
|
||||
byte* localPtr = ptr + 4;
|
||||
while (length > i)
|
||||
{
|
||||
v = *ptr & 0x3F;
|
||||
Val = (Value)(*ptr & 0xC0);
|
||||
localPtr++; i++;
|
||||
if (Val == Value.Int32 )
|
||||
{ v = (v << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; localPtr += 3; i += 3; }
|
||||
else if (Val == Value.Int16 )
|
||||
{ v = (v << 8) | ptr[0]; localPtr += 1; i += 3; }
|
||||
else if (Val == Value.Invalid) break;
|
||||
offset += v;
|
||||
Offsets.Add(offset << bitShift);
|
||||
}
|
||||
}
|
||||
return new POF { Offsets = offsets };
|
||||
}
|
||||
|
||||
public unsafe static byte[] Write(POF pof, bool shiftX)
|
||||
public unsafe byte[] Write(bool shiftX)
|
||||
{
|
||||
pof.Offsets.Sort();
|
||||
Offsets.Sort();
|
||||
long offset = 0;
|
||||
byte bitShift = (byte)(shiftX ? 3 : 2);
|
||||
int max1 = 0x00100 >> bitShift;
|
||||
int max2 = 0x10000 >> bitShift;
|
||||
|
||||
byte[] data = new byte[pof.Length];
|
||||
byte* ptr = data.GetPtr();
|
||||
|
||||
byte Val = 0;
|
||||
*(int*)ptr = pof.length(shiftX); ptr += 4;
|
||||
for (int i = 0; i < pof.Offsets.Count; i++)
|
||||
byte[] data = new byte[length(shiftX)];
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
offset = pof.Offsets[i];
|
||||
if (i > 0) { offset -= pof.Offsets[i - 1]; if (offset == 0) continue; }
|
||||
byte Val = 0;
|
||||
*(int*)ptr = length(shiftX);
|
||||
byte* localPtr = ptr + 4;
|
||||
for (int i = 0; i < Offsets.Count; i++)
|
||||
{
|
||||
offset = Offsets[i];
|
||||
if (i > 0) { offset -= Offsets[i - 1]; if (offset == 0) continue; }
|
||||
|
||||
offset >>= bitShift;
|
||||
Val = (byte)(offset > max2 ? Value.Int32 : offset > max1 ? Value.Int16 : Value.Int8);
|
||||
if (offset < max1) *ptr = (byte)(Val | offset );
|
||||
else if (offset < max2) { *ptr = (byte)(Val | (offset >> 8)); ptr++;
|
||||
*ptr = (byte) offset ; }
|
||||
else { *ptr = (byte)(Val | (offset >> 24)); ptr++;
|
||||
*ptr = (byte) (offset >> 16) ; ptr++;
|
||||
*ptr = (byte) (offset >> 8) ; ptr++;
|
||||
*ptr = (byte) offset ; }
|
||||
ptr++;
|
||||
offset >>= bitShift;
|
||||
Val = (byte)(offset > max2 ? Value.Int32 : offset > max1 ? Value.Int16 : Value.Int8);
|
||||
if (offset < max1) *localPtr = (byte)(Val | offset );
|
||||
else if (offset < max2) { *localPtr = (byte)(Val | (offset >> 8)); localPtr++;
|
||||
*localPtr = (byte) offset ; }
|
||||
else { *localPtr = (byte)(Val | (offset >> 24)); localPtr++;
|
||||
*localPtr = (byte) (offset >> 16) ; localPtr++;
|
||||
*localPtr = (byte) (offset >> 8) ; localPtr++;
|
||||
*localPtr = (byte) offset ; }
|
||||
localPtr++;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -84,7 +88,7 @@
|
||||
else if (offset < max2) length += 2;
|
||||
else length += 4;
|
||||
}
|
||||
return length;
|
||||
return length;
|
||||
}
|
||||
|
||||
public enum Value : byte
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
public byte[] Data;
|
||||
public Struct[] SubStructs;
|
||||
|
||||
public ENRSList ENRS;
|
||||
public ENRS ENRS;
|
||||
public POF POF;
|
||||
|
||||
|
||||
public int Length => length(false);
|
||||
public int LengthX => length( true);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
length += (shiftX ? SubStructs[i].LengthX : SubStructs[i].Length) + SubStructs[i].Header.Length;
|
||||
length += 0x20;
|
||||
}
|
||||
return length;
|
||||
return length;
|
||||
}
|
||||
|
||||
public void Update(bool ShiftX = false)
|
||||
|
||||
+2
-1
@@ -41,7 +41,7 @@ namespace KKdBaseLib
|
||||
return new Half { _value = (ushort)(sign | (exponent << 10) | mantissa) };
|
||||
}
|
||||
|
||||
public static unsafe implicit operator double(Half h)
|
||||
public static unsafe implicit operator double(Half h)
|
||||
{
|
||||
int sign = (h._value >> 15) & 0x001;
|
||||
int exponent = ((h._value >> 10) & 0x01F) + 1023 - 15;
|
||||
@@ -64,6 +64,7 @@ namespace KKdBaseLib
|
||||
return new Half { _value = (ushort)(sign | (exponent << 10) | mantissa) };
|
||||
}
|
||||
|
||||
public static Half operator - (Half a ) => new Half() { _value = (ushort)(a._value ^ 0x8000) };
|
||||
public static Half operator + (Half a, Half b) => (Half)((float)a + (float)b);
|
||||
public static Half operator - (Half a, Half b) => (Half)((float)a - (float)b);
|
||||
public static Half operator * (Half a, Half b) => (Half)((float)a * (float)b);
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace KKdBaseLib.Interpolation
|
||||
|
||||
private float f;
|
||||
private float last;
|
||||
private float deltaFrame;
|
||||
private float df;
|
||||
private float @if;
|
||||
private float rf;
|
||||
private float lastTime;
|
||||
@@ -17,9 +17,9 @@ namespace KKdBaseLib.Interpolation
|
||||
private KFT3 lastKey;
|
||||
|
||||
public float InterpolationFramerate
|
||||
{ get => @if; set { @if = value; deltaFrame = @if / rf; } }
|
||||
{ get => @if; set { @if = value; df = @if / rf; } }
|
||||
public float RequestedFramerate
|
||||
{ get => rf; set { rf = value; deltaFrame = @if / rf; } }
|
||||
{ get => rf; set { rf = value; df = @if / rf; } }
|
||||
|
||||
public float Frame => f;
|
||||
public float Value => last;
|
||||
@@ -29,11 +29,11 @@ namespace KKdBaseLib.Interpolation
|
||||
public A3DAI(A3DAKey key, float a3daFramerate = 60, float requestedFramerate = 60)
|
||||
{
|
||||
lastTime = 0;
|
||||
this.key = key; f = -1; deltaFrame = last = rf = @if = 0;
|
||||
this.key = key; last = rf = @if = 0;
|
||||
f = -1; df = 1;
|
||||
@if = a3daFramerate;
|
||||
firstKey = lastKey = default;
|
||||
RequestedFramerate = requestedFramerate;
|
||||
f = -deltaFrame;
|
||||
ResetFrameCount();
|
||||
|
||||
if (key.Keys != null && key.Length > 0)
|
||||
@@ -60,7 +60,7 @@ namespace KKdBaseLib.Interpolation
|
||||
if ((int)key.Type == 1) return key.Keys[0].V;
|
||||
|
||||
lastTime = frame / rf;
|
||||
f = frame * deltaFrame;
|
||||
f = frame * df;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace KKdBaseLib.Interpolation
|
||||
if ((int)key.Type < 1 || (int)key.Type > 4 || key.Length < 1) return 0;
|
||||
if ((int)key.Type == 1) return key.Keys[0].V;
|
||||
|
||||
f += deltaFrame;
|
||||
f += df;
|
||||
lastTime = f / @if;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
@@ -103,7 +103,7 @@ namespace KKdBaseLib.Interpolation
|
||||
return firstKey.V - df * firstKey.T1;
|
||||
else if (key.EPTypePre == EPType.EP_2 || key.EPTypePre == EPType.EP_3)
|
||||
{
|
||||
frame = lastKey.F - df % key.FDBSaE;
|
||||
frame = lastKey.F - df % key.FrameDelta;
|
||||
f = (int)frame;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ namespace KKdBaseLib.Interpolation
|
||||
return lastKey.V + df * lastKey.T2;
|
||||
else if (key.EPTypePost == EPType.EP_2 || key.EPTypePost == EPType.EP_3)
|
||||
{
|
||||
frame = firstKey.F + df % key.FDBSaE;
|
||||
frame = firstKey.F + df % key.FrameDelta;
|
||||
f = (int)frame;
|
||||
}
|
||||
}
|
||||
@@ -125,9 +125,9 @@ namespace KKdBaseLib.Interpolation
|
||||
if ((f < firstKey.F && key.EPTypePre == EPType.EP_3) ||
|
||||
(f >= firstKey.F && key.EPTypePost == EPType.EP_3))
|
||||
{
|
||||
ep = df / key.FDBSaE;
|
||||
ep = df / key.FrameDelta;
|
||||
ep = (ep >= 0 && ep != (int)ep) ? (ep - (int)ep > 0 ? 1 : 0) : ep;
|
||||
ep = (f < firstKey.F ? -1 : 1) * (ep + 1) * key.VDBSaE;
|
||||
ep = (f < firstKey.F ? -1 : 1) * (ep + 1) * key.ValueDelta;
|
||||
}
|
||||
|
||||
if (f <= firstKey.F)
|
||||
@@ -150,8 +150,8 @@ namespace KKdBaseLib.Interpolation
|
||||
}
|
||||
}
|
||||
|
||||
KFT3 c = key.Keys[data - 1];
|
||||
KFT3 n = key.Keys[data];
|
||||
ref KFT3 c = ref key.Keys[data - 1];
|
||||
ref KFT3 n = ref key.Keys[data];
|
||||
float result;
|
||||
if (frame > c.F && frame < n.F)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ namespace KKdBaseLib.Interpolation
|
||||
return result + ep;
|
||||
}
|
||||
|
||||
public void ResetFrameCount() => f = -deltaFrame;
|
||||
public void ResetFrameCount() => f = -df;
|
||||
|
||||
public override string ToString() => $"Frame: {f}, Value: {last}";
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
float Frame { get; }
|
||||
float Value { get; }
|
||||
|
||||
|
||||
float SetTime (float time);
|
||||
float SetFrame(float frame);
|
||||
float NextFrame(float time);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
public float Value => last;
|
||||
public bool IsNull => array == null ? true : array.Length < 1;
|
||||
public bool NotNull => array == null ? false : array.Length > 0;
|
||||
|
||||
|
||||
public PDI(KFT2[] Array, float InterpolationFramerate = 60, float RequestedFramerate = 60)
|
||||
{
|
||||
lastTime = 0;
|
||||
|
||||
+7
-7
@@ -33,7 +33,7 @@
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
public override bool Equals(object obj)
|
||||
{ if (obj is KFT0 b) return this == b; else return base.Equals(obj); }
|
||||
|
||||
|
||||
public static bool operator > (float a, KFT0 b) => a > b.F;
|
||||
public static bool operator < (float a, KFT0 b) => a < b.F;
|
||||
public static bool operator >=(float a, KFT0 b) => a >= b.F;
|
||||
@@ -49,7 +49,7 @@
|
||||
public static bool operator ==(KFT0 a, KFT0 b) => a.F == b.F;
|
||||
public static bool operator !=(KFT0 a, KFT0 b) => a.F != b.F;
|
||||
}
|
||||
|
||||
|
||||
public struct KFT1 : IKF
|
||||
{
|
||||
public float F;
|
||||
@@ -86,7 +86,7 @@
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
public override bool Equals(object obj)
|
||||
{ if (obj is KFT1 b) return this == b; else return base.Equals(obj); }
|
||||
|
||||
|
||||
public static bool operator > (float a, KFT1 b) => a > b.F;
|
||||
public static bool operator < (float a, KFT1 b) => a < b.F;
|
||||
public static bool operator >=(float a, KFT1 b) => a >= b.F;
|
||||
@@ -102,7 +102,7 @@
|
||||
public static bool operator ==(KFT1 a, KFT1 b) => a.F == b.F && a.V == b.V;
|
||||
public static bool operator !=(KFT1 a, KFT1 b) => a.F != b.F || a.V != b.V;
|
||||
}
|
||||
|
||||
|
||||
public struct KFT2 : IKF
|
||||
{
|
||||
public float F;
|
||||
@@ -121,7 +121,7 @@
|
||||
new KFT3(F, V, T, T);
|
||||
|
||||
public KFT3 ToT3(IKF Previous) =>
|
||||
Previous is KFT2 PreviousT2 ?
|
||||
Previous is KFT2 PreviousT2 ?
|
||||
new KFT3(F, V, PreviousT2.T, T) :
|
||||
new KFT3(F, V, T, T);
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
public override bool Equals(object obj)
|
||||
{ if (obj is KFT2 b) return this == b; else return base.Equals(obj); }
|
||||
|
||||
|
||||
public static bool operator > (float a, KFT2 b) => a > b.F;
|
||||
public static bool operator < (float a, KFT2 b) => a < b.F;
|
||||
public static bool operator >=(float a, KFT2 b) => a >= b.F;
|
||||
@@ -161,7 +161,7 @@
|
||||
public static bool operator ==(KFT2 a, KFT2 b) => a.F == b.F && a.V == b.V && a.T == b.T;
|
||||
public static bool operator !=(KFT2 a, KFT2 b) => a.F != b.F || a.V != b.V || a.T != b.T;
|
||||
}
|
||||
|
||||
|
||||
public struct KFT3 : IKF
|
||||
{
|
||||
public float F;
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{437F63F1-8C23-429E-AB14-38B85C9EDB16}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>KKdBaseLib</RootNamespace>
|
||||
<AssemblyName>KKdBaseLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2019</Copyright>
|
||||
<Description>A base library</Description>
|
||||
<FileVersion>0.4.8.1</FileVersion>
|
||||
<PackageId>KKdBaseLib</PackageId>
|
||||
<Product>KKdBaseLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Title>KKdBaseLib</Title>
|
||||
<Version>0.4.8.1</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -38,37 +39,4 @@
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="F2\ENRS.cs" />
|
||||
<Compile Include="F2\Header.cs" />
|
||||
<Compile Include="F2\POF.cs" />
|
||||
<Compile Include="F2\Struct.cs" />
|
||||
<Compile Include="Interpolation\A3DAI.cs" />
|
||||
<Compile Include="Interpolation\IInterpolation.cs" />
|
||||
<Compile Include="Interpolation\PDI.cs" />
|
||||
<Compile Include="A3DA.cs" />
|
||||
<Compile Include="A3DAKey.cs" />
|
||||
<Compile Include="Aet.cs" />
|
||||
<Compile Include="DCC.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="Format.cs" />
|
||||
<Compile Include="Half.cs" />
|
||||
<Compile Include="Interfaces.cs" />
|
||||
<Compile Include="KF.cs" />
|
||||
<Compile Include="KKdList.cs" />
|
||||
<Compile Include="MsgPack.cs" />
|
||||
<Compile Include="Pointer.cs" />
|
||||
<Compile Include="Text.cs" />
|
||||
<Compile Include="Vector.cs" />
|
||||
<Compile Include="Vector3.cs" />
|
||||
<Compile Include="Vector4.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct KKdDict<TKey, TValue> : System.IDisposable, System.Collections.IEnumerator, INull
|
||||
{
|
||||
public static KKdDict<TKey, TValue> Null => new KKdDict<TKey, TValue>();
|
||||
public static KKdDict<TKey, TValue> New => new KKdDict<TKey, TValue>() { Count = 0, Capacity = 0 };
|
||||
public static KKdDict<TKey, TValue> NewReserve(int Capacity) =>
|
||||
new KKdDict<TKey, TValue>() { Count = 0, Capacity = Capacity };
|
||||
|
||||
private int index;
|
||||
private TKey [] keyArray;
|
||||
private TValue[] valArray;
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public bool IsNull => keyArray == null || valArray == null;
|
||||
public bool NotNull => keyArray != null && valArray != null;
|
||||
|
||||
public int Capacity { get => keyArray != null && valArray != null ? valArray.Length : -1;
|
||||
set { if (keyArray != null) System.Array.Resize(ref keyArray, value); else keyArray = new TKey [value];
|
||||
if (valArray != null) System.Array.Resize(ref valArray, value); else valArray = new TValue[value];
|
||||
if (Count >= value) Count = value; } }
|
||||
|
||||
|
||||
public KKdDict(TKey[] keyArray, TValue[] valArray)
|
||||
{
|
||||
this.keyArray = null; this.valArray = null; Count = 0; index = 0;
|
||||
if (keyArray == null || valArray == null || keyArray.Length != valArray.Length) return;
|
||||
Count = valArray.Length; this.keyArray = keyArray; this.valArray = valArray; }
|
||||
|
||||
public KeyValuePair<TKey, TValue> Current => index < Count ?
|
||||
new KeyValuePair<TKey, TValue>(keyArray[index], valArray[index]) : default;
|
||||
|
||||
object System.Collections.IEnumerator.Current => Current;
|
||||
|
||||
public TKey [] Keys => keyArray;
|
||||
public TValue[] Values => valArray;
|
||||
|
||||
public KeyValuePair<TKey, TValue> this[ int index, bool list]
|
||||
{ get => keyArray != null && valArray != null && index > -1 && index < keyArray.Length &&
|
||||
index < valArray.Length ? new KeyValuePair<TKey, TValue>(keyArray[index], valArray[index]) : default;
|
||||
set { if (keyArray != null && valArray != null && index > -1 && index < keyArray.Length &&
|
||||
index < valArray.Length) { keyArray[index] = value.Key; valArray[index] = value.Value; } } }
|
||||
|
||||
public KeyValuePair<TKey, TValue> this[uint index, bool list]
|
||||
{ get => keyArray != null && valArray != null && index < keyArray.Length &&
|
||||
index < valArray.Length ? new KeyValuePair<TKey, TValue>(keyArray[index], valArray[index]) : default;
|
||||
set { if (keyArray != null && valArray != null && index < keyArray.Length &&
|
||||
index < valArray.Length) { keyArray[index] = value.Key; valArray[index] = value.Value; } } }
|
||||
|
||||
public TValue this[TKey key]
|
||||
{ get => valArray != null && valArray.Length > 0 && ContainsKey(key) ? valArray[IndexOf(key)] : default;
|
||||
set { if (valArray != null && valArray.Length > 0 && ContainsKey(key)) valArray[IndexOf(key)] = value; } }
|
||||
|
||||
public bool MoveNext()
|
||||
{ if (index == Count - 1) { index = 0; return false; }
|
||||
else { index++ ; return true; } }
|
||||
|
||||
|
||||
public System.Collections.IEnumerator GetEnumerator() => this;
|
||||
|
||||
public void Dispose() { valArray = null; Count = 0; index = 0; }
|
||||
|
||||
public void Reset() => index = 0;
|
||||
|
||||
public void Add(KeyValuePair<TKey, TValue> pair)
|
||||
{
|
||||
if (IsNull) return;
|
||||
|
||||
Count++;
|
||||
if (keyArray.Length < Count) System.Array.Resize(ref keyArray, Count);
|
||||
if (valArray.Length < Count) System.Array.Resize(ref valArray, Count);
|
||||
keyArray[Count - 1] = pair.Key;
|
||||
valArray[Count - 1] = pair.Value;
|
||||
}
|
||||
|
||||
public void Add(TKey key, TValue val)
|
||||
{
|
||||
if (IsNull) return;
|
||||
|
||||
Count++;
|
||||
if (keyArray.Length < Count) System.Array.Resize(ref keyArray, Count);
|
||||
if (valArray.Length < Count) System.Array.Resize(ref valArray, Count);
|
||||
keyArray[Count - 1] = key;
|
||||
valArray[Count - 1] = val;
|
||||
}
|
||||
|
||||
public bool RemoveKey(TKey key)
|
||||
{
|
||||
if (IsNull) return false;
|
||||
|
||||
int index = IndexOf(key);
|
||||
if (index == -1) return false;
|
||||
|
||||
for (int i = index + 1; i < Count; i++)
|
||||
{
|
||||
keyArray[i - 1] = keyArray[i];
|
||||
valArray[i - 1] = valArray[i];
|
||||
}
|
||||
Count--;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveValue(TValue val)
|
||||
{
|
||||
if (IsNull) return false;
|
||||
|
||||
int index = IndexOf(val);
|
||||
if (index == -1) return false;
|
||||
|
||||
for (int i = index + 1; i < Count; i++)
|
||||
{
|
||||
keyArray[i - 1] = keyArray[i];
|
||||
valArray[i - 1] = valArray[i];
|
||||
|
||||
}
|
||||
Count--;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (IsNull) return;
|
||||
|
||||
for (int i = index + 1; i < Count; i++)
|
||||
{
|
||||
keyArray[i - 1] = keyArray[i];
|
||||
valArray[i - 1] = valArray[i];
|
||||
}
|
||||
Count--;
|
||||
}
|
||||
|
||||
public void RemoveRange(int IndexStart, int IndexEnd)
|
||||
{
|
||||
if (IsNull) return;
|
||||
if (IndexEnd - IndexStart < 1) return;
|
||||
|
||||
if (IndexEnd - IndexStart != Count)
|
||||
for (int i = IndexStart; i < Count; i++)
|
||||
{
|
||||
keyArray[i] = keyArray[i + IndexEnd - IndexStart];
|
||||
valArray[i] = valArray[i + IndexEnd - IndexStart];
|
||||
}
|
||||
Count -= IndexEnd - IndexStart;
|
||||
}
|
||||
|
||||
public TValue[] ToArray() => valArray;
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
if (IsNull) return false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (keyArray[i] == null && key == null) return true;
|
||||
else if (keyArray[i] == null || key == null) continue;
|
||||
else if (keyArray[i] .Equals(key) ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ContainsValue(TValue val)
|
||||
{
|
||||
if (IsNull) return false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (valArray[i] == null && val == null) return true;
|
||||
else if (valArray[i] == null || val == null) continue;
|
||||
else if (valArray[i] .Equals(val) ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<TKey, TValue> pair)
|
||||
{
|
||||
if (IsNull) return false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if ( keyArray[i] == null && pair.Key == null &&
|
||||
valArray[i] == null && pair.Value == null ) return true;
|
||||
else if ((keyArray[i] == null || pair.Key == null) &&
|
||||
(valArray[i] == null || pair.Value == null)) continue;
|
||||
else if ( keyArray[i] .Equals(pair.Key) &&
|
||||
valArray[i] .Equals(pair.Value) ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private int IndexOf(TKey key)
|
||||
{
|
||||
if (IsNull) return -1;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (keyArray[i] == null && key == null) return i;
|
||||
else if (keyArray[i] == null || key == null) continue;
|
||||
else if (keyArray[i] .Equals(key) ) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int IndexOf(TValue val)
|
||||
{
|
||||
if (IsNull) return -1;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (keyArray[i] == null && val == null) return i;
|
||||
else if (keyArray[i] == null || val == null) continue;
|
||||
else if (keyArray[i] .Equals(val) ) return i;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public struct KeyValuePair<TKey, TValue>
|
||||
{
|
||||
public TKey Key;
|
||||
public TValue Value;
|
||||
|
||||
public KeyValuePair(TKey key, TValue value)
|
||||
{ Key = key; Value = value; }
|
||||
}
|
||||
}
|
||||
@@ -100,12 +100,12 @@ namespace KKdBaseLib
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{ List<T> List = this; List.Sort(); array = List.ToArray(); Count = List.Count; }
|
||||
{ List<T> List = (List<T>)this; List.Sort(); array = List.ToArray(); Count = List.Count; }
|
||||
|
||||
public static implicit operator KKdList<T>( List<T> List) =>
|
||||
public static explicit operator KKdList<T>( List<T> List) =>
|
||||
new KKdList<T> { array = List.ToArray(), Count = List.Count };
|
||||
|
||||
public static implicit operator List<T>(KKdList<T> List)
|
||||
public static explicit operator List<T>(KKdList<T> List)
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
for (int i = 0; i < List.Count; i++) list.Add(List[i]);
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace KKdBaseLib
|
||||
{
|
||||
public string Name;
|
||||
public object Object;
|
||||
|
||||
|
||||
public MsgPack[] Array => Object is MsgPack[] Array ? Array : null;
|
||||
public KKdList<MsgPack> List => Object is KKdList<MsgPack> List ? List : default;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace KKdBaseLib
|
||||
{ get { if (!array) return this[key];
|
||||
if (Object is KKdList<MsgPack> List) { MsgPack MsgPack = List[ElementIndex(key)];
|
||||
return MsgPack.Object is MsgPack[] ? MsgPack : default; } return default; } }
|
||||
|
||||
|
||||
public MsgPack Add(MsgPack obj)
|
||||
{ if (Object is KKdList<MsgPack> List && obj.Object != null) { List.Add(obj); Object = List; } return this; }
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace KKdBaseLib
|
||||
public static implicit operator MsgPack( ulong val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack( float val) => new MsgPack(null, val);
|
||||
public static implicit operator MsgPack(double val) => new MsgPack(null, val);
|
||||
|
||||
|
||||
public MsgPack Add( bool? val) => val.HasValue ? Add(new MsgPack(null, val.Value)) : this;
|
||||
public MsgPack Add( sbyte? val) => val.HasValue ? Add(new MsgPack(null, val.Value)) : this;
|
||||
public MsgPack Add( byte? val) => val.HasValue ? Add(new MsgPack(null, val.Value)) : this;
|
||||
@@ -95,7 +95,7 @@ namespace KKdBaseLib
|
||||
public MsgPack Add( ulong val) => Add(new MsgPack(null, val));
|
||||
public MsgPack Add( float val) => Add(new MsgPack(null, val));
|
||||
public MsgPack Add(double val) => Add(new MsgPack(null, val));
|
||||
|
||||
|
||||
public MsgPack Add(string Val, bool? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, sbyte? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, byte? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
@@ -107,7 +107,7 @@ namespace KKdBaseLib
|
||||
public MsgPack Add(string Val, ulong? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, float? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, double? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
|
||||
|
||||
public MsgPack Add(string Val, byte[] val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, string val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, bool val) => Add(new MsgPack(Val, val));
|
||||
@@ -253,7 +253,7 @@ namespace KKdBaseLib
|
||||
public ulong RU64() => RnU64() ?? default;
|
||||
public float RF32() => RnF32() ?? default;
|
||||
public double RF64() => RnF64() ?? default;
|
||||
|
||||
|
||||
public bool? RnB ()
|
||||
{ if (Object is bool B ) return B ; return null; }
|
||||
public sbyte? RnI8 ()
|
||||
|
||||
+29
-1
@@ -13,7 +13,35 @@
|
||||
public Pointer(int offset, T value)
|
||||
{ O = offset; V = value; }
|
||||
}
|
||||
|
||||
|
||||
public struct PointerI64<T>
|
||||
{
|
||||
public long O;
|
||||
public T V;
|
||||
|
||||
public override string ToString() => Extensions.ToS(V);
|
||||
|
||||
public PointerI64(T value)
|
||||
{ O = 0; V = value; }
|
||||
|
||||
public PointerI64(long offset, T value)
|
||||
{ O = offset; V = value; }
|
||||
}
|
||||
|
||||
public struct PointerU64<T>
|
||||
{
|
||||
public ulong O;
|
||||
public T V;
|
||||
|
||||
public override string ToString() => Extensions.ToS(V);
|
||||
|
||||
public PointerU64(T value)
|
||||
{ O = 0; V = value; }
|
||||
|
||||
public PointerU64(ulong offset, T value)
|
||||
{ O = offset; V = value; }
|
||||
}
|
||||
|
||||
public struct CountPointer<T>
|
||||
{
|
||||
public int C { get => E != null ? E.Length : 0;
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("KKdBaseLib")]
|
||||
[assembly: AssemblyDescription("A base library")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("KKdBaseLib")]
|
||||
[assembly: AssemblyCopyright("korenkonder © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("437F63F1-8C23-429E-AB14-38B85C9EDB16")]
|
||||
[assembly: AssemblyVersion("0.4.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.8.0")]
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ namespace KKdBaseLib
|
||||
public static class Text
|
||||
{
|
||||
public readonly static Encoding ShiftJIS = Encoding.GetEncoding(932);
|
||||
|
||||
|
||||
public static string ToASCII(this byte[] Array) => Encoding.ASCII.GetString(Array ?? new byte[0]);
|
||||
public static string ToUTF8 (this byte[] Array) => Encoding.UTF8 .GetString(Array ?? new byte[0]);
|
||||
public static byte[] ToASCII(this string Data ) => Encoding.ASCII.GetBytes (Data ?? "" );
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
public override string ToString() => $"({X}; {Y})";
|
||||
}
|
||||
|
||||
|
||||
public struct Vector3<T> : INull
|
||||
{
|
||||
public T X;
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
public Vector3(T X, T Y, T Z)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; }
|
||||
|
||||
|
||||
public bool IsNull => X == null && Y == null && Z == null;
|
||||
public bool NotNull => X != null || Y != null || Z != null;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
public Vector4(T X, T Y, T Z, T W)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; this.W = W; }
|
||||
|
||||
|
||||
public bool IsNull => X == null && Y == null && Z == null && W == null;
|
||||
public bool NotNull => X != null || Y != null || Z != null || W != null;
|
||||
|
||||
|
||||
+37
-25
@@ -310,7 +310,7 @@ namespace KKdMainLib
|
||||
name = "m_objhrc" + d + i0 + d;
|
||||
|
||||
dict.FindValue(out Data.MObjectHRC[i0].Name, name + "name");
|
||||
|
||||
|
||||
if (dict.StartsWith(name + "joint_orient"))
|
||||
{
|
||||
Data.MObjectHRC[i0].JointOrient = new Vector3<float?>();
|
||||
@@ -349,7 +349,7 @@ namespace KKdMainLib
|
||||
Data.MObjectHRC[i0].Node[i1].MT = RMT(nameView);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Data.MObjectHRC[i0].MT = RMT(name);
|
||||
}
|
||||
}
|
||||
@@ -434,7 +434,7 @@ namespace KKdMainLib
|
||||
RKUV(nameView + "translateFrame");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Data.Object[i0].MT = RMT(name);
|
||||
}
|
||||
}
|
||||
@@ -527,7 +527,7 @@ namespace KKdMainLib
|
||||
}
|
||||
W("ambient.length=", Data.Fog.Length);
|
||||
}
|
||||
|
||||
|
||||
if (Data.CameraAuxiliary != null)
|
||||
{
|
||||
name = "camera_auxiliary" + d;
|
||||
@@ -922,7 +922,7 @@ namespace KKdMainLib
|
||||
{
|
||||
ModelTransform mt = new ModelTransform();
|
||||
dict.FindValue(out mt.BinOffset, str + MTBO);
|
||||
|
||||
|
||||
mt.Rot = RV3(str + "rot" + d);
|
||||
mt.Scale = RV3(str + "scale" + d);
|
||||
mt.Trans = RV3(str + "trans" + d);
|
||||
@@ -1324,7 +1324,7 @@ namespace KKdMainLib
|
||||
W(ref Data.Ambient[i0].RimLightDiffuse);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (Data.CameraAuxiliary != null)
|
||||
{
|
||||
CameraAuxiliary ca = Data.CameraAuxiliary.Value;
|
||||
@@ -1482,7 +1482,7 @@ namespace KKdMainLib
|
||||
_IO.WE(Head.BinaryOffset, true);
|
||||
_IO.WE(Head.BinaryLength, true);
|
||||
_IO.WE(0x20, true);
|
||||
|
||||
|
||||
if (Head.Format > Format.AFT && Head.Format < Format.FT)
|
||||
{
|
||||
_IO.P = A3DCEnd;
|
||||
@@ -1498,7 +1498,7 @@ namespace KKdMainLib
|
||||
_IO.Dispose();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
private void RMT(ref ModelTransform mt)
|
||||
{
|
||||
if (mt.BinOffset == null) return;
|
||||
@@ -1529,7 +1529,7 @@ namespace KKdMainLib
|
||||
private void RK(ref Key key, bool f16 = false)
|
||||
{
|
||||
if (key.BinOffset == null || key.BinOffset < 0) return;
|
||||
|
||||
|
||||
_IO.P = (int)key.BinOffset;
|
||||
int Type = _IO.RI32();
|
||||
key.Value = _IO.RF32();
|
||||
@@ -1553,7 +1553,7 @@ namespace KKdMainLib
|
||||
for (int i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; kf.F = _IO.RU16(); kf.V = _IO.RF16();
|
||||
kf.T1 = _IO.RF32(); kf.T2 = _IO.RF32(); }
|
||||
else
|
||||
else
|
||||
for (int i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; kf.F = _IO.RF32(); kf.V = _IO.RF32();
|
||||
kf.T1 = _IO.RF32(); kf.T2 = _IO.RF32(); }
|
||||
@@ -1617,7 +1617,7 @@ namespace KKdMainLib
|
||||
for (i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; _IO.W((ushort)kf.F ); _IO.W((Half)kf.V );
|
||||
_IO.W( kf.T1); _IO.W( kf.T2); }
|
||||
else
|
||||
else
|
||||
for (i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; _IO.W( kf.F ); _IO.W( kf.V );
|
||||
_IO.W( kf.T1); _IO.W( kf.T2); }
|
||||
@@ -1787,7 +1787,7 @@ namespace KKdMainLib
|
||||
mData.PostProcess = mPP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void MMT(ref ModelTransform mt, ref ModelTransform mMT)
|
||||
{
|
||||
MV3(ref mt.Scale , ref mMT.Scale );
|
||||
@@ -1808,7 +1808,14 @@ namespace KKdMainLib
|
||||
|
||||
private void MK(ref Key key, ref Key mKey)
|
||||
{
|
||||
if (key.Keys == null || mKey.Keys == null) return;
|
||||
if (key.Keys == null && mKey.Keys != null)
|
||||
return;
|
||||
|
||||
if (key.Keys != null && mKey.Keys == null)
|
||||
return;
|
||||
|
||||
if (key.Keys == null || mKey.Keys == null)
|
||||
return;
|
||||
|
||||
if (key.Keys.Length >= 1 && mKey.Keys.Length == 1)
|
||||
{
|
||||
@@ -1828,10 +1835,15 @@ namespace KKdMainLib
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.Keys[key.Keys.Length - 1] != mKey.Keys[0] && key.Keys[key.Keys.Length - 2] != mKey.Keys[0])
|
||||
return;
|
||||
int i = key.Keys.Length;
|
||||
bool found = false;
|
||||
while (i > 1 && !found)
|
||||
if (key.Keys[--i] == mKey.Keys[0])
|
||||
found = true;
|
||||
|
||||
int OldLength = key.Keys.Length - (key.Keys[key.Keys.Length - 1] == mKey.Keys[0] ? 1 : 2);
|
||||
if (!found) return;
|
||||
|
||||
int OldLength = i;
|
||||
Array.Resize(ref key.Keys, OldLength + mKey.Keys.Length);
|
||||
Array.Copy(mKey.Keys, 0, key.Keys, OldLength, mKey.Keys.Length);
|
||||
key.Length = key.Keys.Length;
|
||||
@@ -2019,7 +2031,7 @@ namespace KKdMainLib
|
||||
Y = temp1.RnF32("Y"),
|
||||
Z = temp1.RnF32("Z"),
|
||||
};
|
||||
|
||||
|
||||
if ((temp1 = temp[i0]["Instance", true]).NotNull)
|
||||
{
|
||||
Data.MObjectHRC[i0].Instances = new MObjectHRC.Instance[temp1.Array.Length];
|
||||
@@ -2032,7 +2044,7 @@ namespace KKdMainLib
|
||||
UIDName = temp1[i1].RS ("UIDName"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if ((temp1 = temp[i0]["Node", true]).NotNull)
|
||||
{
|
||||
Data.MObjectHRC[i0].Node = new Node[temp1.Array.Length];
|
||||
@@ -2053,7 +2065,7 @@ namespace KKdMainLib
|
||||
for (i = 0; i < Data.MObjectHRCList.Length; i++)
|
||||
Data.MObjectHRCList[i] = temp[i].RS();
|
||||
}
|
||||
|
||||
|
||||
if ((temp = a3d["Motion", true]).NotNull)
|
||||
{
|
||||
Data.Motion = new string[temp.Array.Length];
|
||||
@@ -2203,7 +2215,7 @@ namespace KKdMainLib
|
||||
.Add("RimLightDiffuse", ref Data.Ambient[i].RimLightDiffuse);
|
||||
a3d.Add(ambient);
|
||||
}
|
||||
|
||||
|
||||
if (Data.CameraAuxiliary != null)
|
||||
{
|
||||
CameraAuxiliary ca = Data.CameraAuxiliary.Value;
|
||||
@@ -2420,7 +2432,7 @@ namespace KKdMainLib
|
||||
MsgPack _objectHRC = MsgPack.New.Add( "Name", Data.ObjectHRC[i0]. Name)
|
||||
.Add("Shadow" , Data.ObjectHRC[i0].Shadow )
|
||||
.Add("UIDName", Data.ObjectHRC[i0].UIDName);
|
||||
|
||||
|
||||
if (Data.ObjectHRC[i0].JointOrient.NotNull &&
|
||||
(Head.Format == Format.X || Head.Format == Format.XHD))
|
||||
_objectHRC.Add(new MsgPack("JointOrient")
|
||||
@@ -2502,7 +2514,7 @@ namespace KKdMainLib
|
||||
Head = default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class A3DAExt
|
||||
{
|
||||
public static ModelTransform RMT(this MsgPack msgPack, string name) =>
|
||||
@@ -2537,7 +2549,7 @@ namespace KKdMainLib
|
||||
public static Key ReadKey(this MsgPack msgPack)
|
||||
{
|
||||
if (msgPack.Object == null) return default;
|
||||
|
||||
|
||||
Key key = new Key { Max = msgPack.RnF32("Max"), Value = msgPack.RnF32("Value") };
|
||||
if (Enum.TryParse(msgPack.RS("EPTypePost"), out EPType EPTypePost)) key.EPTypePost = EPTypePost;
|
||||
if (Enum.TryParse(msgPack.RS("EPTypePre" ), out EPType EPTypePre )) key.EPTypePre = EPTypePre;
|
||||
@@ -2613,7 +2625,7 @@ namespace KKdMainLib
|
||||
keys.Add("EPTypePre", key.EPTypePre.ToString());
|
||||
|
||||
if (key.RawData.KeyType != 0) keys.Add("RawData", true);
|
||||
|
||||
|
||||
MsgPack Trans = new MsgPack(key.Keys.Length, "Trans");
|
||||
for (int i = 0; i < key.Keys.Length; i++)
|
||||
{
|
||||
@@ -2635,7 +2647,7 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
public struct A3DAHeader
|
||||
{
|
||||
{
|
||||
public int Count;
|
||||
public int BinaryLength;
|
||||
public int BinaryOffset;
|
||||
|
||||
+50
-39
@@ -110,32 +110,32 @@ namespace KKdMainLib.Aet
|
||||
for (i0 = 0; i0 < aet.Surfaces[i].Sprites.C; i0++)
|
||||
aet.Surfaces.E[i].Sprites[i0] = new AetSpriteIdentifier { Name = _IO.RPS(), ID = _IO.RU32() };
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < aet.Compositions.C; i++)
|
||||
{
|
||||
for (i0 = 0; i0 < aet.Compositions[i].C; i0++)
|
||||
{
|
||||
ref AetLayer obj = ref aet.Compositions[i].E[i0];
|
||||
ref int dataID = ref obj.DataID;
|
||||
if (dataID > 0)
|
||||
obj.DataID = -1;
|
||||
int dataOffset = obj.DataOffset;
|
||||
if (dataOffset > 0)
|
||||
{
|
||||
if (obj.Type == AetLayer.AetLayerType.Pic)
|
||||
{
|
||||
for (i1 = 0; i1 < aet.Surfaces.C; i1++)
|
||||
if (aet.Surfaces[i1].O == dataID) { obj.DataID = i1; break; }
|
||||
if (aet. Surfaces[i1].O == dataOffset) { obj.DataID = i1; break; }
|
||||
}
|
||||
else if (obj.Type == AetLayer.AetLayerType.Aif)
|
||||
{
|
||||
for (i1 = 0; i1 < aet.SoundEffects.C; i1++)
|
||||
if (aet. SoundEffects[i1].O == dataID) { obj.DataID = i1; break; }
|
||||
if (aet.SoundEffects[i1].O == dataOffset) { obj.DataID = i1; break; }
|
||||
}
|
||||
else if (obj.Type == AetLayer.AetLayerType.Eff)
|
||||
{
|
||||
for (i1 = 0; i1 < aet.Compositions.C; i1++)
|
||||
if (aet. Compositions[i1].P == dataID) { obj.DataID = i1; break; }
|
||||
if (aet.Compositions[i1].P == dataOffset) { obj.DataID = i1; break; }
|
||||
}
|
||||
}
|
||||
if (dataID == obj.DataID) obj.DataID = -1;
|
||||
|
||||
ref int parentLayer = ref obj.ParentLayer;
|
||||
if (parentLayer > 0)
|
||||
@@ -154,7 +154,7 @@ namespace KKdMainLib.Aet
|
||||
private void AETWriter(ref Pointer<AetData> aetData)
|
||||
{
|
||||
ref AetData aet = ref aetData.V;
|
||||
|
||||
|
||||
for (i = 0; i < aet.Surfaces.C; i++)
|
||||
{
|
||||
ref AetSurface region = ref aet.Surfaces.E[i];
|
||||
@@ -226,7 +226,7 @@ namespace KKdMainLib.Aet
|
||||
W(ref data. ScaleY);
|
||||
W(ref data.Opacity );
|
||||
}
|
||||
|
||||
|
||||
if (obj.Data.V.Persp.O > 0)
|
||||
{
|
||||
_IO.A(0x20);
|
||||
@@ -234,7 +234,7 @@ namespace KKdMainLib.Aet
|
||||
_IO.W(0L); _IO.W(0L); _IO.W(0L); _IO.W(0L);
|
||||
_IO.W(0L); _IO.W(0L); _IO.W(0L); _IO.W(0L);
|
||||
}
|
||||
|
||||
|
||||
if (obj.ExtraData.O > 0)
|
||||
{
|
||||
W(ref extraData.Data0);
|
||||
@@ -250,7 +250,7 @@ namespace KKdMainLib.Aet
|
||||
_IO.W(0L); _IO.W(0L); _IO.W(0L); _IO.W(0L);
|
||||
_IO.W(0L); _IO.W(0L); _IO.W(0L); _IO.W(0L); _IO.W(0L);
|
||||
}
|
||||
|
||||
|
||||
if (obj.ExtraData.O > 0)
|
||||
{
|
||||
_IO.A(0x20);
|
||||
@@ -334,7 +334,21 @@ namespace KKdMainLib.Aet
|
||||
}
|
||||
}
|
||||
|
||||
_IO.A(0x10);
|
||||
for (i = 0; i < aet.Compositions.C; i++)
|
||||
for (i0 = 0; i0 < aet.Compositions.E[i].C; i0++)
|
||||
{
|
||||
ref AetLayer obj = ref aet.Compositions.E[i].E[i0];
|
||||
if (obj.Type == AetLayer.AetLayerType.Pic) obj.DataOffset = aet.Surfaces [obj.DataID].O;
|
||||
else if (obj.Type == AetLayer.AetLayerType.Aif) obj.DataOffset = aet.SoundEffects[obj.DataID].O;
|
||||
else if (obj.Type == AetLayer.AetLayerType.Eff) obj.DataOffset = aet.Compositions[obj.DataID].O;
|
||||
else obj.DataOffset = 0;
|
||||
if (obj.DataOffset == 0)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
_IO.A(0x4);
|
||||
int returnPos = _IO.P;
|
||||
int nvp = 0;
|
||||
|
||||
@@ -350,7 +364,7 @@ namespace KKdMainLib.Aet
|
||||
ref AnimationData data = ref obj.Data.V;
|
||||
ref AnimationData.Perspective persp = ref data.Persp.V;
|
||||
ref AudioData extraData = ref obj.ExtraData.V;
|
||||
|
||||
|
||||
if (obj.Data.V.Persp.O > 0)
|
||||
{
|
||||
_IO.P = data.Persp.O;
|
||||
@@ -382,7 +396,7 @@ namespace KKdMainLib.Aet
|
||||
W(ref _IO, ref data.Opacity );
|
||||
_IO.W(data.Persp.O);
|
||||
}
|
||||
|
||||
|
||||
if (obj.ExtraData.O > 0)
|
||||
{
|
||||
_IO.P = obj.ExtraData.O;
|
||||
@@ -396,7 +410,7 @@ namespace KKdMainLib.Aet
|
||||
{
|
||||
if (keys.C < 1) _IO.W(0L);
|
||||
else { if (keys.C > 0 && keys.O == 0) { keys.O = returnPos + (nvp << 2); nvp++; } _IO.W(keys); }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -422,10 +436,7 @@ namespace KKdMainLib.Aet
|
||||
_IO.W((ushort)obj.Flags);
|
||||
_IO.W(obj.Pad);
|
||||
_IO.W((byte)obj.Type);
|
||||
if (obj.Type == AetLayer.AetLayerType.Pic) _IO.W(aet.Surfaces [obj.DataID].O);
|
||||
else if (obj.Type == AetLayer.AetLayerType.Aif) _IO.W(aet.SoundEffects[obj.DataID].O);
|
||||
else if (obj.Type == AetLayer.AetLayerType.Eff) _IO.W(aet.Compositions[obj.DataID].O);
|
||||
else _IO.W(0x00);
|
||||
_IO.W(obj.DataOffset);
|
||||
|
||||
if (obj.ParentLayer > -1)
|
||||
{
|
||||
@@ -505,12 +516,12 @@ namespace KKdMainLib.Aet
|
||||
obj.Flags = (AetLayer.AetLayerFlags)_IO.RU16();
|
||||
obj.Pad = _IO.RU8();
|
||||
obj.Type = (AetLayer.AetLayerType)_IO.RU8();
|
||||
obj.DataID = _IO.RI32();
|
||||
obj.DataOffset = _IO.RI32();
|
||||
obj.ParentLayer = _IO.RI32();
|
||||
obj.Marker = _IO.ReadCountPointer<AetMarker>();
|
||||
obj.Data = _IO.RP<AnimationData>();
|
||||
obj.ExtraData = _IO.RP<AudioData>();
|
||||
|
||||
|
||||
if (obj.Data.O > 0)
|
||||
{
|
||||
ref AnimationData data = ref obj.Data.V;
|
||||
@@ -528,7 +539,7 @@ namespace KKdMainLib.Aet
|
||||
data. ScaleY = _IO.ReadCountPointer<KFT2>();
|
||||
data.Opacity = _IO.ReadCountPointer<KFT2>();
|
||||
data.Persp = _IO.RP<AnimationData.Perspective>();
|
||||
|
||||
|
||||
RKF(ref data. OriginX);
|
||||
RKF(ref data. OriginY);
|
||||
RKF(ref data.PositionX);
|
||||
@@ -537,7 +548,7 @@ namespace KKdMainLib.Aet
|
||||
RKF(ref data. ScaleX);
|
||||
RKF(ref data. ScaleY);
|
||||
RKF(ref data.Opacity );
|
||||
|
||||
|
||||
if (data.Persp.O > 0)
|
||||
{
|
||||
ref AnimationData.Perspective Persp = ref data.Persp.V;
|
||||
@@ -550,7 +561,7 @@ namespace KKdMainLib.Aet
|
||||
Persp. RotationX = _IO.ReadCountPointer<KFT2>();
|
||||
Persp. RotationY = _IO.ReadCountPointer<KFT2>();
|
||||
Persp. ScaleZ = _IO.ReadCountPointer<KFT2>();
|
||||
|
||||
|
||||
RKF(ref Persp.Unk1 );
|
||||
RKF(ref Persp.Unk2 );
|
||||
RKF(ref Persp.RotReturnX);
|
||||
@@ -561,7 +572,7 @@ namespace KKdMainLib.Aet
|
||||
RKF(ref Persp. ScaleZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (obj.ExtraData.O > 0)
|
||||
{
|
||||
ref AudioData extraData = ref obj.ExtraData.V;
|
||||
@@ -570,13 +581,13 @@ namespace KKdMainLib.Aet
|
||||
extraData.Data1 = _IO.ReadCountPointer<KFT2>();
|
||||
extraData.Data2 = _IO.ReadCountPointer<KFT2>();
|
||||
extraData.Data3 = _IO.ReadCountPointer<KFT2>();
|
||||
|
||||
|
||||
RKF(ref extraData.Data0);
|
||||
RKF(ref extraData.Data1);
|
||||
RKF(ref extraData.Data2);
|
||||
RKF(ref extraData.Data3);
|
||||
}
|
||||
|
||||
|
||||
_IO.P = obj.Marker.O;
|
||||
for (i2 = 0; i2 < obj.Marker.C; i2++)
|
||||
obj.Marker[i2] = new AetMarker() { Frame = _IO.RF32(), Name = _IO.RPSSJIS() };
|
||||
@@ -667,14 +678,14 @@ namespace KKdMainLib.Aet
|
||||
aet.Camera.V.X = RKF(temp, "X");
|
||||
aet.Camera.V.Y = RKF(temp, "Y");
|
||||
}
|
||||
|
||||
|
||||
if ((temp = msgPack["SoundEffect", true]).NotNull)
|
||||
{
|
||||
aet.SoundEffects.C = temp.Array.Length;
|
||||
for (i = 0; i < aet.SoundEffects.C; i++)
|
||||
aet.SoundEffects.E[i] = new AetSoundEffect { Unk = temp[i].RU32("Unk") };
|
||||
}
|
||||
|
||||
|
||||
if ((temp = msgPack["Surface", true]).NotNull)
|
||||
{
|
||||
aet.Surfaces.C = temp.Array.Length;
|
||||
@@ -698,7 +709,7 @@ namespace KKdMainLib.Aet
|
||||
sprite.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((temp = msgPack["Composition", true]).NotNull)
|
||||
{
|
||||
aet.Compositions.C = temp.Array.Length + 1;
|
||||
@@ -727,7 +738,7 @@ namespace KKdMainLib.Aet
|
||||
}
|
||||
temp.Dispose();
|
||||
}
|
||||
|
||||
|
||||
public MsgPack MsgPackWriter(ref Pointer<AetData> aetData)
|
||||
{
|
||||
int i, i0;
|
||||
@@ -757,7 +768,7 @@ namespace KKdMainLib.Aet
|
||||
{
|
||||
ref AetComposition layer = ref aet.Compositions.E[i];
|
||||
MsgPack Object = MsgPack.New.Add("ID", i);
|
||||
if (layer.C > 0)
|
||||
if (layer.C > 0)
|
||||
{
|
||||
MsgPack objects = new MsgPack(layer.C, "Object");
|
||||
for (i0 = 0; i0 < layer.C; i0++)
|
||||
@@ -801,18 +812,18 @@ namespace KKdMainLib.Aet
|
||||
{
|
||||
uint i;
|
||||
layer = default;
|
||||
layer.ID = msg.RI32("ID" );
|
||||
layer.Name.V = msg.RS ("Name" );
|
||||
layer.StartFrame = msg.RF32("StartFrame" );
|
||||
layer. EndFrame = msg.RF32( "EndFrame" );
|
||||
layer.StartOffset = msg.RF32("StartFrame" );
|
||||
layer.ID = msg.RI32("ID" );
|
||||
layer.Name.V = msg.RS ("Name" );
|
||||
layer.StartFrame = msg.RF32("StartFrame" );
|
||||
layer. EndFrame = msg.RF32( "EndFrame" );
|
||||
layer.StartOffset = msg.RF32("StartOffset" );
|
||||
layer.PlaybackSpeed = msg.RF32("PlaybackSpeed");
|
||||
layer.Flags = (AetLayer.AetLayerFlags)msg.RU16("Flags");
|
||||
layer.Pad = msg.RU8("Pad");
|
||||
System.Enum.TryParse(msg.RS("Type"), out layer.Type);
|
||||
layer.DataID = msg.RnI32("DataID" ) ?? -1;
|
||||
layer.ParentLayer = msg.RnI32("ParentLayer") ?? -1;
|
||||
|
||||
|
||||
MsgPack temp;
|
||||
if ((temp = msg["Markers", true]).NotNull)
|
||||
{
|
||||
@@ -830,7 +841,7 @@ namespace KKdMainLib.Aet
|
||||
ref AnimationData data = ref layer.Data.V;
|
||||
System.Enum.TryParse(temp.RS("BlendMode"), out data.Mode);
|
||||
data.UseTextureMask = temp.RB("UseTextureMask");
|
||||
|
||||
|
||||
data. OriginX = RKF(temp, "OriginX");
|
||||
data. OriginY = RKF(temp, "OriginY");
|
||||
data.PositionX = RKF(temp, "PositionX");
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace KKdMainLib.DB
|
||||
_IO.P = aetsOffset;
|
||||
for (i = 0; i < aetsLength; i++)
|
||||
{
|
||||
_IO.I64P += 10;
|
||||
_IO.PI64 += 10;
|
||||
setIndex = _IO.RI16();
|
||||
AetCount[setIndex]++;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
for (i = 0, i0 = 0, i2 = 0; i < AetSets.Length; i++)
|
||||
if (!NotAdd.Contains(i)) { i0 += AetSets[i].Aets.Length; i2++; }
|
||||
|
||||
|
||||
i1 = i0 * 12;
|
||||
i1 = i1.A(0x20) + 0x20;
|
||||
|
||||
@@ -160,12 +160,12 @@ namespace KKdMainLib.DB
|
||||
{ AetSets[i].Aets[i0].NameOffset = _IO.P; _IO.W(AetSets[i].Aets[i0].Name + "\0"); }
|
||||
}
|
||||
_IO.A(0x08, true);
|
||||
|
||||
|
||||
_IO.P = 0x20;
|
||||
for (i = 0, i2 = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
|
||||
for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++)
|
||||
{
|
||||
_IO.W(AetSets[i].Aets[i0].Id );
|
||||
@@ -228,7 +228,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
public void ReadMsgPack(MsgPack msg)
|
||||
{ Id = msg.RnU16("Id"); Name = msg.RS("Name"); }
|
||||
|
||||
|
||||
public MsgPack WriteMsgPack() =>
|
||||
MsgPack.New.Add("Id", Id).Add("Name", Name);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ namespace KKdMainLib.DB
|
||||
public string Name;
|
||||
public string FileName;
|
||||
public AET[] Aets;
|
||||
|
||||
|
||||
public void ReadMsgPack(MsgPack msg)
|
||||
{
|
||||
FileName = msg.RS ("FileName" );
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
MsgPack authDB = new MsgPack("AuthDB");
|
||||
MsgPack authDB = new MsgPack("AuthDB");
|
||||
if (Category != null)
|
||||
{
|
||||
MsgPack category = new MsgPack(Category.Length, "Category");
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace KKdMainLib.DB
|
||||
_IO.P = spritesOffset;
|
||||
for (i = 0; i < spritesLength; i++)
|
||||
{
|
||||
_IO.I64P += 10;
|
||||
_IO.PI64 += 10;
|
||||
setIndex = _IO.RI16();
|
||||
isTexture = (setIndex & 0x1000) == 0x1000;
|
||||
setIndex &= 0xFFF;
|
||||
@@ -68,7 +68,7 @@ namespace KKdMainLib.DB
|
||||
setIndex = _IO.RI16();
|
||||
isTexture = (setIndex & 0x1000) == 0x1000;
|
||||
setIndex &= 0xFFF;
|
||||
|
||||
|
||||
if (isTexture) { SpriteSets[setIndex].Textures[texCount[setIndex]] = st; texCount[setIndex]++; }
|
||||
else { SpriteSets[setIndex]. Sprites[sprCount[setIndex]] = st; sprCount[setIndex]++; }
|
||||
}
|
||||
@@ -159,7 +159,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
for (i = 0, i0 = 0, i2 = 0; i < SpriteSets.Length; i++)
|
||||
if (!notAdd.Contains(i)) { i0 += SpriteSets[i].Sprites.Length + SpriteSets[i].Textures.Length; i2++; }
|
||||
|
||||
|
||||
i1 = i0 * 12;
|
||||
i1 = i1.A(0x20) + 0x20;
|
||||
|
||||
@@ -190,13 +190,13 @@ namespace KKdMainLib.DB
|
||||
SpriteSets[i]. NameOffset = _IO.P; _IO.W(SpriteSets[i]. Name + "\0");
|
||||
SpriteSets[i].FileNameOffset = _IO.P; _IO.W(SpriteSets[i].FileName + "\0");
|
||||
}
|
||||
|
||||
|
||||
_IO.A(0x08, true);
|
||||
_IO.P = 0x20;
|
||||
for (i = 0, i2 = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (notAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
|
||||
for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++)
|
||||
{
|
||||
_IO.W(SpriteSets[i].Textures[i0].Id );
|
||||
@@ -204,7 +204,7 @@ namespace KKdMainLib.DB
|
||||
_IO.W((ushort) i0 );
|
||||
_IO.W((ushort)(0x1000 | (i - i2)));
|
||||
}
|
||||
|
||||
|
||||
for (i0 = 0; i0 < SpriteSets[i]. Sprites.Length; i0++)
|
||||
{
|
||||
_IO.W(SpriteSets[i]. Sprites[i0].Id );
|
||||
@@ -281,7 +281,7 @@ namespace KKdMainLib.DB
|
||||
public string FileName;
|
||||
public SpriteTexture[] Sprites;
|
||||
public SpriteTexture[] Textures;
|
||||
|
||||
|
||||
public void ReadMsgPack(MsgPack msg)
|
||||
{
|
||||
FileName = msg.RS ("FileName");
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ namespace KKdMainLib
|
||||
_IO.W(0x0L);
|
||||
_IO.A(0x20);
|
||||
}
|
||||
for (i = 0; i < Dex.Length; i0++)
|
||||
for (i = 0; i < Dex.Length; i++)
|
||||
{
|
||||
Dex[i].NameOffset = _IO.P;
|
||||
_IO.W(Dex[i].Name + "\0");
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace KKdMainLib
|
||||
(i < pvList.Length ? c : "")));
|
||||
else _IO.W("%2A%2A%2A");
|
||||
}
|
||||
|
||||
|
||||
byte[] data = _IO.ToArray(true);
|
||||
ushort num = DCC.CalculateChecksum(data);
|
||||
File.WriteAllBytes(file + "_" + num + "_" + num2 + ".dat", data);
|
||||
@@ -101,7 +101,7 @@ namespace KKdMainLib
|
||||
Success = true;
|
||||
pvList.Dispose();
|
||||
}
|
||||
|
||||
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
|
||||
+18
-17
@@ -9,8 +9,8 @@ namespace KKdMainLib
|
||||
public static Header ReadHeader(this Stream stream, bool seek, bool readSectionSignature = true)
|
||||
{
|
||||
if (seek)
|
||||
if (stream.I64P > 4) stream.I64P -= 4;
|
||||
else stream.I64P = 0;
|
||||
if (stream.PI64 > 4) stream.PI64 -= 4;
|
||||
else stream.PI64 = 0;
|
||||
return stream.ReadHeader(readSectionSignature);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace KKdMainLib
|
||||
{
|
||||
public static void W(this Stream stream, POF pof, bool shiftX = false, int depth = 0)
|
||||
{
|
||||
byte[] data = POF.Write(pof, shiftX);
|
||||
byte[] data = pof.Write(shiftX);
|
||||
Header header = new Header { Depth = depth, Format = Format.F2LE,
|
||||
Length = 0x20, Signature = shiftX ? 0x31464F50 : 0x30464F50 };
|
||||
header.DataSize = header.SectionSize = data.Length;
|
||||
@@ -81,9 +81,9 @@ namespace KKdMainLib
|
||||
|
||||
public static class ENRSExtensions
|
||||
{
|
||||
public static void W(this Stream stream, ENRSList enrs, int depth = 0)
|
||||
public static void W(this Stream stream, ENRS enrs, int depth = 0)
|
||||
{
|
||||
byte[] data = ENRSList.Write(enrs);
|
||||
byte[] data = enrs.Write();
|
||||
Header header = new Header { Depth = depth, Format = Format.F2LE,
|
||||
Length = 0x20, Signature = 0x53524E45 };
|
||||
header.DataSize = header.SectionSize = data.Length;
|
||||
@@ -107,7 +107,7 @@ namespace KKdMainLib
|
||||
{
|
||||
Struct @struct = new Struct { Header = header, DataOffset =
|
||||
stream.P, Data = stream.RBy(header.SectionSize) };
|
||||
ref int depth = ref header.Depth;
|
||||
int depth = header.Depth;
|
||||
|
||||
int lastSig = 0, sig;
|
||||
long length = stream.L - stream.P;
|
||||
@@ -122,12 +122,13 @@ namespace KKdMainLib
|
||||
else if (sig == 0x53524E45 || (sig & 0xF0FFFFFF) == 0x30464F50)
|
||||
{
|
||||
byte[] Data = stream.RBy(header.SectionSize);
|
||||
if (sig == 0x53524E45) @struct.ENRS = ENRSList.Read(Data);
|
||||
else @struct.POF = POF .Read(Data, sig == 0x31464F50);
|
||||
if (sig == 0x53524E45) @struct.ENRS.Read(Data);
|
||||
else @struct.POF .Read(Data, sig == 0x31464F50);
|
||||
}
|
||||
else if (header.Depth == 0 && sig == 0x43505854)
|
||||
{ }
|
||||
else if (header.Depth <= depth) { stream.I64P -= header.Length; break; }
|
||||
{ subStructs.Add(new Struct { Header = header, DataOffset =
|
||||
stream.P, Data = stream.RBy(header.SectionSize) }); }
|
||||
else if (header.Depth <= depth) { stream.PI64 -= header.Length; break; }
|
||||
else subStructs.Add(stream.RSt(header));
|
||||
lastSig = sig;
|
||||
}
|
||||
@@ -136,20 +137,20 @@ namespace KKdMainLib
|
||||
return @struct;
|
||||
}
|
||||
|
||||
public static byte[] W(this Struct Struct, bool shiftX = false)
|
||||
public static byte[] W(this Struct Struct, bool shiftX = false, bool useDepth = true)
|
||||
{
|
||||
byte[] Data;
|
||||
using (Stream stream = File.OpenWriter()) { Struct.Update(shiftX);
|
||||
stream.W(Struct, shiftX); stream.WEOFC(); Data = stream.ToArray(); }
|
||||
stream.W(Struct, shiftX, useDepth); stream.WEOFC(); Data = stream.ToArray(); }
|
||||
return Data;
|
||||
}
|
||||
|
||||
public static void W(this Stream stream, Struct @struct, bool shiftX = false)
|
||||
public static void W(this Stream stream, Struct @struct, bool shiftX = false, bool useDepth = true)
|
||||
{
|
||||
stream.W(@struct.Header);
|
||||
stream.W(@struct.Data );
|
||||
if (@struct.HasPOF ) stream.W(@struct.POF , shiftX);
|
||||
if (@struct.HasENRS) stream.W(@struct.ENRS);
|
||||
if (@struct.HasPOF ) stream.W(@struct.POF , shiftX, useDepth ? @struct.Depth + 1 : 0);
|
||||
if (@struct.HasENRS) stream.W(@struct.ENRS, useDepth ? @struct.Depth + 1 : 0);
|
||||
if (@struct.HasSubStructs)
|
||||
{
|
||||
for (int i = 0; i < @struct.SubStructs.Length; i++)
|
||||
@@ -158,7 +159,7 @@ namespace KKdMainLib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MPExt
|
||||
{
|
||||
public static MsgPack ReadMP(this byte[] array, bool json = false)
|
||||
@@ -184,7 +185,7 @@ namespace KKdMainLib
|
||||
else using ( MP _IO = new MP(File.OpenReader(file + ".mp" ))) MsgPack = _IO.Read(true);
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
|
||||
public static void Write(this MsgPack mp, bool temp, string file, bool json = false)
|
||||
{ if (temp) MsgPack.New.Add(mp).Write(file, json).Dispose();
|
||||
else mp .Write(file, json); }
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace KKdMainLib.F2
|
||||
public Vector3 Position;
|
||||
public Vector3 ToneCurve;
|
||||
|
||||
public override string ToString() => Flags == 0 ? ",,,,,,,,,,,,,,,," : Type + "," +
|
||||
public override string ToString() => Flags == 0 ? ",,,,,,,,,,,,,,,," : Type + "," +
|
||||
((Flags & Flags.Ambient ) == 0 ? ",,," : Ambient .ToString(6) + ",") +
|
||||
((Flags & Flags.Diffuse ) == 0 ? ",,," : Diffuse .ToString(6) + ",") +
|
||||
((Flags & Flags.Specular ) == 0 ? ",,,," : Specular .ToString(6) + ",") +
|
||||
|
||||
+121
-102
@@ -14,13 +14,13 @@ namespace KKdMainLib
|
||||
public FARC(string File, bool IsDirectory = false)
|
||||
{ if (IsDirectory) DirectoryPath = File; else FilePath = File; NewFARC(); }
|
||||
|
||||
private void NewFARC() { Files = null; Signature = Farc.FArC; cbc = ft = false; }
|
||||
private void NewFARC() { Files = KKdList<FARCFile>.New; Signature = Farc.FArC; cbc = ft = false; }
|
||||
|
||||
public FARCFile[] Files = null;
|
||||
public KKdList<FARCFile> Files = KKdList<FARCFile>.New;
|
||||
public Type FARCType;
|
||||
public Farc Signature = Farc.FArC;
|
||||
public string FilePath, DirectoryPath;
|
||||
public bool HasFiles => Files == null ? false : Files.Length > 0;
|
||||
public bool HasFiles => Files.IsNull ? false : Files.Count > 0;
|
||||
|
||||
private bool cbc, ft;
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace KKdMainLib
|
||||
new AesManaged { KeySize = 128, Key = isFT ? keyFT : key,
|
||||
BlockSize = 128, Mode = isFT ? CipherMode.CBC : CipherMode.ECB,
|
||||
Padding = PaddingMode.Zeros, IV = iv ?? new byte[16] };
|
||||
|
||||
|
||||
public void UnPack(bool saveToDisk = true)
|
||||
{ if (HeaderReader()) { FileReader(); if (saveToDisk) this.SaveToDisk(); } }
|
||||
{ if (HeaderReader()) { FileReader(); if (saveToDisk) SaveToDisk(); } }
|
||||
|
||||
public bool HeaderReader()
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace KKdMainLib
|
||||
ft = farcMode == 0x10;
|
||||
cbc = farcMode != 0x10 && farcMode != 0x40;
|
||||
|
||||
if (cbc && FARCType.HasFlag(Type.ECB))
|
||||
if (cbc && (FARCType & Type.ECB) != 0)
|
||||
{
|
||||
reader.Dispose();
|
||||
byte[] header = new byte[headerLength - 0x08];
|
||||
@@ -79,14 +79,14 @@ namespace KKdMainLib
|
||||
|
||||
if (Signature == Farc.FARC)
|
||||
if (reader.RI32E(true) == 1)
|
||||
Files = new FARCFile[reader.RI32E(true)];
|
||||
Files.Capacity = reader.RI32E(true);
|
||||
reader.RI32();
|
||||
|
||||
if (Files == null)
|
||||
if (Files.Capacity == 0)
|
||||
{
|
||||
int Count = 0;
|
||||
long Position = reader.I64P;
|
||||
while (reader.I64P < headerLength)
|
||||
long Position = reader.PI64;
|
||||
while (reader.PI64 < headerLength)
|
||||
{
|
||||
reader.NT();
|
||||
reader.RI32();
|
||||
@@ -95,18 +95,20 @@ namespace KKdMainLib
|
||||
if (Signature == Farc.FARC && ft) reader.RI32();
|
||||
Count++;
|
||||
}
|
||||
reader.I64P = Position;
|
||||
Files = new FARCFile[Count];
|
||||
reader.PI64 = Position;
|
||||
Files.Capacity = Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
for (int i = 0; i < Files.Capacity; i++)
|
||||
{
|
||||
Files[i].Name = reader.NTUTF8();
|
||||
Files[i].Offset = reader.RI32E(true);
|
||||
if (Signature != Farc.FArc) Files[i].SizeComp = reader.RI32E(true);
|
||||
Files[i].SizeUnc = reader.RI32E(true);
|
||||
FARCFile file = default;
|
||||
file.Name = reader.NTUTF8();
|
||||
file.Offset = reader.RI32E(true);
|
||||
if (Signature != Farc.FArc) file.SizeComp = reader.RI32E(true);
|
||||
file.SizeUnc = reader.RI32E(true);
|
||||
if (Signature == Farc.FARC && ft)
|
||||
Files[i].Type = (Type)reader.RI32E(true);
|
||||
file.Type = (Type)reader.RI32E(true);
|
||||
Files.Add(file);
|
||||
}
|
||||
|
||||
reader.Dispose();
|
||||
@@ -114,92 +116,105 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
private void FileReader()
|
||||
{ for (int i = 0; i < Files.Length; i++) FileReader(i); }
|
||||
{ for (int i = 0; i < Files.Count; i++) FileReader(i); }
|
||||
|
||||
public byte[] FileReader(string file)
|
||||
{
|
||||
if (!HasFiles) return null;
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
if (Files[i].Name.ToLower() == file.ToLower()) return FileReader(i);
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Exists(string file)
|
||||
{
|
||||
if (!HasFiles) return false;
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
if (Files[i].Name.ToLower() == file.ToLower()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public byte[] FileReader(int i)
|
||||
{
|
||||
if (!HasFiles) return null;
|
||||
if (i >= Files.Length) return null;
|
||||
if (i >= Files.Count) return null;
|
||||
|
||||
FARCFile file = Files[i];
|
||||
if (Signature != Farc.FARC)
|
||||
{
|
||||
if (Signature == Farc.FArC)
|
||||
using (MSIO.MemoryStream memorystream = new MSIO.MemoryStream(
|
||||
File.ReadAllBytes(FilePath, Files[i].SizeComp, Files[i].Offset)))
|
||||
File.ReadAllBytes(FilePath, file.SizeComp, file.Offset)))
|
||||
using (GZipStream gZipStream = new GZipStream(memorystream, CompressionMode.Decompress))
|
||||
{
|
||||
Files[i].Data = new byte[Files[i].SizeUnc];
|
||||
gZipStream.Read(Files[i].Data, 0, Files[i].SizeUnc);
|
||||
file.Data = new byte[file.SizeUnc];
|
||||
gZipStream.Read(file.Data, 0, file.SizeUnc);
|
||||
}
|
||||
else Files[i].Data = File.ReadAllBytes(FilePath, Files[i].SizeUnc, Files[i].Offset);
|
||||
return Files[i].Data;
|
||||
else file.Data = File.ReadAllBytes(FilePath, file.SizeUnc, file.Offset);
|
||||
Files[i] = file;
|
||||
return file.Data;
|
||||
}
|
||||
|
||||
int FileSize = FARCType.HasFlag(Type.ECB) || Files[i].Type.HasFlag(Type.ECB) ?
|
||||
Files[i].SizeComp.A(0x10) : Files[i].SizeComp;
|
||||
MSIO.FileStream stream = new MSIO.FileStream(FilePath, MSIO.FileMode.Open,
|
||||
MSIO.FileAccess.ReadWrite, MSIO.FileShare.ReadWrite);
|
||||
stream.Seek(Files[i].Offset, 0);
|
||||
Files[i].Data = new byte[FileSize];
|
||||
|
||||
bool encrypted = false;
|
||||
if (FARCType.HasFlag(Type.ECB))
|
||||
int FileSize = (FARCType & Type.ECB) != 0 || (file.Type & Type.ECB) != 0 ?
|
||||
file.SizeComp.A(0x10) : file.SizeComp;
|
||||
using (MSIO.FileStream stream = new MSIO.FileStream(FilePath, MSIO.FileMode.Open,
|
||||
MSIO.FileAccess.ReadWrite, MSIO.FileShare.ReadWrite))
|
||||
{
|
||||
if ((ft && Files[i].Type.HasFlag(Type.ECB)) || cbc)
|
||||
stream.Seek(file.Offset, 0);
|
||||
file.Data = new byte[FileSize];
|
||||
|
||||
bool encrypted = false;
|
||||
if ((FARCType & Type.ECB) != 0)
|
||||
{
|
||||
using (AesManaged aes = GetAes(true, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(Files[i].Data, 0, FileSize);
|
||||
Files[i].Data = SkipData(Files[i].Data, 0x10);
|
||||
if ((ft && (file.Type & Type.ECB) != 0) || cbc)
|
||||
{
|
||||
using (AesManaged aes = GetAes(true, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(file.Data, 0, FileSize);
|
||||
file.Data = SkipData(file.Data, 0x10);
|
||||
}
|
||||
else
|
||||
using (AesManaged aes = GetAes(false, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(file.Data, 0, FileSize);
|
||||
encrypted = true;
|
||||
}
|
||||
else
|
||||
using (AesManaged aes = GetAes(false, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(Files[i].Data, 0, FileSize);
|
||||
encrypted = true;
|
||||
}
|
||||
|
||||
bool compressed = false;
|
||||
if (((ft && Files[i].Type.HasFlag(Type.GZip)) ||
|
||||
FARCType.HasFlag(Type.GZip)) && Files[i].SizeUnc > 0)
|
||||
{
|
||||
GZipStream gZipStream = new GZipStream(encrypted ? new MSIO.MemoryStream(Files[i].Data) :
|
||||
(MSIO.Stream)stream, CompressionMode.Decompress);
|
||||
byte[] Temp = new byte[Files[i].SizeUnc];
|
||||
gZipStream.Read(Temp, 0, Files[i].SizeUnc);
|
||||
Files[i].Data = Temp;
|
||||
gZipStream.Dispose();
|
||||
compressed = true;
|
||||
}
|
||||
bool compressed = false;
|
||||
if (((ft && (file.Type & Type.GZip) != 0) ||
|
||||
(FARCType & Type.GZip) != 0) && file.SizeUnc > 0)
|
||||
{
|
||||
GZipStream gZipStream = new GZipStream(encrypted ? new MSIO.MemoryStream(file.Data) :
|
||||
(MSIO.Stream)stream, CompressionMode.Decompress);
|
||||
byte[] Temp = new byte[file.SizeUnc];
|
||||
gZipStream.Read(Temp, 0, file.SizeUnc);
|
||||
file.Data = Temp;
|
||||
gZipStream.Dispose();
|
||||
compressed = true;
|
||||
}
|
||||
|
||||
if (!encrypted && !compressed)
|
||||
{
|
||||
Files[i].Data = new byte[Files[i].SizeUnc];
|
||||
stream.Read(Files[i].Data, 0, Files[i].SizeUnc);
|
||||
if (!encrypted && !compressed)
|
||||
{
|
||||
file.Data = new byte[file.SizeUnc];
|
||||
stream.Read(file.Data, 0, file.SizeUnc);
|
||||
}
|
||||
}
|
||||
stream.Dispose();
|
||||
return Files[i].Data;
|
||||
Files[i] = file;
|
||||
return file.Data;
|
||||
}
|
||||
|
||||
private void SaveToDisk()
|
||||
{
|
||||
if (DirectoryPath == null || Files == null) return;
|
||||
if (DirectoryPath == "" || Files.Length < 1) return;
|
||||
if (DirectoryPath == null || Files.IsNull ) return;
|
||||
if (DirectoryPath == "" || Files.Count < 1) return;
|
||||
MSIO.Directory.CreateDirectory(DirectoryPath);
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
{
|
||||
if (Files[i].Data != null)
|
||||
File.WriteAllBytes(Path.Combine(DirectoryPath, Files[i].Name), Files[i].Data);
|
||||
Files[i].Data = null;
|
||||
FARCFile file = Files[i];
|
||||
if (file.Data != null)
|
||||
File.WriteAllBytes(Path.Combine(DirectoryPath, file.Name), file.Data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,9 +229,9 @@ namespace KKdMainLib
|
||||
{
|
||||
NewFARC();
|
||||
string[] files = Directory.GetFiles(DirectoryPath);
|
||||
Files = new FARCFile[files.Length];
|
||||
Files.Capacity = files.Length;
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
Files[i] = new FARCFile { Name = Path.GetFileName(files[i]), Data = File.ReadAllBytes(files[i]) };
|
||||
Files.Add(new FARCFile { Name = Path.GetFileName(files[i]), Data = File.ReadAllBytes(files[i]) });
|
||||
files = null;
|
||||
Signature = signature;
|
||||
Save();
|
||||
@@ -224,7 +239,9 @@ namespace KKdMainLib
|
||||
|
||||
public void Save()
|
||||
{
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
if (!HasFiles) return;
|
||||
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
{
|
||||
string ext = Path.GetExtension(Files[i].Name).ToLower();
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".vag")
|
||||
@@ -246,8 +263,8 @@ namespace KKdMainLib
|
||||
headerWriter.W (0x00);
|
||||
}
|
||||
int HeaderPartLength = Signature == Farc.FArc ? 0x09 : 0x0D;
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
headerWriter.L += Path.GetFileName(Files[i].Name).Length + HeaderPartLength;
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
headerWriter.L += Path.GetFileName(Files[i].Name).Length + HeaderPartLength + 1;
|
||||
writer.WE(headerWriter.L, true);
|
||||
writer.W(headerWriter.ToArray(true));
|
||||
}
|
||||
@@ -256,57 +273,59 @@ namespace KKdMainLib
|
||||
for (int i1 = 0; i1 < align; i1++)
|
||||
writer.W((byte)(Signature == Farc.FArc ? 0x00 : 0x78));
|
||||
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
CompressStuff(i, ref writer);
|
||||
|
||||
writer.P = Signature == Farc.FARC ? 0x1C : 0x0C;
|
||||
for (int i = 0; i < Files.Length; i++)
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
{
|
||||
writer.W(Path.GetFileName(Files[i].Name) + "\0");
|
||||
writer.WE(Files[i].Offset, true);
|
||||
FARCFile file = Files[i];
|
||||
writer.W(Path.GetFileName(file.Name) + "\0");
|
||||
writer.WE(file.Offset, true);
|
||||
if (Signature != Farc.FArc)
|
||||
writer.WE(Files[i].SizeComp, true);
|
||||
writer.WE(Files[i].SizeUnc, true);
|
||||
writer.WE(file.SizeComp, true);
|
||||
writer.WE(file.SizeUnc, true);
|
||||
}
|
||||
writer.Dispose();
|
||||
}
|
||||
|
||||
private void CompressStuff(int i, ref Stream writer)
|
||||
{
|
||||
Files[i].Offset = writer.P;
|
||||
Files[i].SizeUnc = Files[i].Data.Length;
|
||||
Files[i].Type = Type.None;
|
||||
FARCFile file = Files[i];
|
||||
file.Offset = writer.P;
|
||||
file.SizeUnc = file.Data.Length;
|
||||
file.Type = Type.None;
|
||||
|
||||
if (Signature == Farc.FArC || (Signature == Farc.FARC && FARCType.HasFlag(Type.GZip)))
|
||||
byte[] data = file.Data;
|
||||
if (Signature == Farc.FArC || (Signature == Farc.FARC && (FARCType & Type.GZip) != 0))
|
||||
{
|
||||
Files[i].Type |= Type.GZip;
|
||||
file.Type |= Type.GZip;
|
||||
MSIO.MemoryStream stream = new MSIO.MemoryStream();
|
||||
using (GZipStream gZipStream = new GZipStream(stream, CompressionMode.Compress))
|
||||
gZipStream.Write(Files[i].Data, 0, Files[i].Data.Length);
|
||||
Files[i].Data = stream.ToArray();
|
||||
gZipStream.Write(file.Data, 0, file.Data.Length);
|
||||
data = stream.ToArray();
|
||||
stream.Dispose();
|
||||
Files[i].SizeComp = Files[i].Data.Length;
|
||||
file.SizeComp = data.Length;
|
||||
}
|
||||
|
||||
if (Signature == Farc.FARC && FARCType.HasFlag(Type.ECB))
|
||||
if (Signature == Farc.FARC && (FARCType & Type.ECB) != 0)
|
||||
{
|
||||
int AlignData = Files[i].Data.Length.A(0x40);
|
||||
byte[] Data = new byte[AlignData];
|
||||
for (int i1 = 0; i1 < AlignData ; i1++) Data[i1] = 0x78;
|
||||
for (int i1 = 0; i1 < Files[i].Data.Length; i1++) Data[i1] = Files[i].Data[i1];
|
||||
|
||||
Files[i].Data = Encrypt(Data, false);
|
||||
int alignLength = data.Length.A(0x40);
|
||||
byte[] tempData = new byte[alignLength];
|
||||
System.Array.Copy(data, tempData, data.Length);
|
||||
for (int i1 = file.Data.Length; i1 < alignLength; i1++) tempData[i1] = 0x78;
|
||||
data = Encrypt(tempData, false);
|
||||
file.SizeComp = data.Length;
|
||||
}
|
||||
|
||||
writer.W(Files[i].Data);
|
||||
Files[i].Data = null;
|
||||
writer.W(data);
|
||||
|
||||
if (Signature != Farc.FARC)
|
||||
{
|
||||
int Align = writer.P.A(0x20) - writer.P;
|
||||
int Align = writer.P.A(0x10) - writer.P;
|
||||
for (int i1 = 0; i1 < Align; i1++)
|
||||
writer.W((byte)(Signature == Farc.FArc ? 0x00 : 0x78));
|
||||
}
|
||||
Files[i] = file;
|
||||
}
|
||||
|
||||
private byte[] Encrypt(byte[] data, bool isFT)
|
||||
|
||||
+28
-28
@@ -12,7 +12,7 @@ namespace KKdMainLib.IO
|
||||
public static byte[] NT (this Stream stream, byte end = 0)
|
||||
{
|
||||
KKdList<byte> s = KKdList<byte>.New;
|
||||
while (stream.I64P < stream.I64L)
|
||||
while (stream.PI64 < stream.LI64)
|
||||
{
|
||||
byte a = stream.RU8();
|
||||
if (a == end) break;
|
||||
@@ -20,14 +20,14 @@ namespace KKdMainLib.IO
|
||||
}
|
||||
return s.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public static byte PB (this Stream stream)
|
||||
{ byte val = stream.RU8(); stream.I64P--; return val; }
|
||||
{ byte val = stream.RU8(); stream.PI64--; return val; }
|
||||
public static char PCASCII(this Stream stream)
|
||||
{ byte val = stream.RU8(); stream.I64P--; return (char)val; }
|
||||
{ byte val = stream.RU8(); stream.PI64--; return (char)val; }
|
||||
public static char PCUTF8 (this Stream stream)
|
||||
{ long LongPosition = stream.I64P; char val = stream.RCUTF8();
|
||||
stream.I64P = LongPosition; return val; }
|
||||
{ long LongPosition = stream.PI64; char val = stream.RCUTF8();
|
||||
stream.PI64 = LongPosition; return val; }
|
||||
|
||||
public static Stream SW(this Stream stream)
|
||||
{
|
||||
@@ -37,32 +37,32 @@ namespace KKdMainLib.IO
|
||||
return stream;
|
||||
}
|
||||
|
||||
public static bool As(this Stream stream, byte next)
|
||||
{ if (stream.PB() == next) { stream.PB(); return true; } else return false; }
|
||||
public static bool As(this Stream stream, byte[] next)
|
||||
{
|
||||
public static bool As(this Stream stream, byte next)
|
||||
{ if (stream.PB() == next) { stream.PB(); return true; } else return false; }
|
||||
public static bool As(this Stream stream, byte[] next)
|
||||
{
|
||||
for (var i = 0; i < next.Length; i++)
|
||||
if (!As(stream, next[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool AsASCII(this Stream stream, char next)
|
||||
{ if (stream.PCUTF8() == next) { stream.RCUTF8(); return true; } else return false; }
|
||||
public static bool AsASCII(this Stream stream, string next)
|
||||
{
|
||||
}
|
||||
|
||||
public static bool AsASCII(this Stream stream, char next)
|
||||
{ if (stream.PCUTF8() == next) { stream.RCUTF8(); return true; } else return false; }
|
||||
public static bool AsASCII(this Stream stream, string next)
|
||||
{
|
||||
for (var i = 0; i < next.Length; i++)
|
||||
if (!stream.AsASCII(next[i])) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool As(this Stream stream, char next)
|
||||
{ if (stream.PCUTF8() == next) { stream.RCUTF8(); return true; } else return false; }
|
||||
public static bool As(this Stream stream, string next)
|
||||
{
|
||||
public static bool As(this Stream stream, char next)
|
||||
{ if (stream.PCUTF8() == next) { stream.RCUTF8(); return true; } else return false; }
|
||||
public static bool As(this Stream stream, string next)
|
||||
{
|
||||
for (var i = 0; i < next.Length; i++)
|
||||
if (!As(stream, next[i])) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static long RIX(this Stream stream ) => stream.IsX ?
|
||||
stream.RI64() : stream.RU32E( );
|
||||
@@ -86,24 +86,24 @@ namespace KKdMainLib.IO
|
||||
public static byte[] RaO(this Stream stream, long Offset = -1, long Length = -1)
|
||||
{
|
||||
byte[] arr = null;
|
||||
long Position = stream.I64P;
|
||||
long Position = stream.PI64;
|
||||
if (Offset == -1) { Position += stream.IsX ? 8 : 4; Offset = stream.RIX(); }
|
||||
stream.I64P = Offset;
|
||||
stream.PI64 = Offset;
|
||||
if (Length == -1) arr = stream.NT();
|
||||
else arr = stream.RBy(Length);
|
||||
stream.I64P = Position;
|
||||
stream.PI64 = Position;
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static string RSaO(this Stream stream, long Offset = -1, long Length = -1)
|
||||
{
|
||||
string s = null;
|
||||
long Position = stream.I64P;
|
||||
long Position = stream.PI64;
|
||||
if (Offset == -1) { Position += stream.IsX ? 8 : 4; Offset = stream.RIX(); }
|
||||
stream.I64P = Offset;
|
||||
stream.PI64 = Offset;
|
||||
if (Length == -1) s = stream.NTUTF8();
|
||||
else s = stream.RSUTF8(Length);
|
||||
stream.I64P = Position;
|
||||
stream.PI64 = Position;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
+16
-4
@@ -41,14 +41,26 @@ namespace KKdMainLib.IO
|
||||
return Data.Replace(((char)0xFEFF).ToString(), "").Replace("\r", "").Split('\n'); }
|
||||
|
||||
public static void WriteAllBytes(string file, byte[] data)
|
||||
{ using (Stream _IO = OpenWriter(file, true)) _IO.W(data); }
|
||||
{ using Stream _IO = OpenWriter(file, true); if (data != null) _IO.W(data); }
|
||||
|
||||
public static void WriteAllText (string file, string data)
|
||||
{ using (Stream _IO = OpenWriter(file, true)) _IO.W(data); }
|
||||
{ using Stream _IO = OpenWriter(file, true); if (data != null) _IO.W(data); }
|
||||
|
||||
public static void WriteAllLines(string file, string[] data)
|
||||
{ using (Stream _IO = OpenWriter(file, true)) for (int i = 0; i < data.Length; i++)
|
||||
_IO.W(data[i] + "\r\n"); }
|
||||
{ using Stream _IO = OpenWriter(file, true);
|
||||
if (data != null) for (int i = 0; i < data.Length; i++)
|
||||
if (data[i] != null) _IO.W(data[i] + "\r\n"); }
|
||||
|
||||
public static void WriteAllBytes(string file, byte[] data, long length)
|
||||
{ using Stream _IO = OpenWriter(file, true); if (data != null) { _IO.W(data); _IO.LI64 = length; } }
|
||||
|
||||
public static void WriteAllText (string file, string data, long length)
|
||||
{ using Stream _IO = OpenWriter(file, true); if (data != null) { _IO.W(data); _IO.LI64 = length; } }
|
||||
|
||||
public static void WriteAllLines(string file, string[] data, long length)
|
||||
{ using Stream _IO = OpenWriter(file, true);
|
||||
if (data != null) { for (int i = 0; i < data.Length; i++)
|
||||
if (data[i] != null) _IO.W(data[i] + "\r\n"); } _IO.LI64 = length; }
|
||||
|
||||
public static bool Exists(string file) => MSIO.File.Exists(file);
|
||||
public static void Delete(string file) => MSIO.File.Delete(file);
|
||||
|
||||
+49
-48
@@ -37,54 +37,54 @@ namespace KKdMainLib.IO
|
||||
};
|
||||
return new MsgPack(Key, obj);
|
||||
}
|
||||
|
||||
private string RS()
|
||||
{
|
||||
if (!Extensions.As(_IO, '"')) return null;
|
||||
|
||||
private string RS()
|
||||
{
|
||||
if (!Extensions.As(_IO, '"')) return null;
|
||||
char c;
|
||||
string s = "";
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
c = _IO.RCUTF8();
|
||||
|
||||
if (c == '\\')
|
||||
{
|
||||
c = _IO.RCUTF8();
|
||||
if (c == '\\')
|
||||
{
|
||||
c = _IO.RCUTF8();
|
||||
|
||||
switch (char.ToLower(c))
|
||||
{
|
||||
case '"' :
|
||||
case '\\':
|
||||
case '/' : s += c; break;
|
||||
case 'b' : s += '\b'; break;
|
||||
case 'f' : s += '\f'; break;
|
||||
switch (char.ToLower(c))
|
||||
{
|
||||
case '"' :
|
||||
case '\\':
|
||||
case '/' : s += c; break;
|
||||
case 'b' : s += '\b'; break;
|
||||
case 'f' : s += '\f'; break;
|
||||
case 'n' : s += '\n'; break;
|
||||
case 'r' : s += '\r'; break;
|
||||
case 't' : s += '\t'; break;
|
||||
case 'u' : s += RUL(); break;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
else if (c == '"') break;
|
||||
else if (char.IsControl(c))
|
||||
case 'r' : s += '\r'; break;
|
||||
case 't' : s += '\t'; break;
|
||||
case 'u' : s += RUL(); break;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
else if (c == '"') break;
|
||||
else if (char.IsControl(c))
|
||||
return null;
|
||||
else s += c;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private char RUL() =>
|
||||
private char RUL() =>
|
||||
(char)((((((RHD() << 4) | RHD()) << 4) | RHD()) << 4) | RHD());
|
||||
|
||||
private int RHD() => byte.Parse(_IO.RCUTF8().ToString(),
|
||||
private int RHD() => byte.Parse(_IO.RCUTF8().ToString(),
|
||||
System.Globalization.NumberStyles.HexNumber);
|
||||
|
||||
private KKdList<MsgPack> RO()
|
||||
{
|
||||
KKdList<MsgPack> obj = KKdList<MsgPack>.New;
|
||||
if (!Extensions.As(_IO, '{')) return KKdList<MsgPack>.Null;
|
||||
if (_IO.SW().PCUTF8() == '}')
|
||||
if (_IO.SW().PCUTF8() == '}')
|
||||
{ _IO.RCUTF8(); return KKdList<MsgPack>.Null; }
|
||||
|
||||
string key;
|
||||
@@ -99,15 +99,15 @@ namespace KKdMainLib.IO
|
||||
|
||||
obj.Add(ReadValue(key));
|
||||
c = _IO.SW().PCUTF8();
|
||||
|
||||
|
||||
if (c == '}') { _IO.RCUTF8(); break; }
|
||||
else if (c == ',') { _IO.RCUTF8(); continue; }
|
||||
else return KKdList<MsgPack>.Null;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private MsgPack[] RA()
|
||||
{
|
||||
KKdList<MsgPack> obj = KKdList<MsgPack>.New;
|
||||
@@ -126,17 +126,18 @@ namespace KKdMainLib.IO
|
||||
else return null;
|
||||
}
|
||||
return obj.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private object RF()
|
||||
{
|
||||
string s = " ";
|
||||
private object RF()
|
||||
{
|
||||
string s = " ";
|
||||
_IO.SW();
|
||||
if (_IO.PCUTF8() == '-') s += _IO.RCUTF8();
|
||||
if (_IO.PCUTF8() == '0') s += _IO.RCUTF8();
|
||||
else s += ReadDigits ();
|
||||
if (_IO.PCUTF8() == '.') s += _IO.RCUTF8() + ReadDigits();
|
||||
else
|
||||
if (_IO.PCUTF8() == '0') s += _IO.RCUTF8();
|
||||
else s += RD ();
|
||||
char c = _IO.PCUTF8();
|
||||
if (c == '.') s += _IO.RCUTF8() + RD();
|
||||
else if (c != 'e' && c != 'E')
|
||||
{
|
||||
long val = long.Parse(s);
|
||||
if (val >= 0x00000000 && val < 0x000000100) return ( byte)val;
|
||||
@@ -148,19 +149,19 @@ namespace KKdMainLib.IO
|
||||
else return val;
|
||||
}
|
||||
|
||||
char c = _IO.PCUTF8();
|
||||
c = _IO.PCUTF8();
|
||||
if (c == 'e' || c == 'E')
|
||||
{
|
||||
{
|
||||
s += _IO.RCUTF8();
|
||||
c = _IO.PCUTF8();
|
||||
if (c == '+' || c == '-') s += _IO.RCUTF8();
|
||||
s += ReadDigits();
|
||||
}
|
||||
s += RD();
|
||||
}
|
||||
double d = s.ToF64();
|
||||
return (float)d == d ? (float)d : d;
|
||||
}
|
||||
|
||||
private bool RBo()
|
||||
private bool RBo()
|
||||
{
|
||||
char c = _IO.PCUTF8();
|
||||
if (c == 't' && _IO.As( "true")) return true;
|
||||
@@ -168,9 +169,9 @@ namespace KKdMainLib.IO
|
||||
return false;
|
||||
}
|
||||
|
||||
private object RN() { _IO.As("null"); return null; }
|
||||
private object RN() { _IO.As("null"); return null; }
|
||||
|
||||
private string ReadDigits()
|
||||
private string RD()
|
||||
{ string s = ""; while (char.IsDigit(_IO.SW().
|
||||
PCUTF8())) s += _IO.RCUTF8(); return s; }
|
||||
|
||||
|
||||
+5
-5
@@ -96,7 +96,7 @@ namespace KKdMainLib.IO
|
||||
msgPack.Object = _IO.RBy(Length);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private bool RS(ref MsgPack msgPack, ref Types type)
|
||||
{
|
||||
string val = RS(type);
|
||||
@@ -153,7 +153,7 @@ namespace KKdMainLib.IO
|
||||
private bool RE(ref MsgPack MsgPack, ref Types type)
|
||||
{
|
||||
int Length = 0;
|
||||
if (type == Types.FixExt1 ) Length = 1 ;
|
||||
if (type == Types.FixExt1 ) Length = 1 ;
|
||||
else if (type == Types.FixExt2 ) Length = 2 ;
|
||||
else if (type == Types.FixExt4 ) Length = 4 ;
|
||||
else if (type == Types.FixExt8 ) Length = 8 ;
|
||||
@@ -165,7 +165,7 @@ namespace KKdMainLib.IO
|
||||
MsgPack.Object = new MsgPack.Ext { Type = _IO.RI8(), Data = _IO.RBy(Length) };
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public MP W(MsgPack msgPack, bool IsArray = false)
|
||||
{
|
||||
if (msgPack.Name != null && !IsArray) W(msgPack.Name);
|
||||
@@ -235,7 +235,7 @@ namespace KKdMainLib.IO
|
||||
else { _IO.W(0xC6); _IO.WE( val.Length, true); }
|
||||
_IO.W(val);
|
||||
}
|
||||
|
||||
|
||||
private void W(string val)
|
||||
{
|
||||
if (val == null) { WN(); return; }
|
||||
@@ -257,7 +257,7 @@ namespace KKdMainLib.IO
|
||||
else if (val < 0x10000) { _IO.W(0xDC); _IO.WE((ushort)val, true); }
|
||||
else { _IO.W(0xDD); _IO.WE( val, true); }
|
||||
}
|
||||
|
||||
|
||||
private void WM(int val)
|
||||
{
|
||||
if (val == 0) { WN(); return; }
|
||||
|
||||
+27
-27
@@ -30,20 +30,20 @@ namespace KKdMainLib.IO
|
||||
set { if (value && ENRSDict == null)
|
||||
ENRSDict = new ENRSDict(); getENRS = value; } }
|
||||
|
||||
public int O { get => ( int)I64O; set => I64O = value; }
|
||||
public uint U32O { get => (uint)I64O; set => I64O = value; }
|
||||
public long I64O;
|
||||
public int O { get => ( int)OI64; set => OI64 = value; }
|
||||
public uint OU32 { get => (uint)OI64; set => OI64 = value; }
|
||||
public long OI64;
|
||||
|
||||
public int L { get => ( int)s.Length - O; set => s.SetLength(value + O); }
|
||||
public uint U32L { get => (uint)s.Length - U32O; set => s.SetLength(value + U32O); }
|
||||
public long I64L { get => s.Length - I64O; set => s.SetLength(value + I64O); }
|
||||
public int L { get => ( int)s.Length - O; set => s.SetLength(value + O); }
|
||||
public uint LU32 { get => (uint)s.Length - OU32; set => s.SetLength(value + OU32); }
|
||||
public long LI64 { get => s.Length - OI64; set => s.SetLength(value + OI64); }
|
||||
|
||||
public int P
|
||||
public int P
|
||||
{ get => ( int)s.Position - O; set => s.Position = value + O; }
|
||||
public uint U32P
|
||||
{ get => (uint)s.Position - U32O; set => s.Position = value + U32O; }
|
||||
public long I64P
|
||||
{ get => s.Position - I64O; set => s.Position = value + I64O; }
|
||||
public uint PU32
|
||||
{ get => (uint)s.Position - OU32; set => s.Position = value + OU32; }
|
||||
public long PI64
|
||||
{ get => s.Position - OI64; set => s.Position = value + OI64; }
|
||||
|
||||
public bool CanRead => s.CanRead;
|
||||
public bool CanSeek => s.CanSeek;
|
||||
@@ -55,7 +55,7 @@ namespace KKdMainLib.IO
|
||||
public Stream(MSIO.Stream output = null, bool isBE = false)
|
||||
{
|
||||
if (output == null) output = MSIO.Stream.Null;
|
||||
I64O = 0;
|
||||
OI64 = 0;
|
||||
BitRead = 8;
|
||||
ValRead = ValRead = BitWrite = 0;
|
||||
s = output;
|
||||
@@ -72,7 +72,7 @@ namespace KKdMainLib.IO
|
||||
|
||||
public long S(long offset, SeekOrigin origin = 0) =>
|
||||
s.Seek(offset + O, (MSIO.SeekOrigin)(int)origin);
|
||||
|
||||
|
||||
public long? S(long? offset, SeekOrigin origin)
|
||||
{ if (offset == null) return null;
|
||||
return s.Seek((long)offset + O, (MSIO.SeekOrigin)(int)origin); }
|
||||
@@ -122,7 +122,7 @@ namespace KKdMainLib.IO
|
||||
public ulong RU64() { s.Read(b, 0, 8); return b.TU64(); }
|
||||
public float RF32() { s.Read(b, 0, 4); return b.TF32(); }
|
||||
public double RF64() { s.Read(b, 0, 8); return b.TF64(); }
|
||||
|
||||
|
||||
public short RI16E() { s.Read(b, 0, 2); b.E(2, IsBE); return b.TI16(); }
|
||||
public ushort RU16E() { s.Read(b, 0, 2); b.E(2, IsBE); return b.TU16(); }
|
||||
public int RI32E() { s.Read(b, 0, 4); b.E(4, IsBE); return b.TI32(); }
|
||||
@@ -177,7 +177,7 @@ namespace KKdMainLib.IO
|
||||
W(UTF8 ? val.ToString().ToUTF8() : val.ToString().ToASCII());
|
||||
public void W(string val, bool UTF8 = true) =>
|
||||
W(UTF8 ? val .ToUTF8() : val .ToASCII());
|
||||
|
||||
|
||||
public void WE( short val) { b.GBy(val); b.E(2, IsBE); s.Write(b, 0, 2); }
|
||||
public void WE(ushort val) { b.GBy(val); b.E(2, IsBE); s.Write(b, 0, 2); }
|
||||
public void WE( int val) { b.GBy(val); b.E(4, IsBE); s.Write(b, 0, 4); }
|
||||
@@ -198,7 +198,7 @@ namespace KKdMainLib.IO
|
||||
|
||||
private void RENRS(byte[] b, int c)
|
||||
{ if (getENRS) ENRSDict.Add(P, c); s.Read(b, 0, c); }
|
||||
|
||||
|
||||
public short RI16ENRS() { RENRS(b, 2); return b.TI16(); }
|
||||
public ushort RU16ENRS() { RENRS(b, 2); return b.TU16(); }
|
||||
public int RI32ENRS() { RENRS(b, 4); return b.TI32(); }
|
||||
@@ -207,7 +207,7 @@ namespace KKdMainLib.IO
|
||||
public ulong RU64ENRS() { RENRS(b, 8); return b.TU64(); }
|
||||
public float RF32ENRS() { RENRS(b, 4); return b.TF32(); }
|
||||
public double RF64ENRS() { RENRS(b, 8); return b.TF64(); }
|
||||
|
||||
|
||||
public short RI16ENRSE() { RENRS(b, 2); b.E(2, IsBE); return b.TI16(); }
|
||||
public ushort RU16ENRSE() { RENRS(b, 2); b.E(2, IsBE); return b.TU16(); }
|
||||
public int RI32ENRSE() { RENRS(b, 4); b.E(4, IsBE); return b.TI32(); }
|
||||
@@ -216,7 +216,7 @@ namespace KKdMainLib.IO
|
||||
public ulong RU64ENRSE() { RENRS(b, 8); b.E(8, IsBE); return b.TU64(); }
|
||||
public float RF32ENRSE() { RENRS(b, 4); b.E(4, IsBE); return b.TF32(); }
|
||||
public double RF64ENRSE() { RENRS(b, 8); b.E(8, IsBE); return b.TF64(); }
|
||||
|
||||
|
||||
public short RI16ENRSE(bool isBE) { RENRS(b, 2); b.E(2, isBE); return b.TI16(); }
|
||||
public ushort RU16ENRSE(bool isBE) { RENRS(b, 2); b.E(2, isBE); return b.TU16(); }
|
||||
public int RI32ENRSE(bool isBE) { RENRS(b, 4); b.E(4, isBE); return b.TI32(); }
|
||||
@@ -237,7 +237,7 @@ namespace KKdMainLib.IO
|
||||
public void WENRS( ulong val) { b.GBy(val); WENRS(b, 8); }
|
||||
public void WENRS( float val) { b.GBy(val); WENRS(b, 4); }
|
||||
public void WENRS(double val) { b.GBy(val); WENRS(b, 8); }
|
||||
|
||||
|
||||
public void WENRSE( short val) { b.GBy(val); b.E(2, IsBE); WENRS(b, 2); }
|
||||
public void WENRSE(ushort val) { b.GBy(val); b.E(2, IsBE); WENRS(b, 2); }
|
||||
public void WENRSE( int val) { b.GBy(val); b.E(4, IsBE); WENRS(b, 4); }
|
||||
@@ -246,7 +246,7 @@ namespace KKdMainLib.IO
|
||||
public void WENRSE( ulong val) { b.GBy(val); b.E(8, IsBE); WENRS(b, 8); }
|
||||
public void WENRSE( float val) { b.GBy(val); b.E(4, IsBE); WENRS(b, 4); }
|
||||
public void WENRSE(double val) { b.GBy(val); b.E(8, IsBE); WENRS(b, 8); }
|
||||
|
||||
|
||||
public void WENRSE( short val, bool isBE) { b.GBy(val); b.E(2, isBE); WENRS(b, 2); }
|
||||
public void WENRSE(ushort val, bool isBE) { b.GBy(val); b.E(2, isBE); WENRS(b, 2); }
|
||||
public void WENRSE( int val, bool isBE) { b.GBy(val); b.E(4, isBE); WENRS(b, 4); }
|
||||
@@ -269,7 +269,7 @@ namespace KKdMainLib.IO
|
||||
public void WENRS (Half val ) => WENRS ((ushort)val );
|
||||
public void WENRSE(Half val ) => WENRSE((ushort)val );
|
||||
public void WENRSE(Half val, bool isBE) => WENRSE((ushort)val, isBE);
|
||||
|
||||
|
||||
public char RC(bool UTF8 = true) => UTF8 ? RCUTF8() : (char)s.ReadByte();
|
||||
|
||||
public char RCUTF8()
|
||||
@@ -298,18 +298,18 @@ namespace KKdMainLib.IO
|
||||
|
||||
public string RSUTF8 (long Length) => RBy(Length).ToUTF8 ();
|
||||
public string RSASCII(long Length) => RBy(Length).ToASCII();
|
||||
|
||||
|
||||
|
||||
|
||||
public string RS(long? Length, bool UTF8 = true) =>
|
||||
UTF8 ? RSUTF8(Length) : RSASCII(Length);
|
||||
|
||||
public string RSUTF8 (long? Length) => RBy(Length).ToUTF8 ();
|
||||
public string RSASCII(long? Length) => RBy(Length).ToASCII();
|
||||
|
||||
|
||||
public byte[] RBy(long Length, int Offset = -1)
|
||||
{ byte[] Buf = new byte[Length]; if (Offset > -1) s.Position = Offset;
|
||||
s.Read(Buf, 0, (int)Length); return Buf; }
|
||||
|
||||
|
||||
public void RBy(long Length, byte[] Buf, long Offset = -1)
|
||||
{ if (Offset > -1) s.Position = Offset; s.Read(Buf, 0, (int)Length); }
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace KKdMainLib.IO
|
||||
public void RBy(long Length, byte Bits, byte[] Buf, long Offset = -1)
|
||||
{ if (Offset > -1) s.Seek(Offset, 0);
|
||||
if (Bits > 0 && Bits < 8) for (i = 0; i < Length; i++) Buf[i] = RBi(Bits); CR(); }
|
||||
|
||||
|
||||
public byte RBi(byte Bits)
|
||||
{
|
||||
BitRead += Bits;
|
||||
@@ -334,7 +334,7 @@ namespace KKdMainLib.IO
|
||||
}
|
||||
|
||||
public byte RHB() => RBi(4);
|
||||
|
||||
|
||||
public void W(int val, byte Bits)
|
||||
{
|
||||
val &= (1 << Bits) - 1;
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>KKdMainLib</RootNamespace>
|
||||
<AssemblyName>KKdMainLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2018-2019</Copyright>
|
||||
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT files</Description>
|
||||
<FileVersion>0.4.8.1</FileVersion>
|
||||
<PackageId>KKdMainLib</PackageId>
|
||||
<Product>KKdMainLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Title>KKdMainLib</Title>
|
||||
<Version>0.4.8.1</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -39,43 +40,6 @@
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DB\Aet.cs" />
|
||||
<Compile Include="DB\Auth.cs" />
|
||||
<Compile Include="DB\Spr.cs" />
|
||||
<Compile Include="F2\Bloom.cs" />
|
||||
<Compile Include="F2\ColorCorrection.cs" />
|
||||
<Compile Include="F2\DOF.cs" />
|
||||
<Compile Include="F2\Light.cs" />
|
||||
<Compile Include="IO\Directory.cs" />
|
||||
<Compile Include="IO\Extensions.cs" />
|
||||
<Compile Include="IO\File.cs" />
|
||||
<Compile Include="IO\JSON.cs" />
|
||||
<Compile Include="IO\MP.cs" />
|
||||
<Compile Include="IO\Path.cs" />
|
||||
<Compile Include="IO\Stream.cs" />
|
||||
<Compile Include="A3DA.cs" />
|
||||
<Compile Include="Aet.cs" />
|
||||
<Compile Include="DataBank.cs" />
|
||||
<Compile Include="DEX.cs" />
|
||||
<Compile Include="DIVAFILE.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="FARC.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Mot.cs" />
|
||||
<Compile Include="STR.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj">
|
||||
<Project>{437f63f1-8c23-429e-ab14-38b85c9edb16}</Project>
|
||||
<Name>KKdBaseLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ namespace KKdMainLib
|
||||
else Console.Write (TimeFormatHHmmssfff + " - " + Text,
|
||||
time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
|
||||
}
|
||||
|
||||
|
||||
public static string NullTerminated(this string source, ref int i, byte end)
|
||||
{
|
||||
string s = "";
|
||||
@@ -148,7 +148,7 @@ namespace KKdMainLib
|
||||
value = (string)dict[args[0]];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void GetDictionary(this Dictionary<string, object> dict,
|
||||
string args, string value, char split = '.') =>
|
||||
dict.GetDictionary(args.Split(split), value);
|
||||
@@ -180,7 +180,7 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
public static TKey GetKey<TKey, TVal>(this Dictionary<TKey, TVal> dict, TVal val) =>
|
||||
dict.First((KeyValuePair<TKey, TVal> x) => x.Value.Equals(val)).Key;
|
||||
dict.First((System.Collections.Generic.KeyValuePair<TKey, TVal> x) => x.Value.Equals(val)).Key;
|
||||
|
||||
public static string ToTitleCase(this string s)
|
||||
{ return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s); }
|
||||
|
||||
+2
-2
@@ -120,7 +120,7 @@ namespace KKdMainLib
|
||||
{
|
||||
ref KeySet key = ref mot.KeySet.V[i0];
|
||||
if (key.Type == KeySetType.Static)
|
||||
_IO.W(key.Keys[0].V);
|
||||
_IO.W(key.Keys[0].V);
|
||||
else if (key.Type == KeySetType.Linear)
|
||||
{
|
||||
_IO.W((ushort)key.Keys.Length);
|
||||
@@ -251,7 +251,7 @@ namespace KKdMainLib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((temp = msgPack["BoneInfo", true]).NotNull)
|
||||
{
|
||||
mot.BoneInfo.V = new BoneInfo[temp.Array.Length];
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("KKdMainLib")]
|
||||
[assembly: AssemblyDescription("A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT files")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("KKdMainLib")]
|
||||
[assembly: AssemblyCopyright("korenkonder © 2018-2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("2BA7EFC6-91D1-8BBC-C487-06C7F36CC789")]
|
||||
[assembly: AssemblyVersion("0.4.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.8.0")]
|
||||
|
||||
+41
-64
@@ -5,14 +5,12 @@ using KKdMainLib.IO;
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public struct STR : System.IDisposable
|
||||
{
|
||||
private long offset;
|
||||
private long offsetX;
|
||||
{
|
||||
private POF pof;
|
||||
private Header header;
|
||||
private Stream _IO;
|
||||
|
||||
public String[] STRs;
|
||||
public String[] Strings;
|
||||
|
||||
public int STRReader(string filepath, string ext)
|
||||
{
|
||||
@@ -24,43 +22,22 @@ namespace KKdMainLib
|
||||
if (header.Signature == 0x41525453)
|
||||
{
|
||||
header = _IO.ReadHeader(true, false);
|
||||
pof.Offsets = KKdList<long>.New;
|
||||
|
||||
long count = _IO.RI32E();
|
||||
offset = _IO.RI32E();
|
||||
|
||||
if (offset == 0)
|
||||
{
|
||||
offset = count;
|
||||
offsetX = _IO.RI64();
|
||||
count = _IO.RI64();
|
||||
_IO.O = header.Length;
|
||||
_IO.Format = Format.X;
|
||||
_IO.I64O += offset;
|
||||
_IO.P = 0;
|
||||
}
|
||||
else _IO.P = header.Length + 0x40;
|
||||
|
||||
STRs = new String[count];
|
||||
int count = _IO.RI32E();
|
||||
int offset = _IO.RI32E();
|
||||
|
||||
_IO.P = offset;
|
||||
Strings = new String[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
STRs[i].Str.O = _IO.RI32E();
|
||||
STRs[i].ID = _IO.RI32E();
|
||||
Strings[i].Str.O = _IO.RI32E();
|
||||
Strings[i].ID = _IO.RI32E();
|
||||
}
|
||||
|
||||
if (_IO.IsX)
|
||||
{
|
||||
_IO.I64O = header.Length + offsetX;
|
||||
for (int i = 0; i < count; i++)
|
||||
STRs[i].Str.V = _IO.RSaO(STRs[i].Str.O);
|
||||
}
|
||||
else
|
||||
{
|
||||
_IO.O = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
STRs[i].Str.V = STRs[i].Str.O > 0 ?
|
||||
_IO.RSaO(STRs[i].Str.O) : null;
|
||||
}
|
||||
_IO.O = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
Strings[i].Str.V = Strings[i].Str.O > 0 ?
|
||||
_IO.RSaO(Strings[i].Str.O) : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -71,13 +48,13 @@ namespace KKdMainLib
|
||||
a = _IO.RI32();
|
||||
if (a == 0) break;
|
||||
}
|
||||
STRs = new String[count];
|
||||
Strings = new String[count];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_IO.I64P = STRs[i].Str.O;
|
||||
STRs[i].ID = i;
|
||||
STRs[i].Str.V = _IO.NTUTF8();
|
||||
_IO.PI64 = Strings[i].Str.O;
|
||||
Strings[i].ID = i;
|
||||
Strings[i].Str.V = _IO.NTUTF8();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +64,7 @@ namespace KKdMainLib
|
||||
|
||||
public void STRWriter(string filepath)
|
||||
{
|
||||
if (STRs == null || STRs.Length == 0 || header.Format > Format.F2BE) return;
|
||||
if (Strings == null || Strings.Length == 0 || header.Format > Format.F2BE) return;
|
||||
uint offset = 0;
|
||||
uint currentOffset = 0;
|
||||
_IO = File.OpenWriter(filepath + (header.Format > Format.AFT &&
|
||||
@@ -95,7 +72,7 @@ namespace KKdMainLib
|
||||
_IO.Format = header.Format;
|
||||
pof.Offsets = KKdList<long>.New;
|
||||
|
||||
long count = STRs.LongLength;
|
||||
long count = Strings.LongLength;
|
||||
if (_IO.Format > Format.AFT && _IO.Format < Format.FT)
|
||||
{
|
||||
_IO.P = 0x40;
|
||||
@@ -120,34 +97,34 @@ namespace KKdMainLib
|
||||
_IO.W(0);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (!usedSTR.Contains(STRs[i].Str.V))
|
||||
if (!usedSTR.Contains(Strings[i].Str.V))
|
||||
{
|
||||
STRPos[i] = _IO.P;
|
||||
usedSTRPos.Add(STRPos[i]);
|
||||
usedSTR.Add(STRs[i].Str.V);
|
||||
_IO.W(STRs[i].Str.V);
|
||||
usedSTR.Add(Strings[i].Str.V);
|
||||
_IO.W(Strings[i].Str.V);
|
||||
_IO.W(0);
|
||||
}
|
||||
else
|
||||
for (int i2 = 0; i2 < count; i2++)
|
||||
if (usedSTR[i2] == STRs[i].Str.V) { STRPos[i] = usedSTRPos[i2]; break; }
|
||||
if (usedSTR[i2] == Strings[i].Str.V) { STRPos[i] = usedSTRPos[i2]; break; }
|
||||
}
|
||||
|
||||
if (_IO.Format > Format.AFT)
|
||||
{
|
||||
_IO.A(0x10);
|
||||
offset = _IO.U32P;
|
||||
offset = _IO.PU32;
|
||||
_IO.P = 0x80;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
pof.Offsets.Add(_IO.P);
|
||||
_IO.WE(STRPos[i]);
|
||||
_IO.WE(STRs[i].ID);
|
||||
_IO.WE(Strings[i].ID);
|
||||
}
|
||||
|
||||
_IO.U32P = offset;
|
||||
_IO.PU32 = offset;
|
||||
_IO.W(pof, false, 1);
|
||||
currentOffset = _IO.U32P;
|
||||
currentOffset = _IO.PU32;
|
||||
_IO.WEOFC();
|
||||
header.DataSize = (int)(currentOffset - 0x40);
|
||||
header.Signature = 0x41525453;
|
||||
@@ -174,12 +151,12 @@ namespace KKdMainLib
|
||||
|
||||
if ((temp = msgPack["Strings", true]).IsNull) return;
|
||||
|
||||
STRs = new String[temp.Array.Length];
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
Strings = new String[temp.Array.Length];
|
||||
for (int i = 0; i < Strings.Length; i++)
|
||||
{
|
||||
STRs[i].ID = temp[i].RI32("ID" );
|
||||
STRs[i].Str.V = temp[i].RS ("Str");
|
||||
if (STRs[i].Str.V == null) STRs[i].Str.V = "";
|
||||
Strings[i].ID = temp[i].RI32("ID" );
|
||||
Strings[i].Str.V = temp[i].RS ("Str");
|
||||
if (Strings[i].Str.V == null) Strings[i].Str.V = "";
|
||||
}
|
||||
|
||||
msgPack.Dispose();
|
||||
@@ -187,15 +164,15 @@ namespace KKdMainLib
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (STRs == null || STRs.Length == 0) return;
|
||||
if (Strings == null || Strings.Length == 0) return;
|
||||
MsgPack str = new MsgPack("STR").Add("Format", header.Format.ToString());
|
||||
MsgPack strings = new MsgPack(STRs.Length, "Strings");
|
||||
for (int i = 0; i < STRs.Length; i++)
|
||||
MsgPack strings = new MsgPack(Strings.Length, "Strings");
|
||||
for (int i = 0; i < Strings.Length; i++)
|
||||
{
|
||||
strings[i] = MsgPack.New.Add("ID", STRs[i].ID);
|
||||
if (STRs[i].Str.V != null)
|
||||
if (STRs[i].Str.V != "")
|
||||
strings[i] = strings[i].Add("Str", STRs[i].Str.V);
|
||||
strings[i] = MsgPack.New.Add("ID", Strings[i].ID);
|
||||
if (Strings[i].Str.V != null)
|
||||
if (Strings[i].Str.V != "")
|
||||
strings[i] = strings[i].Add("Str", Strings[i].Str.V);
|
||||
}
|
||||
str.Add(strings);
|
||||
|
||||
@@ -204,7 +181,7 @@ namespace KKdMainLib
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); STRs = default;
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); Strings = default;
|
||||
pof = default; header = default; disposed = true; } }
|
||||
|
||||
public struct String
|
||||
@@ -212,7 +189,7 @@ namespace KKdMainLib
|
||||
public int ID;
|
||||
public Pointer<string> Str;
|
||||
|
||||
public override string ToString() => "ID: " + ID + (Str.V != null ||
|
||||
public override string ToString() => "ID: " + ID + (Str.V != null ||
|
||||
Str.V != "" ? ("; Str: " + Str.V) : "");
|
||||
}
|
||||
}
|
||||
|
||||
+50
-43
@@ -28,35 +28,39 @@ namespace KKdSoundLib
|
||||
reader.RU16();
|
||||
Data.Name = reader.RS(0x20);
|
||||
|
||||
Stream writer = File.OpenWriter();
|
||||
if (!ToArray) writer = File.OpenWriter(file + ".wav", true);
|
||||
writer.I64P = 0x2C;
|
||||
|
||||
byte value = 0;
|
||||
byte[] data = new byte[Data.SamplesCount * Data.Channels * 4];
|
||||
int[] current = new int[Data.Channels];
|
||||
int[] currentclamp = new int[Data.Channels];
|
||||
sbyte[] stepindex = new sbyte[Data.Channels];
|
||||
float f;
|
||||
|
||||
int* currentPtr = current.GetPtr();
|
||||
int* currentclampPtr = currentclamp.GetPtr();
|
||||
sbyte* stepindexPtr = stepindex.GetPtr();
|
||||
|
||||
for (i = 0; i < Data.SamplesCount; i++)
|
||||
for (c = 0; c < Data.Channels; c++)
|
||||
{
|
||||
value = reader.RHB();
|
||||
IMADecoder(value, ref currentPtr[c], ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
f = (float)(currentPtr[c] / 32768.0);
|
||||
writer.W(f);
|
||||
}
|
||||
fixed (int* currentPtr = current)
|
||||
fixed (int* currentclampPtr = currentclamp)
|
||||
fixed (sbyte* stepindexPtr = stepindex)
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
float* dataPtr = (float*)ptr;
|
||||
for (i = 0; i < Data.SamplesCount; i++)
|
||||
for (c = 0; c < Data.Channels; c++, dataPtr++)
|
||||
{
|
||||
value = reader.RHB();
|
||||
IMADecoder(value, ref currentPtr[c], ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
*dataPtr = (float)(currentPtr[c] / 32768.0);
|
||||
}
|
||||
}
|
||||
reader.CR();
|
||||
|
||||
WAV.Header Header = new WAV.Header { Bytes = 4, Channels = Data.Channels, Format = 3,
|
||||
SampleRate = Data.SampleRate, Size = Data.SamplesCount * Data.Channels * 4 };
|
||||
writer.W(Header, 0);
|
||||
if (ToArray) Data.Data = writer.ToArray();
|
||||
writer.C();
|
||||
|
||||
if (ToArray) Data.Data = data;
|
||||
else
|
||||
{
|
||||
Stream writer = File.OpenWriter(file + ".wav", true);
|
||||
WAV.Header Header = new WAV.Header { Bytes = 4, Channels = Data.Channels, Format = 3,
|
||||
SampleRate = Data.SampleRate, Size = Data.SamplesCount * Data.Channels * 4 };
|
||||
writer.W(Header, 0);
|
||||
writer.W(data);
|
||||
writer.C();
|
||||
}
|
||||
|
||||
reader.C();
|
||||
}
|
||||
@@ -74,7 +78,9 @@ namespace KKdSoundLib
|
||||
Stream writer = File.OpenWriter(file + ".diva", true);
|
||||
Data.Channels = Header.Channels;
|
||||
Data.SampleRate = Header.SampleRate;
|
||||
writer.I64P = 0x40;
|
||||
Data.SamplesCount = Header.Size / Header.Channels / Header.Bytes;
|
||||
writer.PI64 = 0x40;
|
||||
writer.LI64 = 0x40 + (Data.SamplesCount * Data.Channels).A(2, 2);
|
||||
|
||||
byte value = 0;
|
||||
int[] sample = new int[Data.Channels];
|
||||
@@ -82,23 +88,24 @@ namespace KKdSoundLib
|
||||
int[] currentclamp = new int[Data.Channels];
|
||||
sbyte[] stepindex = new sbyte[Data.Channels];
|
||||
|
||||
int* samplePtr = sample.GetPtr();
|
||||
int* currentPtr = current.GetPtr();
|
||||
int* currentclampPtr = currentclamp.GetPtr();
|
||||
sbyte* stepindexPtr = stepindex.GetPtr();
|
||||
Data.SamplesCount = Header.Size / Header.Channels / Header.Bytes;
|
||||
fixed (int* samplePtr = sample)
|
||||
fixed (int* currentPtr = current)
|
||||
fixed (int* currentclampPtr = currentclamp)
|
||||
fixed (sbyte* stepindexPtr = stepindex)
|
||||
{
|
||||
for (i = 0; i < Data.SamplesCount; i++)
|
||||
for (c = 0; c < Header.Channels; c++)
|
||||
{
|
||||
samplePtr[c] = (reader.RS(Header.Bytes, Header.Format) * 0x8000).CFTI();
|
||||
value = IMAEncoder(samplePtr[c], ref currentPtr[c],
|
||||
ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
writer.W(value, 4);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < Data.SamplesCount; i++)
|
||||
for (c = 0; c < Header.Channels; c++)
|
||||
{
|
||||
samplePtr[c] = (reader.RS(Header.Bytes, Header.Format) * 0x8000).CFTI();
|
||||
value = IMAEncoder(samplePtr[c], ref currentPtr[c],
|
||||
ref currentclampPtr[c], ref stepindexPtr[c]);
|
||||
writer.W(value, 4);
|
||||
}
|
||||
writer.CW();
|
||||
|
||||
writer.I64P = 0x00;
|
||||
writer.PI64 = 0x00;
|
||||
writer.W("DIVA");
|
||||
writer.W(0x00);
|
||||
writer.W((Data.SamplesCount * Data.Channels).A(2, 2));
|
||||
@@ -119,14 +126,14 @@ namespace KKdSoundLib
|
||||
if ((value & 1) == 1) diff += step >> 2;
|
||||
if ((value & 2) == 2) diff += step >> 1;
|
||||
if ((value & 4) == 4) diff += step;
|
||||
|
||||
|
||||
if ((value & 8) == 8)
|
||||
{ currentclamp -= diff; current = currentclamp;
|
||||
if (currentclamp < -0x8000) currentclamp = -0x8000; }
|
||||
else
|
||||
{ currentclamp += diff; current = currentclamp;
|
||||
if (currentclamp > 0x7FFF) currentclamp = 0x7FFF; }
|
||||
|
||||
|
||||
stepindex += ima_index_table[value & 7];
|
||||
if (stepindex < 0) stepindex = 0;
|
||||
if (stepindex > 88) stepindex = 88;
|
||||
@@ -140,9 +147,9 @@ namespace KKdSoundLib
|
||||
{
|
||||
value = 0;
|
||||
step = ima_step_table[stepindex];
|
||||
|
||||
|
||||
delta = sample - current;
|
||||
|
||||
|
||||
if (delta < 0)
|
||||
{ value |= 8; delta = -delta; }
|
||||
diff = step >> 3;
|
||||
@@ -154,14 +161,14 @@ namespace KKdSoundLib
|
||||
step >>= 1;
|
||||
if (delta > step)
|
||||
{ value |= 1; diff += step; }
|
||||
|
||||
|
||||
if ((value & 8) == 8)
|
||||
{ currentclamp -= diff; current = currentclamp;
|
||||
if (currentclamp < -0x8000) currentclamp = -0x8000; }
|
||||
else
|
||||
{ currentclamp += diff; current = currentclamp;
|
||||
if (currentclamp > 0x7FFF) currentclamp = 0x7FFF; }
|
||||
|
||||
|
||||
stepindex += ima_index_table[value & 0x07];
|
||||
if (stepindex < 0) stepindex = 0;
|
||||
if (stepindex > 88) stepindex = 88;
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace KKdSoundLib
|
||||
_IO.S(Offset + 0x14, 0);
|
||||
if (_IO.RS(4) != "data") return Header;
|
||||
Header.Size = _IO.RU32();
|
||||
Header.HeaderSize = _IO.U32P;
|
||||
Header.HeaderSize = _IO.PU32;
|
||||
Header.IsSupported = true;
|
||||
return Header;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ namespace KKdSoundLib
|
||||
_IO.W("fmt ");
|
||||
if (Header.Format != 0xFFFE) _IO.W(0x10);
|
||||
else _IO.W(0x28);
|
||||
|
||||
|
||||
_IO.W(Header.Format);
|
||||
_IO.W((short)Header.Channels);
|
||||
_IO.W(Header.SampleRate);
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{D8A3F2D7-10CC-5723-EC9A-45D3B9C2DFEA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>KKdSoundLib</RootNamespace>
|
||||
<AssemblyName>KKdSoundLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2019</Copyright>
|
||||
<Description>A simple library for working with Project Diva F/AFT/F2/X/FT audio files</Description>
|
||||
<FileVersion>0.1.1.1</FileVersion>
|
||||
<PackageId>KKdSoundLib</PackageId>
|
||||
<Product>KKdSoundLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Title>KKdSoundLib</Title>
|
||||
<Version>0.1.1.1</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -39,27 +40,7 @@
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="DIVA.cs" />
|
||||
<Compile Include="VAG.cs" />
|
||||
<Compile Include="WAV.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj" />
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj">
|
||||
<Project>{da55bfd3-927e-473c-a779-f9e6365384ae}</Project>
|
||||
<Name>KKdBaseLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj">
|
||||
<Project>{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}</Project>
|
||||
<Name>KKdMainLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("KKdSoundLib")]
|
||||
[assembly: AssemblyDescription("A simple library for working with Project Diva F/AFT/F2/X/FT audio files")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("KKdSoundLib")]
|
||||
[assembly: AssemblyCopyright("korenkonder © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("D8A3F2D7-10CC-5723-EC9A-45D3B9C2DFEA")]
|
||||
[assembly: AssemblyVersion("0.1.1.0")]
|
||||
[assembly: AssemblyFileVersion("0.1.1.0")]
|
||||
|
||||
+288
-248
@@ -14,15 +14,13 @@ namespace KKdSoundLib
|
||||
|
||||
public VAGFile VAGData = new VAGFile();
|
||||
|
||||
public VAG() { VAGData = new VAGFile();
|
||||
HEVAG1Ptr = HEVAG1.GetPtr(); HEVAG2Ptr = HEVAG2.GetPtr();
|
||||
HEVAG3Ptr = HEVAG3.GetPtr(); HEVAG4Ptr = HEVAG4.GetPtr(); }
|
||||
|
||||
public VAG() { VAGData = new VAGFile(); }
|
||||
|
||||
public void VAGReader(string file)
|
||||
{
|
||||
Success = false;
|
||||
if (!File.Exists(file + ".vag")) return;
|
||||
|
||||
|
||||
VAGData = new VAGFile();
|
||||
Stream reader = File.OpenReader(file + ".vag", true);
|
||||
|
||||
@@ -44,28 +42,69 @@ namespace KKdSoundLib
|
||||
ch = VAGData.Channels;
|
||||
VBS = BS * ch;
|
||||
|
||||
four_bit = new int[BS]; four_bitPtr = four_bit .GetPtr();
|
||||
temp_buffer = new int[BS]; temp_bufferPtr = temp_buffer.GetPtr();
|
||||
S1 = new int[VAGData.Channels]; S1Ptr = S1.GetPtr();
|
||||
S2 = new int[VAGData.Channels]; S2Ptr = S2.GetPtr();
|
||||
S3 = new int[VAGData.Channels]; S3Ptr = S3.GetPtr();
|
||||
S4 = new int[VAGData.Channels]; S4Ptr = S4.GetPtr();
|
||||
if (VAGData.Size + 0x30 > reader.I64L) VAGData.Size = reader.U32L - 0x30;
|
||||
four_bit = new int[BS]; temp_buffer = new int[BS];
|
||||
|
||||
S1 = new int[VAGData.Channels]; S2 = new int[VAGData.Channels];
|
||||
S3 = new int[VAGData.Channels]; S4 = new int[VAGData.Channels];
|
||||
if (VAGData.Size + 0x30 > reader.LI64) VAGData.Size = reader.LU32 - 0x30;
|
||||
VAGData.Size = (VAGData.Size / VAGData.Channels) >> 4;
|
||||
VAGData.Flags = new byte [VAGData.Size];
|
||||
VAGData.Data = new int[VAGData.Size * VBS];
|
||||
VAGData.DataPtr = VAGData.Data.GetPtr();
|
||||
VAGData.OriginDataPtr = VAGData.DataPtr;
|
||||
fixed (int* four_bitPtr = four_bit)
|
||||
fixed (int* temp_bufferPtr = temp_buffer)
|
||||
fixed (int* S1Ptr = S1)
|
||||
fixed (int* S2Ptr = S2)
|
||||
fixed (int* S3Ptr = S3)
|
||||
fixed (int* S4Ptr = S4)
|
||||
fixed (int* HEVAG1Ptr = HEVAG1)
|
||||
fixed (int* HEVAG2Ptr = HEVAG2)
|
||||
fixed (int* HEVAG3Ptr = HEVAG3)
|
||||
fixed (int* HEVAG4Ptr = HEVAG4)
|
||||
fixed (int* dataPtr = VAGData.Data)
|
||||
{
|
||||
int* localDataPtr = dataPtr;
|
||||
if (HEVAG)
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++, localDataPtr += VBS)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
s = reader.RU8();
|
||||
PrNR = (s & 0xF0) >> 4;
|
||||
ShF = s & 0x0F;
|
||||
s = reader.RU8();
|
||||
PrNR = (s & 0xF0) | PrNR;
|
||||
VAGData.Flags[i1] = (byte)(s & 0xF);
|
||||
|
||||
if (HEVAG)
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
for (c = 0; c < ch; c++)
|
||||
for (i = 0, i2 = 1; i < BS; i += 2, i2 += 2)
|
||||
{
|
||||
s = reader.RU8();
|
||||
four_bitPtr[i ] = s & 0x0F;
|
||||
four_bitPtr[i2] = s & 0xF0;
|
||||
four_bitPtr[i2] >>= 4;
|
||||
}
|
||||
|
||||
HEVAG_1 = HEVAG1Ptr[PrNR]; HEVAG_2 = HEVAG2Ptr[PrNR];
|
||||
HEVAG_3 = HEVAG3Ptr[PrNR]; HEVAG_4 = HEVAG4Ptr[PrNR];
|
||||
tS1 = S1Ptr[c]; tS2 = S2Ptr[c]; tS3 = S3Ptr[c]; tS4 = S4Ptr[c];
|
||||
ShFf = 20 - ShF;
|
||||
for (i = 0; i < BS; i++)
|
||||
{
|
||||
d0 = four_bitPtr[i];
|
||||
d0 = (d0 > 7 ? d0 - 16 : d0) << ShFf;
|
||||
|
||||
g = ((tS1 * HEVAG_1 + tS2 * HEVAG_2 +
|
||||
tS3 * HEVAG_3 + tS4 * HEVAG_4) >> 5) + d0;
|
||||
tS4 = tS3; tS3 = tS2; tS2 = tS1; tS1 = g >> 8;
|
||||
localDataPtr[i * ch + c] = g;
|
||||
}
|
||||
S1Ptr[c] = tS1; S2Ptr[c] = tS2; S3Ptr[c] = tS3; S4Ptr[c] = tS4;
|
||||
}
|
||||
else
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++, localDataPtr += VBS)
|
||||
{
|
||||
s = reader.RU8();
|
||||
PrNR = (s & 0xF0) >> 4;
|
||||
ShF = s & 0x0F;
|
||||
s = reader.RU8();
|
||||
PrNR = (s & 0xF0) | PrNR;
|
||||
VAGData.Flags[i1] = (byte)(s & 0xF);
|
||||
|
||||
for (i = 0, i2 = 1; i < BS; i += 2, i2 += 2)
|
||||
@@ -77,58 +116,26 @@ namespace KKdSoundLib
|
||||
}
|
||||
|
||||
HEVAG_1 = HEVAG1Ptr[PrNR]; HEVAG_2 = HEVAG2Ptr[PrNR];
|
||||
HEVAG_3 = HEVAG3Ptr[PrNR]; HEVAG_4 = HEVAG4Ptr[PrNR];
|
||||
tS1 = S1Ptr[c]; tS2 = S2Ptr[c]; tS3 = S3Ptr[c]; tS4 = S4Ptr[c];
|
||||
tS1 = S1Ptr[c]; tS2 = S2Ptr[c];
|
||||
ShFf = 20 - ShF;
|
||||
i = 0;
|
||||
for (i = 0; i < BS; i++)
|
||||
{
|
||||
d0 = four_bitPtr[i];
|
||||
d0 = (d0 > 7 ? d0 - 16 : d0) << ShFf;
|
||||
|
||||
g = ((tS1 * HEVAG_1 + tS2 * HEVAG_2 +
|
||||
tS3 * HEVAG_3 + tS4 * HEVAG_4) >> 5) + d0;
|
||||
tS4 = tS3; tS3 = tS2; tS2 = tS1; tS1 = g >> 8;
|
||||
VAGData.DataPtr[i * ch + c] = g;
|
||||
g = ((tS1 * HEVAG_1 + tS2 * HEVAG_2) >> 5) + d0;
|
||||
tS2 = tS1; tS1 = g >> 8;
|
||||
localDataPtr[i * ch + c] = g;
|
||||
}
|
||||
S1Ptr[c] = tS1; S2Ptr[c] = tS2; S3Ptr[c] = tS3; S4Ptr[c] = tS4;
|
||||
S1Ptr[c] = tS1; S2Ptr[c] = tS2;
|
||||
}
|
||||
else
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
{
|
||||
s = reader.RU8();
|
||||
PrNR = (s & 0xF0) >> 4;
|
||||
ShF = s & 0x0F;
|
||||
s = reader.RU8();
|
||||
VAGData.Flags[i1] = (byte)(s & 0xF);
|
||||
|
||||
for (i = 0, i2 = 1; i < BS; i += 2, i2 += 2)
|
||||
{
|
||||
s = reader.RU8();
|
||||
four_bitPtr[i ] = s & 0x0F;
|
||||
four_bitPtr[i2] = s & 0xF0;
|
||||
four_bitPtr[i2] >>= 4;
|
||||
}
|
||||
|
||||
HEVAG_1 = HEVAG1Ptr[PrNR]; HEVAG_2 = HEVAG2Ptr[PrNR];
|
||||
tS1 = S1Ptr[c]; tS2 = S2Ptr[c];
|
||||
ShFf = 20 - ShF;
|
||||
i = 0;
|
||||
for (i = 0; i < BS; i++)
|
||||
{
|
||||
d0 = four_bitPtr[i];
|
||||
d0 = (d0 > 7 ? d0 - 16 : d0) << ShFf;
|
||||
|
||||
g = ((tS1 * HEVAG_1 + tS2 * HEVAG_2) >> 5) + d0;
|
||||
tS2 = tS1; tS1 = g >> 8;
|
||||
VAGData.DataPtr[i * ch + c] = g;
|
||||
}
|
||||
S1Ptr[c] = tS1; S2Ptr[c] = tS2;
|
||||
}
|
||||
}
|
||||
|
||||
reader.C();
|
||||
Success = true;
|
||||
}
|
||||
|
||||
|
||||
public void WAVWriterStraight(string file, bool IgnoreEndFlags = false)
|
||||
{
|
||||
if (!Success) return;
|
||||
@@ -136,31 +143,16 @@ namespace KKdSoundLib
|
||||
if (Flag == 7) return;
|
||||
WAV.Header Header = new WAV.Header();
|
||||
Stream writer = File.OpenWriter(file + ".wav", true);
|
||||
writer.I64P = 0x2C;
|
||||
writer.PI64 = 0x2C;
|
||||
|
||||
VAGData.DataPtr = VAGData.Data.GetPtr();
|
||||
VAGData.OriginDataPtr = VAGData.DataPtr;
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.W(f);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.W(0f);
|
||||
|
||||
for (i1 = 0, i2 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
fixed (int* dataPtr = VAGData.Data)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (!IgnoreEndFlags && (Flag == 5 || Flag == 7)) break;
|
||||
int* localDataPtr = dataPtr;
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
f = (float)(localDataPtr[i * ch + c] / 8388608.0);
|
||||
writer.W(f);
|
||||
}
|
||||
else
|
||||
@@ -168,11 +160,28 @@ namespace KKdSoundLib
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.W(0f);
|
||||
|
||||
if (!IgnoreEndFlags && Flag == 1) break;
|
||||
for (i1 = 0, i2 = 0; i1 < VAGData.Size; i1++, localDataPtr += VBS)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (!IgnoreEndFlags && (Flag == 5 || Flag == 7)) break;
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(localDataPtr[i * ch + c] / 8388608.0);
|
||||
writer.W(f);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.W(0f);
|
||||
|
||||
if (!IgnoreEndFlags && Flag == 1) break;
|
||||
}
|
||||
}
|
||||
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
VAGData.SampleRate, Size = writer.U32P - 0x2C };
|
||||
VAGData.SampleRate, Size = writer.PU32 - 0x2C };
|
||||
writer.W(Header, 0);
|
||||
writer.C();
|
||||
}
|
||||
@@ -186,45 +195,16 @@ namespace KKdSoundLib
|
||||
Stream writer;
|
||||
if (!IgnoreEndFlags && Flag == 6) writer = File.OpenWriter(file + ".loop.0.wav", true);
|
||||
else writer = File.OpenWriter(file + ".0.wav", true);
|
||||
writer.I64P = 0x2C;
|
||||
writer.PI64 = 0x2C;
|
||||
|
||||
VAGData.DataPtr = VAGData.Data.GetPtr();
|
||||
VAGData.OriginDataPtr = VAGData.DataPtr;
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
writer.W(f);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.W(0f);
|
||||
|
||||
VAGData.DataPtr += VBS;
|
||||
|
||||
for (i1 = 1, i2 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
fixed (int* dataPtr = VAGData.Data)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (!IgnoreEndFlags && (Flag == 5 || Flag == 7)) break;
|
||||
else if (!IgnoreEndFlags && Flag == 6)
|
||||
{
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
VAGData.SampleRate, Size = writer.U32P - 0x2C };
|
||||
writer.W(Header, 0);
|
||||
writer.C();
|
||||
i2++;
|
||||
|
||||
writer = File.OpenWriter(file + "." + i2 + ".loop.wav", true);
|
||||
writer.I64P = 0x2C;
|
||||
}
|
||||
|
||||
if (!IgnoreEndFlags && Flag < 8)
|
||||
int* localDataPtr = dataPtr;
|
||||
if (Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(VAGData.DataPtr[i * ch + c] / 8388608.0);
|
||||
f = (float)(localDataPtr[i * ch + c] / 8388608.0);
|
||||
writer.W(f);
|
||||
}
|
||||
else
|
||||
@@ -232,25 +212,56 @@ namespace KKdSoundLib
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.W(0f);
|
||||
|
||||
if (!IgnoreEndFlags && Flag == 1) break;
|
||||
else if (!IgnoreEndFlags && Flag == 3)
|
||||
{
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
VAGData.SampleRate, Size = writer.U32P - 0x2C };
|
||||
writer.W(Header, 0);
|
||||
writer.C();
|
||||
i2++;
|
||||
localDataPtr += VBS;
|
||||
|
||||
if (VAGData.Size == i1 + 1)
|
||||
writer = File.OpenWriter();
|
||||
for (i1 = 1, i2 = 0; i1 < VAGData.Size; i1++, localDataPtr += VBS)
|
||||
{
|
||||
Flag = VAGData.Flags[i1];
|
||||
if (!IgnoreEndFlags && (Flag == 5 || Flag == 7)) break;
|
||||
else if (!IgnoreEndFlags && Flag == 6)
|
||||
{
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
VAGData.SampleRate, Size = writer.PU32 - 0x2C };
|
||||
writer.W(Header, 0);
|
||||
writer.C();
|
||||
i2++;
|
||||
|
||||
writer = File.OpenWriter(file + "." + i2 + ".loop.wav", true);
|
||||
writer.PI64 = 0x2C;
|
||||
}
|
||||
|
||||
if (!IgnoreEndFlags && Flag < 8)
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
f = (float)(localDataPtr[i * ch + c] / 8388608.0);
|
||||
writer.W(f);
|
||||
}
|
||||
else
|
||||
writer = File.OpenWriter(file + "." + i2 + ".wav", true);
|
||||
writer.I64P = 0x2C;
|
||||
for (i = 0; i < BS; i++)
|
||||
for (c = 0; c < ch; c++)
|
||||
writer.W(0f);
|
||||
|
||||
if (!IgnoreEndFlags && Flag == 1) break;
|
||||
else if (!IgnoreEndFlags && Flag == 3)
|
||||
{
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
VAGData.SampleRate, Size = writer.PU32 - 0x2C };
|
||||
writer.W(Header, 0);
|
||||
writer.C();
|
||||
i2++;
|
||||
|
||||
if (VAGData.Size == i1 + 1)
|
||||
writer = File.OpenWriter();
|
||||
else
|
||||
writer = File.OpenWriter(file + "." + i2 + ".wav", true);
|
||||
writer.PI64 = 0x2C;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Header = new WAV.Header { Bytes = 4, Channels = ch, Format = 3, SampleRate =
|
||||
VAGData.SampleRate, Size = writer.U32P - 0x2C };
|
||||
VAGData.SampleRate, Size = writer.PU32 - 0x2C };
|
||||
writer.W(Header, 0);
|
||||
writer.C();
|
||||
}
|
||||
@@ -267,27 +278,28 @@ namespace KKdSoundLib
|
||||
|
||||
VAGData.Size = Header.Size / Header.Bytes;
|
||||
VAGData.Data = new int[VAGData.Size.A(VBS)];
|
||||
VAGData.DataPtr = VAGData.Data.GetPtr();
|
||||
VAGData.OriginDataPtr = VAGData.DataPtr;
|
||||
|
||||
if (Header.Bytes == 1 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = (reader.RU8 () - 0x80) << 16;
|
||||
else if (Header.Bytes == 2 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = reader.RI16 () << 8;
|
||||
else if (Header.Bytes == 3 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = reader.RU8 () | (reader.RI16() << 8);
|
||||
else if (Header.Bytes == 4 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = reader.RI32 () >> 8;
|
||||
else if (Header.Bytes == 4 && Header.Format == 0x03)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = (int)(reader.RF32() * 8388608.0);
|
||||
else if (Header.Bytes == 8 && Header.Format == 0x03)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = (int)(reader.RF64() * 8388608.0);
|
||||
fixed (int* dataPtr = VAGData.Data)
|
||||
{
|
||||
int* localDataPtr = dataPtr;
|
||||
if (Header.Bytes == 1 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, localDataPtr++)
|
||||
*localDataPtr = (reader.RU8 () - 0x80) << 16;
|
||||
else if (Header.Bytes == 2 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, localDataPtr++)
|
||||
*localDataPtr = reader.RI16 () << 8;
|
||||
else if (Header.Bytes == 3 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, localDataPtr++)
|
||||
*localDataPtr = reader.RU8 () | (reader.RI16() << 8);
|
||||
else if (Header.Bytes == 4 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, localDataPtr++)
|
||||
*localDataPtr = reader.RI32 () >> 8;
|
||||
else if (Header.Bytes == 4 && Header.Format == 0x03)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, localDataPtr++)
|
||||
*localDataPtr = (int)(reader.RF32() * 8388608.0);
|
||||
else if (Header.Bytes == 8 && Header.Format == 0x03)
|
||||
for (int i1 = 0; i1 < VAGData.Size; i1++, localDataPtr++)
|
||||
*localDataPtr = (int)(reader.RF64() * 8388608.0);
|
||||
}
|
||||
|
||||
VAGData.Size = VAGData.Size.A(VBS, VBS);
|
||||
VAGData.Channels = ch;
|
||||
@@ -311,7 +323,7 @@ namespace KKdSoundLib
|
||||
if (!file.EndsWith(".0")) return WAVReaderStraight(file);
|
||||
file = file.Remove(file.Length - 2);
|
||||
i2 = 0;
|
||||
System.Collections.Generic.List<string> files =
|
||||
System.Collections.Generic.List<string> files =
|
||||
new System.Collections.Generic.List<string>();
|
||||
System.Collections.Generic.List< bool> loop =
|
||||
new System.Collections.Generic.List< bool>();
|
||||
@@ -350,12 +362,10 @@ namespace KKdSoundLib
|
||||
Size += Sizes[i].A(VBS);
|
||||
reader.C();
|
||||
}
|
||||
|
||||
|
||||
VAGData.Size = Size / VBS;
|
||||
VAGData.Data = new int[Size];
|
||||
VAGData.Flags = new byte[VAGData.Size];
|
||||
VAGData.DataPtr = VAGData.Data.GetPtr();
|
||||
VAGData.OriginDataPtr = VAGData.DataPtr;
|
||||
|
||||
if (HasLoop)
|
||||
for (i = 0; i < VAGData.Size; i++)
|
||||
@@ -363,43 +373,47 @@ namespace KKdSoundLib
|
||||
|
||||
i2 = 0;
|
||||
uint Start = 0, End = 0;
|
||||
for (i = 0; i < Files.Length; i++)
|
||||
fixed (int* dataPtr = VAGData.Data)
|
||||
{
|
||||
reader = File.OpenReader(Files[i]);
|
||||
Header = reader.ReadWAVHeader();
|
||||
if (Header.Bytes == 1 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = (reader.RU8 () - 0x80) << 16;
|
||||
else if (Header.Bytes == 2 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = reader.RI16 () << 8;
|
||||
else if (Header.Bytes == 3 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = reader.RU8 () | (reader.RI16() << 8);
|
||||
else if (Header.Bytes == 4 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = reader.RI32 () >> 8;
|
||||
else if (Header.Bytes == 4 && Header.Format == 0x03)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = (int)(reader.RF32() * 8388608.0);
|
||||
else if (Header.Bytes == 8 && Header.Format == 0x03)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, VAGData.DataPtr++)
|
||||
*VAGData.DataPtr = (int)(reader.RF64() * 8388608.0);
|
||||
reader.C();
|
||||
int* localDataPtr = dataPtr;
|
||||
for (i = 0; i < Files.Length; i++)
|
||||
{
|
||||
reader = File.OpenReader(Files[i]);
|
||||
Header = reader.ReadWAVHeader();
|
||||
if (Header.Bytes == 1 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, localDataPtr++)
|
||||
*localDataPtr = (reader.RU8 () - 0x80) << 16;
|
||||
else if (Header.Bytes == 2 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, localDataPtr++)
|
||||
*localDataPtr = reader.RI16 () << 8;
|
||||
else if (Header.Bytes == 3 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, localDataPtr++)
|
||||
*localDataPtr = reader.RU8 () | (reader.RI16() << 8);
|
||||
else if (Header.Bytes == 4 && Header.Format == 0x01)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, localDataPtr++)
|
||||
*localDataPtr = reader.RI32 () >> 8;
|
||||
else if (Header.Bytes == 4 && Header.Format == 0x03)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, localDataPtr++)
|
||||
*localDataPtr = (int)(reader.RF32() * 8388608.0);
|
||||
else if (Header.Bytes == 8 && Header.Format == 0x03)
|
||||
for (int i1 = 0; i1 < Sizes[i]; i1++, localDataPtr++)
|
||||
*localDataPtr = (int)(reader.RF64() * 8388608.0);
|
||||
reader.C();
|
||||
|
||||
AlignVAG = Sizes[i].A(VBS) - Sizes[i];
|
||||
VAGData.DataPtr += AlignVAG;
|
||||
AlignVAG = Sizes[i].A(VBS) - Sizes[i];
|
||||
localDataPtr += AlignVAG;
|
||||
|
||||
AlignVAG = (Sizes[i] + AlignVAG) / VBS;
|
||||
End += AlignVAG;
|
||||
End--;
|
||||
if (Loop[i] ) { VAGData.Flags[Start] = 0x6; VAGData.Flags[End] = 0x3; }
|
||||
else if (ExtendedFlagging) VAGData.Flags[Start] = 0x4;
|
||||
if (i + 1 == Files.Length && !Loop[i]) VAGData.Flags[End] = 0x1;
|
||||
Start += AlignVAG;
|
||||
End++;
|
||||
AlignVAG = (Sizes[i] + AlignVAG) / VBS;
|
||||
End += AlignVAG;
|
||||
End--;
|
||||
if (Loop[i] ) { VAGData.Flags[Start] = 0x6; VAGData.Flags[End] = 0x3; }
|
||||
else if (ExtendedFlagging) VAGData.Flags[Start] = 0x4;
|
||||
if (i + 1 == Files.Length && !Loop[i]) VAGData.Flags[End] = 0x1;
|
||||
Start += AlignVAG;
|
||||
End++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VAGData.Channels = ch;
|
||||
VAGData.SampleRate = SampleRate;
|
||||
|
||||
@@ -415,21 +429,13 @@ namespace KKdSoundLib
|
||||
Stream writer = File.OpenWriter(data);
|
||||
VAGData.Name = Path.GetFileName(file);
|
||||
S1 = new int[ch]; S2 = new int[ch];
|
||||
S3 = new int[ch]; S4 = new int[ch];
|
||||
S3 = new int[ch]; S4 = new int[ch];
|
||||
S_1 = new int[ch]; S_2 = new int[ch];
|
||||
S_3 = new int[ch]; S_4 = new int[ch];
|
||||
PrNRCount = choose == "1" ? 5 : choose == "2" ? 8 : choose == "3" ? 32 :
|
||||
choose == "4" ? 64 : choose == "5" ? 96 : 128;
|
||||
error = new int[PrNRCount]; four_bit = new int[BS];
|
||||
data_buffer = new int[BS]; temp_buffer = new int[BS];
|
||||
errorPtr = error.GetPtr();
|
||||
four_bitPtr = four_bit.GetPtr();
|
||||
data_bufferPtr = data_buffer.GetPtr();
|
||||
temp_bufferPtr = temp_buffer.GetPtr();
|
||||
S1Ptr = S1.GetPtr(); S2Ptr = S2.GetPtr();
|
||||
S3Ptr = S3.GetPtr(); S4Ptr = S4.GetPtr();
|
||||
S_1Ptr = S_1.GetPtr(); S_2Ptr = S_2.GetPtr();
|
||||
S_3Ptr = S_3.GetPtr(); S_4Ptr = S_4.GetPtr();
|
||||
|
||||
writer.W(0x70474156);
|
||||
writer.WE(HEVAG ? 0x00020001 : 0x00000020, true);
|
||||
@@ -441,21 +447,78 @@ namespace KKdSoundLib
|
||||
writer.W((ushort)0);
|
||||
writer.W((ushort)(HEVAG ? VAGData.Channels : 0x1));
|
||||
writer.W(VAGData.Name);
|
||||
writer.I64L = 0x30;
|
||||
writer.I64P = 0x30;
|
||||
writer.LI64 = 0x30;
|
||||
writer.PI64 = 0x30;
|
||||
|
||||
if (HEVAG)
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
for (c = 0; c < ch; c++)
|
||||
fixed (int* errorPtr = error)
|
||||
fixed (int* four_bitPtr = four_bit)
|
||||
fixed (int* data_bufferPtr = data_buffer)
|
||||
fixed (int* temp_bufferPtr = temp_buffer)
|
||||
fixed (int* S1Ptr = S1)
|
||||
fixed (int* S2Ptr = S2)
|
||||
fixed (int* S3Ptr = S3)
|
||||
fixed (int* S4Ptr = S4)
|
||||
fixed (int* S_1Ptr = S_1)
|
||||
fixed (int* S_2Ptr = S_2)
|
||||
fixed (int* S_3Ptr = S_3)
|
||||
fixed (int* S_4Ptr = S_4)
|
||||
fixed (int* HEVAG1Ptr = HEVAG1)
|
||||
fixed (int* HEVAG2Ptr = HEVAG2)
|
||||
fixed (int* HEVAG3Ptr = HEVAG3)
|
||||
fixed (int* HEVAG4Ptr = HEVAG4)
|
||||
fixed (int* dataPtr = VAGData.Data)
|
||||
{
|
||||
this.data_bufferPtr = data_bufferPtr;
|
||||
this.errorPtr = errorPtr;
|
||||
this.four_bitPtr = four_bitPtr;
|
||||
this.temp_bufferPtr = temp_bufferPtr;
|
||||
this.S_1Ptr = S_1Ptr;
|
||||
this.S_2Ptr = S_2Ptr;
|
||||
this.S_3Ptr = S_3Ptr;
|
||||
this.S_4Ptr = S_4Ptr;
|
||||
this.S1Ptr = S1Ptr;
|
||||
this.S2Ptr = S2Ptr;
|
||||
this.S3Ptr = S3Ptr;
|
||||
this.S4Ptr = S4Ptr;
|
||||
this.HEVAG1Ptr = HEVAG1Ptr;
|
||||
this.HEVAG2Ptr = HEVAG2Ptr;
|
||||
this.HEVAG3Ptr = HEVAG3Ptr;
|
||||
this.HEVAG4Ptr = HEVAG4Ptr;
|
||||
|
||||
if (HEVAG)
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++)
|
||||
for (c = 0; c < ch; c++)
|
||||
{
|
||||
for (i = 0, s = 0; i < BS; i++)
|
||||
data_bufferPtr[i] = dataPtr[i1 * BS * ch + i * ch + c];
|
||||
|
||||
Calc4BitsHEVAG();
|
||||
|
||||
s = ((PrNR & 0xF) << 4) | (ShF & 0xF);
|
||||
writer.W((byte)s);
|
||||
s = (PrNR & 0xF0) | (VAGData.Flags[i1] & 0xF);
|
||||
writer.W((byte)s);
|
||||
for (i = 0, i2 = 1; i < BS; i += 2, i2 += 2)
|
||||
{
|
||||
s = ((four_bitPtr[i2] & 0xF) << 4) | (four_bitPtr[i] & 0xF);
|
||||
writer.W((byte)s);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++)
|
||||
{
|
||||
for (i = 0, s = 0; i < BS; i++)
|
||||
data_bufferPtr[i] = VAGData.OriginDataPtr[i1 * BS * ch + i * ch + c];
|
||||
for (i = 0; i < BS; i++)
|
||||
{
|
||||
for (c = 0, s = 0, data_bufferPtr[i] = 0; c < ch; c++)
|
||||
data_bufferPtr[i] += dataPtr[i1 * BS * ch + i * ch + c];
|
||||
data_bufferPtr[i] /= ch;
|
||||
}
|
||||
|
||||
Calc4BitsHEVAG();
|
||||
Calc4BitsVAG();
|
||||
|
||||
s = ((PrNR & 0xF) << 4) | (ShF & 0xF);
|
||||
writer.W((byte)s);
|
||||
s = (PrNR & 0xF0) | (VAGData.Flags[i1] & 0xF);
|
||||
s = VAGData.Flags[i1] & 0xF;
|
||||
writer.W((byte)s);
|
||||
for (i = 0, i2 = 1; i < BS; i += 2, i2 += 2)
|
||||
{
|
||||
@@ -463,28 +526,7 @@ namespace KKdSoundLib
|
||||
writer.W((byte)s);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS)
|
||||
{
|
||||
for (i = 0; i < BS; i++)
|
||||
{
|
||||
for (c = 0, s = 0, data_bufferPtr[i] = 0; c < ch; c++)
|
||||
data_bufferPtr[i] += VAGData.OriginDataPtr[i1 * BS * ch + i * ch + c];
|
||||
data_bufferPtr[i] /= ch;
|
||||
}
|
||||
|
||||
Calc4BitsVAG();
|
||||
|
||||
s = ((PrNR & 0xF) << 4) | (ShF & 0xF);
|
||||
writer.W((byte)s);
|
||||
s = VAGData.Flags[i1] & 0xF;
|
||||
writer.W((byte)s);
|
||||
for (i = 0, i2 = 1; i < BS; i += 2, i2 += 2)
|
||||
{
|
||||
s = ((four_bitPtr[i2] & 0xF) << 4) | (four_bitPtr[i] & 0xF);
|
||||
writer.W((byte)s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!HEVAG) ch = 1;
|
||||
for (c = 0; c < ch; c++)
|
||||
@@ -501,10 +543,10 @@ namespace KKdSoundLib
|
||||
private int max, min, ShM, s1, s2, s3, s4, tS1, tS2, tS3, tS4, PrNRf, ShFf;
|
||||
private int HEVAG_1, HEVAG_2, HEVAG_3, HEVAG_4;
|
||||
private int[] data_buffer, error, four_bit, temp_buffer;
|
||||
private int* data_bufferPtr, errorPtr, four_bitPtr, temp_bufferPtr;
|
||||
private int[] S_1, S_2, S_3, S_4, S1, S2, S3, S4;
|
||||
private int* data_bufferPtr, errorPtr, four_bitPtr, temp_bufferPtr;
|
||||
private int* S_1Ptr, S_2Ptr, S_3Ptr, S_4Ptr, S1Ptr, S2Ptr, S3Ptr, S4Ptr;
|
||||
|
||||
|
||||
private void Calc4BitsVAG()
|
||||
{
|
||||
min = 0x7FFFFFFF;
|
||||
@@ -514,7 +556,7 @@ namespace KKdSoundLib
|
||||
PrNR = j;
|
||||
|
||||
Calc4Bits_VAG();
|
||||
|
||||
|
||||
tS1 = S1Ptr[c]; tS2 = S2Ptr[c];
|
||||
errorPtr[j] = 0;
|
||||
for (i = 0; i < BS; i++)
|
||||
@@ -525,8 +567,8 @@ namespace KKdSoundLib
|
||||
g = ((tS1 * HEVAG_1 + tS2 * HEVAG_2) >> 5) + d0;
|
||||
tS2 = tS1; tS1 = g >> 8;
|
||||
e = data_bufferPtr[i] - g;
|
||||
if (e < 0) e = -e;
|
||||
errorPtr[j] += e;
|
||||
if (e < 0) errorPtr[j] -= e;
|
||||
else errorPtr[j] += e;
|
||||
}
|
||||
|
||||
if (errorPtr[j] < min) { PrNRf = j; min = errorPtr[j]; }
|
||||
@@ -548,11 +590,11 @@ namespace KKdSoundLib
|
||||
g = data_bufferPtr[i];
|
||||
e = (s1 * HEVAG_1 + s2 * HEVAG_2) >> 5;
|
||||
e = g - e;
|
||||
if (e > 0x77FFFF) e = 0x77FFFF;
|
||||
if (e < -0x780000) e = -0x780000;
|
||||
if (e > 0x77FFFF) e = 0x77FFFF;
|
||||
else if (e < -0x780000) e = -0x780000;
|
||||
temp_bufferPtr[i] = e;
|
||||
if (e < 0) e = -e;
|
||||
if (e > max) max = e;
|
||||
if ( e > max) max = e;
|
||||
else if (-e > max) max = -e;
|
||||
s4 = s3; s3 = s2; s2 = s1; s1 = g >> 8;
|
||||
}
|
||||
|
||||
@@ -569,15 +611,15 @@ namespace KKdSoundLib
|
||||
|
||||
d1 = e << ShF;
|
||||
d0 = (d1 + 0x80000) >> 20;
|
||||
if (d0 > 7) d0 = 7;
|
||||
if (d0 < -8) d0 = -8;
|
||||
if (d0 > 7) d0 = 7;
|
||||
else if (d0 < -8) d0 = -8;
|
||||
four_bitPtr[i] = d0;
|
||||
d0 <<= ShFf;
|
||||
|
||||
tS2 = tS1; tS1 = (d0 - e) >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Calc4BitsHEVAG()
|
||||
{
|
||||
min = 0x7FFFFFFF;
|
||||
@@ -587,7 +629,7 @@ namespace KKdSoundLib
|
||||
PrNR = j;
|
||||
|
||||
Calc4Bits_HEVAG();
|
||||
|
||||
|
||||
tS1 = S1Ptr[c]; tS2 = S2Ptr[c]; tS3 = S3Ptr[c]; tS4 = S4Ptr[c];
|
||||
errorPtr[j] = 0;
|
||||
for (i = 0; i < BS; i++)
|
||||
@@ -599,8 +641,8 @@ namespace KKdSoundLib
|
||||
tS3 * HEVAG_3 + tS4 * HEVAG_4) >> 5) + d0;
|
||||
tS4 = tS3; tS3 = tS2; tS2 = tS1; tS1 = g >> 8;
|
||||
e = data_bufferPtr[i] - g;
|
||||
if (e < 0) e = -e;
|
||||
errorPtr[j] += e;
|
||||
if (e < 0) errorPtr[j] -= e;
|
||||
else errorPtr[j] += e;
|
||||
}
|
||||
|
||||
if (errorPtr[j] < min) { PrNRf = j; min = errorPtr[j]; }
|
||||
@@ -624,16 +666,16 @@ namespace KKdSoundLib
|
||||
e = (s1 * HEVAG_1 + s2 * HEVAG_2 +
|
||||
s3 * HEVAG_3 + s4 * HEVAG_4) >> 5;
|
||||
e = g - e;
|
||||
if (e > 0x77FFFF) e = 0x77FFFF;
|
||||
if (e < -0x780000) e = -0x780000;
|
||||
if (e > 0x77FFFF) e = 0x77FFFF;
|
||||
else if (e < -0x780000) e = -0x780000;
|
||||
temp_bufferPtr[i] = e;
|
||||
if (e < 0) e = -e;
|
||||
if (e > max) max = e;
|
||||
if ( e > max) max = e;
|
||||
else if (-e > max) max = -e;
|
||||
s4 = s3; s3 = s2; s2 = s1; s1 = g >> 8;
|
||||
}
|
||||
|
||||
for (ShF = 0, ShM = 0x400000; ShF < 15; ShF++, ShM >>= 1)
|
||||
{ e = max + (ShM >> 3); if ((ShM & e) == ShM) break; }
|
||||
{ e = max + (ShM >> 4); if ((ShM & e) == ShM) break; }
|
||||
ShFf = 20 - ShF;
|
||||
|
||||
tS1 = S_1Ptr[c]; tS2 = S_2Ptr[c]; tS3 = S_3Ptr[c]; tS4 = S_4Ptr[c];
|
||||
@@ -646,8 +688,8 @@ namespace KKdSoundLib
|
||||
|
||||
d1 = e << ShF;
|
||||
d0 = (d1 + 0x80000) >> 20;
|
||||
if (d0 > 7) d0 = 7;
|
||||
if (d0 < -8) d0 = -8;
|
||||
if (d0 > 7) d0 = 7;
|
||||
else if (d0 < -8) d0 = -8;
|
||||
four_bitPtr[i] = d0;
|
||||
d0 <<= ShFf;
|
||||
|
||||
@@ -669,8 +711,6 @@ namespace KKdSoundLib
|
||||
public string Name;
|
||||
public byte[] Flags;
|
||||
public int[] Data;
|
||||
public int* DataPtr;
|
||||
public int* OriginDataPtr;
|
||||
}
|
||||
|
||||
private int* HEVAG1Ptr, HEVAG2Ptr, HEVAG3Ptr, HEVAG4Ptr;
|
||||
|
||||
+102
-3
@@ -11,6 +11,7 @@
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -69,14 +70,112 @@
|
||||
<Name>KKdBaseLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj">
|
||||
<Project>{2BA7EFC6-91D1-8BBC-C487-06C7F36CC789}</Project>
|
||||
<Project>{2ba7efc6-91d1-8bbc-c487-06c7f36cc789}</Project>
|
||||
<Name>KKdMainLib</Name>
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdSoundLib\KKdSoundLib.csproj">
|
||||
<Project>{D8A3F2D7-10CC-5723-EC9A-45D3B9C2DF77}</Project>
|
||||
<Project>{d8a3f2d7-10cc-5723-ec9a-45d3b9c2df77}</Project>
|
||||
<Name>KKdSoundLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>del Microsoft.Win32.Primitives.dll
|
||||
del netstandard.dll
|
||||
del PD_Tool.exe.config
|
||||
del System.AppContext.dll
|
||||
del System.Collections.Concurrent.dll
|
||||
del System.Collections.dll
|
||||
del System.Collections.NonGeneric.dll
|
||||
del System.Collections.Specialized.dll
|
||||
del System.ComponentModel.dll
|
||||
del System.ComponentModel.EventBasedAsync.dll
|
||||
del System.ComponentModel.Primitives.dll
|
||||
del System.ComponentModel.TypeConverter.dll
|
||||
del System.Console.dll
|
||||
del System.Data.Common.dll
|
||||
del System.Diagnostics.Contracts.dll
|
||||
del System.Diagnostics.Debug.dll
|
||||
del System.Diagnostics.FileVersionInfo.dll
|
||||
del System.Diagnostics.Process.dll
|
||||
del System.Diagnostics.StackTrace.dll
|
||||
del System.Diagnostics.TextWriterTraceListener.dll
|
||||
del System.Diagnostics.Tools.dll
|
||||
del System.Diagnostics.TraceSource.dll
|
||||
del System.Diagnostics.Tracing.dll
|
||||
del System.Drawing.Primitives.dll
|
||||
del System.Dynamic.Runtime.dll
|
||||
del System.Globalization.Calendars.dll
|
||||
del System.Globalization.dll
|
||||
del System.Globalization.Extensions.dll
|
||||
del System.IO.Compression.dll
|
||||
del System.IO.Compression.ZipFile.dll
|
||||
del System.IO.dll
|
||||
del System.IO.FileSystem.dll
|
||||
del System.IO.FileSystem.DriveInfo.dll
|
||||
del System.IO.FileSystem.Primitives.dll
|
||||
del System.IO.FileSystem.Watcher.dll
|
||||
del System.IO.IsolatedStorage.dll
|
||||
del System.IO.MemoryMappedFiles.dll
|
||||
del System.IO.Pipes.dll
|
||||
del System.IO.UnmanagedMemoryStream.dll
|
||||
del System.Linq.dll
|
||||
del System.Linq.Expressions.dll
|
||||
del System.Linq.Parallel.dll
|
||||
del System.Linq.Queryable.dll
|
||||
del System.Net.Http.dll
|
||||
del System.Net.NameResolution.dll
|
||||
del System.Net.NetworkInformation.dll
|
||||
del System.Net.Ping.dll
|
||||
del System.Net.Primitives.dll
|
||||
del System.Net.Requests.dll
|
||||
del System.Net.Security.dll
|
||||
del System.Net.Sockets.dll
|
||||
del System.Net.WebHeaderCollection.dll
|
||||
del System.Net.WebSockets.Client.dll
|
||||
del System.Net.WebSockets.dll
|
||||
del System.ObjectModel.dll
|
||||
del System.Reflection.dll
|
||||
del System.Reflection.Extensions.dll
|
||||
del System.Reflection.Primitives.dll
|
||||
del System.Resources.Reader.dll
|
||||
del System.Resources.ResourceManager.dll
|
||||
del System.Resources.Writer.dll
|
||||
del System.Runtime.CompilerServices.VisualC.dll
|
||||
del System.Runtime.dll
|
||||
del System.Runtime.Extensions.dll
|
||||
del System.Runtime.Handles.dll
|
||||
del System.Runtime.InteropServices.dll
|
||||
del System.Runtime.InteropServices.RuntimeInformation.dll
|
||||
del System.Runtime.Numerics.dll
|
||||
del System.Runtime.Serialization.Formatters.dll
|
||||
del System.Runtime.Serialization.Json.dll
|
||||
del System.Runtime.Serialization.Primitives.dll
|
||||
del System.Runtime.Serialization.Xml.dll
|
||||
del System.Security.Claims.dll
|
||||
del System.Security.Cryptography.Algorithms.dll
|
||||
del System.Security.Cryptography.Csp.dll
|
||||
del System.Security.Cryptography.Encoding.dll
|
||||
del System.Security.Cryptography.Primitives.dll
|
||||
del System.Security.Cryptography.X509Certificates.dll
|
||||
del System.Security.Principal.dll
|
||||
del System.Security.SecureString.dll
|
||||
del System.Text.Encoding.dll
|
||||
del System.Text.Encoding.Extensions.dll
|
||||
del System.Text.RegularExpressions.dll
|
||||
del System.Threading.dll
|
||||
del System.Threading.Overlapped.dll
|
||||
del System.Threading.Tasks.dll
|
||||
del System.Threading.Tasks.Parallel.dll
|
||||
del System.Threading.Thread.dll
|
||||
del System.Threading.ThreadPool.dll
|
||||
del System.Threading.Timer.dll
|
||||
del System.ValueTuple.dll
|
||||
del System.Xml.ReaderWriter.dll
|
||||
del System.Xml.XDocument.dll
|
||||
del System.Xml.XmlDocument.dll
|
||||
del System.Xml.XmlSerializer.dll
|
||||
del System.Xml.XPath.dll
|
||||
del System.Xml.XPath.XDocument.dll</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
+5
-5
@@ -233,15 +233,15 @@ namespace PD_Tool
|
||||
GetArgs("STR", true, "str") + bin + json + mp;
|
||||
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:" })
|
||||
if (ofd.ShowDialog() == DialogResult.OK) FileNames = ofd.FileNames;
|
||||
|
||||
using OpenFileDialog ofd = new OpenFileDialog { //InitialDirectory = Application.StartupPath,
|
||||
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,
|
||||
using (OpenFileDialog ofd = new OpenFileDialog { //InitialDirectory = Application.StartupPath,
|
||||
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);
|
||||
|
||||
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
|
||||
[assembly: AssemblyVersion("0.4.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.8.0")]
|
||||
[assembly: AssemblyVersion("0.4.8.1")]
|
||||
[assembly: AssemblyFileVersion("0.4.8.1")]
|
||||
|
||||
+20
-10
@@ -84,15 +84,21 @@ namespace PD_Tool
|
||||
{
|
||||
if (!farc.HeaderReader()) return;
|
||||
if (!farc.HasFiles) return;
|
||||
|
||||
|
||||
KKdList<string> list = KKdList<string>.New;
|
||||
for (int i = 0; i < farc.Files.Length; i++)
|
||||
if (!farc.Files[i].Name.Contains("div") && farc.Files[i].Name.EndsWith(".a3da"))
|
||||
list.Add(farc.Files[i].Name);
|
||||
for (int i = 0; i < farc.Files.Count; i++)
|
||||
{
|
||||
string file = farc.Files[i].Name.ToLower();
|
||||
bool div = false;
|
||||
for (int i0 = 0; i0 < 159 && !div; i0++)
|
||||
if (file.Contains("div_" + i0)) div = true;
|
||||
|
||||
if (!div && file.EndsWith(".a3da")) list.Add(file);
|
||||
}
|
||||
|
||||
KKdList<string> A3DAlist = KKdList<string>.New;
|
||||
for (int i = 0; i < farc.Files.Length; i++)
|
||||
if (farc.Files[i].Name.EndsWith(".a3da"))
|
||||
for (int i = 0; i < farc.Files.Count; i++)
|
||||
if (farc.Files[i].Name.ToLower().EndsWith(".a3da"))
|
||||
A3DAlist.Add(farc.Files[i].Name);
|
||||
|
||||
byte[] data = null;
|
||||
@@ -106,10 +112,12 @@ namespace PD_Tool
|
||||
int state = a3da.A3DAReader(data);
|
||||
if (state == 1)
|
||||
{
|
||||
KKdFARC.FARCFile file = farc.Files[i];
|
||||
a3da.Data._.CompressF16 = format > Format.AFT && format <
|
||||
Format.FT ? format == Format.MGF ? 2 : 1 : 0;
|
||||
a3da.Head.Format = format;
|
||||
farc.Files[i].Data = (choose != "1" && choose != "3") ? a3da.A3DCWriter() : a3da.A3DAWriter();
|
||||
file.Data = (choose != "1" && choose != "3") ? a3da.A3DCWriter() : a3da.A3DAWriter();
|
||||
farc.Files[i] = file;
|
||||
}
|
||||
}
|
||||
farc.Save();
|
||||
@@ -149,14 +157,16 @@ namespace PD_Tool
|
||||
a3daArray[i].Data.PlayControl.Div = null;
|
||||
}
|
||||
|
||||
farc.Files = new KKdFARC.FARCFile[list.Count];
|
||||
farc.Files.Capacity = list.Count;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
farc.Files[i].Name = list[i];
|
||||
KKdFARC.FARCFile file = default;
|
||||
file.Name = list[i];
|
||||
a3daArray[i].Data._.CompressF16 = format > Format.AFT && format <
|
||||
Format.FT ? format == Format.MGF ? 2 : 1 : 0;
|
||||
a3daArray[i].Head.Format = format;
|
||||
farc.Files[i].Data = (choose != "1" && choose != "3") ? a3daArray[i].A3DCWriter() : a3daArray[i].A3DAWriter();
|
||||
file.Data = (choose != "1" && choose != "3") ? a3daArray[i].A3DCWriter() : a3daArray[i].A3DAWriter();
|
||||
farc.Files.Add(file);
|
||||
}
|
||||
farc.Save();
|
||||
return;
|
||||
|
||||
@@ -22,16 +22,16 @@ namespace PD_Tool
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string file = Program.Choose(2, "", out string[] fileNames);
|
||||
Console.Clear();
|
||||
if (file == null || file == "") return;
|
||||
Console.Title = "FARC Creator";
|
||||
|
||||
|
||||
using (KKdFARC farc = new KKdFARC(file, true))
|
||||
{
|
||||
Console.Title = "FARC Creator: " + Path.GetDirectoryName(file);
|
||||
|
||||
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of created FARC:");
|
||||
Program.ConsoleDesign(false);
|
||||
@@ -50,8 +50,8 @@ namespace PD_Tool
|
||||
else if (choose == "3" || choose == "4")
|
||||
{
|
||||
farc.Signature = KKdFARC.Farc.FARC;
|
||||
|
||||
Console.WriteLine();
|
||||
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of FARC:");
|
||||
Program.ConsoleDesign(false);
|
||||
|
||||
Reference in New Issue
Block a user