OSDN Git Service

4f7fa0705ff083e9ba62a0569b42267d54636e52
[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
125 class csp_state_utils;
126 class EMU;
127 class DEVICE;
128 class EVENT;
129
130 class I8255;
131 class IO;
132 #ifdef _PC6001
133 class MC6847;
134 #else
135 class UPD7752;
136 #endif
137 class NOISE;
138 class PC6031;
139 class PC80S31K;
140 class UPD765A;
141 #if defined(_PC6001MK2SR) || defined(_PC6601SR)
142 class YM2203;
143 #else
144 class AY_3_891X;
145 #endif
146 class Z80;
147
148 class DATAREC;
149 class MCS48;
150
151 #ifdef _PC6001
152 class DISPLAY;
153 #endif
154 #if defined(_PC6601) || defined(_PC6601SR)
155 class FLOPPY;
156 #endif
157 class JOYSTICK;
158 class PC6001_MEMORY;
159 class PSUB;
160 class SUB;
161 class TIMER;
162
163 class VM : public VM_TEMPLATE
164 {
165 protected:
166         //EMU* emu;
167         //csp_state_utils *state_entry;
168
169         int vdata;
170         
171         // devices
172         //EVENT* event;
173         
174         DEVICE* printer;
175         I8255* pio_sub;
176         IO* io;
177         NOISE* noise_seek;
178         NOISE* noise_head_down;
179         NOISE* noise_head_up;
180 #if defined(_PC6001MK2SR) || defined(_PC6601SR)
181         YM2203* psg;
182 #else
183         AY_3_891X* psg;
184 #endif
185         Z80* cpu;
186 #ifdef _PC6001
187         MC6847* vdp;
188         DISPLAY* display;
189 #else
190         UPD7752* voice;
191 #endif
192 #if defined(_PC6601) || defined(_PC6601SR)
193         FLOPPY* floppy;
194 #endif
195         JOYSTICK* joystick;
196         PC6001_MEMORY* memory;
197         PSUB* psub;
198         TIMER* timer;
199         
200         MCS48* cpu_sub;
201         SUB* sub;
202         DATAREC* drec;
203         
204         PC6031* pc6031;
205         I8255* pio_fdd;
206         I8255* pio_pc80s31k;
207         PC80S31K *pc80s31k;
208         UPD765A* fdc_pc80s31k;
209         Z80* cpu_pc80s31k;
210         
211         bool support_sub_cpu;
212         bool support_pc80s31k;
213         
214 public:
215         // ----------------------------------------
216         // initialize
217         // ----------------------------------------
218         
219         VM(EMU* parent_emu);
220         ~VM();
221         
222         // ----------------------------------------
223         // for emulation class
224         // ----------------------------------------
225         
226         // drive virtual machine
227         void reset();
228         void run();
229         
230 #ifdef USE_DEBUGGER
231         // debugger
232         DEVICE *get_cpu(int index);
233 #endif
234         
235         // draw screen
236         void draw_screen();
237         
238         // sound generation
239         void initialize_sound(int rate, int samples);
240         uint16_t* create_sound(int* extra_frames);
241         int get_sound_buffer_ptr();
242 #ifdef USE_SOUND_VOLUME
243         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
244 #endif
245         
246         // notify key
247         void key_down(int code, bool repeat);
248         void key_up(int code);
249         
250         // user interface
251         void open_cart(int drv, const _TCHAR* file_path);
252         void close_cart(int drv);
253         bool is_cart_inserted(int drv);
254         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
255         void close_floppy_disk(int drv);
256         bool is_floppy_disk_inserted(int drv);
257         void is_floppy_disk_protected(int drv, bool value);
258         bool is_floppy_disk_protected(int drv);
259         uint32_t is_floppy_disk_accessed();
260         void play_tape(int drv, const _TCHAR* file_path);
261         void rec_tape(int drv, const _TCHAR* file_path);
262         void close_tape(int drv);
263         bool is_tape_inserted(int drv);
264         bool is_tape_playing(int drv);
265         bool is_tape_recording(int drv);
266         int get_tape_position(int drv);
267         const _TCHAR* get_tape_message(int drv);
268         void push_play(int drv);
269         void push_stop(int drv);
270         void push_fast_forward(int drv);
271         void push_fast_rewind(int drv);
272         void push_apss_forward(int drv) {}
273         void push_apss_rewind(int drv) {}
274         bool is_frame_skippable();
275         
276         void update_config();
277         bool process_state(FILEIO* state_fio, bool loading);
278         
279         // ----------------------------------------
280         // for each device
281         // ----------------------------------------
282         
283         // devices
284         DEVICE* get_device(int id);
285         //DEVICE* dummy;
286         //DEVICE* first_device;
287         //DEVICE* last_device;
288         
289         int sr_mode;
290 };
291 #endif