1 /* Project 16 Source Code~
2 * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
4 * This file is part of Project 16.
6 * Project 16 is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * Project 16 is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
19 * Fifth Floor, Boston, MA 02110-1301 USA.
25 /* Function: Wait **********************************************************
\r
27 * Parameters: wait - time in microseconds
\r
29 * Description: pauses for a specified number of microseconds.
\r
32 void wait(clock_t wait){
\r
37 goal = wait + clock();
\r
38 while((goal > clock()) && !kbhit()) ;
\r
41 void* AllocateLargestFreeBlock(size_t* Size)
46 s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
48 while (s0 && (p = malloc(s0)) == NULL)
58 if ((p = malloc(s0 + s1)) != NULL)
66 while (s0 && (p = malloc(s0)) == NULL)
73 size_t GetFreeSize(void)
82 void* p = AllocateLargestFreeBlock(&largest);
84 if (largest < sizeof(void*))
104 while (pFirst != NULL)
106 void* p = *(void**)pFirst;
114 void far* AllocateLargestFarFreeBlock(size_t far* Size)
119 s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
120 while (s0 && (p = _fmalloc(s0)) == NULL)
129 if ((p = _fmalloc(s0 + s1)) != NULL)
136 while (s0 && (p = _fmalloc(s0)) == NULL)
143 size_t GetFarFreeSize(void)
146 void far* pFirst = NULL;
147 void far* pLast = NULL;
151 void far* p = AllocateLargestFarFreeBlock(&largest);
152 if (largest < sizeof(void far*))
158 *(void far* far*)p = NULL;
164 *(void far* far*)pLast = p;
168 while (pFirst != NULL)
170 void far* p = *(void far* far*)pFirst;
180 long int save_pos, size_of_file;
\r
182 save_pos = ftell(fp);
\r
183 fseek(fp, 0L, SEEK_END);
\r
184 size_of_file = ftell(fp);
\r
185 fseek(fp, save_pos, SEEK_SET);
\r
186 return(size_of_file);
\r
189 ///////////////////////////////////////////////////////////////////////////
\r
191 // US_CheckParm() - checks to see if a string matches one of a set of
\r
192 // strings. The check is case insensitive. The routine returns the
\r
193 // index of the string that matched, or -1 if no matches were found
\r
195 ///////////////////////////////////////////////////////////////////////////
\r
197 US_CheckParm(char *parm,char **strings)
\r
203 while (!isalpha(*parm)) // Skip non-alphas
\r
206 for (i = 0;*strings && **strings;i++)
\r
208 for (s = *strings++,p = parm,cs = cp = 0;cs == cp;)
\r
225 ==========================
\r
229 ==========================
\r
232 /*void Quit(char *error, ...)
\r
235 unsigned finscreen;
\r
239 va_start(ap,error);
\r
245 CA_CacheGrChunk (PIRACY);
\r
246 finscreen = (unsigned)grsegs[PIRACY];
\r
252 if (error && *error)
\r
261 movedata (finscreen,0,0xb800,0,4000);
\r
272 _argv[1] = "LAST.SHL";
\r
273 _argv[2] = "ENDSCN.SCN";
\r
275 if (execv("LOADSCN.EXE", _argv) == -1)
\r
278 puts("Couldn't find executable LOADSCN.EXE.\n");
\r