OSDN Git Service

[General] Merge Updtream 2017-03-15 . Still not build all of VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc2001 / pc2001.h
1 /*
2         NEC PC-2001 Emulator 'ePC-2001'
3
4         Origin : PockEmul
5         Author : Takeda.Toshiya
6         Date   : 2016.03.18-
7
8         [ virtual machine ]
9 */
10
11 #ifndef _PC2001_H_
12 #define _PC2001_H_
13
14 #define DEVICE_NAME             "NEC PC-2001"
15 #define CONFIG_NAME             "pc2001"
16
17 // device informations for virtual machine
18 #define FRAMES_PER_SEC          60
19 #define LINES_PER_FRAME         24
20 #define CPU_CLOCKS              (4000000 / 4)
21 #define SCREEN_WIDTH            240
22 #define SCREEN_HEIGHT           24
23 #define HAS_UPD7907
24 #define MEMORY_ADDR_MAX         0x10000
25 #define MEMORY_BANK_SIZE        0x1000
26
27 // device informations for win32
28 #define WINDOW_MODE_BASE        2
29 #define USE_TAPE
30 #define USE_ALT_F10_KEY
31 #define USE_AUTO_KEY            6
32 #define USE_AUTO_KEY_RELEASE    10
33 #define USE_AUTO_KEY_CAPS_LOCK  (0xf2 | 0x100)
34 #define DONT_KEEEP_KEY_PRESSED
35 #define USE_SOUND_VOLUME        3
36 #define USE_DEBUGGER
37 #define USE_STATE
38
39 #include "../../common.h"
40
41 #ifdef USE_SOUND_VOLUME
42 static const _TCHAR *sound_device_caption[] = {
43         _T("Beep"), _T("CMT (Signal)"), _T("Noise (CMT)"),
44 };
45 #endif
46
47 class EMU;
48 class DEVICE;
49 class EVENT;
50
51 class DATAREC;
52 class MEMORY;
53 class PCM1BIT;
54 class UPD16434;
55 class UPD1990A;
56 class UPD7810;
57
58 class IO;
59
60 #include "../../fileio.h"
61
62 class VM
63 {
64 protected:
65         EMU* emu;
66         
67         // devices
68         EVENT* event;
69         
70         DATAREC* drec;
71         MEMORY* memory;
72         PCM1BIT* pcm;
73         UPD16434* lcd[4];
74         UPD1990A* rtc;
75         UPD7810* cpu;
76         
77         IO* io;
78         
79         // memory
80         uint8_t ram[0x5000];
81         uint8_t rom1[0x1000];
82         uint8_t rom2[0x4000];
83         
84 public:
85         // ----------------------------------------
86         // initialize
87         // ----------------------------------------
88         
89         VM(EMU* parent_emu);
90         ~VM();
91         
92         // ----------------------------------------
93         // for emulation class
94         // ----------------------------------------
95         
96         // drive virtual machine
97         void reset();
98         void run();
99         
100 #ifdef USE_DEBUGGER
101         // debugger
102         DEVICE *get_cpu(int index);
103 #endif
104         
105         // draw screen
106         void draw_screen();
107         
108         // sound generation
109         void initialize_sound(int rate, int samples);
110         uint16_t* create_sound(int* extra_frames);
111         int get_sound_buffer_ptr();
112 #ifdef USE_SOUND_VOLUME
113         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
114 #endif
115         
116         // user interface
117         void play_tape(const _TCHAR* file_path);
118         void rec_tape(const _TCHAR* file_path);
119         void close_tape();
120         bool is_tape_inserted();
121         bool is_tape_playing();
122         bool is_tape_recording();
123         int get_tape_position();
124         const _TCHAR* get_tape_message();
125         bool is_frame_skippable();
126         
127         void update_config();
128         void save_state(FILEIO* state_fio);
129         bool load_state(FILEIO* state_fio);
130         
131         // ----------------------------------------
132         // for each device
133         // ----------------------------------------
134         
135         // devices
136         DEVICE* get_device(int id);
137         DEVICE* dummy;
138         DEVICE* first_device;
139         DEVICE* last_device;
140 };
141
142 #endif