kbd.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __KBD
  2. #define __KBD
  3. #include <default.h>
  4. /* We have to use this internal macro since _keytest needs to be able to
  5. accept single parameters (in particular, the RR_... constant pairs). */
  6. #define __keytest(row,col) (!!(_rowread_inverted(1<<(row))&(1<<(col))))
  7. /* If you can read the macro below, you must be a really good C programmer.
  8. But I hope I can make it understandable:
  9. __current_row and __current_rowread_result are defined by BEGIN_KEYTEST
  10. and initialized to dummy values.
  11. The definition is sort of the same as the one above, but
  12. _rowread_inverted (1 << (row))
  13. is replaced with
  14. (__current_row == row ? __current_rowread_result : (__current_row = row, __current_rowread_result = _rowread_inverted (1 << (row))))
  15. So,
  16. if the row which was read the last time this macro was called equals the
  17. one that is to be read now,
  18. then use the last result in place of _rowread_inverted (1 << (row)),
  19. otherwise
  20. set __current_row,
  21. set __current_rowread_result by calling _rowread_inverted,
  22. and also return this value
  23. (see the section in the doc about the ',' operator). */
  24. #define __keytest_optimized(row,col) (!!((__current_row==((short)(row))?__current_rowread_result:(__current_row=((short)(row)),__current_rowread_result=_rowread_inverted(1<<(row))))&(1<<(col))))
  25. /* Begin Auto-Generated Part */
  26. #define KB_AUTOREPEAT (1<<11)
  27. #define NULL ((void*)0)
  28. #ifndef __HAVE_Bool
  29. #define __HAVE_Bool
  30. enum Bool{FALSE,TRUE};
  31. #endif
  32. #ifndef __HAVE_SCR_RECT
  33. #define __HAVE_SCR_RECT
  34. typedef union{struct{unsigned char x0,y0,x1,y1;}xy;unsigned long l;}SCR_RECT;
  35. #endif
  36. enum Arrows{ARROW_UP=1,ARROW_LEFT=2,ARROW_DOWN=3,ARROW_RIGHT=4};
  37. #ifndef __HAVE_CommonKeys
  38. #define __HAVE_CommonKeys
  39. 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};
  40. #endif
  41. enum GKeyFlags{GKF_NORMAL=0,GKF_MODAL=1,GKF_REPUSH_KEY=2,GKF_ACCEPT=4,GKF_SYS=8,GKF_NO_EVS=16};
  42. enum StatKeys{STAT_2ND=1,STAT_DIAMOND=2,STAT_SHIFT=3,STAT_HAND=4};
  43. #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))))
  44. #define _keytest_optimized(rowcol...) (__keytest_optimized(rowcol))
  45. #define _keytest(rowcol...) (__keytest(rowcol))
  46. #define _rowread_internal(row) (~(_rowread(row)))
  47. #define _rowread_inverted(row) (_rowread(~((short)(row))))
  48. extern unsigned short _rowread(short asm("d0"))__ATTR_LIB_ASM__;
  49. #define GKeyDown ({__need_in_use_bit;_rom_call(short,(void),17F);})
  50. #define GKeyFlush ({__need_in_use_bit;_rom_call(void,(void),180);})
  51. #define GKeyIn ({__need_in_use_bit;_rom_call(short,(SCR_RECT*,short),17E);})
  52. #define kbhit ({__need_in_use_bit;_rom_call(short,(void),52);})
  53. #define ngetchx ({__need_in_use_bit;_rom_call(short,(void),51);})
  54. #define OSGetStatKeys _rom_call(short,(void),299)
  55. #define OSInitBetweenKeyDelay(rate) ({short __oldRate=_OSInitBetweenKeyDelay(48);(__oldRate*48-1)/_OSInitBetweenKeyDelay((rate))+1;})
  56. #define OSInitKeyInitDelay _rom_call(short,(short),248)
  57. #define pushkey ({__need_in_use_bit;_rom_call(void,(short),50);})
  58. #define BEGIN_KEYTEST {register short __current_row=RR_NO_KEY;register unsigned short __current_rowread_result=0;
  59. #define END_KEYTEST }
  60. #if MIN_AMS>=200
  61. #define alphaLockOff _rom_call(void,(unsigned char*),482)
  62. #define alphaLockOn _rom_call(void,(unsigned char*),481)
  63. #define GetAlphaStatus _rom_call(unsigned char,(void),164)
  64. #define KeyYesOrNo _rom_call(short,(short),3EB)
  65. #define restoreAlphaLock _rom_call(void,(unsigned char*),483)
  66. #define SetAlphaStatus _rom_call(void,(char),163)
  67. #endif
  68. /* End Auto-Generated Part */
  69. #define _OSInitBetweenKeyDelay _rom_call(short,(short),249)
  70. #endif