OSDN Git Service

[General] More merge upstream 2015-11-30.
[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            768
23 #define SCREEN_HEIGHT           800
24 #define MEMORY_ADDR_MAX         0x10000
25 #define MEMORY_BANK_SIZE        0x200
26 #define IO_ADDR_MAX             0x10000
27 #define SCREEN_WIDTH_ASPECT SCREEN_WIDTH 
28 #define SCREEN_HEIGHT_ASPECT SCREEN_HEIGHT
29 #define WINDOW_WIDTH_ASPECT 256
30 #define WINDOW_HEIGHT_ASPECT 192 
31
32 // device informations for win32
33 #define ONE_BOARD_MICRO_COMPUTER
34 #define MAX_BUTTONS             25
35 #define MAX_DRAW_RANGES         9
36 #define BITMAP_OFFSET_Y         384
37 #define USE_BOOT_MODE           2
38 #define USE_TAPE
39 #define TAPE_BINARY_ONLY
40 #define USE_BINARY_FILE1
41 #define NOTIFY_KEY_DOWN
42 #define USE_ALT_F10_KEY
43 #define USE_AUTO_KEY            5
44 #define USE_AUTO_KEY_RELEASE    6
45 #define USE_AUTO_KEY_NO_CAPS
46 #define USE_DEBUGGER
47
48 #include "../../common.h"
49 #include "../../fileio.h"
50
51 const struct {
52         const _TCHAR* caption;
53         int x, y;
54         int width, height;
55         int font_size;
56         int code;
57 } buttons[] = {
58         // virtual key codes 0x80-0x8f and 0x98-0x9f are not used in pc keyboard
59         {_T("0"), 512, 750, 40, 40, 20, 0x80},
60         {_T("1"), 557, 750, 40, 40, 20, 0x81},
61         {_T("2"), 602, 750, 40, 40, 20, 0x82},
62         {_T("3"), 647, 750, 40, 40, 20, 0x83},
63         {_T("4"), 512, 705, 40, 40, 20, 0x84},
64         {_T("5"), 557, 705, 40, 40, 20, 0x85},
65         {_T("6"), 602, 705, 40, 40, 20, 0x86},
66         {_T("7"), 647, 705, 40, 40, 20, 0x87},
67         {_T("8"), 512, 660, 40, 40, 20, 0x88},
68         {_T("9"), 557, 660, 40, 40, 20, 0x89},
69         {_T("A"), 602, 660, 40, 40, 20, 0x8a},
70         {_T("B"), 647, 660, 40, 40, 20, 0x8b},
71         {_T("C"), 512, 615, 40, 40, 20, 0x8c},
72         {_T("D"), 557, 615, 40, 40, 20, 0x8d},
73         {_T("E"), 602, 615, 40, 40, 20, 0x8e},
74         {_T("F"), 647, 615, 40, 40, 20, 0x8f},
75         {_T("RET"),         512, 570, 40, 40, 9, 0x98},
76         {_T("RUN"),         557, 570, 40, 40, 9, 0x99},
77         {_T("STORE\nDATA"), 602, 570, 40, 40, 9, 0x9a},
78         {_T("LOAD\nDATA"),  647, 570, 40, 40, 9, 0x9b},
79         {_T("RESET"),       692, 570, 40, 40, 9, 0x00},
80         {_T("ADRS\nSET"),   692, 615, 40, 40, 9, 0x9c},
81         {_T("READ\nINCR"),  692, 660, 40, 40, 9, 0x9d},
82         {_T("READ\nDECR"),  692, 705, 40, 40, 9, 0x9e},
83         {_T("WRITE\nINCR"), 692, 750, 40, 40, 9, 0x9f},
84 };
85 const struct {
86         int x, y;
87         int width, height;
88 } ranges[] = {
89         {451,  410, 32,  45 }, // 7-seg LEDs
90         {486,  410, 32,  45 },
91         {521,  410, 32,  45 },
92         {556,  410, 32,  45 },
93         {607,  410, 32,  45 },
94         {642,  410, 32,  45 },
95         {677,  410, 32,  45 },
96         {712,  410, 32,  45 },
97         {0,    0,   768, 384}, // CRT
98 };
99
100 class EMU;
101 class DEVICE;
102 class EVENT;
103
104 class I8251;
105 class I8255;
106 class IO;
107 class MEMORY;
108 class PCM1BIT;
109 class I8080;
110
111 class CMT;
112 class DISPLAY;
113 class KEYBOARD;
114
115 class VM
116 {
117 protected:
118         EMU* emu;
119         
120         // devices
121         EVENT* event;
122         
123         I8251* sio_b;
124         I8255* pio_b;
125         I8255* pio_t;
126         IO* memio;
127         MEMORY* memory;
128         PCM1BIT* pcm0;
129         PCM1BIT* pcm1;
130         I8080* cpu;
131         
132         CMT* cmt;
133         DISPLAY* display;
134         KEYBOARD* keyboard;
135         
136         // memory
137         uint8 mon[0x800];
138         uint8 ext[0x7000];
139         uint8 basic[0x2000];
140         uint8 bsmon[0x1000];
141         uint8 ram[0x5000];      // with TK-M20K
142         uint8 vram[0x200];
143         
144         int boot_mode;
145         
146 public:
147         // ----------------------------------------
148         // initialize
149         // ----------------------------------------
150         
151         VM(EMU* parent_emu);
152         ~VM();
153         
154         // ----------------------------------------
155         // for emulation class
156         // ----------------------------------------
157         
158         // drive virtual machine
159         void reset();
160         void run();
161         
162 #ifdef USE_DEBUGGER
163         // debugger
164         DEVICE *get_cpu(int index);
165 #endif
166         
167         // draw screen
168         void draw_screen();
169         
170         // sound generation
171         void initialize_sound(int rate, int samples);
172         uint16* create_sound(int* extra_frames);
173         int sound_buffer_ptr();
174         
175         // notify key
176         void key_down(int code, bool repeat);
177         void key_up(int code);
178         
179         // user interface
180         void load_binary(int drv, const _TCHAR* file_path);
181         void save_binary(int drv, const _TCHAR* file_path);
182         void play_tape(const _TCHAR* file_path);
183         void rec_tape(const _TCHAR* file_path);
184         void close_tape();
185         bool tape_inserted();
186         bool now_skip();
187         
188         void update_config();
189         
190         // ----------------------------------------
191         // for each device
192         // ----------------------------------------
193         
194         // devices
195         DEVICE* get_device(int id);
196         DEVICE* dummy;
197         DEVICE* first_device;
198         DEVICE* last_device;
199 };
200
201 #endif