From b6b3d845a3dc81b9e30a8d4026153ac576a5b721 Mon Sep 17 00:00:00 2001
From: Thomas Harte <thomas.harte@gmail.com>
Date: Fri, 4 Jun 2021 22:48:08 -0400
Subject: [PATCH] Correct Apple IIe and Enhanced IIe startup.

---
 Machines/Apple/AppleII/AppleII.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp
index 5eb2c81bf..6b6078824 100644
--- a/Machines/Apple/AppleII/AppleII.cpp
+++ b/Machines/Apple/AppleII/AppleII.cpp
@@ -419,6 +419,12 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
 			}
 
 			rom_ = std::move(roms.find(system)->second);
+			// The IIe and Enhanced IIe ROMs often distributed are oversized; trim if necessary.
+			if(system == ROM::Name::AppleIIe || system == ROM::Name::AppleIIEnhancedE) {
+				if(rom_.size() > 16128) {
+					rom_.erase(rom_.begin(), rom_.end() - off_t(16128));
+				}
+			}
 			video_.set_character_rom(roms.find(character)->second);
 
 			// Set up the default memory blocks. On a II or II+ these values will never change.