summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2020-02-22 16:38:19 +0100
committer Olivier Galibert <galibert@pobox.com>2020-02-22 16:45:32 +0100
commitc849d1dc422ed5f23c40bdafe6445f65f9761b77 (patch)
tree445ebd8977970dd91163f6db3342e308cba888aa
parent1db527eed87acf0e563a3dee80c87de9f8667fce (diff)
ks0164: First try at a disassembler [David Carne, O. Galibert]
-rw-r--r--scripts/src/cpu.lua17
-rw-r--r--scripts/target/mame/arcade.lua1
-rw-r--r--src/devices/cpu/ks0164/ks0164.cpp74
-rw-r--r--src/devices/cpu/ks0164/ks0164.h36
-rw-r--r--src/devices/cpu/ks0164/ks0164d.cpp198
-rw-r--r--src/devices/cpu/ks0164/ks0164d.h35
-rw-r--r--src/mame/drivers/dgpix.cpp29
-rw-r--r--src/mame/drivers/xavix2.cpp2
-rw-r--r--src/tools/unidasm.cpp2
9 files changed, 380 insertions, 14 deletions
diff --git a/scripts/src/cpu.lua b/scripts/src/cpu.lua
index 90d8d01dc0c..3cf6ccc28e5 100644
--- a/scripts/src/cpu.lua
+++ b/scripts/src/cpu.lua
@@ -3181,3 +3181,20 @@ if (CPUS["ROMP"]~=null or _OPTIONS["with-tools"]) then
table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/romp/rompdasm.cpp")
table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/romp/rompdasm.h")
end
+
+--------------------------------------------------
+-- KS0164
+--@src/devices/cpu/ks0164/ks0164.h,CPUS["KS0164"] = true
+--------------------------------------------------
+
+if (CPUS["KS0164"]~=null) then
+ files {
+ MAME_DIR .. "src/devices/cpu/ks0164/ks0164.cpp",
+ MAME_DIR .. "src/devices/cpu/ks0164/ks0164.h",
+ }
+end
+
+if (CPUS["KS0164"]~=null or _OPTIONS["with-tools"]) then
+ table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/ks0164/ks0164d.cpp")
+ table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/ks0164/ks0164d.h")
+end
diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua
index d3641c7bebd..c71b8c45816 100644
--- a/scripts/target/mame/arcade.lua
+++ b/scripts/target/mame/arcade.lua
@@ -139,6 +139,7 @@ CPUS["HPC"] = true
--CPUS["CR16B"] = true
CPUS["FR"] = true
CPUS["UPD78K"] = true
+CPUS["KS0164"] = true
--------------------------------------------------
-- specify available sound cores
diff --git a/src/devices/cpu/ks0164/ks0164.cpp b/src/devices/cpu/ks0164/ks0164.cpp
new file mode 100644
index 00000000000..f896ad6931c
--- /dev/null
+++ b/src/devices/cpu/ks0164/ks0164.cpp
@@ -0,0 +1,74 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert, David Carne
+
+// KS0164 core
+
+#include "emu.h"
+#include "ks0164.h"
+#include "ks0164d.h"
+#include "debugger.h"
+
+DEFINE_DEVICE_TYPE(KS0164, ks0164_device, "ks0164", "Samsung KS0164 audio processor")
+
+ks0164_device::ks0164_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : cpu_device(mconfig, KS0164, tag, owner, clock)
+ , m_program_config("program", ENDIANNESS_BIG, 16, 16)
+{
+}
+
+void ks0164_device::device_start()
+{
+ state_add(STATE_GENPC, "GENPC", m_pc).callexport().noshow();
+ state_add(STATE_GENPCBASE, "CURPC", m_pc).callexport().noshow();
+
+ save_item(NAME(m_pc));
+ set_icountptr(m_icount);
+
+ m_pc = 0;
+}
+
+void ks0164_device::device_reset()
+{
+ m_pc = 0x780;
+}
+
+uint32_t ks0164_device::execute_min_cycles() const noexcept
+{
+ return 1;
+}
+
+uint32_t ks0164_device::execute_max_cycles() const noexcept
+{
+ return 1;
+}
+
+uint32_t ks0164_device::execute_input_lines() const noexcept
+{
+ return 0;
+}
+
+void ks0164_device::execute_set_input(int inputnum, int state)
+{
+}
+
+device_memory_interface::space_config_vector ks0164_device::memory_space_config() const
+{
+ return space_config_vector {
+ std::make_pair(AS_PROGRAM, &m_program_config)
+ };
+}
+
+std::unique_ptr<util::disasm_interface> ks0164_device::create_disassembler()
+{
+ return std::make_unique<ks0164_disassembler>();
+}
+
+void ks0164_device::state_string_export(const device_state_entry &entry, std::string &str) const
+{
+}
+
+void ks0164_device::execute_run()
+{
+ debugger_instruction_hook(m_pc);
+ m_icount = 0;
+}
diff --git a/src/devices/cpu/ks0164/ks0164.h b/src/devices/cpu/ks0164/ks0164.h
new file mode 100644
index 00000000000..5041b8270e5
--- /dev/null
+++ b/src/devices/cpu/ks0164/ks0164.h
@@ -0,0 +1,36 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert, David Carne
+
+// KS0164 core
+
+#ifndef MAME_CPU_KS0164_KS0164_H
+#define MAME_CPU_KS0164_KS0164_H
+
+#pragma once
+
+class ks0164_device : public cpu_device
+{
+public:
+ ks0164_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+protected:
+ int m_icount;
+ u32 m_pc;
+
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual uint32_t execute_min_cycles() const noexcept override;
+ virtual uint32_t execute_max_cycles() const noexcept override;
+ virtual uint32_t execute_input_lines() const noexcept override;
+ virtual void execute_run() override;
+ virtual void execute_set_input(int inputnum, int state) override;
+ virtual space_config_vector memory_space_config() const override;
+ virtual std::unique_ptr<util::disasm_interface> create_disassembler() override;
+ virtual void state_string_export(const device_state_entry &entry, std::string &str) const override;
+
+ const address_space_config m_program_config;
+};
+
+DECLARE_DEVICE_TYPE(KS0164, ks0164_device)
+
+#endif
diff --git a/src/devices/cpu/ks0164/ks0164d.cpp b/src/devices/cpu/ks0164/ks0164d.cpp
new file mode 100644
index 00000000000..0cedb4559f7
--- /dev/null
+++ b/src/devices/cpu/ks0164/ks0164d.cpp
@@ -0,0 +1,198 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert, David Carne
+
+// KS0164 disassembler
+
+#include "emu.h"
+#include "ks0164d.h"
+
+u32 ks0164_disassembler::opcode_alignment() const
+{
+ return 2;
+}
+
+const char *const ks0164_disassembler::regs[8] = {
+ "r0", "r1", "r2", "r3", "sp", "psw", "pc", "zero"
+};
+
+s32 ks0164_disassembler::off10(u32 opcode)
+{
+ return opcode & 0x200 ? opcode | 0xfffffc00 : opcode & 0x3ff;
+}
+
+std::string ks0164_disassembler::off16(s16 dt)
+{
+ return dt < 0 ? util::string_format(" - %x", -dt) : dt ? util::string_format(" + %x", dt) : "";
+}
+
+#define P std::ostream &stream, u32 opcode, const data_buffer &opcodes, u32 pc
+const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
+ { 0x0000, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bne %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x0400, 0xfc00, [](P) -> u32 { util::stream_format(stream, "beq %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x0800, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?2 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x0c00, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?3 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x1000, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?4 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x1400, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?5 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x1800, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?6 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x1c00, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?7 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x2000, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?8 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x2400, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?9 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x2800, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?a %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x2c00, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?b %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x3000, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?c %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x3400, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?d %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x3800, 0xfc00, [](P) -> u32 { util::stream_format(stream, "blt %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x3c00, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bra %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+
+ { 0x4000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s.w += %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+ { 0x4800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s.w -= %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+ { 0x5000, 0xf800, [](P) -> u32 { util::stream_format(stream, "cmp %s.w, %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+ { 0x5800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s.w &= %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+ { 0x6000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s.w |= %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+ { 0x6800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s.w ?5 %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+ { 0x7000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s.w = %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+ { 0x7800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s.w ?7 %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+
+ { 0x8004, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b += %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x800c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w += %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x8804, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b -= %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x880c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w -= %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x9004, 0xf88f, [](P) -> u32 { util::stream_format(stream, "cmp %s.b, %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x900c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "cmp %s.w, %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x9804, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b &= %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x980c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w &= %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa004, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b |= %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa00c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w |= %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa804, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b ?5 %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa80c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w ?5 %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xb004, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b = %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xb00c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w = %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xb804, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b ?7 %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xb80c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w ?7 %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+
+ { 0x8075, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.b += %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0x807d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.w += %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0x8875, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.b -= %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0x887d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.w -= %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0x9075, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "cmp %s.b, %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0x907d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "cmp %s.w, %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0x9875, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.b &= %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0x987d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.w &= %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xa075, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.b |= %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xa07d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.w |= %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xa875, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.b ?5 %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xa87d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.w ?5 %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xb075, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.b = %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xb07d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.w = %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xb875, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.b ?7 %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xb87d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s.w ?7 %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+
+ { 0x8006, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b += (%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x800e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w += (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x8806, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b -= (%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x880e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w -= (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x9006, 0xf88f, [](P) -> u32 { util::stream_format(stream, "cmp %s.b, (%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x900e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "cmp %s.w, (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x9806, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b &= (%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0x980e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w &= (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa006, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b |= (%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa00e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w |= (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa806, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b ?5 (%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa80e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w ?5 (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xb006, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b = (%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xb00e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w = (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xb806, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b ?7 (%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xb80e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w ?7 (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+
+ { 0x8077, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.b += (%04x).b", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0x807f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.w += (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0x8877, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.b -= (%04x).b", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0x887f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.w -= (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0x9077, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "cmp %s.b, (%04x).b", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0x907f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "cmp %s.w, (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0x9877, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.b &= (%04x).b", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0x987f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.w &= (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xa077, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.b |= (%04x).b", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xa07f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.w |= (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xa877, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.b ?5 (%04x).b", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xa87f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.w ?5 (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xb077, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.b = (%04x).b", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xb07f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.w = (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xb877, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.b ?7 (%04x).b", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xb87f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s.w ?7 (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+
+ { 0x8007, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b += (%s%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0x800f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w += (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0x8807, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b -= (%s%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0x880f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w -= (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0x9007, 0xf88f, [](P) -> u32 { util::stream_format(stream, "cmp %s.b, (%s%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0x900f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "cmp %s.w, (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0x9807, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b &= (%s%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0x980f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w &= (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xa007, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b |= (%s%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xa00f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w |= (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xa807, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b ?5 (%s%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xa80f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w ?5 (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xb007, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b = (%s%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xb00f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w = (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xb807, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.b ?7 (%s%s).b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xb80f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w ?7 (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+
+ { 0xc000, 0xf88f, [](P) -> u32 { util::stream_format(stream, "-(%s).w = %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xc001, 0xffff, [](P) -> u32 { util::stream_format(stream, "push?"); return 2; } },
+ { 0xc003, 0xffff, [](P) -> u32 { util::stream_format(stream, "pop?"); return 2; } },
+ { 0xc008, 0xf88f, [](P) -> u32 { util::stream_format(stream, "(%s)+.w = %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xc00a, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s.w = (%s)+.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+
+ { 0xc00c, 0xf80f, [](P) -> u32 { util::stream_format(stream, "%s.w <<= %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xc80c, 0xf80f, [](P) -> u32 { util::stream_format(stream, "%s.w >>= %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+
+ { 0xd001, 0xffff, [](P) -> u32 { util::stream_format(stream, "jmp %04x", opcodes.r16(pc+2)); return 4; } },
+ { 0xd002, 0xffff, [](P) -> u32 { util::stream_format(stream, "jsr %04x", opcodes.r16(pc+2)); return 4; } },
+ { 0xd003, 0xffff, [](P) -> u32 { util::stream_format(stream, "rts"); return 2; } },
+ { 0xd004, 0xffff, [](P) -> u32 { util::stream_format(stream, "rti"); return 2; } },
+
+ { 0xe000, 0xf80f, [](P) -> u32 { util::stream_format(stream, "btst %s.b, %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xe008, 0xf80f, [](P) -> u32 { util::stream_format(stream, "btst %s.w, %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xe001, 0xf80f, [](P) -> u32 { util::stream_format(stream, "bset %s.b, %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xe009, 0xf80f, [](P) -> u32 { util::stream_format(stream, "bset %s.w, %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xe002, 0xf80f, [](P) -> u32 { util::stream_format(stream, "btst (%s).b, %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xe00a, 0xf80f, [](P) -> u32 { util::stream_format(stream, "btst (%s).w, %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xe703, 0xff0f, [](P) -> u32 { util::stream_format(stream, "btst (%04x).b, %x", opcodes.r16(pc+2), (opcode >> 4) & 0xf); return 4; } },
+ { 0xe70b, 0xff0f, [](P) -> u32 { util::stream_format(stream, "btst (%04x).w, %x", opcodes.r16(pc+2), (opcode >> 4) & 0xf); return 4; } },
+ { 0xe003, 0xf80f, [](P) -> u32 { util::stream_format(stream, "btst (%s%s).b, %x", regs[(opcode >> 8) & 7], off16(opcodes.r16(pc+2)), (opcode >> 4) & 0xf); return 4; } },
+ { 0xe00b, 0xf80f, [](P) -> u32 { util::stream_format(stream, "btst (%s%s).w, %x", regs[(opcode >> 8) & 7], off16(opcodes.r16(pc+2)), (opcode >> 4) & 0xf); return 4; } },
+ { 0xe004, 0xf80f, [](P) -> u32 { util::stream_format(stream, "bclr %s.b, %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xe00c, 0xf80f, [](P) -> u32 { util::stream_format(stream, "bclr %s.w, %x", regs[(opcode >> 8) & 7], (opcode >> 4) & 0xf); return 2; } },
+ { 0xe006, 0xf88f, [](P) -> u32 { util::stream_format(stream, "(%s).b = %s.b", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xe00e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "(%s).w = %s.w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xe707, 0xff8f, [](P) -> u32 { util::stream_format(stream, "(%04x).b = %s.b", opcodes.r16(pc+2), regs[(opcode >> 4) & 7]); return 4; } },
+ { 0xe70f, 0xff8f, [](P) -> u32 { util::stream_format(stream, "(%04x).w = %s.w", opcodes.r16(pc+2), regs[(opcode >> 4) & 7]); return 4; } },
+ { 0xe007, 0xf88f, [](P) -> u32 { util::stream_format(stream, "(%s%s).b = %s.b", regs[(opcode >> 8) & 7], off16(opcodes.r16(pc+2)), regs[(opcode >> 4) & 7]); return 4; } },
+ { 0xe00f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "(%s%s).w = %s.w", regs[(opcode >> 8) & 7], off16(opcodes.r16(pc+2)), regs[(opcode >> 4) & 7]); return 4; } },
+
+
+ { 0x0000, 0x0000, [](P) -> u32 { util::stream_format(stream, "?%04x", opcode); return 2; } },
+};
+
+#undef P
+
+offs_t ks0164_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params)
+{
+ u32 opcode = opcodes.r16(pc);
+
+ for(u32 i=0;; i++)
+ if((opcode & instructions[i].mask) == instructions[i].value)
+ return instructions[i].cb(stream, opcode, opcodes, pc);
+
+ abort();
+
+#if 0
+ } else if((opcode & 0xf80f) == 0xc800) // c808?
+ util::stream_format(stream, "store.w -(%s), %s", regs[(opcode >> 4) & 7], regs[(opcode >> 7) & 7]);
+
+ else if( (opcode & 0xf88f) == 0xc00a)
+ util::stream_format(stream, "load.w %s, (%s)+ ?2", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]);
+
+#endif
+}
diff --git a/src/devices/cpu/ks0164/ks0164d.h b/src/devices/cpu/ks0164/ks0164d.h
new file mode 100644
index 00000000000..ebc3adc2655
--- /dev/null
+++ b/src/devices/cpu/ks0164/ks0164d.h
@@ -0,0 +1,35 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert, David Carne
+
+// KS0164 disassembler
+
+#ifndef MAME_CPU_KS0164_KS0164DASM_H
+#define MAME_CPU_KS0164_KS0164DASM_H
+
+#pragma once
+
+class ks0164_disassembler : public util::disasm_interface
+{
+public:
+ ks0164_disassembler() = default;
+ virtual ~ks0164_disassembler() = default;
+
+ virtual u32 opcode_alignment() const override;
+ virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
+
+private:
+ struct instruction {
+ u16 value;
+ u16 mask;
+ std::function<u32 (std::ostream &, u32, const data_buffer &, u32)> cb;
+ };
+
+ static const instruction instructions[];
+ static const char *const regs[8];
+
+ static s32 off10(u32 opcode);
+ static std::string off16(s16 dt);
+};
+
+#endif
+
diff --git a/src/mame/drivers/dgpix.cpp b/src/mame/drivers/dgpix.cpp
index f33e4dd0170..ff13439fbf6 100644
--- a/src/mame/drivers/dgpix.cpp
+++ b/src/mame/drivers/dgpix.cpp
@@ -153,6 +153,7 @@ Notes:
#include "emu.h"
#include "cpu/e132xs/e132xs.h"
+#include "cpu/ks0164/ks0164.h"
#include "machine/nvram.h"
#include "emupal.h"
#include "screen.h"
@@ -165,6 +166,7 @@ public:
driver_device(mconfig, type, tag),
m_flash(*this, "flash"),
m_maincpu(*this, "maincpu"),
+ m_soundcpu(*this, "soundcpu"),
m_vblank(*this, "VBLANK")
{ }
@@ -186,6 +188,7 @@ private:
required_memory_region m_flash;
required_device<cpu_device> m_maincpu;
+ required_device<ks0164_device> m_soundcpu;
required_ioport m_vblank;
std::unique_ptr<u16[]> m_vram;
@@ -206,6 +209,7 @@ private:
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void mem_map(address_map &map);
void io_map(address_map &map);
+ void snd_map(address_map &map);
};
@@ -342,6 +346,10 @@ void dgpix_state::io_map(address_map &map)
map(0x0c84, 0x0c87).nopr(); // sound status, checks bit 0x40 and 0x80
}
+void dgpix_state::snd_map(address_map &map)
+{
+ map(0x0000, 0x7fff).rom();
+}
static INPUT_PORTS_START( dgpix )
PORT_START("VBLANK")
@@ -424,10 +432,8 @@ void dgpix_state::dgpix(machine_config &config)
m_maincpu->set_addrmap(AS_PROGRAM, &dgpix_state::mem_map);
m_maincpu->set_addrmap(AS_IO, &dgpix_state::io_map);
-/*
- unknown 16bit sound cpu, embedded inside the KS0164 sound chip
- running at 16.9MHz
-*/
+ KS0164(config, m_soundcpu, 16900000);
+ m_soundcpu->set_addrmap(AS_PROGRAM, &dgpix_state::snd_map);
NVRAM(config, "nvram", nvram_device::DEFAULT_NONE);
@@ -441,9 +447,6 @@ void dgpix_state::dgpix(machine_config &config)
screen.set_palette("palette");
PALETTE(config, "palette", palette_device::BGR_555);
-
- /* sound hardware */
- // KS0164 sound chip
}
@@ -462,7 +465,7 @@ ROM_START( elfin )
ROM_LOAD16_WORD_SWAP( "flash.u8", 0x1800000, 0x400000, CRC(eb56d7ca) SHA1(7c1cfcc68579cf3bdd9707da7d745a410223b8d9) )
ROM_LOAD16_WORD_SWAP( "flash.u9", 0x1c00000, 0x400000, CRC(cbf64ef4) SHA1(1a231872ee14e6d718c3f8888185ede7483e79dd) ) /* game settings & highscores are saved in here */
- ROM_REGION( 0x400000, "cpu1", 0 ) /* sound rom */
+ ROM_REGION( 0x400000, "soundcpu", 0 ) /* sound rom */
ROM_LOAD16_WORD_SWAP( "flash.u10", 0x000000, 0x400000, CRC(d378fe55) SHA1(5cc7bc5ae258cd48816857793a262e7c6c330795) )
ROM_REGION( 0x1000, "cpu2", ROMREGION_ERASEFF ) /* PIC */
@@ -484,7 +487,7 @@ ROM_START( jumpjump )
ROM_LOAD16_WORD_SWAP( "jumpjump.u8", 0x1800000, 0x400000, CRC(210dfd8b) SHA1(a1aee4ec8c01832e77d2e4e334a62c246d7e3635) )
ROM_LOAD16_WORD_SWAP( "jumpjump.u9", 0x1c00000, 0x400000, CRC(16d1e352) SHA1(3c43974fb8d90b0c84472dd9f2167eb983142095) )
- ROM_REGION( 0x400000, "cpu1", 0 ) /* sound rom */
+ ROM_REGION( 0x400000, "soundcpu", 0 ) /* sound rom */
ROM_LOAD16_WORD_SWAP( "jumpjump.u10", 0x000000, 0x400000, CRC(2152ecce) SHA1(522d389952a07fa0830ca8aaa6de3aacf834e32e) )
ROM_REGION( 0x1000, "cpu2", ROMREGION_ERASEFF ) /* PIC */
@@ -509,7 +512,7 @@ ROM_START( xfiles )
ROM_LOAD16_WORD_SWAP( "flash.u8", 0x1800000, 0x400000, CRC(231ad82a) SHA1(a1cc5c4122605e564d51137f1dca2afa82616202) )
ROM_LOAD16_WORD_SWAP( "flash.u9", 0x1c00000, 0x400000, CRC(d68994b7) SHA1(c1752d6795f7aaa6beef73643327205a1c32f0f5) )
- ROM_REGION( 0x400000, "cpu1", 0 ) /* sound rom */
+ ROM_REGION( 0x400000, "soundcpu", 0 ) /* sound rom */
ROM_LOAD16_WORD_SWAP( "flash.u10", 0x0000000, 0x400000, CRC(1af33cda) SHA1(9bbcfb07a4a5bcff3efc1c7bcc51bc16c47ca9e6) )
ROM_REGION( 0x1000, "cpu2", 0 ) /* PIC */
@@ -542,7 +545,7 @@ ROM_START( xfilesk )
ROM_LOAD16_WORD_SWAP( "u8.bin", 0x1800000, 0x400000, CRC(3b2c2bc1) SHA1(1c07fb5bd8a8c9b5fb169e6400fef845f3aee7aa) )
ROM_LOAD16_WORD_SWAP( "u9.bin", 0x1c00000, 0x400000, CRC(6ecdd1eb) SHA1(e26c9711e589865cc75ec693d382758fa52528b8) )
- ROM_REGION( 0x400000, "cpu1", 0 ) /* sound rom */
+ ROM_REGION( 0x400000, "soundcpu", 0 ) /* sound rom */
ROM_LOAD16_WORD_SWAP( "u10.bin", 0x0000000, 0x400000, CRC(f2ef1eb9) SHA1(d033d140fce6716d7d78509aa5387829f0a1404c) )
ROM_REGION( 0x1000, "cpu2", 0 ) /* PIC */
@@ -566,7 +569,7 @@ ROM_START( kdynastg )
ROM_LOAD16_WORD_SWAP( "flash.u8", 0x1800000, 0x400000, CRC(1016b61c) SHA1(eab4934e1f41cc26259e5187a94ceebd45888a94) )
ROM_LOAD16_WORD_SWAP( "flash.u9", 0x1c00000, 0x400000, CRC(093d9243) SHA1(2a643acc7144193aaa3606a84b0c67aadb4c543b) )
- ROM_REGION( 0x400000, "cpu1", 0 ) /* sound rom */
+ ROM_REGION( 0x400000, "soundcpu", 0 ) /* sound rom */
ROM_LOAD16_WORD_SWAP( "flash.u10", 0x0000000, 0x400000, CRC(3f103cb1) SHA1(2ff9bd73f3005f09d872018b81c915b01d6703f5) )
ROM_REGION( 0x1000, "cpu2", 0 ) /* PIC */
@@ -590,7 +593,7 @@ ROM_START( fmaniac3 )
ROM_LOAD16_WORD_SWAP( "flash.u8", 0x1800000, 0x400000, CRC(dc08a224) SHA1(4d14145eb84ad13674296f81e90b9d60403fa0de) )
ROM_LOAD16_WORD_SWAP( "flash.u9", 0x1c00000, 0x400000, CRC(c1fee95f) SHA1(0ed5ed9fa18e7da9242a6df2c210c46de25a2281) )
- ROM_REGION( 0x400000, "cpu1", 0 ) /* sound rom */
+ ROM_REGION( 0x400000, "soundcpu", 0 ) /* sound rom */
ROM_LOAD16_WORD_SWAP( "flash.u10", 0x000000, 0x400000, CRC(dfeb91a0) SHA1(a4a79073c3f6135957ea8a4a66a9c71a3a39893c) )
ROM_REGION( 0x1000, "cpu2", ROMREGION_ERASEFF ) /* PIC */
diff --git a/src/mame/drivers/xavix2.cpp b/src/mame/drivers/xavix2.cpp
index 45d1f10c3a0..58f82a34927 100644
--- a/src/mame/drivers/xavix2.cpp
+++ b/src/mame/drivers/xavix2.cpp
@@ -210,7 +210,7 @@ void xavix2_state::gpu_count_w(u16 data)
default:
for(u32 yy=0; yy<sy; yy++)
for(u32 xx=0; xx<sx; xx++)
- m_sd[yy+y][xx+x] = 0x00000000;
+ m_sd[yy+y][xx+x] = 0xffff0000;
break;
}
}
diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp
index 8865ae012dc..fe2c65ead8b 100644
--- a/src/tools/unidasm.cpp
+++ b/src/tools/unidasm.cpp
@@ -71,6 +71,7 @@ using util::BIT;
#include "cpu/i960/i960dis.h"
#include "cpu/ie15/ie15dasm.h"
#include "cpu/jaguar/jagdasm.h"
+#include "cpu/ks0164/ks0164d.h"
#include "cpu/lc8670/lc8670dsm.h"
#include "cpu/lh5801/5801dasm.h"
#include "cpu/lr35902/lr35902d.h"
@@ -416,6 +417,7 @@ static const dasm_table_entry dasm_table[] =
{ "jaguardsp", be, 0, []() -> util::disasm_interface * { return new jaguar_disassembler(jaguar_disassembler::variant::DSP); } },
{ "jaguargpu", be, 0, []() -> util::disasm_interface * { return new jaguar_disassembler(jaguar_disassembler::variant::GPU); } },
{ "konami", be, 0, []() -> util::disasm_interface * { return new konami_disassembler; } },
+ { "ks0164", be, 0, []() -> util::disasm_interface * { return new ks0164_disassembler; } },
{ "lc8670", be, 0, []() -> util::disasm_interface * { return new lc8670_disassembler; } },
{ "lh5801", le, 0, []() -> util::disasm_interface * { return new lh5801_disassembler; } },
{ "lr35902", le, 0, []() -> util::disasm_interface * { return new lr35902_disassembler; } },