OSDN Git Service

[VM][General] Merge upstream 2016-02-13. Still don't implement OSD/Gui part of joysti...
[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 static const bool sound_device_monophonic[] = {
52         false,
53 };
54 #endif
55
56 class EMU;
57 class DEVICE;
58 class EVENT;
59
60 class I8251;
61 class I8253;
62 class I8255;
63 class I8259;
64 class I286;
65 class IO;
66 class MB8877;
67 class MEMORY;
68 class MSM58321;
69 class NOT;
70 class PCM1BIT;
71
72 class SUB;
73
74 class VM
75 {
76 protected:
77         EMU* emu;
78         
79         // devices
80         EVENT* event;
81         
82         I8251* sio;
83         I8253* pit;
84         I8255* pio;
85         I8259* pic;
86         I286* cpu;
87         IO* io;
88         MB8877* fdc;
89         MEMORY* memory;
90         MSM58321* rtc;
91         NOT* not_pit;
92         PCM1BIT* pcm;
93         
94         SUB* sub;
95         
96         // memory
97         uint8 ram[0x80000];
98         uint8 kanji[0x40000];
99         uint8 cart[0x40000];
100         
101 public:
102         // ----------------------------------------
103         // initialize
104         // ----------------------------------------
105         
106         VM(EMU* parent_emu);
107         ~VM();
108         
109         // ----------------------------------------
110         // for emulation class
111         // ----------------------------------------
112         
113         // drive virtual machine
114         void reset();
115         void notify_power_off();
116         void run();
117         
118 #ifdef USE_DEBUGGER
119         // debugger
120         DEVICE *get_cpu(int index);
121 #endif
122         
123         // draw screen
124         void draw_screen();
125         int access_lamp();
126         
127         // sound generation
128         void initialize_sound(int rate, int samples);
129         uint16* create_sound(int* extra_frames);
130         int sound_buffer_ptr();
131 #ifdef USE_SOUND_VOLUME
132         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
133 #endif
134         
135         // notify key
136         void key_down(int code, bool repeat);
137         void key_up(int code);
138         
139         // user interface
140         void open_disk(int drv, const _TCHAR* file_path, int bank);
141         void close_disk(int drv);
142         bool disk_inserted(int drv);
143         void set_disk_protected(int drv, bool value);
144         bool get_disk_protected(int drv);
145         bool now_skip();
146         
147         void update_config();
148         void save_state(FILEIO* state_fio);
149         bool load_state(FILEIO* state_fio);
150         
151         // ----------------------------------------
152         // for each device
153         // ----------------------------------------
154         
155         // devices
156         DEVICE* get_device(int id);
157         DEVICE* dummy;
158         DEVICE* first_device;
159         DEVICE* last_device;
160 };
161
162 #endif