blob: b5d62212dfa9e8bac072e1541aa52e1df5f5a925 (
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
|
// license:BSD-3-Clause
// copyright-holders:AJR
/***************************************************************************
Kawasaki Steel (Kawatetsu) KP64 Timer/Counter Unit
***************************************************************************/
#ifndef MAME_CPU_Z80_KP64_H
#define MAME_CPU_Z80_KP64_H
#pragma once
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
class kp64_device : public device_t
{
public:
// device type constructor
kp64_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);
// callback configuration
auto out_callback() { return m_out_callback.bind(); }
// I/O register interface
u8 counter_r();
void counter_w(u8 data);
u8 status_r();
void control_w(u8 data);
// input line interface
DECLARE_WRITE_LINE_MEMBER(xclk_w);
DECLARE_WRITE_LINE_MEMBER(gate_w);
protected:
// device-level overrides
virtual void device_resolve_objects() override;
virtual void device_start() override;
virtual void device_reset() override;
private:
// timer callbacks
TIMER_CALLBACK_MEMBER(count_underflow);
TIMER_CALLBACK_MEMBER(pulse_off);
// internal helpers
void set_out(bool state);
u16 count_value() const noexcept;
void reload_count();
void finish_count();
// callback objects
devcb_write_line m_out_callback;
// internal timer
emu_timer *m_count_timer;
emu_timer *m_pulse_timer;
// input state
bool m_xclk;
bool m_gate;
// internal state
u16 m_count;
u16 m_cr;
u16 m_or;
u8 m_tmp;
u8 m_status;
bool m_read_msb;
bool m_write_msb;
bool m_reload;
bool m_started;
};
// device type declaration
DECLARE_DEVICE_TYPE(KP64, kp64_device)
#endif // MAME_CPU_Z80_KP64_H
|