home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Emulatoren / UAE061.LZH / uae-0.6.1 / include / options.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  6.7 KB  |  303 lines

  1.  /*
  2.   * UAE - The Un*x Amiga Emulator
  3.   *
  4.   * cpp magic
  5.   *
  6.   * Copyright 1995, 1996 Bernd Schmidt, Ed Hanway
  7.   */
  8.  
  9. typedef enum { KBD_LANG_US, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT } KbdLang;
  10.  
  11. extern int framerate;
  12. extern int produce_sound;
  13. extern int correct_aspect;
  14. extern int use_fast_draw;
  15. extern int use_debugger;
  16. extern int use_fast_mem;
  17. extern int use_gfxlib;
  18. extern int use_xhair;
  19. extern int use_lores;
  20. extern int automount_uaedev;
  21. extern int fake_joystick;
  22. extern KbdLang keyboard_lang;
  23. extern int color_mode;
  24. extern int screen_res;
  25.  
  26. #define MAX_COLOR_MODES 5
  27. #define MAX_SCREEN_MODES 4
  28.  
  29. extern void target_specific_usage(void);
  30.  
  31. extern char df0[], df1[], df2[], df3[], romfile[], prtname[]; 
  32.  
  33. #ifndef __unix
  34. extern void parse_cmdline(int argc, char **argv);
  35. #endif
  36.  
  37. #ifdef __mac__
  38. /* Apparently, no memcpy :-/ */
  39. static __inline__ void *memcpy(void *to, void *from, int size)
  40. {
  41.     BlockMove(from, to, size);
  42. }
  43. #endif
  44.  
  45. /* strdup() may be non-portable if you have a weird system */
  46. static char *my_strdup(const char*s)
  47. {
  48.     /* The casts to char * are there to shut up the compiler on HPUX */
  49.     char *x = (char*)malloc(strlen((char *)s) + 1);
  50.     strcpy(x, (char *)s);
  51.     return x;
  52. }
  53.  
  54. #undef REGPARAM
  55. #define fast_memcmp memcmp
  56. #define memcmpy generic_memcmpy
  57.  
  58. static __inline__ int generic_memcmpy(void *foo, const void *bar, int len)
  59. {
  60.     int res = memcmp(foo, bar, len);
  61.     if (res)
  62.     memcpy(foo, bar, len);
  63.     return res;
  64. }
  65.  
  66. #if defined(__GNUC_MINOR__)
  67.  
  68. #ifdef __i386__
  69.  
  70. #define INTEL_FLAG_OPT
  71.  
  72. #undef fast_memcmp
  73. #undef memcmpy
  74.  
  75. static __inline__ int fast_memcmp(const void *foo, const void *bar, int len)
  76. {
  77.     int differs, baz;
  78.     __asm__ __volatile__ ("subl $4, %2\n"
  79.               "jc  2f\n"
  80.               "1:\n"
  81.               "movl (%0),%%ebx\n"
  82.               "cmpl (%1),%%ebx\n"
  83.               "jne 5f\n"
  84.               "addl $4, %0\n"
  85.               "addl $4, %1\n"
  86.               "subl $4, %2\n"
  87.               "jnc  1b\n"
  88.               "2:\n"
  89.               "addl $4, %2\n"
  90.               "jz 4f\n"
  91.               "3:\n"
  92.               "movb (%0),%%bl\n"
  93.               "cmpb (%1),%%bl\n"
  94.               "jne 5f\n"
  95.               "incl %0\n"
  96.               "incl %1\n"
  97.               "decl %2\n"
  98.               "jnz 3b\n"
  99.               "4:\n"
  100.               "movl $0, %3\n"
  101.               "jmp 6f\n"
  102.               "5:\n"
  103.               "movl $1, %3\n"
  104.               "6:\n"
  105.               : "=&r" (foo), "=&r" (bar), "=&rm" (len), "=rm" (differs),
  106.                 "=&b" (baz)
  107.               : "0" (foo), "1" (bar), "2" (len), "3" (baz) : "cc");
  108.     return differs;
  109. }
  110.  
  111. static __inline__ int memcmpy(void *foo, const void *bar, int len)
  112. {
  113.     int differs, baz = 0, uupzuq = 0;
  114.  
  115.     __asm__ __volatile__ ("subl %1, %2\n"
  116.               "movl $0, %0\n"
  117.               "subl $16, %3\n"
  118.               "jc 7f\n"
  119.               
  120.               "8:\n"
  121.               "movl (%1),%%ecx\n"
  122.               "movl (%2,%1),%%ebx\n"
  123.               "xorl %%ebx, %%ecx\n"
  124.               "movl %%ebx, (%1)\n"
  125.               "orl %%ecx, %0\n"
  126.               
  127.               "movl 4(%2,%1),%%ebx\n"
  128.               "movl 4(%1),%%ecx\n"
  129.               "xorl %%ebx, %%ecx\n"
  130.               "movl %%ebx, 4(%1)\n"
  131.               "orl %%ecx, %0\n"
  132.               
  133.               "movl 8(%2,%1),%%ebx\n"
  134.               "movl 8(%1),%%ecx\n"
  135.               "xorl %%ebx, %%ecx\n"
  136.               "movl %%ebx, 8(%1)\n"
  137.               "orl %%ecx, %0\n"
  138.               
  139.               "movl 12(%2,%1),%%ebx\n"
  140.               "movl 12(%1),%%ecx\n"
  141.               "xorl %%ebx, %%ecx\n"
  142.               "movl %%ebx, 12(%1)\n"
  143.               "orl %%ecx, %0\n"
  144.               
  145.               "addl $16, %1\n"
  146.               "subl $16, %3\n"
  147.               "jnc  8b\n"
  148.               
  149.               "7:\n"
  150.               "addl $16, %3\n"
  151.               "subl $4, %3\n"
  152.               "jc  2f\n"
  153.               
  154.               "1:\n"
  155.               "movl (%2,%1),%%ebx\n"
  156.               "movl (%1),%%ecx\n"
  157.               "xorl %%ebx, %%ecx\n"
  158.               "movl %%ebx, (%1)\n"
  159.               "orl %%ecx, %0\n"
  160.               "addl $4, %1\n"
  161.               "subl $4, %3\n"
  162.               "jnc  1b\n"
  163.               
  164.               "2:\n"
  165.               "addl $4, %3\n"
  166.               "jz 6f\n"
  167.               "xorl %%ecx, %%ecx\n"
  168.               
  169.               "3:\n"
  170.               "movb (%2,%1),%%bl\n"
  171.               "movb (%1),%%cl\n"
  172.               "xorl %%bl,%%cl\n"
  173.               "movb %%bl,(%1)\n"
  174.               "orl %%ecx, %0\n"
  175.               "incl %1\n"
  176.               "decl %3\n"
  177.               "jnz 3b\n"
  178.               
  179.               "6:\n"
  180.               : "=m" (differs)
  181.               : "r" (foo), "r" (bar), "r" (len), "b" (baz), "c" (uupzuq) : "cc", "memory");
  182.     /* Now tell the compiler that foo, bar and len have been modified 
  183.      * If someone finds a way to express all this cleaner in constraints that
  184.      * GCC 2.7.2 understands, please FIXME */
  185.     __asm__ __volatile__ ("" : "=rm" (foo), "=rm" (bar), "=rm" (len) : :  "ebx", "ecx", "edx", "eax", "esi", "memory");
  186.  
  187.     return differs;
  188. }
  189. #endif /* __i386__ */
  190.  
  191. #if defined(__mc68000__) /* or better */
  192.  
  193. #define M68K_FLAG_OPT
  194.  
  195. #undef fast_memcmp
  196. #undef memcmpy
  197.  
  198. /*
  199.  * This code for memcmp() is supposed to be faster for m68k processors (takes care
  200.  * about alignment).
  201.  */
  202. static __inline__ int fast_memcmp(const void *foo, const void *bar, int len)
  203. {
  204.     if(len<=3) {
  205.         while(len--) if(*((char*)foo)++ != *((char*)bar)++) goto differs;
  206.         goto equal;
  207.     }
  208.  
  209.     switch(((int)foo) & 3) {
  210.         case 3:
  211.     if(*((char *)foo)++ != *((char *)bar)++) goto differs;
  212.     if(!--len) goto equal;
  213.     break;
  214.  
  215.         case 1:
  216.     if(*((char *)foo)++ != *((char *)bar)++) goto differs;
  217.     if(!--len) goto equal;
  218.     /* fall trough */
  219.     
  220.         case 2:
  221.     if(*((short*)foo)++ != *((short*)bar)++) goto differs;
  222.     if(!(len -= 2)) goto equal;
  223.     break;
  224.     
  225.     case 0:
  226.     break;
  227.     }
  228.    
  229.     if(((int)bar)&3) return memcmp(foo,bar,len);
  230.  
  231.     while((len-=4)>=0) {
  232.     if(*((long*)foo)++ != *((long*)bar)++) goto differs;
  233.     }
  234.     switch(len+=4) {
  235.     case 1: case 3:
  236.     if(*((char *)foo)++ != *((char *)bar)++) goto differs;
  237.     if(len == 1) break;
  238.     /* fall trough */
  239.     
  240.     case 2:
  241.     if(*((short*)foo) != *((short*)bar)) goto differs;
  242.     break;
  243.     }
  244. equal:
  245.     return 0;
  246. differs:
  247.     return 1;
  248. }
  249.  
  250. /*
  251.  * memcmp + memcpy.
  252.  */
  253. static __inline__ int memcmpy(void *foo, const void *bar, short len)
  254. {
  255. /*    if(((int)foo)&1 || ((int)foo)&1) goto notaligned;
  256. */  while((len -= 4) >= 0) if(*((long*)foo)++ != *((long*)bar)++) goto diff4;
  257.     len += 4;
  258. notaligned:
  259.     while(len--) if(*((char*)foo)++ != *((char*)bar)++) {((char*)foo)[-1] = ((char*)bar)[-1];goto diff1;}
  260.     return 0;
  261. diff4:
  262.     ((long*)foo)[-1] = ((long*)bar)[-1];
  263.     while((len-=4) >= 0) *((long*)foo)++ = *((long*)bar)++;
  264.     len += 4;
  265. diff1:
  266.     while(len--) *((char*)foo)++ = *((char*)bar)++;
  267.     return 1;
  268. }
  269. #endif /* __mc68000__ */
  270.  
  271. #if __GNUC__ > 2 || __GNUC_MINOR__ > 6
  272.  
  273. #if defined(__i386__) && !defined(USE_PROFILING)
  274. #define REGPARAM __attribute__((regparm(3)))
  275. #endif /* __i386__ */
  276.  
  277. #if defined(AMIGA) && !defined(USE_PROFILING)
  278. #define REGPARAM __attribute__((regargs(4)))
  279. #endif /* AMIGA */
  280.  
  281. #endif /* GCC version 2.7 or higher */
  282. #endif /* GCC 2 */
  283.  
  284. #ifndef REGPARAM
  285. #define REGPARAM
  286. #endif
  287.  
  288. /*
  289.  * You can specify numbers from 0 to 5 here. It is possible that higher
  290.  * numbers will make the CPU emulation slightly faster, but if the setting
  291.  * is too high, you will run out of memory while compiling.
  292.  * Best to leave this as it is.
  293.  */
  294. #define CPU_EMU_SIZE 0
  295.  
  296. /*
  297.  * CPU level: 0 = 68000, 1 = 68010, 2 = sort of a 68020
  298.  * If configured for 68020, the emulator will be a little slower.
  299.  * Don't touch this: Only 0 will work for now.
  300.  */
  301. #define CPU_LEVEL 0
  302.  
  303.