OSDN Git Service

[General][WIP] Merge upstream 2017-03-20.Still not implement UIs.
[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 TV_WINDOW_WIDTH         TV_SCREEN_WIDTH
31 #define TV_WINDOW_HEIGHT        TV_SCREEN_HEIGHT
32
33 #define WINDOW_MODE_BASE        2
34 #define USE_TAPE1
35 #define TAPE_BINARY_ONLY
36 #define NOTIFY_KEY_DOWN
37 #define USE_ALT_F10_KEY
38 #define USE_AUTO_KEY            6
39 #define USE_AUTO_KEY_RELEASE    10
40 #define USE_AUTO_KEY_CAPS
41 #define USE_SOUND_VOLUME        1
42 #define USE_DEBUGGER
43 #define USE_STATE
44
45 #include "../../common.h"
46
47 #ifdef USE_SOUND_VOLUME
48 static const _TCHAR *sound_device_caption[] = {
49         _T("Beep"),
50 };
51 #endif
52
53 class EMU;
54 class DEVICE;
55 class EVENT;
56
57 class BEEP;
58 class MEMORY;
59 class Z80;
60
61 class IO;
62
63 #include "../../fileio.h"
64
65 class VM
66 {
67 protected:
68         EMU* emu;
69         
70         // devices
71         EVENT* event;
72         
73         BEEP* beep;
74         MEMORY* memory;
75         Z80* cpu;
76         
77         IO* io;
78         
79         // memory
80 //      uint8_t c3[0x2000];
81         uint8_t ram[0x6000];
82         uint8_t app[0x2000];
83         uint8_t vram[0x1800];
84         uint8_t tv[0x1000];
85         uint8_t bas[0x5000];
86         
87 public:
88         // ----------------------------------------
89         // initialize
90         // ----------------------------------------
91         
92         VM(EMU* parent_emu);
93         ~VM();
94         
95         // ----------------------------------------
96         // for emulation class
97         // ----------------------------------------
98         
99         // drive virtual machine
100         void reset();
101         void run();
102         
103 #ifdef USE_DEBUGGER
104         // debugger
105         DEVICE *get_cpu(int index);
106 #endif
107         
108         // draw screen
109         void draw_screen();
110         
111         // sound generation
112         void initialize_sound(int rate, int samples);
113         uint16_t* create_sound(int* extra_frames);
114         int get_sound_buffer_ptr();
115 #ifdef USE_SOUND_VOLUME
116         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
117 #endif
118         
119         // notify key
120         void key_down(int code, bool repeat);
121         void key_up(int code);
122         
123         // user interface
124         void play_tape(int drv, const _TCHAR* file_path);
125         void rec_tape(int drv, const _TCHAR* file_path);
126         void close_tape(int drv);
127         bool is_tape_inserted(int drv);
128         bool is_frame_skippable();
129         
130         void update_config();
131         void save_state(FILEIO* state_fio);
132         bool load_state(FILEIO* state_fio);
133         
134         // ----------------------------------------
135         // for each device
136         // ----------------------------------------
137         
138         // devices
139         DEVICE* get_device(int id);
140         DEVICE* dummy;
141         DEVICE* first_device;
142         DEVICE* last_device;
143 };
144
145 #endif