OSDN Git Service

a7d847975ac04795855c09d7976de8a41777f5d6
[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 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 WINDOW_HEIGHT_ASPECT    480
51 #define MAX_DRIVE               2
52 #define UPD765A_NO_ST1_EN_OR_FOR_RESULT7
53 #if defined(_PC8801MA)
54 #define PC80S31K_NO_WAIT
55 #endif
56 #if defined(SUPPORT_PC88_OPNA) || defined(SUPPORT_PC88_SB2)
57 #define HAS_YM2608
58 #endif
59 #define Z80_MEMORY_WAIT
60 #define OVERRIDE_SOUND_FREQ_48000HZ     55467
61 #define SUPPORT_VARIABLE_TIMING
62
63 // device informations for win32
64 #if defined(_PC8001SR)
65 #define USE_BOOT_MODE           3
66 #define USE_CPU_TYPE            2
67 #else
68 #define USE_BOOT_MODE           4
69 #define USE_CPU_TYPE            3
70 #endif
71 #if defined(_PC8801MA)
72 // V2 mode, 4MHz
73 #define BOOT_MODE_DEFAULT       2
74 #define CPU_TYPE_DEFAULT        1
75 #endif
76 #define USE_DIPSWITCH
77 #define USE_JOYSTICK_TYPE       2
78 #define USE_FLOPPY_DISK         2
79 #define USE_TAPE                1
80 #define TAPE_BINARY_ONLY
81 #define NOTIFY_KEY_DOWN
82 #define USE_KEY_LOCKED
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_AUTO_KEY_NUMPAD
89 #define USE_MONITOR_TYPE        2
90 #define USE_SCREEN_FILTER
91 #define USE_SCANLINE
92 #ifdef SUPPORT_PC88_OPNA
93 #ifdef SUPPORT_PC88_SB2
94 #define USE_SOUND_TYPE          6
95 #else
96 #define USE_SOUND_TYPE          2
97 #endif
98 #endif
99 #if    defined(SUPPORT_PC88_OPNA) &&  defined(SUPPORT_PC88_SB2) &&  defined(SUPPORT_PC88_PCG8100)
100 #define USE_SOUND_VOLUME        (4 + 4 + 1 + 1 + 1)
101 #elif  defined(SUPPORT_PC88_OPNA) &&  defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
102 #define USE_SOUND_VOLUME        (4 + 4 + 0 + 1 + 1)
103 #elif  defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) &&  defined(SUPPORT_PC88_PCG8100)
104 #define USE_SOUND_VOLUME        (4 + 0 + 1 + 1 + 1)
105 #elif  defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
106 #define USE_SOUND_VOLUME        (4 + 0 + 0 + 1 + 1)
107 #elif !defined(SUPPORT_PC88_OPNA) &&  defined(SUPPORT_PC88_SB2) &&  defined(SUPPORT_PC88_PCG8100)
108 #define USE_SOUND_VOLUME        (2 + 2 + 1 + 1 + 1)
109 #elif !defined(SUPPORT_PC88_OPNA) &&  defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
110 #define USE_SOUND_VOLUME        (2 + 2 + 0 + 1 + 1)
111 #elif !defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) &&  defined(SUPPORT_PC88_PCG8100)
112 #define USE_SOUND_VOLUME        (2 + 0 + 1 + 1 + 1)
113 #elif !defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
114 #define USE_SOUND_VOLUME        (2 + 0 + 0 + 1 + 1)
115 #endif
116
117 #define SUPPORT_TV_RENDER
118 #define USE_JOYSTICK
119 #define USE_MOUSE
120 #define USE_PRINTER
121 #define USE_PRINTER_TYPE        3
122 #define USE_DEBUGGER
123 #define USE_STATE
124 #define USE_CPU_Z80
125
126 #include "../../common.h"
127 #include "../../fileio.h"
128 #include "../vm_template.h"
129
130 #ifdef USE_SOUND_VOLUME
131 static const _TCHAR *sound_device_caption[] = {
132 #ifdef SUPPORT_PC88_OPNA
133         _T("OPNA (FM)"), _T("OPNA (PSG)"), _T("OPNA (ADPCM)"), _T("OPNA (Rhythm)"),
134 #else
135         _T("OPN (FM)"), _T("OPN (PSG)"),
136 #endif
137 #ifdef SUPPORT_PC88_SB2
138 #ifdef SUPPORT_PC88_OPNA
139         _T("SB2 (FM)"), _T("SB2 (PSG)"), _T("SB2 (ADPCM)"), _T("SB2 (Rhythm)"),
140 #else
141         _T("SB2 (FM)"), _T("SB2 (PSG)"),
142 #endif
143 #endif
144 #ifdef SUPPORT_PC88_PCG8100
145         _T("PCG-8100"),
146 #endif
147         _T("Beep"), _T("Noise (FDD)"),
148 };
149 #endif
150
151 class EMU;
152 class DEVICE;
153 class EVENT;
154
155 class I8251;
156 class I8255;
157 class NOISE;
158 class PCM1BIT;
159 class UPD1990A;
160 class YM2203;
161 class Z80;
162
163 class PC80S31K;
164 class UPD765A;
165
166 #ifdef SUPPORT_PC88_PCG8100
167 class I8253;
168 #endif
169 namespace PC88DEV {
170         class PC88;
171 }
172 class VM : public VM_TEMPLATE
173 {
174 protected:
175         //EMU* emu;
176         //csp_state_utils* state_entry;
177         
178         // devices
179         EVENT* pc88event;
180         
181         DEVICE* pc88prn;
182         I8251* pc88sio;
183         I8255* pc88pio;
184         PCM1BIT* pc88pcm;
185         UPD1990A* pc88rtc;
186         YM2203* pc88opn;
187 #ifdef SUPPORT_PC88_SB2
188         YM2203* pc88sb2;
189 #endif
190         DEVICE* dummycpu;
191         Z80* pc88cpu;
192         
193         PC80S31K* pc88sub;
194         I8255* pc88pio_sub;
195         UPD765A* pc88fdc_sub;
196         NOISE* pc88noise_seek;
197         NOISE* pc88noise_head_down;
198         NOISE* pc88noise_head_up;
199         Z80* pc88cpu_sub;
200 #ifdef SUPPORT_PC88_PCG8100
201         I8253* pc88pit;
202         PCM1BIT* pc88pcm0;
203         PCM1BIT* pc88pcm1;
204         PCM1BIT* pc88pcm2;
205 #endif
206         
207         PC88DEV::PC88* pc88;
208         
209         int boot_mode;
210         
211 public:
212         // ----------------------------------------
213         // initialize
214         // ----------------------------------------
215         
216         VM(EMU* parent_emu);
217         ~VM();
218         
219         // ----------------------------------------
220         // for emulation class
221         // ----------------------------------------
222         
223         // drive virtual machine
224         void reset();
225         void run();
226         double get_frame_rate();
227         
228 #ifdef USE_DEBUGGER
229         // debugger
230         DEVICE *get_cpu(int index);
231 #endif
232         
233         // draw screen
234         void draw_screen();
235         
236         // sound generation
237         void initialize_sound(int rate, int samples);
238         uint16_t* create_sound(int* extra_frames);
239         int get_sound_buffer_ptr();
240 #ifdef USE_SOUND_VOLUME
241         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
242 #endif
243         
244         // notify key
245         void key_down(int code, bool repeat);
246         void key_up(int code);
247         bool get_caps_locked();
248         bool get_kana_locked();
249         
250         // user interface
251         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
252         void close_floppy_disk(int drv);
253         bool is_floppy_disk_inserted(int drv);
254         void is_floppy_disk_protected(int drv, bool value);
255         bool is_floppy_disk_protected(int drv);
256         uint32_t is_floppy_disk_accessed();
257         void play_tape(int drv, const _TCHAR* file_path);
258         void rec_tape(int drv, const _TCHAR* file_path);
259         void close_tape(int drv);
260         bool is_tape_inserted(int drv);
261         bool is_frame_skippable();
262         
263         void update_config();
264         bool process_state(FILEIO* state_fio, bool loading);
265         
266         // ----------------------------------------
267         // for each device
268         // ----------------------------------------
269         
270         // devices
271         DEVICE* get_device(int id);
272         //DEVICE* dummy;
273         //DEVICE* first_device;
274         //DEVICE* last_device;
275 };
276
277 #endif