OSDN Git Service

[VM][STATE] Use namespace {VMNAME} to separate per 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_CART                1
80 #if defined(_PC6601) || defined(_PC6601SR)
81 #define USE_FLOPPY_DISK         4
82 #else
83 #define USE_FLOPPY_DISK         2
84 #endif
85 #define USE_TAPE                1
86 #define USE_TAPE_BUTTON
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_SCREEN_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_PRINTER_TYPE        3
106 #define USE_DEBUGGER
107 #define USE_STATE
108 #define USE_CPU_MCS48
109 #define USE_CPU_Z80
110
111 #include "../../common.h"
112 #include "../../fileio.h"
113 #include "../vm_template.h"
114
115 #ifdef USE_SOUND_VOLUME
116 static const _TCHAR *sound_device_caption[] = {
117         _T("PSG"),
118 #if !defined(_PC6001)
119         _T("Voice"),
120 #endif
121         _T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"),
122 };
123 #endif
124 class EMU;
125 class DEVICE;
126 class EVENT;
127
128 class I8255;
129 class IO;
130 #ifdef _PC6001
131 class MC6847;
132 #else
133 class UPD7752;
134 #endif
135 class NOISE;
136 class PC6031;
137 class PC80S31K;
138 class UPD765A;
139 #if defined(_PC6001MK2SR) || defined(_PC6601SR)
140 class YM2203;
141 #else
142 class AY_3_891X;
143 #endif
144 class Z80;
145
146 class DATAREC;
147 class MCS48;
148
149 #ifdef _PC6001
150 namespace PC6001 {
151         class DISPLAY;
152 }
153 #endif
154 #if defined(_PC6601) || defined(_PC6601SR)
155 namespace PC6001 {
156         class FLOPPY;
157 }
158 #endif
159
160 namespace PC6001 {
161         class JOYSTICK;
162         class MEMORY;
163         class PSUB;
164         class SUB;
165         class TIMER;
166 }
167
168 class VM : public VM_TEMPLATE
169 {
170 protected:
171         //EMU* emu;
172
173         int vdata;
174         
175         // devices
176         //EVENT* event;
177         
178         DEVICE* printer;
179         I8255* pio_sub;
180         IO* io;
181         NOISE* noise_seek;
182         NOISE* noise_head_down;
183         NOISE* noise_head_up;
184 #if defined(_PC6001MK2SR) || defined(_PC6601SR)
185         YM2203* psg;
186 #else
187         AY_3_891X* psg;
188 #endif
189         Z80* cpu;
190 #ifdef _PC6001
191         MC6847* vdp;
192         PC6001::DISPLAY* display;
193 #else
194         UPD7752* voice;
195 #endif
196 #if defined(_PC6601) || defined(_PC6601SR)
197         PC6001::FLOPPY* floppy;
198 #endif
199         PC6001::JOYSTICK* joystick;
200         PC6001::MEMORY* memory;
201         PC6001::PSUB* psub;
202         PC6001::TIMER* timer;
203         
204         MCS48* cpu_sub;
205         PC6001::SUB* sub;
206         DATAREC* drec;
207         
208         PC6031* pc6031;
209         I8255* pio_fdd;
210         I8255* pio_pc80s31k;
211         PC80S31K *pc80s31k;
212         UPD765A* fdc_pc80s31k;
213         Z80* cpu_pc80s31k;
214         
215         bool support_sub_cpu;
216         bool support_pc80s31k;
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         
234 #ifdef USE_DEBUGGER
235         // debugger
236         DEVICE *get_cpu(int index);
237 #endif
238         
239         // draw screen
240         void draw_screen();
241         
242         // sound generation
243         void initialize_sound(int rate, int samples);
244         uint16_t* create_sound(int* extra_frames);
245         int get_sound_buffer_ptr();
246 #ifdef USE_SOUND_VOLUME
247         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
248 #endif
249         
250         // notify key
251         void key_down(int code, bool repeat);
252         void key_up(int code);
253         
254         // user interface
255         void open_cart(int drv, const _TCHAR* file_path);
256         void close_cart(int drv);
257         bool is_cart_inserted(int drv);
258         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
259         void close_floppy_disk(int drv);
260         bool is_floppy_disk_inserted(int drv);
261         void is_floppy_disk_protected(int drv, bool value);
262         bool is_floppy_disk_protected(int drv);
263         uint32_t is_floppy_disk_accessed();
264         void play_tape(int drv, const _TCHAR* file_path);
265         void rec_tape(int drv, const _TCHAR* file_path);
266         void close_tape(int drv);
267         bool is_tape_inserted(int drv);
268         bool is_tape_playing(int drv);
269         bool is_tape_recording(int drv);
270         int get_tape_position(int drv);
271         const _TCHAR* get_tape_message(int drv);
272         void push_play(int drv);
273         void push_stop(int drv);
274         void push_fast_forward(int drv);
275         void push_fast_rewind(int drv);
276         void push_apss_forward(int drv) {}
277         void push_apss_rewind(int drv) {}
278         bool is_frame_skippable();
279         
280         void update_config();
281         bool process_state(FILEIO* state_fio, bool loading);
282         
283         // ----------------------------------------
284         // for each device
285         // ----------------------------------------
286         
287         // devices
288         DEVICE* get_device(int id);
289         //DEVICE* dummy;
290         //DEVICE* first_device;
291         //DEVICE* last_device;
292         
293         int sr_mode;
294 };
295 #endif