OSDN Git Service

c3e621db0731046555fad489b782c717aec1800f
[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 YM2203_PORT_MODE        0x80
52
53 #define SCREEN_WIDTH_ASPECT SCREEN_WIDTH 
54 #define SCREEN_HEIGHT_ASPECT SCREEN_HEIGHT
55 #define WINDOW_WIDTH_ASPECT SCREEN_WIDTH
56 #define WINDOW_HEIGHT_ASPECT SCREEN_HEIGHT 
57
58 // device informations for win32
59 #define USE_CART1
60 #define USE_CART2
61 #define USE_TAPE
62 #define USE_TAPE_PTR
63 #if defined(_PX7)
64 #define USE_LASER_DISC
65 #define USE_MOVIE_PLAYER
66 #else
67 #define USE_FD1
68 #define USE_FD2
69 #endif
70 #define USE_ALT_F10_KEY
71 #define USE_AUTO_KEY            6
72 #define USE_AUTO_KEY_RELEASE    10
73 #define USE_DEBUGGER
74 #define USE_STATE
75
76 #include "../../common.h"
77 #include "../../fileio.h"
78
79 class EMU;
80 class DEVICE;
81 class EVENT;
82
83 class DATAREC;
84 class I8255;
85 class IO;
86 #if defined(_PX7)
87 class LD700;
88 #endif
89 class NOT;
90 class YM2203;
91 class PCM1BIT;
92 #if defined(_MSX2)
93 class RP5C01;
94 class V99X8;
95 #else
96 class TMS9918A;
97 #endif
98 class Z80;
99
100 class JOYSTICK;
101 class KEYBOARD;
102 class MEMORY;
103 #if defined(_MSX2)
104 class RTCIF;
105 #endif
106 class SLOT0;
107 class SLOT1;
108 class SLOT2;
109 class SLOT3;
110
111 class VM
112 {
113 protected:
114         EMU* emu;
115         
116         // devices
117         EVENT* event;
118         
119         DATAREC* drec;
120         I8255* pio;
121         IO* io;
122 #if defined(_PX7)
123         LD700* ldp;
124 #endif
125         NOT* not_remote;
126         YM2203* psg;
127         PCM1BIT* pcm;
128 #if defined(_MSX2)
129         RP5C01* rtc;
130         V99X8* vdp;
131 #else
132         TMS9918A* vdp;
133 #endif
134         Z80* cpu;
135         
136         JOYSTICK* joystick;
137         KEYBOARD* keyboard;
138         MEMORY* memory;
139 #ifdef _MSX2
140         RTCIF* rtcif;
141 #endif
142         SLOT0 *slot0;
143         SLOT1 *slot1;
144         SLOT2 *slot2;
145         SLOT3 *slot3;
146         
147 public:
148         // ----------------------------------------
149         // initialize
150         // ----------------------------------------
151         
152         VM(EMU* parent_emu);
153         ~VM();
154         
155         // ----------------------------------------
156         // for emulation class
157         // ----------------------------------------
158         
159         // drive virtual machine
160         void reset();
161         void run();
162         
163 #ifdef USE_DEBUGGER
164         // debugger
165         DEVICE *get_cpu(int index);
166 #endif
167         
168         // draw screen
169         void draw_screen();
170         
171         // sound generation
172         void initialize_sound(int rate, int samples);
173         uint16* create_sound(int* extra_frames);
174         int sound_buffer_ptr();
175 #if defined(_PX7)
176         void movie_sound_callback(uint8 *buffer, long size);
177 #endif
178         
179         // user interface
180         void open_cart(int drv, const _TCHAR* file_path);
181         void close_cart(int drv);
182         bool cart_inserted(int drv);
183         void play_tape(const _TCHAR* file_path);
184         void rec_tape(const _TCHAR* file_path);
185         void close_tape();
186         bool tape_inserted();
187         bool tape_playing();
188         bool tape_recording();
189         int tape_position();
190 #if defined(_PX7)
191         void open_laser_disc(const _TCHAR* file_path);
192         void close_laser_disc();
193         bool laser_disc_inserted();
194 #else
195         void open_disk(int drv, const _TCHAR* file_path, int bank);
196         void close_disk(int drv);
197         bool disk_inserted(int drv);
198         void set_disk_protected(int drv, bool value);
199         bool get_disk_protected(int drv);
200         //int access_lamp();
201 #endif
202         bool now_skip();
203         
204         void update_config();
205         void save_state(FILEIO* state_fio);
206         bool load_state(FILEIO* state_fio);
207         
208         // ----------------------------------------
209         // for each device
210         // ----------------------------------------
211         
212         // devices
213         DEVICE* get_device(int id);
214         DEVICE* dummy;
215         DEVICE* first_device;
216         DEVICE* last_device;
217 };
218
219 #endif