OSDN Git Service

[General][Qt] Merge upstream 2015-03-15.
[csp-qt/common_source_project-fm7.git] / source / src / vm / ys6464a / ys6464a.h
1 /*
2         SHINKO SANGYO YS-6464A Emulator 'eYS-6464A'
3
4         Author : Takeda.Toshiya
5         Date   : 2009.12.30 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _BABBAGE_2ND_H_
11 #define _BABBAGE_2ND_H_
12
13 #define DEVICE_NAME             "SHINKO SANGYO YS-6464A"
14 #define CONFIG_NAME             "ys6464a"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          30
18 #define LINES_PER_FRAME         256
19 #define CPU_CLOCKS              4000000
20 #define SCREEN_WIDTH            640
21 #define SCREEN_HEIGHT           357
22 #define MEMORY_ADDR_MAX         0x10000
23 #define MEMORY_BANK_SIZE        0x2000
24
25 // device informations for win32
26 #define USE_BINARY_FILE1
27 #define USE_BITMAP
28 #define USE_BUTTON
29 #define MAX_BUTTONS             21
30 #define USE_LED
31 #define MAX_LEDS                6
32
33 #include "../../common.h"
34 #include "../../fileio.h"
35
36 const struct {
37         const _TCHAR* caption;
38         int x, y;
39         int width, height;
40         int font_size;
41         int code;
42 } buttons[] = {
43         {_T("0"), 344, 288, 42, 42, 20, 0x30},
44         {_T("1"), 403, 288, 42, 42, 20, 0x31},
45         {_T("2"), 462, 288, 42, 42, 20, 0x32},
46         {_T("3"), 521, 288, 42, 42, 20, 0x33},
47         {_T("4"), 344, 229, 42, 42, 20, 0x34},
48         {_T("5"), 403, 229, 42, 42, 20, 0x35},
49         {_T("6"), 462, 229, 42, 42, 20, 0x36},
50         {_T("7"), 521, 229, 42, 42, 20, 0x37},
51         {_T("8"), 344, 170, 42, 42, 20, 0x38},
52         {_T("9"), 403, 170, 42, 42, 20, 0x39},
53         {_T("A"), 462, 170, 42, 42, 20, 0x41},
54         {_T("B"), 521, 170, 42, 42, 20, 0x42},
55         {_T("C"), 344, 111, 42, 42, 20, 0x43},
56         {_T("D"), 403, 111, 42, 42, 20, 0x44},
57         {_T("E"), 462, 111, 42, 42, 20, 0x45},
58         {_T("F"), 521, 111, 42, 42, 20, 0x46},
59         {_T("WRITE\nINC"), 581, 288, 42, 42, 10, 0x70},
60         {_T("READ\nDEC"),  581, 229, 42, 42, 10, 0x71},
61         {_T("READ\nINC"),  581, 170, 42, 42, 10, 0x72},
62         {_T("ADR\nRUN"),   581, 111, 42, 42, 10, 0x73},
63         {_T("RESET"),      265, 288, 42, 42, 10, 0x00}
64 };
65 const struct {
66         int x, y;
67         int width, height;
68 } leds[] = {
69         {357, 23, 28, 40},
70         {392, 23, 28, 40},
71         {439, 23, 28, 40},
72         {474, 23, 28, 40},
73         {547, 23, 28, 40},
74         {582, 23, 28, 40},
75 };
76
77 class EMU;
78 class DEVICE;
79 class EVENT;
80
81 class IO;
82 class I8255;
83 class MEMORY;
84 //class PCM1BIT;
85 class Z80;
86
87 class DISPLAY;
88 class KEYBOARD;
89
90 class VM
91 {
92 protected:
93         EMU* emu;
94         
95         // devices
96         EVENT* event;
97         
98         IO* io;
99         I8255* pio;
100         MEMORY* memory;
101 //      PCM1BIT* pcm;
102         Z80* cpu;
103         
104         DISPLAY* display;
105         KEYBOARD* keyboard;
106         
107         // memory
108         uint8 rom[0x2000];
109         uint8 ram[0x2000];
110         
111 public:
112         // ----------------------------------------
113         // initialize
114         // ----------------------------------------
115         
116         VM(EMU* parent_emu);
117         ~VM();
118         
119         // ----------------------------------------
120         // for emulation class
121         // ----------------------------------------
122         
123         // drive virtual machine
124         void reset();
125         void run();
126         
127         // draw screen
128         void draw_screen();
129         
130         // sound generation
131         void initialize_sound(int rate, int samples);
132         uint16* create_sound(int* extra_frames);
133         int sound_buffer_ptr();
134         
135         // user interface
136         void load_binary(int drv, _TCHAR* file_path);
137         void save_binary(int drv, _TCHAR* file_path);
138         bool now_skip();
139         
140         void update_config();
141         
142         // ----------------------------------------
143         // for each device
144         // ----------------------------------------
145         
146         // devices
147         DEVICE* get_device(int id);
148         DEVICE* dummy;
149         DEVICE* first_device;
150         DEVICE* last_device;
151 };
152
153 #endif