OSDN Git Service

[VM][MZ5500][WIP] Applying new state framework.WIP.
[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 #define WINDOW_HEIGHT_ASPECT    240
42 #if defined(SUPPORT_MZ80AIF)
43 #define HAS_MB8866
44 #define MAX_DRIVE               4
45 #elif defined(SUPPORT_MZ80FIO)
46 #define HAS_T3444M
47 #define MAX_DRIVE               4
48 #endif
49 #define PRINTER_STROBE_RISING_EDGE
50
51 // device informations for win32
52 #define USE_DIPSWITCH
53 #define USE_TAPE                1
54 #define USE_TAPE_BUTTON
55 #define NOTIFY_KEY_DOWN
56 #define USE_KEY_LOCKED
57 #define USE_SHIFT_NUMPAD_KEY
58 #define USE_ALT_F10_KEY
59 #define USE_AUTO_KEY            5
60 #define USE_AUTO_KEY_RELEASE    6
61 #define USE_AUTO_KEY_NO_CAPS
62 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
63 #define USE_SOUND_VOLUME        4
64 #else
65 #define USE_SOUND_VOLUME        3
66 #endif
67 #define USE_PRINTER
68 #define USE_PRINTER_TYPE        4
69 #define USE_DEBUGGER
70 #define USE_STATE
71 #if defined(SUPPORT_MZ80AIF)
72 #define USE_DRIVE_TYPE          2
73 #endif
74 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
75 #define USE_FLOPPY_DISK         4
76 #endif
77 #if defined(_MZ80K)
78 #define USE_MONITOR_TYPE        2
79 #endif
80 #define USE_CPU_Z80
81
82 #include "../../common.h"
83 #include "../../fileio.h"
84
85 #ifdef USE_SOUND_VOLUME
86 static const _TCHAR *sound_device_caption[] = {
87         _T("Beep"), _T("CMT (Signal)"),
88 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
89         _T("Noise (FDD)"),
90 #endif
91         _T("Noise (CMT)"),
92 };
93 #endif
94
95 class csp_state_utils;
96 class EMU;
97 class DEVICE;
98 class EVENT;
99
100 #if defined(_MZ1200) || defined(_MZ80A)
101 class AND;
102 #endif
103 class DATAREC;
104 class I8253;
105 class I8255;
106 class LS393;
107 class PCM1BIT;
108 class Z80;
109
110 class KEYBOARD;
111 class MEMORY;
112 class PRINTER;
113
114 #if defined(SUPPORT_MZ80AIF)
115 class MB8877;
116 class IO;
117 class MZ80AIF;
118 #elif defined(SUPPORT_MZ80FIO)
119 class T3444A;
120 class IO;
121 class MZ80FIO;
122 #endif
123
124 class VM
125 {
126 protected:
127         EMU* emu;
128         csp_state_utils* state_entry;
129         
130         // devices
131         EVENT* event;
132         
133 #if defined(_MZ1200) || defined(_MZ80A)
134         AND* and_int;
135 #endif
136         DATAREC* drec;
137         I8253* ctc;
138         I8255* pio;
139         LS393* counter;
140         PCM1BIT* pcm;
141         Z80* cpu;
142         
143         KEYBOARD* keyboard;
144         MEMORY* memory;
145         PRINTER* printer;
146         
147 #if defined(SUPPORT_MZ80AIF)
148         MB8877* fdc;
149         IO* io;
150         MZ80AIF* mz80aif;
151 #elif defined(SUPPORT_MZ80FIO)
152         T3444A* fdc;
153         IO* io;
154         MZ80FIO* mz80fio;
155 #endif
156         
157 public:
158         // ----------------------------------------
159         // initialize
160         // ----------------------------------------
161         
162         VM(EMU* parent_emu);
163         ~VM();
164         
165         // ----------------------------------------
166         // for emulation class
167         // ----------------------------------------
168         
169         // drive virtual machine
170         void reset();
171         void run();
172         
173 #ifdef USE_DEBUGGER
174         // debugger
175         DEVICE *get_cpu(int index);
176 #endif
177         
178         // draw screen
179         void draw_screen();
180         
181         // sound generation
182         void initialize_sound(int rate, int samples);
183         uint16_t* create_sound(int* extra_frames);
184         int get_sound_buffer_ptr();
185 #ifdef USE_SOUND_VOLUME
186         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
187 #endif
188         
189         // notify key
190         void key_down(int code, bool repeat);
191         void key_up(int code);
192         bool get_caps_locked();
193         bool get_kana_locked();
194         
195         // user interface
196 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
197         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
198         void close_floppy_disk(int drv);
199         bool is_floppy_disk_inserted(int drv);
200         void is_floppy_disk_protected(int drv, bool value);
201         bool is_floppy_disk_protected(int drv);
202         uint32_t is_floppy_disk_accessed();
203 #endif
204         void play_tape(int drv, const _TCHAR* file_path);
205         void rec_tape(int drv, const _TCHAR* file_path);
206         void close_tape(int drv);
207         bool is_tape_inserted(int drv);
208         bool is_tape_playing(int drv);
209         bool is_tape_recording(int drv);
210         int get_tape_position(int drv);
211         const _TCHAR* get_tape_message(int drv);
212         void push_play(int drv);
213         void push_stop(int drv);
214         void push_fast_forward(int drv);
215         void push_fast_rewind(int drv);
216         void push_apss_forward(int drv) {}
217         void push_apss_rewind(int drv) {}
218         bool is_frame_skippable();
219         
220         void update_config();
221         void decl_state();
222         void save_state(FILEIO* state_fio);
223         bool load_state(FILEIO* state_fio);
224         
225         // ----------------------------------------
226         // for each device
227         // ----------------------------------------
228         
229         // devices
230         DEVICE* get_device(int id);
231         DEVICE* dummy;
232         DEVICE* first_device;
233         DEVICE* last_device;
234 };
235
236 #endif