OSDN Git Service

[VM] TRY:Use namespace {VMNAME} to separate around VMs. This feature still apply...
[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                1
42 #define TAPE_BINARY_ONLY
43 #define USE_BINARY_FILE         1
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_MONITOR_TYPE        2
49 #define USE_SOUND_VOLUME        1
50 #define USE_DEBUGGER
51 #define USE_STATE
52 #define USE_CPU_I8080
53
54 #include "../../common.h"
55 #include "../../fileio.h"
56 #include "../vm_template.h"
57
58 #ifdef USE_SOUND_VOLUME
59 static const _TCHAR *sound_device_caption[] = {
60         _T("Beep"),
61 };
62 #endif
63
64 #define LED_WIDTH       26
65 #define LED_HEIGHT      51
66
67 const struct {
68         int x, y;
69         int width, height;
70         int code;
71 } vm_buttons[] = {
72         // virtual key codes 0x80-0x8f and 0x98-0x9f are not used in pc keyboard
73         {763 + 36 * 0, 478 + 34 * 4, 30, 21, 0x80}, // 0
74         {763 + 36 * 1, 478 + 34 * 4, 30, 21, 0x81}, // 1
75         {763 + 36 * 2, 478 + 34 * 4, 30, 21, 0x82}, // 2
76         {763 + 36 * 3, 478 + 34 * 4, 30, 21, 0x83}, // 3
77         {763 + 36 * 0, 478 + 34 * 3, 30, 21, 0x84}, // 4
78         {763 + 36 * 1, 478 + 34 * 3, 30, 21, 0x85}, // 5
79         {763 + 36 * 2, 478 + 34 * 3, 30, 21, 0x86}, // 6
80         {763 + 36 * 3, 478 + 34 * 3, 30, 21, 0x87}, // 7
81         {763 + 36 * 0, 478 + 34 * 2, 30, 21, 0x88}, // 8
82         {763 + 36 * 1, 478 + 34 * 2, 30, 21, 0x89}, // 9
83         {763 + 36 * 2, 478 + 34 * 2, 30, 21, 0x8a}, // A
84         {763 + 36 * 3, 478 + 34 * 2, 30, 21, 0x8b}, // B
85         {763 + 36 * 0, 478 + 34 * 1, 30, 21, 0x8c}, // C
86         {763 + 36 * 1, 478 + 34 * 1, 30, 21, 0x8d}, // D
87         {763 + 36 * 2, 478 + 34 * 1, 30, 21, 0x8e}, // E
88         {763 + 36 * 3, 478 + 34 * 1, 30, 21, 0x8f}, // F
89         {763 + 36 * 0, 478 + 34 * 0, 30, 21, 0x98}, // RET
90         {763 + 36 * 1, 478 + 34 * 0, 30, 21, 0x99}, // RUN
91         {763 + 36 * 2, 478 + 34 * 0, 30, 21, 0x9a}, // SDA
92         {763 + 36 * 3, 478 + 34 * 0, 30, 21, 0x9b}, // LDA
93         {763 + 36 * 4, 478 + 34 * 0, 30, 21, 0x00}, // RST
94         {763 + 36 * 4, 478 + 34 * 1, 30, 21, 0x9c}, // ADR
95         {763 + 36 * 4, 478 + 34 * 2, 30, 21, 0x9d}, // RIC
96         {763 + 36 * 4, 478 + 34 * 3, 30, 21, 0x9e}, // RDC
97         {763 + 36 * 4, 478 + 34 * 4, 30, 21, 0x9f}, // WIC
98 };
99 const struct {
100         int x, y;
101         int width, height;
102 } vm_ranges[] = {
103         {668 + 33 * 0, 295, LED_WIDTH, LED_HEIGHT}, // 7-seg LEDs
104         {668 + 33 * 1, 295, LED_WIDTH, LED_HEIGHT},
105         {668 + 33 * 2, 295, LED_WIDTH, LED_HEIGHT},
106         {668 + 33 * 3, 295, LED_WIDTH, LED_HEIGHT},
107         {828 + 33 * 0, 295, LED_WIDTH, LED_HEIGHT},
108         {828 + 33 * 1, 295, LED_WIDTH, LED_HEIGHT},
109         {828 + 33 * 2, 295, LED_WIDTH, LED_HEIGHT},
110         {828 + 33 * 3, 295, LED_WIDTH, LED_HEIGHT},
111         {8, 8, 8 * 6 * 12, 8 * 2 * 29}, // CRT
112 };
113
114 //class csp_state_utils;
115 class EMU;
116 class DEVICE;
117 class EVENT;
118
119 class I8251;
120 class I8255;
121 class IO;
122 class PCM1BIT;
123 class I8080;
124
125 namespace EX80 {
126         class CMT;
127         class DISPLAY;
128         class KEYBOARD;
129         class MEMORY;
130 }
131
132 class VM : public VM_TEMPLATE
133 {
134 protected:
135         //EMU* emu;
136         //csp_state_utils *state_entry;
137         // devices
138         //EVENT* event;
139         
140         I8251* sio;
141         I8255* pio;
142         IO* io;
143         PCM1BIT* pcm;
144         I8080* cpu;
145         
146         EX80::CMT* cmt;
147         EX80::DISPLAY* display;
148         EX80::KEYBOARD* keyboard;
149         EX80::MEMORY* memory;
150         
151 public:
152         // ----------------------------------------
153         // initialize
154         // ----------------------------------------
155         
156         VM(EMU* parent_emu);
157         ~VM();
158         
159         // ----------------------------------------
160         // for emulation class
161         // ----------------------------------------
162         
163         // drive virtual machine
164         void reset();
165         void run();
166         
167 #ifdef USE_DEBUGGER
168         // debugger
169         DEVICE *get_cpu(int index);
170 #endif
171         
172         // draw screen
173         void draw_screen();
174         int max_draw_ranges();
175         
176         // sound generation
177         void initialize_sound(int rate, int samples);
178         uint16_t* create_sound(int* extra_frames);
179         int get_sound_buffer_ptr();
180 #ifdef USE_SOUND_VOLUME
181         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
182 #endif
183         
184         // user interface
185         void load_binary(int drv, const _TCHAR* file_path);
186         void save_binary(int drv, const _TCHAR* file_path);
187         void play_tape(int drv, const _TCHAR* file_path);
188         void rec_tape(int drv, const _TCHAR* file_path);
189         void close_tape(int drv);
190         bool is_tape_inserted(int drv);
191         bool is_frame_skippable();
192         
193         void update_config();
194         bool process_state(FILEIO* state_fio, bool loading);
195         
196         // ----------------------------------------
197         // for each device
198         // ----------------------------------------
199         
200         // devices
201         DEVICE* get_device(int id);
202         //DEVICE* dummy;
203         //DEVICE* first_device;
204         //DEVICE* last_device;
205 };
206
207 #endif