OSDN Git Service

8ceb86b4a973d5490b1ba5f7fcdd456428ceaf8e
[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 SUPPORT_TV_RENDER
27 #define USE_TAPE                        1
28 #define USE_TAPE_BUTTON
29 #define NOTIFY_KEY_DOWN
30 #define USE_ALT_F10_KEY
31 #define USE_AUTO_KEY            8
32 #define USE_AUTO_KEY_RELEASE    10
33 //#define USE_SCREEN_FILTER
34 //#define USE_SCANLINE
35 #define USE_SOUND_VOLUME        3
36 #define USE_DEBUGGER
37 #define USE_STATE
38 #define USE_CPU_MC6800
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 csp_state_utils;
50
51 class EMU;
52 class DEVICE;
53 class EVENT;
54
55 class DATAREC;
56 class MC6800;
57 class MC6820;
58
59 class MEMORY;
60
61 class VM
62 {
63 protected:
64         EMU* emu;
65         csp_state_utils *state_entry;
66         // devices
67         EVENT* event;
68         
69         DATAREC* drec;
70         MC6800* cpu;
71         MC6820* pia;
72         
73         MEMORY* memory;
74         
75 public:
76         // ----------------------------------------
77         // initialize
78         // ----------------------------------------
79         
80         VM(EMU* parent_emu);
81         ~VM();
82         
83         // ----------------------------------------
84         // for emulation class
85         // ----------------------------------------
86         
87         // drive virtual machine
88         void reset();
89         void special_reset();
90         void run();
91         double get_frame_rate();
92         
93 #ifdef USE_DEBUGGER
94         // debugger
95         DEVICE *get_cpu(int index);
96 #endif
97         
98         // draw screen
99         void draw_screen();
100         
101         // sound generation
102         void initialize_sound(int rate, int samples);
103         uint16_t* create_sound(int* extra_frames);
104         int get_sound_buffer_ptr();
105 #ifdef USE_SOUND_VOLUME
106         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
107 #endif
108         
109         // notify key
110         void key_down(int code, bool repeat);
111         void key_up(int code);
112         
113         // user interface
114         void play_tape(int drv, const _TCHAR* file_path);
115         void rec_tape(int drv, const _TCHAR* file_path);
116         void close_tape(int drv);
117         bool is_tape_inserted(int drv);
118         bool is_tape_playing(int drv);
119         bool is_tape_recording(int drv);
120         int get_tape_position(int drv);
121         const _TCHAR* get_tape_message(int drv);
122         void push_play(int drv);
123         void push_stop(int drv);
124         void push_fast_forward(int drv);
125         void push_fast_rewind(int drv);
126         void push_apss_forward(int drv) {}
127         void push_apss_rewind(int drv) {}
128         bool is_frame_skippable();
129         
130         void update_config();
131         void decl_state();
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