OSDN Git Service

[General][WIP] Merge upstream 2017-03-20.Still not implement UIs.
[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_SOUND_FILES_FDD
54 #define USE_SOUND_FILES_BUTTONS
55 #define USE_DIPSWITCH
56 #define USE_TAPE1
57 #define USE_TAPE_BUTTON
58 #define NOTIFY_KEY_DOWN
59 #define USE_SHIFT_NUMPAD_KEY
60 #define USE_ALT_F10_KEY
61 #define USE_AUTO_KEY            5
62 #define USE_AUTO_KEY_RELEASE    6
63 #define USE_AUTO_KEY_NO_CAPS
64 #if defined(USE_SOUND_FILES)
65 #define USE_SOUND_VOLUME        4
66 #else
67 #define USE_SOUND_VOLUME        2
68 #endif
69 #define USE_PRINTER
70 #define USE_PRINTER_TYPE        4
71 #define USE_DEBUGGER
72 #define USE_STATE
73 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
74 #define USE_FD1
75 #define USE_FD2
76 #define USE_FD3
77 #define USE_FD4
78 #endif
79 #if defined(_MZ80K)
80 #define USE_MONITOR_TYPE        2
81 #endif
82
83 #include "../../common.h"
84 #include "../../fileio.h"
85
86 #ifdef USE_SOUND_VOLUME
87 static const _TCHAR *sound_device_caption[] = {
88         _T("Beep"), _T("CMT"),
89 #if defined(USE_SOUND_FILES)
90         _T("FDD SEEK"), _T("CMT Buttons"),
91 #endif
92 };
93 #endif
94
95 class EMU;
96 class DEVICE;
97 class EVENT;
98
99 #if defined(_MZ1200) || defined(_MZ80A)
100 class AND;
101 #endif
102 class DATAREC;
103 class I8253;
104 class I8255;
105 class LS393;
106 class PCM1BIT;
107 class Z80;
108
109 class KEYBOARD;
110 class MEMORY;
111 class PRINTER;
112
113 #if defined(SUPPORT_MZ80AIF)
114 class MB8877;
115 class IO;
116 class MZ80AIF;
117 #elif defined(SUPPORT_MZ80FIO)
118 class T3444A;
119 class IO;
120 class MZ80FIO;
121 #endif
122
123 class VM
124 {
125 protected:
126         EMU* emu;
127         
128         // devices
129         EVENT* event;
130         
131 #if defined(_MZ1200) || defined(_MZ80A)
132         AND* and_int;
133 #endif
134         DATAREC* drec;
135         I8253* ctc;
136         I8255* pio;
137         LS393* counter;
138         PCM1BIT* pcm;
139         Z80* cpu;
140         
141         KEYBOARD* keyboard;
142         MEMORY* memory;
143         PRINTER* printer;
144         
145 #if defined(SUPPORT_MZ80AIF)
146         MB8877* fdc;
147         IO* io;
148         MZ80AIF* mz80aif;
149 #elif defined(SUPPORT_MZ80FIO)
150         T3444A* fdc;
151         IO* io;
152         MZ80FIO* mz80fio;
153 #endif
154         
155 public:
156         // ----------------------------------------
157         // initialize
158         // ----------------------------------------
159         
160         VM(EMU* parent_emu);
161         ~VM();
162         
163         // ----------------------------------------
164         // for emulation class
165         // ----------------------------------------
166         
167         // drive virtual machine
168         void reset();
169         void run();
170         
171 #ifdef USE_DEBUGGER
172         // debugger
173         DEVICE *get_cpu(int index);
174 #endif
175         
176         // draw screen
177         void draw_screen();
178         
179         // sound generation
180         void initialize_sound(int rate, int samples);
181         uint16_t* create_sound(int* extra_frames);
182         int get_sound_buffer_ptr();
183 #ifdef USE_SOUND_VOLUME
184         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
185 #endif
186         
187         // notify key
188         void key_down(int code, bool repeat);
189         void key_up(int code);
190         
191         // user interface
192 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
193         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
194         void close_floppy_disk(int drv);
195         bool is_floppy_disk_inserted(int drv);
196         void is_floppy_disk_protected(int drv, bool value);
197         bool is_floppy_disk_protected(int drv);
198         uint32_t is_floppy_disk_accessed();
199 #endif
200         void play_tape(int drv, const _TCHAR* file_path);
201         void rec_tape(int drv, const _TCHAR* file_path);
202         void close_tape(int drv);
203         bool is_tape_inserted(int drv);
204         bool is_tape_playing(int drv);
205         bool is_tape_recording(int drv);
206         int get_tape_position(int drv);
207         const _TCHAR* get_tape_message(int drv);
208         void push_play(int drv);
209         void push_stop(int drv);
210         void push_fast_forward(int drv);
211         void push_fast_rewind(int drv);
212         void push_apss_forward(int drv) {}
213         void push_apss_rewind(int drv) {}
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