OSDN Git Service

Merge branch 'master' of github.com:Artanejp/common_source_project-fm7
[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_FLOPPY_DISK         4
28 #define USE_TAPE                1
29 #define USE_TAPE_BUTTON
30 #define NOTIFY_KEY_DOWN
31 #define USE_ALT_F10_KEY
32 #define USE_AUTO_KEY                    6
33 #define USE_AUTO_KEY_RELEASE    10
34 #define USE_SOUND_VOLUME                3
35 #define USE_DEBUGGER
36 #define USE_STATE
37 #define USE_CPU_Z80
38
39 #include "../../common.h"
40 #include "../../fileio.h"
41
42 #ifdef USE_SOUND_VOLUME
43 static const _TCHAR *sound_device_caption[] = {
44         _T("Beep"), _T("CMT (Signal)"), _T("Noise (CMT)"),
45 };
46 #endif
47
48 class csp_state_utils;
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         csp_state_utils *state_entry;
66         
67         // devices
68         EVENT* event;
69         
70         BEEP* beep;
71         DATAREC* drec;
72         PTF20* tf20;
73         Z80* cpu;
74         
75         IO* io;
76         MEMORY* memory;
77         
78 public:
79         // ----------------------------------------
80         // initialize
81         // ----------------------------------------
82         
83         VM(EMU* parent_emu);
84         ~VM();
85         
86         // ----------------------------------------
87         // for emulation class
88         // ----------------------------------------
89         
90         // drive virtual machine
91         void reset();
92         void special_reset();
93         void run();
94         
95 #ifdef USE_DEBUGGER
96         // debugger
97         DEVICE *get_cpu(int index);
98 #endif
99         
100         // draw screen
101         void draw_screen();
102         
103         // sound generation
104         void initialize_sound(int rate, int samples);
105         uint16_t* create_sound(int* extra_frames);
106         int get_sound_buffer_ptr();
107 #ifdef USE_SOUND_VOLUME
108         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
109 #endif
110         
111         // notify key
112         void key_down(int code, bool repeat);
113         void key_up(int code);
114         
115         // user interface
116         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
117         void close_floppy_disk(int drv);
118         bool is_floppy_disk_inserted(int drv);
119         void is_floppy_disk_protected(int drv, bool value);
120         bool is_floppy_disk_protected(int drv);
121         uint32_t is_floppy_disk_accessed();
122         void play_tape(int drv, const _TCHAR* file_path);
123         void rec_tape(int drv, const _TCHAR* file_path);
124         void close_tape(int drv);
125         bool is_tape_inserted(int drv);
126         bool is_tape_playing(int drv);
127         bool is_tape_recording(int drv);
128         int get_tape_position(int drv);
129         const _TCHAR* get_tape_message(int drv);
130         void push_play(int drv);
131         void push_stop(int drv);
132         void push_fast_forward(int drv);
133         void push_fast_rewind(int drv);
134         void push_apss_forward(int drv) {}
135         void push_apss_rewind(int drv) {}
136         bool is_frame_skippable();
137         
138         void update_config();
139         void decl_state();
140         void save_state(FILEIO* state_fio);
141         bool load_state(FILEIO* state_fio);
142         
143         // ----------------------------------------
144         // for each device
145         // ----------------------------------------
146         
147         // devices
148         DEVICE* get_device(int id);
149         DEVICE* dummy;
150         DEVICE* first_device;
151         DEVICE* last_device;
152 };
153
154 #endif