OSDN Git Service

ac8e56f3cc6bca7961bbca93b9b30f87ed37c1e2
[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 # ifndef _CONFIGURE_WITH_CMAKE
37 #  define SUPPORT_PC88_SB2
38 #  define SUPPORT_PC88_OPNA
39 #  define PC88_EXRAM_BANKS      4
40 # endif
41 #define HAS_UPD4990A
42 #endif
43 #define SUPPORT_PC88_JOYSTICK
44 # ifndef _CONFIGURE_WITH_CMAKE
45 #  define SUPPORT_PC88_PCG8100
46 # endif
47 // device informations for virtual machine
48 #define FRAMES_PER_SEC          62.422
49 #define LINES_PER_FRAME         260
50 #define CPU_CLOCKS              3993624
51 #define SCREEN_WIDTH            640
52 #define SCREEN_HEIGHT           400
53 #define MAX_DRIVE               2
54 #define UPD765A_NO_ST1_EN_OR_FOR_RESULT7
55 #if defined(_PC8801MA)
56 #define PC80S31K_NO_WAIT
57 #endif
58 #ifdef SUPPORT_PC88_OPNA
59 #define HAS_YM2608
60 #endif
61 #define Z80_MEMORY_WAIT
62 #define OVERRIDE_SOUND_FREQ_48000HZ     55467
63 #define SUPPORT_VARIABLE_TIMING
64
65 // 4:3
66 #define SCREEN_WIDTH_ASPECT 640 
67 #define SCREEN_HEIGHT_ASPECT 400
68 #define WINDOW_WIDTH_ASPECT 640 
69 #define WINDOW_HEIGHT_ASPECT 480
70 // device informations for win32
71 // device informations for win32
72 #if defined(_PC8001SR)
73 #define USE_BOOT_MODE           3
74 #define USE_CPU_TYPE            2
75 #else
76 #define USE_BOOT_MODE           4
77 #define USE_CPU_TYPE            3
78 #endif
79 #if defined(_PC8801MA)
80 // V2 mode, 4MHz
81 #define BOOT_MODE_DEFAULT       2
82 #define CPU_TYPE_DEFAULT        1
83 #endif
84 #define USE_DIPSWITCH
85 #define USE_DEVICE_TYPE         2
86 #define USE_FD1
87 #define USE_FD2
88 #define USE_TAPE
89 #define USE_TAPE_PTR
90 #define TAPE_BINARY_ONLY
91 #define NOTIFY_KEY_DOWN
92 #define USE_SHIFT_NUMPAD_KEY
93 #define USE_ALT_F10_KEY
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_MONITOR_TYPE        2
98 #define USE_CRT_FILTER
99 #define USE_SCANLINE
100 #define USE_ACCESS_LAMP
101 #define USE_DISK_WRITE_PROTECT
102
103 #ifdef SUPPORT_PC88_SB2
104 #  define USE_SOUND_DEVICE_TYPE 3
105 #elif defined(SUPPORT_PC88_OPNA)
106 #  define USE_SOUND_DEVICE_TYPE 2
107 #endif
108
109 #if defined(DATAREC_SOUND)
110 # if defined(SUPPORT_PC88_OPNA)
111 #  define USE_MULTIPLE_SOUNDCARDS 3
112 # else
113 #  define USE_MULTIPLE_SOUNDCARDS 2
114 # endif
115 #else
116 # if defined(SUPPORT_PC88_OPNA)
117 #  define USE_MULTIPLE_SOUNDCARDS 2
118 # else
119 #  define USE_MULTIPLE_SOUNDCARDS 1
120 # endif
121 #endif
122 //#define USE_DEBUGGER
123 #define USE_STATE
124
125 #include "../../common.h"
126 #include "../../fileio.h"
127
128 class EMU;
129 class DEVICE;
130 class EVENT;
131
132 class I8251;
133 class I8255;
134 class PCM1BIT;
135 class UPD1990A;
136 class YM2203;
137 class Z80;
138
139 class PC80S31K;
140 class UPD765A;
141
142 #ifdef SUPPORT_PC88_PCG8100
143 class I8253;
144 #endif
145
146 class PC88;
147
148 class VM
149 {
150 protected:
151         EMU* emu;
152         
153         // devices
154         EVENT* pc88event;
155         
156         I8251* pc88sio;
157         I8255* pc88pio;
158         PCM1BIT* pc88pcm;
159         UPD1990A* pc88rtc;
160         YM2203* pc88opn;
161 #ifdef SUPPORT_PC88_SB2
162         YM2203* pc88sb2;
163 #endif
164         Z80* pc88cpu;
165         DEVICE *dummycpu;
166    
167         PC80S31K* pc88sub;
168         I8255* pc88pio_sub;
169         UPD765A* pc88fdc_sub;
170         Z80* pc88cpu_sub;
171         
172 #ifdef SUPPORT_PC88_PCG8100
173         I8253* pc88pit;
174         PCM1BIT* pc88pcm0;
175         PCM1BIT* pc88pcm1;
176         PCM1BIT* pc88pcm2;
177 #endif
178         
179         PC88* pc88;
180         
181         int boot_mode;
182         
183 public:
184         // ----------------------------------------
185         // initialize
186         // ----------------------------------------
187         
188         VM(EMU* parent_emu);
189         ~VM();
190         
191         // ----------------------------------------
192         // for emulation class
193         // ----------------------------------------
194         
195         // drive virtual machine
196         void reset();
197         void run();
198         double frame_rate();
199         
200 #ifdef USE_DEBUGGER
201         // debugger
202         DEVICE *get_cpu(int index);
203 #endif
204         
205         // draw screen
206         void draw_screen();
207         int access_lamp();
208         
209         // sound generation
210         void initialize_sound(int rate, int samples);
211         uint16* create_sound(int* extra_frames);
212         int sound_buffer_ptr();
213         
214         // notify key
215         void key_down(int code, bool repeat);
216         void key_up(int code);
217         
218         // user interface
219         void open_disk(int drv, _TCHAR* file_path, int bank);
220         void close_disk(int drv);
221         bool disk_inserted(int drv);
222         void play_tape(_TCHAR* file_path);
223         void rec_tape(_TCHAR* file_path);
224         void close_tape();
225         bool tape_inserted();
226         bool now_skip();
227         
228         void update_config();
229         void save_state(FILEIO* state_fio);
230         bool load_state(FILEIO* state_fio);
231 #if defined(USE_TAPE_PTR)
232         int  get_tape_ptr();
233 #endif
234 #if defined(USE_DISK_WRITE_PROTECT)
235         void write_protect_fd(int drv, bool flag);
236         bool is_write_protect_fd(int drv);
237 #endif  
238         // ----------------------------------------
239         // for each device
240         // ----------------------------------------
241         
242         // devices
243         DEVICE* get_device(int id);
244         DEVICE* dummy;
245         DEVICE* first_device;
246         DEVICE* last_device;
247 };
248
249 #endif