OSDN Git Service

[VM][General] Merge upstream 2016-02-13. Still don't implement OSD/Gui part of joysti...
[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 CPU_CLOCKS              4000000
32 #define HAS_AY_3_8910
33 #elif defined(_PC6001MK2SR)
34 #define DEVICE_NAME             "NEC PC-6001mkIISR"
35 #define CONFIG_NAME             "pc6001mk2sr"
36 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.68"
37 #define SCREEN_WIDTH            640
38 #define SCREEN_HEIGHT           400
39 #define CPU_CLOCKS              3580000
40 #elif defined(_PC6601)
41 #define DEVICE_NAME             "NEC PC-6601"
42 #define CONFIG_NAME             "pc6601"
43 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.66"
44 #define SCREEN_WIDTH            640
45 #define SCREEN_HEIGHT           400
46 #define CPU_CLOCKS              4000000
47 #define HAS_AY_3_8910
48 #elif defined(_PC6601SR)
49 #define DEVICE_NAME             "NEC PC-6601SR"
50 #define CONFIG_NAME             "pc6601sr"
51 #define SUB_CPU_1_ROM_FILE_NAME "SUBCPU1.68"
52 #define SUB_CPU_2_ROM_FILE_NAME "SUBCPU2.68"
53 #define SUB_CPU_3_ROM_FILE_NAME "SUBCPU3.68"
54 #define SCREEN_WIDTH            640
55 #define SCREEN_HEIGHT           400
56 #define CPU_CLOCKS              3580000
57 #endif
58
59 // device informations for virtual machine
60 #define FRAMES_PER_SEC          60
61 #define LINES_PER_FRAME         262
62 #define MAX_DRIVE               4
63 #define MC6847_ATTR_OFS         0
64 #define MC6847_VRAM_OFS         0x200
65 #define MC6847_ATTR_AG          0x80
66 #define MC6847_ATTR_AS          0x40
67 #define MC6847_ATTR_INTEXT      0x20
68 #define MC6847_ATTR_GM0         0x10
69 #define MC6847_ATTR_GM1         0x08
70 #define MC6847_ATTR_GM2         0x04
71 #define MC6847_ATTR_CSS         0x02
72 #define MC6847_ATTR_INV         0x01
73
74 // device informations for win32
75 #define USE_CART1
76 #define USE_FD1
77 #define USE_FD2
78 #if defined(_PC6601) || defined(_PC6601SR)
79 #define USE_FD3
80 #define USE_FD4
81 #endif
82 #define USE_TAPE
83 //#define USE_TAPE_PTR
84 #define TAPE_PC6001
85 #define NOTIFY_KEY_DOWN
86 #define USE_SHIFT_NUMPAD_KEY
87 #define USE_ALT_F10_KEY
88 #define USE_AUTO_KEY            6
89 #define USE_AUTO_KEY_RELEASE    10
90 #define USE_AUTO_KEY_CAPS
91 #if !defined(_PC6001)
92 #define USE_CRT_FILTER
93 #define USE_SCANLINE
94 #endif
95 #define USE_ACCESS_LAMP
96 #if defined(_PC6001)
97 #define USE_SOUND_VOLUME        2
98 #else
99 #define USE_SOUND_VOLUME        3
100 #endif
101 #define USE_PRINTER
102 #define USE_DEBUGGER
103 #define USE_STATE
104 #define USE_JOYSTICK
105 #define USE_CRT_MONITOR_4_3 1
106 //#define USE_MOUSE
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"),
118 };
119 static const bool sound_device_monophonic[] = {
120         true,
121 #if !defined(_PC6001)
122         false,
123 #endif
124         false,
125 };
126 #endif
127
128 class EMU;
129 class DEVICE;
130 class EVENT;
131
132 class I8255;
133 class IO;
134 #ifdef _PC6001
135 class MC6847;
136 #else
137 class UPD7752;
138 #endif
139 class PC6031;
140 class PC80S31K;
141 class UPD765A;
142 class YM2203;
143 class Z80;
144
145 class DATAREC;
146 class MCS48;
147
148 #ifdef _PC6001
149 class DISPLAY;
150 #endif
151 #if defined(_PC6601) || defined(_PC6601SR)
152 class FLOPPY;
153 #endif
154 class JOYSTICK;
155 class MEMORY;
156 class PSUB;
157 class SUB;
158 class TIMER;
159
160 class VM
161 {
162 protected:
163         EMU* emu;
164         int vdata;
165         
166         // devices
167         EVENT* event;
168         
169         DEVICE* printer;
170         I8255* pio_sub;
171         IO* io;
172         YM2203* psg;
173         Z80* cpu;
174 #ifdef _PC6001
175         MC6847* vdp;
176         DISPLAY* display;
177 #else
178         UPD7752* voice;
179 #endif
180 #if defined(_PC6601) || defined(_PC6601SR)
181         FLOPPY* floppy;
182 #endif
183         JOYSTICK* joystick;
184         MEMORY* memory;
185         PSUB* psub;
186         TIMER* timer;
187         
188         MCS48* cpu_sub;
189         SUB* sub;
190         DATAREC* drec;
191         
192         PC6031* pc6031;
193         I8255* pio_fdd;
194         I8255* pio_pc80s31k;
195         PC80S31K *pc80s31k;
196         UPD765A* fdc_pc80s31k;
197         Z80* cpu_pc80s31k;
198         
199         bool support_sub_cpu;
200         bool support_pc80s31k;
201         
202 public:
203         // ----------------------------------------
204         // initialize
205         // ----------------------------------------
206         
207         VM(EMU* parent_emu);
208         ~VM();
209         
210         // ----------------------------------------
211         // for emulation class
212         // ----------------------------------------
213         
214         // drive virtual machine
215         void reset();
216         void run();
217         
218 #ifdef USE_DEBUGGER
219         // debugger
220         DEVICE *get_cpu(int index);
221 #endif
222         
223         // draw screen
224         void draw_screen();
225         
226         // sound generation
227         void initialize_sound(int rate, int samples);
228         uint16* create_sound(int* extra_frames);
229         int sound_buffer_ptr();
230 #ifdef USE_SOUND_VOLUME
231         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
232 #endif
233         
234         // notify key
235         void key_down(int code, bool repeat);
236         void key_up(int code);
237         
238         // user interface
239         void open_cart(int drv, const _TCHAR* file_path);
240         void close_cart(int drv);
241         bool cart_inserted(int drv);
242         int access_lamp();
243         void open_disk(int drv, const _TCHAR* file_path, int bank);
244         void close_disk(int drv);
245         bool disk_inserted(int drv);
246         void set_disk_protected(int drv, bool value);
247         bool get_disk_protected(int drv);
248         void play_tape(const _TCHAR* file_path);
249         void rec_tape(const _TCHAR* file_path);
250         void close_tape();
251         bool tape_inserted();
252         bool tape_playing();
253         bool tape_recording();
254         int tape_position();
255         bool now_skip();
256         
257         void update_config();
258         void save_state(FILEIO* state_fio);
259         bool load_state(FILEIO* state_fio);
260         
261         // ----------------------------------------
262         // for each device
263         // ----------------------------------------
264         
265         // devices
266         DEVICE* get_device(int id);
267         DEVICE* dummy;
268         DEVICE* first_device;
269         DEVICE* last_device;
270         
271         int sr_mode;
272 };
273 #endif