Skip to content

Commit d7ad55e

Browse files
committed
Initial Release 1.0
* 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
1 parent a92da2e commit d7ad55e

File tree

9 files changed

+65
-17
lines changed

9 files changed

+65
-17
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77

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

10+
![](docs/splash.gif)
11+
1012
Includes:
1113
* All assets that are smaller or equal size in the JP version will be undubbed
1214
* Audio files that are larger are appended at the end of the archive file
1315
* All FMV are undubbed, but some will retain the english text/logo
16+
* Over 30 voice clips restored from the JP version
17+
* All audio in Japanese!
18+
* *Custom splash screen
1419

1520
Next version:
1621
* New more accurate subtitle (?)
22+
* (Coming soon!) EU support
1723

1824
What this programs needs:
1925
* Your owned copy of Fatal Frame 2 ISO (US)

Zero2UndubProcess/Constants/GameConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ namespace Zero2UndubProcess.Constants
33
public static class GameConstants
44
{
55
public const int FileInfoByteSize = 0xC;
6+
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};
67
}
78
}

Zero2UndubProcess/Constants/GameRegionConstants.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ public static class GameRegionConstants
55
public static class EuIsoConstants
66
{
77
public const string TitleId = "SLES_523.84";
8-
public const int NumberFiles = 0x879;
9-
public const long FileTableStartAddress = 0xA63000;
10-
public const long FileTypeTableStartAddress = 0x2082D000;
11-
public const long FileArchiveStartAddress = 0x30D40000;
12-
public const long FileArchiveEndAddress = 0x9168B000;
13-
public const long FileArchiveEndIsoAddress = 0xC23CB000;
8+
public const int NumberFiles = 0x879; // TODO: Change
9+
public const long FileTableStartAddress = 0xA63000; // TODO: Change
10+
public const long FileTypeTableStartAddress = 0x2082D000; // TODO: Change
11+
public const long FileArchiveStartAddress = 0x493E0000;
12+
public const long FileArchiveEndAddress = 0x92A40000;
13+
public const long FileArchiveEndIsoAddress = 0xDBE20000;
14+
public const long LogoDatOffset = 0x2C4130;
1415
}
1516

1617
public static class UsIsoConstants
@@ -22,6 +23,7 @@ public static class UsIsoConstants
2223
public const long FileArchiveStartAddress = 0x30D40000;
2324
public const long FileArchiveEndAddress = 0x9168B000;
2425
public const long FileArchiveEndIsoAddress = 0xC23CB000;
26+
public const long LogoDatOffset = 0x2C4130;
2527
}
2628

2729
public static class JpIsoConstants
@@ -33,6 +35,7 @@ public static class JpIsoConstants
3335
public const long FileArchiveStartAddress = 0x30D40000;
3436
public const long FileArchiveEndAddress = 0x91566000;
3537
public const long FileArchiveEndIsoAddress = 0xC22A6000;
38+
public const long LogoDatOffset = 0x2C4130;
3639
}
3740
}
3841
}

Zero2UndubProcess/GameFiles/RegionHandler.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ private static RegionInfo GetRegionInfoFromGameRegion(GameRegions gameRegion)
4444
FileTypeTableStartAddress = GameRegionConstants.EuIsoConstants.FileTypeTableStartAddress,
4545
NumberFiles = GameRegionConstants.EuIsoConstants.NumberFiles,
4646
FileArchiveEndAddress = GameRegionConstants.EuIsoConstants.FileArchiveEndAddress,
47-
FileArchiveEndIsoAddress = GameRegionConstants.EuIsoConstants.FileArchiveEndIsoAddress
47+
FileArchiveEndIsoAddress = GameRegionConstants.EuIsoConstants.FileArchiveEndIsoAddress,
48+
LogoDatOffset = GameRegionConstants.EuIsoConstants.LogoDatOffset
4849
},
4950
GameRegions.USA => new RegionInfo
5051
{
@@ -53,7 +54,8 @@ private static RegionInfo GetRegionInfoFromGameRegion(GameRegions gameRegion)
5354
FileTypeTableStartAddress = GameRegionConstants.UsIsoConstants.FileTypeTableStartAddress,
5455
NumberFiles = GameRegionConstants.UsIsoConstants.NumberFiles,
5556
FileArchiveEndAddress = GameRegionConstants.UsIsoConstants.FileArchiveEndAddress,
56-
FileArchiveEndIsoAddress = GameRegionConstants.UsIsoConstants.FileArchiveEndIsoAddress
57+
FileArchiveEndIsoAddress = GameRegionConstants.UsIsoConstants.FileArchiveEndIsoAddress,
58+
LogoDatOffset = GameRegionConstants.UsIsoConstants.LogoDatOffset
5759
},
5860
GameRegions.Japan => new RegionInfo
5961
{
@@ -62,7 +64,8 @@ private static RegionInfo GetRegionInfoFromGameRegion(GameRegions gameRegion)
6264
FileTypeTableStartAddress = GameRegionConstants.JpIsoConstants.FileTypeTableStartAddress,
6365
NumberFiles = GameRegionConstants.JpIsoConstants.NumberFiles,
6466
FileArchiveEndAddress = GameRegionConstants.JpIsoConstants.FileArchiveEndAddress,
65-
FileArchiveEndIsoAddress = GameRegionConstants.JpIsoConstants.FileArchiveEndIsoAddress
67+
FileArchiveEndIsoAddress = GameRegionConstants.JpIsoConstants.FileArchiveEndIsoAddress,
68+
LogoDatOffset = GameRegionConstants.JpIsoConstants.LogoDatOffset
6669
},
6770
GameRegions.UNKNOWN => throw new Exception("Unknown game region."),
6871
_=> throw new Exception("Unknown game region.")
@@ -97,6 +100,7 @@ public class RegionInfo
97100
public long FileTypeTableStartAddress { get; init; }
98101
public long FileArchiveEndAddress { get; set; }
99102
public long FileArchiveEndIsoAddress { get; set; }
103+
public long LogoDatOffset { get; set; }
100104
public int NumberFiles { get; init; }
101105
}
102106

