OSDN Git Service

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