OSDN Git Service

[VM][I286] Save cpustate without StateBuffer().
[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 #include "../vm_template.h"
107
108 #ifdef USE_SOUND_VOLUME
109 static const _TCHAR *sound_device_caption[] = {
110         _T("Beep"), _T("CMT (Signal)"), _T("Noise (CMT)"),
111 };
112 #endif
113
114 class EMU;
115 class DEVICE;
116 class EVENT;
117
118 class DATAREC;
119 //class MC6800;
120 class MB8861;
121 class NOT;
122 class PCM1BIT;
123 class SY6522;
124
125 class JR100_MEMORY;
126
127 class VM : public VM_TEMPLATE
128 {
129 protected:
130         //EMU* emu;
131         
132         // devices
133         //EVENT* event;
134         
135         DATAREC* drec;
136         //MC6800* cpu;
137         MB8861* cpu;
138         NOT* not_mic;
139         NOT* not_ear;
140         PCM1BIT* pcm;
141         SY6522* via;
142         
143         JR100_MEMORY* memory;
144         
145 public:
146         // ----------------------------------------
147         // initialize
148         // ----------------------------------------
149         
150         VM(EMU* parent_emu);
151         ~VM();
152         
153         // ----------------------------------------
154         // for emulation class
155         // ----------------------------------------
156         
157         // drive virtual machine
158         void reset();
159         void special_reset();
160         void run();
161         double get_frame_rate();
162         
163 #ifdef USE_DEBUGGER
164         // debugger
165         DEVICE *get_cpu(int index);
166 #endif
167         
168         // draw screen
169         void draw_screen();
170         
171         // sound generation
172         void initialize_sound(int rate, int samples);
173         uint16_t* create_sound(int* extra_frames);
174         int get_sound_buffer_ptr();
175 #ifdef USE_SOUND_VOLUME
176         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
177 #endif
178         
179         // notify key
180         void key_down(int code, bool repeat) { }
181         void key_up(int code) { }
182         
183         // user interface
184         void play_tape(int drv, const _TCHAR* file_path);
185         void rec_tape(int drv, const _TCHAR* file_path);
186         void close_tape(int drv);
187         bool is_tape_inserted(int drv);
188         bool is_tape_playing(int drv);
189         bool is_tape_recording(int drv);
190         int get_tape_position(int drv);
191         const _TCHAR* get_tape_message(int drv);
192         void push_play(int drv);
193         void push_stop(int drv);
194         void push_fast_forward(int drv);
195         void push_fast_rewind(int drv);
196         void push_apss_forward(int drv) {}
197         void push_apss_rewind(int drv) {}
198         bool is_frame_skippable();
199         
200         void update_config();
201         bool process_state(FILEIO* state_fio, bool loading);
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