OSDN Git Service

[VM] Apply VM_TEMPLATE to all VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pv2000 / pv2000.h
1 /*
2         CASIO PV-2000 Emulator 'EmuGaki'
3
4         Author : Takeda.Toshiya
5         Date   : 2006.08.18 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _PV2000_H_
11 #define _PV2000_H_
12
13 #define DEVICE_NAME             "CASIO PV-2000"
14 #define CONFIG_NAME             "pv2000"
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 MEMORY_ADDR_MAX         0x10000
25 #define MEMORY_BANK_SIZE        0x1000
26
27 // device informations for win32
28 #define SUPPORT_TV_RENDER
29 #define USE_CART                        1
30 #define USE_TAPE                        1
31 #define TAPE_BINARY_ONLY
32 #define NOTIFY_KEY_DOWN
33 #define USE_ALT_F10_KEY
34 #define USE_AUTO_KEY            5
35 #define USE_AUTO_KEY_RELEASE    6
36 #define USE_AUTO_KEY_CAPS
37 #define USE_SOUND_VOLUME        1
38 #define USE_JOYSTICK
39 #define USE_DEBUGGER
40 #define USE_STATE
41 #define USE_CPU_Z80
42
43 #include "../../common.h"
44 #include "../../fileio.h"
45 #include "../vm_template.h"
46
47 #ifdef USE_SOUND_VOLUME
48 static const _TCHAR *sound_device_caption[] = {
49         _T("PSG"),
50 //      _T("CMT Relay"),
51 };
52 #endif
53
54 class csp_state_utils;
55         
56 class EMU;
57 class DEVICE;
58 class EVENT;
59
60 class IO;
61 class MEMORY;
62 class SN76489AN;
63 class TMS9918A;
64 class Z80;
65
66 class CMT;
67 class KEYBOARD;
68 class PRINTER;
69
70 class VM : public VM_TEMPLATE
71 {
72 protected:
73         //EMU* emu;
74         //csp_state_utils* state_entry;
75         
76         // devices
77         //EVENT* event;
78         
79         IO* io;
80         MEMORY* memory;
81         SN76489AN* psg;
82         TMS9918A* vdp;
83         Z80* cpu;
84         
85         CMT* cmt;
86         KEYBOARD* key;
87         PRINTER* prt;
88         
89         // memory
90         uint8_t ipl[0x4000];    // ipl (16k)
91         uint8_t ram[0x1000];    // ram (4k)
92         uint8_t ext[0x4000];    // ext ram/rom (16k)
93         uint8_t cart[0x4000];   // cartridge (16k)
94         bool inserted;
95         
96 public:
97         // ----------------------------------------
98         // initialize
99         // ----------------------------------------
100         
101         VM(EMU* parent_emu);
102         ~VM();
103         
104         // ----------------------------------------
105         // for emulation class
106         // ----------------------------------------
107         
108         // drive virtual machine
109         void reset();
110         void run();
111         
112 #ifdef USE_DEBUGGER
113         // debugger
114         DEVICE *get_cpu(int index);
115 #endif
116         
117         // draw screen
118         void draw_screen();
119         
120         // sound generation
121         void initialize_sound(int rate, int samples);
122         uint16_t* create_sound(int* extra_frames);
123         int get_sound_buffer_ptr();
124 #ifdef USE_SOUND_VOLUME
125         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
126 #endif
127         
128         // notify key
129         void key_down(int code, bool repeat);
130         void key_up(int code);
131         
132         // user interface
133         void open_cart(int drv, const _TCHAR* file_path);
134         void close_cart(int drv);
135         bool is_cart_inserted(int drv);
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_frame_skippable();
141         
142         void update_config();
143         void decl_state();
144         void save_state(FILEIO* state_fio);
145         bool load_state(FILEIO* state_fio);
146         
147         // ----------------------------------------
148         // for each device
149         // ----------------------------------------
150         
151         // devices
152         DEVICE* get_device(int id);
153         //DEVICE* dummy;
154         //DEVICE* first_device;
155         //DEVICE* last_device;
156 };
157
158 #endif