OSDN Git Service

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