summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/capcom/psrockman.cpp
blob: 15c0b65f0662a504ad9788798b7fd12a774f2f5e (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// license:BSD-3-Clause
// copyright-holders:

/*
PANIC SHOT ROCKMAN - カプコン パニックショットロックマン
MECHANICAL GAME (pinball / medal game hybrid)
1992
D-CPC-ROCKMAN-02

===

EPROMS

D27C010A

D27C512

===

PLD
PALACE16V8H-25PC/4

===

OKI M6295

YAMAHA YM2203C

ZILOG Z80 CPU
*/


#include "emu.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"
#include "cpu/z80/z80.h"
#include "sound/okim6295.h"
#include "sound/ymopn.h"


namespace {

class psrockman_state : public driver_device
{
public:
	psrockman_state(const machine_config &mconfig, device_type type, const char *tag)
	: driver_device(mconfig, type, tag)
	{}


	void psrockman(machine_config &config);

private:
	void io_map(address_map &map);
	void prg_map(address_map &map);
};


void psrockman_state::prg_map(address_map &map)
{
	map(0x0000, 0x7fff).rom();
	map(0xd000, 0xd000).portr("IN0"); // TODO: guess, 0x40 seems to make the call attendant speech stutter/restart, also .w()?
	//map(0xd008, 0xd008).rw();
	//map(0xd010, 0xd010).rw();
	//map(0xd018, 0xd018).w();
	//map(0xd020, 0xd020).w();
	//map(0xd038, 0xd038).w();
	map(0xe000, 0xffff).ram();
}

void psrockman_state::io_map(address_map &map) // TODO: only guesses
{
	map.global_mask(0xff);

	map(0x00, 0x01).rw("ym", FUNC(ym2203_device::read), FUNC(ym2203_device::write));
	map(0x40, 0x40).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write));
}


static INPUT_PORTS_START( psrockman ) // 2 8-dip blocks
	PORT_START("IN0")
	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("DSW1")
	PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1")
	PORT_DIPUNKNOWN_DIPLOC(0x02, 0x02, "SW1:2")
	PORT_DIPUNKNOWN_DIPLOC(0x04, 0x04, "SW1:3")
	PORT_DIPUNKNOWN_DIPLOC(0x08, 0x08, "SW1:4")
	PORT_DIPUNKNOWN_DIPLOC(0x10, 0x10, "SW1:5")
	PORT_DIPUNKNOWN_DIPLOC(0x20, 0x20, "SW1:6")
	PORT_DIPUNKNOWN_DIPLOC(0x40, 0x40, "SW1:7")
	PORT_DIPUNKNOWN_DIPLOC(0x80, 0x80, "SW1:8")

	PORT_START("DSW2")
	PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW2:1")
	PORT_DIPUNKNOWN_DIPLOC(0x02, 0x02, "SW2:2")
	PORT_DIPUNKNOWN_DIPLOC(0x04, 0x04, "SW2:3")
	PORT_DIPUNKNOWN_DIPLOC(0x08, 0x08, "SW2:4")
	PORT_DIPUNKNOWN_DIPLOC(0x10, 0x10, "SW2:5")
	PORT_DIPUNKNOWN_DIPLOC(0x20, 0x20, "SW2:6")
	PORT_DIPUNKNOWN_DIPLOC(0x40, 0x40, "SW2:7")
	PORT_DIPUNKNOWN_DIPLOC(0x80, 0x80, "SW2:8")
INPUT_PORTS_END


void psrockman_state::psrockman(machine_config &config)
{
	z80_device &maincpu(Z80(config, "maincpu", 3.579545_MHz_XTAL));
	maincpu.set_addrmap(AS_PROGRAM, &psrockman_state::prg_map);
	maincpu.set_addrmap(AS_IO, &psrockman_state::io_map);

// TODO: flyer picture shows at least two LED displays

	SPEAKER(config, "mono").front_center();

	ym2203_device &ym(YM2203(config, "ym", 3.579545_MHz_XTAL));
	ym.port_a_read_callback().set_ioport("DSW1"); // guess
	ym.port_b_read_callback().set_ioport("DSW2"); // guess
	ym.irq_handler().set_inputline("maincpu", 0); // TODO: with this the game says 係員をお呼びください (Please call staff) over and over
	ym.add_route(ALL_OUTPUTS, "mono", 0.5);

	OKIM6295(config, "oki", XTAL::u(1056000), okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "mono", 0.5); // clock frequency & pin 7 not verified
}


ROM_START( psrockmn )
	ROM_REGION(0x10000, "maincpu", 0)
	ROM_LOAD( "prm0-1b-rom1.bin", 0x00000, 0x10000, CRC(9d840391) SHA1(84d90a5fb7901e18f74cb5acb6dd933023f2836f) )

	ROM_REGION(0x40000, "oki", 0)
	ROM_LOAD( "rockman-f188-rom2.bin", 0x00000, 0x20000, CRC(2ade4f1d) SHA1(e664fbe9d0c4013af3f765a8c52757e8e5ad2449) )
	ROM_LOAD( "rockman-9d48-rom3.bin", 0x20000, 0x20000, CRC(d47373ef) SHA1(a595b09ae75b7dae6ad2332e063fedc3b450e74e) )

	ROM_REGION(0x117, "plds", 0)
	ROM_LOAD( "rock-pal1.bin", 0x000, 0x117, CRC(50688629) SHA1(c7ced85561ff86c6c5a348765d8b3b6eef21554b) )
