OSDN Git Service

[VM][General][WIP] Apply new (Upstream 2016-02-21) APIs to VMs.
[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 ONE_BOARD_MICRO_COMPUTER
27 #define MAX_BUTTONS             21
28 #define MAX_DRAW_RANGES         6
29 #define USE_BINARY_FILE1
30
31 #include "../../common.h"
32 #include "../../fileio.h"
33
34 const struct {
35         const _TCHAR* caption;
36         int x, y;
37         int width, height;
38         int font_size;
39         int code;
40 } vm_buttons[] = {
41         {_T("0"), 344, 288, 42, 42, 20, 0x30},
42         {_T("1"), 403, 288, 42, 42, 20, 0x31},
43         {_T("2"), 462, 288, 42, 42, 20, 0x32},
44         {_T("3"), 521, 288, 42, 42, 20, 0x33},
45         {_T("4"), 344, 229, 42, 42, 20, 0x34},
46         {_T("5"), 403, 229, 42, 42, 20, 0x35},
47         {_T("6"), 462, 229, 42, 42, 20, 0x36},
48         {_T("7"), 521, 229, 42, 42, 20, 0x37},
49         {_T("8"), 344, 170, 42, 42, 20, 0x38},
50         {_T("9"), 403, 170, 42, 42, 20, 0x39},
51         {_T("A"), 462, 170, 42, 42, 20, 0x41},
52         {_T("B"), 521, 170, 42, 42, 20, 0x42},
53         {_T("C"), 344, 111, 42, 42, 20, 0x43},
54         {_T("D"), 403, 111, 42, 42, 20, 0x44},
55         {_T("E"), 462, 111, 42, 42, 20, 0x45},
56         {_T("F"), 521, 111, 42, 42, 20, 0x46},
57         {_T("WRITE\nINC"), 581, 288, 42, 42, 10, 0x70},
58         {_T("READ\nDEC"),  581, 229, 42, 42, 10, 0x71},
59         {_T("READ\nINC"),  581, 170, 42, 42, 10, 0x72},
60         {_T("ADR\nRUN"),   581, 111, 42, 42, 10, 0x73},
61         {_T("RESET"),      265, 288, 42, 42, 10, 0x00}
62 };
63 const struct {
64         int x, y;
65         int width, height;
66 } vm_ranges[] = {
67         {357, 23, 28, 40},
68         {392, 23, 28, 40},
69         {439, 23, 28, 40},
70         {474, 23, 28, 40},
71         {547, 23, 28, 40},
72         {582, 23, 28, 40},
73 };
74
75 class EMU;
76 class DEVICE;
77 class EVENT;
78
79 class IO;
80 class I8255;
81 class MEMORY;
82 //class PCM1BIT;
83 class Z80;
84
85 class DISPLAY;
86 class KEYBOARD;
87
88 class VM
89 {
90 protected:
91         EMU* emu;
92         
93         // devices
94         EVENT* event;
95         
96         IO* io;
97         I8255* pio;
98         MEMORY* memory;
99 //      PCM1BIT* pcm;
100         Z80* cpu;
101         
102         DISPLAY* display;
103         KEYBOARD* keyboard;
104         
105         // memory
106         uint8 rom[0x2000];
107         uint8 ram[0x2000];
108         
109 public:
110         // ----------------------------------------
111         // initialize
112         // ----------------------------------------
113         
114         VM(EMU* parent_emu);
115         ~VM();
116         
117         // ----------------------------------------
118         // for emulation class
119         // ----------------------------------------
120         
121         // drive virtual machine
122         void reset();
123         void run();
124         
125         // draw screen
126         void draw_screen();
127         
128         // sound generation
129         void initialize_sound(int rate, int samples);
130         uint16* create_sound(int* extra_frames);
131         int get_sound_buffer_ptr();
132         
133         // user interface
134         void load_binary(int drv, const _TCHAR* file_path);
135         void save_binary(int drv, const _TCHAR* file_path);
136         bool is_frame_skippable();
137         
138         void update_config();
139         
140         // ----------------------------------------
141         // for each device
142         // ----------------------------------------
143         
144         // devices
145         DEVICE* get_device(int id);
146         DEVICE* dummy;
147         DEVICE* first_device;
148         DEVICE* last_device;
149 };
150
151 #endif