OSDN Git Service

I am understanding why the memory management system is not working now!!
[proj16/16.git] / src / lib / 16_head.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 #include "src/lib/16_head.h"\r
24 \r
25 /* Function: Wait **********************************************************\r
26 *\r
27 *     Parameters:    wait - time in microseconds\r
28 *\r
29 *     Description:    pauses for a specified number of microseconds.\r
30 *\r
31 */\r
32 void wait(clock_t wait){\r
33         clock_t goal;\r
34 \r
35         if(!wait) return;\r
36 \r
37         goal = wait + clock();\r
38         while((goal > clock()) && !kbhit()) ;\r
39 } /* End of wait */\r
40 \r
41 long int\r
42 filesize(FILE *fp)\r
43 {\r
44         long int save_pos, size_of_file;\r
45 \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
51 }\r
52 \r
53 void printmeminfoline(byte *strc, const byte *pee, size_t h_total, size_t h_used, size_t h_free)\r
54 {\r
55         byte str[64];\r
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);\r
57         strcat(strc,"\n");\r
58 }\r
59 \r
60 ///////////////////////////////////////////////////////////////////////////\r
61 //\r
62 //      US_CheckParm() - checks to see if a string matches one of a set of\r
63 //              strings. The check is case insensitive. The routine returns the\r
64 //              index of the string that matched, or -1 if no matches were found\r
65 //\r
66 ///////////////////////////////////////////////////////////////////////////\r
67 int\r
68 US_CheckParm(char *parm,char **strings)\r
69 {\r
70         char    cp,cs,\r
71                         *p,*s;\r
72         int             i;\r
73 \r
74         while (!isalpha(*parm)) // Skip non-alphas\r
75                 parm++;\r
76 \r
77         for (i = 0;*strings && **strings;i++)\r
78         {\r
79                 for (s = *strings++,p = parm,cs = cp = 0;cs == cp;)\r
80                 {\r
81                         cs = *s++;\r
82                         if (!cs)\r
83                                 return(i);\r
84                         cp = *p++;\r
85 \r
86                         if (isupper(cs))\r
87                                 cs = tolower(cs);\r
88                         if (isupper(cp))\r
89                                 cp = tolower(cp);\r
90                 }\r
91         }\r
92         return(-1);\r
93 }\r
94 \r
95 /*\r
96 ==========================\r
97 =\r
98 = Quit\r
99 =\r
100 ==========================\r
101 */\r
102 \r
103 /*void Quit(char *error, ...)\r
104 {\r
105         short exit_code=0;\r
106         unsigned        finscreen;\r
107 \r
108         va_list ap;\r
109 \r
110         va_start(ap,error);\r
111 \r
112 #ifndef CATALOG\r
113         if (!error)\r
114         {\r
115                 CA_SetAllPurge ();\r
116                 CA_CacheGrChunk (PIRACY);\r
117                 finscreen = (unsigned)grsegs[PIRACY];\r
118         }\r
119 #endif\r
120 \r
121         //ShutdownId ();\r
122 \r
123         if (error && *error)\r
124         {\r
125                 vprintf(error,ap);\r
126                 exit_code = 1;\r
127         }\r
128 #ifndef CATALOG\r
129         else\r
130         if (!NoWait)\r
131         {\r
132                 movedata (finscreen,0,0xb800,0,4000);\r
133                 bioskey (0);\r
134         }\r
135 #endif\r
136 \r
137         va_end(ap);\r
138 \r
139 #ifndef CATALOG\r
140         if (!error)\r
141         {\r
142                 _argc = 2;\r
143                 _argv[1] = "LAST.SHL";\r
144                 _argv[2] = "ENDSCN.SCN";\r
145                 _argv[3] = NULL;\r
146                 if (execv("LOADSCN.EXE", _argv) == -1)\r
147                 {\r
148                         clrscr();\r
149                         puts("Couldn't find executable LOADSCN.EXE.\n");\r
150                         exit(1);\r
151                 }\r
152         }\r
153 #endif\r
154 \r
155         exit(exit_code);\r
156 }*/\r