OSDN Git Service

11b4ff76460559a95f0e4be2d200f4856e058e6b
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc2001 / io.h
1 /*
2         NEC PC-2001 Emulator 'ePC-2001'
3
4         Origin : PockEmul
5         Author : Takeda.Toshiya
6         Date   : 2016.03.18-
7
8         [ i/o ]
9 */
10
11 #ifndef _PC2001_IO_H_
12 #define _PC2001_IO_H_
13
14 #include "../vm.h"
15 #include "../../emu.h"
16 #include "../device.h"
17
18 #define SIG_IO_DREC_IN  0
19 #define SIG_IO_RTC_IN   1
20
21 class UPD16434;
22
23 class PC2001_IO : public DEVICE
24 {
25 private:
26         UPD16434 *d_lcd[4];
27         DEVICE *d_drec;
28         DEVICE *d_rtc;
29         DEVICE *d_cpu;
30         
31         uint8_t port_a, port_b, port_s;
32         bool drec_in, rtc_in;
33         
34         const uint8_t *key_stat;
35         uint16_t key_strobe;
36         
37         uint8_t get_key();
38         bool key_hit(int code);
39         
40 public:
41         PC2001_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
42         {
43                 set_device_name(_T("I/O Bus"));
44         }
45         ~PC2001_IO() {}
46         
47         // common functions
48         void initialize();
49         void reset();
50         void write_io8(uint32_t addr, uint32_t data);
51         uint32_t read_io8(uint32_t addr);
52         void write_io16(uint32_t addr, uint32_t data);
53         void write_signal(int id, uint32_t data, uint32_t mask);
54         void event_callback(int event_id, int err);
55         bool process_state(FILEIO* state_fio, bool loading);
56         
57         // unique functions
58         void set_context_lcd(int index, UPD16434* device)
59         {
60                 d_lcd[index] = device;
61         }
62         void set_context_drec(DEVICE* device)
63         {
64                 d_drec = device;
65         }
66         void set_context_rtc(DEVICE* device)
67         {
68                 d_rtc = device;
69         }
70         void set_context_cpu(DEVICE* device)
71         {
72                 d_cpu = device;
73         }
74 };
75
76 #endif