default.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef __DEFAULT
  2. #define __DEFAULT
  3. #ifdef USE_TI92P
  4. #define USE_TI92PLUS
  5. #endif
  6. #if !defined (USE_TI89) && !defined (USE_TI92PLUS) && !defined (USE_V200)
  7. #define USE_TI89
  8. #define USE_TI92PLUS
  9. #define USE_V200
  10. #elif defined(USE_TI89) && !defined (USE_TI92PLUS) && !defined (USE_V200)
  11. #define _TI89_ONLY
  12. #define _ONE_CALC_ONLY
  13. #elif !defined(USE_TI89) && defined (USE_TI92PLUS) && !defined (USE_V200)
  14. #define _TI92PLUS_ONLY
  15. #define _ONE_CALC_ONLY
  16. #elif !defined(USE_TI89) && !defined (USE_TI92PLUS) && defined (USE_V200)
  17. #define _V200_ONLY
  18. #define _ONE_CALC_ONLY
  19. #endif
  20. #if defined (USE_TI89) && defined (USE_TI92PLUS) && defined (USE_V200)
  21. #define _SUPPORT_ALL_CALCS
  22. #endif
  23. #ifdef DOORS
  24. #define USE_KERNEL
  25. #endif
  26. #if defined(EXECUTE_IN_GHOST_SPACE) && defined(USE_KERNEL)
  27. #error EXECUTE_IN_GHOST_SPACE does not work in kernel mode yet
  28. #endif
  29. #if !defined (NO_CALC_DETECT) && (!defined (USE_KERNEL) || !defined (_SUPPORT_ALL_CALCS))
  30. #define _NEED_CALC_DETECT
  31. #ifdef _ONE_CALC_ONLY
  32. #ifdef USE_TI89
  33. #define _CALC_NUM 0
  34. #endif
  35. #ifdef USE_TI92PLUS
  36. #define _CALC_NUM 1
  37. #endif
  38. #ifdef USE_V200
  39. #define _CALC_NUM 3
  40. #endif
  41. #else
  42. #ifndef _SUPPORT_ALL_CALCS
  43. #ifndef USE_TI89
  44. #define _CALC_NUM 0
  45. #endif
  46. #ifndef USE_TI92PLUS
  47. #define _CALC_NUM 1
  48. #endif
  49. #ifndef USE_V200
  50. #define _CALC_NUM 3
  51. #endif
  52. #endif
  53. #endif
  54. #endif
  55. #if !defined (_ONE_CALC_ONLY) && !defined (USE_KERNEL)
  56. #define _NEED_CALC_VAR
  57. #endif
  58. #define __ATTR_STD__ __attribute__((__stkparm__))
  59. #define __ATTR_STD_NORETURN__ __attribute__((__stkparm__,__noreturn__))
  60. #define CALLBACK __ATTR_STD__
  61. #define __ATTR_TIOS__ __ATTR_STD__
  62. #define __ATTR_TIOS_NORETURN__ __ATTR_STD_NORETURN__
  63. #define __ATTR_TIOS_CALLBACK__ CALLBACK
  64. #define __ATTR_GCC__
  65. #define __ATTR_LIB_C__ __attribute__((__regparm__(1)))
  66. #define __ATTR_LIB_ASM__ __ATTR_STD__
  67. #define __ATTR_LIB_ASM_NORETURN__ __ATTR_STD_NORETURN__
  68. #define __ATTR_LIB_CALLBACK_C__ CALLBACK
  69. #define __ATTR_LIB_CALLBACK_ASM__ CALLBACK
  70. #define __jmp_tbl (*(void***)0xC8)
  71. //#define _rom_call(type,args,index) (*((type(*__ATTR_TIOS__)args)(_rom_call_addr_concat(0x##index,_ROM_CALL_##index))))
  72. //#define _rom_call_addr(index) _rom_call_addr_concat(0x##index,_ROM_CALL_##index)
  73. //#define _rom_call_addr_concat(intindex,romindex) (__jmp_tbl[intindex])
  74. #define _rom_call(t,a,i) (*((t(*__ATTR_TIOS__)a)(__jmp_tbl[0x##i])))
  75. #define _rom_call_addr(i) (__jmp_tbl[0x##i])
  76. #define offsetof(t,m) ((unsigned long)&(((t*)0)->m))
  77. #define OFFSETOF offsetof
  78. #define import_binary(f,i) asm { i: incbin f };
  79. #ifdef _GENERIC_ARCHIVE
  80. #undef OPTIMIZE_ROM_CALLS
  81. #undef USE_FLINE_ROM_CALLS
  82. #undef USE_INTERNAL_FLINE_EMULATOR
  83. #endif
  84. #ifndef MIN_AMS
  85. #define MIN_AMS 101
  86. #endif
  87. #ifdef USE_FLINE_ROM_CALLS
  88. #if !defined (USE_FLINE_EMULATOR) && !defined (USE_INTERNAL_FLINE_EMULATOR)
  89. #if MIN_AMS<204
  90. #error You need to define USE_[INTERNAL_]FLINE_EMULATOR
  91. #endif
  92. #endif
  93. //#error _INCLUDE_PATCH(fline_rom_calls);
  94. #endif
  95. #define TIOS_entries (*(unsigned long*)(__jmp_tbl-1))
  96. #ifdef DOORS
  97. #define AMS_1xx ((ROM_VERSION&0x0F00)==0x100)
  98. #define AMS_2xx ((ROM_VERSION&0x0F00)==0x200)
  99. #else
  100. #define AMS_1xx (TIOS_entries<1000)
  101. #define AMS_2xx (TIOS_entries>1000)
  102. #endif
  103. typedef short *__pshort;
  104. typedef unsigned short *__pushort;
  105. typedef long *__plong;
  106. typedef unsigned long *__pulong;
  107. //extern float __BC()__ATTR_LIB_ASM__;
  108. //#define _tios_float_1(f,x,t) ({typedef float(*__temp__type__)(short,t)__ATTR_LIB_ASM__;((__temp__type__)__BC)(4*0x##f,x);})
  109. //#define _tios_float_2(f,x,y,t1,t2) ({typedef //float(*__temp__type__)(short,t1,t2)__ATTR_LIB_ASM__;((__temp__type__)__BC)(4*0x##f,x,y);})
  110. #if !defined (NOSTUB) && !defined (DOORS)
  111. #ifdef USE_KERNEL
  112. #include <doors.h>
  113. #else
  114. #include <nostub.h>
  115. #endif
  116. #endif
  117. #endif