OSDN Git Service

[General] Merge upstream 2018-05-24. Still not test to build, will test.
[csp-qt/common_source_project-fm7.git] / source / src / vm / jr100 / jr100.h
1 /*
2         National JR-100 Emulator 'eJR-100'
3
4         Author : Takeda.Toshiya
5         Date   : 2015.08.27-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _JR100_H_
11 #define _JR100_H_
12
13 #define DEVICE_NAME             "National JR-100"
14 #define CONFIG_NAME             "jr100"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          60
18 #define LINES_PER_FRAME         262
19 #define CPU_CLOCKS              894886
20 #define SCREEN_WIDTH            256
21 #define SCREEN_HEIGHT           192
22 #define HAS_MB8861
23
24 // device informations for win32
25 #define USE_TAPE                1
26 #define USE_TAPE_BUTTON
27 #define USE_ALT_F10_KEY
28 #define USE_AUTO_KEY            8
29 #define USE_AUTO_KEY_RELEASE    10
30 #define USE_VM_AUTO_KEY_TABLE
31 //#define USE_SCREEN_FILTER
32 //#define USE_SCANLINE
33 #define USE_SOUND_VOLUME        3
34 #define USE_JOYSTICK
35 #define USE_DEBUGGER
36 #define USE_STATE
37 #define USE_CPU_MB8861
38
39 static const int vm_auto_key_table_base[][2] = {
40         // 0x100: shift
41         {0x2f,  0x100 | 0x4c},  // '/' => 'L' + SHIFT
42         {0x3f,  0x100 | 0x4b},  // '?' => 'K' + SHIFT
43         {0x40,  0x100 | 0x55},  // '@' => 'U' + SHIFT
44         {0x41,  0x000 | 0x41},  // 'A'
45         {0x42,  0x000 | 0x42},  // 'B'
46         {0x43,  0x000 | 0x43},  // 'C'
47         {0x44,  0x000 | 0x44},  // 'D'
48         {0x45,  0x000 | 0x45},  // 'E'
49         {0x46,  0x000 | 0x46},  // 'F'
50         {0x47,  0x000 | 0x47},  // 'G'
51         {0x48,  0x000 | 0x48},  // 'H'
52         {0x49,  0x000 | 0x49},  // 'I'
53         {0x4a,  0x000 | 0x4a},  // 'J'
54         {0x4b,  0x000 | 0x4b},  // 'K'
55         {0x4c,  0x000 | 0x4c},  // 'L'
56         {0x4d,  0x000 | 0x4d},  // 'M'
57         {0x4e,  0x000 | 0x4e},  // 'N'
58         {0x4f,  0x000 | 0x4f},  // 'O'
59         {0x50,  0x000 | 0x50},  // 'P'
60         {0x51,  0x000 | 0x51},  // 'Q'
61         {0x52,  0x000 | 0x52},  // 'R'
62         {0x53,  0x000 | 0x53},  // 'S'
63         {0x54,  0x000 | 0x54},  // 'T'
64         {0x55,  0x000 | 0x55},  // 'U'
65         {0x56,  0x000 | 0x56},  // 'V'
66         {0x57,  0x000 | 0x57},  // 'W'
67         {0x58,  0x000 | 0x58},  // 'X'
68         {0x59,  0x000 | 0x59},  // 'Y'
69         {0x5a,  0x000 | 0x5a},  // 'Z'
70         {0x5b,  0x100 | 0x4f},  // '[' => 'O' + SHIFT
71         {0x5c,  0x100 | 0x49},  // '\' => 'I' + SHIFT
72         {0x5d,  0x100 | 0x50},  // ']' => 'P' + SHIFT
73         {0x5e,  0x100 | 0x30},  // '^' => '0' + SHIFT
74         {0x5f,  0x100 | 0x4d},  // '_' => 'M' + SHIFT
75         {0x61,  0x000 | 0x41},  // 'a'
76         {0x62,  0x000 | 0x42},  // 'b'
77         {0x63,  0x000 | 0x43},  // 'c'
78         {0x64,  0x000 | 0x44},  // 'd'
79         {0x65,  0x000 | 0x45},  // 'e'
80         {0x66,  0x000 | 0x46},  // 'f'
81         {0x67,  0x000 | 0x47},  // 'g'
82         {0x68,  0x000 | 0x48},  // 'h'
83         {0x69,  0x000 | 0x49},  // 'i'
84         {0x6a,  0x000 | 0x4a},  // 'j'
85         {0x6b,  0x000 | 0x4b},  // 'k'
86         {0x6c,  0x000 | 0x4c},  // 'l'
87         {0x6d,  0x000 | 0x4d},  // 'm'
88         {0x6e,  0x000 | 0x4e},  // 'n'
89         {0x6f,  0x000 | 0x4f},  // 'o'
90         {0x70,  0x000 | 0x50},  // 'p'
91         {0x71,  0x000 | 0x51},  // 'q'
92         {0x72,  0x000 | 0x52},  // 'r'
93         {0x73,  0x000 | 0x53},  // 's'
94         {0x74,  0x000 | 0x54},  // 't'
95         {0x75,  0x000 | 0x55},  // 'u'
96         {0x76,  0x000 | 0x56},  // 'v'
97         {0x77,  0x000 | 0x57},  // 'w'
98         {0x78,  0x000 | 0x58},  // 'x'
99         {0x79,  0x000 | 0x59},  // 'y'
100         {0x7a,  0x000 | 0x5a},  // 'z'
101         {-1, -1},
102 };
103
104 #include "../../common.h"
105 #include "../../fileio.h"
106
107 #ifdef USE_SOUND_VOLUME
108 static const _TCHAR *sound_device_caption[] = {
109         _T("Beep"), _T("CMT (Signal)"), _T("Noise (CMT)"),
110 };
111 #endif
112
113 class EMU;
114 class DEVICE;
115 class EVENT;
116
117 class DATAREC;
118 //class MC6800;
119 class MB8861;
120 class NOT;
121 class PCM1BIT;
122 class SY6522;
123
124 class MEMORY;
125
126 class VM
127 {
128 protected:
129         EMU* emu;
130         
131         // devices
132         EVENT* event;
133         
134         DATAREC* drec;
135         //MC6800* cpu;
136         MB8861* cpu;
137         NOT* not_mic;
138         NOT* not_ear;
139         PCM1BIT* pcm;
140         SY6522* via;
141         
142         MEMORY* memory;
143         
144 public:
145         // ----------------------------------------
146         // initialize
147         // ----------------------------------------
148         
149         VM(EMU* parent_emu);
150         ~VM();
151         
152         // ----------------------------------------
153         // for emulation class
154         // ----------------------------------------
155         
156         // drive virtual machine
157         void reset();
158         void special_reset();
159         void run();
160         double get_frame_rate();
161         
162 #ifdef USE_DEBUGGER
163         // debugger
164         DEVICE *get_cpu(int index);
165 #endif
166         
167         // draw screen
168         void draw_screen();
169         
170         // sound generation
171         void initialize_sound(int rate, int samples);
172         uint16_t* create_sound(int* extra_frames);
173         int get_sound_buffer_ptr();
174 #ifdef USE_SOUND_VOLUME
175         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
176 #endif
177         
178         // notify key
179         void key_down(int code, bool repeat);
180         void key_up(int code);
181         
182         // user interface
183         void play_tape(int drv, const _TCHAR* file_path);
184         void rec_tape(int drv, const _TCHAR* file_path);
185         void close_tape(int drv);
186         bool is_tape_inserted(int drv);
187         bool is_tape_playing(int drv);
188         bool is_tape_recording(int drv);
189         int get_tape_position(int drv);
190         const _TCHAR* get_tape_message(int drv);
191         void push_play(int drv);
192         void push_stop(int drv);
193         void push_fast_forward(int drv);
194         void push_fast_rewind(int drv);
195         void push_apss_forward(int drv) {}
196         void push_apss_rewind(int drv) {}
197         bool is_frame_skippable();
198         
199         void update_config();
200         void save_state(FILEIO* state_fio);
201         bool load_state(FILEIO* state_fio);
202         
203         // ----------------------------------------
204         // for each device
205         // ----------------------------------------
206         
207         // devices
208         DEVICE* get_device(int id);
209         DEVICE* dummy;
210         DEVICE* first_device;
211         DEVICE* last_device;
212 };
213
214 #endif