summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/includes/tvc.h
blob: f32bbace7f8e8c156fcc3a7afd7ac05c8617d98d (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
/*****************************************************************************
 *
 *   includes/tvc.h
 *
 ****************************************************************************/

#pragma once

#ifndef TVC_H_
#define TVC_H_

#include "cpu/z80/z80.h"
#include "video/mc6845.h"
#include "machine/ram.h"
#include "machine/ctronics.h"
#include "imagedev/cartslot.h"
#include "imagedev/cassette.h"
#include "imagedev/snapquik.h"
#include "formats/tvc_cas.h"

#include "machine/tvcexp.h"
#include "machine/tvc_hbf.h"

#define		TVC_RAM_BANK	1
#define		TVC_ROM_BANK	2

#define CENTRONICS_TAG	"centronics"

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

// ======================> tvc_sound_interface

struct tvc_sound_interface
{
	 devcb_write_line		m_sndint_cb;
};

// ======================> tvc_sound_device

class tvc_sound_device : public device_t,
						 public device_sound_interface,
						 public tvc_sound_interface
{
public:
	// construction/destruction
	tvc_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);

	DECLARE_WRITE8_MEMBER(write);
	void reset_divider();

protected:
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();
	virtual void device_config_complete();
	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);

private:
	static const device_timer_id TIMER_SNDINT = 0;

	sound_stream *	m_stream;
	int				m_freq;
	int				m_enabled;
	int				m_volume;
	int 			m_incr;
	int 			m_signal;
	UINT8			m_ports[3];
	emu_timer *		m_sndint_timer;
	devcb_resolved_write_line	m_sndint_func;
};


// ======================> tvc_state

class tvc_state : public driver_device
{
public:
	tvc_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag),
		  m_maincpu(*this, "maincpu"),
		  m_ram(*this, RAM_TAG),
		  m_sound(*this, "custom"),
		  m_cassette(*this, CASSETTE_TAG),
		  m_centronics(*this, CENTRONICS_TAG)
		{ }

	required_device<cpu_device> m_maincpu;
	required_device<ram_device> m_ram;
	required_device<tvc_sound_device> m_sound;
	required_device<cassette_image_device> m_cassette;
	required_device<centronics_device> m_centronics;

	void machine_start();
	void machine_reset();

	void tvc_set_mem_page(UINT8 data);
	DECLARE_WRITE8_MEMBER(tvc_bank_w);
	DECLARE_WRITE8_MEMBER(tvc_vram_bank_w);
	DECLARE_WRITE8_MEMBER(tvc_palette_w);
	DECLARE_WRITE8_MEMBER(tvc_keyboard_w);
	DECLARE_READ8_MEMBER(tvc_keyboard_r);
	DECLARE_READ8_MEMBER(tvc_int_state_r);
	DECLARE_WRITE8_MEMBER(tvc_flipflop_w);
	DECLARE_WRITE8_MEMBER(tvc_border_color_w);
	DECLARE_WRITE8_MEMBER(tvc_sound_w);
	DECLARE_WRITE8_MEMBER(tvc_cassette_w);
	DECLARE_READ8_MEMBER(tvc_5b_r);
	DECLARE_WRITE_LINE_MEMBER(tvc_int_ff_set);
	DECLARE_WRITE_LINE_MEMBER(tvc_centronics_ack);

	// expansions
	DECLARE_WRITE8_MEMBER(tvc_expansion_w);
	DECLARE_READ8_MEMBER(tvc_expansion_r);
	DECLARE_READ8_MEMBER(tvc_exp_id_r);
	DECLARE_WRITE8_MEMBER(tvc_expint_ack_w);

	tvcexp_slot_device * m_expansions[4];
	UINT8		m_video_mode;
	UINT8		m_keyline;
	UINT8		m_active_slot;
	UINT8		m_int_flipflop;
	UINT8		m_col[4];
	UINT8		m_bank_type[4];
	UINT8		m_bank;
	UINT8		m_vram_bank;
	UINT8		m_cassette_ff;
	UINT8		m_centronics_ff;
};


// device type definition
extern const device_type TVC_SOUND;

#endif /* TVC_H_ */