OSDN Git Service

3e1539d184ce3f5c2cb7c7c8540fb6214491ef1d
[csp-qt/common_source_project-fm7.git] / source / src / vm / phc25 / phc25.h
1 /*
2         SANYO PHC-25 Emulator 'ePHC-25'
3         SEIKO MAP-1010 Emulator 'eMAP-1010'
4
5         Author : Takeda.Toshiya
6         Date   : 2010.08.03-
7
8         [ virtual machine ]
9 */
10
11 #ifndef _PHC25_H_
12 #define _PHC25_H_
13
14 #ifdef _MAP1010
15 #define DEVICE_NAME             "SEIKO MAP-1010"
16 #define CONFIG_NAME             "map1010"
17 #else
18 #define DEVICE_NAME             "SANYO PHC-25"
19 #define CONFIG_NAME             "phc25"
20 #endif
21
22 // device informations for virtual machine
23 #define FRAMES_PER_SEC          60
24 #define LINES_PER_FRAME         262
25 #define CPU_CLOCKS              4000000
26 #define SCREEN_WIDTH            256
27 #define SCREEN_HEIGHT           192
28
29 #define MC6847_ATTR_OFS         0x800
30 #define MC6847_ATTR_INV         0x01
31 #define MC6847_ATTR_AS          0x02
32 #define MC6847_ATTR_CSS         0x04
33 #define HAS_AY_3_8910
34
35 // device informations for win32
36 #define USE_TAPE                1
37 #define USE_TAPE_BUTTON
38 #define USE_ALT_F10_KEY
39 #define USE_AUTO_KEY            6
40 #define USE_AUTO_KEY_RELEASE    10
41 #define USE_AUTO_KEY_CAPS
42 #define USE_SOUND_VOLUME        3
43 #define USE_JOYSTICK
44 #define USE_DEBUGGER
45 #define USE_STATE
46 #define USE_CPU_Z80
47
48 #include "../../common.h"
49 #include "../../fileio.h"
50
51 #ifdef USE_SOUND_VOLUME
52 static const _TCHAR *sound_device_caption[] = {
53         _T("PSG"), _T("CMT (Signal)"), _T("Noise (CMT)"),
54 };
55 #endif
56
57 class csp_state_utils;
58
59 class EMU;
60 class DEVICE;
61 class EVENT;
62
63 class DATAREC;
64 class IO;
65 class MC6847;
66 class NOT;
67 //class YM2203;
68 class AY_3_891X;
69 class Z80;
70
71 class JOYSTICK;
72 class KEYBOARD;
73 class MEMORY;
74 class SYSTEM;
75
76 class VM
77 {
78 protected:
79         EMU* emu;
80         csp_state_utils* state_entry;
81         
82         // devices
83         EVENT* event;
84         
85         DATAREC* drec;
86         IO* io;
87         MC6847* vdp;
88         NOT* not_vsync;
89 //      YM2203* psg;
90         AY_3_891X* psg;
91         Z80* cpu;
92         
93         JOYSTICK* joystick;
94         KEYBOARD* keyboard;
95         MEMORY* memory;
96         SYSTEM* system;
97         
98 public:
99         // ----------------------------------------
100         // initialize
101         // ----------------------------------------
102         
103         VM(EMU* parent_emu);
104         ~VM();
105         
106         // ----------------------------------------
107         // for emulation class
108         // ----------------------------------------
109         
110         // drive virtual machine
111         void reset();
112         void run();
113         
114 #ifdef USE_DEBUGGER
115         // debugger
116         DEVICE *get_cpu(int index);
117 #endif
118         
119         // draw screen
120         void draw_screen();
121         
122         // sound generation
123         void initialize_sound(int rate, int samples);
124         uint16_t* create_sound(int* extra_frames);
125         int get_sound_buffer_ptr();
126 #ifdef USE_SOUND_VOLUME
127         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
128 #endif
129         
130         // user interface
131         void play_tape(int drv, const _TCHAR* file_path);
132         void rec_tape(int drv, const _TCHAR* file_path);
133         void close_tape(int drv);
134         bool is_tape_inserted(int drv);
135         bool is_tape_playing(int drv);
136         bool is_tape_recording(int drv);
137         int get_tape_position(int drv);
138         const _TCHAR* get_tape_message(int drv);
139         void push_play(int drv);
140         void push_stop(int drv);
141         void push_fast_forward(int drv);
142         void push_fast_rewind(int drv);
143         void push_apss_forward(int drv) {}
144         void push_apss_rewind(int drv) {}
145         bool is_frame_skippable();
146         
147         void update_config();
148         void decl_state();
149         void save_state(FILEIO* state_fio);
150         bool load_state(FILEIO* state_fio);
151         
152         // ----------------------------------------
153         // for each device
154         // ----------------------------------------
155         
156         // devices
157         DEVICE* get_device(int id);
158         DEVICE* dummy;
159         DEVICE* first_device;
160         DEVICE* last_device;
161 };
162
163 #endif