OSDN Git Service

[VM][STATE] Apply new framework to some VMs.
[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         bool process_state(FILEIO* state_fio, bool loading);
54         
55         // unique functions
56         void set_context_pic(DEVICE* device)
57         {
58                 d_pic = device;
59         }
60         void set_context_fdc(DEVICE* device)
61         {
62                 d_fdc = device;
63         }
64         void set_context_beep(DEVICE* device)
65         {
66                 d_beep = device;
67         }
68         void set_context_pcm(DEVICE* device)
69         {
70                 d_pcm = device;
71         }
72         void key_down(int code);
73         void key_up(int code);
74         bool get_caps_locked()
75         {
76                 return caps;
77         }
78         bool get_kana_locked()
79         {
80                 return kana;
81         }
82 };
83
84 #endif
85