1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
23 /* values for InitCounter() and Counter() */
24 #define INIT_COUNTER 0
25 #define READ_COUNTER 1
27 /* values for InitRND() */
28 #define NEW_RANDOMIZE -1
30 #define InitEngineRND(seed) init_random_number(0, seed)
31 #define InitSimpleRND(seed) init_random_number(1, seed)
32 #define RND(max) get_random_number(0, max)
33 #define SimpleRND(max) get_random_number(1, max)
35 /* values for Error() */
37 #define ERR_RETURN_LINE (1 << 0)
38 #define ERR_WARN (1 << 1)
39 #define ERR_EXIT (1 << 2)
40 #define ERR_HELP (1 << 3)
41 #define ERR_SOUND_SERVER (1 << 4)
42 #define ERR_NETWORK_SERVER (1 << 5)
43 #define ERR_NETWORK_CLIENT (1 << 6)
44 #define ERR_FROM_SERVER (ERR_SOUND_SERVER | ERR_NETWORK_SERVER)
45 #define ERR_EXIT_HELP (ERR_EXIT | ERR_HELP)
46 #define ERR_EXIT_SOUND_SERVER (ERR_EXIT | ERR_SOUND_SERVER)
47 #define ERR_EXIT_NETWORK_SERVER (ERR_EXIT | ERR_NETWORK_SERVER)
48 #define ERR_EXIT_NETWORK_CLIENT (ERR_EXIT | ERR_NETWORK_CLIENT)
50 /* values for getFile...() and putFile...() */
51 #define BYTE_ORDER_BIG_ENDIAN 0
52 #define BYTE_ORDER_LITTLE_ENDIAN 1
54 /* values for cursor bitmap creation */
55 #define BIT_ORDER_MSB 0
56 #define BIT_ORDER_LSB 1
58 /* values for createDirectory() */
59 #define PERMS_PRIVATE 0
60 #define PERMS_PUBLIC 1
62 /* values for general file handling stuff */
63 #define MAX_FILENAME_LEN 256
64 #define MAX_LINE_LEN 1024
66 /* values for general username handling stuff */
67 #define MAX_USERNAME_LEN 1024
70 void fprintf_line(FILE *, char *, int);
71 void printf_line(char *, int);
72 void printf_line_with_prefix(char *, char *, int);
73 char *int2str(int, int);
74 char *i_to_a(unsigned int);
75 int log_2(unsigned int);
77 void InitCounter(void);
78 unsigned long Counter(void);
79 void Delay(unsigned long);
80 boolean FrameReached(unsigned long *, unsigned long);
81 boolean DelayReached(unsigned long *, unsigned long);
82 void WaitUntilDelayReached(unsigned long *, unsigned long);
84 unsigned int init_random_number(int, long);
85 unsigned int get_random_number(int, int);
87 char *getLoginName(void);
88 char *getRealName(void);
90 char *getBasePath(char *);
91 char *getBaseName(char *);
92 char *getBaseNamePtr(char *);
94 char *getPath2(char *, char *);
95 char *getPath3(char *, char *, char*);
96 char *getStringCat2(char *, char *);
97 char *getStringCopy(char *);
98 char *getStringToLower(char *);
99 void setString(char **, char *);
100 boolean strEqual(char *, char *);
102 void GetOptions(char **, void (*print_usage_function)(void));
104 void SetError(char *, ...);
105 char *GetError(void);
106 void Error(int, char *, ...);
108 void *checked_malloc(unsigned long);
109 void *checked_calloc(unsigned long);
110 void *checked_realloc(void *, unsigned long);
111 void checked_free(void *);
113 void swap_numbers(int *, int *);
114 void swap_number_pairs(int *, int *, int *, int *);
116 int getFile8BitInteger(FILE *);
117 int putFile8BitInteger(FILE *, int);
118 int getFile16BitInteger(FILE *, int);
119 int putFile16BitInteger(FILE *, int, int);
120 int getFile32BitInteger(FILE *, int);
121 int putFile32BitInteger(FILE *, int, int);
123 boolean getFileChunk(FILE *, char *, int *, int);
124 int putFileChunk(FILE *, char *, int, int);
125 int getFileVersion(FILE *);
126 int putFileVersion(FILE *, int);
128 void ReadBytesFromFile(FILE *, byte *, unsigned long);
129 void WriteBytesToFile(FILE *, byte *, unsigned long);
131 void ReadUnusedBytesFromFile(FILE *, unsigned long);
132 void WriteUnusedBytesToFile(FILE *, unsigned long);
134 #define getFile8Bit(f) getFile8BitInteger(f)
135 #define putFile8Bit(f,x) putFile8BitInteger(f,x)
136 #define getFile16BitBE(f) getFile16BitInteger(f,BYTE_ORDER_BIG_ENDIAN)
137 #define getFile16BitLE(f) getFile16BitInteger(f,BYTE_ORDER_LITTLE_ENDIAN)
138 #define putFile16BitBE(f,x) putFile16BitInteger(f,x,BYTE_ORDER_BIG_ENDIAN)
139 #define putFile16BitLE(f,x) putFile16BitInteger(f,x,BYTE_ORDER_LITTLE_ENDIAN)
140 #define getFile32BitBE(f) getFile32BitInteger(f,BYTE_ORDER_BIG_ENDIAN)
141 #define getFile32BitLE(f) getFile32BitInteger(f,BYTE_ORDER_LITTLE_ENDIAN)
142 #define putFile32BitBE(f,x) putFile32BitInteger(f,x,BYTE_ORDER_BIG_ENDIAN)
143 #define putFile32BitLE(f,x) putFile32BitInteger(f,x,BYTE_ORDER_LITTLE_ENDIAN)
145 #define getFileChunkBE(f,s,x) getFileChunk(f,s,x,BYTE_ORDER_BIG_ENDIAN)
146 #define getFileChunkLE(f,s,x) getFileChunk(f,s,x,BYTE_ORDER_LITTLE_ENDIAN)
147 #define putFileChunkBE(f,s,x) putFileChunk(f,s,x,BYTE_ORDER_BIG_ENDIAN)
148 #define putFileChunkLE(f,s,x) putFileChunk(f,s,x,BYTE_ORDER_LITTLE_ENDIAN)
150 char *getKeyNameFromKey(Key);
151 char *getX11KeyNameFromKey(Key);
152 Key getKeyFromKeyName(char *);
153 Key getKeyFromX11KeyName(char *);
154 char getCharFromKey(Key);
156 int get_integer_from_string(char *);
157 boolean get_boolean_from_string(char *);
159 ListNode *newListNode(void);
160 void addNodeToList(ListNode **, char *, void *);
161 void deleteNodeFromList(ListNode **, char *, void (*function)(void *));
162 ListNode *getNodeFromKey(ListNode *, char *);
163 int getNumNodes(ListNode *);
165 boolean fileExists(char *);
166 boolean FileIsGraphic(char *);
167 boolean FileIsSound(char *);
168 boolean FileIsMusic(char *);
169 boolean FileIsArtworkType(char *, int);
171 char *get_mapped_token(char *);
173 int get_parameter_value(char *, char *, int);
174 int get_auto_parameter_value(char *, char *);
176 struct ScreenModeInfo *get_screen_mode_from_string(char *);
177 void get_aspect_ratio_from_screen_mode(struct ScreenModeInfo *, int *x, int *y);
179 struct FileInfo *getFileListFromConfigList(struct ConfigInfo *,
180 struct ConfigTypeInfo *,
182 void LoadArtworkConfig(struct ArtworkListInfo *);
183 void ReloadCustomArtworkList(struct ArtworkListInfo *);
184 void FreeCustomArtworkLists(struct ArtworkListInfo *);
186 char *getErrorFilename(char *);
187 void openErrorFile();
188 void closeErrorFile();
189 void dumpErrorFile();
190 void NotifyUserAboutErrorFile();
192 void debug_print_timestamp(int, char *);