Added ROM and RomLoader.cs. Updated Form1.cs to load ROM into memory

This commit is contained in:
2026-04-08 16:51:55 +01:00
parent ea828aad2d
commit edc7ff5981
4 changed files with 63 additions and 2 deletions

26
Desktop/RomLoader.cs Normal file
View 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;
}
}
}