1 #ifndef __KBD
2 #define __KBD
3 
4 #include <default.h>
5 
6 /* We have to use this internal macro since _keytest needs to be able to
7    accept single parameters (in particular, the RR_... constant pairs). */
8 #define __keytest(row,col) (!!(_rowread_inverted(1<<(row))&(1<<(col))))
9 
10 /* If you can read the macro below, you must be a really good C programmer.
11    But I hope I can make it understandable:
12    __current_row and __current_rowread_result are defined by BEGIN_KEYTEST
13    and initialized to dummy values.
14    The definition is sort of the same as the one above, but
15    _rowread_inverted (1 << (row))
16    is replaced with
17    (__current_row == row ? __current_rowread_result : (__current_row = row, __current_rowread_result = _rowread_inverted (1 << (row))))
18    So,
19    if the row which was read the last time this macro was called equals the
20    one that is to be read now,
21      then use the last result in place of _rowread_inverted (1 << (row)),
22    otherwise
23      set __current_row,
24      set __current_rowread_result by calling _rowread_inverted,
25      and also return this value
26      (see the section in the doc about the ',' operator). */
27 #define __keytest_optimized(row,col) (!!((__current_row==row?__current_rowread_result:(__current_row=row,__current_rowread_result=_rowread_inverted(1<<(row))))&(1<<(col))))
28 
29 /* Begin Auto-Generated Part */
30 #define KB_AUTOREPEAT (1<<11)
31 #define NULL ((void*)0)
32 #ifndef __HAVE_Bool
33 #define __HAVE_Bool
34 enum Bool{FALSE,TRUE};
35 #endif
36 #ifndef __HAVE_SCR_RECT
37 #define __HAVE_SCR_RECT
38 typedef union{struct{unsigned char x0,y0,x1,y1;}xy;unsigned long l;}SCR_RECT;
39 #endif
40 enum Arrows{ARROW_UP=1,ARROW_LEFT=2,ARROW_DOWN=3,ARROW_RIGHT=4};
41 #ifndef __HAVE_CommonKeys
42 #define __HAVE_CommonKeys
43 enum CommonKeys{KEY_F1=268,KEY_F2=269,KEY_F3=270,KEY_F4=271,KEY_F5=272,KEY_F6=273,KEY_F7=274,KEY_F8=275,KEY_ESC=264,KEY_QUIT=4360,KEY_APPS=265,KEY_SWITCH=4361,KEY_MODE=266,KEY_BACKSPACE=257,KEY_INS=4353,KEY_CLEAR=263,KEY_VARLNK=4141,KEY_CHAR=4139,KEY_ENTER=13,KEY_ENTRY=4109,KEY_STO=258,KEY_RCL=4354,KEY_SIGN=173,KEY_MATH=4149,KEY_MEM=4150,KEY_ON=267,KEY_OFF=4363};
44 #endif
45 enum GKeyFlags{GKF_NORMAL=0,GKF_MODAL=1,GKF_REPUSH_KEY=2,GKF_ACCEPT=4,GKF_SYS=8,GKF_NO_EVS=16};
46 enum StatKeys{STAT_2ND=1,STAT_DIAMOND=2,STAT_SHIFT=3,STAT_HAND=4};
47 #define OSFastArrows (*((unsigned char*)(_rom_call_addr_hack_concat(0x15C,_ROM_CALL_15C,((unsigned char*)((unsigned long)(*(((short*)(_rom_call_addr(51)))+0x80)))),200,0x508))))
48 #define _keytest_optimized(rowcol...) (__keytest_optimized(rowcol))
49 #define _keytest(rowcol...) (__keytest(rowcol))
50 #define _rowread_internal(row) (~(_rowread(row)))
51 #define _rowread_inverted(row) (_rowread(~((short)(row))))
52 extern unsigned short _rowread(short asm("d0"))__ATTR_LIB_ASM__;
53 #define GKeyDown ({__need_in_use_bit;_rom_call(short,(void),17F);})
54 #define GKeyFlush ({__need_in_use_bit;_rom_call(void,(void),180);})
55 #define GKeyIn ({__need_in_use_bit;_rom_call(short,(SCR_RECT*,short),17E);})
56 #define kbhit ({__need_in_use_bit;_rom_call(short,(void),52);})
57 #define ngetchx ({__need_in_use_bit;_rom_call(short,(void),51);})
58 #define OSGetStatKeys _rom_call(short,(void),299)
59 #define OSInitBetweenKeyDelay(rate) ({short __oldRate=_OSInitBetweenKeyDelay(48);(__oldRate*48-1)/_OSInitBetweenKeyDelay((rate))+1;})
60 #define OSInitKeyInitDelay _rom_call(short,(short),248)
61 #define pushkey ({__need_in_use_bit;_rom_call(void,(short),50);})
62 #define BEGIN_KEYTEST {register short __current_row=RR_NO_KEY;register unsigned short __current_rowread_result=0;
63 #define END_KEYTEST }
64 #if MIN_AMS>=200
65 #define alphaLockOff _rom_call(void,(unsigned char*),482)
66 #define alphaLockOn _rom_call(void,(unsigned char*),481)
67 #define GetAlphaStatus _rom_call(unsigned char,(void),164)
68 #define KeyYesOrNo _rom_call(short,(short),3EB)
69 #define restoreAlphaLock _rom_call(void,(unsigned char*),483)
70 #define SetAlphaStatus _rom_call(void,(char),163)
71 #endif
72 /* End Auto-Generated Part */
73 
74 #define _OSInitBetweenKeyDelay _rom_call(short,(short),249)
75 
76 #endif
77