diff options
| author | 2025-08-22 23:24:20 +0100 | |
|---|---|---|
| committer | 2025-08-22 23:30:10 +0100 | |
| commit | f98130b3dd85b4194a57e2ed037df29d4644440e (patch) | |
| tree | cd8df0562698eaee4f1decbd548452266d4c1f03 | |
| parent | df898cb9d32bcc6875525e5764ba4fd605b226e7 (diff) | |
bus/bbc/rom: Moved classes into anonymous namespace.
| -rw-r--r-- | src/devices/bus/bbc/rom/datagem.cpp | 49 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/datagem.h | 37 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/dfs.cpp | 83 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/dfs.h | 30 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/nvram.cpp | 55 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/nvram.h | 31 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/pal.cpp | 496 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/pal.h | 179 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/ram.cpp | 55 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/ram.h | 31 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/rom.cpp | 50 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/rom.h | 30 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/rtc.cpp | 98 | ||||
| -rw-r--r-- | src/devices/bus/bbc/rom/rtc.h | 62 |
14 files changed, 507 insertions, 779 deletions
diff --git a/src/devices/bus/bbc/rom/datagem.cpp b/src/devices/bus/bbc/rom/datagem.cpp index 11f2cfdb631..f8912fded32 100644 --- a/src/devices/bus/bbc/rom/datagem.cpp +++ b/src/devices/bus/bbc/rom/datagem.cpp @@ -10,27 +10,30 @@ #include "datagem.h" -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** +namespace { -DEFINE_DEVICE_TYPE(BBC_DATAGEM, bbc_datagem_device, "bbc_datagem", "Gemini DataGem ROM Carrier") +class bbc_datagem_device : public device_t, public device_bbc_rom_interface +{ +public: + bbc_datagem_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_DATAGEM, tag, owner, clock) + , device_bbc_rom_interface(mconfig, *this) + , m_bank(0) + { + } +protected: + // device_t overrides + virtual void device_start() override ATTR_COLD; -//************************************************************************** -// LIVE DEVICE -//************************************************************************** + // device_bbc_rom_interface overrides + virtual uint32_t get_rom_size() override { return 0x4000; } + virtual uint8_t read(offs_t offset) override; + virtual void decrypt_rom() override; -//------------------------------------------------- -// bbc_datagem_device - constructor -//------------------------------------------------- - -bbc_datagem_device::bbc_datagem_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, BBC_DATAGEM, tag, owner, clock) - , device_bbc_rom_interface(mconfig, *this) - , m_bank(0) -{ -} +private: + uint8_t m_bank; +}; //------------------------------------------------- @@ -39,7 +42,6 @@ bbc_datagem_device::bbc_datagem_device(const machine_config &mconfig, const char void bbc_datagem_device::device_start() { - /* register for save states */ save_item(NAME(m_bank)); } @@ -53,7 +55,7 @@ void bbc_datagem_device::decrypt_rom() for (int i = 0x0000; i < 0x6000; i++) { - /* decrypt 16K and 8K ROM data lines */ + // decrypt 16K and 8K ROM data lines switch (rom[i] & 0x07) { case 0x01: case 0x06: rom[i] = bitswap<8>(rom[i], 7, 6, 5, 4, 3, 0, 1, 2); break; @@ -61,7 +63,7 @@ void bbc_datagem_device::decrypt_rom() case 0x03: case 0x04: rom[i] = bitswap<8>(rom[i], 7, 6, 5, 4, 3, 1, 2, 0); break; } - /* decrypt additional 8K ROM data lines */ + // decrypt additional 8K ROM data lines if (i & 0x4000) { rom[i] = bitswap<8>(rom[i], 3, 6, 5, 4, 7, 2, 1, 0); @@ -77,7 +79,7 @@ uint8_t bbc_datagem_device::read(offs_t offset) { if (!machine().side_effects_disabled()) { - /* switching zones for DataGem */ + // switching zones for DataGem switch (offset & 0x3fff) { case 0x1ffe: m_bank = 1; break; @@ -94,3 +96,8 @@ uint8_t bbc_datagem_device::read(offs_t offset) return get_rom_base()[offset & 0x3fff]; } } + +} // anonymous namespace + + +DEFINE_DEVICE_TYPE_PRIVATE(BBC_DATAGEM, device_bbc_rom_interface, bbc_datagem_device, "bbc_datagem", "Gemini DataGem ROM Carrier") diff --git a/src/devices/bus/bbc/rom/datagem.h b/src/devices/bus/bbc/rom/datagem.h index ba12df0ff3f..67a21ddc016 100644 --- a/src/devices/bus/bbc/rom/datagem.h +++ b/src/devices/bus/bbc/rom/datagem.h @@ -1,11 +1,5 @@ // license:BSD-3-Clause // copyright-holders:Nigel Barnes -/*************************************************************************** - - Gemini DataGem ROM Carrier - -***************************************************************************/ - #ifndef MAME_BUS_BBC_ROM_DATAGEM_H #define MAME_BUS_BBC_ROM_DATAGEM_H @@ -14,35 +8,6 @@ #include "slot.h" -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> bbc_datagem_device - -class bbc_datagem_device : public device_t, - public device_bbc_rom_interface -{ -public: - // construction/destruction - bbc_datagem_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device-level overrides - virtual void device_start() override ATTR_COLD; - - // device_bbc_rom_interface overrides - virtual uint32_t get_rom_size() override { return 0x4000; } - virtual uint8_t read(offs_t offset) override; - virtual void decrypt_rom() override; - -private: - uint8_t m_bank; -}; - - -// device type definition -DECLARE_DEVICE_TYPE(BBC_DATAGEM, bbc_datagem_device) - +DECLARE_DEVICE_TYPE(BBC_DATAGEM, device_bbc_rom_interface) #endif // MAME_BUS_BBC_ROM_DATAGEM_H diff --git a/src/devices/bus/bbc/rom/dfs.cpp b/src/devices/bus/bbc/rom/dfs.cpp index 7395b31dae9..ff1dbed947e 100644 --- a/src/devices/bus/bbc/rom/dfs.cpp +++ b/src/devices/bus/bbc/rom/dfs.cpp @@ -13,51 +13,42 @@ #include "dfs.h" -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** +namespace { -DEFINE_DEVICE_TYPE(BBC_DFSE00, bbc_dfse00_device, "bbc_dfse00", "BBC Micro E00 DFS") - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// bbc_rom_device - constructor -//------------------------------------------------- - -bbc_dfse00_device::bbc_dfse00_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, BBC_DFSE00, tag, owner, clock) - , device_bbc_rom_interface(mconfig, *this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void bbc_dfse00_device::device_start() -{ -} - -//------------------------------------------------- -// read -//------------------------------------------------- - -uint8_t bbc_dfse00_device::read(offs_t offset) -{ - if (offset < get_rom_size()) - return get_rom_base()[offset & (get_rom_size() - 1)]; - else - return get_ram_base()[offset & (get_ram_size() - 1)]; -} - -//------------------------------------------------- -// write -//------------------------------------------------- - -void bbc_dfse00_device::write(offs_t offset, uint8_t data) +class bbc_dfse00_device : public device_t, public device_bbc_rom_interface { - get_ram_base()[offset & (get_ram_size() - 1)] = data; -} +public: + bbc_dfse00_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_DFSE00, tag, owner, clock) + , device_bbc_rom_interface(mconfig, *this) + , m_ram(*this, "ram", 0x800, ENDIANNESS_LITTLE) + { + } + +protected: + // device_t overrides + virtual void device_start() override ATTR_COLD { } + + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override + { + if (offset & 0x2000) + return m_ram[offset & 0x7ff]; + else + return get_rom_base()[offset]; + } + + virtual void write(offs_t offset, uint8_t data) override + { + if (offset & 0x2000) + m_ram[offset & 0x7ff] = data; + } + +private: + memory_share_creator<uint8_t> m_ram; +}; + +} // anonymous namespace + + +DEFINE_DEVICE_TYPE_PRIVATE(BBC_DFSE00, device_bbc_rom_interface, bbc_dfse00_device, "bbc_dfse00", "BBC Micro E00 DFS") diff --git a/src/devices/bus/bbc/rom/dfs.h b/src/devices/bus/bbc/rom/dfs.h index 59ebb531423..33f6d0ca97a 100644 --- a/src/devices/bus/bbc/rom/dfs.h +++ b/src/devices/bus/bbc/rom/dfs.h @@ -1,11 +1,5 @@ // license:BSD-3-Clause // copyright-holders:Nigel Barnes -/*************************************************************************** - - BBC Micro E00 DFS emulation - -***************************************************************************/ - #ifndef MAME_BUS_BBC_ROM_DFS_H #define MAME_BUS_BBC_ROM_DFS_H @@ -13,29 +7,7 @@ #include "slot.h" -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> bbc_dfse00_device - -class bbc_dfse00_device : public device_t, public device_bbc_rom_interface -{ -public: - // construction/destruction - bbc_dfse00_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device-level overrides - virtual void device_start() override ATTR_COLD; - - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; - virtual void write(offs_t offset, uint8_t data) override; -}; - -// device type definition -DECLARE_DEVICE_TYPE(BBC_DFSE00, bbc_dfse00_device) +DECLARE_DEVICE_TYPE(BBC_DFSE00, device_bbc_rom_interface) #endif // MAME_BUS_BBC_ROM_DFS_H diff --git a/src/devices/bus/bbc/rom/nvram.cpp b/src/devices/bus/bbc/rom/nvram.cpp index 0d24f30c8bd..18ad00d94c9 100644 --- a/src/devices/bus/bbc/rom/nvram.cpp +++ b/src/devices/bus/bbc/rom/nvram.cpp @@ -10,25 +10,33 @@ #include "nvram.h" -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** +namespace { -DEFINE_DEVICE_TYPE(BBC_NVRAM, bbc_nvram_device, "bbc_nvram", "BBC Micro Sideways RAM (Battery Backup)") +class bbc_nvram_device : public device_t, public device_bbc_rom_interface +{ +public: + bbc_nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_NVRAM, tag, owner, clock) + , device_bbc_rom_interface(mconfig, *this) + { + } -//************************************************************************** -// LIVE DEVICE -//************************************************************************** +protected: + // device_t overrides + virtual void device_start() override ATTR_COLD; -//------------------------------------------------- -// bbc_nvram_device - constructor -//------------------------------------------------- + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override + { + return get_nvram_base()[offset & (get_nvram_size() - 1)]; + } + + virtual void write(offs_t offset, uint8_t data) override + { + get_nvram_base()[offset & (get_nvram_size() - 1)] = data; + } +}; -bbc_nvram_device::bbc_nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, BBC_NVRAM, tag, owner, clock) - , device_bbc_rom_interface(mconfig, *this) -{ -} //------------------------------------------------- // device_start - device-specific startup @@ -39,20 +47,7 @@ void bbc_nvram_device::device_start() nvram_alloc(0x4000); } -//------------------------------------------------- -// read -//------------------------------------------------- +} // anonymous namespace -uint8_t bbc_nvram_device::read(offs_t offset) -{ - return get_nvram_base()[offset & (get_nvram_size() - 1)]; -} -//------------------------------------------------- -// write -//------------------------------------------------- - -void bbc_nvram_device::write(offs_t offset, uint8_t data) -{ - get_nvram_base()[offset & (get_nvram_size() - 1)] = data; -} +DEFINE_DEVICE_TYPE_PRIVATE(BBC_NVRAM, device_bbc_rom_interface, bbc_nvram_device, "bbc_nvram", "BBC Micro Sideways RAM (Battery Backup)") diff --git a/src/devices/bus/bbc/rom/nvram.h b/src/devices/bus/bbc/rom/nvram.h index 25f7c58acd2..f87020cf3aa 100644 --- a/src/devices/bus/bbc/rom/nvram.h +++ b/src/devices/bus/bbc/rom/nvram.h @@ -1,11 +1,5 @@ // license:BSD-3-Clause // copyright-holders:Nigel Barnes -/*************************************************************************** - - BBC Micro Sideways RAM (Battery Backup) emulation - -***************************************************************************/ - #ifndef MAME_BUS_BBC_ROM_NVRAM_H #define MAME_BUS_BBC_ROM_NVRAM_H @@ -13,30 +7,7 @@ #include "slot.h" -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> bbc_nvram_device - -class bbc_nvram_device : public device_t, - public device_bbc_rom_interface -{ -public: - // construction/destruction - bbc_nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device-level overrides - virtual void device_start() override ATTR_COLD; - - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; - virtual void write(offs_t offset, uint8_t data) override; -}; - -// device type definition -DECLARE_DEVICE_TYPE(BBC_NVRAM, bbc_nvram_device) +DECLARE_DEVICE_TYPE(BBC_NVRAM, device_bbc_rom_interface) #endif // MAME_BUS_BBC_ROM_NVRAM_H diff --git a/src/devices/bus/bbc/rom/pal.cpp b/src/devices/bus/bbc/rom/pal.cpp index c0cfb1ac7b5..65987025941 100644 --- a/src/devices/bus/bbc/rom/pal.cpp +++ b/src/devices/bus/bbc/rom/pal.cpp @@ -46,293 +46,385 @@ #include "pal.h" -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** - -DEFINE_DEVICE_TYPE(BBC_CCIWORD, bbc_cciword_device, "bbc_cciword", "Computer Concepts 32K ROM Carrier (Inter-Word)") -DEFINE_DEVICE_TYPE(BBC_CCIBASE, bbc_ccibase_device, "bbc_ccibase", "Computer Concepts 64K ROM Carrier (Inter-Base)") -DEFINE_DEVICE_TYPE(BBC_CCISPELL, bbc_ccispell_device, "bbc_ccispell", "Computer Concepts 128K ROM Carrier (SpellMaster)") -DEFINE_DEVICE_TYPE(BBC_PALQST, bbc_palqst_device, "bbc_palqst", "Watford Electronics ROM Carrier (Quest Paint)") -DEFINE_DEVICE_TYPE(BBC_PALWAP, bbc_palwap_device, "bbc_palwap", "Watford Electronics ROM Carrier (Wapping Editor)") -DEFINE_DEVICE_TYPE(BBC_PALTED, bbc_palted_device, "bbc_palted", "Watford Electronics ROM Carrier (TED)") -DEFINE_DEVICE_TYPE(BBC_PALABEP, bbc_palabep_device, "bbc_palabep", "P.R.E.S. 32K ROM Carrier (ABE+)") -DEFINE_DEVICE_TYPE(BBC_PALABE, bbc_palabe_device, "bbc_palabe", "P.R.E.S. 32K ROM Carrier (ABE)") -DEFINE_DEVICE_TYPE(BBC_PALMO2, bbc_palmo2_device, "bbc_palmo2", "Instant Mini Office 2 ROM Carrier") -DEFINE_DEVICE_TYPE(BBC_TRILOGY, bbc_trilogy_device, "bbc_trilogy", "Acornsoft Trilogy Emulator") - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** +namespace { -//------------------------------------------------- -// bbc_palprom_device - constructor -//------------------------------------------------- - -bbc_pal_device::bbc_pal_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock) - , device_bbc_rom_interface(mconfig, *this) - , m_bank(0) -{ -} +// ======================> bbc_pal_device -bbc_cciword_device::bbc_cciword_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_CCIWORD, tag, owner, clock) +class bbc_pal_device : public device_t, public device_bbc_rom_interface { -} - -bbc_ccibase_device::bbc_ccibase_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_CCIBASE, tag, owner, clock) -{ -} +protected: + bbc_pal_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, type, tag, owner, clock) + , device_bbc_rom_interface(mconfig, *this) + , m_bank(0) + { + } -bbc_ccispell_device::bbc_ccispell_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_CCISPELL, tag, owner, clock) -{ -} + // device_t overrides + virtual void device_start() override ATTR_COLD; -bbc_palqst_device::bbc_palqst_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_PALQST, tag, owner, clock) -{ -} + // device_bbc_rom_interface overrides + virtual uint32_t get_rom_size() override { return 0x4000; } -bbc_palwap_device::bbc_palwap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_PALWAP, tag, owner, clock) -{ -} + uint8_t m_bank; +}; -bbc_palted_device::bbc_palted_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_PALTED, tag, owner, clock) -{ -} -bbc_palabep_device::bbc_palabep_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_PALABEP, tag, owner, clock) -{ -} +// ======================> bbc_cciword_device -bbc_palabe_device::bbc_palabe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_PALABE, tag, owner, clock) +class bbc_cciword_device : public bbc_pal_device { -} +public: + bbc_cciword_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_CCIWORD, tag, owner, clock) + { + } -bbc_palmo2_device::bbc_palmo2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_PALMO2, tag, owner, clock) -{ -} +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override + { + if (!machine().side_effects_disabled()) + { + // switching zones for Inter-Word + switch (offset & 0x3fe0) + { + case 0x0060: + case 0x3fc0: m_bank = 0; break; + case 0x0040: + case 0x3fa0: + case 0x3fe0: m_bank = 1; break; + } + } -bbc_trilogy_device::bbc_trilogy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : bbc_pal_device(mconfig, BBC_TRILOGY, tag, owner, clock) -{ -} + return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; + } +}; -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- +// ======================> bbc_ccibase_device -void bbc_pal_device::device_start() +class bbc_ccibase_device : public bbc_pal_device { - save_item(NAME(m_bank)); -} - -//------------------------------------------------- -// read -//------------------------------------------------- +public: + bbc_ccibase_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_CCIBASE, tag, owner, clock) + { + } -uint8_t bbc_cciword_device::read(offs_t offset) -{ - if (!machine().side_effects_disabled()) +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override { - /* switching zones for Inter-Word */ - switch (offset & 0x3fe0) + if (!machine().side_effects_disabled()) { - case 0x0060: - case 0x3fc0: m_bank = 0; break; - case 0x0040: - case 0x3fa0: - case 0x3fe0: m_bank = 1; break; + // switching zones for Inter-Base + switch (offset & 0x3fe0) + { + case 0x3f80: m_bank = 0; break; + case 0x3fa0: m_bank = 1; break; + case 0x3fc0: m_bank = 2; break; + case 0x3fe0: m_bank = 3; break; + } } + + return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; } +}; - return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; -} -uint8_t bbc_ccibase_device::read(offs_t offset) +// ======================> bbc_ccispell_device + +class bbc_ccispell_device : public bbc_pal_device { - if (!machine().side_effects_disabled()) +public: + bbc_ccispell_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_CCISPELL, tag, owner, clock) { - /* switching zones for Inter-Base */ - switch (offset & 0x3fe0) + } + +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override + { + if (!machine().side_effects_disabled()) { - case 0x3f80: m_bank = 0; break; - case 0x3fa0: m_bank = 1; break; - case 0x3fc0: m_bank = 2; break; - case 0x3fe0: m_bank = 3; break; + // switching zones for SpellMaster + if (offset == 0x3fe0) + { + m_bank = 0; + } + else if (m_bank == 0) + { + switch (offset & 0x3fe0) + { + case 0x3fc0: m_bank = 1; break; + case 0x3fa0: m_bank = 2; break; + case 0x3f80: m_bank = 3; break; + case 0x3f60: m_bank = 4; break; + case 0x3f40: m_bank = 5; break; + case 0x3f20: m_bank = 6; break; + case 0x3f00: m_bank = 7; break; + } + } } + + return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; } +}; - return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; -} -uint8_t bbc_ccispell_device::read(offs_t offset) +// ======================> bbc_palqst_device + +class bbc_palqst_device : public bbc_pal_device { - if (!machine().side_effects_disabled()) +public: + bbc_palqst_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_PALQST, tag, owner, clock) { - /* switching zones for SpellMaster */ - if (offset == 0x3fe0) - { - m_bank = 0; - } - else if (m_bank == 0) + } + +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override + { + if (!machine().side_effects_disabled()) { + // switching zones for Quest Paint and ConQuest switch (offset & 0x3fe0) { - case 0x3fc0: m_bank = 1; break; - case 0x3fa0: m_bank = 2; break; - case 0x3f80: m_bank = 3; break; - case 0x3f60: m_bank = 4; break; - case 0x3f40: m_bank = 5; break; - case 0x3f20: m_bank = 6; break; - case 0x3f00: m_bank = 7; break; + case 0x0820: m_bank = 2; break; + case 0x11e0: m_bank = 1; break; + case 0x12c0: m_bank = 3; break; + case 0x1340: m_bank = 0; break; } } - } - - return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; -} -uint8_t bbc_palqst_device::read(offs_t offset) -{ - if (!machine().side_effects_disabled()) - { - /* switching zones for Quest Paint and ConQuest */ - switch (offset & 0x3fe0) + if (offset & 0x2000) + { + return get_rom_base()[(offset & 0x1fff) | (m_bank << 13)]; + } + else { - case 0x0820: m_bank = 2; break; - case 0x11e0: m_bank = 1; break; - case 0x12c0: m_bank = 3; break; - case 0x1340: m_bank = 0; break; + return get_rom_base()[offset & 0x1fff]; } } +}; - if (offset & 0x2000) - { - return get_rom_base()[(offset & 0x1fff) | (m_bank << 13)]; - } - else + +// ======================> bbc_palwap_device + +class bbc_palwap_device : public bbc_pal_device +{ +public: + bbc_palwap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_PALWAP, tag, owner, clock) { - return get_rom_base()[offset & 0x1fff]; } -} -uint8_t bbc_palwap_device::read(offs_t offset) -{ - if (!machine().side_effects_disabled()) +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override { - /* switching zones for Wapping Editor */ - switch (offset & 0x3fe0) + if (!machine().side_effects_disabled()) { - case 0x1f00: m_bank = 0; break; - case 0x1f20: m_bank = 1; break; - case 0x1f40: m_bank = 2; break; - case 0x1f60: m_bank = 3; break; - case 0x1f80: m_bank = 4; break; - case 0x1fa0: m_bank = 5; break; - case 0x1fc0: m_bank = 6; break; - case 0x1fe0: m_bank = 7; break; + // switching zones for Wapping Editor + switch (offset & 0x3fe0) + { + case 0x1f00: m_bank = 0; break; + case 0x1f20: m_bank = 1; break; + case 0x1f40: m_bank = 2; break; + case 0x1f60: m_bank = 3; break; + case 0x1f80: m_bank = 4; break; + case 0x1fa0: m_bank = 5; break; + case 0x1fc0: m_bank = 6; break; + case 0x1fe0: m_bank = 7; break; + } } - } - if (offset & 0x2000) - { - return get_rom_base()[(offset & 0x1fff) | (m_bank << 13)]; + if (offset & 0x2000) + { + return get_rom_base()[(offset & 0x1fff) | (m_bank << 13)]; + } + else + { + return get_rom_base()[offset & 0x1fff]; + } } - else +}; + + +// ======================> bbc_palted_device + +class bbc_palted_device : public bbc_pal_device +{ +public: + bbc_palted_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_PALTED, tag, owner, clock) { - return get_rom_base()[offset & 0x1fff]; } -} -uint8_t bbc_palted_device::read(offs_t offset) -{ - if (!machine().side_effects_disabled()) +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override { - /* switching zones for TED */ - switch (offset & 0x3fe0) + if (!machine().side_effects_disabled()) { - case 0x1f80: m_bank = 0; break; - case 0x1fa0: m_bank = 1; break; - case 0x1fc0: m_bank = 2; break; - case 0x1fe0: m_bank = 3; break; + // switching zones for TED + switch (offset & 0x3fe0) + { + case 0x1f80: m_bank = 0; break; + case 0x1fa0: m_bank = 1; break; + case 0x1fc0: m_bank = 2; break; + case 0x1fe0: m_bank = 3; break; + } } - } - if (offset & 0x2000) - { - return get_rom_base()[(offset & 0x1fff) | (m_bank << 13)]; + if (offset & 0x2000) + { + return get_rom_base()[(offset & 0x1fff) | (m_bank << 13)]; + } + else + { + return get_rom_base()[offset & 0x1fff]; + } } - else +}; + + +// ======================> bbc_palabep_device + +class bbc_palabep_device : public bbc_pal_device +{ +public: + bbc_palabep_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_PALABEP, tag, owner, clock) { - return get_rom_base()[offset & 0x1fff]; } -} -uint8_t bbc_palabep_device::read(offs_t offset) -{ - if (!machine().side_effects_disabled()) +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override { - /* switching zones for Advanced BASIC Editor Plus */ - switch (offset & 0x3ffc) + if (!machine().side_effects_disabled()) { - case 0x3ff8: m_bank = 0; break; - case 0x3ffc: m_bank = 1; break; + // switching zones for Advanced BASIC Editor Plus + switch (offset & 0x3ffc) + { + case 0x3ff8: m_bank = 0; break; + case 0x3ffc: m_bank = 1; break; + } } + + return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; } +}; - return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; -} -uint8_t bbc_palabe_device::read(offs_t offset) +// ======================> bbc_palabe_device + +class bbc_palabe_device : public bbc_pal_device { - if (!machine().side_effects_disabled()) +public: + bbc_palabe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_PALABE, tag, owner, clock) + { + } + +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override { - /* switching zones for Advanced BASIC Editor */ - switch (offset & 0x3ffc) + if (!machine().side_effects_disabled()) { - case 0x3ff8: m_bank = 1; break; - case 0x3ffc: m_bank = 0; break; + // switching zones for Advanced BASIC Editor + switch (offset & 0x3ffc) + { + case 0x3ff8: m_bank = 1; break; + case 0x3ffc: m_bank = 0; break; + } } + + return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; } +}; - return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; -} -uint8_t bbc_palmo2_device::read(offs_t offset) +// ======================> bbc_palmo2_device + +class bbc_palmo2_device : public bbc_pal_device { - if (!machine().side_effects_disabled()) +public: + bbc_palmo2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_PALMO2, tag, owner, clock) + { + } + +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override { - /* switching zones for Instant Mini Office 2 */ - switch (offset & 0x3ff0) + if (!machine().side_effects_disabled()) { - case 0x2000: m_bank = offset & 0x0f; break; + // switching zones for Instant Mini Office 2 + switch (offset & 0x3ff0) + { + case 0x2000: m_bank = offset & 0x0f; break; + } } + + return get_rom_base()[(offset & 0x3fff) | (m_bank << 13)]; } +}; - return get_rom_base()[(offset & 0x3fff) | (m_bank << 13)]; -} -uint8_t bbc_trilogy_device::read(offs_t offset) +// ======================> bbc_trilogy_device + +class bbc_trilogy_device : public bbc_pal_device { - if (!machine().side_effects_disabled()) +public: + bbc_trilogy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : bbc_pal_device(mconfig, BBC_TRILOGY, tag, owner, clock) { - /* switching zones for Acornsoft Trilogy Emulator */ - switch (offset & 0x3ff8) + } + +protected: + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override + { + if (!machine().side_effects_disabled()) { - case 0x3ff8: m_bank = offset & 0x03; break; + // switching zones for Acornsoft Trilogy Emulator + switch (offset & 0x3ff8) + { + case 0x3ff8: m_bank = offset & 0x03; break; + } } + + return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; } +}; + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- - return get_rom_base()[(offset & 0x3fff) | (m_bank << 14)]; +void bbc_pal_device::device_start() +{ + save_item(NAME(m_bank)); } + +} // anonymous namespace + + +DEFINE_DEVICE_TYPE_PRIVATE(BBC_CCIWORD, device_bbc_rom_interface, bbc_cciword_device, "bbc_cciword", "Computer Concepts 32K ROM Carrier (Inter-Word)") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_CCIBASE, device_bbc_rom_interface, bbc_ccibase_device, "bbc_ccibase", "Computer Concepts 64K ROM Carrier (Inter-Base)") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_CCISPELL, device_bbc_rom_interface, bbc_ccispell_device, "bbc_ccispell", "Computer Concepts 128K ROM Carrier (SpellMaster)") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_PALQST, device_bbc_rom_interface, bbc_palqst_device, "bbc_palqst", "Watford Electronics ROM Carrier (Quest Paint)") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_PALWAP, device_bbc_rom_interface, bbc_palwap_device, "bbc_palwap", "Watford Electronics ROM Carrier (Wapping Editor)") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_PALTED, device_bbc_rom_interface, bbc_palted_device, "bbc_palted", "Watford Electronics ROM Carrier (TED)") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_PALABEP, device_bbc_rom_interface, bbc_palabep_device, "bbc_palabep", "P.R.E.S. 32K ROM Carrier (ABE+)") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_PALABE, device_bbc_rom_interface, bbc_palabe_device, "bbc_palabe", "P.R.E.S. 32K ROM Carrier (ABE)") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_PALMO2, device_bbc_rom_interface, bbc_palmo2_device, "bbc_palmo2", "Instant Mini Office 2 ROM Carrier") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_TRILOGY, device_bbc_rom_interface, bbc_trilogy_device, "bbc_trilogy", "Acornsoft Trilogy Emulator") diff --git a/src/devices/bus/bbc/rom/pal.h b/src/devices/bus/bbc/rom/pal.h index faf14e73e54..794f1e2ac93 100644 --- a/src/devices/bus/bbc/rom/pal.h +++ b/src/devices/bus/bbc/rom/pal.h @@ -1,11 +1,5 @@ // license:BSD-3-Clause // copyright-holders:Nigel Barnes -/*************************************************************************** - - BBC Micro PALPROM carrier boards - -***************************************************************************/ - #ifndef MAME_BUS_BBC_ROM_PAL_H #define MAME_BUS_BBC_ROM_PAL_H @@ -14,168 +8,15 @@ #include "slot.h" -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> bbc_pal_device - -class bbc_pal_device : public device_t, - public device_bbc_rom_interface -{ -protected: - // construction/destruction - bbc_pal_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - - // device-level overrides - virtual void device_start() override ATTR_COLD; - - // device_bbc_rom_interface overrides - virtual uint32_t get_rom_size() override { return 0x4000; } - - uint8_t m_bank; -}; - -// ======================> bbc_cciword_device - -class bbc_cciword_device : public bbc_pal_device -{ -public: - // construction/destruction - bbc_cciword_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_ccibase_device - -class bbc_ccibase_device : public bbc_pal_device -{ -public: - // construction/destruction - bbc_ccibase_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_ccispell_device - -class bbc_ccispell_device : public bbc_pal_device -{ -public: - // construction/destruction - bbc_ccispell_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_palqst_device - -class bbc_palqst_device : public bbc_pal_device -{ -public: - bbc_palqst_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_palwap_device - -class bbc_palwap_device : public bbc_pal_device -{ -public: - bbc_palwap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_palted_device - -class bbc_palted_device : public bbc_pal_device -{ -public: - // construction/destruction - bbc_palted_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_palabep_device - -class bbc_palabep_device : public bbc_pal_device -{ -public: - // construction/destruction - bbc_palabep_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_palabe_device - -class bbc_palabe_device : public bbc_pal_device -{ -public: - // construction/destruction - bbc_palabe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_palmo2_device - -class bbc_palmo2_device : public bbc_pal_device -{ -public: - // construction/destruction - bbc_palmo2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// ======================> bbc_trilogy_device - -class bbc_trilogy_device : public bbc_pal_device -{ -public: - // construction/destruction - bbc_trilogy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - - -// device type definition -DECLARE_DEVICE_TYPE(BBC_CCIWORD, bbc_cciword_device) -DECLARE_DEVICE_TYPE(BBC_CCIBASE, bbc_ccibase_device) -DECLARE_DEVICE_TYPE(BBC_CCISPELL, bbc_ccispell_device) -DECLARE_DEVICE_TYPE(BBC_PALQST, bbc_palqst_device) -DECLARE_DEVICE_TYPE(BBC_PALWAP, bbc_palwap_device) -DECLARE_DEVICE_TYPE(BBC_PALTED, bbc_palted_device) -DECLARE_DEVICE_TYPE(BBC_PALABEP, bbc_palabep_device) -DECLARE_DEVICE_TYPE(BBC_PALABE, bbc_palabe_device) -DECLARE_DEVICE_TYPE(BBC_PALMO2, bbc_palmo2_device) -DECLARE_DEVICE_TYPE(BBC_TRILOGY, bbc_trilogy_device) - +DECLARE_DEVICE_TYPE(BBC_CCIWORD, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_CCIBASE, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_CCISPELL, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_PALQST, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_PALWAP, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_PALTED, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_PALABEP, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_PALABE, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_PALMO2, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_TRILOGY, device_bbc_rom_interface) #endif // MAME_BUS_BBC_ROM_PAL_H diff --git a/src/devices/bus/bbc/rom/ram.cpp b/src/devices/bus/bbc/rom/ram.cpp index bbe5d956006..e075d9906fe 100644 --- a/src/devices/bus/bbc/rom/ram.cpp +++ b/src/devices/bus/bbc/rom/ram.cpp @@ -10,25 +10,33 @@ #include "ram.h" -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** +namespace { -DEFINE_DEVICE_TYPE(BBC_RAM, bbc_ram_device, "bbc_ram", "BBC Micro Sideways RAM") +class bbc_ram_device : public device_t, public device_bbc_rom_interface +{ +public: + bbc_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_RAM, tag, owner, clock) + , device_bbc_rom_interface(mconfig, *this) + { + } -//************************************************************************** -// LIVE DEVICE -//************************************************************************** +protected: + // device_t overrides + virtual void device_start() override ATTR_COLD; -//------------------------------------------------- -// bbc_ram_device - constructor -//------------------------------------------------- + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override + { + return get_ram_base()[offset & (get_ram_size() - 1)]; + } + + virtual void write(offs_t offset, uint8_t data) override + { + get_ram_base()[offset & (get_ram_size() - 1)] = data; + } +}; -bbc_ram_device::bbc_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, BBC_RAM, tag, owner, clock) - , device_bbc_rom_interface(mconfig, *this) -{ -} //------------------------------------------------- // device_start - device-specific startup @@ -39,20 +47,7 @@ void bbc_ram_device::device_start() ram_alloc(0x8000); } -//------------------------------------------------- -// read -//------------------------------------------------- +} // anonymous namespace -uint8_t bbc_ram_device::read(offs_t offset) -{ - return get_ram_base()[offset & (get_ram_size() - 1)]; -} -//------------------------------------------------- -// write -//------------------------------------------------- - -void bbc_ram_device::write(offs_t offset, uint8_t data) -{ - get_ram_base()[offset & (get_ram_size() - 1)] = data; -} +DEFINE_DEVICE_TYPE_PRIVATE(BBC_RAM, device_bbc_rom_interface, bbc_ram_device, "bbc_ram", "BBC Micro Sideways RAM") diff --git a/src/devices/bus/bbc/rom/ram.h b/src/devices/bus/bbc/rom/ram.h index 39a3e49a817..bbb5f1dbf0b 100644 --- a/src/devices/bus/bbc/rom/ram.h +++ b/src/devices/bus/bbc/rom/ram.h @@ -1,11 +1,5 @@ // license:BSD-3-Clause // copyright-holders:Nigel Barnes -/*************************************************************************** - - BBC Micro Sideways RAM emulation - -***************************************************************************/ - #ifndef MAME_BUS_BBC_ROM_RAM_H #define MAME_BUS_BBC_ROM_RAM_H @@ -13,30 +7,7 @@ #include "slot.h" -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> bbc_ram_device - -class bbc_ram_device : public device_t, - public device_bbc_rom_interface -{ -public: - // construction/destruction - bbc_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device-level overrides - virtual void device_start() override ATTR_COLD; - - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; - virtual void write(offs_t offset, uint8_t data) override; -}; - -// device type definition -DECLARE_DEVICE_TYPE(BBC_RAM, bbc_ram_device) +DECLARE_DEVICE_TYPE(BBC_RAM, device_bbc_rom_interface) #endif // MAME_BUS_BBC_ROM_RAM_H diff --git a/src/devices/bus/bbc/rom/rom.cpp b/src/devices/bus/bbc/rom/rom.cpp index f419998510b..b57fa6cfe77 100644 --- a/src/devices/bus/bbc/rom/rom.cpp +++ b/src/devices/bus/bbc/rom/rom.cpp @@ -10,39 +10,29 @@ #include "rom.h" -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** +namespace { -DEFINE_DEVICE_TYPE(BBC_ROM, bbc_rom_device, "bbc_rom", "BBC Micro Sideways ROM") - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// bbc_rom_device - constructor -//------------------------------------------------- - -bbc_rom_device::bbc_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, BBC_ROM, tag, owner, clock) - , device_bbc_rom_interface(mconfig, *this) +class bbc_rom_device : public device_t, public device_bbc_rom_interface { -} +public: + bbc_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_ROM, tag, owner, clock) + , device_bbc_rom_interface(mconfig, *this) + { + } -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- +protected: + // device_t overrides + virtual void device_start() override ATTR_COLD { } -void bbc_rom_device::device_start() -{ -} + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override + { + return get_rom_base()[offset & (get_rom_size() - 1)]; + } +}; -//------------------------------------------------- -// read -//------------------------------------------------- +} // anonymous namespace -uint8_t bbc_rom_device::read(offs_t offset) -{ - return get_rom_base()[offset & (get_rom_size() - 1)]; -} + +DEFINE_DEVICE_TYPE_PRIVATE(BBC_ROM, device_bbc_rom_interface, bbc_rom_device, "bbc_rom", "BBC Micro Sideways ROM") diff --git a/src/devices/bus/bbc/rom/rom.h b/src/devices/bus/bbc/rom/rom.h index 0d1a7159278..1e1835d0136 100644 --- a/src/devices/bus/bbc/rom/rom.h +++ b/src/devices/bus/bbc/rom/rom.h @@ -1,11 +1,5 @@ // license:BSD-3-Clause // copyright-holders:Nigel Barnes -/*************************************************************************** - - BBC Micro Sideways ROM emulation - -***************************************************************************/ - #ifndef MAME_BUS_BBC_ROM_ROM_H #define MAME_BUS_BBC_ROM_ROM_H @@ -13,29 +7,7 @@ #include "slot.h" -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> bbc_rom_device - -class bbc_rom_device : public device_t, - public device_bbc_rom_interface -{ -public: - // construction/destruction - bbc_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device-level overrides - virtual void device_start() override ATTR_COLD; - - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -}; - -// device type definition -DECLARE_DEVICE_TYPE(BBC_ROM, bbc_rom_device) +DECLARE_DEVICE_TYPE(BBC_ROM, device_bbc_rom_interface) #endif // MAME_BUS_BBC_ROM_ROM_H diff --git a/src/devices/bus/bbc/rom/rtc.cpp b/src/devices/bus/bbc/rom/rtc.cpp index e2c34beb20d..6e8ef5da53b 100644 --- a/src/devices/bus/bbc/rom/rtc.cpp +++ b/src/devices/bus/bbc/rom/rtc.cpp @@ -13,64 +13,81 @@ #include "emu.h" #include "rtc.h" +#include "machine/ds1215.h" +#include "machine/mc146818.h" -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** -DEFINE_DEVICE_TYPE(BBC_STLRTC, bbc_stlrtc_device, "bbc_stlrtc", "Solidisk Real Time Clock") -DEFINE_DEVICE_TYPE(BBC_PMSRTC, bbc_pmsrtc_device, "bbc_pmsrtc", "PMS Genie Real Time Clock") +namespace { +// ======================> bbc_stlrtc_device -//------------------------------------------------- -// device_add_mconfig - add device configuration -//------------------------------------------------- - -void bbc_stlrtc_device::device_add_mconfig(machine_config &config) +class bbc_stlrtc_device : public device_t, public device_bbc_rom_interface { - MC146818(config, m_rtc, 32.768_kHz_XTAL); // TODO: verify clock -} +public: + bbc_stlrtc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_STLRTC, tag, owner, clock) + , device_bbc_rom_interface(mconfig, *this) + , m_rtc(*this, "rtc") + { + } -void bbc_pmsrtc_device::device_add_mconfig(machine_config &config) -{ - /* Dallas DS1216 SmartWatch ROM */ - DS1216E(config, m_rtc); -} +protected: + // device_t overrides + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; -//************************************************************************** -// LIVE DEVICE -//************************************************************************** + virtual void device_start() override ATTR_COLD { } -//------------------------------------------------- -// bbc_stlrtc_device - constructor -//------------------------------------------------- + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override; -bbc_stlrtc_device::bbc_stlrtc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, BBC_STLRTC, tag, owner, clock) - , device_bbc_rom_interface(mconfig, *this) - , m_rtc(*this, "rtc") -{ -} +private: + required_device<mc146818_device> m_rtc; +}; + + +// ======================> bbc_pmsrtc_device -bbc_pmsrtc_device::bbc_pmsrtc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, BBC_PMSRTC, tag, owner, clock) - , device_bbc_rom_interface(mconfig, *this) - , m_rtc(*this, "rtc") +class bbc_pmsrtc_device : public device_t, public device_bbc_rom_interface { -} +public: + bbc_pmsrtc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_PMSRTC, tag, owner, clock) + , device_bbc_rom_interface(mconfig, *this) + , m_rtc(*this, "rtc") + { + } + +protected: + // device_t overrides + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; + + virtual void device_start() override ATTR_COLD { } + + // device_bbc_rom_interface overrides + virtual uint8_t read(offs_t offset) override; + +private: + required_device<ds1216e_device> m_rtc; +}; + //------------------------------------------------- -// device_start - device-specific startup +// device_add_mconfig - add device configuration //------------------------------------------------- -void bbc_stlrtc_device::device_start() +void bbc_stlrtc_device::device_add_mconfig(machine_config &config) { + MC146818(config, m_rtc, 32.768_kHz_XTAL); // TODO: verify clock } -void bbc_pmsrtc_device::device_start() + +void bbc_pmsrtc_device::device_add_mconfig(machine_config &config) { + // Dallas DS1216 SmartWatch ROM + DS1216E(config, m_rtc); } + //------------------------------------------------- // read //------------------------------------------------- @@ -103,6 +120,7 @@ uint8_t bbc_stlrtc_device::read(offs_t offset) return data; } + uint8_t bbc_pmsrtc_device::read(offs_t offset) { uint8_t data = get_rom_base()[offset & 0x1fff]; @@ -114,3 +132,9 @@ uint8_t bbc_pmsrtc_device::read(offs_t offset) return data; } + +} // anonymous namespace + + +DEFINE_DEVICE_TYPE_PRIVATE(BBC_STLRTC, device_bbc_rom_interface, bbc_stlrtc_device, "bbc_stlrtc", "Solidisk Real Time Clock") +DEFINE_DEVICE_TYPE_PRIVATE(BBC_PMSRTC, device_bbc_rom_interface, bbc_pmsrtc_device, "bbc_pmsrtc", "PMS Genie Real Time Clock") diff --git a/src/devices/bus/bbc/rom/rtc.h b/src/devices/bus/bbc/rom/rtc.h index d975fed41ce..948140de8d2 100644 --- a/src/devices/bus/bbc/rom/rtc.h +++ b/src/devices/bus/bbc/rom/rtc.h @@ -1,72 +1,14 @@ // license:BSD-3-Clause // copyright-holders:Nigel Barnes -/*************************************************************************** - - Solidisk Real Time Clock emulation - - PMS Genie Watch (RTC for the BBC) - -***************************************************************************/ - #ifndef MAME_BUS_BBC_ROM_RTC_H #define MAME_BUS_BBC_ROM_RTC_H #pragma once #include "slot.h" -#include "machine/mc146818.h" -#include "machine/ds1215.h" - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> bbc_stlrtc_device - -class bbc_stlrtc_device : public device_t, - public device_bbc_rom_interface -{ -public: - // construction/destruction - bbc_stlrtc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device-level overrides - virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; - - virtual void device_start() override ATTR_COLD; - - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; - -private: - required_device<mc146818_device> m_rtc; -}; - -// ======================> bbc_pmsrtc_device - -class bbc_pmsrtc_device : public device_t, - public device_bbc_rom_interface -{ -public: - // construction/destruction - bbc_pmsrtc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // device-level overrides - virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; - - virtual void device_start() override ATTR_COLD; - - // device_bbc_rom_interface overrides - virtual uint8_t read(offs_t offset) override; -private: - required_device<ds1216e_device> m_rtc; -}; -// device type definition -DECLARE_DEVICE_TYPE(BBC_STLRTC, bbc_stlrtc_device) -DECLARE_DEVICE_TYPE(BBC_PMSRTC, bbc_pmsrtc_device) +DECLARE_DEVICE_TYPE(BBC_STLRTC, device_bbc_rom_interface) +DECLARE_DEVICE_TYPE(BBC_PMSRTC, device_bbc_rom_interface) #endif // MAME_BUS_BBC_ROM_RTC_H |
