From 886495009b276d43eac9e0f255f7210522829929 Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 5 Jul 2015 02:46:29 +0200 Subject: [PATCH] added sm510 K and S ports --- src/emu/cpu/sm510/sm510.c | 5 +++- src/emu/cpu/sm510/sm510.h | 21 +++++++++++++--- src/emu/cpu/sm510/sm510d.c | 6 ++++- src/emu/cpu/sm510/sm510op.c | 8 +++--- src/mess/drivers/hh_sm510.c | 49 ++++++++++++++++++++++++++++++++++--- 5 files changed, 77 insertions(+), 12 deletions(-) diff --git a/src/emu/cpu/sm510/sm510.c b/src/emu/cpu/sm510/sm510.c index ca8db4635f7..b5dcf501265 100644 --- a/src/emu/cpu/sm510/sm510.c +++ b/src/emu/cpu/sm510/sm510.c @@ -36,7 +36,8 @@ void sm510_base_device::device_start() m_datamask = (1 << m_datawidth) - 1; // resolve callbacks - //.. + m_read_k.resolve_safe(0); + m_write_s.resolve_safe(); // zerofill memset(m_stack, 0, sizeof(m_stack)); @@ -50,6 +51,7 @@ void sm510_base_device::device_start() m_bm = 0; m_c = 0; m_skip = false; + m_w = 0; // register for savestates save_item(NAME(m_stack)); @@ -63,6 +65,7 @@ void sm510_base_device::device_start() save_item(NAME(m_bm)); save_item(NAME(m_c)); save_item(NAME(m_skip)); + save_item(NAME(m_w)); // register state for debugger state_add(SM510_PC, "PC", m_pc).formatstr("%04X"); diff --git a/src/emu/cpu/sm510/sm510.h b/src/emu/cpu/sm510/sm510.h index 0b37d76eef3..c2674ecb9b0 100644 --- a/src/emu/cpu/sm510/sm510.h +++ b/src/emu/cpu/sm510/sm510.h @@ -14,6 +14,16 @@ // I/O ports setup +// 4-bit K input port +#define MCFG_SM510_READ_K_CB(_devcb) \ + sm510_base_device::set_read_k_callback(*device, DEVCB_##_devcb); + +// 8-bit S strobe output port +#define MCFG_SM510_WRITE_S_CB(_devcb) \ + sm510_base_device::set_write_s_callback(*device, DEVCB_##_devcb); + + + // pinout reference /* @@ -31,10 +41,13 @@ public: , m_prgwidth(prgwidth) , m_datawidth(datawidth) , m_stack_levels(stack_levels) + , m_read_k(*this) + , m_write_s(*this) { } // static configuration helpers - //.. + template static devcb_base &set_read_k_callback(device_t &device, _Object object) { return downcast(device).m_read_k.set_callback(object); } + template static devcb_base &set_write_s_callback(device_t &device, _Object object) { return downcast(device).m_write_s.set_callback(object); } protected: // device-level overrides @@ -56,7 +69,7 @@ protected: // device_disasm_interface overrides virtual UINT32 disasm_min_opcode_bytes() const { return 1; } - virtual UINT32 disasm_max_opcode_bytes() const { return 2; } + virtual UINT32 disasm_max_opcode_bytes() const { return 0x40; } // actually 2, but debugger doesn't like non-linear pc address_space_config m_program_config; address_space_config m_data_config; @@ -82,9 +95,11 @@ protected: UINT8 m_bm; UINT8 m_c; bool m_skip; + UINT8 m_w; // i/o handlers - //.. + devcb_read16 m_read_k; + devcb_write8 m_write_s; // misc internal helpers void increment_pc(); diff --git a/src/emu/cpu/sm510/sm510d.c b/src/emu/cpu/sm510/sm510d.c index 43651e52015..1bacab9c91f 100644 --- a/src/emu/cpu/sm510/sm510d.c +++ b/src/emu/cpu/sm510/sm510d.c @@ -115,7 +115,7 @@ CPU_DISASSEMBLE(sm510) if (bits >= 8) { // note: disasm view shows correct parameter, but raw view does not - // note2: oprom array negative index access is intentional + // note2: oprom array negative index doesn't work either :( param = oprom[s_next_pc[pc & 0x3f]]; len++; } @@ -141,6 +141,10 @@ CPU_DISASSEMBLE(sm510) UINT16 address = (param << 4 & 0xc00) | (mask << 6 & 0x3c0) | (param & 0x03f); dst += sprintf(dst, "$%03X", address); } + + // show param offset + if (bits >= 8) + dst += sprintf(dst, " [$%03X]", pc + s_next_pc[pc & 0x3f]); } return len | s_flags[instr] | DASMFLAG_SUPPORTED; diff --git a/src/emu/cpu/sm510/sm510op.c b/src/emu/cpu/sm510/sm510op.c index d0aaffd224d..835289e7ce3 100644 --- a/src/emu/cpu/sm510/sm510op.c +++ b/src/emu/cpu/sm510/sm510op.c @@ -195,13 +195,15 @@ void sm510_base_device::op_lax() void sm510_base_device::op_wr() { // WR: shift 0 into W - op_illegal(); + m_w = m_w << 1 | 0; + m_write_s(0, m_w, 0xff); } void sm510_base_device::op_ws() { // WR: shift 1 into W - op_illegal(); + m_w = m_w << 1 | 1; + m_write_s(0, m_w, 0xff); } @@ -210,7 +212,7 @@ void sm510_base_device::op_ws() void sm510_base_device::op_kta() { // KTA: input K to ACC - op_illegal(); + m_acc = m_read_k(0, 0xff); } void sm510_base_device::op_atbp() diff --git a/src/mess/drivers/hh_sm510.c b/src/mess/drivers/hh_sm510.c index 7b84f673336..e0ffa12a969 100644 --- a/src/mess/drivers/hh_sm510.c +++ b/src/mess/drivers/hh_sm510.c @@ -71,7 +71,14 @@ void hh_sm510_state::machine_reset() UINT8 hh_sm510_state::read_inputs(int columns) { - return 0; + UINT8 ret = 0; + + // read selected input rows + for (int i = 0; i < columns; i++) + if (m_inp_mux >> i & 1) + ret |= m_inp_matrix[i]->read(); + + return ret; } @@ -95,22 +102,56 @@ public: ktopgun_state(const machine_config &mconfig, device_type type, const char *tag) : hh_sm510_state(mconfig, type, tag) { } + + DECLARE_WRITE8_MEMBER(input_w); + DECLARE_READ8_MEMBER(input_r); }; // handlers -//.. + +WRITE8_MEMBER(ktopgun_state::input_w) +{ + // S1-S3: input mux + m_inp_mux = data; +} + +READ8_MEMBER(ktopgun_state::input_r) +{ + //printf("%02X ",m_inp_mux); + return read_inputs(3); +} + // config static INPUT_PORTS_START( ktopgun ) + PORT_START("IN.0") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) + + PORT_START("IN.1") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) + + PORT_START("IN.2") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON5 ) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 ) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON7 ) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON8 ) INPUT_PORTS_END static MACHINE_CONFIG_START( ktopgun, ktopgun_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", SM510, 10000) + MCFG_CPU_ADD("maincpu", SM510, XTAL_32_768kHz) + MCFG_SM510_READ_K_CB(READ8(ktopgun_state, input_r)) + MCFG_SM510_WRITE_S_CB(WRITE8(ktopgun_state, input_w)) /* no video! */ @@ -144,4 +185,4 @@ ROM_END /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY, FULLNAME, FLAGS */ -CONS( 1990, ktopgun, 0, 0, ktopgun, ktopgun, driver_device, 0, "Konami", "Top Gun (Konami)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) +CONS( 1989, ktopgun, 0, 0, ktopgun, ktopgun, driver_device, 0, "Konami", "Top Gun (Konami)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING )