OSDN Git Service

[VM][General] Merge upstream 2016-02-13. Still don't implement OSD/Gui part of joysti...
[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 IO_ADDR_MAX             0x100
43 #define Z80_MEMORY_WAIT
44 #if defined(_MZ800) || defined(_MZ1500)
45 #define MAX_DRIVE               4
46 #define HAS_MB8876
47 #endif
48 #if defined(_MZ1500)
49 #define MZ1P17_SW1_4_ON
50 #endif
51
52 // device informations for win32
53 #if defined(_MZ700)
54 #define USE_DIPSWITCH
55 #elif defined(_MZ800)
56 #define USE_BOOT_MODE           2
57 #endif
58 #define USE_TAPE
59 //#define USE_TAPE_PTR
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_CRT_FILTER
75 #define USE_SCANLINE
76 //#if defined(_MZ1500)
77 #define USE_SCREEN_ROTATE
78 //#endif
79 #if defined(_MZ800) || defined(_MZ1500)
80 #define USE_ACCESS_LAMP
81 //#define USE_DISK_WRITE_PROTECT
82 #endif
83 #if defined(_MZ700)
84 #define USE_SOUND_VOLUME        2
85 #elif defined(_MZ800)
86 #define USE_SOUND_VOLUME        3
87 #elif defined(_MZ1500)
88 #define USE_SOUND_VOLUME        4
89 #endif
90 #if defined(_MZ1500)
91 #define USE_PRINTER
92 #define USE_PRINTER_TYPE        4
93 #endif
94 #define USE_DEBUGGER
95 #define USE_STATE
96 #define USE_JOYSTICK
97 #define USE_CRT_MONITOR_4_3 1
98
99 #include "../../common.h"
100 #include "../../fileio.h"
101
102 #ifdef USE_SOUND_VOLUME
103 static const _TCHAR *sound_device_caption[] = {
104 #if defined(_MZ800)
105         _T("PSG"),
106 #elif defined(_MZ1500)
107         _T("PSG #1"), _T("PSG #2"),
108 #endif
109         _T("Beep"), _T("CMT"),
110 };
111 static const bool sound_device_monophonic[] = {
112 #if defined(_MZ800)
113         false,
114 #elif defined(_MZ1500)
115         false, false,
116 #endif
117         false, false,
118 };
119 #endif
120
121 class EMU;
122 class DEVICE;
123 class EVENT;
124
125 class AND;
126 class DATAREC;
127 class I8253;
128 class I8255;
129 class IO;
130 class PCM1BIT;
131 class Z80;
132
133 //class CMOS;
134 class EMM;
135 class KANJI;
136 class KEYBOARD;
137 class MEMORY;
138 class RAMFILE;
139
140 #if defined(_MZ800) || defined(_MZ1500)
141 class MB8877;
142 class NOT;
143 class SN76489AN;
144 class Z80PIO;
145 class Z80SIO;
146 class FLOPPY;
147 #if defined(_MZ1500)
148 class PSG;
149 #endif
150 class QUICKDISK;
151 #endif
152
153 class VM
154 {
155 protected:
156         EMU* emu;
157         
158         // devices
159         EVENT* event;
160         
161         AND* and_int;
162         DATAREC* drec;
163         I8253* pit;
164         I8255* pio;
165         IO* io;
166         PCM1BIT* pcm;
167         Z80* cpu;
168         
169 //      CMOS* cmos;
170         EMM* emm;
171         KANJI* kanji;
172         KEYBOARD* keyboard;
173         MEMORY* memory;
174         RAMFILE* ramfile;
175         
176 #if defined(_MZ800) || defined(_MZ1500)
177         AND* and_snd;
178         MB8877* fdc;
179 #if defined(_MZ800)
180         NOT* not_pit;
181         SN76489AN* psg;
182 #elif defined(_MZ1500)
183         DEVICE* printer;
184         NOT* not_reset;
185         NOT* not_strobe;
186         SN76489AN* psg_l;
187         SN76489AN* psg_r;
188 #endif
189         Z80PIO* pio_int;
190         Z80SIO* sio_rs; // RS-232C
191         Z80SIO* sio_qd; // QD
192         
193         FLOPPY* floppy;
194 #if defined(_MZ1500)
195         PSG* psg;
196 #endif
197         QUICKDISK* qd;
198 #endif
199         
200 #if defined(_MZ800)
201         int boot_mode;
202 #endif
203         
204 public:
205         // ----------------------------------------
206         // initialize
207         // ----------------------------------------
208         
209         VM(EMU* parent_emu);
210         ~VM();
211         
212         // ----------------------------------------
213         // for emulation class
214         // ----------------------------------------
215         
216         // drive virtual machine
217         void reset();
218         void run();
219         
220 #ifdef USE_DEBUGGER
221         // debugger
222         DEVICE *get_cpu(int index);
223 #endif
224         
225         // draw screen
226         void draw_screen();
227 #if defined(_MZ800) || defined(_MZ1500)
228         int access_lamp();
229 #endif
230         
231         // sound generation
232         void initialize_sound(int rate, int samples);
233         uint16* create_sound(int* extra_frames);
234         int sound_buffer_ptr();
235 #ifdef USE_SOUND_VOLUME
236         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
237 #endif
238         
239         // user interface
240         void play_tape(const _TCHAR* file_path);
241         void rec_tape(const _TCHAR* file_path);
242         void close_tape();
243         bool tape_inserted();
244         bool tape_playing();
245         bool tape_recording();
246         int tape_position();
247         void push_play();
248         void push_stop();
249         void push_fast_forward();
250         void push_fast_rewind();
251         void push_apss_forward() {}
252         void push_apss_rewind() {}
253 #if defined(_MZ800) || defined(_MZ1500)
254         void open_quickdisk(int drv, const _TCHAR* file_path);
255         void close_quickdisk(int drv);
256         bool quickdisk_inserted(int drv);
257         void open_disk(int drv, const _TCHAR* file_path, int bank);
258         void close_disk(int drv);
259         bool disk_inserted(int drv);
260         void set_disk_protected(int drv, bool value);
261         bool get_disk_protected(int drv);
262 #endif
263         bool now_skip();
264         
265         void update_config();
266         void save_state(FILEIO* state_fio);
267         bool load_state(FILEIO* state_fio);
268         
269         // ----------------------------------------
270         // for each device
271         // ----------------------------------------
272         
273         // devices
274         DEVICE* get_device(int id);
275         DEVICE* dummy;
276         DEVICE* first_device;
277         DEVICE* last_device;
278 };
279
280 #endif