OSDN Git Service

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