OSDN Git Service

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