OSDN Git Service

[GENERAL] Merge upstream 2017-02-09, but one-board-computers are not working yet.
[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         int x, y;
66         int width, height;
67         int code;
68 } vm_buttons[] = {
69         // virtual key codes 0x80-0x8f and 0x98-0x9f are not used in pc keyboard
70         {763 + 36 * 0, 478 + 34 * 4, 30, 21, 0x80}, // 0
71         {763 + 36 * 1, 478 + 34 * 4, 30, 21, 0x81}, // 1
72         {763 + 36 * 2, 478 + 34 * 4, 30, 21, 0x82}, // 2
73         {763 + 36 * 3, 478 + 34 * 4, 30, 21, 0x83}, // 3
74         {763 + 36 * 0, 478 + 34 * 3, 30, 21, 0x84}, // 4
75         {763 + 36 * 1, 478 + 34 * 3, 30, 21, 0x85}, // 5
76         {763 + 36 * 2, 478 + 34 * 3, 30, 21, 0x86}, // 6
77         {763 + 36 * 3, 478 + 34 * 3, 30, 21, 0x87}, // 7
78         {763 + 36 * 0, 478 + 34 * 2, 30, 21, 0x88}, // 8
79         {763 + 36 * 1, 478 + 34 * 2, 30, 21, 0x89}, // 9
80         {763 + 36 * 2, 478 + 34 * 2, 30, 21, 0x8a}, // A
81         {763 + 36 * 3, 478 + 34 * 2, 30, 21, 0x8b}, // B
82         {763 + 36 * 0, 478 + 34 * 1, 30, 21, 0x8c}, // C
83         {763 + 36 * 1, 478 + 34 * 1, 30, 21, 0x8d}, // D
84         {763 + 36 * 2, 478 + 34 * 1, 30, 21, 0x8e}, // E
85         {763 + 36 * 3, 478 + 34 * 1, 30, 21, 0x8f}, // F
86         {763 + 36 * 0, 478 + 34 * 0, 30, 21, 0x98}, // RET
87         {763 + 36 * 1, 478 + 34 * 0, 30, 21, 0x99}, // RUN
88         {763 + 36 * 2, 478 + 34 * 0, 30, 21, 0x9a}, // SDA
89         {763 + 36 * 3, 478 + 34 * 0, 30, 21, 0x9b}, // LDA
90         {763 + 36 * 4, 478 + 34 * 0, 30, 21, 0x00}, // RST
91         {763 + 36 * 4, 478 + 34 * 1, 30, 21, 0x9c}, // ADR
92         {763 + 36 * 4, 478 + 34 * 2, 30, 21, 0x9d}, // RIC
93         {763 + 36 * 4, 478 + 34 * 3, 30, 21, 0x9e}, // RDC
94         {763 + 36 * 4, 478 + 34 * 4, 30, 21, 0x9f}, // WIC
95 };
96 const struct {
97         int x, y;
98         int width, height;
99 } vm_ranges[] = {
100         {668 + 33 * 0, 295, LED_WIDTH, LED_HEIGHT}, // 7-seg LEDs
101         {668 + 33 * 1, 295, LED_WIDTH, LED_HEIGHT},
102         {668 + 33 * 2, 295, LED_WIDTH, LED_HEIGHT},
103         {668 + 33 * 3, 295, LED_WIDTH, LED_HEIGHT},
104         {828 + 33 * 0, 295, LED_WIDTH, LED_HEIGHT},
105         {828 + 33 * 1, 295, LED_WIDTH, LED_HEIGHT},
106         {828 + 33 * 2, 295, LED_WIDTH, LED_HEIGHT},
107         {828 + 33 * 3, 295, LED_WIDTH, LED_HEIGHT},
108         {8, 8, 8 * 6 * 12, 8 * 2 * 29}, // CRT
109 };
110
111 class EMU;
112 class DEVICE;
113 class EVENT;
114
115 class I8251;
116 class I8255;
117 class IO;
118 class PCM1BIT;
119 class I8080;
120
121 class CMT;
122 class DISPLAY;
123 class KEYBOARD;
124 class MEMORY;
125
126 class VM
127 {
128 protected:
129         EMU* emu;
130         
131         // devices
132         EVENT* event;
133         
134         I8251* sio;
135         I8255* pio;
136         IO* io;
137         PCM1BIT* pcm;
138         I8080* cpu;
139         
140         CMT* cmt;
141         DISPLAY* display;
142         KEYBOARD* keyboard;
143         MEMORY* memory;
144         
145 public:
146         // ----------------------------------------
147         // initialize
148         // ----------------------------------------
149         
150         VM(EMU* parent_emu);
151         ~VM();
152         
153         // ----------------------------------------
154         // for emulation class
155         // ----------------------------------------
156         
157         // drive virtual machine
158         void reset();
159         void run();
160         
161 #ifdef USE_DEBUGGER
162         // debugger
163         DEVICE *get_cpu(int index);
164 #endif
165         
166         // draw screen
167         void draw_screen();
168         
169         // sound generation
170         void initialize_sound(int rate, int samples);
171         uint16_t* create_sound(int* extra_frames);
172         int get_sound_buffer_ptr();
173 #ifdef USE_SOUND_VOLUME
174         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
175 #endif
176         
177         // user interface
178         void load_binary(int drv, const _TCHAR* file_path);
179         void save_binary(int drv, const _TCHAR* file_path);
180         void play_tape(const _TCHAR* file_path);
181         void rec_tape(const _TCHAR* file_path);
182         void close_tape();
183         bool is_tape_inserted();
184         bool is_frame_skippable();
185         
186         void update_config();
187         void save_state(FILEIO* state_fio);
188         bool load_state(FILEIO* state_fio);
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