diff options
author | 2017-05-07 23:18:47 +1000 | |
---|---|---|
committer | 2017-05-14 21:44:11 +1000 | |
commit | 0f0d39ef81562c75e79176dd3bebb1e491ca39d5 (patch) | |
tree | 201cee7fdf55ee800f83859a92efd2cfe66cf2b3 /src/devices/bus/ti99/peb/samsmem.cpp | |
parent | e6c4be2b4d71c7a6c95be0bae111eb416ff0f9e7 (diff) |
Move static data out of devices into the device types. This is a significant change, so please pay attention.
The core changes are:
* Short name, full name and source file are no longer members of device_t, they are part of the device type
* MACHINE_COFIG_START no longer needs a driver class
* MACHINE_CONFIG_DERIVED_CLASS is no longer necessary
* Specify the state class you want in the GAME/COMP/CONS line
* The compiler will work out the base class where the driver init member is declared
* There is one static device type object per driver rather than one per machine configuration
Use DECLARE_DEVICE_TYPE or DECLARE_DEVICE_TYPE_NS to declare device type.
* DECLARE_DEVICE_TYPE forward-declares teh device type and class, and declares extern object finders.
* DECLARE_DEVICE_TYPE_NS is for devices classes in namespaces - it doesn't forward-declare the device type.
Use DEFINE_DEVICE_TYPE or DEFINE_DEVICE_TYPE_NS to define device types.
* These macros declare storage for the static data, and instantiate the device type and device finder templates.
The rest of the changes are mostly just moving stuff out of headers that shouldn't be there, renaming stuff for consistency, and scoping stuff down where appropriate.
Things I've actually messed with substantially:
* More descriptive names for a lot of devices
* Untangled the fantasy sound from the driver state, which necessitates breaking up sound/flip writes
* Changed DECO BSMT2000 ready callback into a device delegate
* Untangled Microprose 3D noise from driver state
* Used object finders for CoCo multipak, KC85 D002, and Irem sound subdevices
* Started to get TI-99 stuff out of the TI-990 directory and arrange bus devices properly
* Started to break out common parts of Samsung ARM SoC devices
* Turned some of FM, SID, SCSP DSP, EPIC12 and Voodoo cores into something resmbling C++
* Tried to make Z180 table allocation/setup a bit safer
* Converted generic keyboard/terminal to not use WRITE8 - space/offset aren't relevant
* Dynamically allocate generic terminal buffer so derived devices (e.g. teleprinter) can specify size
* Imporved encapsulation of Z80DART channels
* Refactored the SPC7110 bit table generator loop to make it more readable
* Added wrappers for SNES PPU operations so members can be made protected
* Factored out some boilerplate for YM chips with PSG
* toaplan2 gfx
* stic/intv resolution
* Video System video
* Out Run/Y-board sprite alignment
* GIC video hookup
* Amstrad CPC ROM box members
* IQ151 ROM cart region
* MSX cart IRQ callback resolution time
* SMS passthrough control devices starting subslots
I've smoke-tested several drivers, but I've probably missed something. Things I've missed will likely blow up spectacularly with failure to bind errors and the like. Let me know if there's more subtle breakage (could have happened in FM or Voodoo).
And can everyone please, please try to keep stuff clean. In particular, please stop polluting the global namespace. Keep things out of headers that don't need to be there, and use things that can be scoped down rather than macros.
It feels like an uphill battle trying to get this stuff under control while more of it's added.
Diffstat (limited to 'src/devices/bus/ti99/peb/samsmem.cpp')
-rw-r--r-- | src/devices/bus/ti99/peb/samsmem.cpp | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/src/devices/bus/ti99/peb/samsmem.cpp b/src/devices/bus/ti99/peb/samsmem.cpp new file mode 100644 index 00000000000..dc4e1694822 --- /dev/null +++ b/src/devices/bus/ti99/peb/samsmem.cpp @@ -0,0 +1,136 @@ +// license:LGPL-2.1+ +// copyright-holders:Michael Zapf +/**************************************************************************** + + TI-99 SuperAMS Memory Expansion Card. Uses a 74LS612 memory mapper. + The card can be equipped with up to 1 MiB of static CMOS memory; it is + not buffered, however. + + SAMS organizes memory in 4 KiB blocks which are mapped into the address + space by a memory mapper. The mapper can be configured via a sequence of + addresses at 4000, 4002, ..., 401e, which correspond to memory locations + 0000-0fff, 1000-1fff, ..., f000-ffff. + + According to a software distribution disk from the South West 99ers group, + the predecessor of this card was the Asgard Expanded Memory System (AEMS). + Although some documentation and software was available for it, it was never + built. Instead, a simpler memory card called the Asgard Memory System (AMS) + was built. The South West 99ers group built a better version of this card + called the Super AMS. Any documentation and software containing a reference + to the AEMS are applicable to either AMS or SAMS. + + Michael Zapf + +*****************************************************************************/ + +#include "emu.h" +#include "samsmem.h" + +#define SAMS_CRU_BASE 0x1e00 + +sams_memory_expansion_device::sams_memory_expansion_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : ti_expansion_card_device(mconfig, TI99_SAMSMEM, tag, owner, clock), + m_ram(*this, RAM_TAG), + m_map_mode(false), m_access_mapper(false) +{ +} + +/* + Memory read. The SAMS card has two address areas: The memory is at locations + 0x2000-0x3fff and 0xa000-0xffff, and the mapper area is at 0x4000-0x401e + (only even addresses). +*/ +READ8Z_MEMBER(sams_memory_expansion_device::readz) +{ + int base; + + if (m_access_mapper && ((offset & 0xe000)==0x4000)) + { + *value = m_mapper[(offset>>1)&0x000f]; + } + + if (((offset & 0xe000)==0x2000) || ((offset & 0xe000)==0xa000) || ((offset & 0xe000)==0xc000) || ((offset & 0xe000)==0xe000)) + { + if (!m_map_mode) + { + // transparent mode + *value = m_ram->pointer()[offset & 0xffff]; + } + else + { + base = (m_mapper[(offset & 0xf000)>>12] << 12); + *value = m_ram->pointer()[base | (offset & 0x0fff)]; + } + } +} + +WRITE8_MEMBER(sams_memory_expansion_device::write) +{ + int base; + + if (m_access_mapper && ((offset & 0xe000)==0x4000)) + { + m_mapper[(offset>>1)&0x000f] = data; + } + + if (((offset & 0xe000)==0x2000) || ((offset & 0xe000)==0xa000) || ((offset & 0xe000)==0xc000) || ((offset & 0xe000)==0xe000)) + { + if (!m_map_mode) + { + // transparent mode + m_ram->pointer()[offset & 0xffff] = data; + } + else + { + base = (m_mapper[(offset & 0xf000)>>12] << 12); + m_ram->pointer()[base | (offset & 0x0fff)] = data; + } + } +} + +/* + CRU read. None here. +*/ +READ8Z_MEMBER(sams_memory_expansion_device::crureadz) +{ +} + +/* + CRU write. Turns on the mapper and allows to change it. +*/ +WRITE8_MEMBER(sams_memory_expansion_device::cruwrite) +{ + if ((offset & 0xff00)==SAMS_CRU_BASE) + { + if ((offset & 0x000e)==0) m_access_mapper = (data!=0); + if ((offset & 0x000e)==2) m_map_mode = (data!=0); + } +} + +MACHINE_CONFIG_FRAGMENT( sams_mem ) + MCFG_RAM_ADD(RAM_TAG) + MCFG_RAM_DEFAULT_SIZE("1M") + MCFG_RAM_DEFAULT_VALUE(0) +MACHINE_CONFIG_END + +machine_config_constructor sams_memory_expansion_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( sams_mem ); +} + +void sams_memory_expansion_device::device_start() +{ + save_pointer(NAME(m_mapper),16); + save_item(NAME(m_map_mode)); + save_item(NAME(m_mapper)); +} + +void sams_memory_expansion_device::device_reset() +{ + // Resetting values + m_map_mode = false; + m_access_mapper = false; + for (auto & elem : m_mapper) elem = 0; +} + +DEFINE_DEVICE_TYPE(TI99_SAMSMEM, sams_memory_expansion_device, "ti99_sams", "SuperAMS memory expansion card") |