Skip to content

Commit

Permalink
Initial Release 1.0
Browse files Browse the repository at this point in the history
* All assets that are smaller or equal size in the JP version will be undubbed
* Audio files that are larger are appended at the end of the archive file
* All FMV are undubbed, but some will retain the english text/logo
* Over 30 voice clips restored from the JP version
* All audio in Japanese!
* Custom splash screen
  • Loading branch information
wagrenier committed Sep 11, 2021
1 parent a92da2e commit d7ad55e
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 17 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@

## Undub project for Fatal Frame 2 PS2 (Project Zero 2零紅い蝶)

![](docs/splash.gif)

Includes:
* All assets that are smaller or equal size in the JP version will be undubbed
* Audio files that are larger are appended at the end of the archive file
* All FMV are undubbed, but some will retain the english text/logo
* Over 30 voice clips restored from the JP version
* All audio in Japanese!
* *Custom splash screen

Next version:
* New more accurate subtitle (?)
* (Coming soon!) EU support

What this programs needs:
* Your owned copy of Fatal Frame 2 ISO (US)
Expand Down
1 change: 1 addition & 0 deletions Zero2UndubProcess/Constants/GameConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ namespace Zero2UndubProcess.Constants
public static class GameConstants
{
public const int FileInfoByteSize = 0xC;
public static byte[] LogoPatch = new byte[] {0xC0, 0x2C, 0x32, 0x65, 0x46, 0x68, 0x06, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
}
}
15 changes: 9 additions & 6 deletions Zero2UndubProcess/Constants/GameRegionConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ public static class GameRegionConstants
public static class EuIsoConstants
{
public const string TitleId = "SLES_523.84";
public const int NumberFiles = 0x879;
public const long FileTableStartAddress = 0xA63000;
public const long FileTypeTableStartAddress = 0x2082D000;
public const long FileArchiveStartAddress = 0x30D40000;
public const long FileArchiveEndAddress = 0x9168B000;
public const long FileArchiveEndIsoAddress = 0xC23CB000;
public const int NumberFiles = 0x879; // TODO: Change
public const long FileTableStartAddress = 0xA63000; // TODO: Change
public const long FileTypeTableStartAddress = 0x2082D000; // TODO: Change
public const long FileArchiveStartAddress = 0x493E0000;
public const long FileArchiveEndAddress = 0x92A40000;
public const long FileArchiveEndIsoAddress = 0xDBE20000;
public const long LogoDatOffset = 0x2C4130;
}

public static class UsIsoConstants
Expand All @@ -22,6 +23,7 @@ public static class UsIsoConstants
public const long FileArchiveStartAddress = 0x30D40000;
public const long FileArchiveEndAddress = 0x9168B000;
public const long FileArchiveEndIsoAddress = 0xC23CB000;
public const long LogoDatOffset = 0x2C4130;
}

public static class JpIsoConstants
Expand All @@ -33,6 +35,7 @@ public static class JpIsoConstants
public const long FileArchiveStartAddress = 0x30D40000;
public const long FileArchiveEndAddress = 0x91566000;
public const long FileArchiveEndIsoAddress = 0xC22A6000;
public const long LogoDatOffset = 0x2C4130;
}
}
}
10 changes: 7 additions & 3 deletions Zero2UndubProcess/GameFiles/RegionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ private static RegionInfo GetRegionInfoFromGameRegion(GameRegions gameRegion)
FileTypeTableStartAddress = GameRegionConstants.EuIsoConstants.FileTypeTableStartAddress,
NumberFiles = GameRegionConstants.EuIsoConstants.NumberFiles,
FileArchiveEndAddress = GameRegionConstants.EuIsoConstants.FileArchiveEndAddress,
FileArchiveEndIsoAddress = GameRegionConstants.EuIsoConstants.FileArchiveEndIsoAddress
FileArchiveEndIsoAddress = GameRegionConstants.EuIsoConstants.FileArchiveEndIsoAddress,
LogoDatOffset = GameRegionConstants.EuIsoConstants.LogoDatOffset
},
GameRegions.USA => new RegionInfo
{
Expand All @@ -53,7 +54,8 @@ private static RegionInfo GetRegionInfoFromGameRegion(GameRegions gameRegion)
FileTypeTableStartAddress = GameRegionConstants.UsIsoConstants.FileTypeTableStartAddress,
NumberFiles = GameRegionConstants.UsIsoConstants.NumberFiles,
FileArchiveEndAddress = GameRegionConstants.UsIsoConstants.FileArchiveEndAddress,
FileArchiveEndIsoAddress = GameRegionConstants.UsIsoConstants.FileArchiveEndIsoAddress
FileArchiveEndIsoAddress = GameRegionConstants.UsIsoConstants.FileArchiveEndIsoAddress,
LogoDatOffset = GameRegionConstants.UsIsoConstants.LogoDatOffset
},
GameRegions.Japan => new RegionInfo
{
Expand All @@ -62,7 +64,8 @@ private static RegionInfo GetRegionInfoFromGameRegion(GameRegions gameRegion)
FileTypeTableStartAddress = GameRegionConstants.JpIsoConstants.FileTypeTableStartAddress,
NumberFiles = GameRegionConstants.JpIsoConstants.NumberFiles,
FileArchiveEndAddress = GameRegionConstants.JpIsoConstants.FileArchiveEndAddress,
FileArchiveEndIsoAddress = GameRegionConstants.JpIsoConstants.FileArchiveEndIsoAddress
FileArchiveEndIsoAddress = GameRegionConstants.JpIsoConstants.FileArchiveEndIsoAddress,
LogoDatOffset = GameRegionConstants.JpIsoConstants.LogoDatOffset
},
GameRegions.UNKNOWN => throw new Exception("Unknown game region."),
_=> throw new Exception("Unknown game region.")
Expand Down Expand Up @@ -97,6 +100,7 @@ public class RegionInfo
public long FileTypeTableStartAddress { get; init; }
public long FileArchiveEndAddress { get; set; }
public long FileArchiveEndIsoAddress { get; set; }
public long LogoDatOffset { get; set; }
public int NumberFiles { get; init; }
}

