OSDN Git Service

[ROMAKANA] More supported VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / tk80bs / tk80bs.h
1 /*
2         NEC TK-80BS (COMPO BS/80) Emulator 'eTK-80BS'
3
4         Author : Takeda.Toshiya
5         Date   : 2008.08.26 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _TK80BS_H_
11 #define _TK80BS_H_
12
13 #define DEVICE_NAME             "NEC TK-80BS"
14 #define CONFIG_NAME             "tk80bs"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          59.9
18 #define LINES_PER_FRAME         262
19 #define CPU_CLOCKS              2048000
20 #define HAS_I8080
21 #define I8255_AUTO_HAND_SHAKE
22 #define SCREEN_WIDTH            784
23 #define SCREEN_HEIGHT           428
24 #define MEMORY_ADDR_MAX         0x10000
25 #define MEMORY_BANK_SIZE        0x200
26 #define IO_ADDR_MAX             0x10000
27
28 // device informations for win32
29 #define ONE_BOARD_MICRO_COMPUTER
30 #define MAX_BUTTONS             25
31 //#define MAX_DRAW_RANGES               9
32 #define USE_BOOT_MODE           2
33 //#define USE_DIPSWITCH
34 //#define DIPSWITCH_DEFAULT     0
35 #define USE_TAPE
36 #define TAPE_BINARY_ONLY
37 #define USE_BINARY_FILE1
38 #define NOTIFY_KEY_DOWN
39 #define USE_ALT_F10_KEY
40 #define USE_AUTO_KEY            5
41 #define USE_AUTO_KEY_RELEASE    6
42 #define USE_AUTO_KEY_NO_CAPS
43 #define SUPPORT_ROMA_KANA_CONVERSION
44
45 #define USE_SOUND_VOLUME        2
46 #define USE_DEBUGGER
47 #define USE_STATE
48
49 #include "../../common.h"
50 #include "../../fileio.h"
51
52 #ifdef USE_SOUND_VOLUME
53 static const _TCHAR *sound_device_caption[] = {
54         _T("Beep #1"), _T("Beep #2"),
55 };
56 #endif
57
58 const struct {
59         const _TCHAR* caption;
60         int x, y;
61         int width, height;
62         int font_size;
63         int code;
64 } vm_buttons[] = {
65         // virtual key codes 0x80-0x8f and 0x98-0x9f are not used in pc keyboard
66         {_T("0"),               523 + 46 * 0, 190 + 46 * 4, 40, 40, 20, 0x80},
67         {_T("1"),               523 + 46 * 1, 190 + 46 * 4, 40, 40, 20, 0x81},
68         {_T("2"),               523 + 46 * 2, 190 + 46 * 4, 40, 40, 20, 0x82},
69         {_T("3"),               523 + 46 * 3, 190 + 46 * 4, 40, 40, 20, 0x83},
70         {_T("4"),               523 + 46 * 0, 190 + 46 * 3, 40, 40, 20, 0x84},
71         {_T("5"),               523 + 46 * 1, 190 + 46 * 3, 40, 40, 20, 0x85},
72         {_T("6"),               523 + 46 * 2, 190 + 46 * 3, 40, 40, 20, 0x86},
73         {_T("7"),               523 + 46 * 3, 190 + 46 * 3, 40, 40, 20, 0x87},
74         {_T("8"),               523 + 46 * 0, 190 + 46 * 2, 40, 40, 20, 0x88},
75         {_T("9"),               523 + 46 * 1, 190 + 46 * 2, 40, 40, 20, 0x89},
76         {_T("A"),               523 + 46 * 2, 190 + 46 * 2, 40, 40, 20, 0x8a},
77         {_T("B"),               523 + 46 * 3, 190 + 46 * 2, 40, 40, 20, 0x8b},
78         {_T("C"),               523 + 46 * 0, 190 + 46 * 1, 40, 40, 20, 0x8c},
79         {_T("D"),               523 + 46 * 1, 190 + 46 * 1, 40, 40, 20, 0x8d},
80         {_T("E"),               523 + 46 * 2, 190 + 46 * 1, 40, 40, 20, 0x8e},
81         {_T("F"),               523 + 46 * 3, 190 + 46 * 1, 40, 40, 20, 0x8f},
82         {_T("RET"),             523 + 46 * 0, 190 + 46 * 0, 40, 40, 9,  0x98},
83         {_T("RUN"),             523 + 46 * 1, 190 + 46 * 0, 40, 40, 9,  0x99},
84         {_T("STORE\nDATA"),     523 + 46 * 2, 190 + 46 * 0, 40, 40, 9,  0x9a},
85         {_T("LOAD\nDATA"),      523 + 46 * 3, 190 + 46 * 0, 40, 40, 9,  0x9b},
86         {_T("RESET"),           523 + 46 * 4, 190 + 46 * 0, 40, 40, 9,  0x00},
87         {_T("ADRS\nSET"),       523 + 46 * 4, 190 + 46 * 1, 40, 40, 9,  0x9c},
88         {_T("READ\nINCR"),      523 + 46 * 4, 190 + 46 * 2, 40, 40, 9,  0x9d},
89         {_T("READ\nDECR"),      523 + 46 * 4, 190 + 46 * 3, 40, 40, 9,  0x9e},
90         {_T("WRITE\nINCR"),     523 + 46 * 4, 190 + 46 * 4, 40, 40, 9,  0x9f},
91 };
92 const struct {
93         int x, y;
94         int width, height;
95 } vm_ranges[] = {
96         {461 + 36 * 0, 28, 33, 46}, // 7-seg LEDs
97         {461 + 36 * 1, 28, 33, 46},
98         {461 + 36 * 2, 28, 33, 46},
99         {461 + 36 * 3, 28, 33, 46},
100         {618 + 36 * 0, 28, 33, 46},
101         {618 + 36 * 1, 28, 33, 46},
102         {618 + 36 * 2, 28, 33, 46},
103         {618 + 36 * 3, 28, 33, 46},
104         {4, 158, 512, 256}, // CRT
105 };
106
107 class EMU;
108 class DEVICE;
109 class EVENT;
110
111 class I8251;
112 class I8255;
113 class IO;
114 class MEMORY;
115 class PCM1BIT;
116 class I8080;
117
118 class CMT;
119 class DISPLAY;
120 class KEYBOARD;
121
122 class VM
123 {
124 protected:
125         EMU* emu;
126         
127         // devices
128         EVENT* event;
129         
130         I8251* sio_b;
131         I8255* pio_b;
132         I8255* pio_t;
133         IO* memio;
134         MEMORY* memory;
135         PCM1BIT* pcm0;
136         PCM1BIT* pcm1;
137         I8080* cpu;
138         
139         CMT* cmt;
140         DISPLAY* display;
141         KEYBOARD* keyboard;
142         
143         // memory
144         uint8_t mon[0x800];
145         uint8_t ext[0x7000];
146         uint8_t basic[0x2000];
147         uint8_t bsmon[0x1000];
148         uint8_t ram[0x5000];    // with TK-M20K
149         uint8_t vram[0x200];
150         
151         int boot_mode;
152         
153 public:
154         // ----------------------------------------
155         // initialize
156         // ----------------------------------------
157         
158         VM(EMU* parent_emu);
159         ~VM();
160         
161         // ----------------------------------------
162         // for emulation class
163         // ----------------------------------------
164         
165         // drive virtual machine
166         void reset();
167         void run();
168         
169 #ifdef USE_DEBUGGER
170         // debugger
171         DEVICE *get_cpu(int index);
172 #endif
173         
174         // draw screen
175         void draw_screen();
176         int max_draw_ranges();
177         
178         // sound generation
179         void initialize_sound(int rate, int samples);
180         uint16_t* create_sound(int* extra_frames);
181         int get_sound_buffer_ptr();
182 #ifdef USE_SOUND_VOLUME
183         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
184 #endif
185         
186         // notify key
187         void key_down(int code, bool repeat);
188         void key_up(int code);
189         
190         // user interface
191         void load_binary(int drv, const _TCHAR* file_path);
192         void save_binary(int drv, const _TCHAR* file_path);
193         void play_tape(const _TCHAR* file_path);
194         void rec_tape(const _TCHAR* file_path);
195         void close_tape();
196         bool is_tape_inserted();
197         bool is_frame_skippable();
198         
199         void update_config();
200         void save_state(FILEIO* state_fio);
201         bool load_state(FILEIO* state_fio);
202         
203         // ----------------------------------------
204         // for each device
205         // ----------------------------------------
206         
207         // devices
208         DEVICE* get_device(int id);
209         DEVICE* dummy;
210         DEVICE* first_device;
211         DEVICE* last_device;
212         
213         int draw_ranges;
214 };
215
216 #endif