c128: Emulated the PARTNER 128 cartridge. [Curt Coder]

This commit is contained in:
Curt Coder 2015-08-19 21:39:45 +03:00
parent 42c32445f1
commit 70ce9a1742
2 changed files with 37 additions and 23 deletions

View File

@ -45,12 +45,15 @@ const device_type C128_PARTNER = &device_creator<partner128_t>;
WRITE_LINE_MEMBER( partner128_t::nmi_w )
{
m_ls74_d1 = state;
if (state)
{
m_ls74_q1 = 1;
}
}
static INPUT_PORTS_START( c128_partner )
PORT_START("NMI")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Menu") PORT_CODE(KEYCODE_F11) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, partner128_t, nmi_w)
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Menu") PORT_CODE(KEYCODE_END) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, partner128_t, nmi_w)
INPUT_PORTS_END
@ -80,7 +83,6 @@ partner128_t::partner128_t(const machine_config &mconfig, const char *tag, devic
m_ram(*this, "ram"),
m_ram_a12_a7(0),
m_ls74_cd(0),
m_ls74_d1(0),
m_ls74_q1(0),
m_ls74_q2(0),
m_joyb2(0)
@ -97,10 +99,13 @@ void partner128_t::device_start()
// allocate memory
m_ram.allocate(0x2000);
// simulate the 16.7ms pulse from CIA1 PB2 that would arrive thru the joystick port dongle
t_joyb2 = timer_alloc();
t_joyb2->adjust(attotime::from_msec(16), 0, attotime::from_msec(16));
// state saving
save_item(NAME(m_ram_a12_a7));
save_item(NAME(m_ls74_cd));
save_item(NAME(m_ls74_d1));
save_item(NAME(m_ls74_q1));
save_item(NAME(m_ls74_q2));
save_item(NAME(m_joyb2));
@ -123,6 +128,21 @@ void partner128_t::device_reset()
}
//-------------------------------------------------
// device_timer -
//-------------------------------------------------
void partner128_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
if (m_ls74_cd)
{
m_ls74_q2 = m_ls74_q1;
nmi_w(m_ls74_q2 ? ASSERT_LINE : CLEAR_LINE);
}
}
//-------------------------------------------------
// c64_cd_r - cartridge data read
//-------------------------------------------------
@ -140,7 +160,10 @@ UINT8 partner128_t::c64_cd_r(address_space &space, offs_t offset, UINT8 data, in
{
data = m_roml[offset & 0x3fff];
m_ls74_q1 = m_ls74_d1;
if (m_ls74_cd)
{
m_ls74_q1 = 0;
}
}
else
{
@ -148,9 +171,10 @@ UINT8 partner128_t::c64_cd_r(address_space &space, offs_t offset, UINT8 data, in
}
}
if (m_ls74_q2 && ((offset & 0xff3a) == 0xff3a))
if (m_ls74_q2 && ((offset & 0xfffa) == 0xfffa))
{
data = 0x21;
// override the 8502 NMI/IRQ vectors with 0xdede
data = 0xde;
}
return data;
@ -207,30 +231,20 @@ void partner128_t::c64_cd_w(address_space &space, offs_t offset, UINT8 data, int
}
//-------------------------------------------------
// c64_game_r - GAME read
//-------------------------------------------------
int partner128_t::c64_game_r(offs_t offset, int sphi2, int ba, int rw)
{
return 1;
}
//-------------------------------------------------
// vcs_joy_w - joystick write
//-------------------------------------------------
void partner128_t::vcs_joy_w(UINT8 data)
{
int joya2 = BIT(data, 2);
int joyb2 = BIT(data, 2);
if (!m_joyb2 && joya2)
if (!m_joyb2 && joyb2 && m_ls74_cd)
{
m_ls74_q2 = m_ls74_q1;
nmi_w(m_ls74_q2 ? ASSERT_LINE : CLEAR_LINE);
m_joyb2 = joya2;
}
m_joyb2 = joyb2;
}

View File

@ -40,11 +40,11 @@ protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
// device_c64_expansion_card_interface overrides
virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw);
// device_vcs_control_port_interface overrides
virtual void vcs_joy_w(UINT8 data);
@ -52,9 +52,9 @@ protected:
private:
optional_shared_ptr<UINT8> m_ram;
emu_timer *t_joyb2;
int m_ram_a12_a7;
int m_ls74_cd;
int m_ls74_d1;
int m_ls74_q1;
int m_ls74_q2;
int m_joyb2;