-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented dat decompression, 256 and WAKU0 image editing.
- Loading branch information
Showing
20 changed files
with
540 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
AdolTranslator/Ys I - II Chronicles+/Compression/DatDecompression.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace AdolTranslator.Compression | ||
{ | ||
class DatDecompression | ||
{ | ||
// Thanks to twn for explaining how decompression works. | ||
byte cVar1; | ||
uint bVar2; | ||
int addr_pixel; | ||
int pcVar3; | ||
int iVar4; | ||
uint uVar5; | ||
int pcVar6; | ||
ushort short_read; | ||
List<byte> result = new List<byte>(); | ||
public byte[] Decompression(int size, byte[] array, int fileLength) | ||
{ | ||
result.Clear(); | ||
cVar1 = array[6]; | ||
|
||
if (size < 5) | ||
{ | ||
return array; | ||
} | ||
|
||
iVar4 = size - 5; | ||
pcVar6 = 5; | ||
do | ||
{ | ||
do | ||
{ | ||
while (true) | ||
{ | ||
while (true) | ||
{ | ||
while (true) | ||
{ | ||
if (iVar4 == 0) | ||
{ | ||
return result.ToArray(); | ||
} | ||
|
||
if (array[pcVar6] == cVar1) | ||
break; | ||
result.Add(array[pcVar6]); | ||
addr_pixel++; | ||
pcVar6 += 1; | ||
iVar4 += -1; | ||
|
||
} | ||
|
||
bVar2 = array[pcVar6 + 1]; | ||
|
||
if (4 < bVar2) break; | ||
if (bVar2 != 0) | ||
{ | ||
return result.ToArray(); | ||
} | ||
|
||
result.Add(cVar1); | ||
addr_pixel++; | ||
pcVar6 += 2; | ||
iVar4 += -2; | ||
} | ||
|
||
uVar5 = bVar2; | ||
|
||
short_read = BitConverter.ToUInt16(array, pcVar6 + 2); | ||
pcVar3 = addr_pixel + (-1 - short_read); | ||
|
||
pcVar6 += 4; | ||
iVar4 += -4; | ||
if (pcVar6 > fileLength) | ||
return result.ToArray(); | ||
|
||
if (pcVar3 < 0) | ||
break; | ||
|
||
DecompressionRoutine(); | ||
} | ||
} while (bVar2 == 0); | ||
|
||
|
||
|
||
do | ||
{ | ||
|
||
result.Add(0); | ||
addr_pixel++; | ||
pcVar3 += 1; | ||
uVar5 -= 1; | ||
|
||
if (0 <= pcVar3) | ||
DecompressionRoutine(); | ||
|
||
} while (uVar5 != 0); | ||
} while (true); | ||
} | ||
|
||
private void DecompressionRoutine() | ||
{ | ||
while (uVar5 != 0) | ||
{ | ||
|
||
result.Add(result[pcVar3]); | ||
addr_pixel++; | ||
pcVar3 += 1; | ||
uVar5 -= 1; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
AdolTranslator/Ys I - II Chronicles+/Image/256/Binary2Image256.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using Texim; | ||
using Yarhl.FileFormat; | ||
using Yarhl.IO; | ||
|
||
namespace AdolTranslator.Image._256 | ||
{ | ||
class Binary2Image256 : IConverter<BinaryFormat, Image256> | ||
{ | ||
public Palette PalettePassed { get; set; } | ||
public Image256 Convert(BinaryFormat source) | ||
{ | ||
var result = new Image256(); | ||
var reader = new DataReader(source.Stream); | ||
|
||
var width = reader.ReadInt32(); | ||
var height = reader.ReadInt32(); | ||
|
||
|
||
result.Pixels = new PixelArray | ||
{ | ||
Width = width, | ||
Height = height, | ||
}; | ||
|
||
result.Palette = PalettePassed; | ||
result.Pixels.SetData( | ||
reader.ReadBytes((int)reader.Stream.Length-0x8), | ||
PixelEncoding.HorizontalTiles, | ||
ColorFormat.Indexed_8bpp, | ||
new Size(width, height)); | ||
|
||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.