OSDN Git Service

[VM][Qt][OSD][Genaral] Sync to upstream ; phase 1: Merege upstream 20151217.
[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 #define SCREEN_WIDTH_ASPECT SCREEN_WIDTH 
49 #define SCREEN_HEIGHT_ASPECT SCREEN_HEIGHT
50 #define WINDOW_WIDTH_ASPECT 640 
51 #define WINDOW_HEIGHT_ASPECT 480
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_TAPE
60 #define USE_TAPE_PTR
61 #define USE_TAPE_BUTTON
62 #if defined(_MZ800) || defined(_MZ1500)
63 #define USE_QD1
64 #define USE_FD1
65 #define USE_FD2
66 #endif
67 #define USE_SHIFT_NUMPAD_KEY
68 #define USE_ALT_F10_KEY
69 #define USE_AUTO_KEY            5
70 #define USE_AUTO_KEY_RELEASE    6
71 #define USE_AUTO_KEY_CAPS
72 #if defined(_MZ800)
73 #define USE_MONITOR_TYPE        2
74 #endif
75 #define USE_CRT_FILTER
76 #define USE_SCANLINE
77 //#if defined(_MZ1500)
78 #define USE_SCREEN_ROTATE
79 //#endif
80 #if defined(_MZ800) || defined(_MZ1500)
81 #define USE_ACCESS_LAMP
82 #define USE_DISK_WRITE_PROTECT
83 #endif
84 #define USE_DEBUGGER
85 #define USE_STATE
86
87 #include "../../common.h"
88 #include "../../fileio.h"
89
90 class EMU;
91 class DEVICE;
92 class EVENT;
93
94 class AND;
95 class DATAREC;
96 class I8253;
97 class I8255;
98 class IO;
99 class PCM1BIT;
100 class Z80;
101
102 //class CMOS;
103 class EMM;
104 class KANJI;
105 class KEYBOARD;
106 class MEMORY;
107 class RAMFILE;
108
109 #if defined(_MZ800) || defined(_MZ1500)
110 class MB8877;
111 #if defined(_MZ800)
112 class NOT;
113 #endif
114 class SN76489AN;
115 class Z80PIO;
116 class Z80SIO;
117 class FLOPPY;
118 #if defined(_MZ1500)
119 class PSG;
120 #endif
121 class QUICKDISK;
122 #endif
123
124 class VM
125 {
126 protected:
127         EMU* emu;
128         
129         // devices
130         EVENT* event;
131         
132         AND* and_int;
133         DATAREC* drec;
134         I8253* pit;
135         I8255* pio;
136         IO* io;
137         PCM1BIT* pcm;
138         Z80* cpu;
139         
140 //      CMOS* cmos;
141         EMM* emm;
142         KANJI* kanji;
143         KEYBOARD* keyboard;
144         MEMORY* memory;
145         RAMFILE* ramfile;
146         
147 #if defined(_MZ800) || defined(_MZ1500)
148         AND* and_snd;
149         MB8877* fdc;
150 #if defined(_MZ800)
151         NOT* not_pit;
152         SN76489AN* psg;
153 #elif defined(_MZ1500)
154         SN76489AN* psg_l;
155         SN76489AN* psg_r;
156 #endif
157         Z80PIO* pio_int;
158         Z80SIO* sio_rs; // RS-232C
159         Z80SIO* sio_qd; // QD
160         
161         FLOPPY* floppy;
162 #if defined(_MZ1500)
163         PSG* psg;
164 #endif
165         QUICKDISK* qd;
166 #endif
167         
168 #if defined(_MZ800)
169         int boot_mode;
170 #endif
171         
172 public:
173         // ----------------------------------------
174         // initialize
175         // ----------------------------------------
176         
177         VM(EMU* parent_emu);
178         ~VM();
179         
180         // ----------------------------------------
181         // for emulation class
182         // ----------------------------------------
183         
184         // drive virtual machine
185         void reset();
186         void run();
187         
188 #ifdef USE_DEBUGGER
189         // debugger
190         DEVICE *get_cpu(int index);
191 #endif
192         
193         // draw screen
194         void draw_screen();
195 #if defined(_MZ800) || defined(_MZ1500)
196         int access_lamp();
197 #endif
198         
199         // sound generation
200         void initialize_sound(int rate, int samples);
201         uint16* create_sound(int* extra_frames);
202         int sound_buffer_ptr();
203         
204         // user interface
205         void play_tape(const _TCHAR* file_path);
206         void rec_tape(const _TCHAR* file_path);
207         void close_tape();
208         bool tape_inserted();
209         bool tape_playing();
210         bool tape_recording();
211         int tape_position();
212         void push_play();
213         void push_stop();
214         void push_fast_forward();
215         void push_fast_rewind();
216         void push_apss_forward() {}
217         void push_apss_rewind() {}
218 #if defined(_MZ800) || defined(_MZ1500)
219         void open_quickdisk(int drv, const _TCHAR* file_path);
220         void close_quickdisk(int drv);
221         bool quickdisk_inserted(int drv);
222         void open_disk(int drv, const _TCHAR* file_path, int bank);
223         void close_disk(int drv);
224         bool disk_inserted(int drv);
225         void set_disk_protected(int drv, bool value);
226         bool get_disk_protected(int drv);
227 #endif
228         bool now_skip();
229         
230         void update_config();
231         void save_state(FILEIO* state_fio);
232         bool load_state(FILEIO* state_fio);
233         
234         // ----------------------------------------
235         // for each device
236         // ----------------------------------------
237         
238         // devices
239         DEVICE* get_device(int id);
240         DEVICE* dummy;
241         DEVICE* first_device;
242         DEVICE* last_device;
243 };
244
245 #endif