C64: Manage memory for Cartridge, Write protect on media.
This commit is contained in:
parent
f4f45f73a8
commit
b0e4e18ebc
|
@ -10,7 +10,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
{
|
||||
public static CartridgeDevice Load(byte[] crtFile)
|
||||
{
|
||||
var mem = new MemoryStream(crtFile);
|
||||
using (var mem = new MemoryStream(crtFile))
|
||||
{
|
||||
var reader = new BinaryReader(mem);
|
||||
|
||||
if (new string(reader.ReadChars(16)) != "C64 CARTRIDGE ")
|
||||
|
@ -101,6 +102,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
|
|||
result.HardReset();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static int ReadCRTShort(BinaryReader reader)
|
||||
|
|
|
@ -13,12 +13,14 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media
|
|||
[SaveState.DoNotSave] private int[][] _tracks;
|
||||
[SaveState.DoNotSave] private readonly int[] _originalMedia;
|
||||
[SaveState.DoNotSave] public bool Valid;
|
||||
[SaveState.SaveWithName("DiskIsWriteProtected")] public bool WriteProtected;
|
||||
|
||||
/// <summary>
|
||||
/// Create a blank, unformatted disk.
|
||||
/// </summary>
|
||||
public Disk(int trackCapacity)
|
||||
{
|
||||
WriteProtected = false;
|
||||
_tracks = new int[trackCapacity][];
|
||||
FillMissingTracks();
|
||||
_originalMedia = SerializeTracks(_tracks);
|
||||
|
@ -35,6 +37,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media
|
|||
/// <param name="trackCapacity">Total number of tracks on the media.</param>
|
||||
public Disk(IList<byte[]> trackData, IList<int> trackNumbers, IList<int> trackDensities, IList<int> trackLengths, int trackCapacity)
|
||||
{
|
||||
WriteProtected = true;
|
||||
_tracks = new int[trackCapacity][];
|
||||
for (var i = 0; i < trackData.Count; i++)
|
||||
{
|
||||
|
|
|
@ -177,6 +177,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
|
|||
public void RemoveMedia()
|
||||
{
|
||||
_disk = null;
|
||||
_trackImageData = null;
|
||||
_diskBits = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue