OSDN Git Service

[VM][General] Merge upstream 2016-02-13. Still don't implement OSD/Gui part of joysti...
[csp-qt/common_source_project-fm7.git] / source / src / vm / x07 / x07.h
1 /*
2         CANON X-07 Emulator 'eX-07'
3
4         Author : Takeda.Toshiya
5         Date   : 2007.12.26 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _X07_H_
11 #define _X07_H_
12
13 #define DEVICE_NAME             "CANON X-07"
14 #define CONFIG_NAME             "x07"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          60
18 #define LINES_PER_FRAME         262
19 #define CPU_CLOCKS              3840000
20 #define CPU_START_ADDR          0xc3c3
21 #define SCREEN_WIDTH            120
22 #define SCREEN_HEIGHT           32
23 #define TV_SCREEN_WIDTH         256
24 #define TV_SCREEN_HEIGHT        192
25 #define HAS_NSC800
26 #define MEMORY_ADDR_MAX         0x10000
27 #define MEMORY_BANK_SIZE        0x800
28
29 // device informations for win32
30 #define WINDOW_WIDTH            (SCREEN_WIDTH * 2)
31 #define WINDOW_HEIGHT           (SCREEN_HEIGHT * 2)
32 #define TV_WINDOW_WIDTH         TV_SCREEN_WIDTH
33 #define TV_WINDOW_HEIGHT        TV_SCREEN_HEIGHT
34
35 #define USE_TAPE
36 #define TAPE_BINARY_ONLY
37 #define NOTIFY_KEY_DOWN
38 #define USE_ALT_F10_KEY
39 #define USE_AUTO_KEY            6
40 #define USE_AUTO_KEY_RELEASE    10
41 #define USE_AUTO_KEY_CAPS
42 #define USE_SOUND_VOLUME        1
43 #define USE_DEBUGGER
44 #define USE_STATE
45
46 #include "../../common.h"
47
48 #ifdef USE_SOUND_VOLUME
49 static const _TCHAR *sound_device_caption[] = {
50         _T("Beep"),
51 };
52 static const bool sound_device_monophonic[] = {
53         false,
54 };
55 #endif
56
57 class EMU;
58 class DEVICE;
59 class EVENT;
60
61 class BEEP;
62 class MEMORY;
63 class Z80;
64
65 class IO;
66
67 #include "../../fileio.h"
68
69 class VM
70 {
71 protected:
72         EMU* emu;
73         
74         // devices
75         EVENT* event;
76         
77         BEEP* beep;
78         MEMORY* memory;
79         Z80* cpu;
80         
81         IO* io;
82         
83         // memory
84 //      uint8 c3[0x2000];
85         uint8 ram[0x6000];
86         uint8 app[0x2000];
87         uint8 vram[0x1800];
88         uint8 tv[0x1000];
89         uint8 bas[0x5000];
90         
91 public:
92         // ----------------------------------------
93         // initialize
94         // ----------------------------------------
95         
96         VM(EMU* parent_emu);
97         ~VM();
98         
99         // ----------------------------------------
100         // for emulation class
101         // ----------------------------------------
102         
103         // drive virtual machine
104         void reset();
105         void run();
106         
107 #ifdef USE_DEBUGGER
108         // debugger
109         DEVICE *get_cpu(int index);
110 #endif
111         
112         // draw screen
113         void draw_screen();
114         
115         // sound generation
116         void initialize_sound(int rate, int samples);
117         uint16* create_sound(int* extra_frames);
118         int sound_buffer_ptr();
119 #ifdef USE_SOUND_VOLUME
120         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
121 #endif
122         
123         // notify key
124         void key_down(int code, bool repeat);
125         void key_up(int code);
126         
127         // user interface
128         void play_tape(const _TCHAR* file_path);
129         void rec_tape(const _TCHAR* file_path);
130         void close_tape();
131         bool tape_inserted();
132         bool now_skip();
133         
134         void update_config();
135         void save_state(FILEIO* state_fio);
136         bool load_state(FILEIO* state_fio);
137         
138         // ----------------------------------------
139         // for each device
140         // ----------------------------------------
141         
142         // devices
143         DEVICE* get_device(int id);
144         DEVICE* dummy;
145         DEVICE* first_device;
146         DEVICE* last_device;
147 };
148
149 #endif