OSDN Git Service

703827551a045c464f7f3a390e4e6b308a403e99
[csp-qt/common_source_project-fm7.git] / source / src / vm / colecovision / colecovision.h
1 /*
2         COLECO ColecoVision Emulator 'yaCOLECOVISION'
3
4         Author : tanam
5         Date   : 2016.08.14-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _COLECO_VISION_H_
11 #define _COLECO_VISION_H_
12
13 #define DEVICE_NAME             "COLECO ColecoVision"
14 #define CONFIG_NAME             "colecovision"
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
25 // device informations for win32
26 #define USE_CART                1
27 #define USE_SOUND_VOLUME        2
28 #define USE_JOYSTICK
29 #define USE_DEBUGGER
30 #define USE_STATE
31 #define USE_CPU_Z80
32
33 #include "../../common.h"
34 #include "../../fileio.h"
35 #include "../vm_template.h"
36
37 #ifdef USE_SOUND_VOLUME
38 static const _TCHAR *sound_device_caption[] = {
39         _T("PSG"),
40 };
41 #endif
42
43 //class csp_state_utils;
44 class EMU;
45 class DEVICE;
46 class EVENT;
47
48 class IO;
49 class SN76489AN;
50 class TMS9918A;
51 class Z80;
52
53 class KEYBOARD;
54 class MEMORY;
55
56 class VM : public VM_TEMPLATE
57 {
58 protected:
59         //EMU* emu;
60         //csp_state_utils *state_entry;
61         
62         // devices
63         //EVENT* event;
64         
65         IO* io;
66         SN76489AN* psg;
67         TMS9918A* vdp;
68         Z80* cpu;
69         
70         KEYBOARD* key;
71         MEMORY* memory;
72         
73 public:
74         // ----------------------------------------
75         // initialize
76         // ----------------------------------------
77         
78         VM(EMU* parent_emu);
79         ~VM();
80         
81         // ----------------------------------------
82         // for emulation class
83         // ----------------------------------------
84         
85         // drive virtual machine
86         void reset();
87         void run();
88         
89 #ifdef USE_DEBUGGER
90         // debugger
91         DEVICE *get_cpu(int index);
92 #endif
93         
94         // draw screen
95         void draw_screen();
96         
97         // sound generation
98         void initialize_sound(int rate, int samples);
99         uint16_t* create_sound(int* extra_frames);
100         int get_sound_buffer_ptr();
101 #ifdef USE_SOUND_VOLUME
102         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
103 #endif
104         
105         // user interface
106         void open_cart(int drv, const _TCHAR* file_path);
107         void close_cart(int drv);
108         bool is_cart_inserted(int drv);
109         bool is_frame_skippable();
110         
111         void update_config();
112         bool process_state(FILEIO* state_fio, bool loading);
113         
114         // ----------------------------------------
115         // for each device
116         // ----------------------------------------
117         
118         // devices
119         DEVICE* get_device(int id);
120         //DEVICE* dummy;
121         //DEVICE* first_device;
122         //DEVICE* last_device;
123 };
124
125 #endif