OSDN Git Service

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