diff --git a/KKdBaseLib/Auth2D.cs b/KKdBaseLib/Auth2D.cs
index 9b36ed7..bd42748 100644
--- a/KKdBaseLib/Auth2D.cs
+++ b/KKdBaseLib/Auth2D.cs
@@ -1,4 +1,6 @@
-namespace KKdBaseLib.Auth2D
+//Original: AetSet.bt Version: 5.0 by samyuu
+
+namespace KKdBaseLib.Auth2D
{
public struct Header
{
@@ -122,11 +124,46 @@
public enum TransferBlendMode : byte
{
- Alpha = 3,
- Additive = 5,
- DstColorZero = 6,
- SrcAlphaOneMinusSrcColor = 7,
- Transparent = 8,
+ None = 0,
+ Copy = 1,
+ Behind = 2,
+ Normal = 3,
+ Dissolve = 4,
+ Add = 5,
+ Multiply = 6,
+ Screen = 7,
+ Overlay = 8,
+ SoftLight = 9,
+ HardLight = 10,
+ Darken = 11,
+ Lighten = 12,
+ ClassicDifference = 13,
+ Hue = 14,
+ Saturation = 15,
+ Color = 16,
+ Luminosity = 17,
+ StenciilAlpha = 18,
+ StencilLuma = 19,
+ SilhouetteAlpha = 20,
+ SilhouetteLuma = 21,
+ LuminescentPremul = 22,
+ AlphaAdd = 23,
+ ClassicColorDodge = 24,
+ ClassicColorBurn = 25,
+ Exclusion = 26,
+ Difference = 27,
+ ColorDodge = 28,
+ ColorBurn = 29,
+ LinearDodge = 30,
+ LinearBurn = 31,
+ LinearLight = 32,
+ VividLight = 33,
+ PinLight = 34,
+ HardMix = 35,
+ LighterColor = 36,
+ DarkerColor = 37,
+ Subtract = 38,
+ Divide = 39,
}
public enum TransferFlags : byte
diff --git a/KKdBaseLib/KKdBaseLib.csproj b/KKdBaseLib/KKdBaseLib.csproj
index 4a5480d..10e62ad 100644
--- a/KKdBaseLib/KKdBaseLib.csproj
+++ b/KKdBaseLib/KKdBaseLib.csproj
@@ -6,12 +6,12 @@
korenkonder © 2019-2020
A base library
- 0.4.9.0
+ 0.4.9.1
KKdBaseLib
KKdBaseLib
netstandard2.0
KKdBaseLib
- 0.4.9.0
+ 0.4.9.1
AnyCPU
diff --git a/KKdBaseLib/KKdDict.cs b/KKdBaseLib/KKdDict.cs
index 67abf75..edd6812 100644
--- a/KKdBaseLib/KKdDict.cs
+++ b/KKdBaseLib/KKdDict.cs
@@ -49,6 +49,12 @@
set { if (keyArray != null && valArray != null && index < keyArray.Length &&
index < valArray.Length) { keyArray[index] = value.Key; valArray[index] = value.Value; } } }
+ public KeyValuePair this[long index, bool list]
+ { get => keyArray != null && valArray != null && index > -1 && index < keyArray.Length &&
+ index < valArray.Length ? new KeyValuePair(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 TValue this[TKey key]
{ get => valArray != null && valArray.Length > 0 && CK(key, out int index) ? valArray[index] : default;
set { if (valArray != null && valArray.Length > 0) if (CK(key, out int index)) valArray[index] = value; else Add(key, value); } }
diff --git a/KKdBaseLib/KKdList.cs b/KKdBaseLib/KKdList.cs
index 4aa5385..a72ec30 100644
--- a/KKdBaseLib/KKdList.cs
+++ b/KKdBaseLib/KKdList.cs
@@ -43,6 +43,10 @@ namespace KKdBaseLib
{ get => array != null && index < array.Length ? array[index] : default;
set { if (array != null && index < array.Length) array[index] = value; } }
+ public T this[long index]
+ { get => array != null && index < array.Length ? array[index] : default;
+ set { if (array != null && index < array.Length) array[index] = value; } }
+
public IEnumerator GetEnumerator() => enumerator = new Enumerator(array);
IEnumerator IEnumerable.GetEnumerator() => enumerator = new Enumerator(array);
diff --git a/KKdBaseLib/MsgPack.cs b/KKdBaseLib/MsgPack.cs
index eea4454..4928b8c 100644
--- a/KKdBaseLib/MsgPack.cs
+++ b/KKdBaseLib/MsgPack.cs
@@ -36,6 +36,10 @@ namespace KKdBaseLib
{ get => Object is MsgPack[] Array ? Array[index] : default;
set { if (Object is MsgPack[] Array) { Array[index] = value; Object = Array; } } }
+ public MsgPack this[long index]
+ { get => Object is MsgPack[] Array ? Array[index] : default;
+ set { if (Object is MsgPack[] Array) { Array[index] = value; Object = Array; } } }
+
public MsgPack this[string key]
{ get => Object is KKdList List ? List[ElementIndex(key)] : default;
set { if (Object is KKdList List && value.Object != null)
diff --git a/KKdMainLib/AddParam.cs b/KKdMainLib/AddParam.cs
new file mode 100644
index 0000000..f82dcdd
--- /dev/null
+++ b/KKdMainLib/AddParam.cs
@@ -0,0 +1,146 @@
+using KKdBaseLib;
+using KKdMainLib.IO;
+
+namespace KKdMainLib
+{
+ public unsafe struct AddParam : System.IDisposable
+ {
+ private long i;
+ private Stream _IO;
+
+ public HeaderData Header;
+
+ public void MotHeadReader(string file)
+ {
+ Header = new HeaderData();
+
+ _IO = File.OpenReader(file + ".adp");
+ Header.Count = _IO.RI64();
+ Header.DataLength = _IO.RI64();
+ Header.DataOffset = _IO.RI64();
+
+ if (Header.Count < 1 || Header.DataOffset > _IO.P || Header.DataLength > _IO.LI64
+ - Header.DataOffset || Header.Count * 0x20 > _IO.LI64 - Header.DataOffset) { _IO.C(); return; }
+
+ Header.Data = new HeaderData.Sub[Header.Count];
+ byte[] data = _IO.RBy(Header.DataLength, Header.DataOffset);
+ _IO.C();
+
+ fixed (byte* ptr = data)
+ {
+ HeaderData.Sub* hPtr = (HeaderData.Sub*)ptr;
+ for (i = 0; i < Header.Count; i++)
+ Header.Data[i] = hPtr[i];
+ }
+
+ data = null;
+ }
+
+ public void MotHeadWriter(string file)
+ {
+ if (Header.Data == null || Header.Data.LongLength < 1) return;
+
+ Header.Count = Header.Data.LongLength;
+ Header.DataLength = Header.Count * 0x20;
+ Header.DataOffset = 0x18L;
+
+ byte[] data = new byte[Header.DataLength];
+ fixed (byte* ptr = data)
+ {
+ HeaderData.Sub* hPtr = (HeaderData.Sub*)ptr;
+ for (i = 0; i < Header.Count; i++)
+ hPtr[i] = Header.Data[i];
+ }
+
+ _IO = File.OpenWriter(file + ".adp", true);
+ _IO.W(Header.Count);
+ _IO.W(Header.DataLength);
+ _IO.W(Header.DataOffset);
+ _IO.W(data);
+ _IO.C();
+ data = null;
+ }
+
+ public void MsgPackReader(string file, bool json)
+ {
+ Header = new HeaderData();
+
+ MsgPack addParam;
+ MsgPack msgPack = file.ReadMPAllAtOnce(json);
+ if ((addParam = msgPack["AddParam", true]).IsNull) return;
+
+ Header.Count = addParam.Array.LongLength;
+ Header.Data = new HeaderData.Sub[Header.Count];
+ for (i = 0; i < Header.Count; i++)
+ {
+ ref HeaderData.Sub sub = ref Header.Data[i];
+ sub.Time = addParam[i].RF32("Time");
+ sub.Flags = addParam[i].RI32("Flags");
+ sub.Frame = addParam[i].RI32("Frame");
+ sub.ID = addParam[i].RI32("ID");
+ sub.Value = addParam[i].RF32("Value");
+
+ sub.PVBranch = addParam[i].RnI32("PVBranch") ?? 0;
+ float? f = addParam[i].RnF32("Value");
+ if (f.HasValue)
+ {
+ if (sub.ID == 0) { float v = 0; *(uint*)&v = addParam[i].RU32("Value"); sub.Value = v; }
+ else sub.Value = f.Value;
+ }
+ else { float v = 0; *(uint*)&v = 0xFFFFFFFF; sub.Value = v; }
+
+ }
+
+ msgPack.Dispose();
+ }
+
+ public void MsgPackWriter(string file, bool json)
+ {
+ if (Header.Data == null || Header.Data.LongLength < 1) return;
+
+ MsgPack addParam = new MsgPack(Header.Data.LongLength, "AddParam");
+ fixed (HeaderData.Sub* ptr = Header.Data)
+ for (i = 0; i < Header.Count; i++)
+ {
+ ref HeaderData.Sub sub = ref Header.Data[i];
+ addParam[i] = MsgPack.New.Add("Time", sub.Time).Add("Flags", sub.Flags).Add("Frame", sub.Frame);
+
+ if (sub.PVBranch > 0)
+ addParam[i] = addParam[i].Add("PVBranch", sub.PVBranch);
+
+ addParam[i] = addParam[i].Add("ID", sub.ID);
+
+ if (sub.ID == 0)
+ addParam[i] = addParam[i].Add("Value", *(uint*)&ptr[i].Value);
+ else if (*(uint*)&ptr[i].Value != 0xFFFFFFFF)
+ addParam[i] = addParam[i].Add("Value", sub.Value);
+
+ }
+ addParam.WriteAfterAll(true, file, json);
+ }
+
+ public void Dispose()
+ { if (_IO != null) { if (_IO.CanRead || _IO.CanWrite) _IO.D(); _IO = null; } Header = default; }
+
+ public struct HeaderData
+ {
+ public long Count;
+ public long DataLength;
+ public long DataOffset;
+
+ public Sub[] Data;
+
+ public struct Sub
+ {
+ public float Time;
+ public int Flags;
+ public int Frame;
+ public int Pad0C;
+ public int PVBranch;
+ public int ID;
+ public float Value;
+ public int Pad1C;
+ }
+ }
+ }
+}
diff --git a/KKdMainLib/IO/Stream.cs b/KKdMainLib/IO/Stream.cs
index db59b71..a96dbc1 100644
--- a/KKdMainLib/IO/Stream.cs
+++ b/KKdMainLib/IO/Stream.cs
@@ -303,14 +303,14 @@ namespace KKdMainLib.IO
public string RSUTF8 (long? length) => RBy(length).ToUTF8 ();
public string RSASCII(long? length) => RBy(length).ToASCII();
- public byte[] RBy(long length, int offset = -1)
+ public byte[] RBy(long length, long offset = -1)
{ byte[] Buf = new byte[length]; if (offset > -1) s.Position = offset;
s.Read(Buf, 0, (int)length); return Buf; }
public int RBy(long length, byte[] buf, long offset = -1)
{ if (offset > -1) s.Position = offset; return s.Read(buf, 0, (int)length); }
- public byte[] RBy(long? length, int offset = -1)
+ public byte[] RBy(long? length, long offset = -1)
{ if (length == null) return new byte[0]; else return RBy((long)length, offset); }
public void RBy(long length, byte bits, byte[] buf, long offset = -1)
diff --git a/KKdMainLib/KKdMainLib.csproj b/KKdMainLib/KKdMainLib.csproj
index cd33fe0..7704530 100644
--- a/KKdMainLib/KKdMainLib.csproj
+++ b/KKdMainLib/KKdMainLib.csproj
@@ -6,12 +6,12 @@
korenkonder © 2018-2020
A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files
- 0.4.9.0
+ 0.4.9.1
KKdMainLib
KKdMainLib
netstandard2.0
KKdMainLib
- 0.4.9.0
+ 0.4.9.1
AnyCPU
diff --git a/KKdMainLib/MotHead.cs b/KKdMainLib/MotHead.cs
index 3fcd3d7..7b82712 100644
--- a/KKdMainLib/MotHead.cs
+++ b/KKdMainLib/MotHead.cs
@@ -3,7 +3,7 @@ using KKdMainLib.IO;
namespace KKdMainLib
{
- public struct MotHead
+ public struct MotHead : System.IDisposable
{
private int i, i0, i1;
private Stream _IO;
@@ -92,7 +92,8 @@ namespace KKdMainLib
for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
{
ref HeaderData.Sub.Data Data = ref Header.Data[i].Array[i0];
- if (!GetSize(Data.Type, out i1)) goto RETURN;
+ if ((i1 = GetSize(Data.Type)) < 1) continue;
+
if (Data.Offset > 0)
{
@@ -152,27 +153,25 @@ RETURN:
for (i0 = Header.Data[i].Array.Length - 1; i0 > -1; i0--)
{
ref HeaderData.Sub.Data data = ref Header.Data[i].Array[i0];
- if (data.Array != null)
- if (data.Array.Length > 0 &&
- GetSize(data.Type, out int Size))
- {
- if (data.Type == 0x3E) _IO.A(0x20, true);
- data.Offset = _IO.P;
-
- if (Size == 0x01) _IO.W(( byte)data.Array[0]);
- else if (Size == 0x02) _IO.W((short)data.Array[0]);
- else
- {
- if (_IO.P % 0x4 != 0) _IO.A(0x04, true);
- Size /= 4;
-
- data.Offset = _IO.P;
- for (i1 = 0; i1 < data.Array.Length && i1 < Size; i1++)
- _IO.W(data.Array[i1]);
-
- for (; i1 < Size; i1++) _IO.W(0);
- }
- }
+ int Size = GetSize(data.Type);
+ if (data.Array == null || data.Array.Length < 1 || Size < 1) continue;
+
+ if (data.Type == 0x3E) _IO.A(0x20, true);
+ data.Offset = _IO.P;
+
+ if (Size == 0x01) _IO.W(( byte)data.Array[0]);
+ else if (Size == 0x02) _IO.W((short)data.Array[0]);
+ else
+ {
+ if (_IO.P % 0x4 != 0) _IO.A(0x04, true);
+ Size /= 4;
+
+ data.Offset = _IO.P;
+ for (i1 = 0; i1 < data.Array.Length && i1 < Size; i1++)
+ _IO.W(data.Array[i1]);
+
+ for (; i1 < Size; i1++) _IO.W(0);
+ }
}
if (Header.Data[i].Array2 != null)
@@ -678,16 +677,26 @@ RETURN:
motHead.WriteAfterAll(true, file, json);
}
- private static bool GetSize(int Type, out int Size)
- {
- Size = Type switch
+ private static int GetSize(int Type) =>
+ Type switch
{
+ 0x02 => 0x02,
0x03 => 0x04,
+ 0x04 => 0x04,
+ 0x07 => 0x08,
+ 0x08 => 0x08,
+ 0x0D => 0x0C,
+ 0x11 => 0x1C,
+ 0x1D => 0x30,
+ 0x20 => 0x10,
+ 0x21 => 0x18,
0x35 => 0x14,
0x36 => 0x14,
0x37 => 0x14,
0x38 => 0x14,
0x39 => 0x14,
+ 0x3A => 0x14,
+ 0x3B => 0x04,
0x3C => 0x10,
0x3D => 0x08,
0x3E => 0x40,
@@ -705,12 +714,14 @@ RETURN:
0x4B => 0x34,
0x4C => 0x10,
0x4D => 0x04,
+ 0x4E => 0x1C,
0x4F => 0x01,
- 0x50 => 0x04,
+ 0x50 => 0x01,
_ => 0x00,
};
- return Size > 0;
- }
+
+ public void Dispose()
+ { if (_IO != null) { if (_IO.CanRead || _IO.CanWrite) _IO.D(); _IO = null; } Header = default; }
public struct HeaderData
{
diff --git a/PD_Tool/PD_Tool.csproj b/PD_Tool/PD_Tool.csproj
index ac157ce..18cfcce 100644
--- a/PD_Tool/PD_Tool.csproj
+++ b/PD_Tool/PD_Tool.csproj
@@ -41,6 +41,7 @@
+
diff --git a/PD_Tool/Program.cs b/PD_Tool/Program.cs
index 353377f..2ca3038 100644
--- a/PD_Tool/Program.cs
+++ b/PD_Tool/Program.cs
@@ -56,10 +56,11 @@ namespace PD_Tool
ConsoleDesign("3. Decrypt from DIVAFILE");
ConsoleDesign("4. Encrypt to DIVAFILE");
ConsoleDesign("5. DB_Tools");
- ConsoleDesign("6. AC/DT/F/AFT/FT Converting Tools");
- ConsoleDesign("7. F/F2/FT Converting Tools");
- ConsoleDesign("8. X/XHD Converting Tools");
- ConsoleDesign(json ? "9. MsgPack to JSON" : "9. JSON to MsgPack");
+ ConsoleDesign("6. AC/DT/F/AFT Converting Tools");
+ ConsoleDesign("7. F/F2/FT Converting Tools");
+ ConsoleDesign("8. X/XHD Converting Tools");
+ ConsoleDesign("9. FT/M39 Converting Tools");
+ ConsoleDesign(json ? "A. MsgPack to JSON" : "A. JSON to MsgPack");
ConsoleDesign(false);
ConsoleDesign(json ? "M. MessagePack" : "J. JSON");
ConsoleDesign("Q. Quit");
@@ -87,7 +88,7 @@ namespace PD_Tool
else if (choose == "6")
{
Console.Clear();
- Console.Title = "AC/DT/F/AFT/FT Converting Tools";
+ Console.Title = "AC/DT/F/AFT Converting Tools";
ConsoleDesign(true);
ConsoleDesign(" Choose converter:");
ConsoleDesign(false);
@@ -170,6 +171,39 @@ namespace PD_Tool
else choose = localChoose;
}
else if (choose == "9")
+ {
+ Console.Clear();
+ Console.Title = "FT/M39 Converting Tools";
+ ConsoleDesign(true);
+ ConsoleDesign(" Choose converter:");
+ ConsoleDesign(false);
+ ConsoleDesign("1. A3DA" );
+ ConsoleDesign("2. AddParam");
+ ConsoleDesign("3. AET" );
+ ConsoleDesign("4. DEX" );
+ ConsoleDesign("5. DIVA" );
+ ConsoleDesign("6. MotHead" );
+ ConsoleDesign("7. MOT" );
+ ConsoleDesign("8. Table" );
+ ConsoleDesign("9. STR" );
+ ConsoleDesign(false);
+ ConsoleDesign("R. Return to Main Menu");
+ ConsoleDesign(false);
+ ConsoleDesign(true);
+ Console.WriteLine();
+ string localChoose = Console.ReadLine().ToUpper();
+ if (localChoose == "1") A3D.Processor(json);
+ else if (localChoose == "2") ADP.Processor(json);
+ else if (localChoose == "3") AET.Processor(json);
+ else if (localChoose == "4") DEX.Processor(json);
+ else if (localChoose == "5") DIV.Processor();
+ else if (localChoose == "6") MHD.Processor(json);
+ else if (localChoose == "7") MOT.Processor(json);
+ else if (localChoose == "8") TBL.Processor(json);
+ else if (localChoose == "9") STR.Processor(json);
+ else choose = localChoose;
+ }
+ else if (choose == "A")
{
Console.Title = json ? "MsgPack to JSON" : "JSON to MsgPack";
Choose(1, json ? "mp" : "json", out string[] fileNames);
diff --git a/PD_Tool/Properties/AssemblyInfo.cs b/PD_Tool/Properties/AssemblyInfo.cs
index 42690f7..6bf0709 100644
--- a/PD_Tool/Properties/AssemblyInfo.cs
+++ b/PD_Tool/Properties/AssemblyInfo.cs
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
-[assembly: AssemblyVersion("0.4.9.0")]
-[assembly: AssemblyFileVersion("0.4.9.0")]
+[assembly: AssemblyVersion("0.4.9.1")]
+[assembly: AssemblyFileVersion("0.4.9.1")]
diff --git a/PD_Tool/classes/ADP.cs b/PD_Tool/classes/ADP.cs
new file mode 100644
index 0000000..9e01b75
--- /dev/null
+++ b/PD_Tool/classes/ADP.cs
@@ -0,0 +1,39 @@
+using System;
+using KKdMainLib;
+using KKdMainLib.IO;
+
+namespace PD_Tool
+{
+ public class ADP
+ {
+ public static void Processor(bool json)
+ {
+ Console.Title = "Add Param Converter";
+ Program.Choose(1, "adp", out string[] fileNames);
+ if (fileNames.Length < 1) return;
+
+ string filepath, ext;
+ AddParam adp;
+ foreach (string file in fileNames)
+ {
+ adp = new AddParam();
+ ext = Path.GetExtension(file);
+ filepath = file.Replace(ext, "");
+ ext = ext.ToLower();
+
+ Console.Title = "Add Param Converter: " + Path.GetFileNameWithoutExtension(file);
+ if (ext == ".adp")
+ {
+ adp.MotHeadReader(filepath);
+ adp.MsgPackWriter(filepath, json);
+ }
+ else if (ext == ".mp" || ext == ".json")
+ {
+ adp.MsgPackReader(filepath, ext == ".json");
+ adp.MotHeadWriter(filepath);
+ }
+ adp.Dispose();
+ }
+ }
+ }
+}
diff --git a/PD_Tool/classes/MHD.cs b/PD_Tool/classes/MHD.cs
index a566ffa..d91b300 100644
--- a/PD_Tool/classes/MHD.cs
+++ b/PD_Tool/classes/MHD.cs
@@ -32,7 +32,7 @@ namespace PD_Tool
mhd.MsgPackReader(filepath, ext == ".json");
mhd.MotHeadWriter(filepath);
}
- mhd = new MotHead();
+ mhd.Dispose();
}
}
}