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.
23 #include "src/lib/16_head.h"
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
44 long int save_pos, size_of_file;
\r
46 save_pos = ftell(fp);
\r
47 fseek(fp, 0L, SEEK_END);
\r
48 size_of_file = ftell(fp);
\r
49 fseek(fp, save_pos, SEEK_SET);
\r
50 return(size_of_file);
\r
53 void printmeminfoline(byte *strc, const byte *pee, size_t h_total, size_t h_used, size_t h_free)
56 strcat(strc,pee); strcat(strc," "); ultoa((dword)h_total,str,10); strcat(strc,str); strcat(strc," "); ultoa((dword)h_used,str,10); strcat(strc,str); strcat(strc," "); ultoa((dword)h_free,str,10); strcat(strc,str);
60 void print_normal_entry(char *text, dword total, dword used, dword free, byte *str)
62 printf("%-17s", text);
63 convert("%8sB ", total);
64 convert("%9sB ", used);
65 convert("%9sB\n", free);
69 * As for printf(), but format may only contain a single format specifier,
70 * which must be "%s" and is replaced with the string form of num with commas
71 * separating groups of three digits.
73 * e.g. convert("%s bytes", 1234567) -> "1,234,567 bytes"
75 void convert(const char *format, dword num)
78 char des[4*sizeof(dword)+3];
81 char mycountry[48]; /* probably 34 bytes are enough... */
82 char ksep = ','; /* or . */
85 sregs.ds = FP_SEG(&mycountry);
86 regs.x.dx = FP_OFF(&mycountry);
87 intdosx(®s,®s,&sregs);
88 if (regs.x.cflag == 0) {
89 ksep = mycountry[7]; /* 1000's separator */
90 /* dsep = mycountry[9]; ** decimal separator */
93 n = sprintf(des, "%lu", num);
94 /* insert commas in the string */
96 for (i = n - 3; i > 0; i--) {
98 for (j = n; j >= i; j--)
100 des[i]=ksep; /* ',' */
108 ///////////////////////////////////////////////////////////////////////////
\r
110 // US_CheckParm() - checks to see if a string matches one of a set of
\r
111 // strings. The check is case insensitive. The routine returns the
\r
112 // index of the string that matched, or -1 if no matches were found
\r
114 ///////////////////////////////////////////////////////////////////////////
\r
116 US_CheckParm(char *parm,char **strings)
\r
122 while (!isalpha(*parm)) // Skip non-alphas
\r
125 for (i = 0;*strings && **strings;i++)
\r
127 for (s = *strings++,p = parm,cs = cp = 0;cs == cp;)
\r
144 ==========================
\r
148 ==========================
\r
151 /*void Quit(char *error, ...)
\r
154 unsigned finscreen;
\r
158 va_start(ap,error);
\r
164 CA_CacheGrChunk (PIRACY);
\r
165 finscreen = (unsigned)grsegs[PIRACY];
\r
171 if (error && *error)
\r
180 movedata (finscreen,0,0xb800,0,4000);
\r
191 _argv[1] = "LAST.SHL";
\r
192 _argv[2] = "ENDSCN.SCN";
\r
194 if (execv("LOADSCN.EXE", _argv) == -1)
\r
197 puts("Couldn't find executable LOADSCN.EXE.\n");
\r