OSDN Git Service

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