OSDN Git Service

[General][Qt] Enable to build even not support counter of CMT.
[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 USE_SHIFT_NUMPAD_KEY
86 #define USE_ALT_F10_KEY
87 #define USE_AUTO_KEY            6
88 #define USE_AUTO_KEY_RELEASE    10
89 #define USE_AUTO_KEY_CAPS
90 #if !defined(_PC6001)
91 #define USE_CRT_FILTER
92 #define USE_SCANLINE
93 #endif
94 #define USE_ACCESS_LAMP
95 #define USE_DISK_WRITE_PROTECT
96 #define USE_DEBUGGER
97 #define USE_STATE
98
99 #include "../../common.h"
100 #include "../../fileio.h"
101
102 class EMU;
103 class DEVICE;
104 class EVENT;
105
106 class I8255;
107 class IO;
108 #ifdef _PC6001
109 class MC6847;
110 #else
111 class UPD7752;
112 #endif
113 class PC6031;
114 class PC80S31K;
115 class UPD765A;
116 class YM2203;
117 class Z80;
118
119 class DATAREC;
120 class MCS48;
121
122 #ifdef _PC6001
123 class DISPLAY;
124 #endif
125 #if defined(_PC6601) || defined(_PC6601SR)
126 class FLOPPY;
127 #endif
128 class JOYSTICK;
129 class MEMORY;
130 class PRINTER;
131 class PSUB;
132 class SUB;
133 class TIMER;
134
135 class VM
136 {
137 protected:
138         EMU* emu;
139         int vdata;
140         
141         // devices
142         EVENT* event;
143         
144         I8255* pio_sub;
145         IO* io;
146         YM2203* psg;
147         Z80* cpu;
148 #ifdef _PC6001
149         MC6847* vdp;
150         DISPLAY* display;
151 #else
152         UPD7752* voice;
153 #endif
154 #if defined(_PC6601) || defined(_PC6601SR)
155         FLOPPY* floppy;
156 #endif
157         JOYSTICK* joystick;
158         MEMORY* memory;
159         PRINTER *printer;
160         PSUB* psub;
161         TIMER* timer;
162         
163         MCS48* cpu_sub;
164         SUB* sub;
165         DATAREC* drec;
166         
167         PC6031* pc6031;
168         I8255* pio_fdd;
169         I8255* pio_pc80s31k;
170         PC80S31K *pc80s31k;
171         UPD765A* fdc_pc80s31k;
172         Z80* cpu_pc80s31k;
173         
174         bool support_sub_cpu;
175         bool support_pc80s31k;
176         
177 public:
178         // ----------------------------------------
179         // initialize
180         // ----------------------------------------
181         
182         VM(EMU* parent_emu);
183         ~VM();
184         
185         // ----------------------------------------
186         // for emulation class
187         // ----------------------------------------
188         
189         // drive virtual machine
190         void reset();
191         void run();
192         
193 #ifdef USE_DEBUGGER
194         // debugger
195         DEVICE *get_cpu(int index);
196 #endif
197         
198         // draw screen
199         void draw_screen();
200         // sound generation
201         void initialize_sound(int rate, int samples);
202         uint16* create_sound(int* extra_frames);
203         int sound_buffer_ptr();
204         
205         // user interface
206         void open_cart(int drv,_TCHAR* file_path);
207         void close_cart(int drv);
208         bool cart_inserted(int drv);
209         int access_lamp();
210         void open_disk(int drv, _TCHAR* file_path, int bank);
211         void close_disk(int drv);
212         bool disk_inserted(int drv);
213         bool is_write_protect_fd(int drv);
214         void write_protect_fd(int drv, bool flag);
215         void play_tape(_TCHAR* file_path);
216         void rec_tape(_TCHAR* file_path);
217         void close_tape();
218         bool tape_inserted();
219         int  get_tape_ptr();
220         bool now_skip();
221         
222         void update_config();
223         void save_state(FILEIO* state_fio);
224         bool load_state(FILEIO* state_fio);
225         
226         // ----------------------------------------
227         // for each device
228         // ----------------------------------------
229         
230         // devices
231         DEVICE* get_device(int id);
232         DEVICE* dummy;
233         DEVICE* first_device;
234         DEVICE* last_device;
235         
236         int sr_mode;
237 };
238 #endif