OSDN Git Service

1dde1da3924bf5eb4ebd4a0fe923ef7fc320156c
[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_PRINTER
110 #define USE_DEBUGGER
111 #define USE_STATE
112 #define USE_MOUSE
113 #define USE_KEYBOARD
114 #define USE_JOYSTICK
115
116 #include "../../common.h"
117 #include "../../fileio.h"
118
119 class EMU;
120 class DEVICE;
121 class EVENT;
122
123 class DATAREC;
124 class HD46505;
125 class I8255;
126 class IO;
127 class MB8877;
128 class YM2151;
129 class YM2203;
130 class Z80;
131 class Z80CTC;
132 class Z80SIO;
133 #ifdef _X1TURBO_FEATURE
134 class Z80DMA;
135 #endif
136
137 class DISPLAY;
138 class EMM;
139 class FLOPPY;
140 class IOBUS;
141 class JOYSTICK;
142 class MEMORY;
143 class MOUSE;
144 class PSUB;
145
146 class MCS48;
147 class UPD1990A;
148 class SUB;
149 class KEYBOARD;
150
151 #ifdef _X1TWIN
152 class HUC6280;
153 class PCE;
154 #endif
155
156 class VM
157 {
158 protected:
159         EMU* emu;
160         
161         // devices for x1
162         EVENT* event;
163         
164         DATAREC* drec;
165         DEVICE* printer;
166         HD46505* crtc;
167         I8255* pio;
168         IO *io;
169         MB8877* fdc;
170         YM2151* opm1;
171         YM2151* opm2;
172         YM2203* psg;
173         Z80* cpu;
174         Z80CTC* ctc;
175         Z80SIO* sio;
176         Z80CTC* ctc1;
177         Z80CTC* ctc2;
178 #ifdef _X1TURBO_FEATURE
179         Z80DMA* dma;
180 #endif
181         
182         DISPLAY* display;
183         EMM* emm;
184         FLOPPY* floppy;
185         IOBUS* iobus;
186         JOYSTICK* joy;
187         MEMORY* memory;
188         MOUSE* mouse;
189         PSUB* psub;
190         
191         MCS48* cpu_sub;
192         UPD1990A* rtc_sub;
193         I8255* pio_sub;
194         SUB* sub;
195         
196         MCS48* cpu_kbd;
197         KEYBOARD* kbd;
198         
199         bool pseudo_sub_cpu;
200         int sound_device_type;
201         
202 #ifdef _X1TWIN
203         // device for pce
204         EVENT* pceevent;
205         
206         HUC6280* pcecpu;
207         PCE* pce;
208 #endif
209         
210 public:
211         // ----------------------------------------
212         // initialize
213         // ----------------------------------------
214         
215         VM(EMU* parent_emu);
216         ~VM();
217         
218         // ----------------------------------------
219         // for emulation class
220         // ----------------------------------------
221         
222         // drive virtual machine
223         void reset();
224         void special_reset();
225         void run();
226         double frame_rate();
227         
228 #ifdef USE_DEBUGGER
229         // debugger
230         DEVICE *get_cpu(int index);
231 #endif
232         
233         // draw screen
234         void draw_screen();
235         int access_lamp();
236         
237         // sound generation
238         void initialize_sound(int rate, int samples);
239         uint16* create_sound(int* extra_frames);
240         int sound_buffer_ptr();
241         
242         // notify key
243         void key_down(int code, bool repeat);
244         void key_up(int code);
245         
246         // user interface
247         void open_disk(int drv, const _TCHAR* file_path, int bank);
248         void close_disk(int drv);
249         bool disk_inserted(int drv);
250         void set_disk_protected(int drv, bool value);
251         bool get_disk_protected(int drv);
252         void play_tape(const _TCHAR* file_path);
253         void rec_tape(const _TCHAR* file_path);
254         void close_tape();
255         bool tape_inserted();
256         bool tape_playing();
257         bool tape_recording();
258         int tape_position();
259         void push_play();
260         void push_stop();
261         void push_fast_forward();
262         void push_fast_rewind();
263         void push_apss_forward();
264         void push_apss_rewind();
265         bool now_skip();
266 #ifdef _X1TWIN
267         void open_cart(int drv, const _TCHAR* file_path);
268         void close_cart(int drv);
269         bool cart_inserted(int drv);
270 #endif
271         
272         void update_config();
273 #ifdef _X1TURBO_FEATURE
274         void update_dipswitch();
275 #endif
276         void save_state(FILEIO* state_fio);
277         bool load_state(FILEIO* state_fio);
278         
279         // ----------------------------------------
280         // for each device
281         // ----------------------------------------
282         
283         // devices
284         DEVICE* get_device(int id);
285         DEVICE* dummy;
286         DEVICE* first_device;
287         DEVICE* last_device;
288 };
289
290 #endif