Expand Down
7 changes: 7 additions & 0 deletions Zero2UndubProcess/GameFiles/SplashScreen.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Zero2UndubProcess/Importer/ZeroFileImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public void RestoreGame()
var originFile = _isoHandler.OriginGetFile(i);

// Check for splash screen logo
if (targetFile.FileId == 3)
if (targetFile.FileId == 2)
{

_isoHandler.OverwriteSplashScreen(originFile, targetFile);
}

if (targetFile.Type != FileType.VIDEO && targetFile.Type != FileType.AUDIO)
Expand Down
17 changes: 13 additions & 4 deletions Zero2UndubProcess/Iso/IsoHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using Zero2UndubProcess.Constants;
using Zero2UndubProcess.GameFiles;
using Zero2UndubProcess.Pss;

Expand Down Expand Up @@ -71,12 +72,20 @@ public void LargerVideoUndub(ZeroFile origin, ZeroFile target)

public void AppendFile(ZeroFile origin, ZeroFile target)
{
var originHeaderFile = OriginGetFile(origin.FileId - 1);
var targetHeaderFile = TargetGetFile(target.FileId - 1);

if (target.Type == FileType.AUDIO)
{
var originHeaderFile = OriginGetFile(origin.FileId - 1);
var targetHeaderFile = TargetGetFile(target.FileId - 1);
_targetIsoWriter.OverwriteFile(originHeaderFile, targetHeaderFile, GetFileContentOrigin(originHeaderFile));
}

_targetIsoWriter.AppendFile(origin, target, GetFileContentOrigin(origin));
}

_targetIsoWriter.OverwriteFile(originHeaderFile, targetHeaderFile, GetFileContentOrigin(originHeaderFile));
public void OverwriteSplashScreen(ZeroFile origin, ZeroFile target)
{
_targetIsoWriter.AppendCompressedFile(origin, target, SplashScreen.Content);
_targetIsoWriter.PatchBytesAtAbsoluteAddress(IsoRegionHandler.TargetRegionInfo.LogoDatOffset, GameConstants.LogoPatch);
}

private byte[] GetFileContentOrigin(ZeroFile origin)
Expand Down
22 changes: 20 additions & 2 deletions Zero2UndubProcess/Iso/IsoWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public void OverwriteFile(ZeroFile origin, ZeroFile target, byte[] fileContent)
SeekFile(target);
_writer.Write(fileContent);
}

public void AppendCompressedFile(ZeroFile origin, ZeroFile target, byte[] fileContent)
{
AppendFile(origin, target, fileContent);
WriteNewSizeFileCompressed(origin, target, fileContent.Length);
}

public void AppendFile(ZeroFile origin, ZeroFile target, byte[] fileContent)
{
Expand All @@ -52,15 +58,20 @@ public void AppendFile(ZeroFile origin, ZeroFile target, byte[] fileContent)
_regionInfo.FileArchiveEndAddress += fileContent.Length + blankBytes;

WriteNewAddressFile(origin, target, startAddress);
WriteNewSizeFile(origin, target, fileContent.Length);
}

public void PatchBytesAtAbsoluteAddress(long address, byte[] patch)
{
_writer.BaseStream.Seek(address, SeekOrigin.Begin);
_writer.BaseStream.Write(patch);
}

private void WriteNewAddressFile(ZeroFile origin, ZeroFile target, uint newStartAddress)
{
var fileSizeOffset = target.FileId * GameConstants.FileInfoByteSize;

SeekFileTableOffset(fileSizeOffset);
_writer.Write(newStartAddress);
WriteNewSizeFile(origin, target, (int)origin.Size);
}

private void WriteNewSizeFile(ZeroFile origin, ZeroFile target, int newSize)
Expand All @@ -70,6 +81,13 @@ private void WriteNewSizeFile(ZeroFile origin, ZeroFile target, int newSize)
_writer.Write((uint) newSize);
}

private void WriteNewSizeFileCompressed(ZeroFile origin, ZeroFile target, int newSize)
{
var fileSizeOffset = target.FileId * GameConstants.FileInfoByteSize + 0x8;
SeekFileTableOffset(fileSizeOffset);
_writer.Write(newSize);
}

private void SeekFileTableOffset(long offset)
{
_writer.BaseStream.Seek(_regionInfo.FileTableStartAddress, SeekOrigin.Begin);
Expand Down
Binary file added docs/splash.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d7ad55e

Please sign in to comment.