OSDN Git Service

[VM] TRY:Use namespace {VMNAME} to separate around VMs. This feature still apply...
[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         //csp_state_utils* state_entry;
106         
107         // devices
108         //EVENT* event;
109         
110         IO* io;
111         MEMORY* memory;
112         Z80* cpu;
113         Z80CTC* ctc;
114         Z80PIO* pio1;
115         Z80PIO* pio2;
116         
117         BABBAGE2ND::DISPLAY* display;
118         BABBAGE2ND::KEYBOARD* keyboard;
119         
120         // memory
121         uint8_t rom[0x800];
122         uint8_t ram[0x800];
123         
124 public:
125         // ----------------------------------------
126         // initialize
127         // ----------------------------------------
128         
129         VM(EMU* parent_emu);
130         ~VM();
131         
132         // ----------------------------------------
133         // for emulation class
134         // ----------------------------------------
135         
136         // drive virtual machine
137         void reset();
138         void run();
139         
140 #ifdef USE_DEBUGGER
141         // debugger
142         DEVICE *get_cpu(int index);
143 #endif
144         
145         // draw screen
146         void draw_screen();
147         
148         // sound generation
149         void initialize_sound(int rate, int samples);
150         uint16_t* create_sound(int* extra_frames);
151         int get_sound_buffer_ptr();
152         
153         // notify key
154         void key_down(int code, bool repeat);
155         void key_up(int code);
156         
157         // user interface
158         void load_binary(int drv, const _TCHAR* file_path);
159         void save_binary(int drv, const _TCHAR* file_path);
160         bool is_frame_skippable();
161         
162         void update_config();
163         bool process_state(FILEIO* state_fio, bool loading);
164         
165         // ----------------------------------------
166         // for each device
167         // ----------------------------------------
168         
169         // devices
170         DEVICE* get_device(int id);
171         //DEVICE* dummy;
172         //DEVICE* first_device;
173         //DEVICE* last_device;
174 };
175
176 #endif