]> 4ch.mooo.com Git - 16.git/blob - 16/v2/source/verge/ENGINE/CONLIB.C
new file: 16/v2/CONSOLE.TXT
[16.git] / 16 / v2 / source / verge / ENGINE / CONLIB.C
1 /*\r
2 Copyright (C) 1998 BJ Eirich (aka vecna)\r
3 This program is free software; you can redistribute it and/or\r
4 modify it under the terms of the GNU General Public License\r
5 as published by the Free Software Foundation; either version 2\r
6 of the License, or (at your option) any later version.\r
7 This program is distributed in the hope that it will be useful,\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
10 See the GNU General Public Lic\r
11 See the GNU General Public License for more details.\r
12 You should have received a copy of the GNU General Public License\r
13 along with this program; if not, write to the Free Software\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r
15 */\r
16 \r
17 #include "verge.h"\r
18 \r
19 // ================================= Data ====================================\r
20 \r
21 byte cpu_watch, cpubyte=0;\r
22 \r
23 // ================================= Code ====================================\r
24 \r
25 void ListMounts()\r
26 { int i;\r
27 \r
28   Con_NextLine();\r
29   sprintf(strbuf,"There are \81%d~ files mounted.",filesmounted);\r
30   Con_Printf(strbuf);\r
31   for (i=0; i<filesmounted; i++)\r
32   {\r
33     sprintf(strbuf,"File \80%s~ contains \81%d~ files.",pack[i].mountname, pack[i].numfiles);\r
34     Con_Printf(strbuf);\r
35   }\r
36 }\r
37 \r
38 void PackInfo()\r
39 { int i,j;\r
40 \r
41   Con_NextLine();\r
42   i=atoi((char *) args[1]);\r
43   sprintf(strbuf,"Files in %s:",pack[i].mountname);\r
44   Con_Printf(strbuf);\r
45 \r
46   for (j=0; j<pack[i].numfiles; j++)\r
47   {\r
48     sprintf(strbuf,"\80%s~              ",pack[i].files[j].fname);\r
49     sprintf(&strbuf[20],"\81%d~ bytes",pack[i].files[j].size);\r
50     Con_Printf(strbuf);\r
51   }\r
52 }\r
53 \r
54 void FileInfo()\r
55 { VFILE *f;\r
56 \r
57   Con_NextLine();\r
58   sprintf(strbuf,"File stats for \80%s~:",args[1]);\r
59   Con_Printf(strbuf);\r
60 \r
61   f=vopen((char *) args[1]);\r
62   if (!f)\r
63   {\r
64     Con_Printf("File not found.");\r
65     return;\r
66   }\r
67 \r
68   if (f->s)\r
69   {\r
70     sprintf(strbuf,"File is in \80%s~, index \81%d~",pack[f->v].mountname, f->i);\r
71     Con_Printf(strbuf);\r
72     sprintf(strbuf,"Packofs: \81%d~ current ofs: \81%d~",pack[f->v].files[f->i].packofs,pack[f->v].files[f->i].curofs);\r
73     Con_Printf(strbuf);\r
74     if (pack[f->v].files[f->i].extractable)\r
75        Con_Printf("File is extractable.");\r
76     else Con_Printf("File is not extractable.");\r
77     if (pack[f->v].files[f->i].override)\r
78        Con_Printf("Override allowed.");\r
79     else Con_Printf("Override not allowed.");\r
80   }\r
81   else Con_Printf("File is external.");\r
82   sprintf(strbuf,"File is \81%d~ bytes.",filesize(f));\r
83   Con_Printf(strbuf);\r
84   vclose(f);\r
85 }\r
86 \r
87 void vid_mode()\r
88 { int xres,yres;\r
89 \r
90   xres=atoi((char *)args[1]);\r
91   yres=atoi((char *)args[2]);\r
92   Con_NextLine();\r
93 \r
94   ShutdownVideo(0);\r
95   if (InitVideo(xres, yres))\r
96   {\r
97     Con_Printf("{||||||||||||}");\r
98     Con_Printf("Loading new video driver...");\r
99     Con_Printf(DriverDesc);\r
100     Con_Printf("{||||||||||||}");\r
101   }\r
102   else Con_Printf("Unsupported/unknown video mode.");\r
103   set_intensity(63);\r
104 }\r
105 \r
106 void CPU_Usage()\r
107 {\r
108   if (numargs==1)\r
109   {\r
110     sprintf(strbuf,"cpu_usage is \81%d~", cpu_watch);\r
111     Con_Printf(strbuf);\r
112   }\r
113   else cpu_watch=atoi((char *) args[1]);\r
114 }\r
115 \r
116 void Mount()\r
117 {\r
118   MountVFile((char *) args[1]);\r
119   sprintf(strbuf,"%s mounted.",args[1]);\r
120   Con_Printf(strbuf);\r
121 }\r
122 \r
123 void ZeroConWarp(char **args)\r
124 {\r
125   player->x=atoi(args[1])*16;\r
126   player->y=atoi(args[2])*16;\r
127   player->tx=atoi(args[1]);\r
128   player->ty=atoi(args[2]);\r
129 }\r
130 \r
131 void ZeroConBrowseTiles(void)\r
132 {\r
133   int x,y,n,k=0,a=0;\r
134 \r
135   while(last_pressed!=SCAN_Q)\r
136   {\r
137     ClearScreen();\r
138     UpdateControls();\r
139     CheckMessages();\r
140     if(last_pressed==SCAN_A) { if(a) a=0; else a=1; last_pressed=0; }\r
141     if(last_pressed==SCAN_DOWN&&(k+(ty-3)*(tx-3)-tx+4)<numtiles)\r
142     {\r
143       k+=tx-4;\r
144       last_pressed=0;\r
145     }\r
146     if(last_pressed==SCAN_UP&&k>0)\r
147     {\r
148       k-=tx-4;\r
149       last_pressed=0;\r
150     }\r
151     for(y=1; y<ty-2; y++)\r
152     {\r
153       for(x=1; x<tx-3; x++)\r
154       {\r
155         n=((y-1)*(tx-4)+x-1+k);\r
156         if (n<numtiles)\r
157         {\r
158           if (!a) CopyTileClip(x*16,y*16,(unsigned char*)((unsigned int)vsp+((y-1)*(tx-4)+x-1+k)*256));\r
159           else CopyTileClip(x*16,y*16,(unsigned char*)((unsigned int)vsp+tileidx[(y-1)*(tx-4)+x-1+k]*256));\r
160         }\r
161 \r
162       }\r
163       GotoXY((tx-2)*16-8,y*16+5);\r
164       sprintf(strbuf,"%i",(y-1)*(tx-4)+k);\r
165       printstring(0,strbuf);\r
166     }\r
167   GotoXY(16,(ty-1)*16-8);\r
168   printstring(0,"Hit Q to quit, A to toggle anim,");\r
169   GotoXY(16,(ty-1)*16);\r
170   printstring(0,"up/down to change tiles");\r
171   ShowPage();\r
172   }\r
173 }\r
174 \r
175 void CameraTracking()\r
176 {\r
177   if (numargs==1)\r
178   {\r
179     sprintf(strbuf,"cameratracking is \81%d~", cameratracking);\r
180     Con_Printf(strbuf);\r
181   }\r
182   else cameratracking=atoi((char *) args[1]);\r
183 }\r
184 \r
185 void ZeroSetRString(char **args)\r
186 {\r
187   memcpy(rstring,args[1],strlen(args[1])+1);\r
188 }\r
189 \r
190 void ZeroGetRString(void)\r
191 {\r
192   sprintf(strbuf,"Renderstring: \80%s~",rstring);\r
193   Con_Printf(strbuf);\r
194 }\r
195 \r
196 void Obstructions()\r
197 {\r
198   if (numargs==1)\r
199   {\r
200     sprintf(strbuf,"showobs is \81%d~", showobs);\r
201     Con_Printf(strbuf);\r
202   }\r
203   else showobs=atoi((char *) args[1]);\r
204 }\r
205 \r
206 void MoveGranularity()\r
207 {\r
208   if (numargs==1)\r
209   {\r
210     sprintf(strbuf,"movegranularity is \81%d~", movegranularity);\r
211     Con_Printf(strbuf);\r
212   }\r
213   else movegranularity=atoi((char *) args[1]);\r
214 }\r
215 \r
216 void Phantom()\r
217 {\r
218   if (numargs==1)\r
219   {\r
220     sprintf(strbuf,"phantom is \81%d~", phantom);\r
221     Con_Printf(strbuf);\r
222   }\r
223   else phantom=atoi((char *) args[1]);\r
224 }\r
225 \r
226 void CurPos()\r
227 {\r
228   Con_NextLine();\r
229   sprintf(strbuf,"xwc: \82%d~ ywc: \82%d~", player->x, player->y); Con_Printf(strbuf);\r
230   sprintf(strbuf,"xtc: \82%d~ ytc: \82%d~", player->x>>4, player->y>>4); Con_Printf(strbuf);\r
231 }\r
232 \r
233 void PlayerSpeed()\r
234 {\r
235   if (!player)\r
236   {\r
237     Con_Printf("No player.");\r
238     return;\r
239   }\r
240   if (numargs==1)\r
241   {\r
242     Con_NextLine();\r
243     sprintf(strbuf,"speed is is \81%d~", player->speed);\r
244     Con_Printf(strbuf);\r
245   }\r
246   else\r
247   {\r
248     player->speed=atoi((char *) args[1]);\r
249     player->speedct=0;\r
250   }\r
251 }\r
252 \r
253 void Player()\r
254 { int i;\r
255 \r
256   i=atoi((char *) args[1]);\r
257   if (i<entities)\r
258   {\r
259     player=&entity[i];\r
260     playernum=i;\r
261 //    entity[i].movecode=0;\r
262     entity[i].moving=0;\r
263     SiftEntities();\r
264     Con_Printf("Player updated.");\r
265   }\r
266   else Con_Printf("No such entity.");\r
267 }\r
268 \r
269 void SpawnEntity()\r
270 { int i;\r
271 \r
272   i=AllocateEntity(atoi((char *) args[1]), atoi((char *) args[2]), (char *) args[3]);\r
273   sprintf(strbuf,"Entity %d allocated.",i);\r
274   Con_Printf(strbuf);\r
275 }\r
276 \r
277 void ShowZones()\r
278 {\r
279   if (numargs==1)\r
280   {\r
281     sprintf(strbuf,"showzones is \81%d~", showzone);\r
282     Con_Printf(strbuf);\r
283   }\r
284   else showzone=atoi((char *) args[1]);\r
285 }\r