summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/coco/coco_fdc.h
blob: a8df8313a7c87b263e9920b8ac9ff7baa92a2a19 (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:
	DECLARE_WRITE_LINE_MEMBER(fdc_intrq_w) { m_intrq = state; update_lines(); }
	DECLARE_WRITE_LINE_MEMBER(fdc_drq_w) { m_drq = state; update_lines(); }

	DECLARE_FLOPPY_FORMATS(floppy_formats);

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

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

	// FDC overrides
	virtual void update_lines() = 0;
	virtual uint8_t* get_cart_base() override;

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

private:
	// registers
	uint8_t 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_FDC_V11,   coco_family_fdc_device_base)
DECLARE_DEVICE_TYPE(COCO3_HDB1,     coco_family_fdc_device_base)
DECLARE_DEVICE_TYPE(COCO2_HDB1,     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