summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/pd4990a.h
blob: 2d767928e021cedb06048c75cb8487cb7c5a2505 (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
/***************************************************************************

    NEC uPD4990A

    Serial I/O Calendar & Clock IC

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

#ifndef __PD4990A_OLD_H__
#define __PD4990A_OLD_H__



/***************************************************************************
    MACROS / CONSTANTS
***************************************************************************/

class upd4990a_old_device : public device_t
{
public:
	upd4990a_old_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	~upd4990a_old_device() {}
	
	/* this should be refactored, once RTCs get unified */
	void addretrace();

	DECLARE_READ8_MEMBER( testbit_r );
	DECLARE_READ8_MEMBER( databit_r );
	DECLARE_WRITE16_MEMBER( control_16_w );
	
protected:
	// device-level overrides
	virtual void device_config_complete();
	virtual void device_start();
	virtual void device_reset();

private:
	// internal state
	int m_seconds;    /* seconds BCD */
	int m_minutes;    /* minutes BCD */
	int m_hours;      /* hours   BCD */
	int m_days;       /* days    BCD */
	int m_month;      /* month   Hexadecimal form */
	int m_year;       /* year    BCD */
	int m_weekday;    /* weekday BCD */

	UINT32 m_shiftlo;
	UINT32 m_shifthi;

	int m_retraces;   /* Assumes 60 retraces a second */
	int m_testwaits;
	int m_maxwaits;   /* Switch test every frame*/
	int m_testbit;    /* Pulses a bit in order to simulate test output */

	int m_outputbit;
	int m_bitno;
	INT8 m_reading;
	INT8 m_writing;

	int m_clock_line;
	int m_command_line;   //??
	
	void increment_month();
	void increment_day();
	void readbit();
	void resetbitstream();
	void writebit( UINT8 bit );
	void nextbit();
	UINT8 getcommand();
	void update_date();
	void process_command();
	void serial_control( UINT8 data );
};

extern ATTR_DEPRECATED const device_type UPD4990A_OLD;


#define MCFG_UPD4990A_OLD_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, UPD4990A_OLD, 0)

#endif  /*__PD4990A_H__*/