apple2: rewrote 16k language card to pass Zellyn/qkumba tests [R. Belmont]

This commit is contained in:
arbee 2017-02-27 23:43:15 -05:00
parent 3e92c83669
commit f271ad3672
2 changed files with 45 additions and 30 deletions

View File

@ -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) : 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_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) : 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_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_inh_state));
save_item(NAME(m_ram)); save_item(NAME(m_ram));
save_item(NAME(m_dxxx_bank)); save_item(NAME(m_dxxx_bank));
save_item(NAME(m_last_offset)); save_item(NAME(m_writecnt));
} }
void a2bus_ramcard_device::device_reset() void a2bus_ramcard_device::device_reset()
{ {
m_inh_state = INH_NONE; m_inh_state = INH_NONE;
m_dxxx_bank = 0; 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; int old_inh_state = m_inh_state;
switch (offset)
{
case 0x1: case 0x3: case 0x9: case 0xb:
if (offset != m_last_offset)
{
m_last_offset = offset;
return;
}
break;
}
m_last_offset = offset;
m_inh_state = INH_NONE; m_inh_state = INH_NONE;
m_dxxx_bank = 0; m_dxxx_bank = 0;
if (offset & 0x1) switch (offset)
{ {
m_inh_state |= INH_WRITE; 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_writecnt = 0;
}
else
{
m_writecnt++;
}
break;
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: m_inh_state |= INH_WRITE;
case 0x03:
m_inh_state |= INH_READ;
break;
} }
if (!(offset & 8)) 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) uint8_t a2bus_ramcard_device::read_c0nx(address_space &space, uint8_t offset)
{ {
do_io(offset & 0xf); do_io(offset & 0xf, false);
return 0xff; 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) 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) uint8_t a2bus_ramcard_device::read_inh_rom(address_space &space, uint16_t offset)

View File

@ -40,10 +40,10 @@ protected:
virtual int inh_type() override; virtual int inh_type() override;
private: private:
void do_io(int offset); void do_io(int offset, bool write);
int m_inh_state; int m_inh_state;
int m_last_offset; int m_writecnt;
int m_dxxx_bank; int m_dxxx_bank;
uint8_t m_ram[16*1024]; uint8_t m_ram[16*1024];
}; };