update ROM header detection algorithm. Fixes some homebrew roms which have no header and aren't padded to a multiple of 1024 bytes.
This commit is contained in:
parent
c7db5fd543
commit
775845184c
|
@ -9,7 +9,7 @@ namespace BizHawk.MultiClient
|
|||
public byte[] FileData;
|
||||
public GameInfo GameInfo;
|
||||
|
||||
private const int BankSize = 4096;
|
||||
private const int BankSize = 1024;
|
||||
|
||||
public RomGame() { }
|
||||
|
||||
|
@ -21,10 +21,20 @@ namespace BizHawk.MultiClient
|
|||
throw new Exception("The file needs to exist, yo.");
|
||||
|
||||
var stream = file.GetStream();
|
||||
|
||||
FileData = Util.ReadAllBytes(stream);
|
||||
|
||||
// if we're offset exactly 512 bytes from a 1024-byte boundary,
|
||||
// assume we have a header of that size. Otherwise, assume it's just all rom.
|
||||
// Other 'recognized' header sizes may need to be added.
|
||||
int header = (int)(stream.Length % BankSize);
|
||||
if (header.In(0, 512) == false)
|
||||
{
|
||||
Console.WriteLine("ROM was not a multiple of 1024 bytes, and not a recognized header size: {0}. Assume it's purely ROM data.", header);
|
||||
header = 0;
|
||||
}
|
||||
else if (header > 0)
|
||||
Console.WriteLine("Assuming header of {0} bytes.", header);
|
||||
|
||||
stream.Position = header;
|
||||
int length = (int)stream.Length - header;
|
||||
|
||||
|
|
Loading…
Reference in New Issue