diff options
Diffstat (limited to 'src/devices/cpu/m6809/konami.cpp')
-rw-r--r-- | src/devices/cpu/m6809/konami.cpp | 130 |
1 files changed, 45 insertions, 85 deletions
diff --git a/src/devices/cpu/m6809/konami.cpp b/src/devices/cpu/m6809/konami.cpp index d9cf3e2c62b..ea0683c83ce 100644 --- a/src/devices/cpu/m6809/konami.cpp +++ b/src/devices/cpu/m6809/konami.cpp @@ -2,12 +2,18 @@ // copyright-holders:Nathan Woods /********************************************************************* - konami.c - Portable Konami cpu emulator + Custom HD6309 in a gate array with ROM blocks for instruction decoding. Based on M6809 cpu core copyright John Butler + TODO: + - verify cycle timing + - verify status flag handling + - EXG/TFR DP: DP here is apparently part of a 16-bit register. DP is + the high byte, and the low byte is an unknown hidden register? It + doesn't look like any game uses this. See MAME issue #13544. + References: 6809 Simulator V09, By L.C. Benschop, Eindhoven The Netherlands. @@ -55,7 +61,6 @@ March 2013 NPW: *****************************************************************************/ #include "emu.h" -#include "debugger.h" #include "konami.h" #include "m6809inl.h" #include "6x09dasm.h" @@ -85,9 +90,9 @@ DEFINE_DEVICE_TYPE(KONAMI, konami_cpu_device, "konami_cpu", "KONAMI CPU") // konami_cpu_device - constructor //------------------------------------------------- -konami_cpu_device::konami_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : m6809_base_device(mconfig, tag, owner, clock, KONAMI, 1) - , m_set_lines(*this) +konami_cpu_device::konami_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + m6809_base_device(mconfig, tag, owner, clock, KONAMI, 4), + m_set_lines(*this) { } @@ -100,8 +105,13 @@ void konami_cpu_device::device_start() { super::device_start(); - // resolve callbacks - m_set_lines.resolve(); + // initialize variables + m_temp_im = 0; + m_bcount = 0; + + // setup regtable + save_item(NAME(m_temp_im)); + save_item(NAME(m_bcount)); } @@ -177,15 +187,15 @@ inline uint16_t &konami_cpu_device::ireg() { switch(m_opcode & 0x70) { - case 0x20: return m_x.w; - case 0x30: return m_y.w; - case 0x50: return m_u.w; - case 0x60: return m_s.w; - case 0x70: return m_pc.w; + case 0x20: return m_x.w; // X + case 0x30: return m_y.w; // Y + case 0x50: return m_u.w; // U + case 0x60: return m_s.w; // S + case 0x70: return m_pc.w; // PC + default: fatalerror("Should not get here"); // never executed - //return m_x.w; } } @@ -194,21 +204,22 @@ inline uint16_t &konami_cpu_device::ireg() // read_exgtfr_register //------------------------------------------------- -inline m6809_base_device::exgtfr_register konami_cpu_device::read_exgtfr_register(uint8_t reg) +inline uint16_t konami_cpu_device::read_exgtfr_register(uint8_t reg) { - exgtfr_register result; - result.word_value = 0x00FF; + uint16_t result = 0; switch(reg & 0x07) { - case 0: result.word_value = m_q.r.a; break; // A - case 1: result.word_value = m_q.r.b; break; // B - case 2: result.word_value = m_x.w; break; // X - case 3: result.word_value = m_y.w; break; // Y - case 4: result.word_value = m_s.w; break; // S - case 5: result.word_value = m_u.w; break; // U + case 0: result = m_q.r.a | 0x1000; break; // A (high byte is always 0x10) + case 1: result = m_q.r.d; break; // D! + case 2: result = m_x.w; break; // X + case 3: result = m_y.w; break; // Y + case 4: logerror("EXG/TFR unemulated DP reg\n"); break; // DP + case 5: result = m_u.w; break; // U + case 6: result = m_s.w; break; // S + case 7: result = m_pc.w; break; // PC } - result.byte_value = (uint8_t) result.word_value; + return result; } @@ -217,73 +228,23 @@ inline m6809_base_device::exgtfr_register konami_cpu_device::read_exgtfr_registe // write_exgtfr_register //------------------------------------------------- -inline void konami_cpu_device::write_exgtfr_register(uint8_t reg, m6809_base_device::exgtfr_register value) +inline void konami_cpu_device::write_exgtfr_register(uint8_t reg, uint16_t value) { switch(reg & 0x07) { - case 0: m_q.r.a = value.byte_value; break; // A - case 1: m_q.r.b = value.byte_value; break; // B - case 2: m_x.w = value.word_value; break; // X - case 3: m_y.w = value.word_value; break; // Y - case 4: m_s.w = value.word_value; break; // S - case 5: m_u.w = value.word_value; break; // U + case 0: m_q.r.a = value; break; // A + case 1: m_q.r.b = value; break; // B + case 2: m_x.w = value; break; // X + case 3: m_y.w = value; break; // Y + case 4: logerror("EXG/TFR unemulated DP reg\n"); break; // DP + case 5: m_u.w = value; break; // U + case 6: m_s.w = value; break; // S + case 7: m_pc.w = value; break; // PC } } //------------------------------------------------- -// safe_shift_right -//------------------------------------------------- - -template<class T> T konami_cpu_device::safe_shift_right(T value, uint32_t shift) -{ - T result; - - if (shift < (sizeof(T) * 8)) - result = value >> shift; - else if (value < 0) - result = (T) -1; - else - result = 0; - - return result; -} - - -//------------------------------------------------- -// safe_shift_right_unsigned -//------------------------------------------------- - -template<class T> T konami_cpu_device::safe_shift_right_unsigned(T value, uint32_t shift) -{ - T result; - - if (shift < (sizeof(T) * 8)) - result = value >> shift; - else - result = 0; - - return result; -} - -//------------------------------------------------- -// safe_shift_left -//------------------------------------------------- - -template<class T> T konami_cpu_device::safe_shift_left(T value, uint32_t shift) -{ - T result; - - if (shift < (sizeof(T) * 8)) - result = value << shift; - else - result = 0; - - return result; -} - - -//------------------------------------------------- // lmul //------------------------------------------------- @@ -348,8 +309,7 @@ inline void konami_cpu_device::divx() void konami_cpu_device::set_lines(uint8_t data) { - if (!m_set_lines.isnull()) - m_set_lines((offs_t)0, data); + m_set_lines(offs_t(0), data); } |