OSDN Git Service

[VM][STATE][WIP] Apply csp_state_utils:: to some VMs.This is WIP.
[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_FLOPPY_DISK         4
53 #define NOTIFY_KEY_DOWN
54 #define USE_KEY_LOCKED
55 #define USE_SHIFT_NUMPAD_KEY
56 #define USE_ALT_F10_KEY
57 #define USE_AUTO_KEY            5
58 #define USE_AUTO_KEY_RELEASE    6
59 #define USE_AUTO_KEY_NUMPAD
60 #define USE_SCREEN_FILTER
61 #define USE_SCANLINE
62 #define USE_SOUND_VOLUME        2
63 #define USE_MOUSE
64 #define USE_PRINTER
65 #define USE_PRINTER_TYPE        4
66 #define USE_DEBUGGER
67 #define USE_STATE
68 #define USE_CPU_I286
69
70 #include "../../common.h"
71 #include "../../fileio.h"
72
73 #ifdef USE_SOUND_VOLUME
74 static const _TCHAR *sound_device_caption[] = {
75         _T("PSG"), _T("Noise (FDD)"),
76 };
77 #endif
78
79 class csp_state_utils;
80 class EMU;
81 class DEVICE;
82 class EVENT;
83
84 class I8237;
85 class I8255;
86 class I8259;
87 //#if defined(HAS_I286) || defined(HAS_I186)
88 class I286;
89 //#else
90 //class I86;
91 //#endif
92 class IO;
93 class LS393;
94 class NOT;
95 class RP5C01;
96 class UPD7220;
97 class UPD765A;
98 //class YM2203;
99 class AY_3_891X;
100 class Z80CTC;
101 class Z80SIO;
102
103 class DISPLAY;
104 class KEYBOARD;
105 class MEMORY;
106 class SYSPORT;
107
108 class VM
109 {
110 protected:
111         EMU* emu;
112         csp_state_utils *state_entry;
113         
114         // devices
115         EVENT* event;
116         
117         DEVICE* printer;
118         I8237* dma;
119         I8255* pio;
120         I8259* pic;     // includes 2chips
121 //#if defined(HAS_I286) || defined(HAS_I186)
122         I286* cpu;
123 //#else
124 //      I86* cpu;
125 //#endif
126         IO* io;
127         LS393* div;
128         NOT* not_data0;
129         NOT* not_data1;
130         NOT* not_data2;
131         NOT* not_data3;
132         NOT* not_data4;
133         NOT* not_data5;
134         NOT* not_data6;
135         NOT* not_data7;
136         NOT* not_busy;
137         RP5C01* rtc;
138         UPD7220* gdc;
139         UPD765A* fdc;
140 //      YM2203* psg;
141         AY_3_891X* psg;
142         Z80CTC* ctc0;
143 #if defined(_MZ6500) || defined(_MZ6550)
144         Z80CTC* ctc1;
145 #endif
146         Z80SIO* sio;
147         
148         DISPLAY* display;
149         KEYBOARD* keyboard;
150         MEMORY* memory;
151         SYSPORT* sysport;
152         
153 public:
154         // ----------------------------------------
155         // initialize
156         // ----------------------------------------
157         
158         VM(EMU* parent_emu);
159         ~VM();
160         
161         // ----------------------------------------
162         // for emulation class
163         // ----------------------------------------
164         
165         // drive virtual machine
166         void reset();
167         void special_reset();
168         void run();
169         double get_frame_rate();
170         
171 #ifdef USE_DEBUGGER
172         // debugger
173         DEVICE *get_cpu(int index);
174 #endif
175         
176         // draw screen
177         void draw_screen();
178         
179         // sound generation
180         void initialize_sound(int rate, int samples);
181         uint16_t* create_sound(int* extra_frames);
182         int get_sound_buffer_ptr();
183 #ifdef USE_SOUND_VOLUME
184         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
185 #endif
186         
187         // notify key
188         void key_down(int code, bool repeat);
189         void key_up(int code);
190         bool get_caps_locked();
191         bool get_kana_locked();
192         
193         // user interface
194         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
195         void close_floppy_disk(int drv);
196         bool is_floppy_disk_inserted(int drv);
197         void is_floppy_disk_protected(int drv, bool value);
198         bool is_floppy_disk_protected(int drv);
199         uint32_t is_floppy_disk_accessed();
200         bool is_frame_skippable();
201         
202         void update_config();
203         void decl_state();
204         void save_state(FILEIO* state_fio);
205         bool load_state(FILEIO* state_fio);
206         
207         // ----------------------------------------
208         // for each device
209         // ----------------------------------------
210         
211         // devices
212         DEVICE* get_device(int id);
213         DEVICE* dummy;
214         DEVICE* first_device;
215         DEVICE* last_device;
216 };
217
218 #endif