From b53656d50ced58b8ab867f1878f45825d41472a6 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Wed, 16 Sep 2020 18:38:51 +0300 Subject: Cleanup, size check --- NesFile.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'NesFile.cs') diff --git a/NesFile.cs b/NesFile.cs index 9396fc0..77caa76 100644 --- a/NesFile.cs +++ b/NesFile.cs @@ -715,7 +715,11 @@ namespace com.clusterrr.Famicom.Containers throw new InvalidDataException("Mapper > 255 supported by NES 2.0 only"); if (Submapper != 0) throw new InvalidDataException("Submapper supported by NES 2.0 only"); + var length16k = PRG.Length / 0x4000; + if (length16k > 0xFF) throw new ArgumentOutOfRangeException("PRG size is too big for iNES, use NES 2.0 instead"); header[4] = (byte)(PRG.Length / 0x4000); + var length8k = CHR.Length / 0x2000; + if (length8k > 0xFF) throw new ArgumentOutOfRangeException("CHR size is too big for iNES, use NES 2.0 instead"); header[5] = (byte)(CHR.Length / 0x2000); // Hard-wired nametable mirroring type if (Mirroring == MirroringType.Vertical) -- cgit v1.2.3