OSDN Git Service

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