Mercurial > hg > early-roguelike
annotate arogue7/mdport.c @ 125:adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
| author | John "Elwin" Edwards | 
|---|---|
| date | Fri, 08 May 2015 15:24:40 -0400 | 
| parents | |
| children | b786053d2f37 | 
| rev | line source | 
|---|---|
| 
125
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
1 /* | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
2 mdport.c - Machine Dependent Code for Porting Unix/Curses games | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
3 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
4 Copyright (C) 2005 Nicholas J. Kisseberth | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
5 All rights reserved. | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
6 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
7 Redistribution and use in source and binary forms, with or without | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
8 modification, are permitted provided that the following conditions | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
9 are met: | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
10 1. Redistributions of source code must retain the above copyright | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
11 notice, this list of conditions and the following disclaimer. | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
12 2. Redistributions in binary form must reproduce the above copyright | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
13 notice, this list of conditions and the following disclaimer in the | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
14 documentation and/or other materials provided with the distribution. | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
15 3. Neither the name(s) of the author(s) nor the names of other contributors | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
16 may be used to endorse or promote products derived from this software | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
17 without specific prior written permission. | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
18 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
22 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
25 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
26 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
27 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
28 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
29 SUCH DAMAGE. | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
30 */ | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
31 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
32 #if defined(_WIN32) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
33 #include <Windows.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
34 #include <Lmcons.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
35 #include <process.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
36 #include <shlobj.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
37 #include <Shlwapi.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
38 #include <sys/types.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
39 #undef MOUSE_MOVED | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
40 #elif defined(__DJGPP__) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
41 #include <process.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
42 #else | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
43 #include <pwd.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
44 #include <sys/utsname.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
45 #include <unistd.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
46 #endif | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
47 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
48 #include <stdlib.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
49 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
50 #if defined(_WIN32) && !defined(__MINGW32__) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
51 #define PATH_MAX _PATH_MAX | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
52 #endif | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
53 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
54 #include <curses.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
55 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
56 #if defined(__INTERIX) || defined(__MSYS__) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
57 #include <term.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
58 #else | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
59 #ifdef NCURSES_VERSION | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
60 #include <ncurses/term.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
61 #endif | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
62 #endif | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
63 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
64 #include <stdio.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
65 #include <fcntl.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
66 #include <limits.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
67 #include <sys/stat.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
68 #include <signal.h> | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
69 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
70 #define MOD_MOVE(c) (toupper(c) ) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
71 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
72 void | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
73 md_init() | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
74 { | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
75 #ifdef __INTERIX | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
76 char *term; | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
77 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
78 term = getenv("TERM"); | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
79 | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
80 if (term == NULL) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
81 setenv("TERM","interix"); | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
82 #endif | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
83 #if defined(__DJGPP__) || defined(_WIN32) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
84 _fmode = _O_BINARY; | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
85 #endif | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
86 #if defined(__CYGWIN__) || defined(__MSYS__) | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
87 ESCDELAY=250; | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
88 #endif | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards 
parents:  
diff
changeset
 | 
89 } | 
| 
 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 
John "Elwin" Edwards  | 
