OSDN Git Service

[VM][STATE] Use namespace {VMNAME} to separate per VMs.
[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_FILE         1
30 #define NOTIFY_KEY_DOWN
31 #define USE_DEBUGGER
32 #define USE_STATE
33 #define USE_CPU_Z80
34
35 #include "../../common.h"
36 #include "../../fileio.h"
37 #include "../vm_template.h"
38
39 const struct {
40         int x, y;
41         int width, height;
42         int code;
43 } vm_buttons[] = {
44         {353, 419, 49, 49, 0x30},       // 0
45         {407, 419, 49, 49, 0x31},       // 1
46         {461, 419, 49, 49, 0x32},       // 2
47         {515, 419, 49, 49, 0x33},       // 3
48         {353, 353, 49, 49, 0x34},       // 4
49         {407, 353, 49, 49, 0x35},       // 5
50         {461, 353, 49, 49, 0x36},       // 6
51         {515, 353, 49, 49, 0x37},       // 7
52         {353, 287, 49, 49, 0x38},       // 8
53         {407, 287, 49, 49, 0x39},       // 9
54         {461, 287, 49, 49, 0x41},       // A
55         {515, 287, 49, 49, 0x42},       // B
56         {353, 221, 49, 49, 0x43},       // C
57         {407, 221, 49, 49, 0x44},       // D
58         {461, 221, 49, 49, 0x45},       // E
59         {515, 221, 49, 49, 0x46},       // F
60         {575, 419, 49, 49, 0x70},       // INC
61         {575, 353, 49, 49, 0x71},       // DA
62         {575, 287, 49, 49, 0x72},       // AD
63         {575, 221, 49, 49, 0x73},       // GO
64         { 36,  18, 49, 49, 0x00},       // RES
65 };
66 const struct {
67         int x, y;
68         int width, height;
69 } vm_ranges[] = {
70         {587,  37, 34, 58},
71         {530,  37, 34, 58},
72         {455,  37, 34, 58},
73         {398,  37, 34, 58},
74         {341,  37, 34, 58},
75         {284,  37, 34, 58},
76         {600, 133, 17, 17},
77         {567, 133, 17, 17},
78         {534, 133, 17, 17},
79         {501, 133, 17, 17},
80         {468, 133, 17, 17},
81         {435, 133, 17, 17},
82         {402, 133, 17, 17},
83         {369, 133, 17, 17},
84 };
85
86 class EMU;
87 class DEVICE;
88 class EVENT;
89
90 class IO;
91 class MEMORY;
92 class Z80;
93 class Z80CTC;
94 class Z80PIO;
95
96 namespace BABBAGE2ND {
97         class DISPLAY;
98         class KEYBOARD;
99 }
100
101 class VM : public VM_TEMPLATE
102 {
103 protected:
104         //EMU* emu;
105         
106         // devices
107         //EVENT* event;
108         
109         IO* io;
110         MEMORY* memory;
111         Z80* cpu;
112         Z80CTC* ctc;
113         Z80PIO* pio1;
114         Z80PIO* pio2;
115         
116         BABBAGE2ND::DISPLAY* display;
117         BABBAGE2ND::KEYBOARD* keyboard;
118         
119         // memory
120         uint8_t rom[0x800];
121         uint8_t ram[0x800];
122         
123 public:
124         // ----------------------------------------
125         // initialize
126         // ----------------------------------------
127         
128         VM(EMU* parent_emu);
129         ~VM();
130         
131         // ----------------------------------------
132         // for emulation class
133         // ----------------------------------------
134         
135         // drive virtual machine
136         void reset();
137         void run();
138         
139 #ifdef USE_DEBUGGER
140         // debugger
141         DEVICE *get_cpu(int index);
142 #endif
143         
144         // draw screen
145         void draw_screen();
146         
147         // sound generation
148         void initialize_sound(int rate, int samples);
149         uint16_t* create_sound(int* extra_frames);
150         int get_sound_buffer_ptr();
151         
152         // notify key
153         void key_down(int code, bool repeat);
154         void key_up(int code);
155         
156         // user interface
157         void load_binary(int drv, const _TCHAR* file_path);
158         void save_binary(int drv, const _TCHAR* file_path);
159         bool is_frame_skippable();
160         
161         void update_config();
162         bool process_state(FILEIO* state_fio, bool loading);
163         
164         // ----------------------------------------
165         // for each device
166         // ----------------------------------------
167         
168         // devices
169         DEVICE* get_device(int id);
170         //DEVICE* dummy;
171         //DEVICE* first_device;
172         //DEVICE* last_device;
173 };
174
175 #endif