OSDN Git Service

[VM][FMTOWNS][MEMORY] Fix setup around memory banks by I/O 0404h and 0480h.
[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 #define TIMER_PERIOD    (8192. / CPU_CLOCKS * 1000000)
26 #elif defined(_PC6001MK2)
27 #define DEVICE_NAME             "NEC PC-6001mkII"
28 #define CONFIG_NAME             "pc6001mk2"
29 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.62"
30 #define SCREEN_WIDTH            640
31 #define SCREEN_HEIGHT           400
32 #define WINDOW_HEIGHT_ASPECT    480
33 #define CPU_CLOCKS              3993600
34 #define HAS_AY_3_8910
35 #define TIMER_PERIOD    (8192. / CPU_CLOCKS * 1000000)
36 #elif defined(_PC6001MK2SR)
37 #define DEVICE_NAME             "NEC PC-6001mkIISR"
38 #define CONFIG_NAME             "pc6001mk2sr"
39 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.68"
40 #define SCREEN_WIDTH            640
41 #define SCREEN_HEIGHT           400
42 #define WINDOW_HEIGHT_ASPECT    480
43 #define CPU_CLOCKS              3580000
44 #define TIMER_PERIOD    (2000/.999)
45 #elif defined(_PC6601)
46 #define DEVICE_NAME             "NEC PC-6601"
47 #define CONFIG_NAME             "pc6601"
48 #define SUB_CPU_ROM_FILE_NAME   "SUBCPU.66"
49 #define SCREEN_WIDTH            640
50 #define SCREEN_HEIGHT           400
51 #define WINDOW_HEIGHT_ASPECT    480
52 #define CPU_CLOCKS              4000000
53 #define HAS_AY_3_8910
54 #define TIMER_PERIOD    (8192. / CPU_CLOCKS * 1000000)
55 #elif defined(_PC6601SR)
56 #define DEVICE_NAME             "NEC PC-6601SR"
57 #define CONFIG_NAME             "pc6601sr"
58 #define SUB_CPU_1_ROM_FILE_NAME "SUBCPU1.68"
59 #define SUB_CPU_2_ROM_FILE_NAME "SUBCPU2.68"
60 #define SUB_CPU_3_ROM_FILE_NAME "SUBCPU3.68"
61 #define SCREEN_WIDTH            640
62 #define SCREEN_HEIGHT           400
63 #define WINDOW_HEIGHT_ASPECT    480
64 #define CPU_CLOCKS              3580000
65 #define TIMER_PERIOD    (2000 / .999)
66 #endif
67
68 // device informations for virtual machine
69 #define FRAMES_PER_SEC          60
70 #define LINES_PER_FRAME         262
71 #define MAX_DRIVE               4
72 #define MC6847_ATTR_OFS         0
73 #define MC6847_VRAM_OFS         0x200
74 #define MC6847_ATTR_AG          0x80
75 #define MC6847_ATTR_AS          0x40
76 #define MC6847_ATTR_INTEXT      0x20
77 #define MC6847_ATTR_GM0         0x10
78 #define MC6847_ATTR_GM1         0x08
79 #define MC6847_ATTR_GM2         0x04
80 #define MC6847_ATTR_CSS         0x02
81 #define MC6847_ATTR_INV         0x01
82
83 // device informations for win32
84 #define USE_CART                1
85 #if defined(_PC6601) || defined(_PC6601SR)
86 #define USE_FLOPPY_DISK         4
87 #else
88 #define USE_FLOPPY_DISK         2
89 #endif
90 #define USE_TAPE                1
91 #define TAPE_PC6001
92 #define USE_AUTO_KEY            6
93 #define USE_AUTO_KEY_RELEASE    10
94 #define USE_AUTO_KEY_CAPS
95 #if !defined(_PC6001)
96 #define USE_SCREEN_FILTER
97 #define USE_SCANLINE
98 #endif
99 #if defined(_PC6001)
100 #define USE_SOUND_VOLUME        4
101 #else
102 #define USE_SOUND_VOLUME        5
103 #endif
104 #define USE_JOYSTICK
105 #define USE_PRINTER
106 #define USE_PRINTER_TYPE        3
107 #define USE_DEBUGGER
108 #define USE_STATE
109 #define USE_CPU_MCS48
110 #define USE_CPU_Z80
111
112 #include "../../common.h"
113 #include "../../fileio.h"
114 #include "../vm_template.h"
115
116 #ifdef USE_SOUND_VOLUME
117 static const _TCHAR *sound_device_caption[] = {
118         _T("PSG"),
119 #if !defined(_PC6001)
120         _T("Voice"),
121 #endif
122         _T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"),
123 };
124 #endif
125 class EMU;
126 class DEVICE;
127 class EVENT;
128
129 class I8255;
130 class IO;
131 #ifdef _PC6001
132 class MC6847;
133 #else
134 class UPD7752;
135 #endif
136 class NOISE;
137 class PC6031;
138 class PC80S31K;
139 class UPD765A;
140 #if defined(_PC6001MK2SR) || defined(_PC6601SR)
141 class YM2203;
142 #else
143 class AY_3_891X;
144 #endif
145 class Z80;
146
147 class DATAREC;
148 class MCS48;
149
150 #ifdef _PC6001
151 namespace PC6001 {
152         class DISPLAY;
153 }
154 #endif
155 #if defined(_PC6601) || defined(_PC6601SR)
156 namespace PC6001 {
157         class FLOPPY;
158 }
159 #endif
160
161 namespace PC6001 {
162         class JOYSTICK;
163         class MEMORY;
164         //class PSUB;
165         class SUB;
166         class TIMER;
167 }
168
169 class VM : public VM_TEMPLATE
170 {
171 protected:
172         //EMU* emu;
173
174         int vdata;
175
176         // devices
177         //EVENT* event;
178
179         DEVICE* printer;
180         I8255* pio_sub;
181         IO* io;
182         NOISE* noise_seek;
183         NOISE* noise_head_down;
184         NOISE* noise_head_up;
185 #if defined(_PC6001MK2SR) || defined(_PC6601SR)
186         YM2203* psg;
187 #else
188         AY_3_891X* psg;
189 #endif
190         Z80* cpu;
191 #ifdef _PC6001
192         MC6847* vdp;
193         PC6001::DISPLAY* display;
194 #else
195         UPD7752* voice;
196 #endif
197 #if defined(_PC6601) || defined(_PC6601SR)
198         PC6001::FLOPPY* floppy;
199 #endif
200         PC6001::JOYSTICK* joystick;
201         PC6001::MEMORY* memory;
202 //      PC6001::PSUB* psub;
203         PC6001::TIMER* timer;
204
205         MCS48* cpu_sub;
206         PC6001::SUB* sub;
207         DATAREC* drec;
208
209         PC6031* pc6031;
210         I8255* pio_fdd;
211         I8255* pio_pc80s31k;
212         PC80S31K *pc80s31k;
213         UPD765A* fdc_pc80s31k;
214         Z80* cpu_pc80s31k;
215
216         bool support_sub_cpu;
217         bool support_pc80s31k;
218
219 public:
220         // ----------------------------------------
221         // initialize
222         // ----------------------------------------
223
224         VM(EMU_TEMPLATE* parent_emu);
225         ~VM();
226
227         // ----------------------------------------
228         // for emulation class
229         // ----------------------------------------
230
231         // drive virtual machine
232         void reset();
233         void run();
234         double get_frame_rate()
235         {
236                 return FRAMES_PER_SEC;
237         }
238
239 #ifdef USE_DEBUGGER
240         // debugger
241         DEVICE *get_cpu(int index);
242 #endif
243
244         // draw screen
245         void draw_screen();
246
247         // sound generation
248         void initialize_sound(int rate, int samples);
249         uint16_t* create_sound(int* extra_frames);
250         int get_sound_buffer_ptr();
251 #ifdef USE_SOUND_VOLUME
252         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
253 #endif
254
255         // notify key
256         void key_down(int code, bool repeat);
257         void key_up(int code);
258
259         // user interface
260         void open_cart(int drv, const _TCHAR* file_path);
261         void close_cart(int drv);
262         bool is_cart_inserted(int drv);
263         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
264         void close_floppy_disk(int drv);
265         bool is_floppy_disk_inserted(int drv);
266         void is_floppy_disk_protected(int drv, bool value);
267         bool is_floppy_disk_protected(int drv);
268         uint32_t is_floppy_disk_accessed();
269         void play_tape(int drv, const _TCHAR* file_path);
270         void rec_tape(int drv, const _TCHAR* file_path);
271         void close_tape(int drv);
272         bool is_tape_inserted(int drv);
273         bool is_tape_playing(int drv);
274         bool is_tape_recording(int drv);
275         int get_tape_position(int drv);
276         const _TCHAR* get_tape_message(int drv);
277         void push_play(int drv);
278         void push_stop(int drv);
279         void push_fast_forward(int drv);
280         void push_fast_rewind(int drv);
281         void push_apss_forward(int drv) {}
282         void push_apss_rewind(int drv) {}
283         bool is_frame_skippable();
284
285         double get_current_usec();
286         uint64_t get_current_clock_uint64();
287
288         void update_config();
289         bool process_state(FILEIO* state_fio, bool loading);
290
291         // ----------------------------------------
292         // for each device
293         // ----------------------------------------
294
295         // devices
296         DEVICE* get_device(int id);
297         //DEVICE* dummy;
298         //DEVICE* first_device;
299         //DEVICE* last_device;
300
301         int sr_mode;
302 };
303 #endif