Commit b80248cf authored by Spencer Alves's avatar Spencer Alves

Cleanup

parent bd66a65d
......@@ -51,6 +51,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Recomp\Assembler.cs" />
<Compile Include="Recomp\Tokenizer.cs" />
<Compile Include="_BinBuffer\BinBuffer.cs" />
<Compile Include="_BinBuffer\BinBufferByteResource.cs" />
......@@ -117,4 +118,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
\ No newline at end of file
......@@ -130,7 +130,7 @@ namespace Altar.Decomp
break;
case DataType.Double:
if (Value is double)
return ((double)Value).ToString(CultureInfo.InvariantCulture) + DOUBLE_L;
return ((double)Value).ToString(DOUBLE_FMT, CultureInfo.InvariantCulture) + DOUBLE_L;
break;
case DataType.Int16:
if (Value is short)
......@@ -146,7 +146,7 @@ namespace Altar.Decomp
break;
case DataType.Single:
if (Value is float)
return ((float )Value).ToString(CultureInfo.InvariantCulture) + SINGLE_L;
return ((float )Value).ToString(SINGLE_FMT, CultureInfo.InvariantCulture) + SINGLE_L;
break;
case DataType.String:
if (Value is string)
......
using System;
using Altar.Unpack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Altar.Unpack;
namespace Altar.Decomp
{
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
namespace Altar.Decomp
......
using System;
using Altar.Unpack;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Altar.Unpack;
using static Altar.SR;
......@@ -218,10 +217,10 @@ namespace Altar.Decomp
sb.Append(((DwordBool*)&r)->ToPrettyString());
break;
case DataType.Double:
sb.Append(((double*)&r)->ToString("G16", CultureInfo.InvariantCulture));
sb.Append(((double*)&r)->ToString(DOUBLE_FMT, CultureInfo.InvariantCulture));
break;
case DataType.Single:
sb.Append(((float*)&r)->ToString("G8", CultureInfo.InvariantCulture));
sb.Append(((float*)&r)->ToString(SINGLE_FMT, CultureInfo.InvariantCulture));
break;
case DataType.Int32:
sb.Append(unchecked((int)r).ToString(CultureInfo.InvariantCulture));
......
using System;
using LitJson;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.Globalization;
using System.Linq;
using LitJson;
namespace Altar
{
......
using System;
using Altar.Decomp;
using Altar.Unpack;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Altar.Decomp;
using Altar.Repack;
using Altar.Unpack;
using static Altar.SR;
namespace Altar
......@@ -304,7 +302,7 @@ namespace Altar
ret.Extensions = (SectionUnknown*)hdr;
if (!ret.Extensions->IsEmpty())
Console.WriteLine("Warning: EXTN chunk is not empty, its content will not be exported!");
Console.Error.WriteLine("Warning: EXTN chunk is not empty, its content will not be exported!");
break;
case SectionHeaders.Sounds:
ret.Sounds = (SectionCountOffsets*)hdr;
......@@ -325,7 +323,7 @@ namespace Altar
ret.Shaders = (SectionUnknown*)hdr;
if (!ret.Shaders->IsEmpty())
Console.WriteLine("Warning: SHDR chunk is not empty, its content will not be exported!");
Console.Error.WriteLine("Warning: SHDR chunk is not empty, its content will not be exported!");
break;
case SectionHeaders.Fonts:
ret.Fonts = (SectionCountOffsets*)hdr;
......@@ -334,7 +332,7 @@ namespace Altar
ret.Timelines = (SectionUnknown*)hdr;
if (!ret.Timelines->IsEmpty())
Console.WriteLine("Warning: TMLN chunk is not empty, its content will not be exported!");
Console.Error.WriteLine("Warning: TMLN chunk is not empty, its content will not be exported!");
break;
case SectionHeaders.Objects:
ret.Objects = (SectionCountOffsets*)hdr;
......@@ -346,7 +344,7 @@ namespace Altar
ret.DataFiles = (SectionUnknown*)hdr;
if (!ret.DataFiles->IsEmpty())
Console.WriteLine("Warning: DAFL chunk is not empty, its content will not be exported!");
Console.Error.WriteLine("Warning: DAFL chunk is not empty, its content will not be exported!");
break;
case SectionHeaders.TexturePage:
ret.TexturePages = (SectionCountOffsets*)hdr;
......@@ -376,18 +374,18 @@ namespace Altar
ret.Language = (SectionUnknown*)hdr;
if (!ret.Language->IsEmpty())
Console.WriteLine("Warning: LANG chunk is not empty, its content will not be exported!");
Console.Error.WriteLine("Warning: LANG chunk is not empty, its content will not be exported!");
break;
case SectionHeaders.GLOB_Unk:
ret.GLOB_Unk = (SectionUnknown*)hdr;
if (!ret.GLOB_Unk->IsEmpty())
Console.WriteLine("Warning: GLOB chunk is not empty, its content will not be exported!");
Console.Error.WriteLine("Warning: GLOB chunk is not empty, its content will not be exported!");
break;
default:
var unk = (SectionUnknown*)hdr;
if (!unk->IsEmpty())
Console.WriteLine($"Warning: unknown chunk {hdr->Identity.ToChunkName()}, chunk is not empty, its content will not be exported!");
Console.Error.WriteLine($"Warning: unknown chunk {hdr->Identity.ToChunkName()}, chunk is not empty, its content will not be exported!");
ret.UnknownChunks.Add(hdr->Identity, (IntPtr)unk);
break;
......@@ -395,7 +393,7 @@ namespace Altar
for (int i = 0; i < ret.HeaderOffsets.Length; i++)
if (((SectionHeader*)((byte*)basePtr + ret.HeaderOffsets[i]))->Identity == hdr->Identity)
Console.WriteLine($"WARNING: chunk {hdr->MagicString()} encountered (at least) twice! Only the last occurrence will be exported! (If you see this message, consider reversing manually.)");
Console.Error.WriteLine($"WARNING: chunk {hdr->MagicString()} encountered (at least) twice! Only the last occurrence will be exported! (If you see this message, consider reversing manually.)");
if (ret.HeaderOffsets.Length >= headersMet)
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
namespace Altar
......
using System;
using System.Collections.Generic;
using System.Linq;
using CommandLine;
using CommandLine;
using CommandLine.Text;
namespace Altar
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
namespace Altar
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
namespace Altar
......
using System;
using Altar.Decomp;
using Altar.Recomp;
using Altar.Repack;
using Altar.Unpack;
using CommandLine;
using LitJson;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using CommandLine;
using LitJson;
using Altar.Decomp;
using Altar.Unpack;
using static Altar.SR;
using Altar.Repack;
namespace Altar
{
// http://pastebin.com/9t783UNE
using AsmParser = Altar.Recomp.Parser;
using CLParser = CommandLine.Parser;
using CLParser = CommandLine.Parser;
unsafe static class Program
{
......@@ -577,7 +577,7 @@ namespace Altar
var codeChunk = new BBData(new BinBuffer(), new int[0]);
Console.WriteLine($"Preparing code...");
var codeChunkStringOffsetOffsets = SectionWriter.WriteCodes(codeChunk, f, stringOffsets);
var codeChunkStringOffsetOffsets = Assembler.WriteCodes(codeChunk, f, stringOffsets);
var output = Path.GetFullPath(opt.OutputFile);
......@@ -674,7 +674,7 @@ namespace Altar
SectionWriter.WriteAudio(chunk, f.Audio, writer.Buffer.Position);
break;
default:
Console.WriteLine("Don't know how to handle, loading from dump");
Console.Error.WriteLine($"Don't know how to handle {chunkName}, loading from dump");
BinBuffer chunkData = new BinBuffer(File.ReadAllBytes(Path.Combine(baseDir, chunkFile.ToString())));
chunk = new BBData(chunkData, new int[0]);
break;
......
This diff is collapsed.
using System;
using System.Collections;
using Altar.Decomp;
using System;
using System.Collections.Generic;
using System.Linq;
using Altar.Decomp;
namespace Altar.Recomp
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using Altar.Decomp;
using Altar.Decomp;
using System;
namespace Altar.Recomp
{
......
using System;
using System.Collections.Generic;
using System.Linq;
namespace Altar.Recomp
{
......
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
namespace Altar.Recomp
......
This diff is collapsed.
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Altar
namespace Altar
{
static class SR
{
......@@ -47,6 +43,9 @@ namespace Altar
HEX_FM8 = "X8",
HEX_FM6 = "X6",
SINGLE_FMT = "G8" ,
DOUBLE_FMT = "G16",
DOUBLE_L = "d",
SINGLE_L = "f",
SHORT_L = "s",
......
using System;
using Altar.Decomp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Altar.Decomp;
namespace Altar
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
......@@ -352,7 +351,7 @@ namespace Altar.Unpack
}
}
else
Console.WriteLine($"Warning: collision mask of sprite {id} ({((ulong)se - (ulong)content.RawData.BPtr).ToString(SR.HEX_FM8)}) is bogus ({amt.ToString(SR.HEX_FM8)}), ignoring...");
Console.Error.WriteLine($"Warning: collision mask of sprite {id} ({((ulong)se - (ulong)content.RawData.BPtr).ToString(SR.HEX_FM8)}) is bogus ({amt.ToString(SR.HEX_FM8)}), ignoring...");
return ret;
}
......@@ -492,7 +491,7 @@ namespace Altar.Unpack
if ((shapeCop->Count & 0xFFFFF000) != 0)
{
Console.WriteLine($"Warning: shape point coords of object {id} are bogus, ignoring...");
Console.Error.WriteLine($"Warning: shape point coords of object {id} are bogus, ignoring...");
ret.ShapePoints = null;
}
......@@ -509,7 +508,7 @@ namespace Altar.Unpack
//Console.WriteLine(((IntPtr)xoff).ToString(SR.HEX_FM8) + SR.SPACE_S + ((IntPtr)yoff).ToString(SR.HEX_FM8));
if ((shapePointOff & 0xFF000000) != 0 || shapePointPtr == null)
{
Console.WriteLine($"Warning: shape point coord {i} of object {id} is bogus, ignoring...");
Console.Error.WriteLine($"Warning: shape point coord {i} of object {id} is bogus, ignoring...");
continue;
}
......
using System;
using LitJson;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using LitJson;
namespace Altar.Unpack
{
......@@ -274,7 +273,7 @@ namespace Altar.Unpack
r["filename"] = gen8.FileName;
r["config" ] = gen8.Configuration;
r["gameid" ] = gen8.GameID;
r["name"] = gen8.Name;
r["name" ] = gen8.Name;
r["version" ] = gen8.Version.ToString();
r["windowsize"] = SerializeSize(gen8.WindowSize);
r["licensemd5"] = SerializeArray(gen8.LicenseMD5Hash, Utils.Identity);
......@@ -518,7 +517,7 @@ namespace Altar.Unpack
r["general"] = "general.json";
r["options"] = "options.json";
r["strings"] = "strings.json";
r["strings" ] = "strings.json";
r["variables"] = "variables.json";
r["functions"] = "functions.json";
......
using System;
using Altar.Decomp;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Altar.Decomp;
namespace Altar
{
......
......@@ -181,7 +181,7 @@ namespace Altar
var pow = requiredLength == 0 ? 11 : (FastLog2(requiredLength)+1);
Array.Resize(ref buffer, 1 << Math.Max(pow, 1));
Array.Resize(ref buffer, 1 << pow);
}
protected override void Dispose(bool disposing)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment