summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/coco/coco_fdc.h
blob: 4097b4b2e081c1ca511473ec5bbbb0678e3d3710 (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
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
/*********************************************************************

    coco_fdc.h

    CoCo/Dragon Floppy Disk Controller base classes

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

#ifndef MAME_BUS_COCO_COCO_FDC_H
#define MAME_BUS_COCO_COCO_FDC_H

#include "cococart.h"

#include "imagedev/floppy.h"


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

// ======================> coco_family_fdc_device_base

class coco_family_fdc_device_base :
		public device_t,
		public device_cococart_interface
{
public:
	void fdc_intrq_w(int state) { m_intrq = state; update_lines(); }
	void fdc_drq_w(int state) { m_drq = state; update_lines(); }

	static void floppy_formats(format_registration &fr);

protected:
	// construction/destruction
	coco_family_fdc_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
		: device_t(mconfig, type, tag, owner, clock)
		, device_cococart_interface(mconfig, *this)
	{
	};

	// device-level overrides
	virtual void device_start() override ATTR_COLD;
	virtual void device_reset() override ATTR_COLD;

	// FDC overrides
	virtual void update_lines() = 0;
	virtual u8 *get_cart_base() override;
	virtual memory_region *get_cart_memregion() override;

	// accessors
	u8 dskreg() const { return m_dskreg; }
	bool intrq() const { return m_intrq; }
	bool drq() const { return m_drq; }
	void set_dskreg(u8 data) { m_dskreg = data; }

private:
	// registers
	u8 m_dskreg;
	bool m_intrq;
	bool m_drq;
};

// device type definitions - CoCo FDC
DECLARE_DEVICE_TYPE(COCO_FDC,   coco_family_fdc_device_base)
DECLARE_DEVICE_TYPE(COCO_SCII,  coco_family_fdc_device_base)
DECLARE_DEVICE_TYPE(CP450_FDC,  coco_family_fdc_device_base)
DECLARE_DEVICE_TYPE(CD6809_FDC, coco_family_fdc_device_base)

#endif // MAME_BUS_COCO_COCO_FDC_H