From 41da94ea31c8ccf47af3ee48a2c3ad69de908e6a Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Fri, 17 Nov 2017 17:41:24 +0100 Subject: [PATCH 1/2] new working machine ------------------------------- Pac-Eight [rod_wod, The Dumping Union] --- src/mame/drivers/cave.cpp | 89 +++++++++++++++++++++++++++++++++++++-- src/mame/mame.lst | 1 + 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/src/mame/drivers/cave.cpp b/src/mame/drivers/cave.cpp index 9ab27cc75b2..7734583a4c2 100644 --- a/src/mame/drivers/cave.cpp +++ b/src/mame/drivers/cave.cpp @@ -1154,6 +1154,30 @@ static ADDRESS_MAP_START( pacslot_map, AS_PROGRAM, 16, cave_state ) ADDRESS_MAP_END +/*************************************************************************** + Pac-Eight +***************************************************************************/ + +//TODO: leds need verifying + +static ADDRESS_MAP_START( paceight_map, AS_PROGRAM, 16, cave_state ) + AM_RANGE(0x000000, 0x07ffff) AM_ROM // ROM + AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_SHARE("nvram") // RAM (battery) + AM_RANGE(0x200000, 0x207fff) AM_RAM AM_SHARE("spriteram.0") // Sprites + AM_RANGE(0x208000, 0x20ffff) AM_RAM AM_SHARE("spriteram_2.0") // Sprite bank 2 + AM_RANGE(0x300000, 0x307fff) AM_RAM_WRITE(cave_vram_0_w) AM_SHARE("vram.0") // Layer 0 + AM_RANGE(0x400000, 0x40ffff) AM_RAM AM_SHARE("paletteram.0") // Palette + AM_RANGE(0x500000, 0x500001) AM_READ_PORT("IN0") // Inputs + EEPROM + Hopper + AM_RANGE(0x500002, 0x500003) AM_READ_PORT("IN1") // Inputs + AM_RANGE(0x600000, 0x600005) AM_WRITEONLY AM_SHARE("vctrl.0") // Layer 0 Control + AM_RANGE(0x700000, 0x700007) AM_READ(cave_irq_cause_r) // IRQ Cause + AM_RANGE(0x700068, 0x700069) AM_DEVWRITE("watchdog", watchdog_timer_device, reset16_w) // Watchdog + AM_RANGE(0x700000, 0x70007f) AM_WRITEONLY AM_SHARE("videoregs.0") // Video Regs + AM_RANGE(0x800000, 0x800001) AM_DEVREADWRITE8("oki1", okim6295_device, read, write, 0x00ff) // M6295 + AM_RANGE(0xc00000, 0xc00001) AM_WRITE(pacslot_leds_w) // Leds + Hopper + AM_RANGE(0xe00000, 0xe00001) AM_WRITE(tjumpman_eeprom_lsb_w) // EEPROM +ADDRESS_MAP_END + /*************************************************************************** Uo Poko ***************************************************************************/ @@ -1728,7 +1752,7 @@ static INPUT_PORTS_START( pacslot ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME( "Pac-Man" ) PORT_CODE(KEYCODE_Y) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME( "Bet" ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, cave_state,tjumpman_hopper_r, nullptr) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, cave_state, tjumpman_hopper_r, nullptr) PORT_START("IN1") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -1743,6 +1767,16 @@ static INPUT_PORTS_START( pacslot ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END +static INPUT_PORTS_START( paceight ) + PORT_INCLUDE( pacslot ) + + PORT_MODIFY("IN0") + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME( "Left" ) PORT_CODE(KEYCODE_Y) + + PORT_MODIFY("IN1") + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME( "Right" ) PORT_CODE(KEYCODE_N) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME( "Max Bet" ) +INPUT_PORTS_END static INPUT_PORTS_START( ppsatan ) PORT_START("SYSTEM") // $200000 @@ -2569,7 +2603,10 @@ static MACHINE_CONFIG_START( pacslot ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_CONFIG_END - +static MACHINE_CONFIG_DERIVED( paceight, pacslot ) + MCFG_CPU_MODIFY("maincpu") + MCFG_CPU_PROGRAM_MAP(paceight_map) +MACHINE_CONFIG_END /*************************************************************************** Poka Poka Satan ***************************************************************************/ @@ -4244,10 +4281,53 @@ ROM_START( pacslot ) ROM_REGION( 0x117 * 3, "plds", 0 ) ROM_LOAD( "n44u1a.u1", 0x117*0, 0x117, NO_DUMP ) // GAL16V8B-15LP (Protected) ROM_LOAD( "n44u3a.u3", 0x117*1, 0x117, NO_DUMP ) // GAL16V8B-15LP (Protected) - ROM_LOAD( "n44u51a.u51", 0x117*2, 0x117, NO_DUMP ) // GAL16V8B-15LP (Protected) + ROM_LOAD( "n44u51a.u51", 0x117*2, 0x117, CRC(3c5e9bc5) SHA1(b4e04c4fa91ff33542b73971f67e71d13e24c5ec) ) // GAL16V8B-15LP (Protected, dumped from the paceight PCB) ROM_END +/*************************************************************************** + + Pac-Eight by Namco, 1996 (according to http://pacman.com/ja/museum/index.html) + Namco N-44 EM VIDEO platform, PCB C0348 + + TMP 68HC000P-16 + + 013 9341E7002 + 038 9635WY003 + + OKI M6295 x 2 + + Battery + 93C46 EEPROM (at U24) + + 28MHz XTAL + +***************************************************************************/ + +ROM_START( paceight ) + ROM_REGION( 0x80000, "maincpu", 0 ) /* 68000 code */ + ROM_LOAD16_WORD_SWAP( "pae1-mpro.u41", 0x00000, 0x80000, CRC(bb026f97) SHA1(70d48f05275c64b25f37f03206219ef3ee9c0ee2) ) // 27c240 + + ROM_REGION( 0x100000 * 2, "sprites0", 0 ) /* Sprites: * 2 */ + ROM_LOAD16_BYTE( "pae1-obj0.u52", 0x00000, 0x80000, CRC(2cd99155) SHA1(146ed2b3f2763232a60e6b238a16067d3ccfa959) ) // 27c040 + ROM_LOAD16_BYTE( "pae1-obj1.u53", 0x00001, 0x80000, CRC(9ae2685b) SHA1(5eed5f00d28d803358c8ffaf42c4979af23a0a8c) ) // "" + + ROM_REGION( 0x80000, "layer0", 0 ) /* Layer 0 */ + ROM_LOAD( "pae1-cha0.u60", 0x00000, 0x40000, CRC(757263e3) SHA1(668060e9e209752474f48362752a3f819ff82d72) ) // 27c020? not readable + ROM_LOAD( "pae1-cha1.u61", 0x40000, 0x40000, CRC(0396d241) SHA1(79382805fa4486d8dae792f9afc0f02aee1bbb33) ) // "" + + ROM_REGION( 0x40000, "oki1", 0 ) /* OKIM6295 #1 Samples */ + ROM_LOAD( "pae1-vo10.u27", 0x00000, 0x40000, CRC(0be7b94f) SHA1(4179e2ab2d2d1df0cc6cfd71e277ea114578f147) ) // 27c? not readable + + ROM_REGION( 0x40000, "oki2", ROMREGION_ERASE00 ) /* OKIM6295 #2 Samples */ + // empty ROM socket + + ROM_REGION( 0x117 * 3, "plds", 0 ) + ROM_LOAD( "n44u1c.u1", 0x117*0, 0x117, CRC(903fc2d8) SHA1(becbae356efde873225ef64af462d9702aac03f0) ) // GAL16V8B-15LP + ROM_LOAD( "n44u3c.u3", 0x117*1, 0x117, CRC(72201412) SHA1(6ad7d22e612e27343eac5c38f00d548df644d52c) ) // GAL16V8B-15LP + ROM_LOAD( "n44u51a.u51", 0x117*2, 0x117, CRC(3c5e9bc5) SHA1(b4e04c4fa91ff33542b73971f67e71d13e24c5ec) ) // GAL16V8B-15LP +ROM_END + /*************************************************************************** Poka Poka Satan - wack-a-mole game with one frontal upright screen and two @@ -5346,7 +5426,8 @@ GAME( 1996, agalletah, agallet, sailormn, cave, cave_state, agallet, RO GAME( 1996, hotdogst, 0, hotdogst, cave, cave_state, hotdogst, ROT90, "Marble", "Hotdog Storm (International)", MACHINE_SUPPORTS_SAVE ) -GAME( 1996, pacslot, 0, pacslot, pacslot, cave_state, tjumpman, ROT0, "Namco", "Pac-Slot", MACHINE_SUPPORTS_SAVE ) +GAME( 1996, pacslot, 0, pacslot, pacslot, cave_state, tjumpman, ROT0, "Namco", "Pac-Slot", MACHINE_SUPPORTS_SAVE ) +GAME( 1996, paceight, 0, paceight, paceight, cave_state, tjumpman, ROT0, "Namco", "Pac-Eight", MACHINE_SUPPORTS_SAVE ) GAME( 1996, ppsatan, 0, ppsatan, ppsatan, cave_state, ppsatan, ROT0, "Kato Seisakujo Co., Ltd.", "Poka Poka Satan (Japan)", MACHINE_SUPPORTS_SAVE | MACHINE_IMPERFECT_GRAPHICS ) diff --git a/src/mame/mame.lst b/src/mame/mame.lst index ca0fa70444b..f1a7374480e 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -9334,6 +9334,7 @@ mazinger // (c) 1994 Banpresto (country is in EEPROM) mazingerj // (c) 1994 Banpresto (country is in EEPROM) metmqstr // (c) 1995 Banpresto / Pandorabox nmaster // (c) 1995 Banpresto / Pandorabox +paceight // (c) 1996 Namco pacslot // (c) 1996 Namco plegends // (c) 1994 Atlus plegendsj // (c) 1994 Atlus From ec788f6c7a941168b1f56b1fce73527c8563e861 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Fri, 17 Nov 2017 18:07:50 +0100 Subject: [PATCH 2/2] e132xs: templated hi/lo shift bit, simplified set opcode, removed some needless use of set_global_register to get some speed back. --- src/devices/cpu/e132xs/e132xs.cpp | 46 ++-- src/devices/cpu/e132xs/e132xs.h | 20 +- src/devices/cpu/e132xs/e132xsop.hxx | 330 ++++++---------------------- 3 files changed, 107 insertions(+), 289 deletions(-) diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp index 8a8e18fd5f3..f3cf65ee595 100644 --- a/src/devices/cpu/e132xs/e132xs.cpp +++ b/src/devices/cpu/e132xs/e132xs.cpp @@ -697,6 +697,8 @@ void hyperstone_device::set_global_register(uint8_t code, uint32_t val) #define S_BIT ((OP & 0x100) >> 8) #define D_BIT ((OP & 0x200) >> 9) #define N_VALUE (((OP & 0x100) >> 4) | (OP & 0x0f)) +#define HI_N_VALUE (0x10 | (OP & 0x0f)) +#define LO_N_VALUE (OP & 0x0f) #define N_OP_MASK (m_op & 0x10f) #define DST_CODE ((OP & 0xf0) >> 4) #define SRC_CODE (OP & 0x0f) @@ -1759,16 +1761,16 @@ void hyperstone_device::execute_run() case 0x7d: hyperstone_xori(); break; case 0x7e: hyperstone_xori(); break; case 0x7f: hyperstone_xori(); break; - case 0x80: hyperstone_shrdi(); break; - case 0x81: hyperstone_shrdi(); break; + case 0x80: hyperstone_shrdi(); break; + case 0x81: hyperstone_shrdi(); break; case 0x82: hyperstone_shrd(); break; case 0x83: hyperstone_shr(); break; - case 0x84: hyperstone_sardi(); break; - case 0x85: hyperstone_sardi(); break; + case 0x84: hyperstone_sardi(); break; + case 0x85: hyperstone_sardi(); break; case 0x86: hyperstone_sard(); break; case 0x87: hyperstone_sar(); break; - case 0x88: hyperstone_shldi(); break; - case 0x89: hyperstone_shldi(); break; + case 0x88: hyperstone_shldi(); break; + case 0x89: hyperstone_shldi(); break; case 0x8a: hyperstone_shld(); break; case 0x8b: hyperstone_shl(); break; case 0x8c: hyperstone_reserved(); break; @@ -1791,18 +1793,18 @@ void hyperstone_device::execute_run() case 0x9d: hyperstone_stxx2(); break; case 0x9e: hyperstone_stxx2(); break; case 0x9f: hyperstone_stxx2(); break; - case 0xa0: hyperstone_shri(); break; - case 0xa1: hyperstone_shri(); break; - case 0xa2: hyperstone_shri(); break; - case 0xa3: hyperstone_shri(); break; - case 0xa4: hyperstone_sari(); break; - case 0xa5: hyperstone_sari(); break; - case 0xa6: hyperstone_sari(); break; - case 0xa7: hyperstone_sari(); break; - case 0xa8: hyperstone_shli(); break; - case 0xa9: hyperstone_shli(); break; - case 0xaa: hyperstone_shli(); break; - case 0xab: hyperstone_shli(); break; + case 0xa0: hyperstone_shri(); break; + case 0xa1: hyperstone_shri(); break; + case 0xa2: hyperstone_shri(); break; + case 0xa3: hyperstone_shri(); break; + case 0xa4: hyperstone_sari(); break; + case 0xa5: hyperstone_sari(); break; + case 0xa6: hyperstone_sari(); break; + case 0xa7: hyperstone_sari(); break; + case 0xa8: hyperstone_shli(); break; + case 0xa9: hyperstone_shli(); break; + case 0xaa: hyperstone_shli(); break; + case 0xab: hyperstone_shli(); break; case 0xac: hyperstone_reserved(); break; case 0xad: hyperstone_reserved(); break; case 0xae: hyperstone_reserved(); break; @@ -1815,10 +1817,10 @@ void hyperstone_device::execute_run() case 0xb5: hyperstone_muls(); break; case 0xb6: hyperstone_muls(); break; case 0xb7: hyperstone_muls(); break; - case 0xb8: hyperstone_set(); break; - case 0xb9: hyperstone_set(); break; - case 0xba: hyperstone_set(); break; - case 0xbb: hyperstone_set(); break; + case 0xb8: hyperstone_set(); break; + case 0xb9: hyperstone_set(); break; + case 0xba: hyperstone_set(); break; + case 0xbb: hyperstone_set(); break; case 0xbc: hyperstone_mul(); break; case 0xbd: hyperstone_mul(); break; case 0xbe: hyperstone_mul(); break; diff --git a/src/devices/cpu/e132xs/e132xs.h b/src/devices/cpu/e132xs/e132xs.h index 44730b4f163..1acc86d53e9 100644 --- a/src/devices/cpu/e132xs/e132xs.h +++ b/src/devices/cpu/e132xs/e132xs.h @@ -108,6 +108,12 @@ protected: LIMM = 1 }; + enum shift_type + { + N_LO = 0, + N_HI = 1, + }; + // construction/destruction hyperstone_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, const device_type type, uint32_t prg_data_width, uint32_t io_data_width, address_map_constructor internal_map); @@ -240,18 +246,18 @@ private: template void hyperstone_andni(); template void hyperstone_ori(); template void hyperstone_xori(); - void hyperstone_shrdi(); + template void hyperstone_shrdi(); void hyperstone_shrd(); void hyperstone_shr(); - template void hyperstone_shri(); - void hyperstone_sardi(); + template void hyperstone_shri(); + template void hyperstone_sardi(); void hyperstone_sard(); void hyperstone_sar(); - template void hyperstone_sari(); - void hyperstone_shldi(); + template void hyperstone_sari(); + template void hyperstone_shldi(); void hyperstone_shld(); void hyperstone_shl(); - template void hyperstone_shli(); + template void hyperstone_shli(); void hyperstone_testlz(); void hyperstone_rol(); template void hyperstone_ldxx1(); @@ -263,7 +269,7 @@ private: template void hyperstone_muls(); template void hyperstone_mul(); - template void hyperstone_set(); + template void hyperstone_set(); template void hyperstone_ldwr(); template void hyperstone_lddr(); diff --git a/src/devices/cpu/e132xs/e132xsop.hxx b/src/devices/cpu/e132xs/e132xsop.hxx index f25eecca9ec..2a6915bab81 100644 --- a/src/devices/cpu/e132xs/e132xsop.hxx +++ b/src/devices/cpu/e132xs/e132xsop.hxx @@ -144,8 +144,7 @@ void hyperstone_device::hyperstone_divu() //Z -> undefined //N -> undefined SR |= V_MASK; - uint32_t addr = get_trap_addr(TRAPNO_RANGE_ERROR); - execute_exception(addr); + execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR)); } else { @@ -155,16 +154,8 @@ void hyperstone_device::hyperstone_divu() /* TODO: add quotient overflow */ uint32_t quotient = dividend / sreg; - if (DST_GLOBAL) - { - set_global_register(dst_code, dividend % sreg); - set_global_register(dst_code + 1, quotient); - } - else - { - m_local_regs[dst_code] = dividend % sreg; - m_local_regs[dstf_code] = quotient; - } + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = dividend % sreg; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dstf_code] = quotient; SR &= ~(V_MASK | Z_MASK | N_MASK); if (quotient == 0) @@ -209,16 +200,8 @@ void hyperstone_device::hyperstone_divs() { /* TODO: add quotient overflow */ const int32_t quotient = dividend / sreg; - if (DST_GLOBAL) - { - set_global_register(dst_code, dividend % sreg); - set_global_register(dst_code + 1, quotient); - } - else - { - m_local_regs[dst_code] = dividend % sreg; - m_local_regs[dstf_code] = quotient; - } + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = dividend % sreg; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dstf_code] = quotient; SR &= ~(V_MASK | Z_MASK | N_MASK); if (quotient == 0) @@ -276,10 +259,7 @@ void hyperstone_device::hyperstone_xm() sreg <<= (sub_type - 4); } - if (DST_GLOBAL) - set_global_register(dst_code, sreg); - else - m_local_regs[dst_code] = sreg; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = sreg; m_icount -= m_clock_cycles_1; } @@ -1207,7 +1187,7 @@ void hyperstone_device::hyperstone_xori() } - +template void hyperstone_device::hyperstone_shrdi() { check_delay_PC(); @@ -1223,8 +1203,8 @@ void hyperstone_device::hyperstone_shrdi() SR &= ~(C_MASK | Z_MASK | N_MASK); - const uint32_t n = N_VALUE; - if (n) + const uint32_t n = HI_N ? HI_N_VALUE : LO_N_VALUE; + if (HI_N || n) { SR |= (val >> (n - 1)) & 1; @@ -1243,6 +1223,7 @@ void hyperstone_device::hyperstone_shrdi() m_icount -= m_clock_cycles_2; } + void hyperstone_device::hyperstone_shrd() { check_delay_PC(); @@ -1305,6 +1286,7 @@ void hyperstone_device::hyperstone_shr() m_icount -= m_clock_cycles_1; } +template void hyperstone_device::hyperstone_sardi() { check_delay_PC(); @@ -1316,8 +1298,8 @@ void hyperstone_device::hyperstone_sardi() SR &= ~(C_MASK | Z_MASK | N_MASK); - const uint32_t n = N_VALUE; - if (n) + const uint32_t n = HI_N ? HI_N_VALUE : LO_N_VALUE; + if (HI_N || n) { SR |= (val >> (n - 1)) & 1; @@ -1415,6 +1397,7 @@ void hyperstone_device::hyperstone_sar() m_icount -= m_clock_cycles_1; } +template void hyperstone_device::hyperstone_shldi() { check_delay_PC(); @@ -1430,9 +1413,8 @@ void hyperstone_device::hyperstone_shldi() SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK); - const uint32_t n = N_VALUE; - - if (n && ((val << (n - 1)) & 0x8000000000000000U)) + const uint32_t n = HI_N ? HI_N_VALUE : LO_N_VALUE; + if ((HI_N || n) && ((val << (n - 1)) & 0x8000000000000000U)) SR |= C_MASK; const uint64_t mask = ((1U << (32 - n)) - 1) ^ 0xffffffff; @@ -2110,26 +2092,17 @@ void hyperstone_device::hyperstone_stxx2() case 0: // STBS.N // TODO: missing trap on range error WRITE_B(dreg, (uint8_t)sreg); - if (DST_GLOBAL) - set_global_register(dst_code, dreg + extra_s); - else - m_local_regs[dst_code] += extra_s; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] += extra_s; break; case 1: // STBU.N WRITE_B(dreg, (uint8_t)sreg); - if (DST_GLOBAL) - set_global_register(dst_code, dreg + extra_s); - else - m_local_regs[dst_code] += extra_s; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] += extra_s; break; case 2: // STHS.N, STHU.N WRITE_HW(dreg, (uint16_t)sreg); - if (DST_GLOBAL) - set_global_register(dst_code, dreg + (extra_s & ~1)); - else - m_local_regs[dst_code] += extra_s & ~1; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] += extra_s & ~1; // TODO: missing trap on range error with STHS.N break; @@ -2138,20 +2111,14 @@ void hyperstone_device::hyperstone_stxx2() { case 0: // STW.N WRITE_W(dreg, sreg); - if (DST_GLOBAL) - set_global_register(dst_code, dreg + extra_s); - else - m_local_regs[dst_code] += extra_s; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] += extra_s; break; case 1: // STD.N { const uint32_t srcf_code = SRC_GLOBAL ? (src_code + 1) : ((src_code + 1) & 0x3f); const uint32_t sregf = (SRC_GLOBAL && src_code == SR_REGISTER) ? 0 : (SRC_GLOBAL ? m_global_regs : m_local_regs)[srcf_code]; WRITE_W(dreg, sreg); - if (DST_GLOBAL) - set_global_register(dst_code, dreg + (extra_s & ~1)); - else - m_local_regs[dst_code] += extra_s & ~1; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] += extra_s & ~1; if(DST_GLOBAL == SRC_GLOBAL && (src_code + 1) == dst_code) WRITE_W(dreg + 4, sregf + (extra_s & ~1)); // because DREG == SREGF and DREG has been incremented @@ -2170,10 +2137,7 @@ void hyperstone_device::hyperstone_stxx2() else m_local_regs[(dreg & 0xfc) >> 2] = sreg; - if (DST_GLOBAL) - set_global_register(dst_code, dreg + (extra_s & ~3)); - else - m_local_regs[dst_code] += (extra_s & ~3); + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] += (extra_s & ~3); m_icount -= m_clock_cycles_2; // extra cycles break; @@ -2184,7 +2148,7 @@ void hyperstone_device::hyperstone_stxx2() m_icount -= m_clock_cycles_1; } -template +template void hyperstone_device::hyperstone_shri() { check_delay_PC(); @@ -2194,8 +2158,8 @@ void hyperstone_device::hyperstone_shri() SR &= ~(C_MASK | Z_MASK | N_MASK); - const uint32_t n = N_VALUE; - if (n) + const uint32_t n = HI_N ? HI_N_VALUE : LO_N_VALUE; + if (HI_N || n) SR |= (val >> (n - 1)) & 1; val >>= n; @@ -2212,7 +2176,7 @@ void hyperstone_device::hyperstone_shri() m_icount -= m_clock_cycles_1; } -template +template void hyperstone_device::hyperstone_sari() { check_delay_PC(); @@ -2220,10 +2184,10 @@ void hyperstone_device::hyperstone_sari() const uint32_t dst_code = DST_GLOBAL ? DST_CODE : ((DST_CODE + GET_FP) & 0x3f); uint32_t val = (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code]; - const uint32_t n = N_VALUE; - + const uint32_t n = HI_N ? HI_N_VALUE : LO_N_VALUE; SR &= ~(C_MASK | Z_MASK | N_MASK); - if (n) + + if (HI_N || n) { SR |= (val >> (n - 1)) & 1; @@ -2246,7 +2210,7 @@ void hyperstone_device::hyperstone_sari() m_icount -= m_clock_cycles_1; } -template +template void hyperstone_device::hyperstone_shli() { check_delay_PC(); @@ -2254,9 +2218,9 @@ void hyperstone_device::hyperstone_shli() const uint32_t dst_code = DST_GLOBAL ? DST_CODE : ((DST_CODE + GET_FP) & 0x3f); uint32_t val = (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code]; - const uint32_t n = N_VALUE; + const uint32_t n = HI_N ? HI_N_VALUE : LO_N_VALUE; SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK); - SR |= n ? (((val << (n - 1)) & 0x80000000) ? 1 : 0) : 0; + SR |= (HI_N || n) ? (((val << (n - 1)) & 0x80000000) ? 1 : 0) : 0; uint64_t mask = ((1U << (32 - n)) - 1) ^ 0xffffffff; uint32_t val2 = val << n; @@ -2347,13 +2311,13 @@ void hyperstone_device::hyperstone_muls() m_icount -= m_clock_cycles_6; } -template +template void hyperstone_device::hyperstone_set() { check_delay_PC(); const uint32_t dst_code = DST_GLOBAL ? DST_CODE : ((DST_CODE + GET_FP) & 0x3f); - const uint32_t n = N_VALUE; + const uint32_t n = LO_N_VALUE; if (DST_GLOBAL && dst_code < 2) { @@ -2361,201 +2325,47 @@ void hyperstone_device::hyperstone_set() return; } - switch (n) + if (HI_N) { - // SETADR - case 0: - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = (SP & 0xfffffe00) | (GET_FP << 2) | (((SP & 0x100) && (SIGN_BIT(SR) == 0)) ? 1 : 0); - break; + if (n >= 4 || n == 2) + { + static const uint32_t set_result[16] = { 0, 0, 0, 0, 0xffffffff, 0, 0xffffffff, 0, 0xffffffff, 0, 0xffffffff, 0, 0xffffffff, 0, 0xffffffff, 0 }; + static const uint32_t unset_result[16] = { 0, 0, 0xffffffff, 0, 0, 0xffffffff, 0, 0xffffffff, 0, 0xffffffff, 0, 0xffffffff, 0, 0xffffffff, 0, 0xffffffff }; + static const uint32_t mask[16] = { 0, 0, 0, 0, (N_MASK | Z_MASK), (N_MASK | Z_MASK), N_MASK, N_MASK, + (C_MASK | Z_MASK), (C_MASK | Z_MASK), C_MASK, C_MASK, Z_MASK, Z_MASK, V_MASK, V_MASK }; - // Reserved - case 1: - case 16: - case 17: - case 19: + if (SR & mask[n]) + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = set_result[n]; + else + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = unset_result[n]; + } + else + { LOG("Used reserved N value (%d) in hyperstone_set. PC = %08X\n", n, PC); - break; + } + } + else + { + if (n == 0) + { + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = (SP & 0xfffffe00) | (GET_FP << 2) | (((SP & 0x100) && (SIGN_BIT(SR) == 0)) ? 1 : 0); + } + else if (n >= 2) + { + static const uint32_t set_result[16] = { 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; + static const uint32_t unset_result[16] = { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }; + static const uint32_t mask[16] = { 0, 0, 0, 0, (N_MASK | Z_MASK), (N_MASK | Z_MASK), N_MASK, N_MASK, + (C_MASK | Z_MASK), (C_MASK | Z_MASK), C_MASK, C_MASK, Z_MASK, Z_MASK, V_MASK, V_MASK }; - // SETxx - case 2: - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - break; - - case 3: - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 4: - if (SR & (N_MASK | Z_MASK)) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; + if (SR & mask[n]) + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = set_result[n]; else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 5: - if (SR & (N_MASK | Z_MASK)) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - break; - - case 6: - if (SR & N_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 7: - if (SR & N_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - break; - - case 8: - if (SR & (C_MASK | Z_MASK)) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 9: - if (SR & (C_MASK | Z_MASK)) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - break; - - case 10: - if (SR & C_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 11: - if (SR & C_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - break; - - case 12: - if (SR & Z_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 13: - if (SR & Z_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - break; - - case 14: - if (SR & V_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 15: - if (SR & V_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 1; - break; - - case 18: - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - break; - - case 20: - if (SR & (N_MASK | Z_MASK)) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 21: - if (SR & (N_MASK | Z_MASK)) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - break; - - case 22: - if (SR & N_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 23: - if (SR & N_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - break; - - case 24: - if (SR & (C_MASK | Z_MASK)) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 25: - if (SR & (C_MASK | Z_MASK)) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - break; - - case 26: - if (SR & C_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 27: - if (SR & C_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - break; - - case 28: - if (SR & Z_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 29: - if (SR & Z_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - break; - - case 30: - if (SR & V_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - break; - - case 31: - if (SR & V_MASK) - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = 0; - else - (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = ~0; - break; + (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code] = unset_result[n]; + } + else + { + LOG("Used reserved N value (%d) in hyperstone_set. PC = %08X\n", n, PC); + } } m_icount -= m_clock_cycles_1;