OSDN Git Service

[VM][WIP] Use namespace to devices per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / gamegear / mastersystem.h
1 /*
2         SEGA MASTER SYSTEM Emulator 'yaMASTER SYSTEM'
3
4         Author : tanam
5         Date   : 2013.10.20-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _MASTERSYSTEM_H_
11 #define _MASTERSYSTEM_H_
12
13 #define DEVICE_NAME             "SEGA MASTER SYSTEM"
14 #define CONFIG_NAME             "mastersystem"
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_CART                1
28 //#define USE_FLOPPY_DISK       1
29 //#define USE_TAPE              1
30 //#define USE_TAPE_BUTTON
31 #define USE_ALT_F10_KEY
32 #define USE_AUTO_KEY            5
33 #define USE_AUTO_KEY_RELEASE    8
34 #define USE_AUTO_KEY_CAPS
35 #define SUPPORT_TV_RENDER
36 #define USE_SOUND_VOLUME        2
37 ///#define USE_SOUND_VOLUME     4
38 #define USE_JOYSTICK
39 #define USE_DEBUGGER
40 #define USE_CPU_Z80
41
42 #include "../../common.h"
43 #include "../../fileio.h"
44 #include "../vm_template.h"
45
46 #ifdef USE_SOUND_VOLUME
47 static const _TCHAR *sound_device_caption[] = {
48         _T("PSG"), _T("OPLL"),
49 };
50 #endif
51
52 class EMU;
53 class DEVICE;
54 class EVENT;
55
56 ///class DATAREC;
57 ///class I8251;
58 class I8255;
59 class IO;
60 class YM2413;
61 class SN76489AN;
62 class _315_5124;
63 ///class UPD765A;
64 class Z80;
65
66 namespace GAMEGEAR {
67         class KEYBOARD;
68         class MEMORY;
69         class SYSTEM;
70 }
71 class VM : public VM_TEMPLATE
72 {
73 protected:
74         //EMU* emu;
75         
76         // devices
77         //EVENT* event;
78         
79 ///     DATAREC* drec;
80 ///     I8251* sio;
81         I8255* pio_k;
82         I8255* pio_f;
83         IO* io;
84         YM2413* fm;
85         SN76489AN* psg;
86         _315_5124* vdp;
87 ///     UPD765A* fdc;
88         Z80* cpu;
89         
90         GAMEGEAR::KEYBOARD* key;
91         GAMEGEAR::MEMORY* memory;
92         GAMEGEAR::SYSTEM* system;
93         
94 public:
95         // ----------------------------------------
96         // initialize
97         // ----------------------------------------
98         
99         VM(EMU* parent_emu);
100         ~VM();
101         
102         // ----------------------------------------
103         // for emulation class
104         // ----------------------------------------
105         
106         // drive virtual machine
107         void reset();
108         void run();
109         
110 #ifdef USE_DEBUGGER
111         // debugger
112         DEVICE *get_cpu(int index);
113 #endif
114         
115         // draw screen
116         void draw_screen();
117         
118         // sound generation
119         void initialize_sound(int rate, int samples);
120         uint16_t* create_sound(int* extra_frames);
121         int get_sound_buffer_ptr();
122 #ifdef USE_SOUND_VOLUME
123         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
124 #endif
125         
126         // user interface
127         void open_cart(int drv, const _TCHAR* file_path);
128         void close_cart(int drv);
129         bool is_cart_inserted(int drv);
130 ///     void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
131 ///     void close_floppy_disk(int drv);
132 ///     bool is_floppy_disk_inserted(int drv);
133 ///     void is_floppy_disk_protected(int drv, bool value);
134 ///     bool is_floppy_disk_protected(int drv);
135 ///     uint32_t is_floppy_disk_accessed();
136 ///     void play_tape(int drv, const _TCHAR* file_path);
137 ///     void rec_tape(int drv, const _TCHAR* file_path);
138 ///     void close_tape(int drv);
139 ///     bool is_tape_inserted(int drv);
140 ///     bool is_tape_playing(int drv);
141 ///     bool is_tape_recording(int drv);
142 ///     int get_tape_position(int drv);
143 ///     const _TCHAR* get_tape_message(int drv);
144 ///     void push_play(int drv);
145 ///     void push_stop(int drv);
146 ///     void push_fast_forward(int drv);
147 ///     void push_fast_rewind(int drv);
148 ///     void push_apss_forward(int drv) {}
149 ///     void push_apss_rewind(int drv) {}
150         bool is_frame_skippable();
151         
152         void update_config();
153         bool process_state(FILEIO* state_fio, bool loading);
154         
155         // ----------------------------------------
156         // for each device
157         // ----------------------------------------
158         
159         // devices
160         DEVICE* get_device(int id);
161         //DEVICE* dummy;
162         //DEVICE* first_device;
163         //DEVICE* last_device;
164 };
165 #endif