From 857be8d170021da0465445bdef263e015866ae03 Mon Sep 17 00:00:00 2001 From: hap Date: Wed, 1 Jul 2015 21:20:14 +0200 Subject: [PATCH] added sm510 lfsr pc --- src/emu/cpu/hmcs40/hmcs40d.c | 2 +- src/emu/cpu/sm510/sm510.c | 9 ++++++++- src/emu/cpu/sm510/sm510d.c | 23 +++++++++++++++++------ src/mess/drivers/hh_tms1k.c | 1 + 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/emu/cpu/hmcs40/hmcs40d.c b/src/emu/cpu/hmcs40/hmcs40d.c index 4ab55866d5d..8bd9ce4e043 100644 --- a/src/emu/cpu/hmcs40/hmcs40d.c +++ b/src/emu/cpu/hmcs40/hmcs40d.c @@ -82,7 +82,7 @@ static const UINT32 s_flags[] = }; // next program counter in sequence (relative) -static const INT16 s_next_pc[0x40] = +static const INT8 s_next_pc[0x40] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32+0x40, diff --git a/src/emu/cpu/sm510/sm510.c b/src/emu/cpu/sm510/sm510.c index ff504447dd5..7878288205b 100644 --- a/src/emu/cpu/sm510/sm510.c +++ b/src/emu/cpu/sm510/sm510.c @@ -6,6 +6,9 @@ References: - 1990 Sharp Microcomputers Data Book + + TODO: + - proper support for LFSR program counter in debugger */ @@ -130,6 +133,7 @@ void sm510_base_device::device_start() void sm510_base_device::device_reset() { + m_pc = 0x37 << 6; } @@ -143,7 +147,10 @@ void sm510_base_device::device_reset() inline void sm510_base_device::increment_pc() { - m_pc = (m_pc + 1) & m_prgmask; + // PL(program counter low 6 bits) is a simple LFSR: newbit = (bit0==bit1) + // PU,PM(high bits) specify page, PL specifies steps within page + int feed = ((m_pc >> 1 ^ m_pc) & 1) ? 0 : 0x20; + m_pc = feed | (m_pc >> 1 & 0x1f) | (m_pc & ~0x3f); } void sm510_base_device::get_opcode_param() diff --git a/src/emu/cpu/sm510/sm510d.c b/src/emu/cpu/sm510/sm510d.c index 2945bbded3b..71d32fa332d 100644 --- a/src/emu/cpu/sm510/sm510d.c +++ b/src/emu/cpu/sm510/sm510d.c @@ -63,6 +63,16 @@ static const UINT32 s_flags[] = 0, 0, 0, _OVER, 0 }; +// next program counter in sequence (relative) +static const INT8 s_next_pc[0x40] = +{ + 32, -1 /* rollback */, -1, 30, 30, -3, -3, 28, 28, -5, -5, 26, 26, -7, -7, 24, + 24, -9, -9, 22, 22, -11, -11, 20, 20, -13, -13, 18, 18, -15, -15, 16, + 16, -17, -17, 14, 14, -19, -19, 12, 12, -21, -21, 10, 10, -23, -23, 8, + 8, -25, -25, 6, 6, -27, -27, 4, 4, -29, -29, 2, 2, -31, -31, 0 /* gets stuck here */ +}; + + static const UINT8 sm510_mnemonic[0x100] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ @@ -92,18 +102,19 @@ static const UINT8 sm510_mnemonic[0x100] = CPU_DISASSEMBLE(sm510) { // get raw opcode - int pos = 0; - UINT8 op = oprom[pos]; - pos++; + UINT8 op = oprom[0]; UINT8 instr = sm510_mnemonic[op]; + int len = 1; int bits = s_bits[instr]; UINT8 mask = op & ((1 << (bits & 7)) - 1); UINT16 param = mask; if (bits >= 8) { - param = oprom[pos]; - pos++; + // note: disasm view shows correct parameter, but raw view does not + // note2: oprom array negative index access is intentional + param = oprom[s_next_pc[pc & 0x3f]]; + len++; } // disassemble it @@ -133,5 +144,5 @@ CPU_DISASSEMBLE(sm510) } } - return (pos & DASMFLAG_LENGTHMASK) | s_flags[instr] | DASMFLAG_SUPPORTED; + return len | s_flags[instr] | DASMFLAG_SUPPORTED; } diff --git a/src/mess/drivers/hh_tms1k.c b/src/mess/drivers/hh_tms1k.c index 8504f383829..ba2f16dbadb 100644 --- a/src/mess/drivers/hh_tms1k.c +++ b/src/mess/drivers/hh_tms1k.c @@ -24,6 +24,7 @@ @MP1221 TMS1100 1980, Entex Raise The Devil *MP1296 TMS1100? 1982, Entex Black Knight *MP1312 TMS1100 198?, Tandy/RadioShack Science Fair Microcomputer Trainer + *MP1359 TMS1100? 1985, Capsela CRC2000 @MP1525 TMS1170 1980, Coleco Head to Head Baseball *MP1604 ? 1981, Hanzawa Twinvader III/Tandy Cosmic Fire Away 3000 (? note: VFD-capable) @MP2105 TMS1370 1979, Gakken Poker