OSDN Git Service

[VM][General][WIP] Apply new (Upstream 2016-02-21) APIs to VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / fm16pi / fm16pi.h
1 /*
2         FUJITSU FM16pi Emulator 'eFM16pi'
3
4         Author : Takeda.Toshiya
5         Date   : 2010.12.25-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _FM16PI_H_
11 #define _FM16PI_H_
12
13 #define DEVICE_NAME             "FUJITSU FM16pi"
14 #define CONFIG_NAME             "fm16pi"
15
16 // device informations for virtual machine
17
18 // TODO: check refresh rate
19 #define FRAMES_PER_SEC          60
20 #define LINES_PER_FRAME         220
21 #define CPU_CLOCKS              4915200
22 #define SCREEN_WIDTH            640
23 #define SCREEN_HEIGHT           200
24 #define MAX_DRIVE               4
25 #define HAS_I86
26 #define I8259_MAX_CHIPS         1
27 #define MEMORY_ADDR_MAX         0x100000
28 #define MEMORY_BANK_SIZE        0x4000
29 #define IO_ADDR_MAX             0x10000
30
31 // device informations for win32
32 #define USE_FD1
33 #define USE_FD2
34 #define NOTIFY_KEY_DOWN
35 #define USE_ALT_F10_KEY
36 #define USE_AUTO_KEY            5
37 #define USE_AUTO_KEY_RELEASE    6
38 #define USE_NOTIFY_POWER_OFF
39 #define USE_ACCESS_LAMP
40 #define USE_SOUND_VOLUME        1
41 #define USE_DEBUGGER
42 #define USE_STATE
43
44 #include "../../common.h"
45 #include "../../fileio.h"
46
47 #ifdef USE_SOUND_VOLUME
48 static const _TCHAR *sound_device_caption[] = {
49         _T("Beep"),
50 };
51 #endif
52
53 class EMU;
54 class DEVICE;
55 class EVENT;
56
57 class I8251;
58 class I8253;
59 class I8255;
60 class I8259;
61 class I286;
62 class IO;
63 class MB8877;
64 class MEMORY;
65 class MSM58321;
66 class NOT;
67 class PCM1BIT;
68
69 class SUB;
70
71 class VM
72 {
73 protected:
74         EMU* emu;
75         
76         // devices
77         EVENT* event;
78         
79         I8251* sio;
80         I8253* pit;
81         I8255* pio;
82         I8259* pic;
83         I286* cpu;
84         IO* io;
85         MB8877* fdc;
86         MEMORY* memory;
87         MSM58321* rtc;
88         NOT* not_pit;
89         PCM1BIT* pcm;
90         
91         SUB* sub;
92         
93         // memory
94         uint8 ram[0x80000];
95         uint8 kanji[0x40000];
96         uint8 cart[0x40000];
97         
98 public:
99         // ----------------------------------------
100         // initialize
101         // ----------------------------------------
102         
103         VM(EMU* parent_emu);
104         ~VM();
105         
106         // ----------------------------------------
107         // for emulation class
108         // ----------------------------------------
109         
110         // drive virtual machine
111         void reset();
112         void notify_power_off();
113         void run();
114         
115 #ifdef USE_DEBUGGER
116         // debugger
117         DEVICE *get_cpu(int index);
118 #endif
119         
120         // draw screen
121         void draw_screen();
122         int get_access_lamp_status();
123         
124         // sound generation
125         void initialize_sound(int rate, int samples);
126         uint16* create_sound(int* extra_frames);
127         int get_sound_buffer_ptr();
128 #ifdef USE_SOUND_VOLUME
129         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
130 #endif
131         
132         // notify key
133         void key_down(int code, bool repeat);
134         void key_up(int code);
135         
136         // user interface
137         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
138         void close_floppy_disk(int drv);
139         bool is_floppy_disk_inserted(int drv);
140         void is_floppy_disk_protected(int drv, bool value);
141         bool is_floppy_disk_protected(int drv);
142         bool is_frame_skippable();
143         
144         void update_config();
145         void save_state(FILEIO* state_fio);
146         bool load_state(FILEIO* state_fio);
147         
148         // ----------------------------------------
149         // for each device
150         // ----------------------------------------
151         
152         // devices
153         DEVICE* get_device(int id);
154         DEVICE* dummy;
155         DEVICE* first_device;
156         DEVICE* last_device;
157 };
158
159 #endif