OSDN Git Service

8149100c947b6c1bf571d3a75352cf8ede77bfb5
[csp-qt/common_source_project-fm7.git] / source / src / vm / gamegear / gamegear.h
1 /*
2         SEGA GAME GEAR Emulator 'yaGAME GEAR'
3
4         Author : tanam
5         Date   : 2013.08.24-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _GAMEGEAR_H_
11 #define _GAMEGEAR_H_
12
13 #define DEVICE_NAME             "SEGA GAME GEAR"
14 #define CONFIG_NAME             "gamegear"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC                  60
18 #define LINES_PER_FRAME                 262
19 #define CPU_CLOCKS                              3579545
20 #define SCREEN_WIDTH                    256
21 #define SCREEN_HEIGHT                   192
22 #define TMS9918A_VRAM_SIZE              0x4000
23 #define TMS9918A_LIMIT_SPRITES
24 #define MAX_DRIVE                               1
25
26 // device informations for win32
27 #define USE_CART1
28 #define USE_FD1
29 #define USE_TAPE1
30 #define USE_ALT_F10_KEY
31 #define USE_AUTO_KEY                    5
32 #define USE_AUTO_KEY_RELEASE    8
33 #define USE_AUTO_KEY_CAPS
34 #define USE_SOUND_VOLUME        4
35 #define USE_JOYSTICK
36 #define USE_DEBUGGER
37 #define USE_CPU_Z80
38
39 #include "../../common.h"
40 #include "../../fileio.h"
41
42 #ifdef USE_SOUND_VOLUME
43 static const _TCHAR *sound_device_caption[] = {
44         _T("PSG"), _T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"),
45 };
46 #endif
47
48 class EMU;
49 class DEVICE;
50 class EVENT;
51
52 class DATAREC;
53 class I8251;
54 class I8255;
55 class IO;
56 class SN76489AN;
57 class _315_5124;
58 class UPD765A;
59 class Z80;
60
61 class KEYBOARD;
62 class MEMORY;
63 class SYSTEM;
64
65 class VM
66 {
67 protected:
68         EMU* emu;
69         
70         // devices
71         EVENT* event;
72         
73         DATAREC* drec;
74         I8251* sio;
75         I8255* pio_k;
76         I8255* pio_f;
77         IO* io;
78         SN76489AN* psg;
79         _315_5124* vdp;
80         UPD765A* fdc;
81         Z80* cpu;
82         
83         KEYBOARD* key;
84         MEMORY* memory;
85         SYSTEM* system;
86         
87 public:
88         // ----------------------------------------
89         // initialize
90         // ----------------------------------------
91         
92         VM(EMU* parent_emu);
93         ~VM();
94         
95         // ----------------------------------------
96         // for emulation class
97         // ----------------------------------------
98         
99         // drive virtual machine
100         void reset();
101         void run();
102         
103 #ifdef USE_DEBUGGER
104         // debugger
105         DEVICE *get_cpu(int index);
106 #endif
107         
108         // draw screen
109         void draw_screen();
110         
111         // sound generation
112         void initialize_sound(int rate, int samples);
113         uint16_t* create_sound(int* extra_frames);
114         int get_sound_buffer_ptr();
115 #ifdef USE_SOUND_VOLUME
116         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
117 #endif
118         
119         // user interface
120         void open_cart(int drv, const _TCHAR* file_path);
121         void close_cart(int drv);
122         bool is_cart_inserted(int drv);
123         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
124         void close_floppy_disk(int drv);
125         bool is_floppy_disk_inserted(int drv);
126         void is_floppy_disk_protected(int drv, bool value);
127         bool is_floppy_disk_protected(int drv);
128         uint32_t is_floppy_disk_accessed();
129         void play_tape(int drv, const _TCHAR* file_path);
130         void rec_tape(int drv, const _TCHAR* file_path);
131         void close_tape(int drv);
132         bool is_tape_inserted(int drv);
133         bool is_tape_playing(int drv);
134         bool is_tape_recording(int drv);
135         int get_tape_position(int drv);
136         const _TCHAR* get_tape_message(int drv);
137         bool is_frame_skippable();
138         
139         void update_config();
140         
141         // ----------------------------------------
142         // for each device
143         // ----------------------------------------
144         
145         // devices
146         DEVICE* get_device(int id);
147         DEVICE* dummy;
148         DEVICE* first_device;
149         DEVICE* last_device;
150 };
151
152 #endif