OSDN Git Service

[VM] Apply VM_TEMPLATE to all 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_FLOPPY_DISK         2
33 #define NOTIFY_KEY_DOWN
34 #define USE_ALT_F10_KEY
35 #define USE_AUTO_KEY            5
36 #define USE_AUTO_KEY_RELEASE    6
37 #define USE_NOTIFY_POWER_OFF
38 #define USE_SOUND_VOLUME        2
39 #define USE_DEBUGGER
40 #define USE_STATE
41
42 #include "../../common.h"
43 #include "../../fileio.h"
44 #include "../vm_template.h"
45
46 #define USE_CPU_I286
47
48 #ifdef USE_SOUND_VOLUME
49 static const _TCHAR *sound_device_caption[] = {
50         _T("Beep"), _T("Noise (FDD)"),
51 };
52 #endif
53
54 class csp_state_utils;
55 class EMU;
56 class DEVICE;
57 class EVENT;
58
59 class I8251;
60 class I8253;
61 class I8255;
62 class I8259;
63 class I286;
64 class IO;
65 class MB8877;
66 class MEMORY;
67 class MSM58321;
68 class NOT;
69 class PCM1BIT;
70
71 class SUB;
72
73 class VM : public VM_TEMPLATE
74 {
75 protected:
76         //EMU* emu;
77         //csp_state_utils *state_entry;
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_t ram[0x80000];
98         uint8_t kanji[0x40000];
99         uint8_t 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         
126         // sound generation
127         void initialize_sound(int rate, int samples);
128         uint16_t* create_sound(int* extra_frames);
129         int get_sound_buffer_ptr();
130 #ifdef USE_SOUND_VOLUME
131         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
132 #endif
133         
134         // notify key
135         void key_down(int code, bool repeat);
136         void key_up(int code);
137         
138         // user interface
139         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
140         void close_floppy_disk(int drv);
141         bool is_floppy_disk_inserted(int drv);
142         void is_floppy_disk_protected(int drv, bool value);
143         bool is_floppy_disk_protected(int drv);
144         uint32_t is_floppy_disk_accessed();
145         bool is_frame_skippable();
146         
147         void update_config();
148         void decl_state();
149         void save_state(FILEIO* state_fio);
150         bool load_state(FILEIO* state_fio);
151         
152         // ----------------------------------------
153         // for each device
154         // ----------------------------------------
155         
156         // devices
157         DEVICE* get_device(int id);
158         //DEVICE* dummy;
159         //DEVICE* first_device;
160         //DEVICE* last_device;
161 };
162
163 #endif