OSDN Git Service

[General][WIP] Merge Upstream 2017-03-11.
[csp-qt/common_source_project-fm7.git] / source / src / vm / msx / msx.h
1 /*
2         ASCII MSX1 Emulator 'yaMSX1'
3         ASCII MSX2 Emulator 'yaMSX2'
4         Pioneer PX-7 Emulator 'ePX-7'
5
6         Author : tanam
7         Date   : 2013.06.29-
8
9         modified by Takeda.Toshiya
10         modified by umaiboux
11
12         [ virtual machine ]
13 */
14
15 #ifndef _MSX_H_
16 #define _MSX_H_
17
18 #if defined(_PX7)
19 #define DEVICE_NAME             "PIONEER PX-7"
20 #define CONFIG_NAME             "px7"
21 #elif defined(_MSX1)
22 #define DEVICE_NAME             "ASCII MSX1"
23 #define CONFIG_NAME             "msx1"
24 #elif defined(_MSX2)
25 #define DEVICE_NAME             "ASCII MSX2"
26 #define CONFIG_NAME             "msx2"
27 #endif
28
29 // device informations for virtual machine
30 #define FRAMES_PER_SEC          60
31 #define LINES_PER_FRAME         262
32 #define CPU_CLOCKS              3579545
33 #if defined(_MSX2)
34 #define SCREEN_WIDTH            ((256 + 15)*2)  // V99X8_WIDTH
35 #define SCREEN_HEIGHT           ((212 + 15)*2)  // V99X8_HEIGHT
36 #else
37 #define SCREEN_WIDTH            512
38 #define SCREEN_HEIGHT           384
39 #endif
40 #define TMS9918A_VRAM_SIZE      0x4000
41 #define TMS9918A_LIMIT_SPRITES
42 #if defined(_PX7)
43 #define TMS9918A_SUPER_IMPOSE
44 #else
45 #define MAX_DRIVE               2
46 #define SUPPORT_MEDIA_TYPE_1DD
47 #define Z80_PSEUDO_BIOS
48 #endif
49 #define HAS_AY_3_8910
50 // for Flappy Limited '85
51 #define AY_3_891X_PORT_MODE     0x80
52
53 // device informations for win32
54 #define USE_CART1
55 #define USE_CART2
56 #define USE_TAPE
57 #if defined(_PX7)
58 #define USE_LASER_DISC
59 #define USE_MOVIE_PLAYER
60 #else
61 #define USE_FD1
62 #define USE_FD2
63 #endif
64 #define USE_ALT_F10_KEY
65 #define USE_AUTO_KEY            6
66 #define USE_AUTO_KEY_RELEASE    10
67 #if defined(USE_FD1)
68 #define USE_SOUND_FILES         4
69 #else
70 #define USE_SOUND_FILES         3
71 #endif
72 #define USE_SOUND_FILES_FDD
73 #define USE_SOUND_FILES_RELAY
74 #if defined(USE_SOUND_FILES)
75 #if defined(_PX7)
76 #define USE_SOUND_VOLUME        5
77 #else
78 //#define USE_SOUND_VOLUME      5
79 #define USE_SOUND_VOLUME        4
80 #endif
81 #else
82 #if defined(_PX7)
83 #define USE_SOUND_VOLUME        5
84 #else
85 #define USE_SOUND_VOLUME        4
86 #endif
87 #endif
88 #define SUPPORT_ROMA_KANA_CONVERSION
89 #define SUPPORT_TV_RENDER
90 #define USE_JOYSTICK
91 #define USE_DEBUGGER
92 #define USE_STATE
93
94 #include "../../common.h"
95 #include "../../fileio.h"
96
97 #ifdef USE_SOUND_VOLUME
98 static const _TCHAR *sound_device_caption[] = {
99         _T("PSG"), _T("Beep"), _T("CMT"),
100 #if defined(_PX7)
101         _T("LD-700"),
102 #endif
103 #if defined(USE_SOUND_FILES)
104 #if defined(USE_FD1)
105         //_T("FDD SEEK"),
106 #endif
107         _T("CMT Buttons"),
108 #endif
109 };
110 #endif
111
112 class EMU;
113 class DEVICE;
114 class EVENT;
115
116 class DATAREC;
117 class I8255;
118 class IO;
119 #if defined(_PX7)
120 class LD700;
121 #endif
122 class NOT;
123 //class YM2203;
124 class AY_3_891X;
125 class PCM1BIT;
126 #if defined(_MSX2)
127 class RP5C01;
128 class V99X8;
129 #else
130 class TMS9918A;
131 #endif
132 class Z80;
133
134 class JOYSTICK;
135 class KEYBOARD;
136 class MEMORY;
137 #if defined(_MSX2)
138 class RTCIF;
139 #endif
140 class SLOT0;
141 class SLOT1;
142 class SLOT2;
143 class SLOT3;
144
145 class VM
146 {
147 protected:
148         EMU* emu;
149         
150         // devices
151         EVENT* event;
152         
153         DATAREC* drec;
154         I8255* pio;
155         IO* io;
156 #if defined(_PX7)
157         LD700* ldp;
158 #endif
159         NOT* not_remote;
160 //      YM2203* psg;
161         AY_3_891X* psg;
162         PCM1BIT* pcm;
163 #if defined(_MSX2)
164         RP5C01* rtc;
165         V99X8* vdp;
166 #else
167         TMS9918A* vdp;
168 #endif
169         Z80* cpu;
170         
171         JOYSTICK* joystick;
172         KEYBOARD* keyboard;
173         MEMORY* memory;
174 #ifdef _MSX2
175         RTCIF* rtcif;
176 #endif
177         SLOT0 *slot0;
178         SLOT1 *slot1;
179         SLOT2 *slot2;
180         SLOT3 *slot3;
181         
182 public:
183         // ----------------------------------------
184         // initialize
185         // ----------------------------------------
186         
187         VM(EMU* parent_emu);
188         ~VM();
189         
190         // ----------------------------------------
191         // for emulation class
192         // ----------------------------------------
193         
194         // drive virtual machine
195         void reset();
196         void run();
197         
198 #ifdef USE_DEBUGGER
199         // debugger
200         DEVICE *get_cpu(int index);
201 #endif
202         
203         // draw screen
204         void draw_screen();
205         
206         // sound generation
207         void initialize_sound(int rate, int samples);
208         uint16_t* create_sound(int* extra_frames);
209         int get_sound_buffer_ptr();
210 #if defined(_PX7)
211         void movie_sound_callback(uint8_t *buffer, long size);
212 #endif
213 #ifdef USE_SOUND_VOLUME
214         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
215 #endif
216         
217         // user interface
218         void open_cart(int drv, const _TCHAR* file_path);
219         void close_cart(int drv);
220         bool is_cart_inserted(int drv);
221         void play_tape(const _TCHAR* file_path);
222         void rec_tape(const _TCHAR* file_path);
223         void close_tape();
224         bool is_tape_inserted();
225         bool is_tape_playing();
226         bool is_tape_recording();
227         int get_tape_position();
228 #if defined(_PX7)
229         void open_laser_disc(const _TCHAR* file_path);
230         void close_laser_disc();
231         bool is_laser_disc_inserted();
232 #else
233         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
234         void close_floppy_disk(int drv);
235         bool is_floppy_disk_inserted(int drv);
236         void is_floppy_disk_protected(int drv, bool value);
237         bool is_floppy_disk_protected(int drv);
238 #endif
239         bool is_frame_skippable();
240         
241         void update_config();
242         void save_state(FILEIO* state_fio);
243         bool load_state(FILEIO* state_fio);
244         
245         // ----------------------------------------
246         // for each device
247         // ----------------------------------------
248         
249         // devices
250         DEVICE* get_device(int id);
251         DEVICE* dummy;
252         DEVICE* first_device;
253         DEVICE* last_device;
254 };
255
256 #endif