OSDN Git Service

[VM][General] Merge upstream 2015-09-23.
[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 #if defined(SUPPORT_MZ80AIF)
42 #define HAS_MB8866
43 #define MAX_DRIVE               4
44 #elif defined(SUPPORT_MZ80FIO)
45 #define HAS_T3444M
46 #define MAX_DRIVE               4
47 #endif
48
49 #define SCREEN_WIDTH_ASPECT SCREEN_WIDTH 
50 #define SCREEN_HEIGHT_ASPECT SCREEN_HEIGHT
51 #define WINDOW_WIDTH_ASPECT 640 
52 #define WINDOW_HEIGHT_ASPECT 480
53
54 // device informations for win32
55 #define USE_TAPE
56 #define USE_TAPE_PTR
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 #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 #define USE_DISK_WRITE_PROTECT
73 #endif
74 #if defined(_MZ80K)
75 #define USE_MONITOR_TYPE        2
76 #endif
77
78 #include "../../common.h"
79 #include "../../fileio.h"
80
81 class EMU;
82 class DEVICE;
83 class EVENT;
84
85 #if defined(_MZ1200) || defined(_MZ80A)
86 class AND;
87 #endif
88 class DATAREC;
89 class I8253;
90 class I8255;
91 class LS393;
92 class PCM1BIT;
93 class Z80;
94
95 class DISPLAY;
96 class KEYBOARD;
97 class MEMORY;
98
99 #if defined(SUPPORT_MZ80AIF)
100 class MB8877;
101 class IO;
102 class MZ80AIF;
103 #elif defined(SUPPORT_MZ80FIO)
104 class T3444A;
105 class IO;
106 class MZ80FIO;
107 #endif
108
109 class VM
110 {
111 protected:
112         EMU* emu;
113         
114         // devices
115         EVENT* event;
116         
117 #if defined(_MZ1200) || defined(_MZ80A)
118         AND* l_and; // and is reserved word.
119 #endif
120         DATAREC* drec;
121         I8253* ctc;
122         I8255* pio;
123         LS393* counter;
124         PCM1BIT* pcm;
125         Z80* cpu;
126         
127         DISPLAY* display;
128         KEYBOARD* keyboard;
129         MEMORY* memory;
130         
131 #if defined(SUPPORT_MZ80AIF)
132         MB8877* fdc;
133         IO* io;
134         MZ80AIF* mz80aif;
135 #elif defined(SUPPORT_MZ80FIO)
136         T3444A* fdc;
137         IO* io;
138         MZ80FIO* mz80fio;
139 #endif
140         
141 public:
142         // ----------------------------------------
143         // initialize
144         // ----------------------------------------
145         
146         VM(EMU* parent_emu);
147         ~VM();
148         
149         // ----------------------------------------
150         // for emulation class
151         // ----------------------------------------
152         
153         // drive virtual machine
154         void reset();
155         void run();
156         
157 #ifdef USE_DEBUGGER
158         // debugger
159         DEVICE *get_cpu(int index);
160 #endif
161         
162         // draw screen
163         void draw_screen();
164 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
165         int access_lamp();
166 #endif
167         
168         // sound generation
169         void initialize_sound(int rate, int samples);
170         uint16* create_sound(int* extra_frames);
171         int sound_buffer_ptr();
172         
173         // notify key
174         void key_down(int code, bool repeat);
175         void key_up(int code);
176         
177         // user interface
178 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
179         void open_disk(int drv, const _TCHAR* file_path, int bank);
180         void close_disk(int drv);
181         bool disk_inserted(int drv);
182         void set_disk_protected(int drv, bool value);
183         bool get_disk_protected(int drv);
184 #endif
185         void play_tape(const _TCHAR* file_path);
186         void rec_tape(const _TCHAR* file_path);
187         void close_tape();
188         bool tape_inserted();
189 #if defined(USE_TAPE_PTR)
190         int get_tape_ptr(void);
191 #endif
192         bool get_tape_play(void);
193         void push_play();
194         void push_stop();
195         void push_fast_forward();
196         void push_fast_rewind();
197         void push_apss_forward() {}
198         void push_apss_rewind() {}
199         bool now_skip();
200         
201         void update_config();
202         void save_state(FILEIO* state_fio);
203         bool load_state(FILEIO* state_fio);
204         
205         // ----------------------------------------
206         // for each device
207         // ----------------------------------------
208         
209         // devices
210         DEVICE* get_device(int id);
211         DEVICE* dummy;
212         DEVICE* first_device;
213         DEVICE* last_device;
214 };
215
216 #endif