OSDN Git Service

[VM][Qt][UI][EMU][WIP] Use EMU_TEMPLATE:: instead of EMU:: . Some VMs are not apply...
[csp-qt/common_source_project-fm7.git] / source / src / vm / x07 / io.h
1 /*
2         CANON X-07 Emulator 'eX-07'
3
4         Origin : J.Brigaud
5         Author : Takeda.Toshiya
6         Date   : 2007.12.26 -
7
8         [ i/o ]
9 */
10
11 #ifndef _IO_H_
12 #define _IO_H_
13
14 #include "../vm.h"
15 #include "../../emu.h"
16 #include "../device.h"
17
18 #define WRAM_OFS_UDC0   0x200
19 #define WRAM_OFS_UDC1   0x300
20 #define WRAM_OFS_KBUF   0x400
21 #define WRAM_OFS_SPGM   0x500
22 #define WRAM_OFS_RSVD   0x700
23 #define FONT_OFS_UDC0   0x400
24 #define FONT_OFS_UDC1   0x700
25 #define CMT_BUF_SIZE    0x40000
26
27 class BEEP;
28 class FIFO;
29 class FILEIO;
30
31 namespace X07 {
32
33 class IO : public DEVICE
34 {
35 private:
36         BEEP* d_beep;
37         DEVICE *d_cpu, *d_mem;
38         uint8_t* ram;
39         
40         // registers
41         uint8_t rregs[8], wregs[8];
42         
43         // t6834
44         void update_intr();
45         void send_to_sub();
46         void recv_from_sub();
47         void ack_from_sub();
48         void process_sub();
49         dll_cur_time_t cur_time;
50         int register_id_1sec;
51         FIFO* cmd_buf;
52         FIFO* rsp_buf;
53         uint8_t sub_int;
54         uint8_t wram[0x800];
55         uint8_t alarm[8];
56         
57         // keyboard
58         FIFO* key_buf;
59         bool ctrl, shift, kana, graph, brk;
60         uint8_t stick, strig, strig1;
61         
62         // data recorder
63         void send_to_cmt();
64         void recv_from_cmt();
65         FILEIO* cmt_fio;
66         bool cmt_play, cmt_rec, cmt_mode;
67         _TCHAR rec_file_path[_MAX_PATH];
68         int cmt_len, cmt_ptr;
69         uint8_t cmt_buf[CMT_BUF_SIZE];
70         
71         // x-720
72         bool vblank;
73         uint8_t font_code;
74         
75         // video
76         void draw_font(int x, int y, uint8_t code);
77         void draw_udk();
78         void draw_line(int sx, int sy, int ex, int ey);
79         void draw_circle(int x, int y, int r);
80         void line_clear(int y);
81         void scroll();
82         uint8_t font[256 * 8], udc[256 * 8];
83         uint8_t lcd[32][120];
84         bool locate_on, cursor_on, udk_on;
85         int locate_x, locate_y;
86         int cursor_x, cursor_y, cursor_blink;
87         int scroll_min, scroll_max;
88         
89         // beep
90         int register_id_beep;
91         
92 public:
93         IO(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu)
94         {
95                 set_device_name(_T("I/O Bus"));
96         }
97         ~IO() {}
98         
99         // common functions
100         void initialize();
101         void release();
102         void reset();
103         void event_frame();
104         void event_vline(int v, int clock);
105         void event_callback(int event_id, int err);
106         void __FASTCALL write_io8(uint32_t addr, uint32_t data);
107         uint32_t __FASTCALL read_io8(uint32_t addr);
108         bool process_state(FILEIO* state_fio, bool loading);
109         
110         // unique functions
111         void play_tape(const _TCHAR* file_path);
112         void rec_tape(const _TCHAR* file_path);
113         void close_tape();
114         bool is_tape_inserted()
115         {
116                 return (cmt_play || cmt_rec);
117         }
118         void set_context_beep(BEEP* device)
119         {
120                 d_beep = device;
121         }
122         void set_context_cpu(DEVICE* device)
123         {
124                 d_cpu = device;
125         }
126         void set_context_mem(DEVICE* device, uint8_t* ptr)
127         {
128                 d_mem = device;
129                 ram = ptr;
130         }
131         void draw_screen();
132         void key_down(int code);
133         void key_up(int code);
134         bool get_caps_locked()
135         {
136 //              return caps;
137                 return true;
138         }
139         bool get_kana_locked()
140         {
141                 return kana;
142         }
143 };
144
145 }
146 #endif