OSDN Git Service

[VM][BMJR][FM7][MB8877][MSX][MZ80K][MZ700][MZ2500][T3444A][uPD765A] Add playing sound...
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz80k / mz80k.h
1 /*
2         SHARP MZ-80K/C Emulator 'EmuZ-80K'
3         SHARP MZ-1200 Emulator 'EmuZ-1200'
4
5         Author : Takeda.Toshiya
6         Date   : 2010.08.18-
7
8         SHARP MZ-80A Emulator 'EmuZ-80A'
9         Modify : Hideki Suga
10         Date   : 2014.12.10 -
11
12         [ virtual machine ]
13 */
14
15 #ifndef _MZ80K_H_
16 #define _MZ80K_H_
17
18 #if defined(_MZ1200)
19 #define DEVICE_NAME             "SHARP MZ-1200"
20 #define CONFIG_NAME             "mz1200"
21 #elif defined(_MZ80A)
22 #define DEVICE_NAME             "SHARP MZ-80A"
23 #define CONFIG_NAME             "mz80a"
24 #else
25 #define DEVICE_NAME             "SHARP MZ-80K/C"
26 #define CONFIG_NAME             "mz80k"
27 #endif
28
29 #ifdef _MZ80A
30 #define SUPPORT_MZ80AIF
31 #else
32 #define SUPPORT_MZ80FIO
33 #endif
34
35 // device informations for virtual machine
36 #define FRAMES_PER_SEC          60
37 #define LINES_PER_FRAME         262
38 #define CPU_CLOCKS              2000000
39 #define SCREEN_WIDTH            320
40 #define SCREEN_HEIGHT           200
41 #define WINDOW_HEIGHT_ASPECT    240
42 #if defined(SUPPORT_MZ80AIF)
43 #define HAS_MB8866
44 #define MAX_DRIVE               4
45 #elif defined(SUPPORT_MZ80FIO)
46 #define HAS_T3444M
47 #define MAX_DRIVE               4
48 #endif
49 #define PRINTER_STROBE_RISING_EDGE
50
51 // device informations for win32
52 #define USE_SOUND_FILES 4
53 #define USE_DIPSWITCH
54 #define USE_TAPE
55 #define USE_TAPE_BUTTON
56 #define NOTIFY_KEY_DOWN
57 #define USE_SHIFT_NUMPAD_KEY
58 #define USE_ALT_F10_KEY
59 #define USE_AUTO_KEY            5
60 #define USE_AUTO_KEY_RELEASE    6
61 #define USE_AUTO_KEY_NO_CAPS
62 #if defined(USE_SOUND_FILES)
63 #define USE_SOUND_VOLUME        4
64 #else
65 #define USE_SOUND_VOLUME        2
66 #endif
67 #define USE_PRINTER
68 #define USE_PRINTER_TYPE        4
69 #define USE_DEBUGGER
70 #define USE_STATE
71 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
72 #define USE_FD1
73 #define USE_FD2
74 #define USE_FD3
75 #define USE_FD4
76 #define USE_ACCESS_LAMP
77 #endif
78 #if defined(_MZ80K)
79 #define USE_MONITOR_TYPE        2
80 #endif
81
82 #include "../../common.h"
83 #include "../../fileio.h"
84
85 #ifdef USE_SOUND_VOLUME
86 static const _TCHAR *sound_device_caption[] = {
87         _T("Beep"), _T("CMT"),
88 #if defined(USE_SOUND_FILES)
89         _T("FDD SEEK"), _T("CMT Buttons"),
90 #endif
91 };
92 #endif
93
94 class EMU;
95 class DEVICE;
96 class EVENT;
97
98 #if defined(_MZ1200) || defined(_MZ80A)
99 class AND;
100 #endif
101 class DATAREC;
102 class I8253;
103 class I8255;
104 class LS393;
105 class PCM1BIT;
106 class Z80;
107
108 class KEYBOARD;
109 class MEMORY;
110 class PRINTER;
111
112 #if defined(SUPPORT_MZ80AIF)
113 class MB8877;
114 class IO;
115 class MZ80AIF;
116 #elif defined(SUPPORT_MZ80FIO)
117 class T3444A;
118 class IO;
119 class MZ80FIO;
120 #endif
121
122 class VM
123 {
124 protected:
125         EMU* emu;
126         
127         // devices
128         EVENT* event;
129         
130 #if defined(_MZ1200) || defined(_MZ80A)
131         AND* and_int;
132 #endif
133         DATAREC* drec;
134         I8253* ctc;
135         I8255* pio;
136         LS393* counter;
137         PCM1BIT* pcm;
138         Z80* cpu;
139         
140         KEYBOARD* keyboard;
141         MEMORY* memory;
142         PRINTER* printer;
143         
144 #if defined(SUPPORT_MZ80AIF)
145         MB8877* fdc;
146         IO* io;
147         MZ80AIF* mz80aif;
148 #elif defined(SUPPORT_MZ80FIO)
149         T3444A* fdc;
150         IO* io;
151         MZ80FIO* mz80fio;
152 #endif
153         
154 public:
155         // ----------------------------------------
156         // initialize
157         // ----------------------------------------
158         
159         VM(EMU* parent_emu);
160         ~VM();
161         
162         // ----------------------------------------
163         // for emulation class
164         // ----------------------------------------
165         
166         // drive virtual machine
167         void reset();
168         void run();
169         
170 #ifdef USE_DEBUGGER
171         // debugger
172         DEVICE *get_cpu(int index);
173 #endif
174         
175         // draw screen
176         void draw_screen();
177 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
178         uint32_t get_access_lamp_status();
179 #endif
180         
181         // sound generation
182         void initialize_sound(int rate, int samples);
183         uint16_t* create_sound(int* extra_frames);
184         int get_sound_buffer_ptr();
185 #ifdef USE_SOUND_VOLUME
186         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
187 #endif
188         
189         // notify key
190         void key_down(int code, bool repeat);
191         void key_up(int code);
192         
193         // user interface
194 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
195         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
196         void close_floppy_disk(int drv);
197         bool is_floppy_disk_inserted(int drv);
198         void is_floppy_disk_protected(int drv, bool value);
199         bool is_floppy_disk_protected(int drv);
200 #endif
201         void play_tape(const _TCHAR* file_path);
202         void rec_tape(const _TCHAR* file_path);
203         void close_tape();
204         bool is_tape_inserted();
205         bool is_tape_playing();
206         bool is_tape_recording();
207         int get_tape_position();
208         void push_play();
209         void push_stop();
210         void push_fast_forward();
211         void push_fast_rewind();
212         void push_apss_forward() {}
213         void push_apss_rewind() {}
214         bool is_frame_skippable();
215         
216         void update_config();
217         void save_state(FILEIO* state_fio);
218         bool load_state(FILEIO* state_fio);
219         
220         // ----------------------------------------
221         // for each device
222         // ----------------------------------------
223         
224         // devices
225         DEVICE* get_device(int id);
226         DEVICE* dummy;
227         DEVICE* first_device;
228         DEVICE* last_device;
229 };
230
231 #endif