summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/esrip/esripdsm.cpp
blob: 61d8d878ad34f539659583cc335c7604374cf88d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// license:BSD-3-Clause
// copyright-holders:Philip Bennett
/***************************************************************************

    esripdsm.c

    Implementation of the Entertainment Sciences
    AM29116-based Real Time Image Processor

***************************************************************************/

#include "emu.h"
#include "debugger.h"


/***************************************************************************
    DISASSEMBLY HOOK (TODO: FINISH)
***************************************************************************/

static offs_t internal_disasm_esrip(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{
#if 0
	static const char* const jmp_types[] =
	{
		"JCT",
		"JT1",
		"JT2",
		"JT3",
		"JT4",
		"JLBRM",
		"J#HBLANK",
		"JMP",
	};

	static const char* const njmp_types[] =
	{
		"JNCT",
		"JNT1",
		"JNT2",
		"JNT3",
		"JNT4",
		"JNLBRM",
		"J#HBLANK",
		"  ",
	};
#endif

	uint64_t inst = big_endianize_int64(*(uint64_t *)oprom);

	uint32_t inst_hi = inst >> 32;
	uint32_t inst_lo = inst & 0xffffffff;

	uint16_t ins = (inst_hi >> 16) & 0xffff;
	uint8_t  ctrl = (inst_hi >> 8) & 0xff;
	uint8_t  jmp_dest = (inst_lo >> 8) & 0xff;

	uint8_t jmp_ctrl = (ctrl >> 3) & 0x1f;

	uint8_t ctrl1 = (inst_lo >> 16) & 0xff;
	uint8_t ctrl2 = (inst_lo >> 24) & 0xff;
	uint8_t ctrl3 = (inst_hi) & 0xff;

	util::stream_format(stream, "%04x %c%c%c%c %02x %s%s%s%s%s%s%s%s %c%s%s%s %c%c%c%c%c%c%c%c",
			ins,
			ctrl & 1 ? 'D' : ' ',
			ctrl & 2 ? ' ' : 'Y',
			ctrl & 4 ? 'S' : ' ',
			(~jmp_ctrl & 0x18) ? 'J' : ' ',
			jmp_dest,
			ctrl1 & 0x01 ? "  " : "I ",
			ctrl1 & 0x02 ? "  " : "FL",
			ctrl1 & 0x04 ? "FE" : "  ",
			ctrl1 & 0x08 ? "  " : "FR",
			ctrl1 & 0x10 ? "  " : "IL",
			ctrl1 & 0x20 ? "IE" : "  ",
			ctrl1 & 0x40 ? "  " : "IR",
			ctrl1 & 0x80 ? "  " : "IW",

			ctrl2 & 0x80 ? ' ' : 'O',
			ctrl2 & 0x40 ? "     " : "IXLLD",
			ctrl2 & 0x20 ? "     " : "IADLD",
			ctrl2 & 0x10 ? "     " : "SCALD",

			ctrl3 & 0x01 ? ' ' : '0',
			ctrl3 & 0x02 ? ' ' : '1',
			ctrl3 & 0x04 ? ' ' : '2',
			ctrl3 & 0x08 ? ' ' : '3',
			ctrl3 & 0x10 ? ' ' : '4',
			ctrl3 & 0x20 ? ' ' : '5',
			ctrl3 & 0x40 ? ' ' : '6',
			ctrl3 & 0x80 ? ' ' : '7'
			);

	return 1 | DASMFLAG_SUPPORTED;
}


CPU_DISASSEMBLE(esrip)
{
	std::ostringstream stream;
	offs_t result = internal_disasm_esrip(device, stream, pc, oprom, opram, options);
	std::string stream_str = stream.str();
	strcpy(buffer, stream_str.c_str());
	return result;
}