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 / ex80 / ex80.h
1 /*
2         TOSHIBA EX-80 Emulator 'eEX-80'
3
4         Author : Takeda.Toshiya
5         Date   : 2015.12.10-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _EX80_H_
11 #define _EX80_H_
12
13 #define DEVICE_NAME             "TOSHIBA EX-80"
14 #define CONFIG_NAME             "ex80"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          59.94
18 #define LINES_PER_FRAME         525
19 #define CPU_CLOCKS              2048000
20 #define HAS_I8080
21 #define SCREEN_WIDTH            960
22 #define SCREEN_HEIGHT           670
23 #define MEMORY_ADDR_MAX         0x10000
24 #define MEMORY_BANK_SIZE        0x400
25 #define IO_ADDR_MAX             0x100
26
27 // device informations for win32
28 #define ONE_BOARD_MICRO_COMPUTER
29 #define MAX_BUTTONS             25
30 #define MAX_DRAW_RANGES         9
31 /*
32 SW1     ON = STEP / OFF = AUTO
33 SW2     ON = CHAR / OFF = BIT
34 SW3-1/2 ON ,ON  = 8000H-81FFH
35         OFF,ON  = 8200H-83FFH
36         ON ,OFF = 8400H-85FFH
37         OFF,OFF = 8600H-87FFH
38 */
39 #define USE_DIPSWITCH
40 #define DIPSWITCH_DEFAULT       0x0e
41 #define USE_TAPE
42 #define TAPE_BINARY_ONLY
43 #define USE_BINARY_FILE1
44 #define USE_ALT_F10_KEY
45 #define USE_AUTO_KEY            5
46 #define USE_AUTO_KEY_RELEASE    6
47 #define USE_AUTO_KEY_NO_CAPS
48 #define USE_SOUND_VOLUME        1
49 #define USE_DEBUGGER
50 #define USE_STATE
51
52 #include "../../common.h"
53 #include "../../fileio.h"
54
55 #ifdef USE_SOUND_VOLUME
56 static const _TCHAR *sound_device_caption[] = {
57         _T("Beep"),
58 };
59 #endif
60
61 #define LED_WIDTH       26
62 #define LED_HEIGHT      51
63
64 const struct {
65         const _TCHAR* caption;
66         int x, y;
67         int width, height;
68         int font_size;
69         int code;
70 } vm_buttons[] = {
71         // virtual key codes 0x80-0x8f and 0x98-0x9f are not used in pc keyboard
72         {_T("0"),       762 + 36 * 0,   478 + 34 * 4,   32,     20,     14,     0x80},
73         {_T("1"),       762 + 36 * 1,   478 + 34 * 4,   32,     20,     14,     0x81},
74         {_T("2"),       762 + 36 * 2,   478 + 34 * 4,   32,     20,     14,     0x82},
75         {_T("3"),       762 + 36 * 3,   478 + 34 * 4,   32,     20,     14,     0x83},
76         {_T("4"),       762 + 36 * 0,   478 + 34 * 3,   32,     20,     14,     0x84},
77         {_T("5"),       762 + 36 * 1,   478 + 34 * 3,   32,     20,     14,     0x85},
78         {_T("6"),       762 + 36 * 2,   478 + 34 * 3,   32,     20,     14,     0x86},
79         {_T("7"),       762 + 36 * 3,   478 + 34 * 3,   32,     20,     14,     0x87},
80         {_T("8"),       762 + 36 * 0,   478 + 34 * 2,   32,     20,     14,     0x88},
81         {_T("9"),       762 + 36 * 1,   478 + 34 * 2,   32,     20,     14,     0x89},
82         {_T("A"),       762 + 36 * 2,   478 + 34 * 2,   32,     20,     14,     0x8a},
83         {_T("B"),       762 + 36 * 3,   478 + 34 * 2,   32,     20,     14,     0x8b},
84         {_T("C"),       762 + 36 * 0,   478 + 34 * 1,   32,     20,     14,     0x8c},
85         {_T("D"),       762 + 36 * 1,   478 + 34 * 1,   32,     20,     14,     0x8d},
86         {_T("E"),       762 + 36 * 2,   478 + 34 * 1,   32,     20,     14,     0x8e},
87         {_T("F"),       762 + 36 * 3,   478 + 34 * 1,   32,     20,     14,     0x8f},
88         {_T("RET"),     762 + 36 * 0,   478 + 34 * 0,   32,     20,     10,     0x98},
89         {_T("RUN"),     762 + 36 * 1,   478 + 34 * 0,   32,     20,     10,     0x99},
90         {_T("SDA"),     762 + 36 * 2,   478 + 34 * 0,   32,     20,     10,     0x9a},
91         {_T("LDA"),     762 + 36 * 3,   478 + 34 * 0,   32,     20,     10,     0x9b},
92         {_T("RST"),     762 + 36 * 4,   478 + 34 * 0,   32,     20,     10,     0x00},
93         {_T("ADR"),     762 + 36 * 4,   478 + 34 * 1,   32,     20,     10,     0x9c},
94         {_T("RIC"),     762 + 36 * 4,   478 + 34 * 2,   32,     20,     10,     0x9d},
95         {_T("RDC"),     762 + 36 * 4,   478 + 34 * 3,   32,     20,     10,     0x9e},
96         {_T("WIC"),     762 + 36 * 4,   478 + 34 * 4,   32,     20,     10,     0x9f},
97 };
98 const struct {
99         int x, y;
100         int width, height;
101 } vm_ranges[] = {
102         {668 + 33 * 0, 295, LED_WIDTH, LED_HEIGHT }, // 7-seg LEDs
103         {668 + 33 * 1, 295, LED_WIDTH, LED_HEIGHT },
104         {668 + 33 * 2, 295, LED_WIDTH, LED_HEIGHT },
105         {668 + 33 * 3, 295, LED_WIDTH, LED_HEIGHT },
106         {828 + 33 * 0, 295, LED_WIDTH, LED_HEIGHT },
107         {828 + 33 * 1, 295, LED_WIDTH, LED_HEIGHT },
108         {828 + 33 * 2, 295, LED_WIDTH, LED_HEIGHT },
109         {828 + 33 * 3, 295, LED_WIDTH, LED_HEIGHT },
110         {8, 8, 8 * 6 * 12, 8 * 2 * 29}, // CRT
111 };
112
113 class EMU;
114 class DEVICE;
115 class EVENT;
116
117 class I8251;
118 class I8255;
119 class IO;
120 class PCM1BIT;
121 class I8080;
122
123 class CMT;
124 class DISPLAY;
125 class KEYBOARD;
126 class MEMORY;
127
128 class VM
129 {
130 protected:
131         EMU* emu;
132         
133         // devices
134         EVENT* event;
135         
136         I8251* sio;
137         I8255* pio;
138         IO* io;
139         PCM1BIT* pcm;
140         I8080* cpu;
141         
142         CMT* cmt;
143         DISPLAY* display;
144         KEYBOARD* keyboard;
145         MEMORY* memory;
146         
147 public:
148         // ----------------------------------------
149         // initialize
150         // ----------------------------------------
151         
152         VM(EMU* parent_emu);
153         ~VM();
154         
155         // ----------------------------------------
156         // for emulation class
157         // ----------------------------------------
158         
159         // drive virtual machine
160         void reset();
161         void run();
162         
163 #ifdef USE_DEBUGGER
164         // debugger
165         DEVICE *get_cpu(int index);
166 #endif
167         
168         // draw screen
169         void draw_screen();
170         
171         // sound generation
172         void initialize_sound(int rate, int samples);
173         uint16* create_sound(int* extra_frames);
174         int get_sound_buffer_ptr();
175 #ifdef USE_SOUND_VOLUME
176         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
177 #endif
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 is_tape_inserted();
186         bool is_frame_skippable();
187         
188         void update_config();
189         void save_state(FILEIO* state_fio);
190         bool load_state(FILEIO* state_fio);
191         
192         // ----------------------------------------
193         // for each device
194         // ----------------------------------------
195         
196         // devices
197         DEVICE* get_device(int id);
198         DEVICE* dummy;
199         DEVICE* first_device;
200         DEVICE* last_device;
201 };
202
203 #endif