summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/kc_d004.h
blob: 52d38b704030712c224bc3304f4b7ae52be5b6e4 (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
#pragma once

#ifndef __KC_D004_H__
#define __KC_D004_H__

#include "emu.h"
#include "machine/kcexp.h"
#include "machine/z80ctc.h"
#include "cpu/z80/z80.h"
#include "machine/upd765.h"
#include "machine/idectrl.h"
#include "formats/basicdsk.h"
#include "imagedev/harddriv.h"


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

// ======================> kc_d004_device

class kc_d004_device :
		public device_t,
		public device_kcexp_interface
{
public:
	// construction/destruction
	kc_d004_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	kc_d004_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);

	// optional information overrides
	virtual machine_config_constructor device_mconfig_additions() const;
	virtual const rom_entry *device_rom_region() const;

	DECLARE_FLOPPY_FORMATS( floppy_formats );

protected:
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();
	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);

	// kcexp_interface overrides
	virtual UINT8 module_id_r() { return 0xa7; }
	virtual void control_w(UINT8 data);
	virtual void read(offs_t offset, UINT8 &data);
	virtual void io_read(offs_t offset, UINT8 &data);
	virtual void io_write(offs_t offset, UINT8 data);

public:
	DECLARE_READ8_MEMBER(hw_input_gate_r);
	DECLARE_WRITE8_MEMBER(fdd_select_w);
	DECLARE_WRITE8_MEMBER(hw_terminal_count_w);

	void fdc_irq(bool state);
	void fdc_drq(bool state);

private:
	static const device_timer_id TIMER_RESET = 0;
	static const device_timer_id TIMER_TC_CLEAR = 1;

	required_device<cpu_device> m_cpu;
	required_device<upd765a_device> m_fdc;
	required_shared_ptr<UINT8>  m_koppel_ram;

	// internal state
	emu_timer *         m_reset_timer;
	emu_timer *         m_tc_clear_timer;

	UINT8 *             m_rom;
	UINT8               m_hw_input_gate;
	UINT16              m_rom_base;
	UINT8               m_enabled;
	UINT8               m_connected;
	//UINT8               m_active_fdd;

	floppy_image_device *m_floppy;
};


// ======================> kc_d004_gide_device

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

	// optional information overrides
	virtual machine_config_constructor device_mconfig_additions() const;
	virtual const rom_entry *device_rom_region() const;

protected:
	// device-level overrides
	virtual void device_reset();

public:
	DECLARE_READ8_MEMBER(gide_r);
	DECLARE_WRITE8_MEMBER(gide_w);

private:
	required_device<ide_controller_device> m_ide;

	UINT16              m_ide_data;
	int                 m_lh;
};

// device type definition
extern const device_type KC_D004;
extern const device_type KC_D004_GIDE;

#endif  /* __KC_D004_H__ */