From 35da3edf60d5008168f1bb3d4e8cd3649288bd04 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 6 Nov 2017 22:14:15 -0500 Subject: [PATCH] Implements install_roms on the Electron, Oric and ZX80/81. --- Machines/Electron/Electron.cpp | 31 +++++++++++++++++++++++++++---- Machines/Electron/Electron.hpp | 3 ++- Machines/Oric/Oric.cpp | 16 ++++++++++++++++ Machines/Oric/Oric.hpp | 2 +- Machines/ZX8081/ZX8081.cpp | 15 +++++++++++++++ Machines/ZX8081/ZX8081.hpp | 2 +- 6 files changed, 62 insertions(+), 7 deletions(-) diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index edde9f14e..647ed2ed6 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -43,7 +43,8 @@ class ConcreteMachine: uint8_t *target = nullptr; switch(slot) { case ROMSlotDFS: dfs_ = data; return; - case ROMSlotADFS: adfs_ = data; return; + case ROMSlotADFS1: adfs1_ = data; return; + case ROMSlotADFS2: adfs2_ = data; return; case ROMSlotOS: target = os_; break; default: @@ -55,6 +56,28 @@ class ConcreteMachine: memcpy(target, &data[0], std::min(static_cast(16384), data.size())); } + // Obtains the system ROMs. + bool install_roms(const std::function>(const std::string &machine, const std::string &name)> &rom_with_name) override { + ROMSlot slots[] = { + ROMSlotDFS, + ROMSlotADFS1, ROMSlotADFS2, + ROMSlotBASIC, ROMSlotOS + }; + const char *os_files[] = { + "DFS-1770-2.20.rom", + "ADFS-E00_1.rom", "ADFS-E00_2.rom", + "basic.rom", "os.rom" + }; + + for(size_t index = 0; index < sizeof(os_files) / sizeof(*os_files); ++index) { + auto data = rom_with_name("Electron", os_files[index]); + if(!data) return false; + set_rom(slots[index], *data, false); + } + + return true; + } + void set_key_state(uint16_t key, bool isPressed) override final { if(key == KeyBreak) { m6502_.set_reset_line(isPressed); @@ -91,8 +114,8 @@ class ConcreteMachine: set_rom(ROMSlot0, dfs_, true); } if(target.acorn.has_adfs) { - set_rom(ROMSlot4, adfs_, true); - set_rom(ROMSlot5, std::vector(adfs_.begin() + 16384, adfs_.end()), true); + set_rom(ROMSlot4, adfs1_, true); + set_rom(ROMSlot5, adfs2_, true); } } @@ -435,7 +458,7 @@ class ConcreteMachine: uint8_t roms_[16][16384]; bool rom_write_masks_[16] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; uint8_t os_[16384], ram_[32768]; - std::vector dfs_, adfs_; + std::vector dfs_, adfs1_, adfs2_; // Paging ROMSlot active_rom_ = ROMSlot::ROMSlot0; diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index 724956157..cc76e219e 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -28,7 +28,8 @@ enum ROMSlot: uint8_t { ROMSlot12, ROMSlot13, ROMSlot14, ROMSlot15, - ROMSlotOS, ROMSlotDFS, ROMSlotADFS + ROMSlotOS, ROMSlotDFS, + ROMSlotADFS1, ROMSlotADFS2 }; /*! diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 0e1ad22c7..f5cacc1ad 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -203,6 +203,22 @@ class ConcreteMachine: } } + // Obtains the system ROMs. + bool install_roms(const std::function>(const std::string &machine, const std::string &name)> &rom_with_name) override { + const char *os_files[] = { + "basic10.rom", "basic11.rom", + "microdisc.rom", "colour.rom" + }; + + for(size_t index = 0; index < sizeof(os_files) / sizeof(*os_files); ++index) { + auto data = rom_with_name("Oric", os_files[index]); + if(!data) return false; + set_rom(static_cast(index), *data); + } + + return true; + } + void set_key_state(uint16_t key, bool is_pressed) override final { if(key == KeyNMI) { m6502_.set_nmi_line(is_pressed); diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index 9a69965a7..4e4a8c418 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -19,7 +19,7 @@ namespace Oric { enum ROM { - BASIC10, BASIC11, Microdisc, Colour + BASIC10 = 0, BASIC11, Microdisc, Colour }; /*! diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index dcedbdeeb..d9186cc73 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -297,6 +297,21 @@ template class ConcreteMachine: } } + // Obtains the system ROMs. + bool install_roms(const std::function>(const std::string &machine, const std::string &name)> &rom_with_name) override { + const char *os_files[] = { + "zx80.rom", "zx81.rom", + }; + + for(size_t index = 0; index < sizeof(os_files) / sizeof(*os_files); ++index) { + auto data = rom_with_name("ZX8081", os_files[index]); + if(!data) return false; + set_rom(static_cast(index), *data); + } + + return true; + } + #pragma mark - Keyboard void set_key_state(uint16_t key, bool isPressed) override final { diff --git a/Machines/ZX8081/ZX8081.hpp b/Machines/ZX8081/ZX8081.hpp index 9750183e6..8e119823d 100644 --- a/Machines/ZX8081/ZX8081.hpp +++ b/Machines/ZX8081/ZX8081.hpp @@ -19,7 +19,7 @@ namespace ZX8081 { enum ROMType: uint8_t { - ZX80, ZX81 + ZX80 = 0, ZX81 }; class Machine: