]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_head.c
fixed an issue with EMS_INT becuase i learned there is 2 wwww
[16.git] / src / lib / 16_head.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\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 long int\r
26 filesize(FILE *fp)\r
27 {\r
28         long int save_pos, size_of_file;\r
29 \r
30         save_pos = ftell(fp);\r
31         fseek(fp, 0L, SEEK_END);\r
32         size_of_file = ftell(fp);\r
33         fseek(fp, save_pos, SEEK_SET);\r
34         return(size_of_file);\r
35 }\r
36 \r
37 void printmeminfoline(byte *strc, const byte *pee, size_t h_total, size_t h_used, size_t h_free)\r
38 {\r
39         byte str[64];\r
40         strcat(strc,pee); strcat(strc,"            "); ultoa((dword)h_total,str,10); strcat(strc,str);\r
41         if(strlen(str)<=4) strcat(strc,"        "); //printf("%u\n", strlen(str));\r
42         strcat(strc,"   "); ultoa((dword)h_used,str,10); strcat(strc,str); strcat(strc,"        "); strcat(strc,"  ");\r
43         ultoa((dword)h_free,str,10); strcat(strc,str);\r
44         strcat(strc,"\n");\r
45 }\r
46 \r
47 ///////////////////////////////////////////////////////////////////////////\r
48 //\r
49 //      US_CheckParm() - checks to see if a string matches one of a set of\r
50 //              strings. The check is case insensitive. The routine returns the\r
51 //              index of the string that matched, or -1 if no matches were found\r
52 //\r
53 ///////////////////////////////////////////////////////////////////////////\r
54 int\r
55 US_CheckParm(char *parm,char **strings)\r
56 {\r
57         char    cp,cs,\r
58                         *p,*s;\r
59         int             i;\r
60 \r
61         while (!isalpha(*parm)) // Skip non-alphas\r
62                 parm++;\r
63 \r
64         for (i = 0;*strings && **strings;i++)\r
65         {\r
66                 for (s = *strings++,p = parm,cs = cp = 0;cs == cp;)\r
67                 {\r
68                         cs = *s++;\r
69                         if (!cs)\r
70                                 return(i);\r
71                         cp = *p++;\r
72 \r
73                         if (isupper(cs))\r
74                                 cs = tolower(cs);\r
75                         if (isupper(cp))\r
76                                 cp = tolower(cp);\r
77                 }\r
78         }\r
79         return(-1);\r
80 }\r
81 #ifdef __BORLANDC__\r
82 //===========================================================================\r
83 \r
84 /*\r
85 ==========================\r
86 =\r
87 = Quit\r
88 =\r
89 ==========================\r
90 */\r
91 \r
92 void Quit (char *error)\r
93 {\r
94         unsigned        finscreen;\r
95         memptr  screen;\r
96         union REGS in, out;\r
97 \r
98         //ClearMemory ();\r
99         if (!*error)\r
100         {\r
101          //WriteConfig ();\r
102         }\r
103         else\r
104         {\r
105          //CA_CacheGrChunk (ERRORSCREEN);\r
106          //screen = grsegs[ERRORSCREEN];\r
107         }\r
108 \r
109         //ShutdownId ();\r
110         //IN_Shutdown();\r
111         //modexLeave();\r
112         in.h.ah = 0x00;\r
113         in.h.al = 0x3;\r
114         int86(0x10, &in, &out);\r
115 \r
116         if (error && *error)\r
117         {\r
118           //movedata ((unsigned)screen,7,0xb800,0,7*160);\r
119           //gotoxy (10,4);\r
120                 printf("\n");\r
121           puts(error);\r
122                 printf("\n");\r
123           //gotoxy (1,8);\r
124           exit(1);\r
125         }\r
126         else\r
127         if (!error || !(*error))\r
128         {\r
129                 //clrscr();\r
130                 //#ifndef JAPAN\r
131                 movedata ((unsigned)screen,7,0xb800,0,4000);\r
132                 //gotoxy(1,24);\r
133                 //#endif\r
134 //asm   mov     bh,0\r
135 //asm   mov     dh,23   // row\r
136 //asm   mov     dl,0    // collumn\r
137 //asm   mov ah,2\r
138 //asm   int     0x10\r
139         }\r
140 \r
141         exit(0);\r
142 }\r
143 \r
144 //===========================================================================\r
145 #endif\r
146 \r
147 byte dirchar(byte in)\r
148 {\r
149         byte out;\r
150         switch(in)\r
151         {\r
152                 case 0: //up\r
153                         out = 0x1E;\r
154                 break;\r
155                 case 4: //down\r
156                         out = 0x1F;\r
157                 break;\r
158                 case 1: //left\r
159                         out = 0x11;\r
160                 break;\r
161                 case 3: //right\r
162                         out = 0x10;\r
163                 break;\r
164                 default: //null\r
165                         out = 0xB3;\r
166                 break;\r
167         }\r
168         return out;\r
169 }\r