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 / mz5500 / mz5500.h
1 /*
2         SHARP MZ-5500 Emulator 'EmuZ-5500'
3
4         Author : Takeda.Toshiya
5         Date   : 2008.04.10 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _MZ5500_H_
11 #define _MZ5500_H_
12
13 #if defined(_MZ5500)
14 #define DEVICE_NAME             "SHARP MZ-5500"
15 #define CONFIG_NAME             "mz5500"
16 #elif defined(_MZ6500)
17 #define DEVICE_NAME             "SHARP MZ-6500"
18 #define CONFIG_NAME             "mz6500"
19 #elif defined(_MZ6550)
20 #define DEVICE_NAME             "SHARP MZ-6550"
21 #define CONFIG_NAME             "mz6550"
22 #endif
23
24 // device informations for virtual machine
25 #define FRAMES_PER_SEC          55.49
26 #define LINES_PER_FRAME         448
27 #if defined(_MZ5500)
28 #define CPU_CLOCKS              4915200
29 #elif defined(_MZ6500) || defined(_MZ6550)
30 #define CPU_CLOCKS              8000000
31 #endif
32 #define SCREEN_WIDTH            640
33 #define SCREEN_HEIGHT           400
34 #define WINDOW_HEIGHT_ASPECT    480
35 #define MAX_DRIVE               4
36 #define UPD7220_HORIZ_FREQ      24860
37 #define Z80CTC_CLOCKS           2457600
38 #define SINGLE_MODE_DMA
39 #define HAS_AY_3_8912
40 #define PRINTER_STROBE_RISING_EDGE
41
42 // device informations for win32
43 #define USE_SPECIAL_RESET       1
44 #define USE_FLOPPY_DISK         4
45 #define USE_KEY_LOCKED
46 #define USE_AUTO_KEY            5
47 #define USE_AUTO_KEY_RELEASE    6
48 #define USE_AUTO_KEY_NUMPAD
49 #define USE_SCREEN_FILTER
50 #define USE_SCANLINE
51 #define USE_SOUND_VOLUME        2
52 #define USE_MOUSE
53 #define USE_PRINTER
54 #define USE_PRINTER_TYPE        4
55 #define USE_DEBUGGER
56 #define USE_STATE
57 #if defined(_MZ6550)
58 #define USE_CPU_I286
59 #else
60 #define USE_CPU_I86
61 #endif
62
63 #include "../../common.h"
64 #include "../../fileio.h"
65 #include "../vm_template.h"
66
67 #ifdef USE_SOUND_VOLUME
68 static const _TCHAR *sound_device_caption[] = {
69         _T("PSG"), _T("Noise (FDD)"),
70 };
71 #endif
72
73 class EMU;
74 class DEVICE;
75 class EVENT;
76
77 class I8237;
78 class I8255;
79 class I8259;
80 #if defined(_MZ6550)
81 class I286;
82 #else
83 class I86;
84 #endif
85 class IO;
86 class LS393;
87 class MEMORY;
88 class NOT;
89 class RP5C01;
90 class UPD7220;
91 class UPD765A;
92 //class YM2203;
93 class AY_3_891X;
94 class Z80CTC;
95 class Z80SIO;
96
97 namespace MZ5500 {
98         class DISPLAY;
99         class KEYBOARD;
100         class MEMBUS;
101         class SYSPORT;
102 }
103
104 class VM : public VM_TEMPLATE
105 {
106 protected:
107         //EMU* emu;
108         //csp_state_utils *state_entry;
109
110         // devices
111         //EVENT* event;
112
113         DEVICE* printer;
114         I8237* dma;
115         I8255* pio;
116         I8259* pic;     // includes 2chips
117 #if defined(_MZ6550)
118         I286* cpu;
119 #else
120         I86* cpu;
121 #endif
122         IO* io;
123         LS393* div;
124         NOT* not_data0;
125         NOT* not_data1;
126         NOT* not_data2;
127         NOT* not_data3;
128         NOT* not_data4;
129         NOT* not_data5;
130         NOT* not_data6;
131         NOT* not_data7;
132         NOT* not_busy;
133         RP5C01* rtc;
134         UPD7220* gdc;
135         UPD765A* fdc;
136 //      YM2203* psg;
137         AY_3_891X* psg;
138         Z80CTC* ctc0;
139 #if defined(_MZ6500) || defined(_MZ6550)
140         Z80CTC* ctc1;
141 #endif
142         Z80SIO* sio;
143
144         MZ5500::DISPLAY* display;
145         MZ5500::KEYBOARD* keyboard;
146         MZ5500::MEMBUS* memory;
147         MZ5500::SYSPORT* sysport;
148
149 public:
150         // ----------------------------------------
151         // initialize
152         // ----------------------------------------
153
154         VM(EMU_TEMPLATE* parent_emu);
155         ~VM();
156
157         // ----------------------------------------
158         // for emulation class
159         // ----------------------------------------
160
161         // drive virtual machine
162         void reset();
163         void special_reset(int num);
164         void run();
165         double get_frame_rate();
166
167 #ifdef USE_DEBUGGER
168         // debugger
169         DEVICE *get_cpu(int index);
170 #endif
171
172         // draw screen
173         void draw_screen();
174
175         // sound generation
176         void initialize_sound(int rate, int samples);
177         uint16_t* create_sound(int* extra_frames);
178         int get_sound_buffer_ptr();
179 #ifdef USE_SOUND_VOLUME
180         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
181 #endif
182
183         // notify key
184         void key_down(int code, bool repeat);
185         void key_up(int code);
186         bool get_caps_locked();
187         bool get_kana_locked();
188
189         // user interface
190         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
191         void close_floppy_disk(int drv);
192         bool is_floppy_disk_inserted(int drv);
193         void is_floppy_disk_protected(int drv, bool value);
194         bool is_floppy_disk_protected(int drv);
195         uint32_t is_floppy_disk_accessed();
196         bool is_frame_skippable();
197
198         double get_current_usec();
199         uint64_t get_current_clock_uint64();
200
201         void update_config();
202         bool process_state(FILEIO* state_fio, bool loading);
203
204         // ----------------------------------------
205         // for each device
206         // ----------------------------------------
207
208         // devices
209         DEVICE* get_device(int id);
210         //DEVICE* dummy;
211         //DEVICE* first_device;
212         //DEVICE* last_device;
213 };
214
215 #endif