OSDN Git Service

[VM][I286] Save cpustate without StateBuffer().
[csp-qt/common_source_project-fm7.git] / source / src / vm / m5 / m5.h
1 /*
2         SORD m5 Emulator 'Emu5'
3
4         Author : Takeda.Toshiya
5         Date   : 2006.08.18 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _M5_H_
11 #define _M5_H_
12
13 #define DEVICE_NAME             "SORD m5"
14 #define CONFIG_NAME             "m5"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          60
18 #define LINES_PER_FRAME         262
19 #define CPU_CLOCKS              3800000
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 USE_CART                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_SOUND_VOLUME        3
35 #define SUPPORT_TV_RENDER
36 #define USE_JOYSTICK
37 #define USE_DEBUGGER
38 #define USE_STATE
39 #define USE_CPU_Z80
40
41 #include "../../common.h"
42 #include "../../fileio.h"
43 #include "../vm_template.h"
44
45 #ifdef USE_SOUND_VOLUME
46 static const _TCHAR *sound_device_caption[] = {
47         _T("PSG"), _T("CMT (Signal)"), _T("Noise (CMT)"),
48 };
49 #endif
50
51 class csp_state_utils;
52 class EMU;
53 class DEVICE;
54 class EVENT;
55
56 class DATAREC;
57 class IO;
58 class MEMORY;
59 class SN76489AN;
60 class TMS9918A;
61 class Z80;
62 class Z80CTC;
63
64 class CMT;
65 class KEYBOARD;
66
67 class VM : public VM_TEMPLATE
68 {
69 protected:
70         //EMU* emu;
71         //csp_state_utils *state_entry;
72         
73         // devices
74         //EVENT* event;
75         
76         DATAREC* drec;
77         IO* io;
78         MEMORY* memory;
79         SN76489AN* psg;
80         TMS9918A* vdp;
81         Z80* cpu;
82         Z80CTC* ctc;
83         
84         CMT* cmt;
85         KEYBOARD* key;
86         
87         // memory
88         uint8_t ipl[0x2000];    // ipl (8k)
89         uint8_t cart[0x5000];   // cartridge (20k)
90         uint8_t ram[0x1000];    // ram (4k)
91         uint8_t ext[0x8000];    // ext ram (32k)
92         bool inserted;
93         
94         // FD5 floppy drive uint
95         Z80* subcpu;
96         
97 public:
98         // ----------------------------------------
99         // initialize
100         // ----------------------------------------
101         
102         VM(EMU* parent_emu);
103         ~VM();
104         
105         // ----------------------------------------
106         // for emulation class
107         // ----------------------------------------
108         
109         // drive virtual machine
110         void reset();
111         void run();
112         
113 #ifdef USE_DEBUGGER
114         // debugger
115         DEVICE *get_cpu(int index);
116 #endif
117         
118         // draw screen
119         void draw_screen();
120         
121         // sound generation
122         void initialize_sound(int rate, int samples);
123         uint16_t* create_sound(int* extra_frames);
124         int get_sound_buffer_ptr();
125 #ifdef USE_SOUND_VOLUME
126         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
127 #endif
128         
129         // user interface
130         void open_cart(int drv, const _TCHAR* file_path);
131         void close_cart(int drv);
132         bool is_cart_inserted(int drv);
133         void play_tape(int drv, const _TCHAR* file_path);
134         void rec_tape(int drv, const _TCHAR* file_path);
135         void close_tape(int drv);
136         bool is_tape_inserted(int drv);
137         bool is_tape_playing(int drv);
138         bool is_tape_recording(int drv);
139         int get_tape_position(int drv);
140         const _TCHAR* get_tape_message(int drv);
141         void push_play(int drv);
142         void push_stop(int drv);
143         void push_fast_forward(int drv);
144         void push_fast_rewind(int drv);
145         void push_apss_forward(int drv) {}
146         void push_apss_rewind(int drv) {}
147         bool is_frame_skippable();
148         
149         void update_config();
150         bool process_state(FILEIO* state_fio, bool loading);
151         
152         // ----------------------------------------
153         // for each device
154         // ----------------------------------------
155         
156         // devices
157         DEVICE* get_device(int id);
158         //DEVICE* dummy;
159         //DEVICE* first_device;
160         //DEVICE* last_device;
161 };
162
163 #endif