summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus
diff options
context:
space:
mode:
author Peter Ferrie <peter.ferrie@gmail.com>2017-03-02 21:01:44 -0800
committer Peter Ferrie <peter.ferrie@gmail.com>2017-03-02 21:01:58 -0800
commita23d008d861af88316a86e97b9b4c093dfec4eb8 (patch)
tree2f967b2ea1c6d9babd28610273d32dcecf0c726e /src/devices/bus
parent7e9e3f5b4d226fea435da4c829bcb83907d1de7b (diff)
apple2: simplify LC handling even further (nw)
Diffstat (limited to 'src/devices/bus')
-rw-r--r--src/devices/bus/a2bus/ramcard16k.cpp60
-rw-r--r--src/devices/bus/a2bus/ramcard16k.h5
2 files changed, 38 insertions, 27 deletions
diff --git a/src/devices/bus/a2bus/ramcard16k.cpp b/src/devices/bus/a2bus/ramcard16k.cpp
index cbde471a14c..3feb4a62bd3 100644
--- a/src/devices/bus/a2bus/ramcard16k.cpp
+++ b/src/devices/bus/a2bus/ramcard16k.cpp
@@ -31,13 +31,13 @@ const device_type A2BUS_RAMCARD16K = device_creator<a2bus_ramcard_device>;
a2bus_ramcard_device::a2bus_ramcard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source) :
device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_last_offset(0), m_last_access(0), m_dxxx_bank(0)
+ device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_prewrite(false), m_dxxx_bank(0)
{
}
a2bus_ramcard_device::a2bus_ramcard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, A2BUS_RAMCARD16K, "Apple II 16K Language Card", tag, owner, clock, "a2ram16k", __FILE__),
- device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_last_offset(0), m_last_access(0), m_dxxx_bank(0)
+ device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_prewrite(false), m_dxxx_bank(0)
{
}
@@ -55,51 +55,63 @@ void a2bus_ramcard_device::device_start()
save_item(NAME(m_inh_state));
save_item(NAME(m_ram));
save_item(NAME(m_dxxx_bank));
- save_item(NAME(m_last_offset));
- save_item(NAME(m_last_access));
+ save_item(NAME(m_prewrite));
}
void a2bus_ramcard_device::device_reset()
{
m_inh_state = INH_WRITE;
m_dxxx_bank = 0;
- m_last_offset = -1;
- m_last_access = 0;
+ m_prewrite = false;
}
-void a2bus_ramcard_device::do_io(int offset, int access)
+void a2bus_ramcard_device::do_io(int offset, bool writing)
{
int old_inh_state = m_inh_state;
- m_inh_state = INH_NONE;
+ //any even access disables pre-write and writing
+ if ((offset & 1) == 0)
+ {
+ m_prewrite = false;
+ m_inh_state &= ~INH_WRITE;
+ }
- switch (offset & 3)
+ //any write disables pre-write
+ //has no effect on write-enable if writing was enabled already
+ if (writing == true)
{
- case 0:
+ m_prewrite = false;
+ }
+ //first odd read enables pre-write, second one enables writing
+ else if ((offset & 1) == 1)
+ {
+ if (m_prewrite == false)
{
- m_inh_state = INH_READ;
- break;
+ m_prewrite = true;
+ }
+ else
+ {
+ m_inh_state |= INH_WRITE;
}
+ }
+ switch (offset & 3)
+ {
+ case 0:
case 3:
{
- m_inh_state = INH_READ;
- } //fall through
+ m_inh_state |= INH_READ;
+ break;
+ }
case 1:
+ case 2:
{
- //if accessed twice, then write-enable
- if (((m_last_offset & 1) == 1) && (access == m_last_access))
- {
- m_inh_state |= INH_WRITE;
- }
-
+ m_inh_state &= ~INH_READ;
break;
}
}
- m_last_offset = offset;
- m_last_access = access;
m_dxxx_bank = 0;
if (!(offset & 8))
@@ -127,7 +139,7 @@ void a2bus_ramcard_device::do_io(int offset, int access)
uint8_t a2bus_ramcard_device::read_c0nx(address_space &space, uint8_t offset)
{
- do_io(offset & 0xf, 0);
+ do_io(offset & 0xf, false);
return 0xff;
}
@@ -138,7 +150,7 @@ uint8_t a2bus_ramcard_device::read_c0nx(address_space &space, uint8_t offset)
void a2bus_ramcard_device::write_c0nx(address_space &space, uint8_t offset, uint8_t data)
{
- do_io(offset & 0xf, 1);
+ do_io(offset & 0xf, true);
}
uint8_t a2bus_ramcard_device::read_inh_rom(address_space &space, uint16_t offset)
diff --git a/src/devices/bus/a2bus/ramcard16k.h b/src/devices/bus/a2bus/ramcard16k.h
index 2180e2bf826..abfceec35d9 100644
--- a/src/devices/bus/a2bus/ramcard16k.h
+++ b/src/devices/bus/a2bus/ramcard16k.h
@@ -40,11 +40,10 @@ protected:
virtual int inh_type() override;
private:
- void do_io(int offset, int access);
+ void do_io(int offset, bool writing);
int m_inh_state;
- int m_last_offset;
- int m_last_access;
+ bool m_prewrite;
int m_dxxx_bank;
uint8_t m_ram[16*1024];
};