Skip to content

Commit 9660c16

Browse files
fix N64 roms coming through multidisk bundler in ares
1 parent 3dd36f5 commit 9660c16

File tree

1 file changed

+15
-0
lines changed
  • src/BizHawk.Emulation.Cores/Consoles/Nintendo/Ares64

1 file changed

+15
-0
lines changed

src/BizHawk.Emulation.Cores/Consoles/Nintendo/Ares64/Ares64.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ static bool IsGBRom(byte[] rom)
6666
return ninLogoSha1 == SHA1Checksum.ComputeDigestHex(new ReadOnlySpan<byte>(rom).Slice(0x104, 48));
6767
}
6868

69+
// TODO: this is normally handled frontend side
70+
// except XML files don't go through RomGame
71+
// (probably should, but needs refactoring)
72+
foreach (var d in lp.Roms.Select(static r => r.RomData))
73+
{
74+
// magic N64 rom bytes are 0x80, 0x37, 0x12, 0x40
75+
// this should hopefully only ever detect N64 roms and not other kinds of files sent through here...
76+
if ((d[1] is 0x80 && d[0] is 0x37 && d[3] is 0x12 && d[2] is 0x40) // .v64 byteswapped
77+
|| (d[3] is 0x80 && d[2] is 0x37 && d[1] is 0x12 && d[0] is 0x40) // .n64 little-endian
78+
|| (d[0] is 0x80 && d[1] is 0x37 && d[2] is 0x12 && d[3] is 0x40)) // .z64 native
79+
{
80+
N64RomByteswapper.ToZ64Native(d);
81+
}
82+
}
83+
6984
var gbRoms = lp.Roms.FindAll(r => IsGBRom(r.FileData)).Select(r => r.FileData).ToArray();
7085
var rom = lp.Roms.Find(r => !gbRoms.Contains(r.FileData) && (char)r.RomData[0x3B] is 'N' or 'C')?.RomData;
7186
var (disk, error) = TransformDisk(lp.Roms.Find(r => !gbRoms.Contains(r.FileData) && r.RomData != rom)?.FileData);

0 commit comments

Comments
 (0)