OSDN Git Service

[General] Merge upstream 2015-04-07.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz80k / mz80k.h
1 /*
2         SHARP MZ-80K 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"
26 #define CONFIG_NAME             "mz80k"
27 #endif
28
29 #ifdef _MZ80A
30 #define SUPPORT_MZ80AIF
31 #endif
32
33 // device informations for virtual machine
34 #define FRAMES_PER_SEC          60
35 #define LINES_PER_FRAME         262
36 #define CPU_CLOCKS              2000000
37 #define SCREEN_WIDTH            320
38 #define SCREEN_HEIGHT           200
39 #ifdef SUPPORT_MZ80AIF
40 #define HAS_MB8876
41 #define MAX_DRIVE               4
42 #endif
43
44 // device informations for win32
45 #define USE_TAPE
46 #define USE_TAPE_PTR
47 #define USE_TAPE_BUTTON
48 #define USE_SHIFT_NUMPAD_KEY
49 #define USE_ALT_F10_KEY
50 #define USE_AUTO_KEY            5
51 #define USE_AUTO_KEY_RELEASE    6
52 #define USE_AUTO_KEY_NO_CAPS
53 #define USE_DEBUGGER
54 #define USE_STATE
55 #ifdef SUPPORT_MZ80AIF
56 #define USE_FD1
57 #define USE_FD2
58 #define USE_FD3
59 #define USE_FD4
60 #define USE_ACCESS_LAMP
61 #define USE_DISK_WRITE_PROTECT
62 #endif
63
64 #include "../../common.h"
65 #include "../../fileio.h"
66
67 class EMU;
68 class DEVICE;
69 class EVENT;
70
71 #if defined(_MZ1200) || defined(_MZ80A)
72 class AND;
73 #endif
74 class DATAREC;
75 class I8253;
76 class I8255;
77 class LS393;
78 class PCM1BIT;
79 class Z80;
80
81 class DISPLAY;
82 class KEYBOARD;
83 class MEMORY;
84
85 #ifdef SUPPORT_MZ80AIF
86 class MB8877;
87 class FLOPPY;
88 class IO;
89 #endif
90
91 class VM
92 {
93 protected:
94         EMU* emu;
95         
96         // devices
97         EVENT* event;
98         
99 #if defined(_MZ1200) || defined(_MZ80A)
100         AND* l_and; // and is reserved word.
101 #endif
102         DATAREC* drec;
103         I8253* ctc;
104         I8255* pio;
105         LS393* counter;
106         PCM1BIT* pcm;
107         Z80* cpu;
108         
109         DISPLAY* display;
110         KEYBOARD* keyboard;
111         MEMORY* memory;
112         
113 #ifdef SUPPORT_MZ80AIF
114         MB8877* fdc;
115         FLOPPY* floppy;
116         IO* io;
117 #endif
118         
119 public:
120         // ----------------------------------------
121         // initialize
122         // ----------------------------------------
123         
124         VM(EMU* parent_emu);
125         ~VM();
126         
127         // ----------------------------------------
128         // for emulation class
129         // ----------------------------------------
130         
131         // drive virtual machine
132         void reset();
133         void run();
134         
135 #ifdef USE_DEBUGGER
136         // debugger
137         DEVICE *get_cpu(int index);
138 #endif
139         
140         // draw screen
141         void draw_screen();
142 #ifdef SUPPORT_MZ80AIF
143         int access_lamp();
144 #endif
145         
146         // sound generation
147         void initialize_sound(int rate, int samples);
148         uint16* create_sound(int* extra_frames);
149         int sound_buffer_ptr();
150         
151         // user interface
152 #ifdef SUPPORT_MZ80AIF
153         void open_disk(int drv, _TCHAR* file_path, int bank);
154         void close_disk(int drv);
155         bool disk_inserted(int drv);
156  #if defined(USE_DISK_WRITE_PROTECT)
157         void write_protect_fd(int drv, bool flag);
158         bool is_write_protect_fd(int drv);
159  #endif
160 #endif
161         void play_tape(_TCHAR* file_path);
162         void rec_tape(_TCHAR* file_path);
163         void close_tape();
164         bool tape_inserted();
165 #if defined(USE_TAPE_PTR)
166         int get_tape_ptr(void);
167 #endif
168         bool get_tape_play(void);
169         void push_play();
170         void push_stop();
171         void push_fast_forward();
172         void push_fast_rewind();
173         void push_apss_forward() {}
174         void push_apss_rewind() {}
175         bool now_skip();
176         
177         void update_config();
178         void save_state(FILEIO* state_fio);
179         bool load_state(FILEIO* state_fio);
180         
181         // ----------------------------------------
182         // for each device
183         // ----------------------------------------
184         
185         // devices
186         DEVICE* get_device(int id);
187         DEVICE* dummy;
188         DEVICE* first_device;
189         DEVICE* last_device;
190 };
191
192 #endif