OSDN Git Service

[General] Merge Updtream 2017-03-15 . Still not build all of VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc6001 / pc6001.h
1 /*
2         NEC PC-6001 Emulator 'yaPC-6001'
3         NEC PC-6001mkII Emulator 'yaPC-6201'
4         NEC PC-6001mkIISR Emulator 'yaPC-6401'
5         NEC PC-6601 Emulator 'yaPC-6601'
6         NEC PC-6601SR Emulator 'yaPC-6801'
7
8         Author : tanam
9         Date   : 2013.07.15-
10
11         [ virtual machine ]
12 */
13
14 #ifndef _PC6001_H_
15 #define _PC6001_H_
16
17 #if defined(_PC6001)
18 #define DEVICE_NAME             "NEC PC-6001"
19 #define CONFIG_NAME             "pc6001"
20 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.60"
21 #define SCREEN_WIDTH            256
22 #define SCREEN_HEIGHT           192
23 #define CPU_CLOCKS              3993600
24 #define HAS_AY_3_8910
25 #elif defined(_PC6001MK2)
26 #define DEVICE_NAME             "NEC PC-6001mkII"
27 #define CONFIG_NAME             "pc6001mk2"
28 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.62"
29 #define SCREEN_WIDTH            640
30 #define SCREEN_HEIGHT           400
31 #define WINDOW_HEIGHT_ASPECT    480
32 #define CPU_CLOCKS              4000000
33 #define HAS_AY_3_8910
34 #elif defined(_PC6001MK2SR)
35 #define DEVICE_NAME             "NEC PC-6001mkIISR"
36 #define CONFIG_NAME             "pc6001mk2sr"
37 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.68"
38 #define SCREEN_WIDTH            640
39 #define SCREEN_HEIGHT           400
40 #define WINDOW_HEIGHT_ASPECT    480
41 #define CPU_CLOCKS              3580000
42 #elif defined(_PC6601)
43 #define DEVICE_NAME             "NEC PC-6601"
44 #define CONFIG_NAME             "pc6601"
45 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.66"
46 #define SCREEN_WIDTH            640
47 #define SCREEN_HEIGHT           400
48 #define WINDOW_HEIGHT_ASPECT    480
49 #define CPU_CLOCKS              4000000
50 #define HAS_AY_3_8910
51 #elif defined(_PC6601SR)
52 #define DEVICE_NAME             "NEC PC-6601SR"
53 #define CONFIG_NAME             "pc6601sr"
54 #define SUB_CPU_1_ROM_FILE_NAME "SUBCPU1.68"
55 #define SUB_CPU_2_ROM_FILE_NAME "SUBCPU2.68"
56 #define SUB_CPU_3_ROM_FILE_NAME "SUBCPU3.68"
57 #define SCREEN_WIDTH            640
58 #define SCREEN_HEIGHT           400
59 #define WINDOW_HEIGHT_ASPECT    480
60 #define CPU_CLOCKS              3580000
61 #endif
62
63 // device informations for virtual machine
64 #define FRAMES_PER_SEC          60
65 #define LINES_PER_FRAME         262
66 #define MAX_DRIVE               4
67 #define MC6847_ATTR_OFS         0
68 #define MC6847_VRAM_OFS         0x200
69 #define MC6847_ATTR_AG          0x80
70 #define MC6847_ATTR_AS          0x40
71 #define MC6847_ATTR_INTEXT      0x20
72 #define MC6847_ATTR_GM0         0x10
73 #define MC6847_ATTR_GM1         0x08
74 #define MC6847_ATTR_GM2         0x04
75 #define MC6847_ATTR_CSS         0x02
76 #define MC6847_ATTR_INV         0x01
77
78 // device informations for win32
79 #define USE_CART1
80 #define USE_FD1
81 #define USE_FD2
82 #if defined(_PC6601) || defined(_PC6601SR)
83 #define USE_FD3
84 #define USE_FD4
85 #endif
86 #define USE_TAPE
87 #define TAPE_PC6001
88 #define NOTIFY_KEY_DOWN
89 #define USE_SHIFT_NUMPAD_KEY
90 #define USE_ALT_F10_KEY
91 #define USE_AUTO_KEY            6
92 #define USE_AUTO_KEY_RELEASE    10
93 #define USE_AUTO_KEY_CAPS
94 #if !defined(_PC6001)
95 #define USE_CRT_FILTER
96 #define USE_SCANLINE
97 #endif
98 #if defined(_PC6001)
99 #define USE_SOUND_VOLUME        4
100 #else
101 #define USE_SOUND_VOLUME        5
102 #endif
103 #define USE_JOYSTICK
104 #define USE_PRINTER
105 #define USE_DEBUGGER
106 #define USE_STATE
107
108 #include "../../common.h"
109 #include "../../fileio.h"
110
111 #ifdef USE_SOUND_VOLUME
112 static const _TCHAR *sound_device_caption[] = {
113         _T("PSG"),
114 #if !defined(_PC6001)
115         _T("Voice"),
116 #endif
117         _T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"),
118 };
119 #endif
120
121 class EMU;
122 class DEVICE;
123 class EVENT;
124
125 class I8255;
126 class IO;
127 #ifdef _PC6001
128 class MC6847;
129 #else
130 class UPD7752;
131 #endif
132 class NOISE;
133 class PC6031;
134 class PC80S31K;
135 class UPD765A;
136 #if defined(_PC6001MK2SR) || defined(_PC6601SR)
137 class YM2203;
138 #else
139 class AY_3_891X;
140 #endif
141 class Z80;
142
143 class DATAREC;
144 class MCS48;
145
146 #ifdef _PC6001
147 class DISPLAY;
148 #endif
149 #if defined(_PC6601) || defined(_PC6601SR)
150 class FLOPPY;
151 #endif
152 class JOYSTICK;
153 class MEMORY;
154 class PSUB;
155 class SUB;
156 class TIMER;
157
158 class VM
159 {
160 protected:
161         EMU* emu;
162         int vdata;
163         
164         // devices
165         EVENT* event;
166         
167         DEVICE* printer;
168         I8255* pio_sub;
169         IO* io;
170         NOISE* noise_seek;
171         NOISE* noise_head_down;
172         NOISE* noise_head_up;
173 #if defined(_PC6001MK2SR) || defined(_PC6601SR)
174         YM2203* psg;
175 #else
176         AY_3_891X* psg;
177 #endif
178         Z80* cpu;
179 #ifdef _PC6001
180         MC6847* vdp;
181         DISPLAY* display;
182 #else
183         UPD7752* voice;
184 #endif
185 #if defined(_PC6601) || defined(_PC6601SR)
186         FLOPPY* floppy;
187 #endif
188         JOYSTICK* joystick;
189         MEMORY* memory;
190         PSUB* psub;
191         TIMER* timer;
192         
193         MCS48* cpu_sub;
194         SUB* sub;
195         DATAREC* drec;
196         
197         PC6031* pc6031;
198         I8255* pio_fdd;
199         I8255* pio_pc80s31k;
200         PC80S31K *pc80s31k;
201         UPD765A* fdc_pc80s31k;
202         Z80* cpu_pc80s31k;
203         
204         bool support_sub_cpu;
205         bool support_pc80s31k;
206         
207 public:
208         // ----------------------------------------
209         // initialize
210         // ----------------------------------------
211         
212         VM(EMU* parent_emu);
213         ~VM();
214         
215         // ----------------------------------------
216         // for emulation class
217         // ----------------------------------------
218         
219         // drive virtual machine
220         void reset();
221         void run();
222         
223 #ifdef USE_DEBUGGER
224         // debugger
225         DEVICE *get_cpu(int index);
226 #endif
227         
228         // draw screen
229         void draw_screen();
230         
231         // sound generation
232         void initialize_sound(int rate, int samples);
233         uint16_t* create_sound(int* extra_frames);
234         int get_sound_buffer_ptr();
235 #ifdef USE_SOUND_VOLUME
236         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
237 #endif
238         
239         // notify key
240         void key_down(int code, bool repeat);
241         void key_up(int code);
242         
243         // user interface
244         void open_cart(int drv, const _TCHAR* file_path);
245         void close_cart(int drv);
246         bool is_cart_inserted(int drv);
247         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
248         void close_floppy_disk(int drv);
249         bool is_floppy_disk_inserted(int drv);
250         void is_floppy_disk_protected(int drv, bool value);
251         bool is_floppy_disk_protected(int drv);
252         uint32_t is_floppy_disk_accessed();
253         void play_tape(const _TCHAR* file_path);
254         void rec_tape(const _TCHAR* file_path);
255         void close_tape();
256         bool is_tape_inserted();
257         bool is_tape_playing();
258         bool is_tape_recording();
259         int get_tape_position();
260         const _TCHAR* get_tape_message();
261         bool is_frame_skippable();
262         
263         void update_config();
264         void save_state(FILEIO* state_fio);
265         bool load_state(FILEIO* state_fio);
266         
267         // ----------------------------------------
268         // for each device
269         // ----------------------------------------
270         
271         // devices
272         DEVICE* get_device(int id);
273         DEVICE* dummy;
274         DEVICE* first_device;
275         DEVICE* last_device;
276         
277         int sr_mode;
278 };
279 #endif