Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trs/mc10.cpp: Add "Multiport" cartridge and RAM expansion for the Mat…
…ra & Hachette Alice (#12080)
- Loading branch information
Showing
4 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/*************************************************************************** | ||
multiports_ext.cpp | ||
Emulation of the Alice Multiports Extension | ||
Features: | ||
The extension provides an extension doubler and two joystick ports. | ||
The extension also provides (for the whole Alice family and MC-10): | ||
- 16K of RAM expansion ($5000-$8FFF) | ||
- 64K of ROM expansion in two possible configurations: | ||
- 8K of ROM between $1000 and $2FFF, as 8 banks (Cartridge mode). | ||
- 16K of ROM between $C000 and $FFFF, as 4 banks (ROM mode). | ||
Only the RAM/ROM expansion is emulated here. | ||
Banks are selected by writing to: | ||
- $1000 to $1FFF in Cartridge mode (number of bank between 0 and 7) | ||
- $C000 to $CFFF in ROM mode (number of bank between 0 and 3) | ||
***************************************************************************/ | ||
|
||
#include "emu.h" | ||
#include "multiports_ext.h" | ||
|
||
//************************************************************************** | ||
// TYPE DECLARATIONS | ||
//************************************************************************** | ||
|
||
class mc10_multiports_ext_device : public device_t, | ||
public device_mc10cart_interface | ||
{ | ||
public: | ||
mc10_multiports_ext_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); | ||
|
||
virtual int max_rom_length() const override; | ||
virtual std::pair<std::error_condition, std::string> load() override; | ||
|
||
protected: | ||
mc10_multiports_ext_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); | ||
|
||
// device_t implementation | ||
virtual void device_start() override; | ||
virtual void device_reset() override; | ||
virtual void device_post_load() override; | ||
|
||
void control_register_write(offs_t offset, u8 data); | ||
|
||
void multiports_mem(address_map &map); | ||
void update_bank(); | ||
|
||
private: | ||
memory_bank_creator m_bank; | ||
uint8_t rom_bank_index; | ||
memory_share_creator<u8> m_extention_ram; | ||
}; | ||
|
||
DEFINE_DEVICE_TYPE_PRIVATE(ALICE_MULTIPORTS_EXT, device_mc10cart_interface, mc10_multiports_ext_device, "mc10_multiports_ext", "Fred_72 and 6502man's Multiports Extension") | ||
|
||
//------------------------------------------------- | ||
// IMPLEMENTATION | ||
//------------------------------------------------- | ||
|
||
mc10_multiports_ext_device::mc10_multiports_ext_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) | ||
: mc10_multiports_ext_device(mconfig, ALICE_MULTIPORTS_EXT, tag, owner, clock) | ||
{ | ||
} | ||
|
||
mc10_multiports_ext_device::mc10_multiports_ext_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) | ||
: device_t(mconfig, type, tag, owner, clock), device_mc10cart_interface(mconfig, *this), m_bank(*this, "cart_bank"), rom_bank_index(0), m_extention_ram(*this, "ext_ram", 1024 * 16, ENDIANNESS_BIG) | ||
{ | ||
} | ||
|
||
int mc10_multiports_ext_device::max_rom_length() const | ||
{ | ||
return 1024 * 64; | ||
} | ||
|
||
void mc10_multiports_ext_device::multiports_mem(address_map &map) | ||
{ | ||
map(0x0000, 0x1fff).bankr("cart_bank").w(FUNC(mc10_multiports_ext_device::control_register_write)); | ||
} | ||
|
||
//------------------------------------------------- | ||
|
||
void mc10_multiports_ext_device::device_start() | ||
{ | ||
save_item(NAME(rom_bank_index)); | ||
|
||
owning_slot().memspace().install_device(0x1000, 0x2fff, *this, &mc10_multiports_ext_device::multiports_mem); | ||
owning_slot().memspace().install_ram(0x5000, 0x8fff, &m_extention_ram[0]); | ||
} | ||
|
||
//------------------------------------------------- | ||
|
||
void mc10_multiports_ext_device::device_reset() | ||
{ | ||
rom_bank_index = 0; | ||
update_bank(); | ||
} | ||
|
||
void mc10_multiports_ext_device::device_post_load() | ||
{ | ||
update_bank(); | ||
} | ||
|
||
void mc10_multiports_ext_device::control_register_write(offs_t offset, u8 data) | ||
{ | ||
if (offset < 0x1000) | ||
{ | ||
rom_bank_index = data & 0x07; | ||
update_bank(); | ||
} | ||
} | ||
|
||
void mc10_multiports_ext_device::update_bank() | ||
{ | ||
m_bank.target()->set_entry(rom_bank_index); | ||
} | ||
|
||
std::pair<std::error_condition, std::string> mc10_multiports_ext_device::load() | ||
{ | ||
memory_region *const romregion(memregion("^rom")); | ||
if (!romregion) | ||
{ | ||
return std::make_pair(image_error::BADSOFTWARE, "Software item lacks 'rom' data area"); | ||
} | ||
|
||
m_bank.target()->configure_entries(0, 8, romregion->base(), 0x2000); | ||
|
||
return std::make_pair(std::error_condition(), std::string()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef MAME_BUS_MC10_MULTIPORTS_EXT_H | ||
#define MAME_BUS_MC10_MULTIPORTS_EXT_H | ||
|
||
#pragma once | ||
|
||
#include "mc10_cart.h" | ||
|
||
// device type definition | ||
DECLARE_DEVICE_TYPE(ALICE_MULTIPORTS_EXT, device_mc10cart_interface) | ||
|
||
#endif // MAME_BUS_MC10_MC10_MULTIPORTS_EXT_H | ||
|