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
|
// license:BSD-3-Clause
// copyright-holders:F. Ulivi
/*********************************************************************
hp_taco.h
HP TApe COntroller (5006-3012)
*********************************************************************/
#ifndef MAME_MACHINE_HP_TACO_H
#define MAME_MACHINE_HP_TACO_H
#pragma once
#include "formats/hti_tape.h"
#include "machine/hp_dc100_tape.h"
class hp_taco_device : public device_t
{
public:
// construction/destruction
hp_taco_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// configuration helpers
auto irq() { return m_irq_handler.bind(); }
auto flg() { return m_flg_handler.bind(); }
auto sts() { return m_sts_handler.bind(); }
// Set unit name
void set_name(const std::string& name);
// Register read/write
void reg_w(offs_t offset, uint16_t data);
uint16_t reg_r(offs_t offset);
// Flag & status read
DECLARE_READ_LINE_MEMBER(flg_r);
DECLARE_READ_LINE_MEMBER(sts_r);
DECLARE_WRITE_LINE_MEMBER(cart_out_w);
DECLARE_WRITE_LINE_MEMBER(hole_w);
DECLARE_WRITE_LINE_MEMBER(tacho_tick_w);
DECLARE_WRITE_LINE_MEMBER(motion_w);
DECLARE_WRITE_LINE_MEMBER(rd_bit_w);
DECLARE_READ_LINE_MEMBER(wr_bit_r);
protected:
hp_taco_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device-level overrides
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
virtual void device_reset() override;
TIMER_CALLBACK_MEMBER(gap_timer_tick);
TIMER_CALLBACK_MEMBER(evd_timer_tick);
TIMER_CALLBACK_MEMBER(error_timer_tick);
private:
required_device<hp_dc100_tape_device> m_tape;
devcb_write_line m_irq_handler;
devcb_write_line m_flg_handler;
devcb_write_line m_sts_handler;
// Registers
uint16_t m_data_reg;
uint16_t m_cmd_reg;
uint16_t m_status_reg;
uint16_t m_tach_reg;
uint16_t m_checksum_reg;
uint16_t m_threshold_reg;
// State
bool m_irq;
bool m_flg;
bool m_sts;
bool m_error;
bool m_gap_in_read;
// Command FSM state
typedef enum {
CMD_IDLE,
CMD_PH0,
CMD_PH1,
CMD_PH2,
CMD_STOPPING
} cmd_state_t;
cmd_state_t m_cmd_state;
// Timers
emu_timer *m_gap_timer;
emu_timer *m_evd_timer;
emu_timer *m_error_timer;
// Reading & writing
uint16_t m_working_reg;
unsigned m_bit_idx;
void clear_state();
void irq_w(bool state);
void sts_w(bool state);
void set_error(bool error , bool gap_in_read);
hti_format_t::tape_pos_t min_gap_size() const;
void set_gap_timer();
void set_evd_timer();
void set_tape_present(bool present);
void send_go();
void send_stop();
void end_cmd();
void irq_and_end();
bool is_at_slow_speed() const;
void start_rd();
void start_wr();
bool adv_bit_idx();
void update_checksum(uint16_t data);
void cmd_fsm();
static uint8_t get_cmd(uint16_t cmd_reg);
static bool is_cmd_rd_wr(uint16_t cmd_reg);
static bool is_cmd_rd(uint16_t cmd_reg);
static bool is_cmd_wr(uint16_t cmd_reg);
static bool is_double_hole_cmd(uint16_t cmd_reg);
void start_cmd_exec(uint16_t new_cmd_reg);
};
// device type definition
DECLARE_DEVICE_TYPE(HP_TACO, hp_taco_device)
#endif // MAME_MACHINE_HP_TACO_H
|