OSDN Git Service

[VM][General] Apply Upstream 2018-10-07.Still WIP.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc100 / pc100.h
1 /*
2         NEC PC-100 Emulator 'ePC-100'
3
4         Author : Takeda.Toshiya
5         Date   : 2008.07.12 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _PC100_H_
11 #define _PC100_H_
12
13 #define DEVICE_NAME             "NEC PC-100"
14 #define CONFIG_NAME             "pc100"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          55.4
18 #define LINES_PER_FRAME         544
19 #define CPU_CLOCKS              6988800
20 #define SCREEN_WIDTH            720
21 #define SCREEN_HEIGHT           512
22 #define WINDOW_HEIGHT_ASPECT    540
23 //720
24 #define MAX_DRIVE               4
25 #define HAS_I86
26 #define I8259_MAX_CHIPS         1
27 #define MSM58321_START_DAY      -9
28 #define MSM58321_START_YEAR     1980
29 #define UPD765A_NO_ST0_AT_FOR_SEEK
30 #define MEMORY_ADDR_MAX         0x100000
31 #define MEMORY_BANK_SIZE        0x8000
32 #define IO_ADDR_MAX             0x10000
33
34 // device informations for win32
35 #define USE_DRIVE_TYPE          2
36 #define USE_FLOPPY_DISK         2
37 #define USE_KEY_LOCKED
38 #define USE_AUTO_KEY            5
39 #define USE_AUTO_KEY_RELEASE    6
40 #define USE_AUTO_KEY_NUMPAD
41 #define USE_MONITOR_TYPE        2
42 #define USE_SCREEN_FILTER
43 #define USE_SOUND_VOLUME        3
44 #define USE_MOUSE
45 #define USE_DEBUGGER
46 #define USE_STATE
47 #define USE_CPU_I286
48
49 #include "../../common.h"
50 #include "../../fileio.h"
51 #include "../vm_template.h"
52
53 #ifdef USE_SOUND_VOLUME
54 static const _TCHAR *sound_device_caption[] = {
55         _T("Beep #1"), _T("Beep #2"), _T("Noise (FDD)"),
56 };
57 #endif
58
59 class EMU;
60 class DEVICE;
61 class EVENT;
62
63 class AND;
64 class BEEP;
65 class I8251;
66 class I8255;
67 class I8259;
68 class I286;
69 class IO;
70 class MEMORY;
71 class MSM58321;
72 class PCM1BIT;
73 class UPD765A;
74
75 namespace PC100 {
76         class CRTC;
77         class IOCTRL;
78         class KANJI;
79 }
80
81 class VM : public VM_TEMPLATE
82 {
83 protected:
84         //EMU* emu;
85         //csp_state_utils *state_entry;
86         
87         // devices
88         //EVENT* event;
89         
90         AND* and_drq;
91         BEEP* beep;
92         I8251* sio;
93         I8255* pio0;
94         I8255* pio1;
95         I8259* pic;     // includes 2chips
96         I286* cpu;
97         IO* io;
98         MEMORY* memory;
99         MSM58321* rtc;
100         PCM1BIT* pcm;
101         UPD765A* fdc;
102         
103         PC100::CRTC* crtc;
104         PC100::IOCTRL* ioctrl;
105         PC100::KANJI* kanji;
106         
107         // memory
108         uint8_t ram[0xc0000];   // Main RAM 768KB
109         uint8_t ipl[0x8000];    // IPL 32KB
110         
111 public:
112         // ----------------------------------------
113         // initialize
114         // ----------------------------------------
115         
116         VM(EMU* parent_emu);
117         ~VM();
118         
119         // ----------------------------------------
120         // for emulation class
121         // ----------------------------------------
122         
123         // drive virtual machine
124         void reset();
125         void run();
126         double get_frame_rate()
127         {
128                 return FRAMES_PER_SEC;
129         }
130         
131 #ifdef USE_DEBUGGER
132         // debugger
133         DEVICE *get_cpu(int index);
134 #endif
135         
136         // draw screen
137         void draw_screen();
138         
139         // sound generation
140         void initialize_sound(int rate, int samples);
141         uint16_t* create_sound(int* extra_frames);
142         int get_sound_buffer_ptr();
143 #ifdef USE_SOUND_VOLUME
144         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
145 #endif
146         
147         // notify key
148         void key_down(int code, bool repeat);
149         void key_up(int code);
150         bool get_caps_locked();
151         bool get_kana_locked();
152         
153         // user interface
154         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
155         void close_floppy_disk(int drv);
156         bool is_floppy_disk_inserted(int drv);
157         void is_floppy_disk_protected(int drv, bool value);
158         bool is_floppy_disk_protected(int drv);
159         uint32_t is_floppy_disk_accessed();
160         bool is_frame_skippable();
161         
162         void update_config();
163         bool process_state(FILEIO* state_fio, bool loading);
164         
165         // ----------------------------------------
166         // for each device
167         // ----------------------------------------
168         
169         // devices
170         DEVICE* get_device(int id);
171         //DEVICE* dummy;
172         //DEVICE* first_device;
173         //DEVICE* last_device;
174 };
175
176 #endif