OSDN Git Service

a36c7a914ebed4ab379b454008363437c72e057e
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc100 / ioctrl.h
1 /*
2         NEC PC-100 Emulator 'ePC-100'
3
4         Author : Takeda.Toshiya
5         Date   : 2008.07.14 -
6
7         [ i/o controller ]
8 */
9
10 #ifndef _IOCTRL_H_
11 #define _IOCTRL_H_
12
13 #include "../vm.h"
14 #include "../../emu.h"
15 #include "../device.h"
16
17 #define SIG_IOCTRL_RESET        0
18
19 class FIFO;
20
21 class IOCTRL : public DEVICE
22 {
23 private:
24         DEVICE *d_pic, *d_fdc, *d_beep, *d_pcm;
25         const uint8_t* key_stat;
26         const int32_t* mouse_stat;
27         
28         bool caps, kana;
29         FIFO* key_buf;
30         uint32_t key_val, key_mouse;
31         int key_prev;
32         bool key_res, key_done;
33         int register_id;
34         uint8_t ts;
35         
36         void update_key();
37         
38 public:
39         IOCTRL(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
40         {
41                 set_device_name(_T("I/O Controller"));
42         }
43         ~IOCTRL() {}
44         
45         // common functions
46         void initialize();
47         void release();
48         void reset();
49         void write_io8(uint32_t addr, uint32_t data);
50         uint32_t read_io8(uint32_t addr);
51         void event_callback(int event_id, int err);
52         void write_signal(int id, uint32_t data, uint32_t mask);
53         void decl_state();
54         void save_state(FILEIO* state_fio);
55         bool load_state(FILEIO* state_fio);
56         
57         // unique functions
58         void set_context_pic(DEVICE* device)
59         {
60                 d_pic = device;
61         }
62         void set_context_fdc(DEVICE* device)
63         {
64                 d_fdc = device;
65         }
66         void set_context_beep(DEVICE* device)
67         {
68                 d_beep = device;
69         }
70         void set_context_pcm(DEVICE* device)
71         {
72                 d_pcm = device;
73         }
74         void key_down(int code);
75         void key_up(int code);
76         bool get_caps_locked()
77         {
78                 return caps;
79         }
80         bool get_kana_locked()
81         {
82                 return kana;
83         }
84 };
85
86 #endif
87