OSDN Git Service

[VM][General] Merge Upstream 2017-03-30.
[csp-qt/common_source_project-fm7.git] / source / src / vm / babbage2nd / babbage2nd.h
1 /*
2         Gijutsu-Hyoron-Sha Babbage-2nd Emulator 'eBabbage-2nd'
3
4         Author : Takeda.Toshiya
5         Date   : 2009.12.26 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _BABBAGE_2ND_H_
11 #define _BABBAGE_2ND_H_
12
13 #define DEVICE_NAME             "GIJUTSU HYORON SHA Babbage-2nd"
14 #define CONFIG_NAME             "babbage2nd"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          30
18 #define LINES_PER_FRAME         256
19 #define CPU_CLOCKS              2500000
20 #define SCREEN_WIDTH            640
21 #define SCREEN_HEIGHT           483
22 #define MEMORY_ADDR_MAX         0x10000
23 #define MEMORY_BANK_SIZE        0x800
24
25 // device informations for win32
26 #define ONE_BOARD_MICRO_COMPUTER
27 #define MAX_BUTTONS             21
28 #define MAX_DRAW_RANGES         14
29 #define USE_BINARY_FILE1
30 #define NOTIFY_KEY_DOWN
31 #define USE_DEBUGGER
32 #define USE_STATE
33
34 #include "../../common.h"
35 #include "../../fileio.h"
36
37 const struct {
38         int x, y;
39         int width, height;
40         int code;
41 } vm_buttons[] = {
42         {353, 419, 49, 49, 0x30},       // 0
43         {407, 419, 49, 49, 0x31},       // 1
44         {461, 419, 49, 49, 0x32},       // 2
45         {515, 419, 49, 49, 0x33},       // 3
46         {353, 353, 49, 49, 0x34},       // 4
47         {407, 353, 49, 49, 0x35},       // 5
48         {461, 353, 49, 49, 0x36},       // 6
49         {515, 353, 49, 49, 0x37},       // 7
50         {353, 287, 49, 49, 0x38},       // 8
51         {407, 287, 49, 49, 0x39},       // 9
52         {461, 287, 49, 49, 0x41},       // A
53         {515, 287, 49, 49, 0x42},       // B
54         {353, 221, 49, 49, 0x43},       // C
55         {407, 221, 49, 49, 0x44},       // D
56         {461, 221, 49, 49, 0x45},       // E
57         {515, 221, 49, 49, 0x46},       // F
58         {575, 419, 49, 49, 0x70},       // INC
59         {575, 353, 49, 49, 0x71},       // DA
60         {575, 287, 49, 49, 0x72},       // AD
61         {575, 221, 49, 49, 0x73},       // GO
62         { 36,  18, 49, 49, 0x00},       // RES
63 };
64 const struct {
65         int x, y;
66         int width, height;
67 } vm_ranges[] = {
68         {587,  37, 34, 58},
69         {530,  37, 34, 58},
70         {455,  37, 34, 58},
71         {398,  37, 34, 58},
72         {341,  37, 34, 58},
73         {284,  37, 34, 58},
74         {600, 133, 17, 17},
75         {567, 133, 17, 17},
76         {534, 133, 17, 17},
77         {501, 133, 17, 17},
78         {468, 133, 17, 17},
79         {435, 133, 17, 17},
80         {402, 133, 17, 17},
81         {369, 133, 17, 17},
82 };
83
84 class EMU;
85 class DEVICE;
86 class EVENT;
87
88 class IO;
89 class MEMORY;
90 class Z80;
91 class Z80CTC;
92 class Z80PIO;
93
94 class DISPLAY;
95 class KEYBOARD;
96
97 class VM
98 {
99 protected:
100         EMU* emu;
101         
102         // devices
103         EVENT* event;
104         
105         IO* io;
106         MEMORY* memory;
107         Z80* cpu;
108         Z80CTC* ctc;
109         Z80PIO* pio1;
110         Z80PIO* pio2;
111         
112         DISPLAY* display;
113         KEYBOARD* keyboard;
114         
115         // memory
116         uint8_t rom[0x800];
117         uint8_t ram[0x800];
118         
119 public:
120         // ----------------------------------------
121         // initialize
122         // ----------------------------------------
123         
124         VM(EMU* parent_emu);
125         ~VM();
126         
127         // ----------------------------------------
128         // for emulation class
129         // ----------------------------------------
130         
131         // drive virtual machine
132         void reset();
133         void run();
134         
135 #ifdef USE_DEBUGGER
136         // debugger
137         DEVICE *get_cpu(int index);
138 #endif
139         
140         // draw screen
141         void draw_screen();
142         
143         // sound generation
144         void initialize_sound(int rate, int samples);
145         uint16_t* create_sound(int* extra_frames);
146         int get_sound_buffer_ptr();
147         
148         // notify key
149         void key_down(int code, bool repeat);
150         void key_up(int code);
151         
152         // user interface
153         void load_binary(int drv, const _TCHAR* file_path);
154         void save_binary(int drv, const _TCHAR* file_path);
155         bool is_frame_skippable();
156         
157         void update_config();
158         void save_state(FILEIO* state_fio);
159         bool load_state(FILEIO* state_fio);
160         
161         // ----------------------------------------
162         // for each device
163         // ----------------------------------------
164         
165         // devices
166         DEVICE* get_device(int id);
167         DEVICE* dummy;
168         DEVICE* first_device;
169         DEVICE* last_device;
170 };
171
172 #endif