OSDN Git Service

[VM][FMTOWNS][MEMORY] Fix setup around memory banks by I/O 0404h and 0480h.
[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_KEY_LOCKED
55 #define USE_AUTO_KEY            5
56 #define USE_AUTO_KEY_RELEASE    6
57 #define USE_AUTO_KEY_NO_CAPS
58 #if defined(_MZ80K) || defined(_MZ1200)
59 //#define USE_AUTO_KEY_NUMPAD
60 #define USE_VM_AUTO_KEY_TABLE
61 #endif
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 // COLOR GAL 5 - 2019.01.24 Suga
78 #if defined(_MZ80K)
79 #define USE_MONITOR_TYPE        8
80 #endif
81 #if defined(_MZ1200)
82 #define USE_MONITOR_TYPE        4
83 #endif
84 #define USE_CPU_Z80
85
86 #if defined(_MZ80K) || defined(_MZ1200)
87 static const int vm_auto_key_table_base[][2] = {
88         {0xa1,  0x200 | 0x74},  // '。': KANA + F5
89         {0xa2,  0x200 | 0x70},  // '「': KANA + F1
90         {0xa3,  0x200 | 0x71},  // '」': KANA + F2
91         {0xa4,  0x200 | 0x72},  // '、': KANA + F3
92         {0xa5,  0x200 | 0x73},  // '・': KANA + F4
93         {0xa6,  0x200 | 0xdb},  // 'ヲ': KANA + '['
94         {0xa7,  0x200 | 0x6f},  // 'ァ': KANA + NumPad '/'
95         {0xa8,  0x200 | 0x67},  // 'ィ': KANA + NumPad '7'
96         {0xa9,  0x200 | 0x64},  // 'ゥ': KANA + NumPad '4'
97         {0xaa,  0x200 | 0x61},  // 'ェ': KANA + NumPad '1'
98         {0xab,  0x200 | 0x75},  // 'ォ': KANA + F6
99         {0xac,  0x200 | 0xfa},  // 'ャ': KANA + NumPad '*'
100         {0xad,  0x200 | 0x68},  // 'ュ': KANA + NumPad '8'
101         {0xae,  0x200 | 0x65},  // 'ョ': KANA + NumPad '5'
102         {0xaf,  0x200 | 0x62},  // 'ッ': KANA + NumPad '2'
103         {0xb0,  0x200 | 0x76},  // 'ー': KANA + F7
104         {0xb9,  0x200 | 0xde},  // 'ケ': KANA + '^'
105         {0xcd,  0x200 | 0xc0},  // 'ヘ': KANA + '@'
106         {0xd1,  0x200 | 0xdc},  // 'ム': KANA + '\'
107         {0xdb,  0x200 | 0xba},  // 'ロ': KANA + ':'
108         {0xde,  0x200 | 0xe2},  // '゙': KANA + '_'
109         {0xdf,  0x200 | 0xdd},  // '゚': KANA + ']'
110         {-1,    -1},
111 };
112 #endif
113
114 #include "../../common.h"
115 #include "../../fileio.h"
116 #include "../vm_template.h"
117
118 #ifdef USE_SOUND_VOLUME
119 static const _TCHAR *sound_device_caption[] = {
120         _T("Beep"), _T("CMT (Signal)"),
121 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
122         _T("Noise (FDD)"),
123 #endif
124         _T("Noise (CMT)"),
125 };
126 #endif
127
128 class EMU;
129 class DEVICE;
130 class EVENT;
131
132 #if defined(_MZ1200) || defined(_MZ80A)
133 class AND;
134 #endif
135 class DATAREC;
136 class I8253;
137 class I8255;
138 class LS393;
139 class PCM1BIT;
140 class Z80;
141
142 namespace MZ80 {
143         class KEYBOARD;
144         class MEMORY;
145         class PRINTER;
146 }
147 #if defined(SUPPORT_MZ80AIF)
148 class MB8877;
149 class IO;
150 namespace MZ80 {
151         class MZ80AIF;
152 }
153 #elif defined(SUPPORT_MZ80FIO)
154 class IO;
155 class T3444A;
156 namespace MZ80 {
157         class MZ80FIO;
158 }
159 #endif
160
161 class VM : public VM_TEMPLATE
162 {
163 protected:
164         //EMU* emu;
165         //csp_state_utils* state_entry;
166         
167         // devices
168         //EVENT* event;
169         
170 #if defined(_MZ1200) || defined(_MZ80A)
171         AND* and_int;
172 #endif
173         DATAREC* drec;
174         I8253* ctc;
175         I8255* pio;
176         LS393* counter;
177         PCM1BIT* pcm;
178         Z80* cpu;
179         
180         MZ80::KEYBOARD* keyboard;
181         MZ80::MEMORY* memory;
182         MZ80::PRINTER* printer;
183         
184 #if defined(SUPPORT_MZ80AIF)
185         MB8877* fdc;
186         IO* io;
187         MZ80::MZ80AIF* mz80aif;
188 #elif defined(SUPPORT_MZ80FIO)
189         T3444A* fdc;
190         IO* io;
191         MZ80::MZ80FIO* mz80fio;
192 #endif
193         
194 public:
195         // ----------------------------------------
196         // initialize
197         // ----------------------------------------
198         
199         VM(EMU_TEMPLATE* parent_emu);
200         ~VM();
201         
202         // ----------------------------------------
203         // for emulation class
204         // ----------------------------------------
205         
206         // drive virtual machine
207         void reset();
208         void run();
209         double get_frame_rate()
210         {
211                 return FRAMES_PER_SEC;
212         }
213         
214 #ifdef USE_DEBUGGER
215         // debugger
216         DEVICE *get_cpu(int index);
217 #endif
218         
219         // draw screen
220         void draw_screen();
221         
222         // sound generation
223         void initialize_sound(int rate, int samples);
224         uint16_t* create_sound(int* extra_frames);
225         int get_sound_buffer_ptr();
226 #ifdef USE_SOUND_VOLUME
227         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
228 #endif
229         
230         // notify key
231         void key_down(int code, bool repeat);
232         void key_up(int code);
233         bool get_caps_locked();
234         bool get_kana_locked();
235         
236         // user interface
237 #if defined(SUPPORT_MZ80AIF) || defined(SUPPORT_MZ80FIO)
238         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
239         void close_floppy_disk(int drv);
240         bool is_floppy_disk_inserted(int drv);
241         void is_floppy_disk_protected(int drv, bool value);
242         bool is_floppy_disk_protected(int drv);
243         uint32_t is_floppy_disk_accessed();
244 #endif
245         void play_tape(int drv, const _TCHAR* file_path);
246         void rec_tape(int drv, const _TCHAR* file_path);
247         void close_tape(int drv);
248         bool is_tape_inserted(int drv);
249         bool is_tape_playing(int drv);
250         bool is_tape_recording(int drv);
251         int get_tape_position(int drv);
252         const _TCHAR* get_tape_message(int drv);
253         void push_play(int drv);
254         void push_stop(int drv);
255         void push_fast_forward(int drv);
256         void push_fast_rewind(int drv);
257         void push_apss_forward(int drv) {}
258         void push_apss_rewind(int drv) {}
259         bool is_frame_skippable();
260         
261         double get_current_usec();
262         uint64_t get_current_clock_uint64();
263         
264         void update_config();
265         bool process_state(FILEIO* state_fio, bool loading);
266         
267         // ----------------------------------------
268         // for each device
269         // ----------------------------------------
270         
271         // devices
272         DEVICE* get_device(int id);
273         //DEVICE* dummy;
274         //DEVICE* first_device;
275         //DEVICE* last_device;
276 };
277
278 #endif