OSDN Git Service

[General][CMAKE] Integrate all devices to upstream 2015-12-17.
[csp-qt/common_source_project-fm7.git] / source / src / vm / x1 / x1.h
1 /*
2         SHARP X1 Emulator 'eX1'
3         SHARP X1twin Emulator 'eX1twin'
4         SHARP X1turbo Emulator 'eX1turbo'
5
6         Author : Takeda.Toshiya
7         Date   : 2009.03.11-
8
9         [ virtual machine ]
10 */
11
12 #ifndef _X1_H_
13 #define _X1_H_
14
15 #if defined(_X1TURBOZ)
16 #define DEVICE_NAME             "SHARP X1turboZ"
17 #define CONFIG_NAME             "x1turboz"
18 #elif defined(_X1TURBO)
19 #define DEVICE_NAME             "SHARP X1turbo"
20 #define CONFIG_NAME             "x1turbo"
21 #elif defined(_X1TWIN)
22 #define DEVICE_NAME             "SHARP X1twin"
23 #define CONFIG_NAME             "x1twin"
24 #else
25 #define DEVICE_NAME             "SHARP X1"
26 #define CONFIG_NAME             "x1"
27 #endif
28
29 #if defined(_X1TURBO) || defined(_X1TURBOZ)
30 #define _X1TURBO_FEATURE
31 #endif
32
33 // device informations for virtual machine (x1)
34 //#ifdef _X1TURBO_FEATURE
35 //24KHz
36 //#define FRAMES_PER_SEC        55.49
37 //#define LINES_PER_FRAME       448
38 //#define CHARS_PER_LINE        56
39 //#define HD46505_HORIZ_FREQ    24860
40 //#else
41 // 15KHz
42 #define FRAMES_PER_SEC          61.94
43 #define LINES_PER_FRAME         258
44 #define CHARS_PER_LINE          56
45 #define HD46505_HORIZ_FREQ      15980
46 //#endif
47 #define CPU_CLOCKS              4000000
48 #define SCREEN_WIDTH            640
49 #define SCREEN_HEIGHT           400
50 #define MAX_DRIVE               4
51 #define IO_ADDR_MAX             0x10000
52 #define HAS_AY_3_8910
53 #define Z80_IO_WAIT
54 #ifdef _X1TURBO_FEATURE
55 #define SINGLE_MODE_DMA
56 #endif
57 #define DATAREC_FF_REW_SPEED    16
58 #define SUPPORT_VARIABLE_TIMING
59
60 #ifdef _X1TURBO_FEATURE
61 #define IPL_ROM_FILE_SIZE       0x8000
62 #define IPL_ROM_FILE_NAME       _T("IPLROM.X1T")
63 #define SUB_ROM_FILE_NAME       _T("SUBROM.X1T")
64 #define KBD_ROM_FILE_NAME       _T("KBDROM.X1T")
65 #else
66 #define IPL_ROM_FILE_SIZE       0x1000
67 #define IPL_ROM_FILE_NAME       _T("IPLROM.X1")
68 #define SUB_ROM_FILE_NAME       _T("SUBROM.X1")
69 #define KBD_ROM_FILE_NAME       _T("KBDROM.X1")
70 #endif
71 #define CRC32_MSM80C49_262      0x43EE7D6F      // X1turbo with CMT
72 #define CRC32_MSM80C49_277      0x75904EFB      // X1turbo (not supported yet)
73
74 #ifdef _X1TWIN
75 // device informations for virtual machine (pce)
76 #define PCE_FRAMES_PER_SEC      60
77 #define PCE_LINES_PER_FRAME     262
78 #define PCE_CPU_CLOCKS          7159090
79 #endif
80
81 // device informations for win32
82 #define USE_SPECIAL_RESET
83 #ifdef _X1TURBO_FEATURE
84 #define USE_DEVICE_TYPE         2
85 // Keyboard mode B
86 #define DEVICE_TYPE_DEFAULT     1
87 #define USE_DRIVE_TYPE          2
88 #endif
89 #define USE_FD1
90 #define USE_FD2
91 #define FD_BASE_NUMBER          0
92 #define USE_TAPE
93 #define USE_TAPE_BUTTON
94 #ifdef _X1TWIN
95 #define USE_CART1
96 #endif
97 #define NOTIFY_KEY_DOWN
98 #define USE_SHIFT_NUMPAD_KEY
99 #define USE_ALT_F10_KEY
100 #define USE_AUTO_KEY            8
101 #define USE_AUTO_KEY_RELEASE    10
102 #define USE_MONITOR_TYPE        2
103 #define USE_CRT_FILTER
104 #define USE_SCANLINE
105 #define USE_ACCESS_LAMP
106 #define USE_SOUND_DEVICE_TYPE           3
107 // CZ-8BS1 x1
108 #define SOUND_DEVICE_TYPE_DEFAULT       1
109 #define USE_DEBUGGER
110 #define USE_STATE
111
112 #include "../../common.h"
113 #include "../../fileio.h"
114
115 class EMU;
116 class DEVICE;
117 class EVENT;
118
119 class DATAREC;
120 class HD46505;
121 class I8255;
122 class IO;
123 class MB8877;
124 class YM2151;
125 class YM2203;
126 class Z80;
127 class Z80CTC;
128 class Z80SIO;
129 #ifdef _X1TURBO_FEATURE
130 class Z80DMA;
131 #endif
132
133 class DISPLAY;
134 class EMM;
135 class FLOPPY;
136 class IOBUS;
137 class JOYSTICK;
138 class MEMORY;
139 class MOUSE;
140 class PRINTER;
141 class PSUB;
142
143 class MCS48;
144 class UPD1990A;
145 class SUB;
146 class KEYBOARD;
147
148 #ifdef _X1TWIN
149 class HUC6280;
150 class PCE;
151 #endif
152
153 class VM
154 {
155 protected:
156         EMU* emu;
157         
158         // devices for x1
159         EVENT* event;
160         
161         DATAREC* drec;
162         HD46505* crtc;
163         I8255* pio;
164         IO *io;
165         MB8877* fdc;
166         YM2151* opm1;
167         YM2151* opm2;
168         YM2203* psg;
169         Z80* cpu;
170         Z80CTC* ctc;
171         Z80SIO* sio;
172         Z80CTC* ctc1;
173         Z80CTC* ctc2;
174 #ifdef _X1TURBO_FEATURE
175         Z80DMA* dma;
176 #endif
177         
178         DISPLAY* display;
179         EMM* emm;
180         FLOPPY* floppy;
181         IOBUS* iobus;
182         JOYSTICK* joy;
183         MEMORY* memory;
184         MOUSE* mouse;
185         PRINTER* printer;
186         PSUB* psub;
187         
188         MCS48* cpu_sub;
189         UPD1990A* rtc_sub;
190         I8255* pio_sub;
191         SUB* sub;
192         
193         MCS48* cpu_kbd;
194         KEYBOARD* kbd;
195         
196         bool pseudo_sub_cpu;
197         int sound_device_type;
198         
199 #ifdef _X1TWIN
200         // device for pce
201         EVENT* pceevent;
202         
203         HUC6280* pcecpu;
204         PCE* pce;
205 #endif
206         
207 public:
208         // ----------------------------------------
209         // initialize
210         // ----------------------------------------
211         
212         VM(EMU* parent_emu);
213         ~VM();
214         
215         // ----------------------------------------
216         // for emulation class
217         // ----------------------------------------
218         
219         // drive virtual machine
220         void reset();
221         void special_reset();
222         void run();
223         double frame_rate();
224         
225 #ifdef USE_DEBUGGER
226         // debugger
227         DEVICE *get_cpu(int index);
228 #endif
229         
230         // draw screen
231         void draw_screen();
232         int access_lamp();
233         
234         // sound generation
235         void initialize_sound(int rate, int samples);
236         uint16* create_sound(int* extra_frames);
237         int sound_buffer_ptr();
238         
239         // notify key
240         void key_down(int code, bool repeat);
241         void key_up(int code);
242         
243         // user interface
244         void open_disk(int drv, const _TCHAR* file_path, int bank);
245         void close_disk(int drv);
246         bool disk_inserted(int drv);
247         void set_disk_protected(int drv, bool value);
248         bool get_disk_protected(int drv);
249         void play_tape(const _TCHAR* file_path);
250         void rec_tape(const _TCHAR* file_path);
251         void close_tape();
252         bool tape_inserted();
253         bool tape_playing();
254         bool tape_recording();
255         int tape_position();
256         void push_play();
257         void push_stop();
258         void push_fast_forward();
259         void push_fast_rewind();
260         void push_apss_forward();
261         void push_apss_rewind();
262         bool now_skip();
263 #ifdef _X1TWIN
264         void open_cart(int drv, const _TCHAR* file_path);
265         void close_cart(int drv);
266         bool cart_inserted(int drv);
267 #endif
268         
269         void update_config();
270 #ifdef _X1TURBO_FEATURE
271         void update_dipswitch();
272 #endif
273         void save_state(FILEIO* state_fio);
274         bool load_state(FILEIO* state_fio);
275         
276         // ----------------------------------------
277         // for each device
278         // ----------------------------------------
279         
280         // devices
281         DEVICE* get_device(int id);
282         DEVICE* dummy;
283         DEVICE* first_device;
284         DEVICE* last_device;
285 };
286
287 #endif