OSDN Git Service

[VM][Qt][General][CMAKE] Merge upstream 2016-03-01, phase 2. Expect to build and...
[csp-qt/common_source_project-fm7.git] / source / src / vm / familybasic / familybasic.h
1 /*
2         Nintendo Family BASIC Emulator 'eFamilyBASIC'
3
4         Origin : nester
5         Author : Takeda.Toshiya
6         Date   : 2010.08.11-
7
8         [ virtual machine ]
9 */
10
11 #ifndef _FAMILYBASIC_H_
12 #define _FAMILYBASIC_H_
13
14 #define DEVICE_NAME             "Nintendo Family BASIC"
15 #define CONFIG_NAME             "familybasic"
16
17 // device informations for virtual machine
18 #define FRAMES_PER_SEC          60
19 #define LINES_PER_FRAME         262
20 #define CPU_CLOCKS              1789772
21 #define SCREEN_WIDTH            256
22 #define SCREEN_HEIGHT           240
23 // pixel aspect should be 8:7
24 #define WINDOW_HEIGHT_ASPECT    210
25 #define HAS_N2A03
26
27 // device informations for win32
28 #define USE_BOOT_MODE           3
29 #define USE_TAPE
30 #define USE_ALT_F10_KEY
31 #define USE_AUTO_KEY            5
32 #define USE_AUTO_KEY_RELEASE    6
33 #define USE_AUTO_KEY_NO_CAPS
34 #define USE_SOUND_VOLUME        2
35 #define USE_JOYSTICK
36 #define USE_JOY_BUTTON_CAPTIONS
37 #define USE_STATE
38
39 #include "../../common.h"
40 #include "../../fileio.h"
41
42 #ifdef USE_SOUND_VOLUME
43 static const _TCHAR *sound_device_caption[] = {
44         _T("APU"), _T("CMT"),
45 };
46 #endif
47
48 #ifdef USE_JOY_BUTTON_CAPTIONS
49 static const _TCHAR *joy_button_captions[] = {
50         _T("Up"),
51         _T("Down"),
52         _T("Left"),
53         _T("Right"),
54         _T("Button #1"),
55         _T("Button #2"),
56         _T("Select"),
57         _T("Start"),
58 };
59 #endif
60
61 class EMU;
62 class DEVICE;
63 class EVENT;
64
65 class DATAREC;
66 class M6502;
67
68 class MEMORY;
69 class APU;
70 class PPU;
71
72 class VM
73 {
74 protected:
75         EMU* emu;
76         
77         // devices
78         EVENT* event;
79         
80         DATAREC* drec;
81         M6502* cpu;
82         
83         MEMORY* memory;
84         APU* apu;
85         PPU* ppu;
86         
87         int boot_mode;
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         // draw screen
106         void draw_screen();
107         
108         // sound generation
109         void initialize_sound(int rate, int samples);
110         uint16_t* create_sound(int* extra_frames);
111         int get_sound_buffer_ptr();
112 #ifdef USE_SOUND_VOLUME
113         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
114 #endif
115         
116         // user interface
117         void play_tape(const _TCHAR* file_path);
118         void rec_tape(const _TCHAR* file_path);
119         void close_tape();
120         bool is_tape_inserted();
121         bool is_tape_playing();
122         bool is_tape_recording();
123         int get_tape_position();
124         bool is_frame_skippable();
125         
126         void update_config();
127         void save_state(FILEIO* state_fio);
128         bool load_state(FILEIO* state_fio);
129         
130         // ----------------------------------------
131         // for each device
132         // ----------------------------------------
133         
134         // devices
135         DEVICE* get_device(int id);
136         DEVICE* dummy;
137         DEVICE* first_device;
138         DEVICE* last_device;
139 };
140
141 #endif