diff --git a/src/emu/cpu/amis2000/amis2000.c b/src/emu/cpu/amis2000/amis2000.c index 5afe974f681..d6c4967d0dc 100644 --- a/src/emu/cpu/amis2000/amis2000.c +++ b/src/emu/cpu/amis2000/amis2000.c @@ -5,6 +5,7 @@ American Microsystems, Inc.(AMI) S2000-family 4-bit MCU cores, introduced late 1970s TODO: + - bug(s)? - MESS wildfire.c doesn't work yet - unemulated opcodes (need more testing material) - support external program map - add 50/60hz timer @@ -25,12 +26,12 @@ const device_type AMI_S2150 = &device_creator; // internal memory maps static ADDRESS_MAP_START(program_1k, AS_PROGRAM, 8, amis2000_device) - AM_RANGE(0x0000, 0x03ff) AM_ROM AM_MIRROR(0x1c00) + AM_RANGE(0x0000, 0x03ff) AM_ROM ADDRESS_MAP_END static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_device) - AM_RANGE(0x0000, 0x03ff) AM_ROM AM_MIRROR(0x1800) - AM_RANGE(0x0400, 0x05ff) AM_ROM AM_MIRROR(0x1a00) + AM_RANGE(0x0000, 0x03ff) AM_ROM + AM_RANGE(0x0400, 0x05ff) AM_ROM AM_MIRROR(0x200) ADDRESS_MAP_END @@ -116,7 +117,7 @@ offs_t amis2000_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 enum { S2000_PC=1, S2000_BL, S2000_BU, - S2000_ACC, S2000_E, S2000_CARRY + S2000_ACC, S2000_E, S2000_CY }; void amis2000_device::device_start() @@ -138,9 +139,9 @@ void amis2000_device::device_start() m_pc = 0; m_ppr = 0; m_pbr = 0; - m_pp_index = 0; m_skip = false; m_op = 0; + m_prev_op = 0; m_f = 0; m_carry = 0; m_bl = 0; @@ -157,9 +158,9 @@ void amis2000_device::device_start() save_item(NAME(m_pc)); save_item(NAME(m_ppr)); save_item(NAME(m_pbr)); - save_item(NAME(m_pp_index)); save_item(NAME(m_skip)); save_item(NAME(m_op)); + save_item(NAME(m_prev_op)); save_item(NAME(m_f)); save_item(NAME(m_carry)); save_item(NAME(m_bl)); @@ -177,7 +178,7 @@ void amis2000_device::device_start() state_add(S2000_BU, "BU", m_bu ).formatstr("%01X"); state_add(S2000_ACC, "ACC", m_acc ).formatstr("%01X"); state_add(S2000_E, "E", m_e ).formatstr("%01X"); - state_add(S2000_CARRY, "CARRY", m_carry ).formatstr("%01X"); + state_add(S2000_CY, "CY", m_carry ).formatstr("%01X"); state_add(STATE_GENPC, "curpc", m_pc).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_f).formatstr("%6s").noshow(); @@ -218,14 +219,8 @@ void amis2000_device::execute_run() { m_icount--; - // increase PP prefix count - if ((m_op & 0xf0) == 0x60) - { - if (m_pp_index < 2) - m_pp_index++; - } - else - m_pp_index = 0; + // remember previous opcode + m_prev_op = m_op; debugger_instruction_hook(this, m_pc); m_op = m_program->read_byte(m_pc); diff --git a/src/emu/cpu/amis2000/amis2000.h b/src/emu/cpu/amis2000/amis2000.h index 966a85cd524..d8960bfd062 100644 --- a/src/emu/cpu/amis2000/amis2000.h +++ b/src/emu/cpu/amis2000/amis2000.h @@ -80,9 +80,9 @@ protected: UINT16 m_pc; // 13-bit program counter UINT8 m_ppr; // prepared page register (PP 1) UINT8 m_pbr; // prepared bank register (PP 2) - UINT8 m_pp_index; // number of handled PP prefixes bool m_skip; // skip next opcode, including PP prefixes UINT8 m_op; + UINT8 m_prev_op; // previous opcode, needed for PP, LAI, LB* UINT8 m_f; // generic flags: 2 on 2000/2150, 6 on 2200/2400 UINT8 m_carry; // carry flag UINT8 m_bl; // 4-bit ram index x diff --git a/src/emu/cpu/amis2000/amis2000op.inc b/src/emu/cpu/amis2000/amis2000op.inc index 97fa6b6db82..5a188a3f336 100644 --- a/src/emu/cpu/amis2000/amis2000op.inc +++ b/src/emu/cpu/amis2000/amis2000op.inc @@ -4,13 +4,13 @@ UINT8 amis2000_device::ram_r() { - UINT16 address = m_bu << m_bu_bits | m_bl; + UINT16 address = m_bu << 4 | m_bl; return m_data->read_byte(address) & 0xf; } void amis2000_device::ram_w(UINT8 data) { - UINT16 address = m_bu << m_bu_bits | m_bl; + UINT16 address = m_bu << 4 | m_bl; m_data->write_byte(address, data & 0xf); } @@ -44,10 +44,14 @@ void amis2000_device::op_illegal() void amis2000_device::op_lai() { // LAI X: load ACC with X, select I and K inputs - UINT8 param = m_op & 0x0f; - m_acc = param; - m_i = m_read_i(0, 0xff) & param; - m_k = m_read_k(0, 0xff) & param; + // note: only execute the first one in a sequence of LAI + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x0f; + m_acc = param; + m_i = m_read_i(0, 0xff) & param; + m_k = m_read_k(0, 0xff) & param; + } } void amis2000_device::op_lab() @@ -89,33 +93,49 @@ void amis2000_device::op_xae() void amis2000_device::op_lbe() { // LBE Y: load BU with Y, load BL with E - UINT8 param = m_op & 0x03; - m_bu = param & m_bu_mask; - m_bl = m_e; + // note: only execute the first one in a sequence of LB* + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x03; + m_bu = param & m_bu_mask; + m_bl = m_e; + } } void amis2000_device::op_lbep() { // LBEP Y: load BU with Y, load BL with E+1 - UINT8 param = m_op & 0x03; - m_bu = param & m_bu_mask; - m_bl = m_e + 1; + // note: only execute the first one in a sequence of LB* + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x03; + m_bu = param & m_bu_mask; + m_bl = m_e + 1; + } } void amis2000_device::op_lbz() { // LBZ Y: load BU with Y, load BL with 0 - UINT8 param = m_op & 0x03; - m_bu = param & m_bu_mask; - m_bl = 0; + // note: only execute the first one in a sequence of LB* + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x03; + m_bu = param & m_bu_mask; + m_bl = 0; + } } void amis2000_device::op_lbf() { // LBF Y: load BU with Y, load BL with 15 - UINT8 param = m_op & 0x03; - m_bu = param & m_bu_mask; - m_bl = 0xf; + // note: only execute the first one in a sequence of LB* + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) + { + UINT8 param = m_op & 0x03; + m_bu = param & m_bu_mask; + m_bl = 0xf; + } } @@ -279,7 +299,7 @@ void amis2000_device::op_pp() { // PP _X: prepare page/bank with _X UINT8 param = ~m_op & 0x0f; - if (m_pp_index == 0) + if ((m_prev_op & 0xf0) != (m_op & 0xf0)) m_ppr = param; else m_pbr = param & 7; @@ -290,15 +310,12 @@ void amis2000_device::op_jmp() // JMP X: jump to X(+PP) UINT16 mask = 0x3f; UINT16 param = m_op & mask; - if (m_pp_index > 0) + + // if previous opcode was PP, change PC high bits too + if ((m_prev_op & 0xf0) == 0x60) { - param |= m_ppr << 6; - mask |= 0x3c0; - } - if (m_pp_index > 1) - { - param |= m_pbr << 10; - mask |= 0x1c00; + param |= (m_ppr << 6) | (m_pbr << 10); + mask = 0x1fff; } m_pc = (m_pc & ~mask) | param; } @@ -308,13 +325,11 @@ void amis2000_device::op_jms() // JMS X: call to X(+PP) m_icount--; push_callstack(); - if (m_pp_index == 0) - { - // subroutines default location is page 15 - m_ppr = 0xf; - m_pp_index++; - } op_jmp(); + + // subroutines default location is page 15 + if ((m_prev_op & 0xf0) != 0x60) + m_pc |= 0x3c0; } void amis2000_device::op_rt() @@ -384,13 +399,13 @@ void amis2000_device::op_sos() void amis2000_device::op_tf1() { // TF1: skip next on flag 1 - m_skip = (m_f & 0x01); + m_skip = (m_f & 0x01) ? true : false; } void amis2000_device::op_tf2() { // TF2: skip next on flag 2 - m_skip = (m_f & 0x02); + m_skip = (m_f & 0x02) ? true : false; } diff --git a/src/mess/drivers/wildfire.c b/src/mess/drivers/wildfire.c index c4dce72cc1a..39db9be728f 100644 --- a/src/mess/drivers/wildfire.c +++ b/src/mess/drivers/wildfire.c @@ -31,6 +31,9 @@ public: required_device m_maincpu; required_device m_speaker; + DECLARE_WRITE8_MEMBER(write_d); + DECLARE_WRITE16_MEMBER(write_a); + virtual void machine_start(); }; @@ -41,7 +44,13 @@ public: ***************************************************************************/ -//.. +WRITE8_MEMBER(wildfire_state::write_d) +{ +} + +WRITE16_MEMBER(wildfire_state::write_a) +{ +} @@ -52,6 +61,11 @@ public: ***************************************************************************/ static INPUT_PORTS_START( wildfire ) + PORT_START("IN1") // I + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Shooter Button") + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Left Flipper") + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Right Flipper") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END @@ -71,6 +85,9 @@ static MACHINE_CONFIG_START( wildfire, wildfire_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", AMI_S2150, MASTER_CLOCK) + MCFG_AMI_S2000_READ_I_CB(IOPORT("IN1")) + MCFG_AMI_S2000_WRITE_D_CB(WRITE8(wildfire_state, write_d)) + MCFG_AMI_S2000_WRITE_A_CB(WRITE16(wildfire_state, write_a)) MCFG_DEFAULT_LAYOUT(layout_wildfire)