OSDN Git Service

[General][Qt] Enable to build even not support counter of CMT.
[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 // 4:3
82 #define SCREEN_WIDTH_ASPECT 400 
83 #define SCREEN_HEIGHT_ASPECT 300
84 // device informations for win32
85 #define USE_SPECIAL_RESET
86 #ifdef _X1TURBO_FEATURE
87 #define USE_DEVICE_TYPE         2
88 #define USE_DRIVE_TYPE          2
89 #endif
90 #define USE_FD1
91 #define USE_FD2
92 #define FD_BASE_NUMBER          0
93 #define USE_TAPE
94 #define USE_TAPE_BUTTON
95 #define USE_TAPE_PTR
96 #ifdef _X1TWIN
97 #define USE_CART1
98 #endif
99 #define NOTIFY_KEY_DOWN
100 #define USE_SHIFT_NUMPAD_KEY
101 #define USE_ALT_F10_KEY
102 #define USE_AUTO_KEY            8
103 #define USE_AUTO_KEY_RELEASE    10
104 #define USE_MONITOR_TYPE        2
105 #define USE_CRT_FILTER
106 #define USE_SCANLINE
107 #define USE_ACCESS_LAMP
108 #define USE_DISK_WRITE_PROTECT
109 #define USE_SOUND_DEVICE_TYPE   3
110 #define USE_DEBUGGER
111 #define USE_STATE
112
113 #include "../../common.h"
114 #include "../../fileio.h"
115
116 class EMU;
117 class DEVICE;
118 class EVENT;
119
120 class DATAREC;
121 class HD46505;
122 class I8255;
123 class IO;
124 class MB8877;
125 class YM2151;
126 class YM2203;
127 class Z80;
128 class Z80CTC;
129 class Z80SIO;
130 #ifdef _X1TURBO_FEATURE
131 class Z80DMA;
132 #endif
133
134 class DISPLAY;
135 class EMM;
136 class FLOPPY;
137 class IOBUS;
138 class JOYSTICK;
139 class MEMORY;
140 class MOUSE;
141 class PRINTER;
142 class PSUB;
143
144 class MCS48;
145 class UPD1990A;
146 class SUB;
147 class KEYBOARD;
148
149 #ifdef _X1TWIN
150 class HUC6280;
151 class PCE;
152 #endif
153
154 class VM
155 {
156 protected:
157         EMU* emu;
158         
159         // devices for x1
160         EVENT* event;
161         
162         DATAREC* drec;
163         HD46505* crtc;
164         I8255* pio;
165         IO *io;
166         MB8877* fdc;
167         YM2151* opm1;
168         YM2151* opm2;
169         YM2203* psg;
170         Z80* cpu;
171         Z80CTC* ctc;
172         Z80SIO* sio;
173         Z80CTC* ctc1;
174         Z80CTC* ctc2;
175 #ifdef _X1TURBO_FEATURE
176         Z80DMA* dma;
177 #endif
178         
179         DISPLAY* display;
180         EMM* emm;
181         FLOPPY* floppy;
182         IOBUS* iobus;
183         JOYSTICK* joy;
184         MEMORY* memory;
185         MOUSE* mouse;
186         PRINTER* printer;
187         PSUB* psub;
188         
189         MCS48* cpu_sub;
190         UPD1990A* rtc_sub;
191         I8255* pio_sub;
192         SUB* sub;
193         
194         MCS48* cpu_kbd;
195         KEYBOARD* kbd;
196         
197         bool pseudo_sub_cpu;
198         int sound_device_type;
199         
200 #ifdef _X1TWIN
201         // device for pce
202         EVENT* pceevent;
203         
204         HUC6280* pcecpu;
205         PCE* pce;
206 #endif
207         
208 public:
209         // ----------------------------------------
210         // initialize
211         // ----------------------------------------
212         
213         VM(EMU* parent_emu);
214         ~VM();
215         
216         // ----------------------------------------
217         // for emulation class
218         // ----------------------------------------
219         
220         // drive virtual machine
221         void reset();
222         void special_reset();
223         void run();
224         double frame_rate();
225         
226 #ifdef USE_DEBUGGER
227         // debugger
228         DEVICE *get_cpu(int index);
229 #endif
230         
231         // draw screen
232         void draw_screen();
233         int access_lamp();
234         
235         // sound generation
236         void initialize_sound(int rate, int samples);
237         uint16* create_sound(int* extra_frames);
238         int sound_buffer_ptr();
239         
240         // notify key
241         void key_down(int code, bool repeat);
242         void key_up(int code);
243         
244         // user interface
245         void open_disk(int drv, _TCHAR* file_path, int bank);
246         void close_disk(int drv);
247         bool disk_inserted(int drv);
248         void write_protect_fd(int drv, bool flag);
249         bool is_write_protect_fd(int drv);
250         void play_tape(_TCHAR* file_path);
251         void rec_tape(_TCHAR* file_path);
252         void close_tape();
253         bool tape_inserted();
254         void push_play();
255         void push_stop();
256         void push_fast_forward();
257         void push_fast_rewind();
258         void push_apss_forward();
259         void push_apss_rewind();
260         bool now_skip();
261         int get_tape_ptr(void);
262         bool get_tape_play(void);
263 #ifdef _X1TWIN
264         void open_cart(int drv, _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