OSDN Git Service

[VM][SOUND][Qt] Remove USE_MULTIPLE_SPEAKER, using upstream's APIs.
[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_SB2
37 #define SUPPORT_PC88_OPNA
38 #define PC88_EXRAM_BANKS        4
39 #define HAS_UPD4990A
40 #endif
41 #define SUPPORT_PC88_JOYSTICK
42 #define SUPPORT_PC88_PCG8100
43
44 // device informations for virtual machine
45 #define FRAMES_PER_SEC          62.422
46 #define LINES_PER_FRAME         260
47 #define CPU_CLOCKS              3993624
48 #define SCREEN_WIDTH            640
49 #define SCREEN_HEIGHT           400
50 #define MAX_DRIVE               2
51 #define UPD765A_NO_ST1_EN_OR_FOR_RESULT7
52 #if defined(_PC8801MA)
53 #define PC80S31K_NO_WAIT
54 #endif
55 #if defined(SUPPORT_PC88_OPNA) || defined(SUPPORT_PC88_SB2)
56 #define HAS_YM2608
57 #endif
58 #define Z80_MEMORY_WAIT
59 #define OVERRIDE_SOUND_FREQ_48000HZ     55467
60 #define SUPPORT_VARIABLE_TIMING
61
62 // device informations for win32
63 #if defined(_PC8001SR)
64 #define USE_BOOT_MODE           3
65 #define USE_CPU_TYPE            2
66 #else
67 #define USE_BOOT_MODE           4
68 #define USE_CPU_TYPE            3
69 #endif
70 #if defined(_PC8801MA)
71 // V2 mode, 4MHz
72 #define BOOT_MODE_DEFAULT       2
73 #define CPU_TYPE_DEFAULT        1
74 #endif
75 #define USE_DIPSWITCH
76 #define USE_DEVICE_TYPE         2
77 #define USE_FD1
78 #define USE_FD2
79 #define USE_TAPE
80 //#define USE_TAPE_PTR
81 #define TAPE_BINARY_ONLY
82 #define NOTIFY_KEY_DOWN
83 #define USE_SHIFT_NUMPAD_KEY
84 #define USE_ALT_F10_KEY
85 // slow enough for N88-\93ú\96{\8cêBASIC
86 #define USE_AUTO_KEY            8
87 #define USE_AUTO_KEY_RELEASE    10
88 #define USE_MONITOR_TYPE        2
89 #define USE_CRT_FILTER
90 #define USE_SCANLINE
91 #define USE_SCREEN_ROTATE
92 #define USE_ACCESS_LAMP
93 #define USE_DISK_WRITE_PROTECT
94
95 #ifdef SUPPORT_PC88_OPNA
96   #ifdef SUPPORT_PC88_SB2
97     #define USE_SOUND_DEVICE_TYPE       3
98   #else
99     #define USE_SOUND_DEVICE_TYPE       2
100   #endif
101 #endif
102
103 #if    defined(SUPPORT_PC88_OPNA) &&  defined(SUPPORT_PC88_SB2) &&  defined(SUPPORT_PC88_PCG8100)
104 #define USE_SOUND_VOLUME        (4 + 4 + 1 + 1)
105 #elif  defined(SUPPORT_PC88_OPNA) &&  defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
106 #define USE_SOUND_VOLUME        (4 + 4 + 0 + 1)
107 #elif  defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) &&  defined(SUPPORT_PC88_PCG8100)
108 #define USE_SOUND_VOLUME        (4 + 0 + 1 + 1)
109 #elif  defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
110 #define USE_SOUND_VOLUME        (4 + 0 + 0 + 1)
111 #elif !defined(SUPPORT_PC88_OPNA) &&  defined(SUPPORT_PC88_SB2) &&  defined(SUPPORT_PC88_PCG8100)
112 #define USE_SOUND_VOLUME        (2 + 4 + 1 + 1)
113 #elif !defined(SUPPORT_PC88_OPNA) &&  defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
114 #define USE_SOUND_VOLUME        (2 + 4 + 0 + 1)
115 #elif !defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) &&  defined(SUPPORT_PC88_PCG8100)
116 #define USE_SOUND_VOLUME        (2 + 0 + 1 + 1)
117 #elif !defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
118 #define USE_SOUND_VOLUME        (2 + 0 + 0 + 1)
119 #endif
120 #define USE_PRINTER
121 #define USE_PRINTER_TYPE        4
122 #define USE_DEBUGGER
123 #define USE_STATE
124 #define USE_MOUSE
125 #define USE_JOYSTICK
126 #define USE_CRT_MONITOR_4_3 1
127
128 #include "../../common.h"
129 #include "../../fileio.h"
130
131 #ifdef USE_SOUND_VOLUME
132 static const _TCHAR *sound_device_caption[] = {
133 #ifdef SUPPORT_PC88_OPNA
134         _T("OPNA (FM)"), _T("OPNA (PSG)"), _T("OPNA (ADPCM)"), _T("OPNA (Rhythm)"),
135 #else
136         _T("OPN (FM)"), _T("OPN (PSG)"),
137 #endif
138 #ifdef SUPPORT_PC88_SB2
139         _T("SB2 (FM)"), _T("SB2 (PSG)"), _T("SB2 (ADPCM)"), _T("SB2 (Rhythm)"),
140 #endif
141 #ifdef SUPPORT_PC88_PCG8100
142         _T("PCG-8100"),
143 #endif
144         _T("Beep"),
145 };
146 static const bool sound_device_monophonic[] = {
147 #ifdef SUPPORT_PC88_OPNA
148         true, true, true, true,
149 #else
150         true, true,
151 #endif
152 #ifdef SUPPORT_PC88_SB2
153         true, true, true, true,
154 #endif
155 #ifdef SUPPORT_PC88_PCG8100
156         false,
157 #endif
158         false,
159 };
160 #endif
161
162 class EMU;
163 class DEVICE;
164 class EVENT;
165
166 class I8251;
167 class I8255;
168 class PCM1BIT;
169 class UPD1990A;
170 class YM2203;
171 class Z80;
172
173 class PC80S31K;
174 class UPD765A;
175
176 #ifdef SUPPORT_PC88_PCG8100
177 class I8253;
178 #endif
179
180 class PC88;
181
182 class VM
183 {
184 protected:
185         EMU* emu;
186         
187         // devices
188         EVENT* pc88event;
189         
190         DEVICE* pc88prn;
191         I8251* pc88sio;
192         I8255* pc88pio;
193         PCM1BIT* pc88pcm;
194         UPD1990A* pc88rtc;
195         YM2203* pc88opn;
196 #ifdef SUPPORT_PC88_SB2
197         YM2203* pc88sb2;
198 #endif
199         Z80* pc88cpu;
200         DEVICE *dummycpu;
201    
202         PC80S31K* pc88sub;
203         I8255* pc88pio_sub;
204         UPD765A* pc88fdc_sub;
205         Z80* pc88cpu_sub;
206         
207 #ifdef SUPPORT_PC88_PCG8100
208         I8253* pc88pit;
209         PCM1BIT* pc88pcm0;
210         PCM1BIT* pc88pcm1;
211         PCM1BIT* pc88pcm2;
212 #endif
213         
214         PC88* pc88;
215         
216         int boot_mode;
217         
218 public:
219         // ----------------------------------------
220         // initialize
221         // ----------------------------------------
222         
223         VM(EMU* parent_emu);
224         ~VM();
225         
226         // ----------------------------------------
227         // for emulation class
228         // ----------------------------------------
229         
230         // drive virtual machine
231         void reset();
232         void run();
233         double frame_rate();
234         
235 #ifdef USE_DEBUGGER
236         // debugger
237         DEVICE *get_cpu(int index);
238 #endif
239         
240         // draw screen
241         void draw_screen();
242         int access_lamp();
243         
244         // sound generation
245         void initialize_sound(int rate, int samples);
246         uint16* create_sound(int* extra_frames);
247         int sound_buffer_ptr();
248 #ifdef USE_SOUND_VOLUME
249         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
250 #endif
251         
252         // notify key
253         void key_down(int code, bool repeat);
254         void key_up(int code);
255         
256         // user interface
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         void play_tape(const _TCHAR* file_path);
263         void rec_tape(const _TCHAR* file_path);
264         void close_tape();
265         bool tape_inserted();
266         bool now_skip();
267         
268         void update_config();
269         void save_state(FILEIO* state_fio);
270         bool load_state(FILEIO* state_fio);
271         // ----------------------------------------
272         // for each device
273         // ----------------------------------------
274         
275         // devices
276         DEVICE* get_device(int id);
277         DEVICE* dummy;
278         DEVICE* first_device;
279         DEVICE* last_device;
280 };
281
282 #endif