OSDN Git Service

19b4c0e2e9faffa15db302131b909b0799c85e44
[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_FILES                 1
43 #define USE_SOUND_FILES_FDD
44 #if defined(USE_SOUND_FILES)
45 #define USE_SOUND_VOLUME                2
46 #else
47 #define USE_SOUND_VOLUME                1
48 #endif
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 #if defined(USE_SOUND_FILES)
59         _T("FDD Seek"),
60 #endif
61 };
62 #endif
63
64 class EMU;
65 class DEVICE;
66 class EVENT;
67
68 class BEEP;
69 class HD146818P;
70 class I8255;
71 class MC6800;
72 class TF20;
73 class UPD765A;
74 class Z80;
75 class Z80SIO;
76
77 class MEMORY;
78
79 class VM
80 {
81 protected:
82         EMU* emu;
83         
84         // devices
85         EVENT* event;
86         
87         BEEP* beep;
88         HD146818P* rtc;
89         MC6800* cpu;
90         
91         TF20* tf20;
92         I8255* pio_tf20;
93         UPD765A* fdc_tf20;
94         Z80* cpu_tf20;
95         Z80SIO* sio_tf20;
96         
97         MEMORY* memory;
98         
99 public:
100         // ----------------------------------------
101         // initialize
102         // ----------------------------------------
103         
104         VM(EMU* parent_emu);
105         ~VM();
106         
107         // ----------------------------------------
108         // for emulation class
109         // ----------------------------------------
110         
111         // drive virtual machine
112         void reset();
113         void notify_power_off();
114         void run();
115         
116 #ifdef USE_DEBUGGER
117         // debugger
118         DEVICE *get_cpu(int index);
119 #endif
120         
121         // draw screen
122         void draw_screen();
123         uint32_t get_access_lamp_status();
124         
125         // sound generation
126         void initialize_sound(int rate, int samples);
127         uint16_t* create_sound(int* extra_frames);
128         int get_sound_buffer_ptr();
129 #ifdef USE_SOUND_VOLUME
130         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
131 #endif
132         
133         // notify key
134         void key_down(int code, bool repeat);
135         void key_up(int code);
136         
137         // user interface
138         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
139         void close_floppy_disk(int drv);
140         bool is_floppy_disk_inserted(int drv);
141         void is_floppy_disk_protected(int drv, bool value);
142         bool is_floppy_disk_protected(int drv);
143         void play_tape(const _TCHAR* file_path);
144         void rec_tape(const _TCHAR* file_path);
145         void close_tape();
146         bool is_tape_inserted();
147         bool is_frame_skippable();
148         
149         void update_config();
150         void save_state(FILEIO* state_fio);
151         bool load_state(FILEIO* state_fio);
152         
153         // ----------------------------------------
154         // for each device
155         // ----------------------------------------
156         
157         // devices
158         DEVICE* get_device(int id);
159         DEVICE* dummy;
160         DEVICE* first_device;
161         DEVICE* last_device;
162 };
163
164 #endif