OSDN Git Service

[VM][FMTOWNS][MEMORY] Fix setup around memory banks by I/O 0404h and 0480h.
[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 _YS_6464A_H_
11 #define _YS_6464A_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
23 // device informations for win32
24 #define ONE_BOARD_MICRO_COMPUTER
25 #define MAX_BUTTONS             21
26 #define MAX_DRAW_RANGES         6
27 #define USE_BINARY_FILE         1
28 #define USE_DEBUGGER
29 #define USE_STATE
30 #define USE_CPU_Z80
31
32 #include "../../common.h"
33 #include "../../fileio.h"
34 #include "../vm_template.h"
35
36 const struct {
37         int x, y;
38         int width, height;
39         int code;
40 } vm_buttons[] = {
41         {342 + 59 * 0, 287 - 59 * 0, 46, 46, 0x30},     // 0
42         {342 + 59 * 1, 287 - 59 * 0, 46, 46, 0x31},     // 1
43         {342 + 59 * 2, 287 - 59 * 0, 46, 46, 0x32},     // 2
44         {342 + 59 * 3, 287 - 59 * 0, 46, 46, 0x33},     // 3
45         {342 + 59 * 0, 287 - 59 * 1, 46, 46, 0x34},     // 4
46         {342 + 59 * 1, 287 - 59 * 1, 46, 46, 0x35},     // 5
47         {342 + 59 * 2, 287 - 59 * 1, 46, 46, 0x36},     // 6
48         {342 + 59 * 3, 287 - 59 * 1, 46, 46, 0x37},     // 7
49         {342 + 59 * 0, 287 - 59 * 2, 46, 46, 0x38},     // 8
50         {342 + 59 * 1, 287 - 59 * 2, 46, 46, 0x39},     // 9
51         {342 + 59 * 2, 287 - 59 * 2, 46, 46, 0x41},     // A
52         {342 + 59 * 3, 287 - 59 * 2, 46, 46, 0x42},     // B
53         {342 + 59 * 0, 287 - 59 * 3, 46, 46, 0x43},     // C
54         {342 + 59 * 1, 287 - 59 * 3, 46, 46, 0x44},     // D
55         {342 + 59 * 2, 287 - 59 * 3, 46, 46, 0x45},     // E
56         {342 + 59 * 3, 287 - 59 * 3, 46, 46, 0x46},     // F
57         {342 + 59 * 4, 287 - 59 * 0, 46, 46, 0x70},     // WRITE INC
58         {342 + 59 * 4, 287 - 59 * 1, 46, 46, 0x71},     // READ DEC
59         {342 + 59 * 4, 287 - 59 * 2, 46, 46, 0x72},     // READ INC
60         {342 + 59 * 4, 287 - 59 * 3, 46, 46, 0x73},     // ADR RUN
61         {262         , 287         , 46, 46, 0x00},     // RESET
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 namespace YS6464A {
86         class DISPLAY;
87         class KEYBOARD;
88 }
89
90 class VM : public VM_TEMPLATE
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         YS6464A::DISPLAY* display;
105         YS6464A::KEYBOARD* keyboard;
106
107         // memory
108         uint8_t rom[0x2000];
109         uint8_t ram[0x2000];
110
111 public:
112         // ----------------------------------------
113         // initialize
114         // ----------------------------------------
115
116         VM(EMU_TEMPLATE* parent_emu);
117         ~VM();
118
119         // ----------------------------------------
120         // for emulation class
121         // ----------------------------------------
122
123         // drive virtual machine
124         void reset();
125         void run();
126
127 #ifdef USE_DEBUGGER
128         // debugger
129         DEVICE *get_cpu(int index);
130 #endif
131
132         // draw screen
133         void draw_screen();
134
135         // sound generation
136         void initialize_sound(int rate, int samples);
137         uint16_t* create_sound(int* extra_frames);
138         int get_sound_buffer_ptr();
139
140         // user interface
141         void load_binary(int drv, const _TCHAR* file_path);
142         void save_binary(int drv, const _TCHAR* file_path);
143         bool is_frame_skippable();
144
145         double get_current_usec();
146         uint64_t get_current_clock_uint64();
147
148         void update_config();
149         bool process_state(FILEIO* state_fio, bool loading);
150
151         // ----------------------------------------
152         // for each device
153         // ----------------------------------------
154
155         // devices
156         DEVICE* get_device(int id);
157         //DEVICE* dummy;
158         //DEVICE* first_device;
159         //DEVICE* last_device;
160 };
161
162 #endif