OSDN Git Service

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