OSDN Git Service

[VM][General][WIP] Apply new (Upstream 2016-02-21) APIs to VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / bmjr / bmjr.h
1 /*
2         HITACH BASIC Master Jr Emulator 'eBASICMasterJr'
3
4         Author : Takeda.Toshiya
5         Date   : 2015.08.28-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _BMJR_H_
11 #define _BMJR_H_
12
13 #define DEVICE_NAME             "HITACHI BASIC Master Jr"
14 #define CONFIG_NAME             "bmjr"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          60
18 #define LINES_PER_FRAME         262
19 #define CPU_CLOCKS              754560
20 #define SCREEN_WIDTH            256
21 #define SCREEN_HEIGHT           192
22 //#define HAS_MB8861
23 #define HAS_MC6800
24
25 // device informations for win32
26 #define USE_TAPE
27 #define USE_TAPE_BUTTON
28 #define NOTIFY_KEY_DOWN
29 #define USE_CRT_MONITOR_4_3 1
30 #define USE_ALT_F10_KEY
31 #define USE_AUTO_KEY            8
32 #define USE_AUTO_KEY_RELEASE    10
33 //#define USE_CRT_FILTER
34 //#define USE_SCANLINE
35 #define USE_SOUND_VOLUME        2
36 #define USE_DEBUGGER
37 #define USE_STATE
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"),
45 };
46 #endif
47
48 class EMU;
49 class DEVICE;
50 class EVENT;
51
52 class DATAREC;
53 class MC6800;
54 class MC6820;
55
56 class MEMORY;
57
58 class VM
59 {
60 protected:
61         EMU* emu;
62         
63         // devices
64         EVENT* event;
65         
66         DATAREC* drec;
67         MC6800* cpu;
68         MC6820* pia;
69         
70         MEMORY* memory;
71         
72 public:
73         // ----------------------------------------
74         // initialize
75         // ----------------------------------------
76         
77         VM(EMU* parent_emu);
78         ~VM();
79         
80         // ----------------------------------------
81         // for emulation class
82         // ----------------------------------------
83         
84         // drive virtual machine
85         void reset();
86         void special_reset();
87         void run();
88         double get_frame_rate();
89         
90 #ifdef USE_DEBUGGER
91         // debugger
92         DEVICE *get_cpu(int index);
93 #endif
94         
95         // draw screen
96         void draw_screen();
97 //      int get_access_lamp_status();
98         
99         // sound generation
100         void initialize_sound(int rate, int samples);
101         uint16* create_sound(int* extra_frames);
102         int get_sound_buffer_ptr();
103 #ifdef USE_SOUND_VOLUME
104         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
105 #endif
106         
107         // notify key
108         void key_down(int code, bool repeat);
109         void key_up(int code);
110         
111         // user interface
112         void play_tape(const _TCHAR* file_path);
113         void rec_tape(const _TCHAR* file_path);
114         void close_tape();
115         bool is_tape_inserted();
116         bool is_tape_playing();
117         bool is_tape_recording();
118         int get_tape_position();
119         void push_play();
120         void push_stop();
121         void push_fast_forward();
122         void push_fast_rewind();
123         void push_apss_forward() {}
124         void push_apss_rewind() {}
125         bool is_frame_skippable();
126         
127         void update_config();
128         void save_state(FILEIO* state_fio);
129         bool load_state(FILEIO* state_fio);
130         
131         // ----------------------------------------
132         // for each device
133         // ----------------------------------------
134         
135         // devices
136         DEVICE* get_device(int id);
137         DEVICE* dummy;
138         DEVICE* first_device;
139         DEVICE* last_device;
140 };
141
142 #endif