OSDN Git Service

[VM][WIP] Use namespace to devices per VMs.
[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_CART                2
55 #define USE_TAPE                1
56 #define USE_TAPE_BUTTON
57 #if defined(_PX7)
58 #define USE_LASER_DISC          1
59 #define USE_MOVIE_PLAYER
60 #else
61 #define USE_FLOPPY_DISK         2
62 #endif
63 #define USE_ALT_F10_KEY
64 #define USE_AUTO_KEY            6
65 #define USE_AUTO_KEY_RELEASE    10
66 #if defined(_PX7)
67 #define USE_SOUND_VOLUME        5
68 #else
69 //#define USE_SOUND_VOLUME      5
70 #define USE_SOUND_VOLUME        4
71 #endif
72 #define SUPPORT_TV_RENDER
73 #define USE_JOYSTICK
74 #define USE_DEBUGGER
75 #define USE_STATE
76 #define USE_CPU_Z80
77
78 #include "../../common.h"
79 #include "../../fileio.h"
80 #include "../vm_template.h"
81
82 #ifdef USE_SOUND_VOLUME
83 static const _TCHAR *sound_device_caption[] = {
84         _T("PSG"), _T("Beep"), _T("CMT (Signal)"),
85 #if defined(_PX7)
86         _T("LD-700"),
87 #endif
88          _T("Noise (CMT)"),
89 };
90 #endif
91
92 class EMU;
93 class DEVICE;
94 class EVENT;
95
96 class DATAREC;
97 class I8255;
98 class IO;
99 #if defined(_PX7)
100 class LD700;
101 #endif
102 class NOT;
103 //class YM2203;
104 class AY_3_891X;
105 class PCM1BIT;
106 #if defined(_MSX2)
107 class RP5C01;
108 class V99X8;
109 #else
110 class TMS9918A;
111 #endif
112 class Z80;
113
114 namespace MSX {
115         class JOYSTICK;
116         class KEYBOARD;
117         class MEMORY;
118 #if defined(_MSX2)
119         class RTCIF;
120 #endif
121         class SLOT0;
122         class SLOT1;
123         class SLOT2;
124         class SLOT3;
125 }
126 class VM : public VM_TEMPLATE
127 {
128 protected:
129         //EMU* emu;
130         
131         // devices
132         //EVENT* event;
133         
134         DATAREC* drec;
135         I8255* pio;
136         IO* io;
137 #if defined(_PX7)
138         LD700* ldp;
139 #endif
140         NOT* not_remote;
141 //      YM2203* psg;
142         AY_3_891X* psg;
143         PCM1BIT* pcm;
144 #if defined(_MSX2)
145         RP5C01* rtc;
146         V99X8* vdp;
147 #else
148         TMS9918A* vdp;
149 #endif
150         Z80* cpu;
151         
152         MSX::JOYSTICK* joystick;
153         MSX::KEYBOARD* keyboard;
154         MSX::MEMORY* memory;
155 #ifdef _MSX2
156         MSX::RTCIF* rtcif;
157 #endif
158         MSX::SLOT0 *slot0;
159         MSX::SLOT1 *slot1;
160         MSX::SLOT2 *slot2;
161         MSX::SLOT3 *slot3;
162         
163 public:
164         // ----------------------------------------
165         // initialize
166         // ----------------------------------------
167         
168         VM(EMU* parent_emu);
169         ~VM();
170         
171         // ----------------------------------------
172         // for emulation class
173         // ----------------------------------------
174         
175         // drive virtual machine
176         void reset();
177         void run();
178         
179 #ifdef USE_DEBUGGER
180         // debugger
181         DEVICE *get_cpu(int index);
182 #endif
183         
184         // draw screen
185         void draw_screen();
186         
187         // sound generation
188         void initialize_sound(int rate, int samples);
189         uint16_t* create_sound(int* extra_frames);
190         int get_sound_buffer_ptr();
191 #if defined(_PX7)
192         void movie_sound_callback(uint8_t *buffer, long size);
193 #endif
194 #ifdef USE_SOUND_VOLUME
195         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
196 #endif
197         
198         // user interface
199         void open_cart(int drv, const _TCHAR* file_path);
200         void close_cart(int drv);
201         bool is_cart_inserted(int drv);
202         void play_tape(int drv, const _TCHAR* file_path);
203         void rec_tape(int drv, const _TCHAR* file_path);
204         void close_tape(int drv);
205         bool is_tape_inserted(int drv);
206         bool is_tape_playing(int drv);
207         bool is_tape_recording(int drv);
208         int get_tape_position(int drv);
209         const _TCHAR* get_tape_message(int drv);
210         void push_play(int drv);
211         void push_stop(int drv);
212         void push_fast_forward(int drv);
213         void push_fast_rewind(int drv);
214         void push_apss_forward(int drv) {}
215         void push_apss_rewind(int drv) {}
216 #if defined(_PX7)
217         void open_laser_disc(int drv, const _TCHAR* file_path);
218         void close_laser_disc(int drv);
219         bool is_laser_disc_inserted(int drv);
220         uint32_t is_laser_disc_accessed();
221 #else
222         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
223         void close_floppy_disk(int drv);
224         bool is_floppy_disk_inserted(int drv);
225         void is_floppy_disk_protected(int drv, bool value);
226         bool is_floppy_disk_protected(int drv);
227         uint32_t is_floppy_disk_accessed();
228 #endif
229         bool is_frame_skippable();
230         
231         void update_config();
232         bool process_state(FILEIO* state_fio, bool loading);
233         
234         // ----------------------------------------
235         // for each device
236         // ----------------------------------------
237         
238         // devices
239         DEVICE* get_device(int id);
240         //DEVICE* dummy;
241         //DEVICE* first_device;
242         //DEVICE* last_device;
243 };
244
245 #endif