From cbfd8e18e85a8f2df9acdada10dae304649435a6 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 2 Sep 2022 15:54:16 -0400 Subject: [PATCH] Eliminate repetitive magic constants. --- Machines/Apple/AppleII/AppleII.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index 7a63a981e..136c9beb1 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -39,6 +39,13 @@ #include #include +namespace { + +constexpr int DiskIISlot = 6; // Apple recommended slot 6 for the (first) Disk II. +constexpr int SCSISlot = 7; // Install the SCSI card in slot 7, to one-up any connected Disk II. + +} + namespace Apple { namespace II { @@ -149,11 +156,11 @@ template class ConcreteMachine: } Apple::II::DiskIICard *diskii_card() { - return dynamic_cast(cards_[5].get()); + return dynamic_cast(cards_[DiskIISlot - 1].get()); } Apple::II::SCSICard *scsi_card() { - return dynamic_cast(cards_[6].get()); + return dynamic_cast(cards_[SCSISlot - 1].get()); } // MARK: - Memory Map. @@ -488,16 +495,13 @@ template class ConcreteMachine: } if(has_disk_controller) { - // Apple recommended slot 6 for the (first) Disk II. - install_card(6, new Apple::II::DiskIICard(roms, is_sixteen_sector)); + install_card(DiskIISlot, new Apple::II::DiskIICard(roms, is_sixteen_sector)); } if(has_scsi_card) { - // Install the SCSI card in slot 7, to one-up any connected Disk II. - // // Rounding the clock rate slightly shouldn't matter, but: // TODO: be [slightly] more honest about clock rate. - install_card(7, new Apple::II::SCSICard(roms, int(master_clock / 14.0f))); + install_card(SCSISlot, new Apple::II::SCSICard(roms, int(master_clock / 14.0f))); } rom_ = std::move(roms.find(system)->second);