summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author arbee <rb6502@users.noreply.github.com>2017-02-27 23:43:15 -0500
committer arbee <rb6502@users.noreply.github.com>2017-02-27 23:43:15 -0500
commitf271ad36726211075b7d6803fbcfca2d05af90e2 (patch)
tree53149c28060cd19700d5501187cba95cfa555c31
parent3e92c836699f568bd948debf2cbcb1d21b1e5c33 (diff)
apple2: rewrote 16k language card to pass Zellyn/qkumba tests [R. Belmont]
-rw-r--r--src/devices/bus/a2bus/ramcard16k.cpp65
-rw-r--r--src/devices/bus/a2bus/ramcard16k.h4
2 files changed, 42 insertions, 27 deletions
diff --git a/src/devices/bus/a2bus/ramcard16k.cpp b/src/devices/bus/a2bus/ramcard16k.cpp
index 22978a214af..3c03ecba37f 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_dxxx_bank(0)
+ device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_writecnt(0), 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_dxxx_bank(0)
+ device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_writecnt(0), m_dxxx_bank(0)
{
}
@@ -55,46 +55,61 @@ 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_writecnt));
}
void a2bus_ramcard_device::device_reset()
{
m_inh_state = INH_NONE;
m_dxxx_bank = 0;
- m_last_offset = -1;
+ m_writecnt = 0;
}
-void a2bus_ramcard_device::do_io(int offset)
+void a2bus_ramcard_device::do_io(int offset, bool write)
{
int old_inh_state = m_inh_state;
+ m_inh_state = INH_NONE;
+ m_dxxx_bank = 0;
+
switch (offset)
{
- case 0x1: case 0x3: case 0x9: case 0xb:
- if (offset != m_last_offset)
+ case 0x0: case 0x8: case 0x4: case 0xc:
+ m_writecnt = 0;
+ m_inh_state = INH_READ;
+ break;
+
+ case 0x1: case 0x9: case 0x5: case 0xd:
+ if (write)
{
- m_last_offset = offset;
- return;
+ m_writecnt = 0;
}
+ else
+ {
+ m_writecnt++;
+ }
break;
- }
- m_last_offset = offset;
- m_inh_state = INH_NONE;
- m_dxxx_bank = 0;
-
- if (offset & 0x1)
- {
- m_inh_state |= INH_WRITE;
+ case 0x2: case 0xa: case 0x6: case 0xe:
+ m_writecnt = 0;
+ break;
+
+ case 0x3: case 0xb: case 0x7: case 0xf:
+ if (write)
+ {
+ m_writecnt = 0;
+ }
+ else
+ {
+ m_writecnt++;
+ }
+ m_inh_state = INH_READ;
+ break;
}
-
- switch(offset & 0x03)
+
+ if (m_writecnt >= 2)
{
- case 0x00:
- case 0x03:
- m_inh_state |= INH_READ;
- break;
+ m_inh_state |= INH_WRITE;
}
if (!(offset & 8))
@@ -122,7 +137,7 @@ void a2bus_ramcard_device::do_io(int offset)
uint8_t a2bus_ramcard_device::read_c0nx(address_space &space, uint8_t offset)
{
- do_io(offset & 0xf);
+ do_io(offset & 0xf, false);
return 0xff;
}
@@ -133,7 +148,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);
+ 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 67676fe50b5..2484d65cfba 100644
--- a/src/devices/bus/a2bus/ramcard16k.h
+++ b/src/devices/bus/a2bus/ramcard16k.h
@@ -40,10 +40,10 @@ protected:
virtual int inh_type() override;
private:
- void do_io(int offset);
+ void do_io(int offset, bool write);
int m_inh_state;
- int m_last_offset;
+ int m_writecnt;
int m_dxxx_bank;
uint8_t m_ram[16*1024];
};