OSDN Git Service

[VM][STATE] Apply new framework to some VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz3500 / mz3500.h
1 /*
2         SHARP MZ-3500 Emulator 'EmuZ-3500'
3
4         Author : Takeda.Toshiya
5         Date   : 2010.08.31-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _MZ3500_H_
11 #define _MZ3500_H_
12
13 #define DEVICE_NAME             "SHARP MZ-3500"
14 #define CONFIG_NAME             "mz3500"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          47.3
18 #define LINES_PER_FRAME         441
19 #define CPU_CLOCKS              4000000
20 #define SCREEN_WIDTH            640
21 #define SCREEN_HEIGHT           400
22 #define WINDOW_HEIGHT_ASPECT    480
23 #define MAX_DRIVE               4
24 #define UPD765A_WAIT_RESULT7
25 #define UPD765A_EXT_DRVSEL
26 #define UPD7220_HORIZ_FREQ      20920
27 #define IO_ADDR_MAX             0x100
28 #define PRINTER_STROBE_RISING_EDGE
29 #define SUPPORT_VARIABLE_TIMING
30
31 // device informations for win32
32 #define USE_SPECIAL_RESET
33 #define USE_DIPSWITCH
34 #define DIPSWITCH_DEFAULT       0x1fd
35 #define USE_FLOPPY_DISK         4
36 #define NOTIFY_KEY_DOWN
37 #define USE_KEY_LOCKED
38 #define USE_SHIFT_NUMPAD_KEY
39 #define USE_ALT_F10_KEY
40 #define USE_AUTO_KEY            5
41 #define USE_AUTO_KEY_RELEASE    6
42 #define USE_AUTO_KEY_NUMPAD
43 #define USE_MONITOR_TYPE        4
44 #define USE_SCREEN_FILTER
45 #define USE_SCANLINE
46 #define USE_SOUND_VOLUME        2
47 #define USE_PRINTER
48 #define USE_PRINTER_TYPE        4
49 #define USE_DEBUGGER
50 #define USE_STATE
51 #define USE_CPU_Z80
52
53 #include "../../common.h"
54 #include "../../fileio.h"
55 #include "../vm_template.h"
56
57 #ifdef USE_SOUND_VOLUME
58 static const _TCHAR *sound_device_caption[] = {
59         _T("Beep"), _T("Noise (FDD)"),
60 };
61 #endif
62
63 class csp_state_utils;
64 class EMU;
65 class DEVICE;
66 class EVENT;
67
68 class I8251;
69 class I8253;
70 class I8255;
71 class IO;
72 class LS244;
73 class NOT;
74 class PCM1BIT;
75 class UPD1990A;
76 class UPD7220;
77 class UPD765A;
78 class Z80;
79
80 class MAIN;
81 class SUB;
82 class KEYBOARD;
83
84 class VM : public VM_TEMPLATE
85 {
86 protected:
87         //EMU* emu;
88         //csp_state_utils *state_entry;
89         
90         // devices
91         //EVENT* event;
92         
93         // for main cpu
94         IO* mainio;
95         UPD765A* fdc;
96         Z80* maincpu;
97         MAIN* mainbus;
98         
99         // for sub cpu
100         DEVICE* printer;
101         I8251* sio;
102         I8253* pit;
103         I8255* pio;
104         IO* subio;
105         LS244* ls244;
106         NOT* not_data0;
107         NOT* not_data1;
108         NOT* not_data2;
109         NOT* not_data3;
110         NOT* not_data4;
111         NOT* not_data5;
112         NOT* not_data6;
113         NOT* not_data7;
114         NOT* not_busy;
115         PCM1BIT* pcm;
116         UPD1990A* rtc;
117         UPD7220* gdc_chr;
118         UPD7220* gdc_gfx;
119         Z80* subcpu;
120         SUB* subbus;
121         KEYBOARD* kbd;
122         
123         uint8_t halt;
124         
125 public:
126         // ----------------------------------------
127         // initialize
128         // ----------------------------------------
129         
130         VM(EMU* parent_emu);
131         ~VM();
132         
133         // ----------------------------------------
134         // for emulation class
135         // ----------------------------------------
136         
137         // drive virtual machine
138         void reset();
139         void special_reset();
140         void run();
141         double get_frame_rate();
142         
143 #ifdef USE_DEBUGGER
144         // debugger
145         DEVICE *get_cpu(int index);
146 #endif
147         
148         // draw screen
149         void draw_screen();
150         
151         // sound generation
152         void initialize_sound(int rate, int samples);
153         uint16_t* create_sound(int* extra_frames);
154         int get_sound_buffer_ptr();
155 #ifdef USE_SOUND_VOLUME
156         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
157 #endif
158         
159         // notify key
160         void key_down(int code, bool repeat);
161         void key_up(int code);
162         bool get_caps_locked();
163         bool get_kana_locked();
164         
165         // user interface
166         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
167         void close_floppy_disk(int drv);
168         bool is_floppy_disk_inserted(int drv);
169         void is_floppy_disk_protected(int drv, bool value);
170         bool is_floppy_disk_protected(int drv);
171         uint32_t is_floppy_disk_accessed();
172         bool is_frame_skippable();
173         
174         void update_config();
175         bool process_state(FILEIO* state_fio, bool loading);
176         
177         // ----------------------------------------
178         // for each device
179         // ----------------------------------------
180         
181         // devices
182         DEVICE* get_device(int id);
183         //DEVICE* dummy;
184         //DEVICE* first_device;
185         //DEVICE* last_device;
186 };
187
188 #endif