1 #include <stdlib.h>
2 #include <string.h>
3
4 #include "quasi88.h"
5 #include "keyboard.h"
6 #include "romaji.h"
7 #include "event.h"
8
9 #include "soundbd.h" /* sound_reg[] */
10 #include "graph.h" /* set_key_and_mouse() */
11 #include "pc88cpu.h" /* z80main_cpu */
12 #include "intr.h" /* state_of_cpu */
13
14 #include "snddrv.h" /* xmame_XXX */
15 #include "wait.h" /* wait_rate */
16 #include "pc88main.h" /* boot_clock_4mhz */
17
18 #include "drive.h"
19
20 #include "emu.h"
21 #include "status.h"
22 #include "pause.h"
23 #include "menu.h"
24 #include "screen.h"
25 #include "snapshot.h"
26
27 #include "suspend.h"
28
29 /******************************************************************************
30 *
31 *****************************************************************************/
32
33 /*
34 * �������� (���ơ��ȥ���������?)
35 */
36
37 int mouse_x; /* ���ߤ� �ޥ��� x��ɸ */
38 int mouse_y; /* ���ߤ� �ޥ��� y��ɸ */
39
40 static int mouse_dx; /* �ޥ��� x������ư�� */
41 static int mouse_dy; /* �ޥ��� y������ư�� */
42
43 static int mouse_sx; /* ���ꥢ��ޥ��� x������ư�� */
44 static int mouse_sy; /* ���ꥢ��ޥ��� y������ư�� */
45 static int mouse_sb; /* ���ꥢ��ޥ��� �ܥ��� */
46
47
48 unsigned char key_scan[ 0x10 ]; /* IN(00h)��(0Eh) ����������� */
49 /* key_scan[0]��[14] ���� */
50 /* I/O�ݡ��� 00H��0EH �������� */
51 /* key_scan[15] �ϡ����祤 */
52 /* ���ƥ��å��ΰ������˻��� */
53
54 static int key_func[ KEY88_END ]; /* ���������إ�����,��ǽ���� */
55
56
57 /*
58 * PC88���� / ��������
59 */
60
61 static int jop1_step; /* ����I/O�ݡ��ȤΥ�ɥ��ƥå� */
62 static int jop1_dx; /* ����I/O�ݡ��Ȥ��� (�ޥ��� x�����Ѱ�) */
63 static int jop1_dy; /* ����I/O�ݡ��Ȥ��� (�ޥ��� y�����Ѱ�) */
64 static int jop1_time; /* ����I/O�ݡ��ȤΥ��ȥ��ֽ��������� */
65
66 int romaji_input_mode = FALSE; /* ��:���������� */
67
68
69
70 /*
71 mouse_x, mouse_dx, jop1_dx �δط�
72 �ޥ�������ư������
73 mouse_x �ˤ������к�ɸ�åȤ��롣
74 �����ɸ�Ȥ��Ѱ� mouse_dx �˥��åȤ��롣
75 ����I/O�ݡ��Ȥ���ޥ�����ɸ���ɤ�������
76 mouse_dx ��åԥ����ͤ� jop1_dx �˥��åȤ��롣
77 */
78
79
80
81 /*
82 * ����
83 */
84
85 int mouse_mode = 0; /* �ޥ��������祤���ƥå����� */
86
87 int mouse_sensitivity = 100; /* �ޥ������� */
88 int mouse_swap_button = FALSE; /* �ޥ����ܥ���������ؤ��� */
89
90
91 int mouse_key_mode = 0; /* �ޥ������Ϥ���ȿ�� */
92 int mouse_key_assign[6]; /* 0:�ʤ� 1:�ƥ� 2:Ǥ�� */
93 static const int mouse_key_assign_tenkey[6] =
94 {
95 KEY88_KP_8, KEY88_KP_2, KEY88_KP_4, KEY88_KP_6,
96 KEY88_x, KEY88_z,
97 };
98
99
100 int joy_key_mode = 0; /* ���祤���Ϥ���ȿ�� */
101 int joy_key_assign[12]; /* 0:�ʤ� 1:�ƥ� 2:Ǥ�� */
102 static const int joy_key_assign_tenkey[12] =
103 {
104 KEY88_KP_8, KEY88_KP_2, KEY88_KP_4, KEY88_KP_6,
105 KEY88_x, KEY88_z, 0, 0, 0, 0, 0, 0,
106 };
107 int joy_swap_button = FALSE; /* �ܥ����AB�������ؤ��� */
108
109
110 int joy2_key_mode = 0; /* ���祤�����Ϥ���ȿ�� */
111 int joy2_key_assign[12]; /* 0:�ʤ� 1:�ƥ� 2:Ǥ�� */
112 int joy2_swap_button = FALSE; /* �ܥ����AB�������ؤ��� */
113
114
115
116 int cursor_key_mode = 0; /* �������륭�����̥�����ȿ�� */
117 int cursor_key_assign[4]; /* 0:�ʤ� 1:�ƥ� 2:Ǥ�� */
118 static const int cursor_key_assign_tenkey[4] =
119 {
120 KEY88_KP_8, KEY88_KP_2, KEY88_KP_4, KEY88_KP_6,
121 }; /* Cursor KEY -> 10 KEY , original by funa. (thanks!) */
122 /* Cursor Key -> Ǥ�դΥ��� , original by floi. (thanks!) */
123
124
125
126 int tenkey_emu = FALSE; /* ��:����������ƥ��� */
127 int numlock_emu = FALSE; /* ��:���եȥ�����NumLock��Ԥ� */
128
129
130
131
132 int function_f[ 1 + 20 ] = /* �ե�������ε�ǽ */
133 {
134 FN_FUNC, /* [0] �ϥ��ߡ� */
135 FN_FUNC, FN_FUNC, FN_FUNC, FN_FUNC, FN_FUNC, /* f1 ��f5 */
136 FN_FUNC, FN_FUNC, FN_FUNC, FN_FUNC, FN_FUNC, /* f6 ��f10 */
137 FN_STATUS, FN_MENU, FN_FUNC, FN_FUNC, FN_FUNC, /* f11��f15 */
138 FN_FUNC, FN_FUNC, FN_FUNC, FN_FUNC, FN_FUNC, /* f16��f20 */
139 };
140
141
142 int fn_max_speed = 1600;
143 double fn_max_clock = CONST_4MHZ_CLOCK*16;
144 int fn_max_boost = 16;
145
146
147 int romaji_type = 0; /* �����Ѵ��Υ����� */
148
149
150
151
152
153 /*
154 * ������� ��Ͽ������
155 */
156
157 char *file_rec = NULL; /* �������ϵ�Ͽ�Υե�����̾ */
158 char *file_pb = NULL; /* �������Ϻ����Υե�����̾ */
159
160 static OSD_FILE *fp_rec;
161 static OSD_FILE *fp_pb;
162
163 static struct { /* �������ϵ�Ͽ��¤�� */
164 Uchar key[16]; /* I/O 00H��0FH */
165 char dx_h; /* �ޥ��� dx ��� */
166 Uchar dx_l; /* �ޥ��� dx ���� */
167 char dy_h; /* �ޥ��� dy ��� */
168 Uchar dy_l; /* �ޥ��� dy ���� */
169 char image[2]; /* �����No -1��,0Ʊ,1�� */
170 char resv[2];
171 } key_record; /* 24 bytes */
172
173
174
175
176
177 /*---------------------------------------------------------------------------
178 * ���������� �� I/O �ݡ��Ȥ��б�
179 *---------------------------------------------------------------------------*/
180
181 #define Port0 0x00
182 #define Port1 0x01
183 #define Port2 0x02
184 #define Port3 0x03
185 #define Port4 0x04
186 #define Port5 0x05
187 #define Port6 0x06
188 #define Port7 0x07
189 #define Port8 0x08
190 #define Port9 0x09
191 #define PortA 0x0a
192 #define PortB 0x0b
193 #define PortC 0x0c
194 #define PortD 0x0d
195 #define PortE 0x0e
196 #define PortX 0x0f
197
198 #define Bit0 0x01
199 #define Bit1 0x02
200 #define Bit2 0x04
201 #define Bit3 0x08
202 #define Bit4 0x10
203 #define Bit5 0x20
204 #define Bit6 0x40
205 #define Bit7 0x80
206
207 #define PadA Bit4
208 #define PadB Bit5
209
210 #define PadU Bit0
211 #define PadD Bit1
212 #define PadL Bit2
213 #define PadR Bit3
214
215
216 enum {
217 /* �������������̾��� */
218
219 KEY88_EXT_F6 = KEY88_END + 0,
220 KEY88_EXT_F7 = KEY88_END + 1,
221 KEY88_EXT_F8 = KEY88_END + 2,
222 KEY88_EXT_F9 = KEY88_END + 3,
223 KEY88_EXT_F10 = KEY88_END + 4,
224 KEY88_EXT_BS = KEY88_END + 5,
225 KEY88_EXT_INS = KEY88_END + 6,
226 KEY88_EXT_DEL = KEY88_END + 7,
227 KEY88_EXT_HENKAN = KEY88_END + 8,
228 KEY88_EXT_KETTEI = KEY88_END + 9,
229 KEY88_EXT_PC = KEY88_END + 10,
230 KEY88_EXT_ZENKAKU = KEY88_END + 11,
231 KEY88_EXT_RETURNL = KEY88_END + 12,
232 KEY88_EXT_RETURNR = KEY88_END + 13,
233 KEY88_EXT_SHIFTL = KEY88_END + 14,
234 KEY88_EXT_SHIFTR = KEY88_END + 15,
235
236 KEY88_EXT_END = KEY88_END + 16
237 };
238
239
240 typedef struct {
241 unsigned char port;
242 unsigned char mask;
243 } T_KEYPORT;
244
245 static const T_KEYPORT keyport[ KEY88_EXT_END ] =
246 {
247 { 0,0 }, /* KEY88_INVALID = 0, */
248
249 { 0,0 },{ 0,0 },{ 0,0 },
250 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
251 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
252 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
253 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
254 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
255 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
256 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
257
258 { Port9, Bit6 }, /* KEY88_SPACE = 32, */
259 { Port6, Bit1 }, /* KEY88_EXCLAM = 33, */
260 { Port6, Bit2 }, /* KEY88_QUOTEDBL = 34, */
261 { Port6, Bit3 }, /* KEY88_NUMBERSIGN = 35, */
262 { Port6, Bit4 }, /* KEY88_DOLLAR = 36, */
263 { Port6, Bit5 }, /* KEY88_PERCENT = 37, */
264 { Port6, Bit6 }, /* KEY88_AMPERSAND = 38, */
265 { Port6, Bit7 }, /* KEY88_APOSTROPHE = 39, */
266 { Port7, Bit0 }, /* KEY88_PARENLEFT = 40, */
267 { Port7, Bit1 }, /* KEY88_PARENRIGHT = 41, */
268 { Port7, Bit2 }, /* KEY88_ASTERISK = 42, */
269 { Port7, Bit3 }, /* KEY88_PLUS = 43, */
270 { Port7, Bit4 }, /* KEY88_COMMA = 44, */
271 { Port5, Bit7 }, /* KEY88_MINUS = 45, */
272 { Port7, Bit5 }, /* KEY88_PERIOD = 46, */
273 { Port7, Bit6 }, /* KEY88_SLASH = 47, */
274 { Port6, Bit0 }, /* KEY88_0 = 48, */
275 { Port6, Bit1 }, /* KEY88_1 = 49, */
276 { Port6, Bit2 }, /* KEY88_2 = 50, */
277 { Port6, Bit3 }, /* KEY88_3 = 51, */
278 { Port6, Bit4 }, /* KEY88_4 = 52, */
279 { Port6, Bit5 }, /* KEY88_5 = 53, */
280 { Port6, Bit6 }, /* KEY88_6 = 54, */
281 { Port6, Bit7 }, /* KEY88_7 = 55, */
282 { Port7, Bit0 }, /* KEY88_8 = 56, */
283 { Port7, Bit1 }, /* KEY88_9 = 57, */
284 { Port7, Bit2 }, /* KEY88_COLON = 58, */
285 { Port7, Bit3 }, /* KEY88_SEMICOLON = 59, */
286 { Port7, Bit4 }, /* KEY88_LESS = 60, */
287 { Port5, Bit7 }, /* KEY88_EQUAL = 61, */
288 { Port7, Bit5 }, /* KEY88_GREATER = 62, */
289 { Port7, Bit6 }, /* KEY88_QUESTION = 63, */
290 { Port2, Bit0 }, /* KEY88_AT = 64, */
291 { Port2, Bit1 }, /* KEY88_A = 65, */
292 { Port2, Bit2 }, /* KEY88_B = 66, */
293 { Port2, Bit3 }, /* KEY88_C = 67, */
294 { Port2, Bit4 }, /* KEY88_D = 68, */
295 { Port2, Bit5 }, /* KEY88_E = 69, */
296 { Port2, Bit6 }, /* KEY88_F = 70, */
297 { Port2, Bit7 }, /* KEY88_G = 71, */
298 { Port3, Bit0 }, /* KEY88_H = 72, */
299 { Port3, Bit1 }, /* KEY88_I = 73, */
300 { Port3, Bit2 }, /* KEY88_J = 74, */
301 { Port3, Bit3 }, /* KEY88_K = 75, */
302 { Port3, Bit4 }, /* KEY88_L = 76, */
303 { Port3, Bit5 }, /* KEY88_M = 77, */
304 { Port3, Bit6 }, /* KEY88_N = 78, */
305 { Port3, Bit7 }, /* KEY88_O = 79, */
306 { Port4, Bit0 }, /* KEY88_P = 80, */
307 { Port4, Bit1 }, /* KEY88_Q = 81, */
308 { Port4, Bit2 }, /* KEY88_R = 82, */
309 { Port4, Bit3 }, /* KEY88_S = 83, */
310 { Port4, Bit4 }, /* KEY88_T = 84, */
311 { Port4, Bit5 }, /* KEY88_U = 85, */
312 { Port4, Bit6 }, /* KEY88_V = 86, */
313 { Port4, Bit7 }, /* KEY88_W = 87, */
314 { Port5, Bit0 }, /* KEY88_X = 88, */
315 { Port5, Bit1 }, /* KEY88_Y = 89, */
316 { Port5, Bit2 }, /* KEY88_Z = 90, */
317 { Port5, Bit3 }, /* KEY88_BRACKETLEFT = 91, */
318 { Port5, Bit4 }, /* KEY88_YEN = 92, */
319 { Port5, Bit5 }, /* KEY88_BRACKETRIGHT = 93, */
320 { Port5, Bit6 }, /* KEY88_CARET = 94, */
321 { Port7, Bit7 }, /* KEY88_UNDERSCORE = 95, */
322 { Port2, Bit0 }, /* KEY88_BACKQUOTE = 96, */
323 { Port2, Bit1 }, /* KEY88_a = 97, */
324 { Port2, Bit2 }, /* KEY88_b = 98, */
325 { Port2, Bit3 }, /* KEY88_c = 99, */
326 { Port2, Bit4 }, /* KEY88_d = 100, */
327 { Port2, Bit5 }, /* KEY88_e = 101, */
328 { Port2, Bit6 }, /* KEY88_f = 102, */
329 { Port2, Bit7 }, /* KEY88_g = 103, */
330 { Port3, Bit0 }, /* KEY88_h = 104, */
331 { Port3, Bit1 }, /* KEY88_i = 105, */
332 { Port3, Bit2 }, /* KEY88_j = 106, */
333 { Port3, Bit3 }, /* KEY88_k = 107, */
334 { Port3, Bit4 }, /* KEY88_l = 108, */
335 { Port3, Bit5 }, /* KEY88_m = 109, */
336 { Port3, Bit6 }, /* KEY88_n = 110, */
337 { Port3, Bit7 }, /* KEY88_o = 111, */
338 { Port4, Bit0 }, /* KEY88_p = 112, */
339 { Port4, Bit1 }, /* KEY88_q = 113, */
340 { Port4, Bit2 }, /* KEY88_r = 114, */
341 { Port4, Bit3 }, /* KEY88_s = 115, */
342 { Port4, Bit4 }, /* KEY88_t = 116, */
343 { Port4, Bit5 }, /* KEY88_u = 117, */
344 { Port4, Bit6 }, /* KEY88_v = 118, */
345 { Port4, Bit7 }, /* KEY88_w = 119, */
346 { Port5, Bit0 }, /* KEY88_x = 120, */
347 { Port5, Bit1 }, /* KEY88_y = 121, */
348 { Port5, Bit2 }, /* KEY88_z = 122, */
349 { Port5, Bit3 }, /* KEY88_BRACELEFT = 123, */
350 { Port5, Bit4 }, /* KEY88_BAR = 124, */
351 { Port5, Bit5 }, /* KEY88_BRACERIGHT = 125, */
352 { Port5, Bit6 }, /* KEY88_TILDE = 126, */
353 { 0, 0 },
354 { Port0, Bit0 }, /* KEY88_KP_0 = 128, */
355 { Port0, Bit1 }, /* KEY88_KP_1 = 129, */
356 { Port0, Bit2 }, /* KEY88_KP_2 = 130, */
357 { Port0, Bit3 }, /* KEY88_KP_3 = 131, */
358 { Port0, Bit4 }, /* KEY88_KP_4 = 132, */
359 { Port0, Bit5 }, /* KEY88_KP_5 = 133, */
360 { Port0, Bit6 }, /* KEY88_KP_6 = 134, */
361 { Port0, Bit7 }, /* KEY88_KP_7 = 135, */
362 { Port1, Bit0 }, /* KEY88_KP_8 = 136, */
363 { Port1, Bit1 }, /* KEY88_KP_9 = 137, */
364 { Port1, Bit2 }, /* KEY88_KP_MULTIPLY = 138, */
365 { Port1, Bit3 }, /* KEY88_KP_ADD = 139, */
366 { Port1, Bit4 }, /* KEY88_KP_EQUAL = 140, */
367 { Port1, Bit5 }, /* KEY88_KP_COMMA = 141, */
368 { Port1, Bit6 }, /* KEY88_KP_PERIOD = 142, */
369 { PortA, Bit5 }, /* KEY88_KP_SUB = 143, */
370 { PortA, Bit6 }, /* KEY88_KP_DIVIDE = 144, */
371
372 { Port1, Bit7 }, /* KEY88_RETURN = 145, */
373 { Port8, Bit0 }, /* KEY88_HOME = 146, */
374 { Port8, Bit1 }, /* KEY88_UP = 147, */
375 { Port8, Bit2 }, /* KEY88_RIGHT = 148, */
376 { Port8, Bit3 }, /* KEY88_INS_DEL = 149, */
377 { Port8, Bit4 }, /* KEY88_GRAPH = 150, */
378 { Port8, Bit5 }, /* KEY88_KANA = 151, */
379 { Port8, Bit6 }, /* KEY88_SHIFT = 152, */
380 { Port8, Bit7 }, /* KEY88_CTRL = 153, */
381 { Port9, Bit0 }, /* KEY88_STOP = 154, */
382 { Port9, Bit6 }, /* KEY88_SPACE = 155, */
383 { Port9, Bit7 }, /* KEY88_ESC = 156, */
384 { PortA, Bit0 }, /* KEY88_TAB = 157, */
385 { PortA, Bit1 }, /* KEY88_DOWN = 158, */
386 { PortA, Bit2 }, /* KEY88_LEFT = 159, */
387 { PortA, Bit3 }, /* KEY88_HELP = 160, */
388 { PortA, Bit4 }, /* KEY88_COPY = 161, */
389 { PortA, Bit7 }, /* KEY88_CAPS = 162, */
390 { PortB, Bit0 }, /* KEY88_ROLLUP = 163, */
391 { PortB, Bit1 }, /* KEY88_ROLLDOWN = 164, */
392
393 { Port9, Bit1 }, /* KEY88_F1 = 165, */
394 { Port9, Bit2 }, /* KEY88_F2 = 166, */
395 { Port9, Bit3 }, /* KEY88_F3 = 167, */
396 { Port9, Bit4 }, /* KEY88_F4 = 168, */
397 { Port9, Bit5 }, /* KEY88_F5 = 169, */
398
399 { 0,0 },{ 0,0 },
400 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
401 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
402
403 { Port9, Bit1 }, /*f-1*/ /* KEY88_F6 = 180, */
404 { Port9, Bit2 }, /*f-2*/ /* KEY88_F7 = 181, */
405 { Port9, Bit3 }, /*f-3*/ /* KEY88_F8 = 182, */
406 { Port9, Bit4 }, /*f-4*/ /* KEY88_F9 = 183, */
407 { Port9, Bit5 }, /*f-5*/ /* KEY88_F10 = 184, */
408 { Port8, Bit3 }, /*del*/ /* KEY88_BS = 185, */
409 { Port8, Bit3 }, /*del*/ /* KEY88_INS = 186, */
410 { Port8, Bit3 }, /*del*/ /* KEY88_DEL = 187, */
411 { Port9, Bit6 }, /*spc*/ /* KEY88_HENKAN = 188, */
412 { Port9, Bit6 }, /*spc*/ /* KEY88_KETTEI = 189, */
413 { 0, 0 }, /* KEY88_PC = 190, */
414 { 0, 0 }, /* KEY88_ZENKAKU = 191, */
415 { Port1, Bit7 }, /*ret*/ /* KEY88_RETURNL = 192, */
416 { Port1, Bit7 }, /*ret*/ /* KEY88_RETURNR = 193, */
417 { Port8, Bit6 }, /*sft*/ /* KEY88_SHIFTL = 194, */
418 { Port8, Bit6 }, /*sft*/ /* KEY88_SHIFTR = 195, */
419
420 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
421 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
422 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
423
424 { 0, 0 }, /* KEY88_MOUSE_UP = 208, */
425 { 0, 0 }, /* KEY88_MOUSE_DOWN = 209, */
426 { 0, 0 }, /* KEY88_MOUSE_LEFT = 210, */
427 { 0, 0 }, /* KEY88_MOUSE_RIGHT = 211, */
428 { 0, 0 }, /* KEY88_MOUSE_L = 212, */
429 { 0, 0 }, /* KEY88_MOUSE_M = 213, */
430 { 0, 0 }, /* KEY88_MOUSE_R = 214, */
431 { 0, 0 }, /* KEY88_MOUSE_WUP = 215, */
432 { 0, 0 }, /* KEY88_MOUSE_WDN = 216, */
433
434 { 0,0 },{ 0,0 },{ 0,0 },
435 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
436
437 { PortX, PadU }, /* KEY88_PAD1_UP = 224, */
438 { PortX, PadD }, /* KEY88_PAD1_DOWN = 225, */
439 { PortX, PadL }, /* KEY88_PAD1_LEFT = 226, */
440 { PortX, PadR }, /* KEY88_PAD1_RIGHT = 227, */
441 { PortX, PadA }, /* KEY88_PAD1_A = 228, */
442 { PortX, PadB }, /* KEY88_PAD1_B = 229, */
443 { 0, 0 }, /* KEY88_PAD1_C = 230, */
444 { 0, 0 }, /* KEY88_PAD1_D = 231, */
445 { 0, 0 }, /* KEY88_PAD1_E = 232, */
446 { 0, 0 }, /* KEY88_PAD1_F = 233, */
447 { 0, 0 }, /* KEY88_PAD1_G = 234, */
448 { 0, 0 }, /* KEY88_PAD1_H = 235, */
449
450 { 0, 0 }, /* KEY88_PAD2_UP = 236, */
451 { 0, 0 }, /* KEY88_PAD2_DOWN = 237, */
452 { 0, 0 }, /* KEY88_PAD2_LEFT = 238, */
453 { 0, 0 }, /* KEY88_PAD2_RIGHT = 239, */
454 { 0, 0 }, /* KEY88_PAD2_A = 240, */
455 { 0, 0 }, /* KEY88_PAD2_B = 241, */
456 { 0, 0 }, /* KEY88_PAD2_C = 242, */
457 { 0, 0 }, /* KEY88_PAD2_D = 243, */
458 { 0, 0 }, /* KEY88_PAD2_E = 244, */
459 { 0, 0 }, /* KEY88_PAD2_F = 245, */
460 { 0, 0 }, /* KEY88_PAD2_G = 246, */
461 { 0, 0 }, /* KEY88_PAD2_H = 247, */
462
463 { 0,0 },{ 0,0 },{ 0,0 },{ 0,0 },
464 { 0,0 },{ 0,0 },
465 { 0,0 }, /* KEY88_SYS_STATUS = 254, */
466 { 0,0 }, /* KEY88_SYS_MENU = 255, */
467
468 { PortC, Bit0 }, /* KEY88_EXT_F6 = 256, */
469 { PortC, Bit1 }, /* KEY88_EXT_F7 = 257, */
470 { PortC, Bit2 }, /* KEY88_EXT_F8 = 258, */
471 { PortC, Bit3 }, /* KEY88_EXT_F9 = 259, */
472 { PortC, Bit4 }, /* KEY88_EXT_F10 = 260, */
473 { PortC, Bit5 }, /* KEY88_EXT_BS = 261, */
474 { PortC, Bit6 }, /* KEY88_EXT_INS = 262, */
475 { PortC, Bit7 }, /* KEY88_EXT_DEL = 263, */
476 { PortD, Bit0 }, /* KEY88_EXT_HENKAN = 264, */
477 { PortD, Bit1 }, /* KEY88_EXT_KETTEI = 265, */
478 { PortD, Bit2 }, /* KEY88_EXT_PC = 266, */
479 { PortD, Bit3 }, /* KEY88_EXT_ZENKAKU = 267, */
480 { PortE, Bit0 }, /* KEY88_EXT_RETURNL = 268, */
481 { PortE, Bit1 }, /* KEY88_EXT_RETURNR = 269, */
482 { PortE, Bit2 }, /* KEY88_EXT_SHIFTL = 270, */
483 { PortE, Bit3 }, /* KEY88_EXT_SHIFTR = 271, */
484 };
485
486
487 /*---------------------------------------------------------------------------
488 *
489 *---------------------------------------------------------------------------*/
490
491 #define IS_JOY_STATUS() key_scan[ PortX ]
492
493
494 #define KEY88_PRESS(code) \
495 key_scan[ keyport[(code)].port ] &= ~keyport[(code)].mask
496
497 #define KEY88_RELEASE(code) \
498 key_scan[ keyport[(code)].port ] |= keyport[(code)].mask
499
500 #define KEY88_TOGGLE(code) \
501 key_scan[ keyport[(code)].port ] ^= keyport[(code)].mask
502
503 #define IS_KEY88_PRESS(code) \
504 (~key_scan[ keyport[(code)].port ] & keyport[(code)].mask)
505
506 #define IS_KEY88_RELEASE(code) \
507 ( key_scan[ keyport[(code)].port ] & keyport[(code)].mask)
508
509
510 #define IS_KEY88_PRINTTABLE(c) (32 <= (c) && (c) <= 144)
511 #define IS_KEY88_FUNCTION(c) (KEY88_F1 <= (c) && (c) <= KEY88_F20)
512 #define IS_KEY88_LATTERTYPE(c) (KEY88_F6 <= (c) && (c) <= KEY88_SHIFTR)
513
514
515
516
517
518 /*---------------------------------------------------------------------------
519 * �����ΥХ���ǥ����ѹ� (���������ɡ���ǽ)
520 *---------------------------------------------------------------------------*/
clr_key_function(void)521 static void clr_key_function(void)
522 {
523 int i;
524 for (i=0; i<COUNTOF(key_func); i++) { key_func[i] = 0; }
525
526 /* ����2�ĤΥ����ϡ���ǽ���� */
527 key_func[ KEY88_SYS_STATUS ] = FN_STATUS;
528 key_func[ KEY88_SYS_MENU ] = FN_MENU;
529 }
530
531
set_key_function(int keycode,int func_no)532 static void set_key_function(int keycode, int func_no)
533 {
534 key_func[ keycode ] = func_no;
535
536 /* ����2�ĤΥ����ϡ���ǽ���� */
537 key_func[ KEY88_SYS_STATUS ] = FN_STATUS;
538 key_func[ KEY88_SYS_MENU ] = FN_MENU;
539 }
540
541
swap_key_function(int keycode1,int keycode2)542 static void swap_key_function(int keycode1, int keycode2)
543 {
544 int tmp = key_func[ keycode1 ];
545 key_func[ keycode1 ] = key_func[ keycode2 ];
546 key_func[ keycode2 ] = tmp;
547 }
548
549
550 /*---------------------------------------------------------------------------
551 * �ޥ����κ�ɸ���̥������˹�碌����������
552 *---------------------------------------------------------------------------*/
mouse_movement_adjust(int * x,int * y)553 static void mouse_movement_adjust(int *x, int *y)
554 {
555 (*x) -= SCREEN_DX;
556 (*y) -= SCREEN_DY;
557
558 switch (quasi88_cfg_now_size()) {
559 case SCREEN_SIZE_HALF: (*x) *= 2; (*y) *= 2; break;
560 case SCREEN_SIZE_FULL: break;
561 #ifdef SUPPORT_DOUBLE
562 case SCREEN_SIZE_DOUBLE: (*x) /= 2; (*y) /= 2; break;
563 #endif
564 }
565 }
566
567
568 /****************************************************************************
569 * �����ΥХ���ǥ����ѹ�
570 * ���ץ����䡢��˥塼�Ǥ�����˴�Ť��������Х���ɤ��ѹ�����/�᤹��
571 *****************************************************************************/
keyboard_switch(void)572 void keyboard_switch(void)
573 {
574 int swap;
575 const int *p;
576
577 if (quasi88_is_exec()) { /* ���ߥ���ϡ������Х���ǥ����ѹ� */
578
579 clr_key_function();
580
581 if (numlock_emu) {
582 event_numlock_on(); /* Num lock ��ͭ���� (�����ƥ��¸) */
583 }
584
585 if (tenkey_emu) { /* ����������ƥ������� */
586 set_key_function( KEY88_1, KEY88_KP_1 );
587 set_key_function( KEY88_2, KEY88_KP_2 );
588 set_key_function( KEY88_3, KEY88_KP_3 );
589 set_key_function( KEY88_4, KEY88_KP_4 );
590 set_key_function( KEY88_5, KEY88_KP_5 );
591 set_key_function( KEY88_6, KEY88_KP_6 );
592 set_key_function( KEY88_7, KEY88_KP_7 );
593 set_key_function( KEY88_8, KEY88_KP_8 );
594 set_key_function( KEY88_9, KEY88_KP_9 );
595 set_key_function( KEY88_0, KEY88_KP_0 );
596 }
597
598 if (cursor_key_mode) { /* ������������ϳ�������ѹ� */
599 if (cursor_key_mode == 1) p = cursor_key_assign_tenkey;
600 else p = cursor_key_assign;
601
602 set_key_function( KEY88_UP, *p ); p ++;
603 set_key_function( KEY88_DOWN, *p ); p ++;
604 set_key_function( KEY88_LEFT, *p ); p ++;
605 set_key_function( KEY88_RIGHT, *p );
606 }
607
608 /*
609 �����ƥफ��Υޥ������ϡ�����ӥ��祤���ƥ��å����Ϥ���
610 QUASI88 �Υݡ��ȤˤɤΤ褦��ȿ�Ǥ���뤫�ΰ�����
611
612 | �ޥ�����ư �ޥ����ܥ��� | ���祤���ƥ��å�
613 ---------------+--------------+--------------+-----------------
614 MOUSE_NONE | �ʤ� | �ʤ� | �ʤ�
615 ---------------+--------------+--------------+-----------------
616 MOUSE_JOYMOUSE | ������ȿ�� | ������ȿ�� | �ʤ�
617 ---------------+--------------+--------------+-----------------
618 MOUSE_MOUSE | ��ư�̤�ȿ�� | ������ȿ�� | �ʤ�
619 ---------------+--------------+--------------+-----------------
620 MOUSE_JOYSTICK | �ʤ� | �ʤ� | ������ȿ��
621
622 �֤ʤ��פ���ϡ�QUASI88�ˤ�ȿ�Ǥ���ʤ��Τǡ���ͳ�˥���������Ʋ�ǽ��
623 */
624 swap = FALSE;
625
626 switch (mouse_mode) { /* �ޥ��������ϳ�������ѹ� */
627 case MOUSE_NONE:
628 case MOUSE_JOYSTICK:
629 if (mouse_key_mode) {
630 if (mouse_key_mode == 1) p = mouse_key_assign_tenkey;
631 else p = mouse_key_assign;
632
633 set_key_function( KEY88_MOUSE_UP, *p ); p ++;
634 set_key_function( KEY88_MOUSE_DOWN, *p ); p ++;
635 set_key_function( KEY88_MOUSE_LEFT, *p ); p ++;
636 set_key_function( KEY88_MOUSE_RIGHT, *p ); p ++;
637 set_key_function( KEY88_MOUSE_L, *p ); p ++;
638 set_key_function( KEY88_MOUSE_R, *p );
639 if (mouse_key_mode == 1) {
640 swap = mouse_swap_button;
641 }
642 }
643 break;
644
645 case MOUSE_JOYMOUSE:
646 set_key_function( KEY88_MOUSE_UP, KEY88_PAD1_UP );
647 set_key_function( KEY88_MOUSE_DOWN, KEY88_PAD1_DOWN );
648 set_key_function( KEY88_MOUSE_LEFT, KEY88_PAD1_LEFT );
649 set_key_function( KEY88_MOUSE_RIGHT, KEY88_PAD1_RIGHT );
650 set_key_function( KEY88_MOUSE_L, KEY88_PAD1_A );
651 set_key_function( KEY88_MOUSE_R, KEY88_PAD1_B );
652 swap = mouse_swap_button;
653 break;
654
655 case MOUSE_MOUSE:
656 set_key_function( KEY88_MOUSE_L, KEY88_PAD1_A );
657 set_key_function( KEY88_MOUSE_R, KEY88_PAD1_B );
658 swap = mouse_swap_button;
659 break;
660 }
661 if (swap) {
662 swap_key_function(KEY88_MOUSE_L, KEY88_MOUSE_R);
663 }
664
665
666 swap = FALSE;
667
668 switch (mouse_mode) { /* ���祤���ƥ��å����ϳ�������ѹ� */
669 case MOUSE_NONE:
670 case MOUSE_MOUSE:
671 case MOUSE_JOYMOUSE:
672 if (joy_key_mode) {
673 if (joy_key_mode == 1) p = joy_key_assign_tenkey;
674 else p = joy_key_assign;
675
676 set_key_function( KEY88_PAD1_UP, *p ); p ++;
677 set_key_function( KEY88_PAD1_DOWN, *p ); p ++;
678 set_key_function( KEY88_PAD1_LEFT, *p ); p ++;
679 set_key_function( KEY88_PAD1_RIGHT, *p ); p ++;
680 set_key_function( KEY88_PAD1_A, *p ); p ++;
681 set_key_function( KEY88_PAD1_B, *p ); p ++;
682 set_key_function( KEY88_PAD1_C, *p ); p ++;
683 set_key_function( KEY88_PAD1_D, *p ); p ++;
684 set_key_function( KEY88_PAD1_E, *p ); p ++;
685 set_key_function( KEY88_PAD1_F, *p ); p ++;
686 set_key_function( KEY88_PAD1_G, *p ); p ++;
687 set_key_function( KEY88_PAD1_H, *p ); p ++;
688 if (joy_key_mode == 1) {
689 swap = joy_swap_button;
690 }
691 }
692 break;
693
694 case MOUSE_JOYSTICK:
695 /* KEY88_PAD1_C �� KEY88_PAD1_H �ϳ�����Ƥʤ� */
696 swap = joy_swap_button;
697 break;
698 }
699 if (swap) {
700 swap_key_function(KEY88_PAD1_A, KEY88_PAD1_B);
701 }
702
703
704 if (joy2_key_mode) { /* ���祤���ƥ��å������ϳ�������ѹ� */
705 if (joy2_key_mode == 1) p = joy_key_assign_tenkey;
706 else p = joy2_key_assign;
707
708 set_key_function( KEY88_PAD2_UP, *p ); p ++;
709 set_key_function( KEY88_PAD2_DOWN, *p ); p ++;
710 set_key_function( KEY88_PAD2_LEFT, *p ); p ++;
711 set_key_function( KEY88_PAD2_RIGHT, *p ); p ++;
712 set_key_function( KEY88_PAD2_A, *p ); p ++;
713 set_key_function( KEY88_PAD2_B, *p ); p ++;
714 set_key_function( KEY88_PAD2_C, *p ); p ++;
715 set_key_function( KEY88_PAD2_D, *p ); p ++;
716 set_key_function( KEY88_PAD2_E, *p ); p ++;
717 set_key_function( KEY88_PAD2_F, *p ); p ++;
718 set_key_function( KEY88_PAD2_G, *p ); p ++;
719 set_key_function( KEY88_PAD2_H, *p ); p ++;
720 if (joy2_key_mode == 1) {
721 swap = joy2_swap_button;
722 }
723 }
724 if (swap) {
725 swap_key_function(KEY88_PAD2_A, KEY88_PAD2_B);
726 }
727
728
729 /* �ե�������ε�ǽ������� */
730 set_key_function( KEY88_F1, function_f[ 1 ] );
731 set_key_function( KEY88_F2, function_f[ 2 ] );
732 set_key_function( KEY88_F3, function_f[ 3 ] );
733 set_key_function( KEY88_F4, function_f[ 4 ] );
734 set_key_function( KEY88_F5, function_f[ 5 ] );
735 set_key_function( KEY88_F6, function_f[ 6 ] );
736 set_key_function( KEY88_F7, function_f[ 7 ] );
737 set_key_function( KEY88_F8, function_f[ 8 ] );
738 set_key_function( KEY88_F9, function_f[ 9 ] );
739 set_key_function( KEY88_F10, function_f[ 10 ] );
740 set_key_function( KEY88_F11, function_f[ 11 ] );
741 set_key_function( KEY88_F12, function_f[ 12 ] );
742 set_key_function( KEY88_F13, function_f[ 13 ] );
743 set_key_function( KEY88_F14, function_f[ 14 ] );
744 set_key_function( KEY88_F15, function_f[ 15 ] );
745 set_key_function( KEY88_F16, function_f[ 16 ] );
746 set_key_function( KEY88_F17, function_f[ 17 ] );
747 set_key_function( KEY88_F18, function_f[ 18 ] );
748 set_key_function( KEY88_F19, function_f[ 19 ] );
749 set_key_function( KEY88_F20, function_f[ 20 ] );
750
751
752 } else { /* ��˥塼��ʤɤϡ������Х���ǥ����᤹ */
753
754 romaji_clear(); /* �����Ѵ���������� */
755
756 event_numlock_off(); /* Num lock ��̵���� (�����ƥ��¸) */
757 }
758
759
760 /* �ޥ������Ϥ������ơ��ޥ������֤������ */
761 event_get_mouse_pos(&mouse_x, &mouse_y);
762 mouse_movement_adjust(&mouse_x, &mouse_y);
763
764 mouse_dx = 0;
765 mouse_dy = 0;
766
767 mouse_sx = 0;
768 mouse_sy = 0;
769 mouse_sb = 0;
770 }
771
772
773
774 /****************************************************************************
775 * �������ϤΥ��(�ݡ���)�����
776 *****************************************************************************/
keyboard_reset(void)777 void keyboard_reset(void)
778 {
779 size_t i;
780 for (i=0; i<sizeof(key_scan); i++) key_scan[i] = 0xff;
781
782 romaji_init();
783 }
784
785
786
787 /****************************************************************************
788 * �������Ϥ���(�ݡ���)��ȿ�� ���ߥ�⡼�ɤΤ�
789 *****************************************************************************/
790 static void record_playback(void);
791
keyboard_update(void)792 void keyboard_update(void)
793 {
794 int status;
795
796 /* �������ϥ⡼�ɻ��ϡ������Ѵ���Υ��ʤ� key_scan[] ��ȿ�� */
797
798 if (romaji_input_mode) romaji_output();
799
800
801 /* �ޥ������Ϥ� key_scan[] ��ȿ�� */
802
803 switch (mouse_mode) {
804
805 case MOUSE_NONE:
806 case MOUSE_JOYSTICK:
807 if (mouse_key_mode == 0) { /* �ޥ��������������̵���ʤ� */
808 mouse_dx = 0; /* �ޥ�����ư�̤����� */
809 mouse_dy = 0;
810 break;
811 }
812 /* FALLTHROUGH */ /* �ޥ��������������ͭ�꤫�� */
813 /* ���祤���ƥ��å��⡼�ɤʤ� */
814 case MOUSE_JOYMOUSE: /* �ޥ�����ư�̤�ݡ��Ȥ�ȿ�� */
815 if (mouse_dx == 0) {
816 if (mouse_dy == 0) status = 0; /* ---- */
817 else if (mouse_dy > 0) status = (PadD); /* �� */
818 else status = (PadU); /* �� */
819 } else if (mouse_dx > 0) {
820 int a = mouse_dy * 100 / mouse_dx;
821 if (a > 241) status = (PadD); /* �� */
822 else if (a > 41) status = (PadD | PadR); /* ���� */
823 else if (a > -41) status = ( PadR); /* �� */
824 else if (a > -241) status = (PadU | PadR); /* ���� */
825 else status = (PadU); /* �� */
826 } else {
827 int a = -mouse_dy * 100 / mouse_dx;
828 if (a > 241) status = (PadD); /* �� */
829 else if (a > 41) status = (PadD | PadL); /* ���� */
830 else if (a > -41) status = ( PadL); /* �� */
831 else if (a > -241) status = (PadU | PadL); /* ���� */
832 else status = (PadU); /* �� */
833 }
834
835 quasi88_mouse( KEY88_MOUSE_UP, (status & PadU) );
836 quasi88_mouse( KEY88_MOUSE_DOWN, (status & PadD) );
837 quasi88_mouse( KEY88_MOUSE_LEFT, (status & PadL) );
838 quasi88_mouse( KEY88_MOUSE_RIGHT, (status & PadR) );
839
840 mouse_dx = 0; /* �ݡ���ȿ�Ǹ�ϰ�ư�̥��ꥢ */
841 mouse_dy = 0;
842 break;
843
844 case MOUSE_MOUSE: /* �ޥ���������ʤ顢 */
845 break; /* �ޥ�����ư�̤��ݻ����Ƥ��� */
846 }
847
848
849 /* �������(scan_key[], mouse_dx, mouse_dy) ��Ͽ������ */
850
851 record_playback();
852
853
854 /* key_scan[0x0f] (���祤���ƥ��å�) ������������ϥݡ��Ȥ�ȿ�� */
855
856 switch (mouse_mode) {
857 case MOUSE_NONE:
858 sound_reg[ 0x0e ] = 0xff;
859 sound_reg[ 0x0f ] = 0xff;
860 break;
861
862 case MOUSE_MOUSE:
863 sound_reg[ 0x0f ] = (IS_JOY_STATUS() >> 4) | 0xfc;
864 break;
865
866 case MOUSE_JOYMOUSE:
867 case MOUSE_JOYSTICK:
868 sound_reg[ 0x0e ] = (IS_JOY_STATUS() ) | 0xf0;
869 sound_reg[ 0x0f ] = (IS_JOY_STATUS() >> 4) | 0xfc;
870 /*printf("%02x\n",sound_reg[ 0x0e ]&0xff);*/
871 break;
872 }
873
874 }
875
876
877
878 /****************************************************************************
879 * ���ꥢ��ޥ�������Υ��ꥢ�������ͼ���
880 *
881 * ���ȥåץӥå� 1���ǡ���Ĺ 7bit���ѥ�ƥ��ʤ����ܡ��졼�� 1200bps��
882 * +--+--+--+--+--+--+--+--+
883 * 1������ |��|��|��|��|Y7|Y6|X7|X6|
884 * +--+--+--+--+--+--+--+--+
885 * +--+--+--+--+--+--+--+--+
886 * 2������ |��|��|X5|X4|X3|X2|X1|X0|
887 * +--+--+--+--+--+--+--+--+
888 * +--+--+--+--+--+--+--+--+
889 * 3������ |��|��|Y5|Y4|Y3|Y2|Y1|Y0|
890 * +--+--+--+--+--+--+--+--+
891 *
892 * �� �� �� ���ܥ����ܥ��� (��������1)
893 * X7X6X5X4X3X2X1X0 �� X������ư�� (����դ�)
894 * Y7Y6Y5Y4Y3Y2Y1Y0 �� X������ư�� (����դ�)
895 *
896 *****************************************************************************/
897 static int serial_mouse_x;
898 static int serial_mouse_y;
899 static int serial_mouse_step;
900
init_serial_mouse_data(void)901 void init_serial_mouse_data(void)
902 {
903 serial_mouse_x = 0;
904 serial_mouse_y = 0;
905 serial_mouse_step = 0;
906 }
get_serial_mouse_data(void)907 int get_serial_mouse_data(void)
908 {
909 int result;
910 switch (serial_mouse_step) {
911 case 0:
912 if (mouse_sx > 127) serial_mouse_x = 127;
913 else if (mouse_sx < -127) serial_mouse_x = -127;
914 else serial_mouse_x = mouse_sx;
915 if (mouse_sy > 127) serial_mouse_y = 127;
916 else if (mouse_sy < -127) serial_mouse_y = -127;
917 else serial_mouse_y = mouse_sy;
918 mouse_sx = 0;
919 mouse_sy = 0;
920
921 result =
922 0x40 |
923 mouse_sb |
924 ((serial_mouse_y & 0xc0) >> 4) |
925 ((serial_mouse_x & 0xc0) >> 6);
926 /*printf("%02x\n", result);*/
927 break;
928
929 case 1:
930 result = (serial_mouse_x & 0x3f);
931 /*printf(" %02x\n", result);*/
932 break;
933
934 default:
935 result = (serial_mouse_y & 0x3f);
936 /*printf(" %02x\n", result);*/
937 break;
938 }
939 if (++serial_mouse_step >= 3) serial_mouse_step = 0;
940 return result;
941 }
942
943
944
945 /****************************************************************************
946 * �������� ��Ͽ������
947 *****************************************************************************/
key_record_playback_init(void)948 void key_record_playback_init(void)
949 {
950 int i;
951
952 for( i=0; i<16; i++ ) key_record.key[i] = 0xff;
953 key_record.dx_h = 0;
954 key_record.dx_l = 0;
955 key_record.dy_h = 0;
956 key_record.dy_l = 0;
957 key_record.image[0] = -1;
958 key_record.image[1] = -1;
959
960
961 fp_pb = NULL;
962 fp_rec = NULL;
963
964 if( file_pb && file_pb[0] ){ /* �����ѥե�������ץ� */
965
966 fp_pb = osd_fopen( FTYPE_KEY_PB, file_pb, "rb" );
967
968 if( fp_pb ){
969 if( verbose_proc )
970 printf( "Key-Input Playback file <%s> ... OK\n", file_pb );
971 }else{
972 printf( "Can't open <%s>\nKey-Input PlayBack is invalid\n", file_pb );
973 }
974 }
975
976 if( file_rec && file_rec[0] ){ /* ��Ͽ�ѥե�������ץ� */
977
978 fp_rec = osd_fopen( FTYPE_KEY_REC, file_rec, "wb" );
979
980 if( fp_rec ){
981 if( verbose_proc )
982 printf( "Key-Input Record file <%s> ... OK\n", file_rec );
983 }else{
984 printf( "Can't open <%s>\nKey-Input Record is invalid\n", file_rec );
985 }
986 }
987 }
988
key_record_playback_exit(void)989 void key_record_playback_exit(void)
990 {
991 if( fp_pb ){
992 osd_fclose( fp_pb );
993 fp_pb = NULL;
994 if( file_pb ) file_pb[0] = '\0';
995 }
996 if( fp_rec ){
997 osd_fclose( fp_rec );
998 fp_rec = NULL;
999 if( file_rec ) file_rec[0] = '\0';
1000 }
1001 }
1002
1003
1004
1005 /*----------------------------------------------------------------------
1006 * �������� ��Ͽ����������
1007 *----------------------------------------------------------------------*/
record_playback(void)1008 static void record_playback(void)
1009 {
1010 int i, img;
1011
1012 if (quasi88_is_exec() == FALSE) return;
1013
1014 if( fp_rec ){
1015 for( i=0; i<0x10; i++ )
1016 key_record.key[i] = key_scan[i];
1017
1018 key_record.dx_h = (mouse_dx>>8) & 0xff;
1019 key_record.dx_l = mouse_dx & 0xff;
1020 key_record.dy_h = (mouse_dy>>8) & 0xff;
1021 key_record.dy_l = mouse_dy & 0xff;
1022
1023 for( i=0; i<2; i++ ){
1024 if( disk_image_exist( i ) &&
1025 drive_check_empty( i ) == FALSE )
1026 img = disk_image_selected(i) + 1;
1027 else
1028 img = -1;
1029 if( key_record.image[i] != img ) key_record.image[i] = img;
1030 else key_record.image[i] = 0;
1031 }
1032
1033 if( osd_fwrite( &key_record, sizeof(char), sizeof(key_record), fp_rec )
1034 == sizeof(key_record)){
1035 ;
1036 }else{
1037 printf( "Can't write Record file <%s>\n", file_rec );
1038 osd_fclose( fp_rec );
1039 fp_rec = NULL;
1040 }
1041 }
1042
1043
1044 if( fp_pb ){
1045
1046 if( osd_fread( &key_record, sizeof(char), sizeof(key_record), fp_pb )
1047 == sizeof(key_record)){
1048 for( i=0; i<0x10; i++ )
1049 key_scan[i] = key_record.key[i];
1050
1051 mouse_dx = (int)key_record.dx_h << 8;
1052 mouse_dx |= key_record.dx_l;
1053 mouse_dy = (int)key_record.dy_h << 8;
1054 mouse_dy |= key_record.dy_l;
1055
1056 for( i=0; i<2; i++ ){
1057 if( key_record.image[i]==-1 ){
1058 drive_set_empty( i );
1059 }else if( disk_image_exist( i ) &&
1060 key_record.image[i] > 0 &&
1061 key_record.image[i] <= disk_image_num( i ) ){
1062 drive_unset_empty( i );
1063 disk_change_image( i, key_record.image[i]-1 );
1064 }
1065 }
1066
1067 }else{
1068 printf(" (( %s : Playback file EOF ))\n", file_pb );
1069 status_message( 1, STATUS_INFO_TIME, "Playback [EOF]" );
1070 osd_fclose( fp_pb );
1071 fp_pb = NULL;
1072 }
1073 }
1074
1075 /* ���ꥢ��ޥ����ϡ�ȿ�ǥ����ߥ� VSYNC �Ȥϰۤʤ�Τǡ�Ŭ�Ѥ��ʤ� */
1076 }
1077
1078
1079
1080 /****************************************************************************
1081 * ���� I/O �ݡ��ȤΥ�������
1082 *****************************************************************************/
1083 /* ���� I/O �ݡ��Ȥ������Ϣ����� ���ڤ��ؤ�ä����ν��� */
keyboard_jop1_reset(void)1084 void keyboard_jop1_reset(void)
1085 {
1086 #if 0 /* - - - - - - - - - - - - - - - - - �ޥ�����Ϣ�Υ������������ */
1087
1088 #if 0 /* �ޥ�����ɸ�����������ۤ�*/
1089 event_get_mouse_pos(&mouse_x, &mouse_y); /* ���������⤷��ʤ����ɡ� */
1090 mouse_movement_adjust(&mouse_x, &mouse_y); /* �����ޤǤ��ʤ��Ƥ⤤�ä� */
1091 #endif
1092 mouse_dx = 0;
1093 mouse_dy = 0;
1094
1095 #endif /* - - - - - - - - �Ǥ⡢�ºݤˤϤ���ʤ��Ƥ�³��ϤǤʤ��Ȼפ���*/
1096 /* �³������ä��Τǡ�ver 0.6.2 �ʹߤǤϺ�� */
1097
1098 jop1_step = 0;
1099 jop1_dx = 0;
1100 jop1_dy = 0;
1101 }
1102
1103
1104
1105 /****************************************************************************
1106 * ���� I/O �ݡ��� ���ȥ��� ON/OFF
1107 *****************************************************************************/
1108
1109 /* ���ȥ��ֽ����� 720state ����˴�λ�����롣 (��1.25�ϥޡ�����) */
1110 /* (8MHz�ξ��� 1440state �ʤ�����ɤޤ����ä�) */
1111 #define JOP1_STROBE_LIMIT ((int)(720 * 1.25))
1112
keyboard_jop1_strobe(void)1113 void keyboard_jop1_strobe(void)
1114 {
1115 if( mouse_mode==MOUSE_MOUSE && /* �ޥ��� ͭ�� */
1116 (sound_reg[ 0x07 ] & 0x80)==0 ){ /* ����I/O ��������� */
1117
1118 {
1119 int now = state_of_cpu + z80main_cpu.state0;
1120
1121 /*int interval = now - jop1_time;
1122 if( interval < 0 ) interval += state_of_vsync;
1123 printf("JOP %d (%d)\n",jop1_step,interval);*/
1124
1125 if( jop1_step == 2 ){
1126 int interval = now - jop1_time;
1127 if( interval < 0 ) interval += state_of_vsync;
1128 if( interval > JOP1_STROBE_LIMIT ) keyboard_jop1_reset();
1129 }
1130
1131 jop1_time = now;
1132 }
1133
1134 switch( jop1_step ){
1135
1136 case 0: /* �ǽ�Υ��ȥ���(ON)�ǡ��ޥ�����ư�̤��ͤ���ꤷ */
1137 /* 2���ܰʹߤΥ��ȥ��֤ǡ����γ��ꤷ���ͤ�ž������ */
1138 {
1139 int dx = mouse_dx; /* x ���� �Ѱ� */
1140 int dy = mouse_dy; /* y ���� �Ѱ� */
1141
1142 #if 1 /* �Ѱ̤��127���ϰ���˥���åԥ��� */
1143 int f = 0;
1144
1145 /* x��y�Τ��� �Ѱ̤� ��127��Ķ���Ƥ�������õ���� */
1146 /* �Ȥ��Ķ���Ƥ��顢�Ѱ̤��礭���ۤ���Ķ�����Ȥ��롣*/
1147 if( dx < -127 || 127 < dx ) f |= 0x01;
1148 if( dy < -127 || 127 < dy ) f |= 0x02;
1149 if( f==0x03 ){
1150 if( ABS(dx) > ABS(dy) ) f = 0x01;
1151 else f = 0x02;
1152 }
1153 if( f==0x01 ){ /* x�Ѱ̤� ��127��Ķ������� */
1154 /* x�Ѱ̤�max�ͤˤ���y������ */
1155 dy = 127 * SGN(dx) * dy / dx;
1156 dx = 127 * SGN(dx);
1157 }
1158 else if( f==0x02 ){ /* y�Ѱ̤� ��127��Ķ������� */
1159 /* y�Ѱ̤�max�ͤˤ���x������ */
1160 dx = 127 * SGN(dy) * dx / dy;
1161 dy = 127 * SGN(dy);
1162 }
1163 #endif
1164 mouse_dx -= dx;
1165 mouse_dy -= dy;
1166
1167 jop1_dx = dx;
1168 jop1_dy = dy;
1169 /*printf("%d,%d\n",jop1_dx,jop1_dy);*/
1170 }
1171 sound_reg[ 0x0e ] = ((-jop1_dx)>>4) & 0x0f; break;
1172 case 1: sound_reg[ 0x0e ] = (-jop1_dx) & 0x0f; break;
1173 case 2: sound_reg[ 0x0e ] = ((-jop1_dy)>>4) & 0x0f; break;
1174 case 3: sound_reg[ 0x0e ] = (-jop1_dy) & 0x0f; break;
1175 }
1176
1177 }else{
1178 sound_reg[ 0x0e ] = 0xff;
1179 }
1180
1181 jop1_step = (jop1_step + 1) & 0x03;
1182 }
1183
1184
1185
1186 /***********************************************************************
1187 * ���եȥ�����NumLock
1188 * ���ʡʥ����˥�����å�
1189 ************************************************************************/
quasi88_cfg_key_numlock(int on)1190 void quasi88_cfg_key_numlock(int on)
1191 {
1192 if (((numlock_emu) && (on == FALSE)) ||
1193 ((numlock_emu == FALSE) && (on))) {
1194
1195 if (numlock_emu) event_numlock_off();
1196 numlock_emu ^= 1;
1197 keyboard_switch();
1198 }
1199 }
quasi88_cfg_key_kana(int on)1200 void quasi88_cfg_key_kana(int on)
1201 {
1202 if (((IS_KEY88_PRESS(KEY88_KANA)) && (on == FALSE)) ||
1203 ((IS_KEY88_PRESS(KEY88_KANA) == FALSE) && (on))) {
1204
1205 KEY88_TOGGLE(KEY88_KANA);
1206 romaji_input_mode = FALSE;
1207 }
1208 }
quasi88_cfg_key_romaji(int on)1209 void quasi88_cfg_key_romaji(int on)
1210 {
1211 if (((IS_KEY88_PRESS(KEY88_KANA)) && (on == FALSE)) ||
1212 ((IS_KEY88_PRESS(KEY88_KANA) == FALSE) && (on))) {
1213
1214 KEY88_TOGGLE(KEY88_KANA);
1215 if (IS_KEY88_PRESS(KEY88_KANA)) {
1216 romaji_input_mode = TRUE;
1217 romaji_clear();
1218 } else {
1219 romaji_input_mode = FALSE;
1220 }
1221 }
1222 }
1223
1224
1225
1226 /****************************************************************************
1227 * �ڵ����¸����ꡢ�����������˸ƤӽФ�����
1228 *
1229 * code �ϡ����������ɤǡ� KEY88_SPACE <= code <= KEY88_SHIFTR
1230 * on �ϡ����������ʤ鿿�����������ʤ鵶
1231 *****************************************************************************/
1232 static void do_lattertype(int code, int on);
1233 static int do_func(int func, int on);
1234
quasi88_key(int code,int on)1235 void quasi88_key(int code, int on)
1236 {
1237 if (quasi88_is_exec()) { /*===================================*/
1238
1239 if (key_func[ code ]) { /* �ü����������ƺѤξ�� */
1240 code = do_func(key_func[ code ], on); /* �ü쵡ǽ������¹� */
1241 if (code == 0) return; /* ���ͤ� ������������ */
1242 }
1243
1244 if (romaji_input_mode && on) { /* �������ϥ⡼�ɤξ�� */
1245 if (romaji_input(code) == 0) { /* �Ѵ�������¹� */
1246 return;
1247 }
1248 }
1249
1250 if (IS_KEY88_LATTERTYPE(code)) { /* ����������ܡ��ɤν��� */
1251 do_lattertype(code, on);
1252 }
1253 /* ����������IO�ݡ��Ȥ�ȿ�� */
1254 if (on) KEY88_PRESS(code);
1255 else KEY88_RELEASE(code);
1256
1257 /*
1258 if(code == KEY88_RETURNL){
1259 if (on) printf("+%d\n",code);
1260 else printf("-%d\n",code);
1261 }
1262 */
1263
1264 } else
1265 if (quasi88_is_menu()) { /*===================================*/
1266 /*printf("%d\n",code);*/
1267 /* ��˥塼�Ѥ��ɤ��ؤ��� */
1268 switch (code) {
1269 case KEY88_KP_0: code = KEY88_0; break;
1270 case KEY88_KP_1: code = KEY88_1; break;
1271 case KEY88_KP_2: code = KEY88_2; break;
1272 case KEY88_KP_3: code = KEY88_3; break;
1273 case KEY88_KP_4: code = KEY88_4; break;
1274 case KEY88_KP_5: code = KEY88_5; break;
1275 case KEY88_KP_6: code = KEY88_6; break;
1276 case KEY88_KP_7: code = KEY88_7; break;
1277 case KEY88_KP_8: code = KEY88_8; break;
1278 case KEY88_KP_9: code = KEY88_9; break;
1279 case KEY88_KP_MULTIPLY: code = KEY88_ASTERISK; break;
1280 case KEY88_KP_ADD: code = KEY88_PLUS; break;
1281 case KEY88_KP_EQUAL: code = KEY88_EQUAL; break;
1282 case KEY88_KP_COMMA: code = KEY88_COMMA; break;
1283 case KEY88_KP_PERIOD: code = KEY88_PERIOD; break;
1284 case KEY88_KP_SUB: code = KEY88_MINUS; break;
1285 case KEY88_KP_DIVIDE: code = KEY88_SLASH; break;
1286
1287 case KEY88_INS_DEL: code = KEY88_BS; break;
1288 /*case KEY88_DEL: code = KEY88_BS; break; DEL�Τޤ� */
1289 case KEY88_KETTEI: code = KEY88_SPACE; break;
1290 case KEY88_HENKAN: code = KEY88_SPACE; break;
1291 case KEY88_RETURNL: code = KEY88_RETURN; break;
1292 case KEY88_RETURNR: code = KEY88_RETURN; break;
1293 case KEY88_SHIFTL: code = KEY88_SHIFT; break;
1294 case KEY88_SHIFTR: code = KEY88_SHIFT; break;
1295 }
1296 if (on) q8tk_event_key_on(code);
1297 else q8tk_event_key_off(code);
1298
1299 } else
1300 if (quasi88_is_pause()) { /*===================================*/
1301
1302 if (on) {
1303 if (key_func[ code ]) {
1304 if (key_func[ code ] == FN_MENU) {
1305
1306 pause_event_key_on_menu();
1307
1308 } else if (key_func[ code ] == FN_PAUSE) {
1309
1310 pause_event_key_on_esc();
1311
1312 }
1313
1314 } else if (code == KEY88_ESC) {
1315
1316 pause_event_key_on_esc();
1317
1318 }
1319
1320 }
1321 }
1322 }
1323
1324
1325
1326
1327
1328 /*----------------------------------------------------------------------
1329 * ����������ܡ��ɤΥ�������/�������ν���
1330 * ���եȥ����䡢Ʊ�쵡ǽ�����Υݡ��Ȥ�Ʊ����������
1331 *----------------------------------------------------------------------*/
do_lattertype(int code,int on)1332 static void do_lattertype(int code, int on)
1333 {
1334 /* KEY88_XXX �� KEY88_EXT_XXX ���Ѵ� */
1335 int code2 = code - KEY88_F6 + KEY88_END;
1336
1337 switch (code) {
1338 case KEY88_F6:
1339 case KEY88_F7:
1340 case KEY88_F8:
1341 case KEY88_F9:
1342 case KEY88_F10:
1343 case KEY88_INS: /* KEY88_SHIFTR, KEY88_SHIFTL �� ? */
1344 if (on) { KEY88_PRESS (KEY88_SHIFT); KEY88_PRESS (code2); }
1345 else { KEY88_RELEASE(KEY88_SHIFT); KEY88_RELEASE(code2); }
1346 break;
1347
1348 case KEY88_DEL:
1349 case KEY88_BS:
1350 case KEY88_HENKAN:
1351 case KEY88_KETTEI:
1352 case KEY88_ZENKAKU:
1353 case KEY88_PC:
1354 case KEY88_RETURNR: /* KEY88_RETURNL �� ? */
1355 case KEY88_RETURNL: /* KEY88_RETURNR �� ? */
1356 case KEY88_SHIFTR: /* KEY88_SHIFTL �� ? */
1357 case KEY88_SHIFTL: /* KEY88_SHIFTR �� ? */
1358 if (on) { KEY88_PRESS (code2); }
1359 else { KEY88_RELEASE(code2); }
1360 break;
1361
1362 default:
1363 return;
1364 }
1365 }
1366
1367 /*----------------------------------------------------------------------
1368 * �ե�������˳�����Ƥ���ǽ�ν���
1369 * ����ͤϡ������ʥ��������� (0�ʤ饭�������ʤ�����)
1370 *----------------------------------------------------------------------*/
1371 static void change_framerate(int sign);
1372 static void change_volume(int sign);
1373 static void change_wait(int sign);
1374 static void change_max_speed(int new_speed);
1375 static void change_max_clock(double new_clock);
1376 static void change_max_boost(int new_boost);
1377
do_func(int func,int on)1378 static int do_func(int func, int on)
1379 {
1380 switch (func) {
1381 case FN_FUNC: /* ��ǽ�ʤ� */
1382 return 0;
1383
1384 case FN_FRATE_UP: /* �ե졼�� */
1385 if (on) change_framerate(+1);
1386 return 0;
1387 case FN_FRATE_DOWN: /* �ե졼�� */
1388 if (on) change_framerate(-1);
1389 return 0;
1390
1391 case FN_VOLUME_UP: /* ���� */
1392 if (on) change_volume(-1);
1393 return 0;
1394 case FN_VOLUME_DOWN: /* ���� */
1395 if (on) change_volume(+1);
1396 return 0;
1397
1398 case FN_PAUSE: /* ������ */
1399 if (on) quasi88_pause();
1400 return 0;
1401
1402 case FN_RESIZE: /* �ꥵ���� */
1403 if (on) {
1404 quasi88_cfg_set_size_large();
1405 }
1406 return 0;
1407
1408 case FN_NOWAIT: /* �������� */
1409 if (on) change_wait(0);
1410 return 0;
1411 case FN_SPEED_UP:
1412 if (on) change_wait(+1);
1413 return 0;
1414 case FN_SPEED_DOWN:
1415 if (on) change_wait(-1);
1416 return 0;
1417
1418 case FN_FULLSCREEN: /* �������ڤ��ؤ� */
1419 if (on) {
1420 if (quasi88_cfg_can_fullscreen()) {
1421 int now = quasi88_cfg_now_fullscreen();
1422 int next = (now) ? FALSE : TRUE;
1423 quasi88_cfg_set_fullscreen(next);
1424 }
1425 }
1426 return 0;
1427
1428 case FN_IMAGE_NEXT1: /* DRIVE1: ������ѹ� */
1429 if (on) quasi88_disk_image_empty(DRIVE_1);
1430 else quasi88_disk_image_next(DRIVE_1);
1431 return 0;
1432 case FN_IMAGE_PREV1:
1433 if (on) quasi88_disk_image_empty(DRIVE_1);
1434 else quasi88_disk_image_prev(DRIVE_1);
1435 return 0;
1436 case FN_IMAGE_NEXT2: /* DRIVE2: ������ѹ� */
1437 if (on) quasi88_disk_image_empty(DRIVE_2);
1438 else quasi88_disk_image_next(DRIVE_2);
1439 return 0;
1440 case FN_IMAGE_PREV2:
1441 if (on) quasi88_disk_image_empty(DRIVE_2);
1442 else quasi88_disk_image_prev(DRIVE_2);
1443 return 0;
1444
1445 case FN_NUMLOCK: /* NUM lock */
1446 if (on) {
1447 if (numlock_emu) event_numlock_off();
1448 numlock_emu ^= 1;
1449 keyboard_switch();
1450 }
1451 return 0;
1452
1453 case FN_RESET: /* �ꥻ�å� */
1454 if (on) quasi88_reset(NULL);
1455 return 0;
1456
1457 case FN_KANA: /* ���� */
1458 if (on) {
1459 KEY88_TOGGLE(KEY88_KANA);
1460 romaji_input_mode = FALSE;
1461 }
1462 return 0;
1463
1464 case FN_ROMAJI: /* ����(����) */
1465 if (on) {
1466 KEY88_TOGGLE(KEY88_KANA);
1467 if (IS_KEY88_PRESS(KEY88_KANA)) {
1468 romaji_input_mode = TRUE;
1469 romaji_clear();
1470 } else {
1471 romaji_input_mode = FALSE;
1472 }
1473 }
1474 return 0;
1475
1476 case FN_CAPS: /* CAPS */
1477 if (on) {
1478 KEY88_TOGGLE(KEY88_CAPS);
1479 }
1480 return 0;
1481
1482 case FN_SNAPSHOT: /* ������ʥåץ���å�*/
1483 if (on) quasi88_screen_snapshot();
1484 return 0;
1485
1486 case FN_MAX_SPEED:
1487 if (on) change_max_speed(fn_max_speed);
1488 return 0;
1489 case FN_MAX_CLOCK:
1490 if (on) change_max_clock(fn_max_clock);
1491 return 0;
1492 case FN_MAX_BOOST:
1493 if (on) change_max_boost(fn_max_boost);
1494 return 0;
1495
1496 case FN_STATUS: /* FDD���ơ�����ɽ�� */
1497 if (on) {
1498 if (quasi88_cfg_can_showstatus()) {
1499 int now = quasi88_cfg_now_showstatus();
1500 int next = (now) ? FALSE : TRUE;
1501 quasi88_cfg_set_showstatus(next);
1502 }
1503 }
1504 return 0;
1505 case FN_MENU: /* ��˥塼�⡼�� */
1506 if (on) quasi88_menu();
1507 return 0;
1508
1509 }
1510 return func;
1511 }
1512
1513
1514
1515 /*
1516 * �ե졼�ॹ���å��ѹ� : -frameskip ���ͤ��ѹ����롣
1517 */
change_framerate(int sign)1518 static void change_framerate(int sign)
1519 {
1520 int i, rate;
1521 /* framerate up �� */
1522 static const int list[] = { 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60, };
1523 /* �� framerate down */
1524
1525 rate = quasi88_cfg_now_frameskip_rate();
1526
1527 if (sign > 0) { /* framerate up */
1528
1529 for (i=COUNTOF(list)-1; i>=0; i--) {
1530 if (list[i] < rate) { rate = list[i]; break; }
1531 }
1532 if (i < 0) rate = list[COUNTOF(list)-1];
1533
1534 } else { /* framerate down*/
1535
1536 for (i=0; i<COUNTOF(list); i++) {
1537 if (rate < list[i]) { rate = list[i]; break; }
1538 }
1539 if (i == COUNTOF(list)) rate = list[0];
1540 }
1541
1542 quasi88_cfg_set_frameskip_rate(rate);
1543 }
1544
1545
1546
1547 /*
1548 * �ܥ�塼���ѹ� : -vol ���ͤ��ѹ����롣
1549 */
change_volume(int sign)1550 static void change_volume(int sign)
1551 {
1552 #ifdef USE_SOUND
1553 int diff, vol;
1554 char str[32];
1555
1556 if (xmame_has_sound()) {
1557 if (xmame_has_mastervolume()) {
1558 diff = (sign > 0) ? +1 : ((sign < 0) ? -1 : 0);
1559 if (diff){
1560 vol = xmame_cfg_get_mastervolume() + diff;
1561 if (vol > 0) vol = 0;
1562 if (vol < -32) vol = -32;
1563 xmame_cfg_set_mastervolume(vol);
1564 }
1565
1566 sprintf(str, "VOLUME %3d[db]", xmame_cfg_get_mastervolume());
1567 status_message(1, STATUS_INFO_TIME, str);
1568 /* �ѹ�������ϡ����Ф餯���̤˲��̤�ɽ�������� */
1569 }
1570 }
1571 #endif
1572 }
1573
1574
1575
1576 /*
1577 * �����������ѹ� : -nowait, -speed ���ͤ��ѹ����롣
1578 */
change_wait(int sign)1579 static void change_wait(int sign)
1580 {
1581 int w;
1582
1583 if (sign == 0) { /* ��������̵ͭ���ѹ� */
1584
1585 w = quasi88_cfg_now_no_wait();
1586 w ^= 1;
1587 quasi88_cfg_set_no_wait(w);
1588
1589 } else { /* ���������������� */
1590
1591 w = quasi88_cfg_now_wait_rate();
1592
1593 if (sign < 0) {
1594 w -= 10;
1595 if (w < 10) w = 10;
1596 } else {
1597 w += 10;
1598 if (w > 200) w = 200;
1599 }
1600
1601 quasi88_cfg_set_wait_rate(w);
1602 }
1603 }
1604
1605
1606 /*
1607 * ®���ѹ� (speed/clock/boost)
1608 */
change_max_speed(int new_speed)1609 static void change_max_speed(int new_speed)
1610 {
1611 char str[32];
1612
1613 if (! (5 <= new_speed || new_speed <= 5000)) {
1614 new_speed = 1600;
1615 }
1616
1617 if (wait_rate < new_speed) wait_rate = new_speed;
1618 else wait_rate = 100;
1619
1620 wait_vsync_switch();
1621
1622 no_wait = 0;
1623
1624 sprintf(str, "WAIT %4d[%%]", wait_rate);
1625 status_message(1, STATUS_INFO_TIME, str);
1626 }
change_max_clock(double new_clock)1627 static void change_max_clock(double new_clock)
1628 {
1629 double def_clock = (boot_clock_4mhz ? CONST_4MHZ_CLOCK : CONST_8MHZ_CLOCK);
1630 char str[32];
1631
1632 if (! (0.1 <= new_clock && new_clock < 1000.0)) {
1633 new_clock = CONST_4MHZ_CLOCK * 16;
1634 }
1635
1636 if (cpu_clock_mhz < new_clock) cpu_clock_mhz = new_clock;
1637 else cpu_clock_mhz = def_clock;
1638 interval_work_init_all();
1639
1640 sprintf(str, "CLOCK %8.4f[MHz]", cpu_clock_mhz);
1641 status_message(1, STATUS_INFO_TIME, str);
1642 }
change_max_boost(int new_boost)1643 static void change_max_boost(int new_boost)
1644 {
1645 char str[32];
1646
1647 if (! (1 <= new_boost || new_boost <= 100)) {
1648 new_boost = 16;
1649 }
1650
1651 if (boost < new_boost) boost_change(new_boost);
1652 else boost_change(1);
1653
1654 sprintf(str, "BOOST [x%2d]", boost);
1655 status_message(1, STATUS_INFO_TIME, str);
1656 }
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670 /******************************************************************************
1671 * �ڵ����¸����ꡢ�ޥ����Υܥ������˸ƤӽФ�����
1672 *
1673 * code �ϡ����������ɤǡ� KEY88_MOUSE_L <= code <= KEY88_MOUSE_DOWN
1674 * on �ϡ����������ʤ鿿�����������ʤ鵶
1675 *****************************************************************************/
quasi88_mouse(int code,int on)1676 void quasi88_mouse(int code, int on)
1677 {
1678 if (quasi88_is_exec()) { /*===================================*/
1679 /*
1680 if (on) printf("+%d\n",code);
1681 else printf("-%d\n",code);
1682 */
1683
1684 if (key_func[ code ]) { /* ���������ɤ��ɤ��ؤ� */
1685 code = do_func(key_func[ code ], on); /* �ü쵡ǽ������С� */
1686 if (code == 0) return; /* ������������� */
1687 } /* �������Ϥ䡢 */
1688 /* ����������Ͻ������ʤ�*/
1689
1690 if (on) KEY88_PRESS(code); /* I/O�ݡ��Ȥ�ȿ�� */
1691 else KEY88_RELEASE(code);
1692
1693 /* ���ꥢ��ޥ����ѤΥ�����å� */
1694 if (code == KEY88_MOUSE_L) {
1695 if (on) mouse_sb |= 0x20;
1696 else mouse_sb &= ~0x20;
1697 }
1698 if (code == KEY88_MOUSE_R) {
1699 if (on) mouse_sb |= 0x10;
1700 else mouse_sb &= ~0x10;
1701 }
1702
1703 }
1704 else if (quasi88_is_menu()) { /*===================================*/
1705
1706 if (on) q8tk_event_mouse_on(code);
1707 else q8tk_event_mouse_off(code);
1708 }
1709
1710 if (on) screen_attr_mouse_click(); /* �ޥ�����ư����֡Ĥ����ǥ���� */
1711 }
1712
1713
1714
1715
1716 /******************************************************************************
1717 * �ڵ����¸����ꡢ���祤���ƥ��å����ϻ��˸ƤӽФ�����
1718 *
1719 * code �ϡ����������ɤǡ� KEY88_PAD1_UP <= code <= KEY88_PAD1_H
1720 * on �ϡ����������ʤ鿿�����������ʤ鵶
1721 *****************************************************************************/
quasi88_pad(int code,int on)1722 void quasi88_pad(int code, int on)
1723 {
1724 if (quasi88_is_exec()) { /*===================================*/
1725
1726 if (key_func[ code ]) { /* ���������ɤ��ɤ��ؤ� */
1727 code = do_func(key_func[ code ], on); /* �ü쵡ǽ������С� */
1728 if (code == 0) return; /* ������������� */
1729 } /* �������Ϥ䡢 */
1730 /* ����������Ͻ������ʤ�*/
1731
1732 if (on) KEY88_PRESS(code); /* I/O�ݡ��Ȥ�ȿ�� */
1733 else KEY88_RELEASE(code);
1734
1735 }
1736 }
1737
1738
1739
1740
1741
1742
1743 /****************************************************************************
1744 * �ڵ����¸����ꡢ�ޥ�����ư���˸ƤӽФ���롣��
1745 *
1746 * abs_coord �������ʤ顢x,y �ϥޥ����ΰ�ư��κ�ɸ����
1747 * ��ɸ�ϡ�graph_setup() ������ͤˤƱ������� ���̥�����
1748 * width �� height ���Ф����ͤåȤ��뤳�ȡ�
1749 * (�ʤ����ϰϳ����ͤǤ�ĤȤ���)
1750 *
1751 * abs_coord �� ���ʤ顢x,y �ϥޥ����ΰ�ư�̤���
1752 *****************************************************************************/
quasi88_mouse_move(int x,int y,int abs_coord)1753 void quasi88_mouse_move(int x, int y, int abs_coord)
1754 {
1755 if (abs_coord) {
1756 mouse_movement_adjust(&x, &y);
1757 } else {
1758 /* �������ˤ�������ϡ� */
1759 }
1760
1761
1762 if (quasi88_is_exec()) { /*===================================*/
1763 if (abs_coord) {
1764 mouse_dx += x - mouse_x;
1765 mouse_dy += y - mouse_y;
1766 mouse_x = x;
1767 mouse_y = y;
1768
1769 } else {
1770
1771 /* �ޥ�����®��Ĵ�� */
1772 x = x * mouse_sensitivity / 100;
1773 y = y * mouse_sensitivity / 100;
1774
1775 mouse_dx += x;
1776 mouse_dy += y;
1777 }
1778 mouse_sx = mouse_dx;
1779 mouse_sy = mouse_dy;
1780
1781 }
1782 else if (quasi88_is_menu()) { /*===================================*/
1783
1784 if (abs_coord) {
1785 mouse_x = x;
1786 mouse_y = y;
1787
1788 } else {
1789 mouse_x += x;
1790 if (mouse_x < 0) mouse_x = 0;
1791 if (mouse_x > 640) mouse_x = 640;
1792
1793 mouse_y += y;
1794 if (mouse_y < 0) mouse_y = 0;
1795 if (mouse_y > 400) mouse_y = 400;
1796 }
1797
1798 q8tk_event_mouse_moved(mouse_x, mouse_y);
1799 }
1800
1801 screen_attr_mouse_move(); /* �ޥ�����ư�DZ����Ĥ����Dz�� */
1802 }
1803
1804
1805
1806 /****************************************************************************
1807 * ��˥塼�⡼�ɤΥ��եȥ����������ܡ��ɽ��� (����Ȥ��� scan_key �����)
1808 *****************************************************************************/
1809
1810 /* ���եȥ����������ܡ��ɤ������줿���֤ʤ鿿���֤� */
softkey_is_pressed(int code)1811 int softkey_is_pressed(int code)
1812 {
1813 if (IS_KEY88_LATTERTYPE(code)) {
1814 code = code - KEY88_F6 + KEY88_END;
1815 }
1816 return ((key_scan[ keyport[(code)].port ] & keyport[(code)].mask) == 0);
1817 }
1818
1819 /* ���եȥ����������ܡ��ɤ� */
softkey_press(int code)1820 void softkey_press(int code)
1821 {
1822 if (IS_KEY88_LATTERTYPE(code)) {
1823 do_lattertype(code, TRUE);
1824 }
1825 KEY88_PRESS(code);
1826 }
1827
1828 /* ���եȥ����������ܡ��ɤ�Υ�� */
softkey_release(int code)1829 void softkey_release(int code)
1830 {
1831 if (IS_KEY88_LATTERTYPE(code)) {
1832 do_lattertype(code, FALSE);
1833 }
1834 KEY88_RELEASE(code);
1835 }
1836
1837 /* ���եȥ����������ܡ��ɤ�����Υ�� */
softkey_release_all(void)1838 void softkey_release_all(void)
1839 {
1840 size_t i;
1841 for (i=0; i<sizeof(key_scan); i++) key_scan[i] = 0xff;
1842 }
1843
1844 /* ���եȥ����������ܡ��ɤΡ������ܡ��ɥХ���Ƹ� */
softkey_bug(void)1845 void softkey_bug(void)
1846 {
1847 int my_port, your_port;
1848 byte my_val, your_val, save_val;
1849
1850 save_val = key_scan[8] & 0xf0; /* port 8 �� ��� 4bit ���оݳ� */
1851 key_scan[8] |= 0xf0;
1852
1853 /* port 0��11(����������ܡ��ɤ��ϰ�) �Τߡ��������� */
1854 for (my_port=0; my_port<12; my_port++) {
1855 for (your_port=0; your_port<12; your_port++) {
1856
1857 if (my_port == your_port) continue;
1858
1859 my_val = key_scan[ my_port ];
1860 your_val = key_scan[ your_port ];
1861
1862 if ((my_val | your_val) != 0xff) {
1863 key_scan[ my_port ] =
1864 key_scan[ your_port ] = my_val & your_val;
1865 }
1866
1867 }
1868 }
1869
1870 key_scan[8] &= ~0xf0;
1871 key_scan[8] |= save_val;
1872 }
1873
1874
1875
1876
1877
1878
1879
1880 /***********************************************************************
1881 * ���ơ��ȥ��ɡ����ơ��ȥ�����
1882 ************************************************************************/
1883 /* ver 0.6.2 ������ ver 0.6.3 �ʹߤǥե�������ε�ǽ���Ѥ�ä��Τǡ�
1884 ���ơ��ȥ��ɡ����ơ��ȥ����֤κݤ��Ѵ����롣*/
1885
1886 enum { /* ver 0.6.2�����Ρ��ե�������ε�ǽ */
1887 OLD_FN_FUNC,
1888 OLD_FN_FRATE_UP,
1889 OLD_FN_FRATE_DOWN,
1890 OLD_FN_VOLUME_UP,
1891 OLD_FN_VOLUME_DOWN,
1892 OLD_FN_PAUSE,
1893 OLD_FN_RESIZE,
1894 OLD_FN_NOWAIT,
1895 OLD_FN_SPEED_UP,
1896 OLD_FN_SPEED_DOWN,
1897 OLD_FN_MOUSE_HIDE,
1898 OLD_FN_FULLSCREEN,
1899 OLD_FN_IMAGE_NEXT1,
1900 OLD_FN_IMAGE_PREV1,
1901 OLD_FN_IMAGE_NEXT2,
1902 OLD_FN_IMAGE_PREV2,
1903 OLD_FN_NUMLOCK,
1904 OLD_FN_RESET,
1905 OLD_FN_KANA,
1906 OLD_FN_ROMAJI,
1907 OLD_FN_CAPS,
1908 OLD_FN_KETTEI,
1909 OLD_FN_HENKAN,
1910 OLD_FN_ZENKAKU,
1911 OLD_FN_PC,
1912 OLD_FN_SNAPSHOT,
1913 OLD_FN_STOP,
1914 OLD_FN_COPY,
1915 OLD_FN_STATUS,
1916 OLD_FN_MENU,
1917 OLD_FN_end
1918 };
1919 static struct{ /* ver 0.6.3�ʹߤȤΡ���ǽ���б�ɽ */
1920 int old; int now;
1921 } func_f_convert[] =
1922 {
1923 { OLD_FN_FUNC, FN_FUNC, },
1924 { OLD_FN_FRATE_UP, FN_FRATE_UP, },
1925 { OLD_FN_FRATE_DOWN, FN_FRATE_DOWN, },
1926 { OLD_FN_VOLUME_UP, FN_VOLUME_UP, },
1927 { OLD_FN_VOLUME_DOWN, FN_VOLUME_DOWN, },
1928 { OLD_FN_PAUSE, FN_PAUSE, },
1929 { OLD_FN_RESIZE, FN_RESIZE, },
1930 { OLD_FN_NOWAIT, FN_NOWAIT, },
1931 { OLD_FN_SPEED_UP, FN_SPEED_UP, },
1932 { OLD_FN_SPEED_DOWN, FN_SPEED_DOWN, },
1933 { OLD_FN_MOUSE_HIDE, FN_FUNC, },
1934 { OLD_FN_FULLSCREEN, FN_FULLSCREEN, },
1935 { OLD_FN_IMAGE_NEXT1, FN_IMAGE_NEXT1, },
1936 { OLD_FN_IMAGE_PREV1, FN_IMAGE_PREV1, },
1937 { OLD_FN_IMAGE_NEXT2, FN_IMAGE_NEXT2, },
1938 { OLD_FN_IMAGE_PREV2, FN_IMAGE_PREV2, },
1939 { OLD_FN_NUMLOCK, FN_NUMLOCK, },
1940 { OLD_FN_RESET, FN_RESET, },
1941 { OLD_FN_KANA, FN_KANA, },
1942 { OLD_FN_ROMAJI, FN_ROMAJI, },
1943 { OLD_FN_CAPS, FN_CAPS, },
1944 { OLD_FN_KETTEI, KEY88_KETTEI, },
1945 { OLD_FN_HENKAN, KEY88_HENKAN, },
1946 { OLD_FN_ZENKAKU, KEY88_ZENKAKU, },
1947 { OLD_FN_PC, KEY88_PC, },
1948 { OLD_FN_SNAPSHOT, FN_SNAPSHOT, },
1949 { OLD_FN_STOP, KEY88_STOP, },
1950 { OLD_FN_COPY, KEY88_COPY, },
1951 { OLD_FN_STATUS, FN_STATUS, },
1952 { OLD_FN_MENU, FN_MENU, },
1953 { OLD_FN_FUNC, FN_MAX_SPEED, },
1954 { OLD_FN_FUNC, FN_MAX_CLOCK, },
1955 { OLD_FN_FUNC, FN_MAX_BOOST, },
1956 };
1957 static int old_func_f[ 1 + 20 ];
function_new2old(void)1958 static void function_new2old( void )
1959 {
1960 int i, j;
1961 for( i=1; i<=20; i++ ){
1962 old_func_f[i] = OLD_FN_FUNC;
1963 for( j=0; j<COUNTOF(func_f_convert); j++ ){
1964 if( function_f[i] == func_f_convert[j].now ){
1965 old_func_f[i] = func_f_convert[j].old;
1966 break;
1967 }
1968 }
1969 }
1970 }
function_old2new(void)1971 static void function_old2new( void )
1972 {
1973 int i, j;
1974 for( i=1; i<=20; i++ ){
1975 function_f[i] = FN_FUNC;
1976 for( j=0; j<COUNTOF(func_f_convert); j++ ){
1977 if( old_func_f[i] == func_f_convert[j].old ){
1978 function_f[i] = func_f_convert[j].now;
1979 break;
1980 }
1981 }
1982 }
1983 }
1984
1985
1986
1987 #define SID "KYBD"
1988 #define SID2 "KYB2"
1989 #define SID3 "KYB3"
1990 #define SID4 "KYB4"
1991
1992 static T_SUSPEND_W suspend_keyboard_work[] =
1993 {
1994 { TYPE_INT, &jop1_step },
1995 { TYPE_INT, &jop1_dx },
1996 { TYPE_INT, &jop1_dy },
1997
1998 { TYPE_INT, &romaji_input_mode },
1999
2000 { TYPE_INT, &mouse_mode },
2001 { TYPE_INT, &mouse_key_mode },
2002 { TYPE_INT, &mouse_key_assign[ 0] },
2003 { TYPE_INT, &mouse_key_assign[ 1] },
2004 { TYPE_INT, &mouse_key_assign[ 2] },
2005 { TYPE_INT, &mouse_key_assign[ 3] },
2006 { TYPE_INT, &mouse_key_assign[ 4] },
2007 { TYPE_INT, &mouse_key_assign[ 5] },
2008
2009 { TYPE_INT, &joy_key_mode },
2010 { TYPE_INT, &joy_key_assign[ 0] },
2011 { TYPE_INT, &joy_key_assign[ 1] },
2012 { TYPE_INT, &joy_key_assign[ 2] },
2013 { TYPE_INT, &joy_key_assign[ 3] },
2014 { TYPE_INT, &joy_key_assign[ 4] },
2015 { TYPE_INT, &joy_key_assign[ 5] },
2016 { TYPE_INT, &joy_key_assign[ 6] },
2017 { TYPE_INT, &joy_key_assign[ 7] },
2018 { TYPE_INT, &joy_key_assign[ 8] },
2019 { TYPE_INT, &joy_key_assign[ 9] },
2020 { TYPE_INT, &joy_key_assign[10] },
2021 { TYPE_INT, &joy_key_assign[11] },
2022 { TYPE_INT, &joy_swap_button },
2023
2024 { TYPE_INT, &cursor_key_mode },
2025 { TYPE_INT, &cursor_key_assign[0] },
2026 { TYPE_INT, &cursor_key_assign[1] },
2027 { TYPE_INT, &cursor_key_assign[2] },
2028 { TYPE_INT, &cursor_key_assign[3] },
2029
2030 { TYPE_INT, &tenkey_emu },
2031 { TYPE_INT, &numlock_emu },
2032
2033 { TYPE_INT, &old_func_f[ 1] },
2034 { TYPE_INT, &old_func_f[ 2] },
2035 { TYPE_INT, &old_func_f[ 3] },
2036 { TYPE_INT, &old_func_f[ 4] },
2037 { TYPE_INT, &old_func_f[ 5] },
2038 { TYPE_INT, &old_func_f[ 6] },
2039 { TYPE_INT, &old_func_f[ 7] },
2040 { TYPE_INT, &old_func_f[ 8] },
2041 { TYPE_INT, &old_func_f[ 9] },
2042 { TYPE_INT, &old_func_f[10] },
2043 { TYPE_INT, &old_func_f[11] },
2044 { TYPE_INT, &old_func_f[12] },
2045 { TYPE_INT, &old_func_f[13] },
2046 { TYPE_INT, &old_func_f[14] },
2047 { TYPE_INT, &old_func_f[15] },
2048 { TYPE_INT, &old_func_f[16] },
2049 { TYPE_INT, &old_func_f[17] },
2050 { TYPE_INT, &old_func_f[18] },
2051 { TYPE_INT, &old_func_f[19] },
2052 { TYPE_INT, &old_func_f[20] },
2053
2054 { TYPE_INT, &romaji_type },
2055
2056 { TYPE_END, 0 },
2057 };
2058
2059 static T_SUSPEND_W suspend_keyboard_work2[] =
2060 {
2061 { TYPE_INT, &jop1_time },
2062 { TYPE_END, 0 },
2063 };
2064
2065 static T_SUSPEND_W suspend_keyboard_work3[] =
2066 {
2067 { TYPE_INT, &function_f[ 1] },
2068 { TYPE_INT, &function_f[ 2] },
2069 { TYPE_INT, &function_f[ 3] },
2070 { TYPE_INT, &function_f[ 4] },
2071 { TYPE_INT, &function_f[ 5] },
2072 { TYPE_INT, &function_f[ 6] },
2073 { TYPE_INT, &function_f[ 7] },
2074 { TYPE_INT, &function_f[ 8] },
2075 { TYPE_INT, &function_f[ 9] },
2076 { TYPE_INT, &function_f[10] },
2077 { TYPE_INT, &function_f[11] },
2078 { TYPE_INT, &function_f[12] },
2079 { TYPE_INT, &function_f[13] },
2080 { TYPE_INT, &function_f[14] },
2081 { TYPE_INT, &function_f[15] },
2082 { TYPE_INT, &function_f[16] },
2083 { TYPE_INT, &function_f[17] },
2084 { TYPE_INT, &function_f[18] },
2085 { TYPE_INT, &function_f[19] },
2086 { TYPE_INT, &function_f[20] },
2087 { TYPE_END, 0 },
2088 };
2089
2090 static T_SUSPEND_W suspend_keyboard_work4[] =
2091 {
2092 { TYPE_INT, &mouse_sensitivity },
2093 { TYPE_INT, &mouse_swap_button },
2094
2095 { TYPE_INT, &joy2_key_mode },
2096 { TYPE_INT, &joy2_key_assign[ 0] },
2097 { TYPE_INT, &joy2_key_assign[ 1] },
2098 { TYPE_INT, &joy2_key_assign[ 2] },
2099 { TYPE_INT, &joy2_key_assign[ 3] },
2100 { TYPE_INT, &joy2_key_assign[ 4] },
2101 { TYPE_INT, &joy2_key_assign[ 5] },
2102 { TYPE_INT, &joy2_key_assign[ 6] },
2103 { TYPE_INT, &joy2_key_assign[ 7] },
2104 { TYPE_INT, &joy2_key_assign[ 8] },
2105 { TYPE_INT, &joy2_key_assign[ 9] },
2106 { TYPE_INT, &joy2_key_assign[10] },
2107 { TYPE_INT, &joy2_key_assign[11] },
2108 { TYPE_INT, &joy2_swap_button },
2109
2110 { TYPE_INT, &serial_mouse_x },
2111 { TYPE_INT, &serial_mouse_y },
2112 { TYPE_INT, &serial_mouse_step },
2113
2114 { TYPE_END, 0 },
2115 };
2116
2117
statesave_keyboard(void)2118 int statesave_keyboard( void )
2119 {
2120 function_new2old();
2121
2122 if( statesave_table( SID, suspend_keyboard_work ) != STATE_OK ) return FALSE;
2123
2124 if( statesave_table( SID2,suspend_keyboard_work2) != STATE_OK ) return FALSE;
2125
2126 if( statesave_table( SID3,suspend_keyboard_work3) != STATE_OK ) return FALSE;
2127
2128 if( statesave_table( SID4,suspend_keyboard_work4) != STATE_OK ) return FALSE;
2129
2130 return TRUE;
2131 }
2132
stateload_keyboard(void)2133 int stateload_keyboard( void )
2134 {
2135 if( stateload_table( SID, suspend_keyboard_work ) != STATE_OK ) return FALSE;
2136
2137 if( stateload_table( SID2,suspend_keyboard_work2) != STATE_OK ){
2138
2139 /* ��С������ʤ顢�ߤΤ��� */
2140
2141 printf( "stateload : Statefile is old. (ver 0.6.0 or 1?)\n" );
2142
2143 goto NOT_HAVE_SID2;
2144 }
2145
2146 if( stateload_table( SID3,suspend_keyboard_work3) != STATE_OK ){
2147
2148 /* ��С������ʤ顢�ߤΤ��� */
2149
2150 printf( "stateload : Statefile is old. (ver 0.6.0, 1 or 2?)\n" );
2151
2152 goto NOT_HAVE_SID3;
2153 }
2154
2155 if( stateload_table( SID4,suspend_keyboard_work4) != STATE_OK ){
2156
2157 /* ��С������ʤ顢�ߤΤ��� */
2158
2159 printf( "stateload : Statefile is old. (ver 0.6.0, 1, 2 or 3?)\n" );
2160 }
2161
2162 return TRUE;
2163
2164
2165
2166 NOT_HAVE_SID2:
2167 /* ���δؿ��θƤӽФ������ˡ� stateload_pc88main �� stateload_intr ��
2168 �ƤӽФ���Ƥ��ʤ���С��ʲ��ν�����ϰ�̣���ʤ� */
2169
2170 jop1_time = state_of_cpu + z80main_cpu.state0;
2171
2172
2173 NOT_HAVE_SID3:
2174 /* function_f[] ���ؤ��� */
2175 function_old2new();
2176
2177
2178 return TRUE;
2179 }
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190 /****************************************************************************
2191 *
2192 * �桼�ƥ���ƥ�
2193 *
2194 *****************************************************************************/
2195
2196 /* QUASI88 ���������ɤ�ʸ����� int �ͤ��Ѵ�����ơ��֥� */
2197
2198 static const T_SYMBOL_TABLE key88sym_list[] =
2199 {
2200 { "KEY88_INVALID" , KEY88_INVALID },
2201 { "KEY88_SPACE" , KEY88_SPACE },
2202 { "KEY88_EXCLAM" , KEY88_EXCLAM },
2203 { "KEY88_QUOTEDBL" , KEY88_QUOTEDBL },
2204 { "KEY88_NUMBERSIGN" , KEY88_NUMBERSIGN },
2205 { "KEY88_DOLLAR" , KEY88_DOLLAR },
2206 { "KEY88_PERCENT" , KEY88_PERCENT },
2207 { "KEY88_AMPERSAND" , KEY88_AMPERSAND },
2208 { "KEY88_APOSTROPHE" , KEY88_APOSTROPHE },
2209 { "KEY88_PARENLEFT" , KEY88_PARENLEFT },
2210 { "KEY88_PARENRIGHT" , KEY88_PARENRIGHT },
2211 { "KEY88_ASTERISK" , KEY88_ASTERISK },
2212 { "KEY88_PLUS" , KEY88_PLUS },
2213 { "KEY88_COMMA" , KEY88_COMMA },
2214 { "KEY88_MINUS" , KEY88_MINUS },
2215 { "KEY88_PERIOD" , KEY88_PERIOD },
2216 { "KEY88_SLASH" , KEY88_SLASH },
2217 { "KEY88_0" , KEY88_0 },
2218 { "KEY88_1" , KEY88_1 },
2219 { "KEY88_2" , KEY88_2 },
2220 { "KEY88_3" , KEY88_3 },
2221 { "KEY88_4" , KEY88_4 },
2222 { "KEY88_5" , KEY88_5 },
2223 { "KEY88_6" , KEY88_6 },
2224 { "KEY88_7" , KEY88_7 },
2225 { "KEY88_8" , KEY88_8 },
2226 { "KEY88_9" , KEY88_9 },
2227 { "KEY88_COLON" , KEY88_COLON },
2228 { "KEY88_SEMICOLON" , KEY88_SEMICOLON },
2229 { "KEY88_LESS" , KEY88_LESS },
2230 { "KEY88_EQUAL" , KEY88_EQUAL },
2231 { "KEY88_GREATER" , KEY88_GREATER },
2232 { "KEY88_QUESTION" , KEY88_QUESTION },
2233 { "KEY88_AT" , KEY88_AT },
2234 { "KEY88_A" , KEY88_A },
2235 { "KEY88_B" , KEY88_B },
2236 { "KEY88_C" , KEY88_C },
2237 { "KEY88_D" , KEY88_D },
2238 { "KEY88_E" , KEY88_E },
2239 { "KEY88_F" , KEY88_F },
2240 { "KEY88_G" , KEY88_G },
2241 { "KEY88_H" , KEY88_H },
2242 { "KEY88_I" , KEY88_I },
2243 { "KEY88_J" , KEY88_J },
2244 { "KEY88_K" , KEY88_K },
2245 { "KEY88_L" , KEY88_L },
2246 { "KEY88_M" , KEY88_M },
2247 { "KEY88_N" , KEY88_N },
2248 { "KEY88_O" , KEY88_O },
2249 { "KEY88_P" , KEY88_P },
2250 { "KEY88_Q" , KEY88_Q },
2251 { "KEY88_R" , KEY88_R },
2252 { "KEY88_S" , KEY88_S },
2253 { "KEY88_T" , KEY88_T },
2254 { "KEY88_U" , KEY88_U },
2255 { "KEY88_V" , KEY88_V },
2256 { "KEY88_W" , KEY88_W },
2257 { "KEY88_X" , KEY88_X },
2258 { "KEY88_Y" , KEY88_Y },
2259 { "KEY88_Z" , KEY88_Z },
2260 { "KEY88_BRACKETLEFT" , KEY88_BRACKETLEFT },
2261 { "KEY88_YEN" , KEY88_YEN },
2262 { "KEY88_BRACKETRIGHT" , KEY88_BRACKETRIGHT },
2263 { "KEY88_CARET" , KEY88_CARET },
2264 { "KEY88_UNDERSCORE" , KEY88_UNDERSCORE },
2265 { "KEY88_BACKQUOTE" , KEY88_BACKQUOTE },
2266 { "KEY88_a" , KEY88_a },
2267 { "KEY88_b" , KEY88_b },
2268 { "KEY88_c" , KEY88_c },
2269 { "KEY88_d" , KEY88_d },
2270 { "KEY88_e" , KEY88_e },
2271 { "KEY88_f" , KEY88_f },
2272 { "KEY88_g" , KEY88_g },
2273 { "KEY88_h" , KEY88_h },
2274 { "KEY88_i" , KEY88_i },
2275 { "KEY88_j" , KEY88_j },
2276 { "KEY88_k" , KEY88_k },
2277 { "KEY88_l" , KEY88_l },
2278 { "KEY88_m" , KEY88_m },
2279 { "KEY88_n" , KEY88_n },
2280 { "KEY88_o" , KEY88_o },
2281 { "KEY88_p" , KEY88_p },
2282 { "KEY88_q" , KEY88_q },
2283 { "KEY88_r" , KEY88_r },
2284 { "KEY88_s" , KEY88_s },
2285 { "KEY88_t" , KEY88_t },
2286 { "KEY88_u" , KEY88_u },
2287 { "KEY88_v" , KEY88_v },
2288 { "KEY88_w" , KEY88_w },
2289 { "KEY88_x" , KEY88_x },
2290 { "KEY88_y" , KEY88_y },
2291 { "KEY88_z" , KEY88_z },
2292 { "KEY88_BRACELEFT" , KEY88_BRACELEFT },
2293 { "KEY88_BAR" , KEY88_BAR },
2294 { "KEY88_BRACERIGHT" , KEY88_BRACERIGHT },
2295 { "KEY88_TILDE" , KEY88_TILDE },
2296 { "KEY88_KP_0" , KEY88_KP_0 },
2297 { "KEY88_KP_1" , KEY88_KP_1 },
2298 { "KEY88_KP_2" , KEY88_KP_2 },
2299 { "KEY88_KP_3" , KEY88_KP_3 },
2300 { "KEY88_KP_4" , KEY88_KP_4 },
2301 { "KEY88_KP_5" , KEY88_KP_5 },
2302 { "KEY88_KP_6" , KEY88_KP_6 },
2303 { "KEY88_KP_7" , KEY88_KP_7 },
2304 { "KEY88_KP_8" , KEY88_KP_8 },
2305 { "KEY88_KP_9" , KEY88_KP_9 },
2306 { "KEY88_KP_MULTIPLY" , KEY88_KP_MULTIPLY },
2307 { "KEY88_KP_ADD" , KEY88_KP_ADD },
2308 { "KEY88_KP_EQUAL" , KEY88_KP_EQUAL },
2309 { "KEY88_KP_COMMA" , KEY88_KP_COMMA },
2310 { "KEY88_KP_PERIOD" , KEY88_KP_PERIOD },
2311 { "KEY88_KP_SUB" , KEY88_KP_SUB },
2312 { "KEY88_KP_DIVIDE" , KEY88_KP_DIVIDE },
2313 { "KEY88_RETURN" , KEY88_RETURN },
2314 { "KEY88_HOME" , KEY88_HOME },
2315 { "KEY88_UP" , KEY88_UP },
2316 { "KEY88_RIGHT" , KEY88_RIGHT },
2317 { "KEY88_INS_DEL" , KEY88_INS_DEL },
2318 { "KEY88_GRAPH" , KEY88_GRAPH },
2319 { "KEY88_KANA" , KEY88_KANA },
2320 { "KEY88_SHIFT" , KEY88_SHIFT },
2321 { "KEY88_CTRL" , KEY88_CTRL },
2322 { "KEY88_STOP" , KEY88_STOP },
2323 { "KEY88_ESC" , KEY88_ESC },
2324 { "KEY88_TAB" , KEY88_TAB },
2325 { "KEY88_DOWN" , KEY88_DOWN },
2326 { "KEY88_LEFT" , KEY88_LEFT },
2327 { "KEY88_HELP" , KEY88_HELP },
2328 { "KEY88_COPY" , KEY88_COPY },
2329 { "KEY88_CAPS" , KEY88_CAPS },
2330 { "KEY88_ROLLUP" , KEY88_ROLLUP },
2331 { "KEY88_ROLLDOWN" , KEY88_ROLLDOWN },
2332 { "KEY88_F1" , KEY88_F1 },
2333 { "KEY88_F2" , KEY88_F2 },
2334 { "KEY88_F3" , KEY88_F3 },
2335 { "KEY88_F4" , KEY88_F4 },
2336 { "KEY88_F5" , KEY88_F5 },
2337 { "KEY88_F11" , KEY88_F11 },
2338 { "KEY88_F12" , KEY88_F12 },
2339 { "KEY88_F13" , KEY88_F13 },
2340 { "KEY88_F14" , KEY88_F14 },
2341 { "KEY88_F15" , KEY88_F15 },
2342 { "KEY88_F16" , KEY88_F16 },
2343 { "KEY88_F17" , KEY88_F17 },
2344 { "KEY88_F18" , KEY88_F18 },
2345 { "KEY88_F19" , KEY88_F19 },
2346 { "KEY88_F20" , KEY88_F20 },
2347 { "KEY88_F6" , KEY88_F6 },
2348 { "KEY88_F7" , KEY88_F7 },
2349 { "KEY88_F8" , KEY88_F8 },
2350 { "KEY88_F9" , KEY88_F9 },
2351 { "KEY88_F10" , KEY88_F10 },
2352 { "KEY88_BS" , KEY88_BS },
2353 { "KEY88_INS" , KEY88_INS },
2354 { "KEY88_DEL" , KEY88_DEL },
2355 { "KEY88_HENKAN" , KEY88_HENKAN },
2356 { "KEY88_KETTEI" , KEY88_KETTEI },
2357 { "KEY88_PC" , KEY88_PC },
2358 { "KEY88_ZENKAKU" , KEY88_ZENKAKU },
2359 { "KEY88_RETURNL" , KEY88_RETURNL },
2360 { "KEY88_RETURNR" , KEY88_RETURNR },
2361 { "KEY88_SHIFTL" , KEY88_SHIFTL },
2362 { "KEY88_SHIFTR" , KEY88_SHIFTR },
2363
2364 { "KEY88_SYS_MENU" , KEY88_SYS_MENU },
2365 { "KEY88_SYS_STATUS" , KEY88_SYS_STATUS },
2366 };
2367
2368
2369 /***********************************************************************
2370 * Ϳ����줿ʸ�����QUASI88 ���������ɤ��Ѵ�����
2371 * ��������ե�����β��Ϥʤɤ˻Ȥ���
2372 *
2373 * ��)
2374 * "KEY88_SPACE" -> KEY88_SPACE ������Τޤޤ�ʸ����ϡ�ľ���Ѵ�
2375 * "key88_SPACE" -> KEY88_SPACE ��ʸ�����ߤǤ�褤
2376 * "KEY88_Z" -> KEY88_Z ����⡢������Τޤޤ���
2377 * "KEY88_z" -> KEY88_z ����⡢������Τޤޤ���
2378 * "key88_z" -> KEY88_Z ��ʸ�����ߤξ�����ʸ���ˤʤ��
2379 * "0x20" -> KEY88_SPACE 0x20��0xf7 ��ľ�˥��������ɤ��Ѵ�
2380 * "0x01" -> KEY88_INVALID �嵭���ϰϳ��ʤ�̵��(0)���֤�
2381 * "32" -> KEY88_SPACE 10�ʿ���8�ʿ��Ǥ�Ʊ��
2382 * "KP1" -> KEY88_KP_1 KP �� 1ʸ�� �ǡ��ƥ��Ȥ���
2383 * "KP+" -> KEY88_KP_ADD ����Ǥ�褤
2384 * "Kp9" -> KEY88_KP_9 ��ʸ�����ߤǤ�褤
2385 * "Err" -> -1 �ɤ�ˤ���פ��ʤ��ä��顢����֤�
2386 ************************************************************************/
2387
keyboard_str2key88(const char * str)2388 int keyboard_str2key88(const char *str)
2389 {
2390 static const T_SYMBOL_TABLE tenkey_list[] =
2391 { /* �ƥ��˸¤ꡢ�㳰Ū��ɽ������ǽ */
2392 { "KP0" , KEY88_KP_0 },
2393 { "KP1" , KEY88_KP_1 },
2394 { "KP2" , KEY88_KP_2 },
2395 { "KP3" , KEY88_KP_3 },
2396 { "KP4" , KEY88_KP_4 },
2397 { "KP5" , KEY88_KP_5 },
2398 { "KP6" , KEY88_KP_6 },
2399 { "KP7" , KEY88_KP_7 },
2400 { "KP8" , KEY88_KP_8 },
2401 { "KP9" , KEY88_KP_9 },
2402 { "KP*" , KEY88_KP_MULTIPLY },
2403 { "KP+" , KEY88_KP_ADD },
2404 { "KP=" , KEY88_KP_EQUAL },
2405 { "KP," , KEY88_KP_COMMA },
2406 { "KP." , KEY88_KP_PERIOD },
2407 { "KP-" , KEY88_KP_SUB },
2408 { "KP/" , KEY88_KP_DIVIDE },
2409 };
2410
2411 int len, i;
2412 char *conv_end;
2413 unsigned long l;
2414
2415 if (str == NULL) return -1;
2416 len = strlen(str);
2417 if (len == 0) return -1;
2418
2419
2420 /* 0��9 �ǻϤޤ�С��������Ѵ� */
2421 if ('0'<=str[0] && str[0]<='9') {
2422 l = strtoul(str, &conv_end, 0); /* 10��,16��,8�ʿ�����ǽ */
2423 if (*conv_end == '\0') {
2424 if (32 <= l && l <= 247) {
2425 return l;
2426 } else {
2427 return KEY88_INVALID;
2428 }
2429 }
2430 return -1;
2431 }
2432 /* 3ʸ���ʤ顢�ƥ����� */
2433 if (len == 3) {
2434 for (i=0; i<COUNTOF(tenkey_list); i++) {
2435 if (strcmp(tenkey_list[i].name, str) == 0) {
2436 return tenkey_list[i].val;
2437 }
2438 }
2439 for (i=0; i<COUNTOF(tenkey_list); i++) {
2440 if (my_strcmp(tenkey_list[i].name, str) == 0) {
2441 return tenkey_list[i].val;
2442 }
2443 }
2444 }
2445 /* ���ʸ����˹��פ���Τ�õ�� */
2446 for (i=0; i<COUNTOF(key88sym_list); i++) {
2447 if (strcmp(key88sym_list[i].name, str) == 0) {
2448 return key88sym_list[i].val;
2449 }
2450 }
2451 for (i=0; i<COUNTOF(key88sym_list); i++) {
2452 if (my_strcmp(key88sym_list[i].name, str) == 0) {
2453 return key88sym_list[i].val;
2454 }
2455 }
2456
2457 return -1;
2458 }
2459
2460
keyboard_key882str(int key88)2461 const char *keyboard_key882str(int key88)
2462 {
2463 int i;
2464 for (i=0; i<COUNTOF(key88sym_list); i++) {
2465 if (key88sym_list[i].val == KEY88_INVALID) continue;
2466 if (key88sym_list[i].val == key88) {
2467 return key88sym_list[i].name;
2468 }
2469 }
2470 return NULL;
2471 }
2472
2473
2474
2475
2476
2477 /****************************************************************************
2478 * ��������ե�������ɤ߹���ǡ������Ԥ���
2479 *
2480 * ����Ū�ˤϡ���������ե�������ɤि�Ӥˡ�������Хå��ؿ���Ƥ֡�
2481 * ���ιԤ����Ƥ������ȿ�Ǥ��뤫�ɤ����ϡ�������Хå��ؿ����衣
2482 *
2483 * --------------------------------------------------------------------------
2484 * ��������ե�����νϡ�����ʴ���
2485 * (��ԤˤĤ� ����3�ĤΥȡ�������¤٤��롣 # ��������ޤǤϥ����ȤȤ���)
2486 *
2487 * [SDL] dga
2488 * SDLK_ESCAPE KEY88_ESC KEY88_KP_4
2489 * <49> KEY88_ZENKAKU
2490 *
2491 * 1���ܤΤ褦�ˡ�[��] �ǻϤޤ�Ԥϡ��ּ��̥����ԡפȤ��롣
2492 * 1���ܤΥȡ������ [��] �η����ǡ�2���ܡ�3���ܤΥȡ������Ǥ�� (̵���Ƥ�褤)
2493 * �ּ��̥����ԡפ��ɤि�Ӥˡ��ʲ��Υ�����Хå��ؿ����ƤӽФ���롣
2494 *
2495 * identify_callback(const char *param1, const char *param2,
2496 * const char *param3)
2497 *
2498 * �����ξ�硢�����ϰʲ������åȤ����
2499 * param1 �� "[SDL]"
2500 * param2 �� "dga"
2501 * param3 �� NULL (3���ܤΥȡ����ʤ����Ȥ��̣����)
2502 *
2503 * ���Υ�����Хå��ؿ��ϡ����Ρּ��̥����ԡפ�ͭ���Ǥ���С� NULL ���֤��Τǡ�
2504 * ���μ��ιԤ��顢���Ρּ��̥����ԡ� ([��] �ǻϤޤ��) �ޤǤ������롣
2505 * �֤��ͤ� NULL �Ǥʤ����ϡ����Ρּ��̥����ԡפޤǥ����åפ��롣
2506 * �ʤ����֤��ͤ���ʸ���� "" �Ǥʤ���С���˥Ȥ��Ƥ����ɽ�����롣
2507 *
2508 * 2���ܤϡ������Ρ�����ԡפȤ��롣
2509 * 1���ܡ�2���ܤΥȡ������ɬ�ܤǡ�3���ܤΥȡ������Ǥ�� (̵���Ƥ�褤)
2510 * ������ԡפΤ��Ӥˡ��ʲ��Υ�����Хå��ؿ����ƤӽФ���롣
2511 *
2512 * setting_callback(int type, int code, int key88, int numlock_key88);
2513 *
2514 * �����ξ�硢�����ϰʲ������åȤ���롣
2515 * type �� 1
2516 * code �� "SDLK_ESCAPE" �� int ���Ѵ�������� (��� ��1)
2517 * key88 �� KEY88_ESC �� enum��
2518 * numlock_key88 �� KEY88_KP_4 �� enum��
2519 *
2520 * 3���ܤ⡢�����Ρ�����ԡפ��������㴳�ۤʤäƤ��롣
2521 * ���ξ��⡢Ʊ�ͤ˥�����Хå��ؿ����ƤӽФ���롣
2522 *
2523 * callback(int type, int code, int key88, int numlock_key88);
2524 *
2525 * �����ξ�硢�����ϰʲ������åȤ���롣
2526 * type �� 2
2527 * code �� 49
2528 * key88 �� KEY88_ZENKAKU �� enum��
2529 * numlock_key88 �� -1 (3���ܤΥȡ����ʤ����Ȥ��̣����)
2530 *
2531 * �Ĥޤꡢ2���ܤη����ξ��ϡ�1���ܤΥȡ������ int ���Ѵ������ͤ� code ��
2532 * ���åȤ���뤬��3���ܤη����ξ��ϡ� <��> ����ο��ͤ����åȤ���롣
2533 *
2534 * ���Υ�����Хå��ؿ��ϡ����꤬ͭ���Ǥ���� NULL ���֤����֤��ͤ� NULL ��
2535 * �ʤ�����ʸ���� "" �Ǥ�ʤ����ϥ�˥Ȥ��Ƥ����ɽ�����롣
2536 *
2537 *
2538 * ���ơ���1 �Τ褦�ʡ� SDLK_ESCAPE �� int ���Ѵ�������ˡ�ϡ��ʲ�������ˤ�롣
2539 *
2540 * T_SYMBOL_TABLE table_symbol2int[]; (����Υ������ϡ� table_size)
2541 *
2542 * �����������Ƭ��������å����ơ� table_symbol2int[].name ��1���ܤΥȡ�����
2543 * �����פ������ˡ�table_symbol2int[].val ���ͤ��֤���
2544 *
2545 * table_ignore_case �����ξ�硢��ʸ����ʸ����̵�뤷�ƥ����å�����Τǡ�
2546 * �����ξ��� "SDLK_ESCAPE" "sdlk_escape" �ɤ���Ǥ���פȤߤʤ���
2547 *
2548 *
2549 *
2550 *
2551 *****************************************************************************/
2552 #include <file-op.h>
2553
2554 static int symbol2int(const char *str,
2555 const T_SYMBOL_TABLE table_symbol2int[],
2556 int table_size,
2557 int table_ignore_case);
2558
2559 /* ��������ե�����1�Ԥ�����κ���ʸ���� */
2560 #define MAX_KEYFILE_LINE (256)
2561
config_read_keyconf_file(const char * keyconf_filename,const char * (* identify_callback)(const char * parm1,const char * parm2,const char * parm3),const T_SYMBOL_TABLE table_symbol2int[],int table_size,int table_ignore_case,const char * (* setting_callback)(int type,int code,int key88,int numlock_key88))2562 int config_read_keyconf_file(
2563 const char *keyconf_filename,
2564 const char *(*identify_callback)(const char *parm1,
2565 const char *parm2,
2566 const char *parm3),
2567 const T_SYMBOL_TABLE table_symbol2int[],
2568 int table_size,
2569 int table_ignore_case,
2570 const char *(*setting_callback)(int type,
2571 int code,
2572 int key88,
2573 int numlock_key88))
2574 {
2575 const char *filename;
2576 OSD_FILE *fp = NULL;
2577 int working = FALSE;
2578 int effective = FALSE;
2579
2580 int line_cnt = 0;
2581 char line[ MAX_KEYFILE_LINE ];
2582 char buffer[ MAX_KEYFILE_LINE ];
2583
2584 char *parm1, *parm2, *parm3, *parm4;
2585
2586 int type, code, key88, numlock_key88;
2587 const char *err_mes;
2588
2589
2590 /* ��������ե������ */
2591
2592 if (keyconf_filename == NULL) { /* �ե�����̤̾����ʤ�� */
2593 filename = filename_alloc_keyboard_cfgname(); /* �ǥե����̾����� */
2594 } else {
2595 filename = keyconf_filename;
2596 }
2597
2598 if (filename) {
2599 fp = osd_fopen(FTYPE_CFG, filename, "r");
2600 if (verbose_proc) {
2601 if (fp) {
2602 printf("\"%s\" read and initialize\n", filename);
2603 } else {
2604 printf("can't open keyboard configuration file \"%s\"\n",
2605 filename);
2606 printf("\n");
2607 }
2608 }
2609 if (keyconf_filename == NULL) { /* �ǥե���Ȥʤ�� */
2610 free((void*)filename); /* ����������Ȥ� */
2611 }
2612 }
2613
2614 if (fp == NULL) return FALSE; /* �����ʤ��ä��鵶���֤� */
2615
2616
2617
2618 /* ��������ե������1�ԤŤIJ��� */
2619
2620 while (osd_fgets(line, MAX_KEYFILE_LINE, fp)) {
2621
2622 line_cnt ++;
2623 parm1 = parm2 = parm3 = parm4 = NULL;
2624
2625 /* �Ԥ����Ƥ�ȡ������ʬ�ƥȡ�����ϡ�parm1 �� parm4 �˥��å� */
2626
2627 { char *str = line;
2628 char *b; { b = &buffer[0]; str = my_strtok(b, str); }
2629 if (str) { parm1 = b; b += strlen(b) + 1; str = my_strtok(b, str); }
2630 if (str) { parm2 = b; b += strlen(b) + 1; str = my_strtok(b, str); }
2631 if (str) { parm3 = b; b += strlen(b) + 1; str = my_strtok(b, str); }
2632 if (str) { parm4 = b; }
2633 }
2634
2635
2636 /* �ȡ����ʤ���м��ιԤ� */
2637 if (parm1 == NULL) continue;
2638
2639 /* �ȡ����İʾ夢��С����ιԤϥ��顼�ʤΤǼ��ιԤ� */
2640 if (parm4 != NULL) {
2641 if (working) {
2642 fprintf(stderr,
2643 "warning: too many argument in line %d\n", line_cnt);
2644 }
2645 continue;
2646 }
2647
2648 /* �ȡ�����ġ����Ĥʤ���� */
2649 if (parm1[0] == '[') { /* �ּ��̥����ԡפ���� */
2650
2651 /* ������Хå��ؿ���ƤӽФ��ơ�ͭ���ʼ��̥�������Ƚ�� */
2652 err_mes = (identify_callback)(parm1, parm2, parm3);
2653
2654 if (err_mes == NULL) { /* ͭ���ʼ��̥������ä� */
2655 working = TRUE;
2656 effective = TRUE;
2657
2658 if (verbose_proc)
2659 printf("(read start in line %d)\n", line_cnt);
2660
2661 } else { /* ̵���ʼ��̥������ä� */
2662
2663 if (working) { /* ������ʤ齪λ */
2664 if (verbose_proc)
2665 printf("(read stop in line %d)\n", line_cnt - 1);
2666 } /* �Ǥʤ����̵�� */
2667
2668 if (err_mes[0] != '\0') {
2669 fprintf(stderr,
2670 "warning: %s in %d (ignored)\n",
2671 err_mes, line_cnt);
2672 }
2673
2674 working = FALSE;
2675 }
2676
2677 } else { /* ������ԡפ���� */
2678
2679 if (working) {
2680
2681 /* ������ԡפǡ��ȡ������Ĥ����ϡ����顼�����ιԤ� */
2682 if (parm2 == NULL) {
2683 fprintf(stderr,
2684 "warning: error in line %d (ignored)\n", line_cnt);
2685 } else {
2686
2687 code = symbol2int(parm1, table_symbol2int,
2688 table_size, table_ignore_case);
2689 key88 = keyboard_str2key88(parm2);
2690
2691 if (parm3) { numlock_key88 = keyboard_str2key88(parm3); }
2692 else { numlock_key88 = -1; }
2693
2694 if (code < 0 ||
2695 key88 < 0 ||
2696 (parm3 && numlock_key88 < 0)) {
2697 fprintf(stderr,
2698 "warning: error in line %d (ignored)\n", line_cnt);
2699 } else {
2700
2701 if (parm1[0] == '<') { type = KEYCODE_SCAN; }
2702 else { type = KEYCODE_SYM; }
2703
2704 err_mes = (setting_callback)(type, code,
2705 key88, numlock_key88);
2706
2707 if (err_mes == NULL) { /* ͭ����������ä� */
2708 /* OK */ ;
2709 } else { /* ̵����������ä� */
2710 /* NG */
2711 if (err_mes[0] != '\0') {
2712 fprintf(stderr,
2713 "warning: %s in %d (ignored)\n",
2714 err_mes, line_cnt);
2715 }
2716 }
2717 }
2718 }
2719 }
2720 }
2721 }
2722 osd_fclose(fp);
2723
2724
2725 if (working) {
2726 if(verbose_proc) printf("(read end in line %d)\n", line_cnt-1);
2727 }
2728
2729 if (effective == FALSE) {
2730 fprintf(stderr, "warning: not configured (use initial config)\n");
2731 }
2732
2733 if (verbose_proc) {
2734 printf("\n");
2735 }
2736
2737 return (effective) ? TRUE : FALSE;
2738 }
2739
2740
symbol2int(const char * str,const T_SYMBOL_TABLE table_symbol2int[],int table_size,int table_ignore_case)2741 static int symbol2int(const char *str,
2742 const T_SYMBOL_TABLE table_symbol2int[],
2743 int table_size,
2744 int table_ignore_case)
2745 {
2746 int i;
2747 char *conv_end;
2748 unsigned long l;
2749
2750 if ( str == NULL) return -1;
2751 if (*str == '\0') return -1;
2752
2753 if (str[0] == '<') { /* <����> �� */
2754 l = strtoul(&str[1], &conv_end, 0);
2755 if (*conv_end == '>') {
2756 return l;
2757 }
2758 return -1;
2759 }
2760 /* ���ʸ����˹��פ���Τ�õ�� */
2761 for (i=0; i<table_size; i++) {
2762 if (strcmp(table_symbol2int[i].name, str) == 0) {
2763 return table_symbol2int[i].val;
2764 }
2765 }
2766 if (table_ignore_case) {
2767 for (i=0; i<table_size; i++) {
2768 if (my_strcmp(table_symbol2int[i].name, str) == 0) {
2769 return table_symbol2int[i].val;
2770 }
2771 }
2772 }
2773
2774 return -1;
2775 }
2776