OSDN Git Service

[VM][General] Merge upstream 2016-03-01. (Pahse 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
50 // device informations for win32
51 #define USE_DIPSWITCH
52 #define USE_TAPE
53 //#define USE_TAPE_PTR
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_DEBUGGER
63 #define USE_STATE
64 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
65 #define USE_FD1
66 #define USE_FD2
67 #define USE_FD3
68 #define USE_FD4
69 #define USE_ACCESS_LAMP
70 #define USE_CRT_MONITOR_4_3 1
71 //#define USE_DISK_WRITE_PROTECT
72 #endif
73 #if defined(_MZ80K)
74 #define USE_MONITOR_TYPE        2
75 #endif
76 #define USE_CRT_MONITOR_4_3 1
77
78 #include "../../common.h"
79 #include "../../fileio.h"
80
81 #ifdef USE_SOUND_VOLUME
82 static const _TCHAR *sound_device_caption[] = {
83         _T("Beep"), _T("CMT"),
84 };
85 #endif
86
87 class EMU;
88 class DEVICE;
89 class EVENT;
90
91 #if defined(_MZ1200) || defined(_MZ80A)
92 class AND;
93 #endif
94 class DATAREC;
95 class I8253;
96 class I8255;
97 class LS393;
98 class PCM1BIT;
99 class Z80;
100
101 class KEYBOARD;
102 class MEMORY;
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         
135 #if defined(SUPPORT_MZ80AIF)
136         MB8877* fdc;
137         IO* io;
138         MZ80AIF* mz80aif;
139 #elif defined(SUPPORT_MZ80FIO)
140         T3444A* fdc;
141         IO* io;
142         MZ80FIO* mz80fio;
143 #endif
144         
145 public:
146         // ----------------------------------------
147         // initialize
148         // ----------------------------------------
149         
150         VM(EMU* parent_emu);
151         ~VM();
152         
153         // ----------------------------------------
154         // for emulation class
155         // ----------------------------------------
156         
157         // drive virtual machine
158         void reset();
159         void run();
160         
161 #ifdef USE_DEBUGGER
162         // debugger
163         DEVICE *get_cpu(int index);
164 #endif
165         
166         // draw screen
167         void draw_screen();
168 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
169         uint32_t get_access_lamp_status();
170 #endif
171         
172         // sound generation
173         void initialize_sound(int rate, int samples);
174         uint16_t* create_sound(int* extra_frames);
175         int get_sound_buffer_ptr();
176 #ifdef USE_SOUND_VOLUME
177         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
178 #endif
179         
180         // notify key
181         void key_down(int code, bool repeat);
182         void key_up(int code);
183         
184         // user interface
185 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
186         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
187         void close_floppy_disk(int drv);
188         bool is_floppy_disk_inserted(int drv);
189         void is_floppy_disk_protected(int drv, bool value);
190         bool is_floppy_disk_protected(int drv);
191 #endif
192         void play_tape(const _TCHAR* file_path);
193         void rec_tape(const _TCHAR* file_path);
194         void close_tape();
195         bool is_tape_inserted();
196         bool is_tape_playing();
197         bool is_tape_recording();
198         int get_tape_position();
199         void push_play();
200         void push_stop();
201         void push_fast_forward();
202         void push_fast_rewind();
203         void push_apss_forward() {}
204         void push_apss_rewind() {}
205         bool is_frame_skippable();
206         
207         void update_config();
208         void save_state(FILEIO* state_fio);
209         bool load_state(FILEIO* state_fio);
210         
211         // ----------------------------------------
212         // for each device
213         // ----------------------------------------
214         
215         // devices
216         DEVICE* get_device(int id);
217         DEVICE* dummy;
218         DEVICE* first_device;
219         DEVICE* last_device;
220 };
221
222 #endif