OSDN Git Service

[General][WIP] Merge Upstream 2017-03-11.
[csp-qt/common_source_project-fm7.git] / source / src / vm / hc20 / hc20.h
1 /*
2         EPSON HC-20 Emulator 'eHC-20'
3
4         Author : Takeda.Toshiya
5         Date   : 2011.05.23-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _HC20_H_
11 #define _HC20_H_
12
13 #define DEVICE_NAME             "EPSON HC-20"
14 #define CONFIG_NAME             "hc20"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          72
18 #define LINES_PER_FRAME         64
19 #define CPU_CLOCKS              614400
20 #define SCREEN_WIDTH            120
21 #define SCREEN_HEIGHT           32
22 #define MAX_DRIVE               2
23 #define HAS_HD6301
24 #define HAS_UPD7201
25
26 // device informations for win32
27 #define WINDOW_MODE_BASE        3
28 #define USE_DIPSWITCH
29 #define DIPSWITCH_DEFAULT       0x0f
30 #define USE_FD1
31 #define USE_FD2
32 #define USE_TAPE
33 #define TAPE_BINARY_ONLY
34 #define NOTIFY_KEY_DOWN
35 #define USE_ALT_F10_KEY
36 #define USE_AUTO_KEY            6
37 #define USE_AUTO_KEY_RELEASE    12
38 #define USE_AUTO_KEY_CAPS
39 #define DONT_KEEEP_KEY_PRESSED
40 #define USE_NOTIFY_POWER_OFF
41 #define USE_ACCESS_LAMP
42 #define USE_SOUND_VOLUME                2
43 #define USE_DEBUGGER
44 #define USE_STATE
45
46 #include "../../common.h"
47 #include "../../fileio.h"
48
49 #ifdef USE_SOUND_VOLUME
50 static const _TCHAR *sound_device_caption[] = {
51         _T("Beep"), _T("Noise (FDD)"),
52 };
53 #endif
54
55 class EMU;
56 class DEVICE;
57 class EVENT;
58
59 class BEEP;
60 class HD146818P;
61 class I8255;
62 class MC6800;
63 class TF20;
64 class UPD765A;
65 class Z80;
66 class Z80SIO;
67
68 class MEMORY;
69
70 class VM
71 {
72 protected:
73         EMU* emu;
74         
75         // devices
76         EVENT* event;
77         
78         BEEP* beep;
79         HD146818P* rtc;
80         MC6800* cpu;
81         
82         TF20* tf20;
83         I8255* pio_tf20;
84         UPD765A* fdc_tf20;
85         Z80* cpu_tf20;
86         Z80SIO* sio_tf20;
87         
88         MEMORY* memory;
89         
90 public:
91         // ----------------------------------------
92         // initialize
93         // ----------------------------------------
94         
95         VM(EMU* parent_emu);
96         ~VM();
97         
98         // ----------------------------------------
99         // for emulation class
100         // ----------------------------------------
101         
102         // drive virtual machine
103         void reset();
104         void notify_power_off();
105         void run();
106         
107 #ifdef USE_DEBUGGER
108         // debugger
109         DEVICE *get_cpu(int index);
110 #endif
111         
112         // draw screen
113         void draw_screen();
114         uint32_t get_access_lamp_status();
115         
116         // sound generation
117         void initialize_sound(int rate, int samples);
118         uint16_t* create_sound(int* extra_frames);
119         int get_sound_buffer_ptr();
120 #ifdef USE_SOUND_VOLUME
121         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
122 #endif
123         
124         // notify key
125         void key_down(int code, bool repeat);
126         void key_up(int code);
127         
128         // user interface
129         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
130         void close_floppy_disk(int drv);
131         bool is_floppy_disk_inserted(int drv);
132         void is_floppy_disk_protected(int drv, bool value);
133         bool is_floppy_disk_protected(int drv);
134         void play_tape(const _TCHAR* file_path);
135         void rec_tape(const _TCHAR* file_path);
136         void close_tape();
137         bool is_tape_inserted();
138         bool is_frame_skippable();
139         
140         void update_config();
141         void save_state(FILEIO* state_fio);
142         bool load_state(FILEIO* state_fio);
143         
144         // ----------------------------------------
145         // for each device
146         // ----------------------------------------
147         
148         // devices
149         DEVICE* get_device(int id);
150         DEVICE* dummy;
151         DEVICE* first_device;
152         DEVICE* last_device;
153 };
154
155 #endif