OSDN Git Service

649e826c4728ef760213d180f3e44b7ce9ff9a21
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc8801 / pc8801.h
1 /*
2         NEC PC-8801MA Emulator 'ePC-8801MA'
3         NEC PC-8001mkIISR Emulator 'ePC-8001mkIISR'
4
5         Author : Takeda.Toshiya
6         Date   : 2012.02.16-
7
8         [ virtual machine ]
9 */
10
11 #ifndef _PC8801_H_
12 #define _PC8801_H_
13
14 #if defined(_PC8801MA)
15 #define DEVICE_NAME             "NEC PC-8801MA"
16 #define CONFIG_NAME             "pc8801ma"
17 #elif defined(_PC8001SR)
18 #define DEVICE_NAME             "NEC PC-8001mkIISR"
19 #define CONFIG_NAME             "pc8001mk2sr"
20 #endif
21
22 #if defined(_PC8001SR)
23 #define MODE_PC80_V1    0
24 #define MODE_PC80_V2    1
25 #define MODE_PC80_N     2
26 #else
27 #define MODE_PC88_V1S   0
28 #define MODE_PC88_V1H   1
29 #define MODE_PC88_V2    2
30 #define MODE_PC88_N     3
31 #endif
32
33 #if defined(_PC8801MA)
34 #define SUPPORT_PC88_DICTIONARY
35 #define SUPPORT_PC88_HIGH_CLOCK
36 #define SUPPORT_PC88_OPNA
37 #define SUPPORT_PC88_SB2
38 #define SUPPORT_PC88_CDROM
39 #define SUPPORT_PC88_VAB
40 #define SUPPORT_PC88_HMB20
41 #if defined(SUPPORT_PC88_VAB)
42 // X88000
43 #define PC88_EXRAM_BANKS        8
44 #define PC88_VAB_PAGE           1
45 #else
46 #define PC88_EXRAM_BANKS        4
47 #endif
48 #define HAS_UPD4990A
49 #endif
50 #define SUPPORT_PC88_JOYSTICK
51 #define SUPPORT_PC88_PCG8100
52
53 // device informations for virtual machine
54 #define FRAMES_PER_SEC          62.422
55 #define LINES_PER_FRAME         260
56 #define CPU_CLOCKS              3993624
57 #define SCREEN_WIDTH            640
58 #define SCREEN_HEIGHT           400
59 #define WINDOW_HEIGHT_ASPECT    480
60 #define MAX_DRIVE               2
61 #define UPD765A_NO_ST1_EN_OR_FOR_RESULT7
62 #if defined(_PC8801MA)
63 #define PC80S31K_NO_WAIT
64 #endif
65 #if defined(SUPPORT_PC88_CDROM)
66 #define SCSI_HOST_AUTO_ACK
67 #define SCSI_DEV_IMMEDIATE_SELECT
68 #endif
69 #define Z80_MEMORY_WAIT
70 #define OVERRIDE_SOUND_FREQ_48000HZ     55467
71
72 // device informations for win32
73 #if defined(_PC8001SR)
74 #define USE_BOOT_MODE           3
75 #define USE_CPU_TYPE            2
76 #else
77 #define USE_BOOT_MODE           4
78 #define USE_CPU_TYPE            3
79 #endif
80 #if defined(_PC8801MA)
81 // V2 mode, 4MHz
82 #define BOOT_MODE_DEFAULT       2
83 #define CPU_TYPE_DEFAULT        1
84 #endif
85 #define USE_DIPSWITCH
86 #define USE_JOYSTICK_TYPE       2
87 #define USE_FLOPPY_DISK         2
88 #define USE_TAPE                1
89 #define TAPE_BINARY_ONLY
90 #if defined(SUPPORT_PC88_CDROM)
91 #define USE_COMPACT_DISC        1
92 #endif
93 #define USE_KEY_LOCKED
94 // slow enough for N88-\93ú\96{\8cêBASIC
95 #define USE_AUTO_KEY            8
96 #define USE_AUTO_KEY_RELEASE    10
97 #define USE_AUTO_KEY_NUMPAD
98 #define USE_MONITOR_TYPE        2
99 #define USE_SCREEN_FILTER
100 #define USE_SCANLINE
101 #ifdef SUPPORT_PC88_OPNA
102 #ifdef SUPPORT_PC88_SB2
103 #define USE_SOUND_TYPE          6
104 #else
105 #define USE_SOUND_TYPE          2
106 #endif
107 #endif
108
109 #undef _SOUNDS_OPN
110 #undef _SOUNDS_SB2
111 #undef _SOUNDS_PCG8100
112 #undef _SOUNDS_CDROM
113 #undef _SOUNDS_HMB20
114 #undef _SOUNDS_BEEP
115 #undef _SOUNDS_NOISE
116
117 #if defined(SUPPORT_PC88_OPNA)
118         #define _SOUNDS_OPN 4
119 #else /* ToDo: PC8001 without OPN/OPNA */
120         #define _SOUNDS_OPN 2
121 #endif
122 #if defined(SUPPORT_PC88_SB2)
123         #if defined(SUPPORT_PC88_OPNA)
124         #define _SOUNDS_SB2 4
125         #else /* SB2=OPN */
126         #define _SOUNDS_SB2 2
127         #endif
128 #else /* Have not SB2 */
129         #define _SOUNDS_SB2 0
130 #endif
131 #if defined(SUPPORT_PC88_PCG8100)
132         #define _SOUNDS_PCG8100 1
133 #else
134         #define _SOUNDS_PCG8100 0
135 #endif
136 #if defined(SUPPORT_PC88_CDROM)
137         #define _SOUNDS_CDROM 1
138 #else
139         #define _SOUNDS_CDROM 0
140 #endif
141 #if defined(SUPPORT_PC88_HMB20)
142         #define _SOUNDS_HMB20 1
143 #else
144         #define _SOUNDS_HMB20 0
145 #endif
146 #define _SOUNDS_BEEP 1
147 #define _SOUNDS_NOISE 1
148
149 #define USE_SOUND_VOLUME (_SOUNDS_OPN + _SOUNDS_SB2 + _SOUNDS_PCG8100 + _SOUNDS_CDROM + _SOUNDS_HMB20 + _SOUNDS_BEEP + _SOUNDS_NOISE)
150
151
152 #define SUPPORT_TV_RENDER
153 #define USE_JOYSTICK
154 #define USE_MOUSE
155 #define USE_PRINTER
156 #define USE_PRINTER_TYPE        3
157 #define USE_DEBUGGER
158 #define USE_STATE
159 #define USE_CPU_Z80
160
161 #include "../../common.h"
162 #include "../../fileio.h"
163 #include "../vm_template.h"
164
165 #ifdef USE_SOUND_VOLUME
166 static const _TCHAR *sound_device_caption[USE_SOUND_VOLUME] = {
167 #ifdef SUPPORT_PC88_OPNA
168         _T("OPNA (FM)"), _T("OPNA (PSG)"), _T("OPNA (ADPCM)"), _T("OPNA (Rhythm)"),
169 #else
170         _T("OPN (FM)"), _T("OPN (PSG)"),
171 #endif
172 #ifdef SUPPORT_PC88_SB2
173 #ifdef SUPPORT_PC88_OPNA
174         _T("SB2 (FM)"), _T("SB2 (PSG)"), _T("SB2 (ADPCM)"), _T("SB2 (Rhythm)"),
175 #else
176         _T("SB2 (FM)"), _T("SB2 (PSG)"),
177 #endif
178 #endif
179 #ifdef SUPPORT_PC88_CDROM
180         _T("CD-DA"),
181 #endif
182 #ifdef SUPPORT_PC88_HMB20
183         _T("HMB-20"),
184 #endif
185 #ifdef SUPPORT_PC88_PCG8100
186         _T("PCG-8100"),
187 #endif
188         _T("Beep"), _T("Noise (FDD)"),
189 };
190 #endif
191
192 class EMU;
193 class DEVICE;
194 class EVENT;
195
196 class I8251;
197 class I8255;
198 class NOISE;
199 class PCM1BIT;
200 class UPD1990A;
201 class YM2203;
202 class Z80;
203
204 class PC80S31K;
205 class UPD765A;
206
207 #ifdef SUPPORT_PC88_CDROM
208 class SCSI_HOST;
209 class SCSI_CDROM;
210 #endif
211
212 #ifdef SUPPORT_PC88_HMB20
213 class YM2151;
214 #endif
215
216 #ifdef SUPPORT_PC88_PCG8100
217 class I8253;
218 #endif
219 namespace PC88DEV {
220         class PC88;
221 }
222 class VM : public VM_TEMPLATE
223 {
224 protected:
225         //EMU* emu;
226         //csp_state_utils* state_entry;
227         
228         // devices
229         EVENT* pc88event;
230         
231         DEVICE* pc88prn;
232         I8251* pc88sio;
233         I8255* pc88pio;
234         PCM1BIT* pc88pcm;
235         UPD1990A* pc88rtc;
236         YM2203* pc88opn;
237 #ifdef SUPPORT_PC88_SB2
238         YM2203* pc88sb2;
239 #endif
240         DEVICE* dummycpu;
241         Z80* pc88cpu;
242         
243         PC80S31K* pc88sub;
244         I8255* pc88pio_sub;
245         UPD765A* pc88fdc_sub;
246         NOISE* pc88noise_seek;
247         NOISE* pc88noise_head_down;
248         NOISE* pc88noise_head_up;
249         Z80* pc88cpu_sub;
250
251 #ifdef SUPPORT_PC88_CDROM
252         SCSI_HOST* pc88scsi_host;
253         SCSI_CDROM* pc88scsi_cdrom;
254 #endif
255
256 #ifdef SUPPORT_PC88_HMB20
257         YM2151* pc88opm;
258 #endif
259         
260 #ifdef SUPPORT_PC88_PCG8100
261         I8253* pc88pit;
262         PCM1BIT* pc88pcm0;
263         PCM1BIT* pc88pcm1;
264         PCM1BIT* pc88pcm2;
265 #endif
266         
267         PC88DEV::PC88* pc88;
268         
269         int boot_mode;
270         
271 public:
272         // ----------------------------------------
273         // initialize
274         // ----------------------------------------
275         
276         VM(EMU* parent_emu);
277         ~VM();
278         
279         // ----------------------------------------
280         // for emulation class
281         // ----------------------------------------
282         
283         // drive virtual machine
284         void reset();
285         void run();
286         double get_frame_rate();
287         
288 #ifdef USE_DEBUGGER
289         // debugger
290         DEVICE *get_cpu(int index);
291 #endif
292         
293         // draw screen
294         void draw_screen();
295         
296         // sound generation
297         void initialize_sound(int rate, int samples);
298         uint16_t* create_sound(int* extra_frames);
299         int get_sound_buffer_ptr();
300 #ifdef USE_SOUND_VOLUME
301         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
302 #endif
303         
304         // notify key
305         void key_down(int code, bool repeat);
306         void key_up(int code);
307         bool get_caps_locked();
308         bool get_kana_locked();
309         
310         // user interface
311         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
312         void close_floppy_disk(int drv);
313         bool is_floppy_disk_inserted(int drv);
314         void is_floppy_disk_protected(int drv, bool value);
315         bool is_floppy_disk_protected(int drv);
316         uint32_t is_floppy_disk_accessed();
317         void play_tape(int drv, const _TCHAR* file_path);
318         void rec_tape(int drv, const _TCHAR* file_path);
319         void close_tape(int drv);
320         bool is_tape_inserted(int drv);
321 #ifdef SUPPORT_PC88_CDROM
322         void open_compact_disc(int drv, const _TCHAR* file_path);
323         void close_compact_disc(int drv);
324         bool is_compact_disc_inserted(int drv);
325         uint32_t is_compact_disc_accessed();
326 #endif
327         bool is_frame_skippable();
328         
329         void update_config();
330         bool process_state(FILEIO* state_fio, bool loading);
331         
332         // ----------------------------------------
333         // for each device
334         // ----------------------------------------
335         
336         // devices
337         DEVICE* get_device(int id);
338         //DEVICE* dummy;
339         //DEVICE* first_device;
340         //DEVICE* last_device;
341 };
342
343 #endif