OSDN Git Service

[VM][Draw][Qt] Add 4:3 screen to MZ80K/C/1200/1500 , PC8801, X1.
[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 // device informations for win32
50 #define USE_DIPSWITCH
51 #define USE_TAPE
52 //#define USE_TAPE_PTR
53 #define USE_TAPE_BUTTON
54 #define NOTIFY_KEY_DOWN
55 #define USE_SHIFT_NUMPAD_KEY
56 #define USE_ALT_F10_KEY
57 #define USE_AUTO_KEY            5
58 #define USE_AUTO_KEY_RELEASE    6
59 #define USE_AUTO_KEY_NO_CAPS
60 #define USE_DEBUGGER
61 #define USE_STATE
62 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
63 #define USE_FD1
64 #define USE_FD2
65 #define USE_FD3
66 #define USE_FD4
67 #define USE_ACCESS_LAMP
68 //#define USE_DISK_WRITE_PROTECT
69 #endif
70 #if defined(_MZ80K)
71 #define USE_MONITOR_TYPE        2
72 #endif
73 #define USE_CRT_MONITOR_4_3 1
74
75 #include "../../common.h"
76 #include "../../fileio.h"
77
78 class EMU;
79 class DEVICE;
80 class EVENT;
81
82 #if defined(_MZ1200) || defined(_MZ80A)
83 class AND;
84 #endif
85 class DATAREC;
86 class I8253;
87 class I8255;
88 class LS393;
89 class PCM1BIT;
90 class Z80;
91
92 class KEYBOARD;
93 class MEMORY;
94
95 #if defined(SUPPORT_MZ80AIF)
96 class MB8877;
97 class IO;
98 class MZ80AIF;
99 #elif defined(SUPPORT_MZ80FIO)
100 class T3444A;
101 class IO;
102 class MZ80FIO;
103 #endif
104
105 class VM
106 {
107 protected:
108         EMU* emu;
109         
110         // devices
111         EVENT* event;
112         
113 #if defined(_MZ1200) || defined(_MZ80A)
114         AND* and_int;
115 #endif
116         DATAREC* drec;
117         I8253* ctc;
118         I8255* pio;
119         LS393* counter;
120         PCM1BIT* pcm;
121         Z80* cpu;
122         
123         KEYBOARD* keyboard;
124         MEMORY* memory;
125         
126 #if defined(SUPPORT_MZ80AIF)
127         MB8877* fdc;
128         IO* io;
129         MZ80AIF* mz80aif;
130 #elif defined(SUPPORT_MZ80FIO)
131         T3444A* fdc;
132         IO* io;
133         MZ80FIO* mz80fio;
134 #endif
135         
136 public:
137         // ----------------------------------------
138         // initialize
139         // ----------------------------------------
140         
141         VM(EMU* parent_emu);
142         ~VM();
143         
144         // ----------------------------------------
145         // for emulation class
146         // ----------------------------------------
147         
148         // drive virtual machine
149         void reset();
150         void run();
151         
152 #ifdef USE_DEBUGGER
153         // debugger
154         DEVICE *get_cpu(int index);
155 #endif
156         
157         // draw screen
158         void draw_screen();
159 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
160         int access_lamp();
161 #endif
162         
163         // sound generation
164         void initialize_sound(int rate, int samples);
165         uint16* create_sound(int* extra_frames);
166         int sound_buffer_ptr();
167         
168         // notify key
169         void key_down(int code, bool repeat);
170         void key_up(int code);
171         
172         // user interface
173 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
174         void open_disk(int drv, const _TCHAR* file_path, int bank);
175         void close_disk(int drv);
176         bool disk_inserted(int drv);
177         void set_disk_protected(int drv, bool value);
178         bool get_disk_protected(int drv);
179 #endif
180         void play_tape(const _TCHAR* file_path);
181         void rec_tape(const _TCHAR* file_path);
182         void close_tape();
183         bool tape_inserted();
184         bool tape_playing();
185         bool tape_recording();
186         int tape_position();
187         void push_play();
188         void push_stop();
189         void push_fast_forward();
190         void push_fast_rewind();
191         void push_apss_forward() {}
192         void push_apss_rewind() {}
193         bool now_skip();
194         
195         void update_config();
196         void save_state(FILEIO* state_fio);
197         bool load_state(FILEIO* state_fio);
198         
199         // ----------------------------------------
200         // for each device
201         // ----------------------------------------
202         
203         // devices
204         DEVICE* get_device(int id);
205         DEVICE* dummy;
206         DEVICE* first_device;
207         DEVICE* last_device;
208 };
209
210 #endif