OSDN Git Service

[VM] Fix FTBFS for Upstream 2017-03-12.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz2500 / mz80b.h
1 /*
2         SHARP MZ-80B Emulator 'EmuZ-80B'
3         SHARP MZ-2200 Emulator 'EmuZ-2200'
4
5         Author : Takeda.Toshiya
6         Date   : 2013.03.14-
7
8         [ virtual machine ]
9 */
10
11 #ifndef _MZ80B_H_
12 #define _MZ80B_H_
13
14 #if defined(_MZ80B)
15 #define DEVICE_NAME             "SHARP MZ-80B"
16 #define CONFIG_NAME             "mz80b"
17 #elif defined(_MZ2000)
18 #define DEVICE_NAME             "SHARP MZ-2000"
19 #define CONFIG_NAME             "mz2000"
20 #else
21 #define DEVICE_NAME             "SHARP MZ-2200"
22 #define CONFIG_NAME             "mz2200"
23 #endif
24
25 #ifndef _MZ80B
26 #define SUPPORT_QUICK_DISK
27 #define SUPPORT_16BIT_BOARD
28 #endif
29
30 // device informations for virtual machine
31 #define FRAMES_PER_SEC          60
32 #define LINES_PER_FRAME         262
33 #define CPU_CLOCKS              4000000
34 #define SCREEN_WIDTH            640
35 #define SCREEN_HEIGHT           400
36 #define WINDOW_HEIGHT_ASPECT    480
37 #define MAX_DRIVE               4
38 #define HAS_MB8876
39 #ifdef SUPPORT_QUICK_DISK
40 #endif
41 #ifdef SUPPORT_16BIT_BOARD
42 #define HAS_I88
43 #define I8259_MAX_CHIPS         1
44 #endif
45 #define PRINTER_STROBE_RISING_EDGE
46
47 // memory wait
48 #define Z80_MEMORY_WAIT
49 #define Z80_IO_WAIT
50
51 // device informations for win32
52 #define USE_SPECIAL_RESET
53 #define USE_FD1
54 #define USE_FD2
55 #define USE_FD3
56 #define USE_FD4
57 #ifdef SUPPORT_QUICK_DISK
58 #define USE_QD1
59 #endif
60 #define USE_TAPE
61 #define USE_TAPE_BUTTON
62 #define USE_SHIFT_NUMPAD_KEY
63 #define USE_ALT_F10_KEY
64 #define USE_AUTO_KEY            5
65 #define USE_AUTO_KEY_RELEASE    6
66 #define USE_AUTO_KEY_CAPS
67 #define USE_MONITOR_TYPE        4
68 #ifndef _MZ80B
69 #define USE_CRT_FILTER
70 #endif
71 #define USE_SCANLINE
72 #define USE_ACCESS_LAMP
73 #define USE_SOUND_VOLUME        4
74 #define USE_PRINTER
75 #define USE_PRINTER_TYPE        4
76 #define USE_DEBUGGER
77 #define USE_STATE
78 #define SUPPORT_ROMA_KANA_CONVERSION
79
80 #include "../../common.h"
81 #include "../../fileio.h"
82
83 #ifdef USE_SOUND_VOLUME
84 static const _TCHAR *sound_device_caption[] = {
85         _T("Beep"), _T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"),
86 };
87 #endif
88
89 class EMU;
90 class DEVICE;
91 class EVENT;
92
93 class DATAREC;
94 class I8253;
95 class I8255;
96 class IO;
97 class MB8877;
98 class PCM1BIT;
99 class Z80;
100 class Z80PIO;
101
102 class CMT;
103 class FLOPPY;
104 class KEYBOARD;
105 class MEMORY;
106 class MZ1R12;
107 class MZ1R13;
108 class PRINTER;
109 class TIMER;
110
111 #ifdef SUPPORT_QUICK_DISK
112 class Z80SIO;
113 class QUICKDISK;
114 #endif
115
116 #ifdef SUPPORT_16BIT_BOARD
117 class I286;
118 class I8259;
119 class MZ1M01;
120 #endif
121
122 class VM
123 {
124 protected:
125         EMU* emu;
126         
127         // devices
128         EVENT* event;
129         
130         DATAREC* drec;
131         I8253* pit;
132         I8255* pio_i;
133         IO* io;
134         MB8877* fdc;
135         PCM1BIT* pcm;
136         Z80* cpu;
137         Z80PIO* pio;
138         
139         CMT* cmt;
140         FLOPPY* floppy;
141         KEYBOARD* keyboard;
142         MEMORY* memory;
143         MZ1R12* mz1r12;
144         MZ1R13* mz1r13;
145         PRINTER* printer;
146         TIMER* timer;
147         
148 #ifdef SUPPORT_QUICK_DISK
149         Z80SIO* sio;
150         QUICKDISK* qd;
151 #endif
152         
153 #ifdef SUPPORT_16BIT_BOARD
154         Z80PIO* pio_to16;
155         I286* cpu_16;
156         I8259* pic_16;
157         MZ1M01* mz1m01;
158 #endif
159         
160 public:
161         // ----------------------------------------
162         // initialize
163         // ----------------------------------------
164         
165         VM(EMU* parent_emu);
166         ~VM();
167         
168         // ----------------------------------------
169         // for emulation class
170         // ----------------------------------------
171         
172         // drive virtual machine
173         void reset();
174         void special_reset();
175         void run();
176         
177 #ifdef USE_DEBUGGER
178         // debugger
179         DEVICE *get_cpu(int index);
180 #endif
181         
182         // draw screen
183         void draw_screen();
184         uint32_t get_access_lamp_status();
185         
186         // sound generation
187         void initialize_sound(int rate, int samples);
188         uint16_t* create_sound(int* extra_frames);
189         int get_sound_buffer_ptr();
190 #ifdef USE_SOUND_VOLUME
191         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
192 #endif
193         
194         // user interface
195         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
196         void close_floppy_disk(int drv);
197         bool is_floppy_disk_inserted(int drv);
198         void is_floppy_disk_protected(int drv, bool value);
199         bool is_floppy_disk_protected(int drv);
200 #ifdef SUPPORT_QUICK_DISK
201         void open_quick_disk(int drv, const _TCHAR* file_path);
202         void close_quick_disk(int drv);
203         bool is_quick_disk_inserted(int drv);
204 #endif
205         void play_tape(const _TCHAR* file_path);
206         void rec_tape(const _TCHAR* file_path);
207         void close_tape();
208         bool is_tape_inserted();
209         bool is_tape_playing();
210         bool is_tape_recording();
211         int get_tape_position();
212         void push_play();
213         void push_stop();
214         void push_fast_forward();
215         void push_fast_rewind();
216         void push_apss_forward() {}
217         void push_apss_rewind() {}
218         bool is_frame_skippable();
219         
220         void update_config();
221         void save_state(FILEIO* state_fio);
222         bool load_state(FILEIO* state_fio);
223         
224         // ----------------------------------------
225         // for each device
226         // ----------------------------------------
227         
228         // devices
229         DEVICE* get_device(int id);
230         DEVICE* dummy;
231         DEVICE* first_device;
232         DEVICE* last_device;
233 };
234
235 #endif