OSDN Git Service

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