c64 nitpicks

This commit is contained in:
adelikat 2017-05-12 14:57:22 -05:00
parent 48080c838f
commit 2c2b58d98b
2 changed files with 43 additions and 11 deletions

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public enum C64Format
{

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.IO;
using System.Text;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
@ -11,36 +8,76 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
public static C64Format GetFormat(byte[] data)
{
if (data == null || data.Length < 0x10)
{
return C64Format.Unknown;
}
using (var mem = new MemoryStream(data))
{
var reader = new BinaryReader(mem);
var header = Encoding.GetEncoding(437).GetString(reader.ReadBytes(0x10));
if (header.StartsWith("C64 CARTRIDGE "))
{
return C64Format.CRT;
}
if (header.StartsWith("GCR-1541"))
{
return C64Format.G64;
}
if (header.StartsWith("C64S tape image "))
{
return C64Format.T64;
}
if (header.StartsWith("C64-TAPE-RAW"))
{
return C64Format.TAP;
}
if (header.StartsWith("C64File"))
return C64Format.P00;
{
return C64Format.P00; // poo :)
}
if (header.StartsWith("P64-1541"))
{
return C64Format.P64;
}
if (data[0] == 0x43 && data[1] == 0x15 && data[2] == 0x41 && data[3] == 0x64)
{
return C64Format.X64;
}
if (data.Length == 174848 || data.Length == 175531 || data.Length == 196608 || data.Length == 197376)
{
return C64Format.D64;
}
if (data.Length == 349696 || data.Length == 351062)
{
return C64Format.D71;
}
if (data.Length == 533248)
{
return C64Format.D80;
}
if (data.Length == 819200 || data.Length == 822400)
{
return C64Format.D81;
}
if (data.Length == 1066496)
{
return C64Format.D82;
}
}
return C64Format.Unknown;
}
}