OSDN Git Service

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