1 // license:BSD-3-Clause
2 // copyright-holders:Olivier Galibert
3 /***************************************************************************
4 
5     m65ce02.c
6 
7     6502 with Z register and some more stuff
8 
9 ***************************************************************************/
10 
11 #include "emu.h"
12 #include "m65ce02.h"
13 #include "m65ce02d.h"
14 
15 DEFINE_DEVICE_TYPE(M65CE02, m65ce02_device, "m65ce02", "CSG 65CE02")
16 
m65ce02_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)17 m65ce02_device::m65ce02_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
18 	m65ce02_device(mconfig, M65CE02, tag, owner, clock)
19 {
20 }
21 
m65ce02_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,uint32_t clock)22 m65ce02_device::m65ce02_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
23 	m65c02_device(mconfig, type, tag, owner, clock), TMP3(0), Z(0), B(0)
24 {
25 }
26 
create_disassembler()27 std::unique_ptr<util::disasm_interface> m65ce02_device::create_disassembler()
28 {
29 	return std::make_unique<m65ce02_disassembler>();
30 }
31 
init()32 void m65ce02_device::init()
33 {
34 	m65c02_device::init();
35 	state_add(M65CE02_Z, "Z", Z);
36 	state_add(M65CE02_B, "B", B).callimport().formatstr("%2s");
37 	save_item(NAME(B));
38 	save_item(NAME(Z));
39 	save_item(NAME(TMP3));
40 	Z = 0x00;
41 	B = 0x0000;
42 	TMP3 = 0x0000;
43 }
44 
device_start()45 void m65ce02_device::device_start()
46 {
47 	mintf = std::make_unique<mi_default>();
48 
49 	init();
50 }
51 
device_reset()52 void m65ce02_device::device_reset()
53 {
54 	m65c02_device::device_reset();
55 	Z = 0x00;
56 	B = 0x0000;
57 }
58 
state_import(const device_state_entry & entry)59 void m65ce02_device::state_import(const device_state_entry &entry)
60 {
61 	switch(entry.index()) {
62 	case STATE_GENFLAGS:
63 	case M6502_P:
64 		P = P | F_B;
65 		break;
66 	case M65CE02_B:
67 		B <<= 8;
68 		break;
69 	}
70 }
71 
state_string_export(const device_state_entry & entry,std::string & str) const72 void m65ce02_device::state_string_export(const device_state_entry &entry, std::string &str) const
73 {
74 	switch(entry.index()) {
75 	case STATE_GENFLAGS:
76 	case M6502_P:
77 		str = string_format("%c%c%c%c%c%c%c",
78 						P & F_N ? 'N' : '.',
79 						P & F_V ? 'V' : '.',
80 						P & F_E ? 'E' : '.',
81 						P & F_D ? 'D' : '.',
82 						P & F_I ? 'I' : '.',
83 						P & F_Z ? 'Z' : '.',
84 						P & F_C ? 'C' : '.');
85 		break;
86 	case M65CE02_B:
87 		str = string_format("%02x", B >> 8);
88 		break;
89 	}
90 }
91 
92 #include "cpu/m6502/m65ce02.hxx"
93