summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/ad_sound.h
blob: c508386c2210a302ad353b040ac58e17d1d1cf5f (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
// license:BSD-3-Clause
// copyright-holders:Acho A. Tang, Nicola Salmoria

//****************************************************************************
//    Functions to emulate the Alpha Denshi "59MC07" audio board
//****************************************************************************

#ifndef MAME_AUDIO_AD_SOUND_H
#define MAME_AUDIO_AD_SOUND_H

#pragma once

#include "cpu/i8085/i8085.h"
#include "machine/gen_latch.h"
#include "machine/i8155.h"
#include "sound/dac.h"
#include "sound/msm5232.h"
#include "sound/samples.h"


//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DECLARE_DEVICE_TYPE(AD_59MC07, ad_59mc07_device)


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> ad_59mc07_device

class ad_59mc07_device : public device_t
{
public:
	// construction/destruction
	ad_59mc07_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);

	void sound_command_w(uint8_t data) { m_soundlatch->write(data); }

protected:
	// device level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	required_device<i8085a_cpu_device> m_audiocpu;
	required_device<i8155_device> m_audio8155;
	required_device<samples_device> m_samples;
	required_device<msm5232_device> m_msm;
	required_device<dac_byte_interface> m_dac_1;
	required_device<dac_byte_interface> m_dac_2;
	required_device<generic_latch_8_device> m_soundlatch;
	required_ioport m_frq_adjuster;

	int       m_sound_prom_address;
	uint8_t   m_dac_latch;
	uint8_t   m_8155_port_b;
	uint8_t   m_8155_port_a;
	uint8_t   m_8155_port_c;
	uint8_t   m_ay_port_a;
	uint8_t   m_ay_port_b;
	uint8_t   m_cymbal_ctrl;
	float     m_cymvol;
	float     m_hihatvol;
	emu_timer *m_adjuster_timer;

	void sound_map(address_map &map);
	void sound_portmap(address_map &map);

	void c0f8_w(offs_t offset, uint8_t data);
	void cymbal_ctrl_w(uint8_t data);
	void dac_latch_w(uint8_t data);
	void i8155_porta_w(uint8_t data);
	void i8155_portb_w(uint8_t data);
	void i8155_portc_w(uint8_t data);
	void ay8910_porta_w(uint8_t data);
	void ay8910_portb_w(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(i8155_timer_pulse);
	TIMER_CALLBACK_MEMBER(frq_adjuster_callback);
	void update_dac();
	DECLARE_WRITE_LINE_MEMBER(msm5232_gate);
};


//****************************************************************************
//    Functions to emulate the Alpha Denshi "60MC01" audio board
//****************************************************************************

//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DECLARE_DEVICE_TYPE(AD_60MC01, ad_60mc01_device)


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> ad_60mc01_device

class ad_60mc01_device : public device_t
{
public:
	// construction/destruction
	ad_60mc01_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);

	static constexpr feature_type imperfect_features() { return feature::SOUND; } // TODO: fix interrupts, missing music?

	void sound_command_w(uint8_t data) { m_soundlatch->write(data); }

protected:
	// device level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	required_device<cpu_device> m_audiocpu;
	required_device<generic_latch_8_device> m_soundlatch;

	void sound_map(address_map &map);
	void sound_portmap(address_map &map);

	INTERRUPT_GEN_MEMBER(sound_irq) { m_audiocpu->set_input_line(0, HOLD_LINE); }
};

#endif // MAME_AUDIO_AD_SOUND_H