|
|
1.1 root 1: /*
2: * UAE - The Un*x Amiga Emulator
3: *
4: * cpp magic
5: *
6: * Copyright 1995, 1996 Bernd Schmidt, Ed Hanway
7: */
8:
9: #define UAEMAJOR 0
10: #define UAEMINOR 6
11: #define UAEURSAMINOR 4
12:
13: typedef enum { KBD_LANG_US, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT } KbdLang;
14:
15: extern int version;
16: extern int framerate;
17: extern int produce_sound;
18: extern int correct_aspect;
19: extern int use_fast_draw;
20: extern int use_debugger;
21: extern int use_serial;
22: extern int illegal_mem;
23: extern int use_fast_mem;
24: extern int use_gfxlib;
25: extern int no_xhair;
26: extern int use_lores;
27: extern int automount_uaedev;
28: extern int fake_joystick;
29: extern KbdLang keyboard_lang;
30: extern int color_mode;
31: extern int screen_res;
32: extern int sound_desired_bits;
33: extern int sound_desired_freq;
34: extern int sound_desired_bsiz;
35: extern int allow_save;
36: extern int no_gui;
37: extern long hardfile_size;
38:
39: /* Contains the filename of .uaerc */
40: extern char optionsfile[];
41:
42: /* AIX doesn't think it is Unix. Neither do I. */
43: #if defined(_ALL_SOURCE) || defined(_AIX)
44: #undef __unix
45: #define __unix
46: #endif
47:
48: #define MAX_COLOR_MODES 5
49: #define MAX_SCREEN_MODES 4
50:
51: extern void target_specific_usage(void);
52:
53: extern char df0[], df1[], df2[], df3[], romfile[], prtname[], sername[];
54:
55: #ifndef __unix
56: extern void parse_cmdline(int argc, char **argv);
57: #endif
58:
59: #ifdef __mac__
60: /* Apparently, no memcpy :-/ */
61: static __inline__ void *memcpy(void *to, void *from, int size)
62: {
63: BlockMove(from, to, size);
64: }
65: #endif
66:
67: /* strdup() may be non-portable if you have a weird system */
68: static char *my_strdup(const char*s)
69: {
70: /* The casts to char * are there to shut up the compiler on HPUX */
71: char *x = (char*)malloc(strlen((char *)s) + 1);
72: strcpy(x, (char *)s);
73: return x;
74: }
75:
76: #undef REGPARAM
77: #define fast_memcmp memcmp
78: #define memcmpy generic_memcmpy
79:
80: static __inline__ int generic_memcmpy(void *foo, const void *bar, int len)
81: {
82: int res = memcmp(foo, bar, len);
83: if (res)
84: memcpy(foo, bar, len);
85: return res;
86: }
87:
88: #if defined(__GNUC_MINOR__)
89:
90: #ifdef __i386__
91:
92: #define INTEL_FLAG_OPT
93:
94: #undef fast_memcmp
95: #undef memcmpy
96:
97: /*
98: * Careful: These inline functions may be used only _once_. We'd want to
99: * generate unique labels for each inline function, but unfortunately not each
100: * installation of GCC comes with GAS. Bletch.
101: */
102:
103: static __inline__ int fast_memcmp(const void *foo, const void *bar, int len)
104: {
105: int differs, baz;
106: __asm__ __volatile__ ("subl $4, %2\n"
107: "jc LLA2\n"
108: "LLA1:\n"
109: "movl (%0),%%ebx\n"
110: "cmpl (%1),%%ebx\n"
111: "jne LLA5\n"
112: "addl $4, %0\n"
113: "addl $4, %1\n"
114: "subl $4, %2\n"
115: "jnc LLA1\n"
116: "LLA2:\n"
117: "addl $4, %2\n"
118: "jz LLA4\n"
119: "LLA3:\n"
120: "movb (%0),%%bl\n"
121: "cmpb (%1),%%bl\n"
122: "jne LLA5\n"
123: "incl %0\n"
124: "incl %1\n"
125: "decl %2\n"
126: "jnz LLA3\n"
127: "LLA4:\n"
128: "movl $0, %3\n"
129: "jmp LLA6\n"
130: "LLA5:\n"
131: "movl $1, %3\n"
132: "LLA6:\n"
133: : "=&r" (foo), "=&r" (bar), "=&rm" (len), "=rm" (differs),
134: "=&b" (baz)
135: : "0" (foo), "1" (bar), "2" (len), "3" (baz) : "cc");
136: return differs;
137: }
138:
139: static __inline__ int memcmpy(void *foo, const void *bar, int len)
140: {
141: int differs, baz = 0, uupzuq = 0;
142:
143: __asm__ __volatile__ ("subl %1, %2\n"
144: "movl $0, %0\n"
145: "subl $16, %3\n"
146: "jc LLB7\n"
147:
148: "LLB8:\n"
149: "movl (%1),%%ecx\n"
150: "movl (%2,%1),%%ebx\n"
151: "xorl %%ebx, %%ecx\n"
152: "movl %%ebx, (%1)\n"
153: "orl %%ecx, %0\n"
154:
155: "movl 4(%2,%1),%%ebx\n"
156: "movl 4(%1),%%ecx\n"
157: "xorl %%ebx, %%ecx\n"
158: "movl %%ebx, 4(%1)\n"
159: "orl %%ecx, %0\n"
160:
161: "movl 8(%2,%1),%%ebx\n"
162: "movl 8(%1),%%ecx\n"
163: "xorl %%ebx, %%ecx\n"
164: "movl %%ebx, 8(%1)\n"
165: "orl %%ecx, %0\n"
166:
167: "movl 12(%2,%1),%%ebx\n"
168: "movl 12(%1),%%ecx\n"
169: "xorl %%ebx, %%ecx\n"
170: "movl %%ebx, 12(%1)\n"
171: "orl %%ecx, %0\n"
172:
173: "addl $16, %1\n"
174: "subl $16, %3\n"
175: "jnc LLB8\n"
176:
177: "LLB7:\n"
178: "addl $16, %3\n"
179: "subl $4, %3\n"
180: "jc LLB2\n"
181:
182: "LLB1:\n"
183: "movl (%2,%1),%%ebx\n"
184: "movl (%1),%%ecx\n"
185: "xorl %%ebx, %%ecx\n"
186: "movl %%ebx, (%1)\n"
187: "orl %%ecx, %0\n"
188: "addl $4, %1\n"
189: "subl $4, %3\n"
190: "jnc LLB1\n"
191:
192: "LLB2:\n"
193: "addl $4, %3\n"
194: "jz LLB6\n"
195: "xorl %%ecx, %%ecx\n"
196:
197: "LLB3:\n"
198: "movb (%2,%1),%%bl\n"
199: "movb (%1),%%cl\n"
200: "xorb %%bl,%%cl\n"
201: "movb %%bl,(%1)\n"
202: "orl %%ecx, %0\n"
203: "incl %1\n"
204: "decl %3\n"
205: "jnz LLB3\n"
206:
207: "LLB6:\n"
208: : "=m" (differs)
209: : "r" (foo), "r" (bar), "r" (len), "b" (baz), "c" (uupzuq) : "cc", "memory");
210: /* Now tell the compiler that foo, bar and len have been modified
211: * If someone finds a way to express all this cleaner in constraints that
212: * GCC 2.7.2 understands, please FIXME */
213: __asm__ __volatile__ ("" : "=rm" (foo), "=rm" (bar), "=rm" (len) : : "ebx", "ecx", "edx", "eax", "esi", "memory");
214:
215: return differs;
216: }
217: #endif /* __i386__ */
218:
219: #if __GNUC__ > 2 || __GNUC_MINOR__ > 6
220:
221: #if defined(__i386__) && !defined(USE_PROFILING)
222: #define REGPARAM __attribute__((regparm(3)))
223: #endif /* __i386__ */
224:
225: #endif /* GCC version 2.7 or higher */
226: #endif /* GCC 2 */
227:
228: #ifndef REGPARAM
229: #define REGPARAM
230: #endif
231:
232: /*
233: * You can specify numbers from 0 to 5 here. It is possible that higher
234: * numbers will make the CPU emulation slightly faster, but if the setting
235: * is too high, you will run out of memory while compiling.
236: * Best to leave this as it is.
237: */
238: #define CPU_EMU_SIZE 0
239:
240: #ifdef DONT_WANT_SOUND
241: #undef LINUX_SOUND
242: #undef AF_SOUND
243: #undef SOLARIS_SOUND
244: #undef SGI_SOUND
245: #endif
246:
247: /* #define NEED_TO_DEBUG_BADLY */
248:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.