OSDN Git Service

[VM][General] Merge upstream 2016-03-01. (Pahse 1).
[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 #ifdef _MZ6550
37 #define HAS_I286
38 #else
39 #define HAS_I86
40 #endif
41 #define I8259_MAX_CHIPS         2
42 #define UPD7220_HORIZ_FREQ      24860
43 #define Z80CTC_CLOCKS           2457600
44 #define SINGLE_MODE_DMA
45 #define IO_ADDR_MAX             0x400
46 #define HAS_AY_3_8912
47 #define PRINTER_STROBE_RISING_EDGE
48 #define SUPPORT_VARIABLE_TIMING
49
50 // device informations for win32
51 #define USE_SPECIAL_RESET
52 #define USE_FD1
53 #define USE_FD2
54 #define USE_FD3
55 #define USE_FD4
56 #define NOTIFY_KEY_DOWN
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_CRT_FILTER
62 #define USE_SCANLINE
63 #define USE_ACCESS_LAMP
64 #define USE_SOUND_VOLUME        1
65 #define USE_MOUSE
66 #define USE_PRINTER
67 #define USE_PRINTER_TYPE        4
68 #define USE_DEBUGGER
69 #define USE_STATE
70 #define USE_MOUSE
71 #define USE_JOYSTICK
72
73 #include "../../common.h"
74 #include "../../fileio.h"
75
76 #ifdef USE_SOUND_VOLUME
77 static const _TCHAR *sound_device_caption[] = {
78         _T("PSG"),
79 };
80 #endif
81
82 class EMU;
83 class DEVICE;
84 class EVENT;
85
86 class I8237;
87 class I8255;
88 class I8259;
89 class I286;
90 class IO;
91 class LS393;
92 class NOT;
93 class RP5C01;
94 class UPD7220;
95 class UPD765A;
96 class YM2203;
97 class Z80CTC;
98 class Z80SIO;
99
100 class DISPLAY;
101 class KEYBOARD;
102 class MEMORY;
103 class SYSPORT;
104
105 class VM
106 {
107 protected:
108         EMU* emu;
109         
110         // devices
111         EVENT* event;
112         
113         DEVICE* printer;
114         I8237* dma;
115         I8255* pio;
116         I8259* pic;     // includes 2chips
117         I286* cpu;
118         IO* io;
119         LS393* div;
120         NOT* not_data1;
121         NOT* not_data2;
122         NOT* not_data3;
123         NOT* not_data4;
124         NOT* not_data5;
125         NOT* not_data6;
126         NOT* not_data7;
127         NOT* not_data8;
128         NOT* not_busy;
129         RP5C01* rtc;
130         UPD7220* gdc;
131         UPD765A* fdc;
132         YM2203* psg;
133         Z80CTC* ctc0;
134 #if defined(_MZ6500) || defined(_MZ6550)
135         Z80CTC* ctc1;
136 #endif
137         Z80SIO* sio;
138         
139         DISPLAY* display;
140         KEYBOARD* keyboard;
141         MEMORY* memory;
142         SYSPORT* sysport;
143         
144 public:
145         // ----------------------------------------
146         // initialize
147         // ----------------------------------------
148         
149         VM(EMU* parent_emu);
150         ~VM();
151         
152         // ----------------------------------------
153         // for emulation class
154         // ----------------------------------------
155         
156         // drive virtual machine
157         void reset();
158         void special_reset();
159         void run();
160         double get_frame_rate();
161         
162 #ifdef USE_DEBUGGER
163         // debugger
164         DEVICE *get_cpu(int index);
165 #endif
166         
167         // draw screen
168         void draw_screen();
169         uint32_t get_access_lamp_status();
170         
171         // sound generation
172         void initialize_sound(int rate, int samples);
173         uint16_t* create_sound(int* extra_frames);
174         int get_sound_buffer_ptr();
175 #ifdef USE_SOUND_VOLUME
176         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
177 #endif
178         
179         // notify key
180         void key_down(int code, bool repeat);
181         void key_up(int code);
182         
183         // user interface
184         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
185         void close_floppy_disk(int drv);
186         bool is_floppy_disk_inserted(int drv);
187         void is_floppy_disk_protected(int drv, bool value);
188         bool is_floppy_disk_protected(int drv);
189         bool is_frame_skippable();
190         
191         void update_config();
192         void save_state(FILEIO* state_fio);
193         bool load_state(FILEIO* state_fio);
194         
195         // ----------------------------------------
196         // for each device
197         // ----------------------------------------
198         
199         // devices
200         DEVICE* get_device(int id);
201         DEVICE* dummy;
202         DEVICE* first_device;
203         DEVICE* last_device;
204 };
205
206 #endif