OSDN Git Service

1dee026e9ebe19cdae7f0bbf625c023d6eaa26e6
[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                1
30 #define USE_TAPE_BUTTON
31 #define USE_ALT_F10_KEY
32 #define USE_AUTO_KEY            6
33 #define USE_AUTO_KEY_RELEASE    10
34 #define USE_AUTO_KEY_CAPS_LOCK  (0xf2 | 0x100)
35 #define USE_AUTO_KEY_NUMPAD
36 #define DONT_KEEEP_KEY_PRESSED
37 #define USE_SOUND_VOLUME        3
38 #define USE_DEBUGGER
39 #define USE_STATE
40 #define USE_CPU_UPD7810
41
42 #include "../../common.h"
43 #include "../../fileio.h"
44 #include "../vm_template.h"
45
46 #ifdef USE_SOUND_VOLUME
47 static const _TCHAR *sound_device_caption[] = {
48         _T("Beep"), _T("CMT (Signal)"), _T("Noise (CMT)"),
49 };
50 #endif
51
52 //class csp_state_utils;
53 class EMU;
54 class DEVICE;
55 class EVENT;
56
57 class DATAREC;
58 class MEMORY;
59 class PCM1BIT;
60 class UPD16434;
61 class UPD1990A;
62 class UPD7810;
63
64 class PC2001_IO;
65 class VM : public VM_TEMPLATE
66 {
67 protected:
68         //EMU* emu;
69         //csp_state_utils *state_entry;
70         
71         // devices
72         //EVENT* event;
73         
74         DATAREC* drec;
75         MEMORY* memory;
76         PCM1BIT* pcm;
77         UPD16434* lcd[4];
78         UPD1990A* rtc;
79         UPD7810* cpu;
80         
81         PC2001_IO* io;
82         
83         // memory
84         uint8_t ram[0x5000];
85         uint8_t rom1[0x1000];
86         uint8_t rom2[0x4000];
87         
88 public:
89         // ----------------------------------------
90         // initialize
91         // ----------------------------------------
92         
93         VM(EMU* parent_emu);
94         ~VM();
95         
96         // ----------------------------------------
97         // for emulation class
98         // ----------------------------------------
99         
100         // drive virtual machine
101         void reset();
102         void run();
103         
104 #ifdef USE_DEBUGGER
105         // debugger
106         DEVICE *get_cpu(int index);
107 #endif
108         
109         // draw screen
110         void draw_screen();
111         
112         // sound generation
113         void initialize_sound(int rate, int samples);
114         uint16_t* create_sound(int* extra_frames);
115         int get_sound_buffer_ptr();
116 #ifdef USE_SOUND_VOLUME
117         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
118 #endif
119         
120         // user interface
121         void play_tape(int drv, const _TCHAR* file_path);
122         void rec_tape(int drv, const _TCHAR* file_path);
123         void close_tape(int drv);
124         bool is_tape_inserted(int drv);
125         bool is_tape_playing(int drv);
126         bool is_tape_recording(int drv);
127         int get_tape_position(int drv);
128         const _TCHAR* get_tape_message(int drv);
129         void push_play(int drv);
130         void push_stop(int drv);
131         void push_fast_forward(int drv);
132         void push_fast_rewind(int drv);
133         void push_apss_forward(int drv) {}
134         void push_apss_rewind(int drv) {}
135         bool is_frame_skippable();
136         
137         void update_config();
138         bool process_state(FILEIO* state_fio, bool loading);
139         
140         // ----------------------------------------
141         // for each device
142         // ----------------------------------------
143         
144         // devices
145         DEVICE* get_device(int id);
146         //DEVICE* dummy;
147         //DEVICE* first_device;
148         //DEVICE* last_device;
149 };
150
151 #endif