OSDN Git Service

b0757ed9a3177c0681a5b7de2967efb756b87068
[csp-qt/common_source_project-fm7.git] / source / src / vm / pcengine / pcengine.h
1 /*
2         NEC-HE PC Engine Emulator 'ePCEngine'
3
4         Author : Takeda.Toshiya
5         Date   : 2012.10.31-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _PCENGINE_H_
11 #define _PCENGINE_H_
12
13 #define DEVICE_NAME             "NEC-HE PC Engine"
14 #define CONFIG_NAME             "pcengine"
15
16 #define FRAMES_PER_SEC          60
17 #define LINES_PER_FRAME         262
18 #define CPU_CLOCKS              7159090
19 #define SCREEN_WIDTH            352
20 #define SCREEN_HEIGHT           240
21 // pixel aspect should be 8:7
22 #define WINDOW_HEIGHT_ASPECT    210
23
24 #define SUPPORT_SUPER_GFX
25 #define SUPPORT_BACKUP_RAM
26 #define SUPPORT_CDROM
27 //#define SCSI_HOST_AUTO_ACK
28 #define SCSI_DEV_IMMEDIATE_SELECT
29
30 // device informations for win32
31 #define SOUND_RATE_DEFAULT      5       // 44100Hz
32 #define SUPPORT_TV_RENDER
33 #define USE_CART                1
34 #define USE_COMPACT_DISC        1
35 #define USE_SOUND_VOLUME        3
36 #define USE_JOYSTICK
37 #define USE_JOYSTICK_TYPE       4
38 #define JOYSTICK_TYPE_DEFAULT   0
39 #define USE_JOY_BUTTON_CAPTIONS
40 #define USE_DEBUGGER
41 #define USE_STATE
42 //#define USE_SEPARATED_ADPCM
43
44 #include "../../common.h"
45 #include "../../fileio.h"
46 #include "../vm_template.h"
47
48 #ifdef USE_SOUND_VOLUME
49 static const _TCHAR *sound_device_caption[] = {
50         _T("PSG"), _T("CD-DA"), _T("ADPCM")
51 };
52 #endif
53
54 #ifdef USE_JOY_BUTTON_CAPTIONS
55 static const _TCHAR *joy_button_captions[] = {
56         _T("Up"),
57         _T("Down"),
58         _T("Left"),
59         _T("Right"),
60         _T("Button #1"),
61         _T("Button #2"),
62         _T("Select"),
63         _T("Run"),
64         _T("Button #3"),
65         _T("Button #4"),
66         _T("Button #5"),
67         _T("Button #6"),
68 };
69 #endif
70
71 class EMU;
72 class DEVICE;
73 class EVENT;
74
75 class HUC6280;
76 class MSM5205;
77 class SCSI_HOST;
78 class SCSI_CDROM;
79
80 namespace PCEDEV {
81         class PCE;
82 #ifdef USE_SEPARATED_ADPCM
83         class ADPCM;
84 #endif
85 }
86 class VM : public VM_TEMPLATE
87 {
88 protected:
89         //EMU* emu;
90         //csp_state_utils* state_entry;
91         
92         // devices
93         EVENT* pceevent;
94         
95         HUC6280* pcecpu;
96         MSM5205* adpcm;
97         SCSI_HOST* scsi_host;
98         SCSI_CDROM* scsi_cdrom;
99         PCEDEV::PCE* pce;
100 #ifdef USE_SEPARATED_ADPCM
101         PCEDEV::ADPCM* pce_adpcm;
102 #endif
103 public:
104         // ----------------------------------------
105         // initialize
106         // ----------------------------------------
107         
108         VM(EMU* parent_emu);
109         ~VM();
110         
111         // ----------------------------------------
112         // for emulation class
113         // ----------------------------------------
114         
115         // drive virtual machine
116         void reset();
117         void run();
118         double get_frame_rate();
119         
120 #ifdef USE_DEBUGGER
121         // debugger
122         DEVICE *get_cpu(int index);
123 #endif
124         
125         // draw screen
126         void draw_screen();
127         
128         // sound generation
129         void initialize_sound(int rate, int samples);
130         uint16_t* create_sound(int* extra_frames);
131         int get_sound_buffer_ptr();
132 #ifdef USE_SOUND_VOLUME
133         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
134 #endif
135         
136         // user interface
137         void open_cart(int drv, const _TCHAR* file_path);
138         void close_cart(int drv);
139         bool is_cart_inserted(int drv);
140         void open_compact_disc(int drv, const _TCHAR* file_path);
141         void close_compact_disc(int drv);
142         bool is_compact_disc_inserted(int drv);
143         uint32_t is_compact_disc_accessed();
144         bool is_frame_skippable()
145         {
146                 return false;
147         }
148         void update_config();
149         bool process_state(FILEIO* state_fio, bool loading);
150         
151         // ----------------------------------------
152         // for each device
153         // ----------------------------------------
154         
155         // devices
156         DEVICE* get_device(int id);
157         //DEVICE* dummy;
158         //DEVICE* first_device;
159         //DEVICE* last_device;
160 };
161
162 #endif