OSDN Git Service

85032bef4b0d58d79daee3a51ca644d16ff896c1
[csp-qt/common_source_project-fm7.git] / source / src / vm / msx / msx_ex.h
1 /*
2         Common Source Code Project
3         MSX Series (experimental)
4
5         Origin : src/vm/msx/msx.h
6
7         modified by umaiboux
8         Date   : 2016.03.xx-
9
10         [ virtual machine ]
11 */
12
13 #ifndef _MSX_EX_H_
14 #define _MSX_EX_H_
15
16 #if defined(_PX7)
17 #define DEVICE_NAME             "PIONEER PX-7"
18 #define CONFIG_NAME             "px7"
19 #elif defined(_MSX1)
20 #define DEVICE_NAME             "ASCII MSX1"
21 #define CONFIG_NAME             "msx1"
22 #elif defined(_MSX2)
23 #define DEVICE_NAME             "ASCII MSX2"
24 #define CONFIG_NAME             "msx2"
25 #elif defined(_MSX2P)
26 #define DEVICE_NAME             "ASCII MSX2+"
27 #define CONFIG_NAME             "msx2p"
28 #elif defined(_HX20)
29 #define DEVICE_NAME             "TOSHIBA HX-20+"
30 #define CONFIG_NAME             "hx20"
31 #elif defined(_FSA1)
32 #define DEVICE_NAME             "Panasonic FS-A1"
33 #define CONFIG_NAME             "fsa1"
34 #elif defined(_HBF1XDJ)
35 #define DEVICE_NAME             "SONY HB-F1XDJ"
36 #define CONFIG_NAME             "hbf1xdj"
37 #endif
38
39 #if defined(_PX7)
40
41 #define _MSX1_VARIANTS
42 #define MAINROM_SLOT    0x00
43 #define CART1_SLOT      0x01
44 #define LDC_SLOT        0x02
45 #define CART2_SLOT      0x03
46 #define MAINROM_PLUS_RAM_32K
47
48 #elif defined(_HX20)
49
50 #define _MSX1_VARIANTS
51 #define MAINROM_SLOT    0x00
52 #define CART1_SLOT      0x01
53 #define CART2_SLOT      0x02
54 #define RAM64K_SLOT     0x83
55 #define FDD_PATCH_SLOT  0x8B
56 #define FIRMWARE32K1_SLOT 0x8F
57 #define FIRMWARE32K1_FILENAME _T("HX20FIRM.ROM")
58 #define MSX_PSG_STEREO
59
60 #elif defined(_FSA1)
61
62 #define _MSX2_VARIANTS
63 #define MAINROM_SLOT    0x00
64 #define CART1_SLOT      0x01
65 #define CART2_SLOT      0x02
66 #define RAM64K_SLOT     0x83
67 #define SUBROM_SLOT     0x87
68 #define FIRMWARE32K1_SLOT 0x8B
69 #define FIRMWARE32K1_FILENAME _T("FSA1FIRM1.ROM")
70 #define FIRMWARE32K2_SLOT 0x8F
71 #define FIRMWARE32K2_FILENAME _T("FSA1FIRM2.ROM")
72 #define MSX_KEYBOARD_50ON
73
74 #elif defined(_HBF1XDJ)
75
76 #define _MSX2P_VARIANTS
77 #define MAINROM_SLOT    0x80
78 //#define HALNOTE_SLOT  0x8C /* MSX-JE */
79 #define CART1_SLOT      0x01
80 #define CART2_SLOT      0x02
81 #define MAPPERRAM_SLOT  0x83
82 #define SUBROM_SLOT     0x87
83 #define FDD_PATCH_SLOT  0x8B
84 #define MSXMUSIC_SLOT   0x8F
85 #define MAPPERRAM_SIZE  (64*1024)
86 #define MAPPERRAM_MASK  0x03
87
88 #elif defined(_MSX2P)
89
90 #define _MSX2P_VARIANTS
91 #define MAINROM_SLOT    0x80
92 #define MSXMUSIC_SLOT   0x88
93 #define MSXDOS2_SLOT    0x8C
94 #define CART1_SLOT      0x01
95 #define CART2_SLOT      0x02
96 #define MAPPERRAM_SLOT  0x83
97 #define SUBROM_SLOT     0x87
98 #define FDD_PATCH_SLOT  0x8B
99 #define MAPPERRAM_SIZE  (2*1024*1024)
100 #define MAPPERRAM_MASK  0x7F
101 #define MSX_FDD_PATCH_WITH_2HD
102
103 #elif defined(_MSX2)
104
105 #define _MSX2_VARIANTS
106 #define MAINROM_SLOT    0x00
107 #define CART1_SLOT      0x01
108 #define CART2_SLOT      0x02
109 #define MAPPERRAM_SLOT  0x83
110 #define SUBROM_SLOT     0x87
111 #define MSXDOS2_SLOT    0x8B
112 #define FDD_PATCH_SLOT  0x8F
113 #define MAPPERRAM_SIZE  (128*1024)
114 #define MAPPERRAM_MASK  0x07
115
116 #elif defined(_MSX1)
117
118 #define _MSX1_VARIANTS
119 #define MAINROM_SLOT    0x00
120 #define CART1_SLOT      0x01
121 #define CART2_SLOT      0x02
122 #define MAPPERRAM_SLOT  0x83
123 #define MSXMUSIC_SLOT   0x87
124 #define FDD_PATCH_SLOT  0x8B
125 #define MAPPERRAM_SIZE  (128*1024)
126 #define MAPPERRAM_MASK  0x07
127
128 #endif
129
130 #if defined(_MSX_VDP_MESS)
131 #if defined(_MSX2P_VARIANTS)
132 #define V99X8 v9958_device
133 #elif defined(_MSX2_VARIANTS)
134 #define V99X8 v9938_device
135 #endif
136 #endif
137
138 // device informations for virtual machine
139 #define FRAMES_PER_SEC          60
140 #define LINES_PER_FRAME         262
141 #define CPU_CLOCKS              3579545
142 #if !defined(_MSX1_VARIANTS)
143 #if defined(_MSX_VDP_MESS)
144 //#define SCREEN_WIDTH          (544)   // v99x8_device::HVISIBLE
145 //#define SCREEN_HEIGHT         (480)   //
146 //#define WINDOW_WIDTH_ASPECT   (544*9/8)
147 #define SCREEN_WIDTH            ((256 + 15)*2)  // same as V99X8_WIDTH
148 #define SCREEN_HEIGHT           ((212 + 15)*2)  // same as V99X8_HEIGHT
149 #define WINDOW_WIDTH_ASPECT     ((288 + 17)*2)
150 #else
151 #define SCREEN_WIDTH            ((256 + 15)*2)  // V99X8_WIDTH
152 #define SCREEN_HEIGHT           ((212 + 15)*2)  // V99X8_HEIGHT
153 #define WINDOW_WIDTH_ASPECT     ((288 + 17)*2)
154 #endif
155 #else
156 #define SCREEN_WIDTH            512
157 #define SCREEN_HEIGHT           384
158 #define WINDOW_WIDTH_ASPECT     576
159 #endif
160 #define TMS9918A_VRAM_SIZE      0x4000
161 #define TMS9918A_LIMIT_SPRITES
162 #if defined(LDC_SLOT)
163 #define TMS9918A_SUPER_IMPOSE
164 #endif
165 #if defined(FDD_PATCH_SLOT)
166 #define MAX_DRIVE               2
167 #define SUPPORT_MEDIA_TYPE_1DD
168 #define Z80_PSEUDO_BIOS
169 #endif
170 #define HAS_AY_3_8910
171 // for Flappy Limited '85
172 #define AY_3_891X_PORT_MODE     0x80
173
174 // device informations for win32
175 #define USE_CART                2
176 #define USE_TAPE                1
177 #if defined(LDC_SLOT)
178 #define USE_LASER_DISC          1
179 #define USE_MOVIE_PLAYER
180 #endif
181 #if defined(FDD_PATCH_SLOT)
182 #define USE_FLOPPY_DISK         2
183 #endif
184 #define USE_AUTO_KEY            6
185 #define USE_AUTO_KEY_RELEASE    10
186 #if defined(_PX7)
187 #define USE_SOUND_VOLUME        8
188 #else
189 #define USE_SOUND_VOLUME        7
190 #endif
191 #define USE_JOYSTICK
192 #define USE_DEBUGGER
193 #define USE_STATE
194 #define USE_PRINTER
195 #define USE_PRINTER_TYPE        4
196 #if defined(MSX_PSG_STEREO)
197 #define USE_SOUND_TYPE          2
198 #endif
199 #define USE_CPU_Z80
200 #define SUPPORT_TV_RENDER
201
202 #include "../../common.h"
203 #include "../../fileio.h"
204 #include "../vm_template.h"
205
206 #ifdef USE_SOUND_VOLUME
207 static const _TCHAR *sound_device_caption[] = {
208         _T("PSG"), _T("Beep"), _T("CMT (Signal)"),
209 #if defined(_PX7)
210         _T("LD-700"),
211 #endif
212         _T("Cart#1"), _T("Cart#2"), _T("MSX-MUSIC"), _T("Noise (CMT)"),
213 };
214 #endif
215
216 class EMU;
217 class DEVICE;
218 class EVENT;
219
220 class DATAREC;
221 class I8255;
222 class IO;
223 #if defined(LDC_SLOT)
224 class LD700;
225 #endif
226 class NOT;
227 //class YM2203;
228 class AY_3_891X;
229 class PCM1BIT;
230 #if !defined(_MSX1_VARIANTS)
231 class RP5C01;
232 class V99X8;
233 #else
234 class TMS9918A;
235 #endif
236 class Z80;
237
238 namespace MSX {
239         class JOYSTICK;
240         class KEYBOARD;
241         class MEMORY_EX;
242 #if !defined(_MSX1_VARIANTS)
243         class RTCIF;
244 #endif
245         class SLOT_MAINROM;
246         class SLOT_CART;
247         class SOUND_CART;
248         class KANJIROM;
249 #if defined(MSX_PSG_STEREO)
250         class PSG_STEREO;
251 #endif
252 #if defined(USE_PRINTER)
253         class PRINTER;
254 #endif
255 #if defined(LDC_SLOT)
256         class SLOT_LDC;
257 #endif
258 #if defined(MAPPERRAM_SLOT)
259         class SLOT_MAPPERRAM;
260 #endif
261 #if defined(RAM64K_SLOT)
262         class SLOT_RAM64K;
263 #endif
264 #if defined(SUBROM_SLOT)
265         class SLOT_SUBROM;
266 #endif
267 #if defined(FIRMWARE32K1_SLOT)
268         class SLOT_FIRMWARE32K;
269 #endif
270 #if defined(FDD_PATCH_SLOT)
271         class SLOT_FDD_PATCH;
272 #endif
273 #if defined(MSXDOS2_SLOT)
274         class SLOT_MSXDOS2;
275 #endif
276 }
277 class YM2413;
278 #if defined(MSXMUSIC_SLOT)
279 namespace MSX {
280         class SLOT_MSXMUSIC;
281 }
282 #endif
283
284
285 class VM : public VM_TEMPLATE
286 {
287 protected:
288         //EMU* emu;
289         //csp_state_utils* state_entry;
290         
291         // devices
292         //EVENT* event;
293         
294         DATAREC* drec;
295         I8255* pio;
296         IO* io;
297 #if defined(LDC_SLOT)
298         LD700* ldp;
299 #endif
300         NOT* not_remote;
301 //      YM2203* psg;
302         AY_3_891X* psg;
303         PCM1BIT* pcm;
304 #if !defined(_MSX1_VARIANTS)
305         RP5C01* rtc;
306         V99X8* vdp;
307 #else
308         TMS9918A* vdp;
309 #endif
310         Z80* cpu;
311         
312         MSX::JOYSTICK* joystick;
313         MSX::KEYBOARD* keyboard;
314         MSX::MEMORY_EX* memory;
315 #if !defined(_MSX1_VARIANTS)
316         MSX::RTCIF* rtcif;
317 #endif
318         MSX::SLOT_MAINROM *slot_mainrom;
319         MSX::SLOT_CART *slot_cart[2];
320         MSX::SOUND_CART* sound_cart[2];
321         MSX::KANJIROM* kanjirom;
322 #if defined(MSX_PSG_STEREO)
323         MSX::PSG_STEREO* psg_stereo;
324 #endif
325 #ifdef USE_PRINTER
326         MSX::PRINTER* printer;
327 #endif
328 #if defined(LDC_SLOT)
329         MSX::SLOT_LDC *slot_ldc;
330 #endif
331 #if defined(MAPPERRAM_SLOT)
332         MSX::SLOT_MAPPERRAM *slot_ram;
333 #endif
334 #if defined(RAM64K_SLOT)
335         MSX::SLOT_RAM64K *slot_ram;
336 #endif
337 #if defined(SUBROM_SLOT)
338         MSX::SLOT_SUBROM *slot_subrom;
339 #endif
340 #if defined(FIRMWARE32K1_SLOT)
341         MSX::SLOT_FIRMWARE32K *slot_firmware32k1;
342 #endif
343 #if defined(FIRMWARE32K2_SLOT)
344         MSX::SLOT_FIRMWARE32K *slot_firmware32k2;
345 #endif
346 #if defined(FDD_PATCH_SLOT)
347         MSX::SLOT_FDD_PATCH *slot_fdd_patch;
348 #endif
349 #if defined(MSXDOS2_SLOT)
350         MSX::SLOT_MSXDOS2 *slot_msxdos2;
351 #endif
352         YM2413* ym2413;
353 #if defined(MSXMUSIC_SLOT)
354         MSX::SLOT_MSXMUSIC *slot_msxmusic;
355 #endif
356         
357 public:
358         // ----------------------------------------
359         // initialize
360         // ----------------------------------------
361         
362         VM(EMU* parent_emu);
363         ~VM();
364         
365         // ----------------------------------------
366         // for emulation class
367         // ----------------------------------------
368         
369         // drive virtual machine
370         void reset();
371         void run();
372         double get_frame_rate()
373         {
374                 return FRAMES_PER_SEC;
375         }
376         
377 #ifdef USE_DEBUGGER
378         // debugger
379         DEVICE *get_cpu(int index);
380 #endif
381         
382         // draw screen
383         void draw_screen();
384         
385         // sound generation
386         void initialize_sound(int rate, int samples);
387         uint16_t* create_sound(int* extra_frames);
388         int get_sound_buffer_ptr();
389 #if defined(LDC_SLOT)
390         void movie_sound_callback(uint8_t *buffer, long size);
391 #endif
392 #ifdef USE_SOUND_VOLUME
393         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
394 #endif
395         
396         // user interface
397         void open_cart(int drv, const _TCHAR* file_path);
398         void close_cart(int drv);
399         bool is_cart_inserted(int drv);
400         void play_tape(int drv, const _TCHAR* file_path);
401         void rec_tape(int drv, const _TCHAR* file_path);
402         void close_tape(int drv);
403         bool is_tape_inserted(int drv);
404         bool is_tape_playing(int drv);
405         bool is_tape_recording(int drv);
406         int get_tape_position(int drv);
407         const _TCHAR* get_tape_message(int drv);
408         void push_play(int drv);
409         void push_stop(int drv);
410         void push_fast_forward(int drv);
411         void push_fast_rewind(int drv);
412         void push_apss_forward(int drv) {}
413         void push_apss_rewind(int drv) {}
414 #if defined(LDC_SLOT)
415         void open_laser_disc(int drv, const _TCHAR* file_path);
416         void close_laser_disc(int drv);
417         bool is_laser_disc_inserted(int drv);
418         uint32_t is_laser_disc_accessed();
419 #endif
420 #if defined(FDD_PATCH_SLOT)
421         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
422         void close_floppy_disk(int drv);
423         bool is_floppy_disk_inserted(int drv);
424         void is_floppy_disk_protected(int drv, bool value);
425         bool is_floppy_disk_protected(int drv);
426         uint32_t is_floppy_disk_accessed();
427 #endif
428         bool is_frame_skippable();
429         
430         void update_config();
431         bool process_state(FILEIO* state_fio, bool loading);
432         
433         // ----------------------------------------
434         // for each device
435         // ----------------------------------------
436         
437         // devices
438         DEVICE* get_device(int id);
439         //DEVICE* dummy;
440         //DEVICE* first_device;
441         //DEVICE* last_device;
442 };
443
444 #endif