Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

Commit

Permalink
improve first_text_offset calculation again. Add TODO.
Browse files Browse the repository at this point in the history
  • Loading branch information
xupefei committed Jan 25, 2013
1 parent 971b4e1 commit 73f3822
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions ScriptDecoder/Program.cs
@@ -1,7 +1,6 @@
using System;
using System.IO;
using System.Text;

using Amemiya.Extensions;

namespace ScriptDecoder
Expand Down Expand Up @@ -53,10 +52,11 @@ private static void Main(string[] args)
// Remove HEADER.
scriptBuffer = scriptBuffer.Slice(headerLength, scriptBuffer.Length);

// TODO: Analyze more about this offset. Sometime it is marked as 0x00000001 and sometime 0x0000007F.
// Get the text offset.
// The offset is always next to 0x00000001 (HEADER length not included).
// The offset is always next to 0x0000007F (HEADER length not included).
int firstTextOffset;
int offset = scriptBuffer.IndexOf(new byte[] {1, 0, 0, 0}, 0, false);
int offset = scriptBuffer.IndexOf(new byte[] {0x7F, 0, 0, 0}, 0, false);
// Avoid possible overflow.
if (offset < 0 || offset > 128)
{
Expand All @@ -81,8 +81,8 @@ private static void Main(string[] args)
{
// Look up the text in original buffer.
byte[] bytesTextBlock = scriptBuffer.Slice(intTextOffset,
scriptBuffer.IndexOf(new byte[] {0x00},
intTextOffset, false));
scriptBuffer.IndexOf(new byte[] {0x00},
intTextOffset, false));

if (bytesTextBlock != null)
{
Expand All @@ -105,4 +105,4 @@ private static void Main(string[] args)
//Console.ReadLine();
}
}
}
}
30 changes: 15 additions & 15 deletions SysgrpConverter/Program.cs
Expand Up @@ -47,12 +47,12 @@ private static void BeginBuildResource(string strBmpFile)

using (var bw = new BinaryWriter(new FileStream(strBmpFile + ".out", FileMode.Create)))
{
bw.Write((Int16)width);
bw.Write((Int16)Math.Abs(height));
bw.Write((Int16)depth);
bw.Write((Int16)0);
bw.Write((Int32)0);
bw.Write((Int32)0);
bw.Write((Int16) width);
bw.Write((Int16) Math.Abs(height));
bw.Write((Int16) depth);
bw.Write((Int16) 0);
bw.Write((Int32) 0);
bw.Write((Int32) 0);
bw.Write(bits);

bw.Close();
Expand All @@ -73,7 +73,7 @@ private static void BeginBuildBMP(string strFilename)
depth = br.ReadInt16();

br.BaseStream.Position = 0x10;
bits = br.ReadBytes((int)br.BaseStream.Length - 0x10);
bits = br.ReadBytes((int) br.BaseStream.Length - 0x10);
br.Close();
}

Expand Down Expand Up @@ -106,17 +106,17 @@ public static byte[] BuildBMP(byte[] bits, int width, int height, int depth)
//height
ms.Write(BitConverter.GetBytes(height), 0, 4);
//nplanes
ms.Write(BitConverter.GetBytes((Int16)1), 0, 2);
ms.Write(BitConverter.GetBytes((Int16) 1), 0, 2);
//bitspp
ms.Write(BitConverter.GetBytes((Int16)depth), 0, 2);
ms.Write(BitConverter.GetBytes((Int16) depth), 0, 2);
//set other info to 0
ms.Write(new byte[]
{
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
}, 0, 24);
{
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
}, 0, 24);
//write bits
ms.Write(bits, 0, bits.Length);

Expand Down

0 comments on commit 73f3822

Please sign in to comment.