compat.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #ifndef __COMPAT
  2. #define __COMPAT
  3. #include <default.h>
  4. /* Begin Auto-Generated Part */
  5. #define KEY_DIAMOND (PSEUDO_CONST_KBD(16384,8192))
  6. #define KEY_DOWN (PSEUDO_CONST_KBD(340,344))
  7. #define KEY_DOWNLEFT (PSEUDO_CONST_KBD(342,345))
  8. #define KEY_LEFT (PSEUDO_CONST_KBD(338,337))
  9. #define KEY_OFF2 (PSEUDO_CONST_KBD(16651,8459))
  10. #define KEY_RIGHT (PSEUDO_CONST_KBD(344,340))
  11. #define KEY_SHIFT (PSEUDO_CONST_KBD(8192,16384))
  12. #define KEY_UP (PSEUDO_CONST_KBD(337,338))
  13. #define KEY_UPRIGHT (PSEUDO_CONST_KBD(345,342))
  14. #define LCD_HEIGHT (PSEUDO_CONST_SCREEN(100,128))
  15. #define LCD_LINE_BYTES (PSEUDO_CONST_SCREEN(20,30))
  16. #define LCD_WIDTH (PSEUDO_CONST_SCREEN(160,240))
  17. #define RR_0 (PSEUDO_CONST_KBD(4,9)),(PSEUDO_CONST_KBD(0,5))
  18. #define RR_1 (PSEUDO_CONST_KBD(4,1)),(PSEUDO_CONST_KBD(1,5))
  19. #define RR_2 (PSEUDO_CONST_KBD(3,1)),(PSEUDO_CONST_KBD(1,6))
  20. #define RR_3 (PSEUDO_CONST_KBD(2,1)),(PSEUDO_CONST_KBD(1,7))
  21. #define RR_4 (PSEUDO_CONST_KBD(4,2)),(PSEUDO_CONST_KBD(2,5))
  22. #define RR_5 (PSEUDO_CONST_KBD(3,2)),(PSEUDO_CONST_KBD(2,6))
  23. #define RR_6 2,(PSEUDO_CONST_KBD(2,7))
  24. #define RR_7 (PSEUDO_CONST_KBD(4,3)),(PSEUDO_CONST_KBD(3,5))
  25. #define RR_8 3,(PSEUDO_CONST_KBD(3,6))
  26. #define RR_9 (PSEUDO_CONST_KBD(2,3)),(PSEUDO_CONST_KBD(3,7))
  27. #define RR_2ND 0,(PSEUDO_CONST_KBD(4,0))
  28. #define RR_A (PSEUDO_CONST_KBD(RR_NO_KEY,9)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  29. #define RR_ALPHA (PSEUDO_CONST_KBD(0,RR_NO_KEY)),(PSEUDO_CONST_KBD(7,RR_NO_KEY))
  30. #define RR_APPS (PSEUDO_CONST_KBD(5,7)),(PSEUDO_CONST_KBD(0,6))
  31. #define RR_B (PSEUDO_CONST_KBD(RR_NO_KEY,5)),(PSEUDO_CONST_KBD(RR_NO_KEY,1))
  32. #define RR_BCKSPC (PSEUDO_CONST_KBD(2,8)),(PSEUDO_CONST_KBD(6,0))
  33. #define RR_C (PSEUDO_CONST_KBD(RR_NO_KEY,3)),(PSEUDO_CONST_KBD(RR_NO_KEY,1))
  34. #define RR_CATALOG (PSEUDO_CONST_KBD(3,RR_NO_KEY)),(PSEUDO_CONST_KBD(6,RR_NO_KEY))
  35. #define RR_CLEAR (PSEUDO_CONST_KBD(1,7)),(PSEUDO_CONST_KBD(6,5))
  36. #define RR_COMMA (PSEUDO_CONST_KBD(2,4)),(PSEUDO_CONST_KBD(4,7))
  37. #define RR_COS (PSEUDO_CONST_KBD(RR_NO_KEY,5)),(PSEUDO_CONST_KBD(RR_NO_KEY,6))
  38. #define RR_D (PSEUDO_CONST_KBD(RR_NO_KEY,2)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  39. #define RR_DIAMOND 0,(PSEUDO_CONST_KBD(6,1))
  40. #define RR_DIVIDE (PSEUDO_CONST_KBD(1,5)),(PSEUDO_CONST_KBD(4,0))
  41. #define RR_DOT (PSEUDO_CONST_KBD(3,9)),(PSEUDO_CONST_KBD(0,6))
  42. #define RR_DOWN 0,(PSEUDO_CONST_KBD(2,7))
  43. #define RR_E (PSEUDO_CONST_KBD(RR_NO_KEY,2)),(PSEUDO_CONST_KBD(RR_NO_KEY,3))
  44. #define RR_EE (PSEUDO_CONST_KBD(5,RR_NO_KEY)),(PSEUDO_CONST_KBD(2,RR_NO_KEY))
  45. #define RR_ENTER1 (PSEUDO_CONST_KBD(1,9)),(PSEUDO_CONST_KBD(0,1))
  46. #define RR_ENTER2 (PSEUDO_CONST_KBD(1,6)),(PSEUDO_CONST_KBD(0,6))
  47. #define RR_ENTER RR_ENTER1
  48. #define RR_EQUALS (PSEUDO_CONST_KBD(5,7)),(PSEUDO_CONST_KBD(4,0))
  49. #define RR_ESC (PSEUDO_CONST_KBD(6,8)),(PSEUDO_CONST_KBD(0,6))
  50. #define RR_F1 (PSEUDO_CONST_KBD(5,6)),(PSEUDO_CONST_KBD(7,4))
  51. #define RR_F2 4,(PSEUDO_CONST_KBD(7,4))
  52. #define RR_F3 (PSEUDO_CONST_KBD(3,2)),(PSEUDO_CONST_KBD(7,4))
  53. #define RR_F4 (PSEUDO_CONST_KBD(2,9)),(PSEUDO_CONST_KBD(7,4))
  54. #define RR_F5 (PSEUDO_CONST_KBD(1,7)),(PSEUDO_CONST_KBD(7,4))
  55. #define RR_F6 (PSEUDO_CONST_KBD(RR_NO_KEY,5)),(PSEUDO_CONST_KBD(RR_NO_KEY,4))
  56. #define RR_F7 (PSEUDO_CONST_KBD(RR_NO_KEY,3)),(PSEUDO_CONST_KBD(RR_NO_KEY,4))
  57. #define RR_F8 (PSEUDO_CONST_KBD(RR_NO_KEY,1)),(PSEUDO_CONST_KBD(RR_NO_KEY,4))
  58. #define RR_F (PSEUDO_CONST_KBD(RR_NO_KEY,3)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  59. #define RR_G (PSEUDO_CONST_KBD(RR_NO_KEY,4)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  60. #define RR_H (PSEUDO_CONST_KBD(RR_NO_KEY,5)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  61. #define RR_HAND (PSEUDO_CONST_KBD(RR_NO_KEY,0)),(PSEUDO_CONST_KBD(RR_NO_KEY,3))
  62. #define RR_HOME (PSEUDO_CONST_KBD(5,RR_NO_KEY)),(PSEUDO_CONST_KBD(6,RR_NO_KEY))
  63. #define RR_I (PSEUDO_CONST_KBD(RR_NO_KEY,7)),(PSEUDO_CONST_KBD(RR_NO_KEY,3))
  64. #define RR_J (PSEUDO_CONST_KBD(RR_NO_KEY,6)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  65. #define RR_K (PSEUDO_CONST_KBD(RR_NO_KEY,7)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  66. #define RR_L (PSEUDO_CONST_KBD(RR_NO_KEY,8)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  67. #define RR_LEFT 0,(PSEUDO_CONST_KBD(1,4))
  68. #define RR_LN (PSEUDO_CONST_KBD(RR_NO_KEY,6)),(PSEUDO_CONST_KBD(RR_NO_KEY,5))
  69. #define RR_M (PSEUDO_CONST_KBD(RR_NO_KEY,7)),(PSEUDO_CONST_KBD(RR_NO_KEY,1))
  70. #define RR_MINUS (PSEUDO_CONST_KBD(1,9)),(PSEUDO_CONST_KBD(2,0))
  71. #define RR_MODE (PSEUDO_CONST_KBD(4,8)),(PSEUDO_CONST_KBD(6,5))
  72. #define RR_MULTIPLY (PSEUDO_CONST_KBD(1,7)),(PSEUDO_CONST_KBD(3,7))
  73. #define RR_N (PSEUDO_CONST_KBD(RR_NO_KEY,6)),(PSEUDO_CONST_KBD(RR_NO_KEY,1))
  74. #define RR_NEGATE (PSEUDO_CONST_KBD(2,9)),(PSEUDO_CONST_KBD(0,7))
  75. #define RR_NO_KEY 0xF
  76. #define RR_O (PSEUDO_CONST_KBD(RR_NO_KEY,8)),(PSEUDO_CONST_KBD(RR_NO_KEY,3))
  77. #define RR_P (PSEUDO_CONST_KBD(RR_NO_KEY,6)),(PSEUDO_CONST_KBD(RR_NO_KEY,7))
  78. #define RR_PAREN_CLOSE (PSEUDO_CONST_KBD(3,4)),(PSEUDO_CONST_KBD(4,6))
  79. #define RR_PAREN_OPEN 4,(PSEUDO_CONST_KBD(4,5))
  80. #define RR_PLUS (PSEUDO_CONST_KBD(1,8)),(PSEUDO_CONST_KBD(1,4))
  81. #define RR_POWER (PSEUDO_CONST_KBD(1,6)),(PSEUDO_CONST_KBD(5,0))
  82. #define RR_Q (PSEUDO_CONST_KBD(RR_NO_KEY,9)),(PSEUDO_CONST_KBD(RR_NO_KEY,3))
  83. #define RR_R (PSEUDO_CONST_KBD(RR_NO_KEY,3)),(PSEUDO_CONST_KBD(RR_NO_KEY,3))
  84. #define RR_RIGHT 0,(PSEUDO_CONST_KBD(3,6))
  85. #define RR_S (PSEUDO_CONST_KBD(RR_NO_KEY,1)),(PSEUDO_CONST_KBD(RR_NO_KEY,2))
  86. #define RR_SHIFT 0,(PSEUDO_CONST_KBD(5,2))
  87. #define RR_SIN (PSEUDO_CONST_KBD(RR_NO_KEY,5)),(PSEUDO_CONST_KBD(RR_NO_KEY,5))
  88. #define RR_SPACE (PSEUDO_CONST_KBD(RR_NO_KEY,4)),(PSEUDO_CONST_KBD(RR_NO_KEY,0))
  89. #define RR_STORE (PSEUDO_CONST_KBD(5,3)),(PSEUDO_CONST_KBD(1,0))
  90. #define RR_T (PSEUDO_CONST_KBD(2,4)),(PSEUDO_CONST_KBD(5,3))
  91. #define RR_TAN (PSEUDO_CONST_KBD(RR_NO_KEY,5)),(PSEUDO_CONST_KBD(RR_NO_KEY,7))
  92. #define RR_THETA (PSEUDO_CONST_KBD(RR_NO_KEY,8)),(PSEUDO_CONST_KBD(RR_NO_KEY,1))
  93. #define RR_U (PSEUDO_CONST_KBD(RR_NO_KEY,6)),(PSEUDO_CONST_KBD(RR_NO_KEY,3))
  94. #define RR_UP 0,(PSEUDO_CONST_KBD(0,5))
  95. #define RR_V (PSEUDO_CONST_KBD(RR_NO_KEY,4)),(PSEUDO_CONST_KBD(RR_NO_KEY,1))
  96. #define RR_W (PSEUDO_CONST_KBD(RR_NO_KEY,1)),(PSEUDO_CONST_KBD(RR_NO_KEY,3))
  97. #define RR_WITH (PSEUDO_CONST_KBD(5,RR_NO_KEY)),(PSEUDO_CONST_KBD(3,RR_NO_KEY))
  98. #define RR_X (PSEUDO_CONST_KBD(5,2)),(PSEUDO_CONST_KBD(5,1))
  99. #define RR_Y (PSEUDO_CONST_KBD(4,5)),(PSEUDO_CONST_KBD(5,3))
  100. #define RR_Z (PSEUDO_CONST_KBD(3,1)),(PSEUDO_CONST_KBD(5,1))
  101. #define TI89_CLASSIC (TI89&&HW_VERSION<3)
  102. #define TI89_TITANIUM (TI89&&HW_VERSION>=3)
  103. #define TI89 (CALCULATOR==0)
  104. #define TI92PLUS (CALCULATOR==1)
  105. #define V200 (CALCULATOR==3)
  106. #define PSEUDO_CONST_CALC(calc92,calc89,calc92plus,calcv200) (CALCULATOR?((CALCULATOR==1)?(calc92plus):(calcv200)):(calc89))
  107. #define PSEUDO_CONST_KBD(kbd89,kbd92) PSEUDO_CONST_CALC(kbd92,kbd89,kbd92,kbd92)
  108. #define PSEUDO_CONST_SCREEN(screen89,screen92) PSEUDO_CONST_CALC(screen92,screen89,screen92,screen92)
  109. /* End Auto-Generated Part */
  110. #ifdef DOORS
  111. #define _CALCULATOR _ram_call (0,const unsigned char*)
  112. #define HW_VERSION ((unsigned short)(_CALCULATOR[1]))
  113. #else /* !DOORS */
  114. unsigned short __get_hw_version(void) __attribute__((const));
  115. #define HW_VERSION (__get_hw_version())
  116. #endif /* !DOORS */
  117. #if defined (_TI89_ONLY)
  118. #define ROM_base ((void*)(((unsigned long)__jmp_tbl)&0xE00000))
  119. #define CALCULATOR 0
  120. #elif defined (_TI92PLUS_ONLY)
  121. #define ROM_base ((void*)0x400000)
  122. #define CALCULATOR 1
  123. #elif defined (_V200_ONLY)
  124. #define ROM_base ((void*)(((unsigned long)__jmp_tbl)&0xE00000))
  125. #define CALCULATOR 3
  126. #else /* not only one calculator */
  127. #ifdef DOORS
  128. #define ROM_base _ram_call (3,const void*)
  129. /* PreOs 0.70 says CALCULATOR is -1 on the Titanium. We don't. */
  130. #define CALCULATOR ((signed char)_CALCULATOR[0]>0?_CALCULATOR[0]:0)
  131. #undef LCD_WIDTH
  132. #define LCD_WIDTH _ram_call (1,unsigned long)
  133. #undef LCD_HEIGHT
  134. #define LCD_HEIGHT _ram_call (2,unsigned long)
  135. #undef LCD_LINE_BYTES
  136. #define LCD_LINE_BYTES _ram_call (4,unsigned long)
  137. #undef KEY_LEFT
  138. #define KEY_LEFT _ram_call (5,unsigned long)
  139. #undef KEY_RIGHT
  140. #define KEY_RIGHT _ram_call (6,unsigned long)
  141. #undef KEY_UP
  142. #define KEY_UP _ram_call (7,unsigned long)
  143. #undef KEY_DOWN
  144. #define KEY_DOWN _ram_call (8,unsigned long)
  145. #undef KEY_UPRIGHT
  146. #define KEY_UPRIGHT _ram_call (9,unsigned long)
  147. #undef KEY_DOWNLEFT
  148. #define KEY_DOWNLEFT _ram_call (A,unsigned long)
  149. #undef KEY_DIAMOND
  150. #define KEY_DIAMOND _ram_call (B,unsigned long)
  151. #undef KEY_SHIFT
  152. #define KEY_SHIFT _ram_call (D,unsigned long)
  153. #else /* !DOORS */
  154. #define ROM_base ((void*)(((unsigned long)__jmp_tbl)&0xE00000))
  155. #ifdef NO_CALC_DETECT
  156. #ifdef USE_V200
  157. #define CALCULATOR (ROM_base==(void*)0x400000?1:(((unsigned char*)(_rom_call_addr(2F)))[2]>=200?3:0))
  158. #else
  159. #define CALCULATOR (ROM_base==(void*)0x400000)
  160. #endif
  161. #else /* !NO_CALC_DETECT */
  162. extern const short __calculator;
  163. #ifdef USE_TI89
  164. #define CALCULATOR (__calculator)
  165. #else /* !USE_TI89 */
  166. /* Special optimization: __calculator cannot be 0 */
  167. #define CALCULATOR (__calculator==3?3:1)
  168. #endif /* !USE_TI89 */
  169. #endif /* !NO_CALC_DETECT */
  170. #endif /* !DOORS */
  171. #ifdef OPTIMIZE_CALC_CONSTS
  172. #undef PSEUDO_CONST_CALC
  173. #define PSEUDO_CONST_CALC(calc92,calc89,calc92plus,calcv200) ({extern void __ld_calc_const_##calc92##_##calc89##_##calc92plus##_##calcv200;(unsigned short)&__ld_calc_const_##calc92##_##calc89##_##calc92plus##_##calcv200;})
  174. #endif /* OPTIMIZE_CALC_CONSTS */
  175. #endif /* not only one calculator */
  176. #pragma GCC poison TI92
  177. //#define TI92 (CALCULATOR==2)
  178. #endif