OSDN Git Service

[General] Merge Upstream 2017-04-02.
[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          50
29 #define LINES_PER_FRAME         312
30 //#define CPU_CLOCKS            3546900
31 // 228*312*50
32 #define CPU_CLOCKS              3556800
33 #else
34 #define FRAMES_PER_SEC          60
35 #define LINES_PER_FRAME         262
36 //#define CPU_CLOCKS            3579545
37 // 228*262*60
38 #define CPU_CLOCKS              3584160
39 #endif
40 #define SCREEN_WIDTH            640
41 #define SCREEN_HEIGHT           400
42 #define WINDOW_HEIGHT_ASPECT    480
43 #define IO_ADDR_MAX             0x100
44 #define Z80_MEMORY_WAIT
45 #if defined(_MZ800) || defined(_MZ1500)
46 #define MAX_DRIVE               4
47 #define HAS_MB8876
48 #endif
49 #if defined(_MZ1500)
50 #define MZ1P17_SW1_4_ON
51 #endif
52
53 // device informations for win32
54 #if defined(_MZ700)
55 #define USE_DIPSWITCH
56 #elif defined(_MZ800)
57 #define USE_BOOT_MODE           2
58 #endif
59 #define USE_TAPE1
60 #define USE_TAPE_BUTTON
61 #if defined(_MZ800) || defined(_MZ1500)
62 #define USE_QD1
63 #define USE_FD1
64 #define USE_FD2
65 #endif
66 #define USE_SHIFT_NUMPAD_KEY
67 #define USE_ALT_F10_KEY
68 #define USE_AUTO_KEY            5
69 #define USE_AUTO_KEY_RELEASE    6
70 #define USE_AUTO_KEY_CAPS
71 #if defined(_MZ800)
72 #define USE_MONITOR_TYPE        2
73 #endif
74 #define USE_SCREEN_FILTER
75 #define USE_SCANLINE
76 #if defined(_MZ700)
77 #define USE_SOUND_VOLUME        3
78 #elif defined(_MZ800)
79 #define USE_SOUND_VOLUME        5
80 //#define USE_SOUND_FILES_QD
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_ROMA_KANA_CONVERSION
89 #define SUPPORT_TV_RENDER
90 #define USE_DEBUGGER
91 #define USE_STATE
92
93 #include "../../common.h"
94 #include "../../fileio.h"
95
96 #ifdef USE_SOUND_VOLUME
97 static const _TCHAR *sound_device_caption[] = {
98 #if defined(_MZ800)
99         _T("PSG"),
100 #elif defined(_MZ1500)
101         _T("PSG #1"), _T("PSG #2"),
102 #endif
103         _T("Beep"), _T("CMT (Signal)"),
104 #if defined(_MZ800) || defined(_MZ1500)
105         _T("Noise (FDD)"),
106 #endif
107         _T("Noise (CMT)"),
108 };
109 #endif
110
111 class EMU;
112 class DEVICE;
113 class EVENT;
114
115 class AND;
116 class DATAREC;
117 class I8253;
118 class I8255;
119 class IO;
120 class PCM1BIT;
121 class Z80;
122
123 //class CMOS;
124 class EMM;
125 class KANJI;
126 class KEYBOARD;
127 class MEMORY;
128 class RAMFILE;
129
130 #if defined(_MZ800) || defined(_MZ1500)
131 class MB8877;
132 class NOT;
133 class SN76489AN;
134 class Z80PIO;
135 class Z80SIO;
136 class FLOPPY;
137 #if defined(_MZ1500)
138 class PSG;
139 #endif
140 class QUICKDISK;
141 #endif
142
143 class VM
144 {
145 protected:
146         EMU* emu;
147         
148         // devices
149         EVENT* event;
150         
151         AND* and_int;
152         DATAREC* drec;
153         I8253* pit;
154         I8255* pio;
155         IO* io;
156         PCM1BIT* pcm;
157         Z80* cpu;
158         
159 //      CMOS* cmos;
160         EMM* emm;
161         KANJI* kanji;
162         KEYBOARD* keyboard;
163         MEMORY* memory;
164         RAMFILE* ramfile;
165         
166 #if defined(_MZ800) || defined(_MZ1500)
167         AND* and_snd;
168         MB8877* fdc;
169 #if defined(_MZ800)
170         NOT* not_pit;
171         SN76489AN* psg;
172 #elif defined(_MZ1500)
173         DEVICE* printer;
174         NOT* not_reset;
175         NOT* not_strobe;
176         SN76489AN* psg_l;
177         SN76489AN* psg_r;
178 #endif
179         Z80PIO* pio_int;
180         Z80SIO* sio_rs; // RS-232C
181         Z80SIO* sio_qd; // QD
182         
183         FLOPPY* floppy;
184 #if defined(_MZ1500)
185         PSG* psg;
186 #endif
187         QUICKDISK* qd;
188 #endif
189         
190 #if defined(_MZ800)
191         int boot_mode;
192 #endif
193         
194 public:
195         // ----------------------------------------
196         // initialize
197         // ----------------------------------------
198         
199         VM(EMU* parent_emu);
200         ~VM();
201         
202         // ----------------------------------------
203         // for emulation class
204         // ----------------------------------------
205         
206         // drive virtual machine
207         void reset();
208         void run();
209         
210 #ifdef USE_DEBUGGER
211         // debugger
212         DEVICE *get_cpu(int index);
213 #endif
214         
215         // draw screen
216         void draw_screen();
217         
218         // sound generation
219         void initialize_sound(int rate, int samples);
220         uint16_t* create_sound(int* extra_frames);
221         int get_sound_buffer_ptr();
222 #ifdef USE_SOUND_VOLUME
223         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
224 #endif
225         
226         // user interface
227         void play_tape(int drv, const _TCHAR* file_path);
228         void rec_tape(int drv, const _TCHAR* file_path);
229         void close_tape(int drv);
230         bool is_tape_inserted(int drv);
231         bool is_tape_playing(int drv);
232         bool is_tape_recording(int drv);
233         int get_tape_position(int drv);
234         const _TCHAR* get_tape_message(int drv);
235         void push_play(int drv);
236         void push_stop(int drv);
237         void push_fast_forward(int drv);
238         void push_fast_rewind(int drv);
239         void push_apss_forward(int drv) {}
240         void push_apss_rewind(int drv) {}
241 #if defined(_MZ800) || defined(_MZ1500)
242         void open_quick_disk(int drv, const _TCHAR* file_path);
243         void close_quick_disk(int drv);
244         bool is_quick_disk_inserted(int drv);
245         uint32_t is_quick_disk_accessed();
246         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
247         void close_floppy_disk(int drv);
248         bool is_floppy_disk_inserted(int drv);
249         void is_floppy_disk_protected(int drv, bool value);
250         bool is_floppy_disk_protected(int drv);
251         uint32_t is_floppy_disk_accessed();
252 #endif
253         bool is_frame_skippable();
254         
255         void update_config();
256         void save_state(FILEIO* state_fio);
257         bool load_state(FILEIO* state_fio);
258         
259         // ----------------------------------------
260         // for each device
261         // ----------------------------------------
262         
263         // devices
264         DEVICE* get_device(int id);
265         DEVICE* dummy;
266         DEVICE* first_device;
267         DEVICE* last_device;
268 };
269
270 #endif