Added ROM and RomLoader.cs. Updated Form1.cs to load ROM into memory
This commit is contained in:
26
Desktop/RomLoader.cs
Normal file
26
Desktop/RomLoader.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Desktop
|
||||
{
|
||||
public static class RomLoader
|
||||
{
|
||||
public static byte[] Load(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
throw new FileNotFoundException($"Could not find the ROM file at: {filePath}");
|
||||
}
|
||||
|
||||
byte[] romData = File.ReadAllBytes(filePath);
|
||||
|
||||
// The standard ZX Spectrum 48k ROM is exactly 16384 bytes (16KB)
|
||||
if (romData.Length != 16384)
|
||||
{
|
||||
throw new InvalidDataException($"Invalid ROM size. Expected 16384 bytes, got {romData.Length} bytes.");
|
||||
}
|
||||
|
||||
return romData;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user