OSDN Git Service

8471ed756fb277f8a051627b34b32a71b1fde3d4
[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_FLOPPY_DISK         2
31 #define USE_TAPE                1
32 #define TAPE_BINARY_ONLY
33 #define NOTIFY_KEY_DOWN
34 #define USE_ALT_F10_KEY
35 #define USE_AUTO_KEY            6
36 #define USE_AUTO_KEY_RELEASE    12
37 #define USE_AUTO_KEY_CAPS
38 #define DONT_KEEEP_KEY_PRESSED
39 #define USE_NOTIFY_POWER_OFF
40 #define USE_SOUND_VOLUME                2
41 #define USE_DEBUGGER
42 #define USE_STATE
43 #define USE_CPU_HD6301
44 #define USE_CPU_Z80
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 csp_state_utils;
56 class EMU;
57 class DEVICE;
58 class EVENT;
59
60 class BEEP;
61 class HD146818P;
62 class I8255;
63 //class MC6800;
64 class HD6301;
65 class TF20;
66 class UPD765A;
67 class Z80;
68 class Z80SIO;
69
70 class MEMORY;
71
72 class VM
73 {
74 protected:
75         EMU* emu;
76         csp_state_utils *state_entry;
77         
78         // devices
79         EVENT* event;
80         
81         BEEP* beep;
82         HD146818P* rtc;
83         //MC6800* cpu;
84         HD6301* cpu;
85         
86         TF20* tf20;
87         I8255* pio_tf20;
88         UPD765A* fdc_tf20;
89         Z80* cpu_tf20;
90         Z80SIO* sio_tf20;
91         
92         MEMORY* memory;
93         
94 public:
95         // ----------------------------------------
96         // initialize
97         // ----------------------------------------
98         
99         VM(EMU* parent_emu);
100         ~VM();
101         
102         // ----------------------------------------
103         // for emulation class
104         // ----------------------------------------
105         
106         // drive virtual machine
107         void reset();
108         void notify_power_off();
109         void run();
110         
111 #ifdef USE_DEBUGGER
112         // debugger
113         DEVICE *get_cpu(int index);
114 #endif
115         
116         // draw screen
117         void draw_screen();
118         
119         // sound generation
120         void initialize_sound(int rate, int samples);
121         uint16_t* create_sound(int* extra_frames);
122         int get_sound_buffer_ptr();
123 #ifdef USE_SOUND_VOLUME
124         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
125 #endif
126         
127         // notify key
128         void key_down(int code, bool repeat);
129         void key_up(int code);
130         
131         // user interface
132         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
133         void close_floppy_disk(int drv);
134         bool is_floppy_disk_inserted(int drv);
135         void is_floppy_disk_protected(int drv, bool value);
136         bool is_floppy_disk_protected(int drv);
137         uint32_t is_floppy_disk_accessed();
138         void play_tape(int drv, const _TCHAR* file_path);
139         void rec_tape(int drv, const _TCHAR* file_path);
140         void close_tape(int drv);
141         bool is_tape_inserted(int drv);
142         bool is_frame_skippable();
143         
144         void update_config();
145         void decl_state();
146         void save_state(FILEIO* state_fio);
147         bool load_state(FILEIO* state_fio);
148         
149         // ----------------------------------------
150         // for each device
151         // ----------------------------------------
152         
153         // devices
154         DEVICE* get_device(int id);
155         DEVICE* dummy;
156         DEVICE* first_device;
157         DEVICE* last_device;
158 };
159
160 #endif