ROM_END

} // Anonymous namespace


GAME( 1992, psrockmn, 0, psrockman, psrockman, psrockman_state, empty_init, ROT0, "Capcom", "Panic Shot Rockman", MACHINE_IS_SKELETON_MECHANICAL )
// state_add_psw - overridable method for PSW // state registration //------------------------------------------------- void upd78k3_device::state_add_psw() { state_add(UPD78K3_PSW, "PSW", m_psw).mask(0xf0fd); state_add(STATE_GENFLAGS, "FLAGS", m_psw).mask(0xf0fd).formatstr("%12s").noshow(); state_add<u8>(UPD78K3_PSWL, "PSWL", [this]() { return m_psw & 0x00ff; }, [this](u8 data) { m_psw = (m_psw & 0xff00) | data; } ).mask(0xfd).noshow(); state_add<u8>(UPD78K3_PSWH, "PSWH", [this]() { return (m_psw & 0xff00) >> 8; }, [this](u8 data) { m_psw = (m_psw & 0x00ff) | u16(data) << 8; } ).mask(0xf0).noshow(); } //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void upd78k3_device::device_start() { // get address spaces and access caches space(AS_PROGRAM).cache(m_program_cache); space(AS_PROGRAM).specific(m_program_space); space(AS_DATA).cache(m_iram_cache); space(AS_IO).specific(m_sfr_space); set_icountptr(m_icount); // debug state state_add(UPD78K3_PC, "PC", m_pc); state_add(STATE_GENPC, "GENPC", m_pc).noshow(); state_add(STATE_GENPCBASE, "GENPCBASE", m_ppc).noshow(); state_add_psw(); state_add<u8>(UPD78K3_RBS, "RBS", [this]() { return (m_psw & 7000) >> 12; }, [this](u8 data) { m_psw = (m_psw & 0x8fff) | u16(data) << 12; } ).mask(7).noshow(); state_add(UPD78K3_SP, "SP", m_sp); for (int n = 0; n < 4; n++) state_add<u16>(UPD78K3_RP0 + n, string_format("RP%d", n).c_str(), [this, n]() { return m_iram[register_base() >> 1 | n]; }, [this, n](u16 data) { m_iram[register_base() >> 1 | n] = data; } ).formatstr("%9s"); for (int n = 0; n < 2; n++) state_add<u16>(UPD78K3_AX + n, std::array<const char *, 2>{{"AX", "BC"}}[n], [this, n]() { return m_iram[register_base() >> 1 | (m_psw & 0x0020) >> 4 | n]; }, [this, n](u16 data) { m_iram[register_base() >> 1 | (m_psw & 0x0020) >> 4 | n] = data; } ).noshow(); for (int n = 0; n < 4; n++) { state_add<u16>(UPD78K3_VP + n, std::array<const char *, 4>{{"VP", "UP", "DE", "HL"}}[n], [this, n]() { return m_iram[register_base() >> 1 | 0x04 | n]; }, [this, n](u16 data) { m_iram[register_base() >> 1 | 0x04 | n] = data; } ); state_add<u16>(UPD78K3_RP4 + n, string_format("RP%d", 4 + n).c_str(), [this, n]() { return m_iram[register_base() >> 1 | 0x04 | n]; }, [this, n](u16 data) { m_iram[register_base() >> 1 | 0x04 | n] = data; } ).noshow(); } for (int n = 0; n < 16; n++) state_add<u8>(UPD78K3_R0 + n, string_format("R%d", n).c_str(), [this, n]() { return iram_byte_r(register_base() | n); }, [this, n](u8 data) { iram_byte_w(register_base() | n, data); } ).noshow(); for (int n = 0; n < 4; n++) state_add<u8>(UPD78K3_X + n, std::array<const char *, 4>{{"X", "A", "C", "B"}}[n], [this, n]() { return iram_byte_r(register_base() | (m_psw & 0x0020) >> 3 | n); }, [this, n](u8 data) { iram_byte_w(register_base() | (m_psw & 0x0020) >> 3 | n, data); } ).noshow(); for (int n = 0; n < 8; n++) state_add<u8>(UPD78K3_VPL + n, std::array<const char *, 8>{{"VPL", "VPH", "UPL", "UPH", "E", "D", "L", "H"}}[n], [this, n]() { return iram_byte_r(register_base() | 0x08 | n); }, [this, n](u8 data) { iram_byte_w(register_base() | 0x08 | n, data); } ).noshow(); // save state save_item(NAME(m_pc)); save_item(NAME(m_ppc)); save_item(NAME(m_sp)); save_item(NAME(m_psw)); } //------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- void upd78k3_device::device_reset() { // PC will be initialized from vector following reset m_psw = 0x0000; } //------------------------------------------------- // execute_run - //------------------------------------------------- void upd78k3_device::execute_run() { m_pc = m_program_cache.read_word(0); m_ppc = m_pc; debugger_instruction_hook(m_pc); // TODO m_icount = 0; } //------------------------------------------------- // state_string_export - //------------------------------------------------- void upd78k3_device::state_string_export(const device_state_entry &entry, std::string &str) const { switch (entry.index()) { case STATE_GENFLAGS: str = string_format("RB%d:%c%c%c%c%c%c%c%c", (m_psw & 0x7000) >> 12, BIT(m_psw, 15) ? 'U' : '.', BIT(m_psw, 7) ? 'S' : '.', BIT(m_psw, 6) ? 'Z' : '.', BIT(m_psw, 5) ? 'R' : '.', BIT(m_psw, 4) ? 'A' : '.', BIT(m_psw, 3) ? 'I' : '.', BIT(m_psw, 2) ? 'V' : '.', BIT(m_psw, 0) ? 'C' : '.'); break; case UPD78K3_RP0: str = string_format("%04X %s", m_iram[register_base() >> 1], BIT(m_psw, 5) ? " " : "(AX)"); break; case UPD78K3_RP1: str = string_format("%04X %s", m_iram[register_base() >> 1 | 1], BIT(m_psw, 5) ? " " : "(BC)"); break; case UPD78K3_RP2: str = string_format("%04X %s", m_iram[register_base() >> 1 | 2], BIT(m_psw, 5) ? "(AX)" : " "); break; case UPD78K3_RP3: str = string_format("%04X %s", m_iram[register_base() >> 1 | 3], BIT(m_psw, 5) ? "(BC)" : " "); break; } } //************************************************************************** // 78K/III SUBSERIES DEVICES //************************************************************************** //------------------------------------------------- // upd78312_device - constructor //------------------------------------------------- upd78312_device::upd78312_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) : upd78312_device(mconfig, UPD78312, tag, owner, clock, address_map_constructor(FUNC(upd78312_device::mem_map), this)) { } upd78312_device::upd78312_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock, address_map_constructor map) : upd78k3_device(mconfig, type, tag, owner, clock, map, address_map_constructor(FUNC(upd78312_device::sfr_map), this)) { } //------------------------------------------------- // upd78310_device - constructor //------------------------------------------------- upd78310_device::upd78310_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) : upd78312_device(mconfig, UPD78310, tag, owner, clock, address_map_constructor()) { } //------------------------------------------------- // create_disassembler - //------------------------------------------------- std::unique_ptr<util::disasm_interface> upd78312_device::create_disassembler() { return std::make_unique<upd78312_disassembler>(); } //------------------------------------------------- // mem_map - type-specific internal memory map // (excluding IRAM and SFRs) //------------------------------------------------- void upd78312_device::mem_map(address_map &map) { map(0x0000, 0x1fff).rom().region(DEVICE_SELF, 0); // 8K mask ROM map(0xfe00, 0xfeff).rw(FUNC(upd78312_device::iram_byte_r), FUNC(upd78312_device::iram_byte_w)); } //------------------------------------------------- // sfr_map - type-specific SFR map //------------------------------------------------- void upd78312_device::sfr_map(address_map &map) { // TODO } //------------------------------------------------- // state_add_psw - overridable method for PSW // state registration //------------------------------------------------- void upd78312_device::state_add_psw() { state_add(UPD78K3_PSW, "PSW", m_psw).mask(0x72ff); state_add(STATE_GENFLAGS, "FLAGS", m_psw).mask(0x72ff).formatstr("%13s").noshow(); state_add<u8>(UPD78K3_PSWL, "PSWL", [this]() { return m_psw & 0x00ff; }, [this](u8 data) { m_psw = (m_psw & 0xff00) | data; } ).noshow(); state_add<u8>(UPD78K3_PSWH, "PSWH", [this]() { return (m_psw & 0xff00) >> 8; }, [this](u8 data) { m_psw = (m_psw & 0x00ff) | u16(data) << 8; } ).mask(0x72).noshow(); } //------------------------------------------------- // state_string_export - //------------------------------------------------- void upd78312_device::state_string_export(const device_state_entry &entry, std::string &str) const { switch (entry.index()) { case STATE_GENFLAGS: str = string_format("RB%d:%c%c%c%c%c%c%c%c%c", (m_psw & 0x7000) >> 12, BIT(m_psw, 9) ? 'I' : '.', BIT(m_psw, 7) ? 'S' : '.', BIT(m_psw, 6) ? 'Z' : '.', BIT(m_psw, 5) ? 'R' : '.', BIT(m_psw, 4) ? 'A' : '.', BIT(m_psw, 3) ? 'I' : '.', BIT(m_psw, 2) ? 'V' : '.', BIT(m_psw, 1) ? '-' : '+', BIT(m_psw, 0) ? 'C' : '.'); break; default: upd78k3_device::state_string_export(entry, str); break; } }