OSDN Git Service

bb33046255db022a081a78dd2422c47b60fcc36f
[csp-qt/common_source_project-fm7.git] / source / src / vm / tk80bs / keyboard.h
1 /*
2         NEC TK-80BS (COMPO BS/80) Emulator 'eTK-80BS'
3         NEC TK-80 Emulator 'eTK-80'
4         NEC TK-85 Emulator 'eTK-85'
5
6         Author : Takeda.Toshiya
7         Date   : 2008.08.26 -
8
9         [ keyboard ]
10 */
11
12 #ifndef _KEYBOARD_H_
13 #define _KEYBOARD_H_
14
15 #include "../vm.h"
16 #include "../../emu.h"
17 #include "../device.h"
18
19 #define SIG_KEYBOARD_COLUMN     0
20
21 class KEYBOARD : public DEVICE
22 {
23 private:
24 #if defined(_TK80BS)
25         DEVICE *d_pio_b, *d_cpu;
26         
27         uint8_t prev_type, prev_brk, prev_kana;
28         bool kana_lock;
29         uint32_t kb_type;
30 #endif
31         
32         DEVICE *d_pio_t;
33         const uint8_t* key_stat;
34         
35         uint32_t column;
36         
37         void update_tk80();
38         
39 public:
40         KEYBOARD(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
41         {
42                 set_device_name(_T("Keyboard"));
43         }
44         ~KEYBOARD() {}
45         
46         // common functions
47         void initialize();
48         void reset();
49         void write_signal(int id, uint32_t data, uint32_t mask);
50         uint32_t get_intr_ack();
51 #if defined(_TK80BS)
52         uint32_t read_signal(int ch)
53         {
54                 return kb_type & 3;
55         }
56 #endif
57         void decl_state();
58         void save_state(FILEIO* state_fio);
59         bool load_state(FILEIO* state_fio);
60         
61         // unique functions
62 #if defined(_TK80BS)
63         void set_context_pio_b(DEVICE* device)
64         {
65                 d_pio_b = device;
66         }
67         void set_context_cpu(DEVICE* device)
68         {
69                 d_cpu = device;
70         }
71 #endif
72         void set_context_pio_t(DEVICE* device)
73         {
74                 d_pio_t = device;
75         }
76         void key_down(int code);
77         void key_up(int code);
78         bool get_caps_locked()
79         {
80 //              return caps_lock;
81                 return true;
82         }
83         bool get_kana_locked()
84         {
85 #if defined(_TK80BS)
86                 return kana_lock;
87 #else
88                 return false;
89 #endif
90         }
91 };
92
93 #endif
94