Zero2UndubProcess/GameFiles/SplashScreen.cs

Lines changed: 7 additions & 0 deletions
Large diffs are not rendered by default.

Zero2UndubProcess/Importer/ZeroFileImporter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public void RestoreGame()
3838
var originFile = _isoHandler.OriginGetFile(i);
3939

4040
// Check for splash screen logo
41-
if (targetFile.FileId == 3)
41+
if (targetFile.FileId == 2)
4242
{
43-
43+
_isoHandler.OverwriteSplashScreen(originFile, targetFile);
4444
}
4545

4646
if (targetFile.Type != FileType.VIDEO && targetFile.Type != FileType.AUDIO)

Zero2UndubProcess/Iso/IsoHandler.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.IO;
2+
using Zero2UndubProcess.Constants;
23
using Zero2UndubProcess.GameFiles;
34
using Zero2UndubProcess.Pss;
45

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

7273
public void AppendFile(ZeroFile origin, ZeroFile target)
7374
{
74-
var originHeaderFile = OriginGetFile(origin.FileId - 1);
75-
var targetHeaderFile = TargetGetFile(target.FileId - 1);
76-
75+
if (target.Type == FileType.AUDIO)
76+
{
77+
var originHeaderFile = OriginGetFile(origin.FileId - 1);
78+
var targetHeaderFile = TargetGetFile(target.FileId - 1);
79+
_targetIsoWriter.OverwriteFile(originHeaderFile, targetHeaderFile, GetFileContentOrigin(originHeaderFile));
80+
}
81+
7782
_targetIsoWriter.AppendFile(origin, target, GetFileContentOrigin(origin));
83+
}
7884

79-
_targetIsoWriter.OverwriteFile(originHeaderFile, targetHeaderFile, GetFileContentOrigin(originHeaderFile));
85+
public void OverwriteSplashScreen(ZeroFile origin, ZeroFile target)
86+
{
87+
_targetIsoWriter.AppendCompressedFile(origin, target, SplashScreen.Content);
88+
_targetIsoWriter.PatchBytesAtAbsoluteAddress(IsoRegionHandler.TargetRegionInfo.LogoDatOffset, GameConstants.LogoPatch);
8089
}
8190

8291
private byte[] GetFileContentOrigin(ZeroFile origin)

Zero2UndubProcess/Iso/IsoWriter.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public void OverwriteFile(ZeroFile origin, ZeroFile target, byte[] fileContent)
3636
SeekFile(target);
3737
_writer.Write(fileContent);
3838
}
39+
40+
public void AppendCompressedFile(ZeroFile origin, ZeroFile target, byte[] fileContent)
41+
{
42+
AppendFile(origin, target, fileContent);
43+
WriteNewSizeFileCompressed(origin, target, fileContent.Length);
44+
}
3945

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

5460
WriteNewAddressFile(origin, target, startAddress);
61+
WriteNewSizeFile(origin, target, fileContent.Length);
62+
}
63+
64+
public void PatchBytesAtAbsoluteAddress(long address, byte[] patch)
65+
{
66+
_writer.BaseStream.Seek(address, SeekOrigin.Begin);
67+
_writer.BaseStream.Write(patch);
5568
}
5669

5770
private void WriteNewAddressFile(ZeroFile origin, ZeroFile target, uint newStartAddress)
5871
{
5972
var fileSizeOffset = target.FileId * GameConstants.FileInfoByteSize;
60-
6173
SeekFileTableOffset(fileSizeOffset);
6274
_writer.Write(newStartAddress);
63-
WriteNewSizeFile(origin, target, (int)origin.Size);
6475
}
6576

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

84+
private void WriteNewSizeFileCompressed(ZeroFile origin, ZeroFile target, int newSize)
85+
{
86+
var fileSizeOffset = target.FileId * GameConstants.FileInfoByteSize + 0x8;
87+
SeekFileTableOffset(fileSizeOffset);
88+
_writer.Write(newSize);
89+
}
90+
7391
private void SeekFileTableOffset(long offset)
7492
{
7593
_writer.BaseStream.Seek(_regionInfo.FileTableStartAddress, SeekOrigin.Begin);

docs/splash.gif

3.29 MB
Loading

0 commit comments

Comments
 (0)