This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
190 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.IO; | ||
using System.Windows.Forms; | ||
|
||
namespace Cyclone | ||
{ | ||
public class Cyclone | ||
{ | ||
[STAThread] | ||
private static void Main() | ||
{ | ||
//Load ZIB. | ||
var ZibFolder = ""; | ||
using (var Fbd = new FolderBrowserDialog()) | ||
{ | ||
Fbd.ShowNewFolderButton = false; | ||
Fbd.Description = "Select the ZIB folder."; | ||
Fbd.SelectedPath = Application.StartupPath; | ||
|
||
if (Fbd.ShowDialog() != DialogResult.OK) | ||
Environment.Exit(1); | ||
else | ||
ZibFolder = Fbd.SelectedPath; | ||
} | ||
|
||
switch (new DirectoryInfo(ZibFolder).Name.Replace(" Unpacked", string.Empty)) | ||
{ | ||
// PC version .zib files | ||
case "busts.zib": | ||
Packer.Pack(ZibFolder, 0x2390); | ||
break; | ||
case "cardcropHD400.jpg.zib": | ||
Packer.Pack(ZibFolder); | ||
break; | ||
case "cardcropHD401.jpg.zib": | ||
Packer.Pack(ZibFolder); | ||
break; | ||
case "decks.zib": | ||
Packer.Pack(ZibFolder, 0x8650); | ||
break; | ||
case "packs.zib": | ||
Packer.Pack(ZibFolder, 0x750); | ||
break; | ||
|
||
// switch version .zib files | ||
case "cardcropHD400.illust_a.jpg.zib": | ||
Packer.Pack(ZibFolder, 0xE750); | ||
break; | ||
case "cardcropHD400.illust_j.jpg.zib": | ||
Packer.Pack(ZibFolder, 0x903D0); | ||
break; | ||
default: | ||
throw new Exception("This is either an unsupported ZIB"); | ||
} | ||
} | ||
} | ||
} |
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,133 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
using Celtic_Guardian; | ||
|
||
namespace Relinquished | ||
{ | ||
internal class Program | ||
{ | ||
[STAThread] | ||
private static void Main(string[] args) | ||
{ | ||
Console.Title = "Relinquished"; | ||
var ZibFileName = ""; | ||
using (var FileDialog = new OpenFileDialog()) | ||
{ | ||
FileDialog.Title = "Open Yu-Gi-Oh ZIB File..."; | ||
FileDialog.Filter = "Yu-Gi-Oh! Wolf ZIB File |*.zib"; | ||
if (FileDialog.ShowDialog() != DialogResult.OK) return; | ||
|
||
ZibFileName = new FileInfo(FileDialog.FileName).Name; | ||
|
||
if (Directory.Exists($"{ZibFileName} Unpacked") || File.Exists($"{ZibFileName} Unpacked/Index.zib")) | ||
return; | ||
|
||
Directory.CreateDirectory($"{ZibFileName} Unpacked"); | ||
File.Create($"{ZibFileName} Unpacked/Index.zib").Close(); | ||
File.SetAttributes($"{ZibFileName} Unpacked/Index.zib", | ||
File.GetAttributes($"{ZibFileName} Unpacked/Index.zib") | FileAttributes.Hidden); | ||
|
||
long DataStartOffset = 0x0; | ||
int OffsetReadSize = 0x0, SizeReadSize = 0x0, FileNameReadSize = 0x0; //These Should Add Up To 64. | ||
|
||
switch (ZibFileName) | ||
{ | ||
// PC version .zib files | ||
case "cardcropHD400.jpg.zib": | ||
OffsetReadSize = 8; | ||
SizeReadSize = 8; | ||
FileNameReadSize = 48; | ||
DataStartOffset = 0x69F10; | ||
break; | ||
|
||
case "cardcropHD401.jpg.zib": | ||
OffsetReadSize = 8; | ||
SizeReadSize = 8; | ||
FileNameReadSize = 48; | ||
DataStartOffset = 0xC810; | ||
break; | ||
|
||
case "busts.zib": | ||
OffsetReadSize = 4; | ||
SizeReadSize = 4; | ||
FileNameReadSize = 56; | ||
DataStartOffset = 0x2390; | ||
break; | ||
|
||
case "decks.zib": | ||
OffsetReadSize = 4; | ||
SizeReadSize = 4; | ||
FileNameReadSize = 56; | ||
DataStartOffset = 0x8650; | ||
break; | ||
|
||
case "packs.zib": | ||
OffsetReadSize = 4; | ||
SizeReadSize = 4; | ||
FileNameReadSize = 56; | ||
DataStartOffset = 0x750; | ||
break; | ||
|
||
// Swtich version .zib files | ||
case "cardcropHD400.illust_a.jpg.zib": | ||
OffsetReadSize = 4; | ||
SizeReadSize = 4; | ||
FileNameReadSize = 56; | ||
DataStartOffset = 0xE750; | ||
break; | ||
case "cardcropHD400.illust_j.jpg.zib": | ||
OffsetReadSize = 4; | ||
SizeReadSize = 4; | ||
FileNameReadSize = 56; | ||
DataStartOffset = 0x903D0; | ||
break; | ||
|
||
default: | ||
throw new Exception("Not valid ZIB File"); | ||
} | ||
|
||
using (var IndexWriter = new StreamWriter(File.Open($"{ZibFileName} Unpacked/Index.zib", FileMode.Open, | ||
FileAccess.Write))) | ||
{ | ||
using (var Reader = | ||
new BinaryReader(File.Open(FileDialog.FileName, FileMode.Open, FileAccess.Read))) | ||
{ | ||
while (Reader.BaseStream.Position + 64 <= DataStartOffset) | ||
{ | ||
var CurrentChunk = Reader.ReadBytes(64); //40 In HEX is 64 in DEC | ||
var CurrentStartOffset = Utilities.HexToDec(CurrentChunk.Take(OffsetReadSize).ToArray()); | ||
CurrentChunk = CurrentChunk.Skip(OffsetReadSize).ToArray(); | ||
var CurrentFileSize = Utilities.HexToDec(CurrentChunk.Take(SizeReadSize).ToArray(), true); | ||
CurrentChunk = CurrentChunk.Skip(SizeReadSize).ToArray(); | ||
var CurrentFileName = Utilities.GetText(CurrentChunk.Take(FileNameReadSize).ToArray()); | ||
|
||
//Start Offsets Are WRONG In ZIB For Some Reason, Or Maybe I Am... (Thanks thomasneff for other files) | ||
if (CurrentFileName == "adriangecko_neutral.png") | ||
CurrentStartOffset = 0x2390; | ||
if (CurrentFileName == "1classic_01a_yugimuto.ydc") | ||
CurrentStartOffset = 0x8650; | ||
if (CurrentFileName == "bpack_BattlePack1.bin") | ||
CurrentStartOffset = 0x750; | ||
|
||
Utilities.Log($"Exporting {CurrentFileName} ({CurrentFileSize} Bytes)", | ||
Utilities.Event.Information); | ||
|
||
var SnapBack = Reader.BaseStream.Position; | ||
Reader.BaseStream.Position = CurrentStartOffset; | ||
using (var Writer = new BinaryWriter(File.Open($"{ZibFileName} Unpacked/" + CurrentFileName, | ||
FileMode.Create, FileAccess.Write))) | ||
{ | ||
Writer.Write(Reader.ReadBytes(CurrentFileSize)); | ||
IndexWriter.Write(CurrentFileName + "\n"); | ||
} | ||
|
||
Reader.BaseStream.Position = SnapBack; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |