OSDN Git Service

a3b291685805cf1920b40f9bb9dfc114594ad92f
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz700 / mz700.h
1 /*
2         SHARP MZ-700 Emulator 'EmuZ-700'
3         SHARP MZ-800 Emulator 'EmuZ-800'
4         SHARP MZ-1500 Emulator 'EmuZ-1500'
5
6         Author : Takeda.Toshiya
7         Date   : 2008.06.05 -
8
9         [ virtual machine ]
10 */
11
12 #ifndef _MZ700_H_
13 #define _MZ700_H_
14
15 #if defined(_MZ700)
16 #define DEVICE_NAME             "SHARP MZ-700"
17 #define CONFIG_NAME             "mz700"
18 #elif defined(_MZ800)
19 #define DEVICE_NAME             "SHARP MZ-800"
20 #define CONFIG_NAME             "mz800"
21 #elif defined(_MZ1500)
22 #define DEVICE_NAME             "SHARP MZ-1500"
23 #define CONFIG_NAME             "mz1500"
24 #endif
25
26 // device informations for virtual machine
27 #if defined(_MZ800)
28 #define FRAMES_PER_SEC          (3546895.0 / 228.0 / 312.0)
29 #define LINES_PER_FRAME         312
30 #define CPU_CLOCKS              3546895
31 #else
32 #define FRAMES_PER_SEC          (3579545.0 / 228.0 / 262.0)
33 #define LINES_PER_FRAME         262
34 #define CPU_CLOCKS              3579545
35 #endif
36 #define SCREEN_WIDTH            640
37 #define SCREEN_HEIGHT           400
38 #define WINDOW_HEIGHT_ASPECT    480
39 #define IO_ADDR_MAX             0x100
40 #define Z80_MEMORY_WAIT
41 #define Z80_IO_WAIT
42 #if defined(_MZ800) || defined(_MZ1500)
43 #define MAX_DRIVE               4
44 #define HAS_MB8876
45 #endif
46 #if defined(_MZ1500)
47 #define MZ1P17_SW1_4_ON
48 #endif
49
50 // device informations for win32
51 #if defined(_MZ700)
52 #define USE_DIPSWITCH
53 #elif defined(_MZ800)
54 #define USE_BOOT_MODE           2
55 #endif
56 #define USE_TAPE                1
57 #define USE_TAPE_BUTTON
58 #if defined(_MZ800) || defined(_MZ1500)
59 #define USE_DRIVE_TYPE          2
60 #define USE_FLOPPY_DISK         2
61 #define USE_QUICK_DISK          1
62 #endif
63 #define USE_SHIFT_NUMPAD_KEY
64 #define USE_ALT_F10_KEY
65 #define USE_AUTO_KEY            5
66 #define USE_AUTO_KEY_RELEASE    6
67 #define USE_AUTO_KEY_CAPS
68 #if defined(_MZ700) || defined(_MZ1500)
69 #define USE_AUTO_KEY_NUMPAD
70 #define USE_VM_AUTO_KEY_TABLE
71 #endif
72 #if defined(_MZ800)
73 #define USE_MONITOR_TYPE        2
74 #endif
75 #define USE_SCREEN_FILTER
76 #define USE_SCANLINE
77 #if defined(_MZ700)
78 #define USE_SOUND_VOLUME        3
79 #elif defined(_MZ800)
80 #define USE_SOUND_VOLUME        5
81 #elif defined(_MZ1500)
82 #define USE_SOUND_VOLUME        6
83 #endif
84 #if defined(_MZ1500)
85 #define USE_PRINTER
86 #define USE_PRINTER_TYPE        4
87 #endif
88 #define SUPPORT_TV_RENDER
89 #define USE_DEBUGGER
90 #define USE_STATE
91 #define USE_CPU_Z80
92
93 #if defined(_MZ700) || defined(_MZ1500)
94 static const int vm_auto_key_table_base[][2] = {
95         // thanks Mr.Koucha Youkan
96         {0xa1,  0x300 | 0xbe},  // '¡'    *** MODIFIED ***
97         {0xa2,  0x300 | 0x38},  // '¢'    *** MODIFIED ***
98         {0xa3,  0x300 | 0x39},  // '£'    *** MODIFIED ***
99         {0xa4,  0x300 | 0xbc},  // '¤'    *** MODIFIED ***
100         {0xa5,  0x300 | 0x30},  // '¥'    *** MODIFIED ***
101         {0xa6,  0x200 | 0xdb},  // '¦'    *** MODIFIED ***
102         {0xa7,  0x300 | 0x31},  // '§'
103         {0xa8,  0x300 | 0x32},  // '¨'
104         {0xa9,  0x300 | 0x33},  // '©'
105         {0xaa,  0x300 | 0x34},  // 'ª'
106         {0xab,  0x300 | 0x35},  // '«'
107         {0xac,  0x300 | 0xbd},  // '¬'    *** MODIFIED ***
108         {0xad,  0x300 | 0xde},  // '­'    *** MODIFIED ***
109         {0xae,  0x300 | 0xdc},  // '®'    *** MODIFIED ***
110         {0xaf,  0x300 | 0x43},  // '¯'
111         {0xb0,  0x200 | 0xe2},  // '°'    *** MODIFIED ***
112         {0xb1,  0x200 | 0x31},  // '±'
113         {0xb2,  0x200 | 0x32},  // '²'
114         {0xb3,  0x200 | 0x33},  // '³'
115         {0xb4,  0x200 | 0x34},  // '´'
116         {0xb5,  0x200 | 0x35},  // 'µ'
117         {0xb6,  0x200 | 0x51},  // '¶'
118         {0xb7,  0x200 | 0x57},  // '·'
119         {0xb8,  0x200 | 0x45},  // '¸'
120         {0xb9,  0x200 | 0x52},  // '¹'
121         {0xba,  0x200 | 0x54},  // 'º'
122         {0xbb,  0x200 | 0x41},  // '»'
123         {0xbc,  0x200 | 0x53},  // '¼'
124         {0xbd,  0x200 | 0x44},  // '½'
125         {0xbe,  0x200 | 0x46},  // '¾'
126         {0xbf,  0x200 | 0x47},  // '¿'
127         {0xc0,  0x200 | 0x5a},  // 'À'
128         {0xc1,  0x200 | 0x58},  // 'Á'
129         {0xc2,  0x200 | 0x43},  // 'Â'
130         {0xc3,  0x200 | 0x56},  // 'Ã'
131         {0xc4,  0x200 | 0x42},  // 'Ä'
132         {0xc5,  0x200 | 0x36},  // 'Å'
133         {0xc6,  0x200 | 0x37},  // 'Æ'
134         {0xc7,  0x200 | 0x38},  // 'Ç'
135         {0xc8,  0x200 | 0x39},  // 'È'
136         {0xc9,  0x200 | 0x30},  // 'É'
137         {0xca,  0x200 | 0x59},  // 'Ê'
138         {0xcb,  0x200 | 0x55},  // 'Ë'
139         {0xcc,  0x200 | 0x49},  // 'Ì'
140         {0xcd,  0x200 | 0x4f},  // 'Í'
141         {0xce,  0x200 | 0x50},  // 'Î'
142         {0xcf,  0x200 | 0x48},  // 'Ï'
143         {0xd0,  0x200 | 0x4a},  // 'Ð'
144         {0xd1,  0x200 | 0x4b},  // 'Ñ'
145         {0xd2,  0x200 | 0x4c},  // 'Ò'
146         {0xd3,  0x200 | 0xbb},  // 'Ó'
147         {0xd4,  0x200 | 0xbd},  // 'Ô'    *** MODIFIED ***
148         {0xd5,  0x200 | 0xde},  // 'Õ'    *** MODIFIED ***
149         {0xd6,  0x200 | 0xdc},  // 'Ö'    *** MODIFIED ***
150         {0xd7,  0x200 | 0x4e},  // '×'    *** MODIFIED ***
151         {0xd8,  0x200 | 0x4d},  // 'Ø'    *** MODIFIED ***
152         {0xd9,  0x200 | 0xbc},  // 'Ù'    *** MODIFIED ***
153         {0xda,  0x200 | 0xbe},  // 'Ú'    *** MODIFIED ***
154         {0xdb,  0x200 | 0xbf},  // 'Û'    *** MODIFIED ***
155         {0xdc,  0x200 | 0xc0},  // 'Ü'    *** MODIFIED ***
156         {0xdd,  0x200 | 0x78},  // 'Ý'    *** MODIFIED ***
157         {0xde,  0x200 | 0xba},  // 'Þ'    *** MODIFIED ***
158         {0xdf,  0x200 | 0xdd},  // 'ß'    *** MODIFIED ***
159         {-1,    -1},
160 };
161 #endif
162
163 #include "../../common.h"
164 #include "../../fileio.h"
165 #include "../vm_template.h"
166
167 #ifdef USE_SOUND_VOLUME
168 static const _TCHAR *sound_device_caption[] = {
169 #if defined(_MZ800)
170         _T("PSG"),
171 #elif defined(_MZ1500)
172         _T("PSG #1"), _T("PSG #2"),
173 #endif
174         _T("Beep"), _T("CMT (Signal)"),
175 #if defined(_MZ800) || defined(_MZ1500)
176         _T("Noise (FDD)"),
177 #endif
178         _T("Noise (CMT)"),
179 };
180 #endif
181
182 class csp_state_utils;
183 class EMU;
184 class DEVICE;
185 class EVENT;
186
187 class AND;
188 class DATAREC;
189 class I8253;
190 class I8255;
191 class IO;
192 class PCM1BIT;
193 class Z80;
194
195 //class CMOS;
196 class EMM;
197 class KANJI;
198 class KEYBOARD;
199 class MEMORY;
200 class RAMFILE;
201
202 #if defined(_MZ800) || defined(_MZ1500)
203 class MB8877;
204 class NOT;
205 class SN76489AN;
206 class Z80PIO;
207 class Z80SIO;
208 class FLOPPY;
209 #if defined(_MZ1500)
210 class PSG;
211 #endif
212 class QUICKDISK;
213 #endif
214
215 class VM : public VM_TEMPLATE
216 {
217 protected:
218         //EMU* emu;
219         //csp_state_utils* state_entry;
220         
221         // devices
222         //EVENT* event;
223         
224         AND* and_int;
225         DATAREC* drec;
226         I8253* pit;
227         I8255* pio;
228         IO* io;
229         PCM1BIT* pcm;
230         Z80* cpu;
231         
232 //      CMOS* cmos;
233         EMM* emm;
234         KANJI* kanji;
235         KEYBOARD* keyboard;
236         MEMORY* memory;
237         RAMFILE* ramfile;
238         
239 #if defined(_MZ800) || defined(_MZ1500)
240         AND* and_snd;
241         MB8877* fdc;
242 #if defined(_MZ800)
243         NOT* not_pit;
244         SN76489AN* psg;
245 #elif defined(_MZ1500)
246         DEVICE* printer;
247         NOT* not_reset;
248         NOT* not_strobe;
249         SN76489AN* psg_l;
250         SN76489AN* psg_r;
251 #endif
252         Z80PIO* pio_int;
253         Z80SIO* sio_rs; // RS-232C
254         Z80SIO* sio_qd; // QD
255         
256         FLOPPY* floppy;
257 #if defined(_MZ1500)
258         PSG* psg;
259 #endif
260         QUICKDISK* qd;
261 #endif
262         
263 #if defined(_MZ800)
264         int boot_mode;
265 #endif
266         
267 public:
268         // ----------------------------------------
269         // initialize
270         // ----------------------------------------
271         
272         VM(EMU* parent_emu);
273         ~VM();
274         
275         // ----------------------------------------
276         // for emulation class
277         // ----------------------------------------
278         
279         // drive virtual machine
280         void reset();
281         void run();
282         
283 #ifdef USE_DEBUGGER
284         // debugger
285         DEVICE *get_cpu(int index);
286 #endif
287         
288         // draw screen
289         void draw_screen();
290         
291         // sound generation
292         void initialize_sound(int rate, int samples);
293         uint16_t* create_sound(int* extra_frames);
294         int get_sound_buffer_ptr();
295 #ifdef USE_SOUND_VOLUME
296         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
297 #endif
298         
299         // user interface
300         void play_tape(int drv, const _TCHAR* file_path);
301         void rec_tape(int drv, const _TCHAR* file_path);
302         void close_tape(int drv);
303         bool is_tape_inserted(int drv);
304         bool is_tape_playing(int drv);
305         bool is_tape_recording(int drv);
306         int get_tape_position(int drv);
307         const _TCHAR* get_tape_message(int drv);
308         void push_play(int drv);
309         void push_stop(int drv);
310         void push_fast_forward(int drv);
311         void push_fast_rewind(int drv);
312         void push_apss_forward(int drv) {}
313         void push_apss_rewind(int drv) {}
314 #if defined(_MZ800) || defined(_MZ1500)
315         void open_quick_disk(int drv, const _TCHAR* file_path);
316         void close_quick_disk(int drv);
317         bool is_quick_disk_inserted(int drv);
318         uint32_t is_quick_disk_accessed();
319         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
320         void close_floppy_disk(int drv);
321         bool is_floppy_disk_inserted(int drv);
322         void is_floppy_disk_protected(int drv, bool value);
323         bool is_floppy_disk_protected(int drv);
324         uint32_t is_floppy_disk_accessed();
325 #endif
326         bool is_frame_skippable();
327         
328         void update_config();
329         void decl_state();
330         void save_state(FILEIO* state_fio);
331         bool load_state(FILEIO* state_fio);
332         
333         // ----------------------------------------
334         // for each device
335         // ----------------------------------------
336         
337         // devices
338         DEVICE* get_device(int id);
339         //DEVICE* dummy;
340         //DEVICE* first_device;
341         //DEVICE* last_device;
342 };
343
344 #endif