1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <math.h>
5 #include <time.h>
6 
7 #ifdef UNIX
8 
9 #include"xpired_unix.h"
10 
11 #endif
12 
13 #include <SDL.h>
14 #include <SDL_image.h>
15 #include <SDL_gfxPrimitives.h>
16 
17 #define	TURBO 1
18 #define	APPNAME "X-pir-Ed-It"
19 #define VERSION "1.2"
20 
21 #ifdef UNIX
22   char *SHARE_DIR=SHARE_PREFIX;
23 #else
24   char *SHARE_DIR=".";
25 #endif;
26 
27 char GAME_HOME[255];
28 
29 Uint8	BPP=8;
30 Uint8	Shades=128;
31 
32 SDL_Surface *screen,*Sh=NULL,*SLevel,*SLives,*STime,*SNumbers;
33 
34 char Quit=0,Left=0,Right=0,Up=0,Down=0,Fire=0,Alt=0,Ctrl=0,Shift=0,FULLSCR;
35 int  Level=-1,MX,MY,MB,MBlock;
36 int  WIDTH=440,HEIGHT=410;
37 char LFile[256]="./xpired.lvl";
38 Uint16 UC;
39 
40 SDL_Event event;
41 
42 int MVolume=64;
43 int SVolume=64;
44 
45 typedef struct T_Spr{
46 	SDL_Surface *img,*sha;
47 }T_Spr;
48 
49 T_Spr Spr[256];
50 
51 
52 typedef struct T_LElem{
53 	unsigned char FSpr,FTyp,BSpr,BTyp;
54 	char x,y,px,py,f,txt;
55 }T_LElem;
56 
57 typedef struct T_Lev{
58 	T_LElem M[20][20];
59 	char Name[100],BgFile[256],Pw[11];
60 	unsigned int DL;
61 	SDL_Surface *Bg;
62 	char Text[10][51];
63 }T_Lev;
64 
65 T_Lev Lvl[100];
66 
67 // menucka...
68 typedef struct T_E_Sel_E{
69 	unsigned char Spr,Typ;
70 	char Desc[50];
71 }T_E_Sel_E;
72 
73 typedef struct T_E_Sel{
74 	T_E_Sel_E E[256];
75 	int X,L,Top,Akt;
76 	char Name[10];
77 }T_E_Sel;
78 
79 T_E_Sel M_Fg,M_Bg;
80 
81 char M_Txt[10][20],M_Msg[10][20];
82 
83 char ConfFName[255];
84 
85 //--------------------------------------
86 
87 
VIDEO_INIT()88 void VIDEO_INIT(){
89 Uint32 videoflags;
90 const SDL_VideoInfo *info;
91 
92 	info = SDL_GetVideoInfo();
93 	BPP=info->vfmt->BitsPerPixel;
94 
95 	videoflags = SDL_SRCALPHA; // | SDL_RESIZABLE;
96 	if(FULLSCR){
97 		videoflags = SDL_SRCALPHA | SDL_FULLSCREEN | SDL_SWSURFACE;
98 	}else{
99 		videoflags = SDL_SRCALPHA;
100 		if (TURBO) videoflags=videoflags | SDL_HWSURFACE | SDL_HWPALETTE;
101 		else videoflags=videoflags | SDL_SWSURFACE;
102 	}
103 
104 	if ( (screen=SDL_SetVideoMode(WIDTH,HEIGHT,BPP,videoflags)) == NULL ) {
105 		fprintf(stderr, "Couldn't set %ix%i video mode: %s\n",WIDTH,HEIGHT,SDL_GetError());
106 		exit(2);
107 	}
108 
109 //	SDL_SetAlpha(screen, SDL_SRCALPHA, 0);
110 //	vscreen=SDL_CreateRGBSurface(SDL_SWSURFACE,WIDTH,HEIGHT,BPP,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,screen->format->Amask);
111 //	if (vscreen==NULL) printf("VSCREEN neni!!\n");
112 
113 //	fprintf(stdout,"VIDEO SET: W=%d H=%d BPP=%d TURBO=%d\n",WIDTH,HEIGHT,BPP,TURBO);
114 }
115 
116 
ClearSurface(SDL_Surface * Co)117 void ClearSurface(SDL_Surface *Co){
118 Uint32 color;
119 SDL_Rect clip;
120 
121 	clip.x = 0;
122 	clip.y = 0;
123 	clip.w = Co->w;
124 	clip.h = Co->h;
125 
126 	/* Setup clear color color */
127 	color=SDL_MapRGBA(Co->format, 255,0,255,0);
128 
129 	/* Clear the screen */
130 //	SDL_SetClipRect(Co, &clip);
131 	SDL_FillRect (Co, &clip, color);
132 }
133 
134 
E_FILTER(const SDL_Event * event)135 int E_FILTER(const SDL_Event *event) {
136 char *Str;
137 	if ( event->type == SDL_VIDEORESIZE ) {
138 		WIDTH=event->resize.w;
139 		HEIGHT=event->resize.h;
140 		VIDEO_INIT();
141 		return 0;
142 	}
143 
144 	if (event->type==SDL_KEYDOWN){
145 		if (event->key.keysym.sym==SDLK_RALT) Fire=1;
146 		if (event->key.keysym.sym==SDLK_RETURN) Fire=1;
147 		if (event->key.keysym.sym==SDLK_ESCAPE) Quit=1;
148 		if (event->key.keysym.sym==SDLK_LALT) Alt=1;
149 		if (event->key.keysym.sym==SDLK_LCTRL) Ctrl=1;
150 		if (event->key.keysym.sym==SDLK_q) Quit=2;
151 		if ((event->key.keysym.sym==SDLK_c)&&(Ctrl)) Quit=2;
152 		if ((event->key.keysym.sym==SDLK_F4)&&(Alt)) Quit=2;
153 
154 		if (event->key.keysym.sym==SDLK_LEFT) Left=1;
155 		if (event->key.keysym.sym==SDLK_RIGHT) Right=1;
156 		if (event->key.keysym.sym==SDLK_UP) Up=1;
157 		if (event->key.keysym.sym==SDLK_DOWN) Down=1;
158 		if (event->key.keysym.sym==SDLK_LSHIFT)
159 			Shift=1;
160 		UC=event->key.keysym.unicode;
161 		return(0);
162 	}
163 
164 	if (event->type==SDL_KEYUP){
165 		if (event->key.keysym.sym==SDLK_LEFT) Left=0;
166 		if (event->key.keysym.sym==SDLK_RIGHT) Right=0;
167 		if (event->key.keysym.sym==SDLK_UP) Up=0;
168 		if (event->key.keysym.sym==SDLK_DOWN) Down=0;
169 		if (event->key.keysym.sym==SDLK_RETURN) Fire=0;
170 		if (event->key.keysym.sym==SDLK_RALT) Fire=0;
171 		if (event->key.keysym.sym==SDLK_ESCAPE) Quit=0;
172 		if (event->key.keysym.sym==SDLK_LALT) Alt=0;
173 		if (event->key.keysym.sym==SDLK_LCTRL) Ctrl=0;
174 		if (event->key.keysym.sym==SDLK_LSHIFT) Shift=0;
175 		return 0;
176 	}
177 
178 	if ( event->type == SDL_MOUSEBUTTONDOWN ) {
179 		if (event->button.button==SDL_BUTTON_LEFT)
180 			MB=1;
181 		if (event->button.button==SDL_BUTTON_RIGHT)
182 			MB=2;
183 		return 0;
184 	}
185 
186 	if ( event->type == SDL_MOUSEBUTTONUP ) {
187 		MB=0;
188 		MBlock=0;
189 		return 0;
190 	}
191 
192 	if ( event->type == SDL_MOUSEMOTION ) {
193         MX=event->motion.x;
194 		MY=event->motion.y;
195 		return(0);
196     }
197 
198 	if (event->type==SDL_QUIT) Quit=2;
199 
200 	return(1);
201 }
202 
203 
DrawSpr(SDL_Surface * Co,SDL_Surface * Kam,int X,int Y)204 void DrawSpr(SDL_Surface *Co,SDL_Surface *Kam,int X,int Y){
205 SDL_Rect Dest;
206 	if (Co==NULL) return;
207 	Dest.x=X;
208 	Dest.y=Y;
209 	Dest.w=Co->w;
210 	Dest.h=Co->h;
211 	SDL_BlitSurface(Co,NULL,Kam,&Dest);
212 }
213 
214 
R_Blit(SDL_Surface * Co,SDL_Surface * Kam,int SX,int SY,int SW,int SH,int X,int Y)215 void R_Blit(SDL_Surface *Co,SDL_Surface *Kam,int SX, int SY, int SW, int SH, int X, int Y){
216 SDL_Rect Src,Dest;
217 	if (Co==NULL) return;
218 	Src.x=SX;
219 	Src.y=SY;
220 	Src.w=SW;
221 	Src.h=SH;
222 	Dest.x=X;
223 	Dest.y=Y;
224 	Dest.w=SW;
225 	Dest.h=SH;
226 	SDL_BlitSurface(Co,&Src,Kam,&Dest);
227 }
228 
229 
230 //---------------- EXEC ------------------
231 
232 
LoadSprite(SDL_Surface ** Co,char * Soubor,Uint8 sh)233 void LoadSprite(SDL_Surface **Co, char *Soubor, Uint8 sh){
234 	*Co=IMG_Load(Soubor);
235 	if (*Co==NULL) fprintf(stderr,"Error loading %s!\n",Soubor);
236 	else{
237 		SDL_SetColorKey(*Co,SDL_SRCCOLORKEY|SDL_RLEACCEL,SDL_MapRGB((*Co)->format,255,0,255));
238 		if (sh)
239 			SDL_SetAlpha(*Co,SDL_SRCALPHA,sh);
240 		*Co=SDL_DisplayFormat(*Co);
241 	}
242 }
243 
244 
LoadSprites(void)245 void LoadSprites(void){
246 int I;
247 
248 	for (I=0;I<256;I++){
249 		Spr[I].img=NULL;
250 		Spr[I].sha=NULL;
251 	}
252 
253 #ifdef UNIX
254 
255   chdir(SHARE_DIR);
256 
257 #endif
258 
259 	LoadSprite(&SLevel,"./img/level.bmp",0);
260 	LoadSprite(&SLives,"./img/lives.bmp",0);
261 	LoadSprite(&STime,"./img/time.bmp",0);
262 	LoadSprite(&SNumbers,"./img/numbers.bmp",0);
263 	LoadSprite(&(Spr['*']).img,"./img/start.bmp",128);
264 	LoadSprite(&(Spr['+']).img,"./img/exit.bmp",128);
265 	LoadSprite(&(Spr['%']).img,"./img/retard.bmp",96);
266 	LoadSprite(&(Spr['#']).img,"./img/ice.bmp",128);
267 	LoadSprite(&(Spr['&']).img,"./img/flamable.bmp",200);
268 	LoadSprite(&(Spr['@']).img,"./img/hot.bmp",200);
269 	LoadSprite(&(Spr['T']).img,"./img/teleport.bmp",200);
270 
271 	LoadSprite(&(Spr['X']).img,"./img/wall.bmp",0);
272 	LoadSprite(&(Spr['X']).sha,"./img/shade-square.bmp",0);
273 	LoadSprite(&(Spr['x']).img,"./img/tinywall.bmp",0);
274 	LoadSprite(&(Spr['x']).sha,"./img/shade-square.bmp",0);
275 	LoadSprite(&(Spr['c']).img,"./img/crate.bmp",0);
276 	LoadSprite(&(Spr['c']).sha,"./img/shade-crate.bmp",0);
277 	LoadSprite(&(Spr['o']).img,"./img/barel.bmp",0);
278 	LoadSprite(&(Spr['o']).sha,"./img/shade-round.bmp",0);
279 	LoadSprite(&(Spr['O']).img,"./img/explosive.bmp",0);
280 	LoadSprite(&(Spr['O']).sha,"./img/shade-round.bmp",0);
281 
282 	LoadSprite(&(Spr[1]).img,"./img/expl3.bmp",0);
283 	Spr[1].sha=NULL;
284 	LoadSprite(&(Spr[2]).img,"./img/expl2.bmp",0);
285 	Spr[2].sha=NULL;
286 	LoadSprite(&(Spr[3]).img,"./img/expl1.bmp",0);
287 	LoadSprite(&(Spr[3]).sha,"./img/shade-expl1.bmp",0);
288 
289 	LoadSprite(&(Spr[4]).img,"./img/bo-flamable.bmp",0);
290 	Spr[3].sha=NULL;
291 
292 	LoadSprite(&(Spr[5]).img,"./img/fire1.bmp",128);
293 	Spr[5].sha=NULL;
294 	LoadSprite(&(Spr[6]).img,"./img/fire2.bmp",128);
295 	Spr[6].sha=NULL;
296 	LoadSprite(&(Spr[7]).img,"./img/fire3.bmp",128);
297 	Spr[7].sha=NULL;
298 	LoadSprite(&(Spr[8]).img,"./img/fire2.bmp",128);
299 	Spr[8].sha=NULL;
300 
301 	LoadSprite(&(Spr['B']).img,"./img/bem1.bmp",0);
302 	LoadSprite(&(Spr['B']).sha,"./img/shade-bem1.bmp",0);
303 
304 
305 }
306 
307 
chartoint(char Co)308 int chartoint(char Co){
309 	if (Co=='0') return 0;
310 	if (Co=='1') return 1;
311 	if (Co=='2') return 2;
312 	if (Co=='3') return 3;
313 	if (Co=='4') return 4;
314 	if (Co=='5') return 5;
315 	if (Co=='6') return 6;
316 	if (Co=='7') return 7;
317 	if (Co=='8') return 8;
318 	if (Co=='9') return 9;
319 	return -1;
320 }
321 
322 
myatoi(char Co[])323 int myatoi(char Co[]){
324 int I=strlen(Co)-1,Exp=1,Res=0;
325 
326 while ((Exp!=-1)&&(I>=0)&&(Co[I]!='-')){
327 	Res+=Exp*chartoint(Co[I]);
328 	if (Exp<10000)
329 		Exp*=10;
330 	else
331 		Exp=-1;
332 	I--;
333 }
334 if ((I>=0)&&(Co[I]=='-')) Res*=-1;
335 return Res;
336 }
337 
338 
LoadConfig(char * Soubor)339 char LoadConfig(char *Soubor){
340 	FILE *F;
341 	char S[256],T[10];
342 	int I,J;
343 
344 	if ((F=fopen(Soubor,"r"))==NULL)
345 		return 0;
346 	while (!feof(F)){
347 		fgets (S,255,F);
348 		while ((strlen(S)>0)&&(S[strlen(S)-1]<' '))
349 			S[strlen(S)-1]='\0';
350 		if ((S[0]!='\0')&&(S[0]!='#')){
351 //			printf("%s\n",S);
352 				if (!strcmp(S,"shades=none"))
353 					Shades=0;
354 				else
355 				if (!strcmp(S,"shades=solid"))
356 					Shades=255;
357 				else
358 				if (!strcmp(S,"shades=transparent"))
359 					Shades=128;
360 				else
361 				if (!strncmp(S,"fullscreen=",11))
362 					FULLSCR=chartoint(S[11]);
363 
364 		}
365 	}
366 	fclose (F);
367 	return 1;
368 }
369 
370 
LoadLevels(char * Soubor)371 char LoadLevels(char *Soubor){
372 	FILE *F;
373 	char S[256],T[10];
374 	int I=0,J,L=-1;
375 
376 	for (J=0;J<100;J++)
377 		Lvl[J].Name[0]='\0';
378 
379 	if ((F=fopen(Soubor,"r"))==NULL)
380 		return 0;
381 	while ((!feof(F))&&(fgets(S,255,F)!=NULL)){
382 		while ((strlen(S)>0)&&(S[strlen(S)-1]<' '))
383 			S[strlen(S)-1]='\0';
384 		if ((S[0]!='\0')&&(S[0]!='#')){
385 //			printf("%s\n",S);
386 			if ((S[0]=='>')&&(S[strlen(S)-1]=='-')){
387 				L++;
388 				Lvl[L].Name[0]='\0';
389 				Lvl[L].Pw[0]='\0';
390 				Lvl[L].BgFile[0]='\0';
391 				Lvl[L].Bg=NULL;
392 				Lvl[L].DL=0;
393 				for (I=0;I<20;I++)
394 					for (J=0;J<20;J++){
395 						Lvl[L].M[I][J].FSpr=' ';
396 						Lvl[L].M[I][J].FTyp=' ';
397 						Lvl[L].M[I][J].BSpr=' ';
398 						Lvl[L].M[I][J].BTyp=' ';
399 						Lvl[L].M[I][J].x=0;
400 						Lvl[L].M[I][J].y=0;
401 						Lvl[L].M[I][J].px=0;
402 						Lvl[L].M[I][J].py=0;
403 						Lvl[L].M[I][J].f=0;
404 						Lvl[L].M[I][J].txt=-1;
405 					}
406 				for (I=0;I<10;I++)
407 					Lvl[L].Text[I][0]='\0';
408 
409 				I=0;
410 //				fprintf(stdout,"Level(%d) loaded...\n",L);
411 			}else{// LEVEL
412 				if ((S[1]=='=')&&(chartoint(S[0])>=0))
413 					for (J=2;J<=strlen(S);J++)
414 						Lvl[L].Text[chartoint(S[0])][J-2]=S[J];
415 				else
416 				if (!strncmp(S,"name=",5))
417 					for (J=5;J<=strlen(S);J++)
418 						Lvl[L].Name[J-5]=S[J];
419 				else
420 				if (!strncmp(S,"password=",9))
421 					for (J=9;J<=strlen(S);J++)
422 						Lvl[L].Pw[J-9]=S[J];
423 				else
424 				if (!strncmp(S,"deadline=",5)){
425 					for (J=9;J<=strlen(S);J++)
426 						T[J-9]=S[J];
427 					Lvl[L].DL=myatoi(T);
428 				}
429 				else
430 				if (!strncmp(S,"background=",5)){
431 					for (J=11;J<=strlen(S);J++)
432 						T[J-11]=S[J];
433 					strcpy(Lvl[L].BgFile,T);
434 				}
435 				else
436 				if ((I<20)&&(strlen(S)>=20*7)&&(S[0]==',')){
437 					for (J=0;J<20*7;J+=7){
438 							Lvl[L].M[J/7][I].FTyp=S[J+1];
439 							Lvl[L].M[J/7][I].FSpr=S[J+2];
440 							Lvl[L].M[J/7][I].BTyp=S[J+3];
441 							Lvl[L].M[J/7][I].BSpr=S[J+4];
442 							Lvl[L].M[J/7][I].x=0;
443 							Lvl[L].M[J/7][I].y=0;
444 							Lvl[L].M[J/7][I].px=0;
445 							Lvl[L].M[J/7][I].py=0;
446 							Lvl[L].M[J/7][I].f=chartoint(S[J+5]);
447 							Lvl[L].M[J/7][I].txt=chartoint(S[J+6]);
448 					}
449 					I++;
450 				}
451 			}
452 
453 		}
454 	}
455 	fclose (F);
456 	return 1;
457 }
458 
459 
DrawGame(void)460 void DrawGame(void){
461 int I,J;
462 char Str[20];
463 SDL_Rect Rct;
464 
465 	SDL_BlitSurface(Lvl[Level].Bg,NULL,screen,NULL);
466 	for (I=0;I<20;I++)
467 		for (J=0;J<20;J++)
468 			DrawSpr(Spr[Lvl[Level].M[I][J].BSpr].img,screen,I*20+Lvl[Level].M[I][J].x,J*20+Lvl[Level].M[I][J].y);
469 
470 	if (Shades){
471 //	ClearSurface(Sh);
472 		boxRGBA(Sh,0,0,399,14,0,0,0,0xFF);
473 		boxRGBA(Sh,0,15,14,399,0,0,0,0xFF);
474 		boxRGBA(Sh,15,15,399,399,255,0,255,0xFF);
475 
476 		for (I=0;I<20;I++)
477 			for (J=0;J<20;J++)
478 				DrawSpr(Spr[Lvl[Level].M[I][J].FSpr].sha,Sh,I*20+Lvl[Level].M[I][J].x,J*20+Lvl[Level].M[I][J].y);
479 
480 		SDL_BlitSurface(Sh,NULL,screen,NULL);
481 	}
482 
483 
484 	for (I=0;I<20;I++)
485 		for (J=0;J<20;J++){
486 			DrawSpr(Spr[Lvl[Level].M[I][J].FSpr].img,screen,I*20+Lvl[Level].M[I][J].x,J*20+Lvl[Level].M[I][J].y);
487 			if (Lvl[Level].M[I][J].txt>=0){
488 				sprintf(Str,"T%c",'0'+Lvl[Level].M[I][J].txt);
489 				stringRGBA(screen,I*20+2,J*20+6,Str,0xE0,0xE0,0xE0,150);
490 			}
491 		}
492 
493 	// Stat: Level---
494 		DrawSpr(SLevel,screen,1,400-16);
495 		R_Blit(SNumbers,screen,(Level/10)*11,0,11,15,15,400-16);
496 		R_Blit(SNumbers,screen,(Level%10)*11,0,11,15,26,400-16);
497 	// Stat: DeadLine---
498 	if (Lvl[Level].DL){
499 		DrawSpr(STime,screen,200-23,400-17);
500 		R_Blit(SNumbers,screen,(Lvl[Level].DL/100)*11,0,11,15,200-9,400-16);
501 		R_Blit(SNumbers,screen,((Lvl[Level].DL%100)/10)*11,0,11,15,200+2,400-16);
502 		R_Blit(SNumbers,screen,(Lvl[Level].DL%10)*11,0,11,15,200+13,400-16);
503 	}
504 
505 	SDL_UpdateRect(screen,0,0,400,400);
506 }
507 
508 
sgn(int X)509 int sgn(int X){
510 	if (X<0) return -1;
511 	if (X>0) return 1;
512 	return 0;
513 }
514 
515 
SetCaption(void)516 void SetCaption(void){
517 char Caption[100];
518 
519 	if (Lvl[Level].Pw[0]=='\0')
520 		sprintf(Caption,"%s: %s",APPNAME,Lvl[Level].Name);
521 	else
522 		sprintf(Caption,"%s: %s [%s]",APPNAME,Lvl[Level].Name,Lvl[Level].Pw);
523 	SDL_WM_SetCaption(Caption,Caption);
524 }
525 
526 
SetLevel(char Lev)527 void SetLevel(char Lev){
528 int I,J;
529 char Name[50];
530 SDL_Surface *Img;
531 SDL_Rect Rct;
532 	Level=Lev;
533 
534 	SetCaption();
535 
536 	if (Lvl[Level].Name[0]=='\0'){
537 		sprintf(Name,"Level %d entered.",Level);
538 		strcpy(Lvl[Level].Name,Name);
539 		Lvl[Level].BgFile[0]='\0';
540 		Lvl[Level].Bg=NULL;
541 		Lvl[Level].DL=0;
542 		for (I=0;I<20;I++)
543 			for (J=0;J<20;J++){
544 				Lvl[Level].M[I][J].FSpr=' ';
545 				Lvl[Level].M[I][J].FTyp=' ';
546 				Lvl[Level].M[I][J].BSpr=' ';
547 				Lvl[Level].M[I][J].BTyp=' ';
548 				Lvl[Level].M[I][J].x=0;
549 				Lvl[Level].M[I][J].y=0;
550 				Lvl[Level].M[I][J].px=0;
551 				Lvl[Level].M[I][J].py=0;
552 				Lvl[Level].M[I][J].f=0;
553 				Lvl[Level].M[I][J].txt=-1;
554 			}
555 		for (I=0;I<10;I++)
556 			Lvl[Level].Text[I][0]='\0';
557 	}
558 
559 	if (Lvl[Level].Bg==NULL)
560 		Lvl[Level].Bg=SDL_DisplayFormat(SDL_CreateRGBSurface(SDL_HWSURFACE,400,400,BPP,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,screen->format->Amask));
561 	if (Lvl[Level].Bg==NULL) fprintf(stderr,"ALvl.BG neni!!\n");
562 
563 	Img=IMG_Load(Lvl[Level].BgFile);
564 	if (Img!=NULL){
565 		Rct.w=Img->w;
566 		Rct.h=Img->h;
567 		for (I=0;I<400;I+=Rct.w)
568 			for (J=0;J<400;J+=Rct.h){
569 				Rct.x=I;
570 				Rct.y=J;
571 				SDL_BlitSurface(Img,NULL,Lvl[Level].Bg,&Rct);
572 			}
573 		SDL_FreeSurface(Img);
574 	}else
575 		boxRGBA(Lvl[Level].Bg,0,0,399,399,0x40,0x40,0x40,0xFF);
576 }
577 
578 
DrawMsg(char Msg[])579 void DrawMsg(char Msg[]){
580 	boxRGBA(screen,350,400,439,409,16,16,16,0xFF);
581 	rectangleRGBA(screen,350,400,439,409,32,32,32,0xFF);
582 	if (Msg[strlen(Msg)-1]!='!')
583 		stringRGBA(screen,351,401,Msg,200,200,200,0xFF);
584 	else
585 		stringRGBA(screen,351,401,Msg,250,50,50,0xFF);
586 	SDL_UpdateRect(screen,350,400,90,10);
587 }
588 
DrawMenu(T_E_Sel Mnu)589 void DrawMenu(T_E_Sel Mnu){
590 int I;
591 	boxRGBA(screen,Mnu.X,0,Mnu.X+19,399,64,64,64,0xFF);
592 	boxRGBA(screen,Mnu.X+19,0,Mnu.X+19,399,32,32,32,0xFF);
593 
594 	rectangleRGBA(screen,Mnu.X,0,Mnu.X+19,19,32,32,32,0xFF);
595 	lineRGBA(screen,Mnu.X+5,5,Mnu.X+10,0,200,200,200,0xFF);
596 	lineRGBA(screen,Mnu.X+10,0,Mnu.X+15,5,200,200,200,0xFF);
597 	stringRGBA(screen,Mnu.X+1,10,Mnu.Name,200,200,200,0xFF);
598 
599 	rectangleRGBA(screen,Mnu.X,380,Mnu.X+19,399,32,32,32,0xFF);
600 	lineRGBA(screen,Mnu.X+5,395,Mnu.X+10,399,200,200,200,0xFF);
601 	lineRGBA(screen,Mnu.X+10,399,Mnu.X+15,395,200,200,200,0xFF);
602 
603 	for (I=0;(I<18)&&(Mnu.Top+I<Mnu.L);I++)
604 		DrawSpr(Spr[Mnu.E[Mnu.Top+I].Spr].img,screen,Mnu.X,20+I*20);
605 
606 	if ((Mnu.Akt>=Mnu.Top)&&(Mnu.Akt<Mnu.Top+18)){
607 		rectangleRGBA(screen,Mnu.X+1,21+(Mnu.Akt-Mnu.Top)*20,Mnu.X+18,19+(Mnu.Akt-Mnu.Top)*20+19,0,0,0,128);
608 		rectangleRGBA(screen,Mnu.X,20+(Mnu.Akt-Mnu.Top)*20,Mnu.X+19,20+(Mnu.Akt-Mnu.Top)*20+19,255,255,255,128);
609 	}
610 
611 	SDL_UpdateRect(screen,Mnu.X,0,20,400);
612 }
613 
OperMenu(T_E_Sel * Mnu)614 void OperMenu(T_E_Sel *Mnu){
615 int Y;
616 	if ((MX>=Mnu->X)&&(MX<Mnu->X+20)){
617 		Y=MY/20;
618 		if ((!MBlock)&&(MB)&&(Y==0)&&(Mnu->Top)) {Mnu->Top--;DrawMenu(*Mnu);MBlock=1;}
619 		if ((!MBlock)&&(MB)&&(Y==19)&&(Mnu->Top<Mnu->L-1)) {Mnu->Top++;DrawMenu(*Mnu);MBlock=1;}
620 		if ((Y>0)&&(Y<19)&&(Mnu->Top+Y-1<Mnu->L)){
621 			if ((!MBlock)&&(MB)){Mnu->Akt=Mnu->Top+Y-1;DrawMenu(*Mnu);MBlock=1;}
622 			else DrawMsg(Mnu->E[Mnu->Top+Y-1].Desc);
623 		}
624 	}
625 }
626 
GetMenu(T_E_Sel Mnu)627 unsigned char GetMenu(T_E_Sel Mnu){
628 	return Mnu.E[Mnu.Akt].Spr;
629 }
630 
631 
DrawTxtMenu(char Mnu[10][20])632 void DrawTxtMenu(char Mnu[10][20]){
633 int I,L=0;
634 	boxRGBA(screen,0,400,419,409,64,64,64,0xFF);
635 	rectangleRGBA(screen,0,400,419,409,32,32,32,0xFF);
636 	for (I=0;(I<10)&&(Mnu[I][0]!='\0');I++){
637 		stringRGBA(screen,2+L*8,402,Mnu[I],250,250,250,0xFF);
638 		L+=strlen(Mnu[I]);
639 	}
640 	SDL_UpdateRect(screen,0,400,400,10);
641 }
642 
OperTxtMenu(char Mnu[10][20])643 char OperTxtMenu(char Mnu[10][20]){
644 int I,L=2;
645 	if ((!MBlock)&&(MB)&&(MY>400)){
646 		for (I=0;(I<10)&&(Mnu[I][0]!='\0');I++)
647 			if ((L+=strlen(Mnu[I])*8)>=MX) return I+1;
648 	}
649 	return 0;
650 }
651 
652 
SelectBgImg(void)653 void SelectBgImg(void){
654 FILE *F;
655 SDL_Surface *Img;
656 SDL_Rect Rct;
657 char Fls[256][256];
658 int I,J,C=1,Akt=0;
659 	Fls[0][0]='\0';
660 	F=fopen("./bgimages.txt","r");
661 	while ((!feof(F))&&(fgets(Fls[C],255,F)!=NULL)){
662 		while ((strlen(Fls[C]))&&(Fls[C][strlen(Fls[C])-1]<' '))
663 			Fls[C][strlen(Fls[C])-1]='\0';
664 		if (Fls[C][0]!='\0'){
665 //			fprintf(stdout,">%s\n",Fls[C]);
666 			if (!strcmp(Fls[C],Lvl[Level].BgFile)) Akt=C;
667 			C++;
668 		}
669 	}
670 	fclose(F);
671 
672 	while ((!Fire)&&(!Quit)){
673 		strcpy(Lvl[Level].BgFile,Fls[Akt]);
674 		Img=IMG_Load(Lvl[Level].BgFile);
675 		if (Img!=NULL){
676 			Rct.w=Img->w;
677 			Rct.h=Img->h;
678 			for (I=0;I<400;I+=Rct.w)
679 				for (J=0;J<400;J+=Rct.h){
680 					Rct.x=I;
681 					Rct.y=J;
682 					SDL_BlitSurface(Img,NULL,Lvl[Level].Bg,&Rct);
683 				}
684 			SDL_FreeSurface(Img);
685 		}else
686 			boxRGBA(Lvl[Level].Bg,0,0,399,399,0x40,0x40,0x40,0xFF);
687 		DrawGame();
688 		boxRGBA(screen,0,0,200,200,32,32,32,0xFF);
689 		boxRGBA(screen,0,100,200,110,64,64,64,0xFF);
690 		stringRGBA(screen,1,1,"Select BgImage:",255,255,255,0xFF);
691 		for (I=0;I<19;I++)
692 			if ((Akt-9+I>=0)&&(Akt-9+I<C))
693 				stringRGBA(screen,1,10+I*10,Fls[Akt-9+I],200,200,200,0xFF);
694 		SDL_UpdateRect(screen,0,0,200,200);
695 		while ((Fire)||(Up)||(Down)) SDL_PollEvent(&event);
696 		while ((!Fire)&&(!Up)&&(!Down)&&(!Quit)) SDL_PollEvent(&event);
697 		if ((Up)&&(Akt>0)) Akt--;
698 		if ((Down)&&(Akt<C-1)) Akt++;
699 	}
700 	DrawGame();
701 }
702 
703 
Save(char FileName[])704 char Save(char FileName[]){
705 FILE *F;
706 int I,J,K;
707 char P,S[100];
708 
709 if ((F=fopen(FileName,"w"))==NULL)
710 	return 0;
711 fprintf(F,"#	Level Definition File for X-pired (xpired.ldx)\n");
712 fprintf(F,"#\n");
713 fprintf(F,"#	Level record:\n");
714 fprintf(F,"#	>---------		- level begin (/^>-+$/)\n");
715 fprintf(F,"#	name=Name		- level name (max 100 chars)		(optional)\n");
716 fprintf(F,"#	password=psw	- level password (max 10 chars)		(optional)\n");
717 fprintf(F,"#	deadline=X		- level deadline (in secs 0-999)	(optional)\n");
718 fprintf(F,"#	background=file	- level background (would be tiled)	(optional)\n");
719 fprintf(F,"#	X=some text		- text message definition (X-text ID (0-9), Text length must by less than 50 chars.)\n");
720 fprintf(F,"#	- Follows 20 lines consisting of 20 chunks ',FfBbXT' (level matrix 20x20) (F-foreground type, f-foreground sprite, B-background type, b-background sprite, X-effector, T-message ID).\n");
721 fprintf(F,"#	- Unrecognized and empty lines or lines beginning with # are ignored.\n");
722 fprintf(F,"#\n");
723 fprintf(F,"#	Level elems:\n");
724 fprintf(F,"#	*...Start position\n");
725 fprintf(F,"#	+...Exit position\n");
726 fprintf(F,"#	c...Crate\n");
727 fprintf(F,"#	o...Barrel\n");
728 fprintf(F,"#	O...HiExplosive\n");
729 fprintf(F,"#	X...Wall\n");
730 fprintf(F,"#	x...Tiny wall\n");
731 fprintf(F,"#	B...BEM\n");
732 fprintf(F,"#	%%...Retarder\n");
733 fprintf(F,"#	&...Flamable\n");
734 fprintf(F,"#	@...Hot\n");
735 fprintf(F,"#	#...Ice\n");
736 fprintf(F,"#	T...Teleport\n");
737 fprintf(F,"\n");
738 
739 fprintf(F,"\n");
740 for (I=0;(I<100)&&(Lvl[I].Name[0]!='\0');I++){
741 	fprintf(F,">--------------------\n");
742 	fprintf(F,"name=%s\n",Lvl[I].Name);
743 	if (Lvl[I].Pw[0]!='\0')
744 		fprintf(F,"password=%s\n",Lvl[I].Pw);
745 	if (Lvl[I].BgFile[0]!='\0')
746 		fprintf(F,"background=%s\n",Lvl[I].BgFile);
747 	if (Lvl[I].DL)
748 		fprintf(F,"deadline=%d\n",Lvl[I].DL);
749 	for (J=0;J<20;J++){
750 		for (K=0;K<20;K++){
751 			if (Lvl[I].M[K][J].txt<0)
752 				P=' ';
753 			else
754 				P='0'+Lvl[I].M[K][J].txt;
755 			fprintf(F,",%c%c%c%c%d%c",Lvl[I].M[K][J].FTyp,Lvl[I].M[K][J].FSpr,Lvl[I].M[K][J].BTyp,Lvl[I].M[K][J].BSpr,Lvl[I].M[K][J].f,P);
756 		}
757 		fprintf(F,"\n");
758 	}
759 	for (J=0;J<10;J++)
760 		if (Lvl[I].Text[J][0]!='\0')
761 			fprintf(F,"%d=%s\n",J,Lvl[I].Text[J]);
762 }
763 
764 fclose(F);
765 return 1;
766 }
767 
768 
GetString(char * Dest,int MaxLen,int X,int Y)769 char GetString(char *Dest,int MaxLen,int X, int Y){
770 int P=strlen(Dest);
771 char *Bck;
772 
773 	Bck=(char *)malloc(strlen(Dest)+1);
774 	strcpy(Bck,Dest);
775 
776 	do{
777 		boxRGBA(screen,X,Y,X+((MaxLen<50)?MaxLen:50)*8,Y+10,100,55,55,255);
778 		if (strlen(Dest)<=50)
779 			stringRGBA(screen,X+1,Y+1,Dest,250,250,250,255);
780 		else
781 			stringRGBA(screen,X+1,Y+1,Dest+(strlen(Dest)-50),250,250,250,255);
782 		SDL_UpdateRect(screen,X,Y,((MaxLen<50)?MaxLen:50)*8,10);
783 		UC=0;
784 		do {SDL_PollEvent(&event);}
785 		while (!UC);
786 //		fprintf(stdout,"'%c'\n",Key);
787 		if (UC==8){
788 			if (P>0){
789 				P--;
790 				Dest[P]='\0';
791 			}
792 		}
793 		else
794 		if ((!Fire)&&(!Quit)&&(P<MaxLen)){
795 			Dest[P]=UC;
796 			P++;
797 			Dest[P]='\0';
798 		}
799 	}while ((!Fire)&&(!Quit)&&(UC!=13));
800 
801 	if (Quit){
802 		strcpy(Dest,Bck);
803 		free(Bck);
804 		return 0;
805 	}
806 
807 	free(Bck);
808 	return 1;
809 }
810 
811 
InputScr(char * Title)812 void InputScr(char *Title){
813 	boxRGBA(screen,0,150,399,250,55,55,55,255);
814 	stringRGBA(screen,1,151,Title,255,255,255,255);
815 	SDL_UpdateRect(screen,0,150,400,100);
816 }
817 
818 
DrawMessages(void)819 void DrawMessages(void){
820 char Str[55],I;
821 	boxRGBA(screen,0,0,399,100,100,100,100,255);
822 	for (I=0;I<10;I++){
823 		sprintf(Str,"%d:%s",I,Lvl[Level].Text[I]);
824 		stringRGBA(screen,0,I*10,Str,200,200,200,255);
825 	}
826 	SDL_UpdateRect(screen,0,0,400,100);
827 }
828 
SetMessages(void)829 void SetMessages(void){
830 char M;
831 	DrawTxtMenu(M_Msg);
832 	DrawMsg("...Esc");
833 	DrawMessages();
834 	while (MB)
835 		SDL_PollEvent(&event);
836 	do{
837 		SDL_PollEvent(&event);
838 		if (M=OperTxtMenu(M_Msg)){
839 			InputScr("Enter message:");
840 			GetString(Lvl[Level].Text[M-1],50,1,195);
841 			DrawGame();
842 			DrawMessages();
843 		}
844 	} while (!Quit);
845 	DrawGame();
846 	DrawTxtMenu(M_Txt);
847 	DrawMsg("");
848 }
849 
850 // --------------------
Edit(void)851 void Edit(void){
852 char M,Str[256];
853 int I,LX,LY;
854 SetLevel(0);
855 DrawGame();
856 DrawMenu(M_Fg);
857 DrawMenu(M_Bg);
858 DrawTxtMenu(M_Txt);
859 DrawMsg("");
860 while (1){
861 	LX=MX;
862 	LY=MY;
863 	UC=0;
864 	if (!MB)
865 		SDL_Delay(200);
866 	else
867 		SDL_Delay(50);
868 	SDL_PollEvent(&event);
869 	OperMenu(&M_Fg);
870 	OperMenu(&M_Bg);
871 	if ((UC>='0')&&(UC<='9')){
872 		Lvl[Level].M[MX/20][MY/20].txt=UC-'0';
873 		DrawGame();
874 	}
875 	if (Shift){
876 		Lvl[Level].M[MX/20][MY/20].txt=-1;
877 		DrawGame();
878 	}
879 	if ((MB==1)&&(MX<400)&&(MY<400)){
880 		if ((LX/20!=MX/20)||(LY/2!=MY/20))
881 			MBlock=0;
882 		if (!MBlock){
883 			Lvl[Level].M[MX/20][MY/20].FSpr=M_Fg.E[M_Fg.Akt].Spr;
884 			Lvl[Level].M[MX/20][MY/20].FTyp=M_Fg.E[M_Fg.Akt].Typ;
885 			Lvl[Level].M[MX/20][MY/20].BSpr=M_Bg.E[M_Bg.Akt].Spr;
886 			Lvl[Level].M[MX/20][MY/20].BTyp=M_Bg.E[M_Bg.Akt].Typ;
887 			MBlock=1;
888 			DrawGame();
889 		}
890 	}
891 	if ((MB==2)&&(MX<400)&&(MY<400)){
892 		for (I=0;I<M_Fg.L;I++)
893 			if ((Lvl[Level].M[MX/20][MY/20].FSpr==M_Fg.E[I].Spr)&&(Lvl[Level].M[MX/20][MY/20].FTyp==M_Fg.E[I].Typ)){
894 				M_Fg.Top=M_Fg.Akt=I;
895 				DrawMenu(M_Fg);
896 			}
897 		for (I=0;I<M_Bg.L;I++)
898 			if ((Lvl[Level].M[MX/20][MY/20].BSpr==M_Bg.E[I].Spr)&&(Lvl[Level].M[MX/20][MY/20].BTyp==M_Bg.E[I].Typ)){
899 				M_Bg.Top=M_Bg.Akt=I;
900 				DrawMenu(M_Bg);
901 			}
902 		MBlock=1;
903 		DrawGame();
904 	}
905 	if (M=OperTxtMenu(M_Txt)){
906 		if (M==1){			//name
907 			InputScr("Enter level name:");
908 			GetString(Lvl[Level].Name,50,1,195);
909 			SetCaption();
910 			DrawGame();
911 		}
912 		else if (M==2){			//password
913 			InputScr("Enter level password:");
914 			GetString(Lvl[Level].Pw,10,1,195);
915 			SetCaption();
916 			DrawGame();
917 		}
918 		else if (M==3){		//timer
919 			InputScr("Enter time limit (0-999 secs):");
920 			sprintf(Str,"%d",Lvl[Level].DL);
921 			GetString(Str,3,1,195);
922 			Lvl[Level].DL=atoi(Str);
923 			DrawGame();
924 		}
925 		else if (M==4)		//bgimg
926 			SelectBgImg();
927 		else if (M==5)		//txt
928 			SetMessages();
929 		else if (M==6){		//go to
930 			InputScr("Enter level no. (0-99):");
931 			sprintf(Str,"%d",Level);
932 			GetString(Str,2,1,195);
933 			Level=atoi(Str);
934 			SetLevel(Level);
935 			DrawGame();
936 		}
937 		else if (M==7){		//save
938 			InputScr("Enter filename:");
939 			if (GetString(LFile,255,1,195)){
940 				if (Save(LFile))
941 					DrawMsg("Saved...");
942 				else
943 					DrawMsg("Can't save!");
944 			}else
945 				DrawMsg("Aborted...");
946 			DrawGame();
947 		}
948 	}
949 	if (Up&&(Level<99)){
950 		SetLevel(Level+1);
951 		DrawGame();
952 		SDL_Delay(200);
953 	}
954 	if ((Down)&&(Level>0)){
955 		SetLevel(Level-1);
956 		DrawGame();
957 		SDL_Delay(200);
958 	}
959 
960 	if (Quit==2)
961 		return;
962 }
963 }
964 
965 
966 
967 // MAIN ---------------------------------
main(int argc,char * argv[])968 int main(int argc, char *argv[]){
969 int I;
970 char buf[255];
971 
972 #ifdef UNIX
973   strcpy(GAME_HOME,getenv("HOME"));
974   strcat(GAME_HOME,"/.xpired");
975 #else
976   strcpy(GAME_HOME,".");
977 #endif
978 
979   sprintf(ConfFName,"%s/xpired.cfg",GAME_HOME);
980 
981   if(!LoadConfig(ConfFName))
982   {
983     sprintf(buf,"%s/xpired.cfg",SHARE_DIR);
984     LoadConfig(buf);
985   }
986 
987   sprintf(LFile,"%s/xpired.lvl",SHARE_DIR);
988 
989   for (I=1;I<argc;I++){
990     if ((!strcmp("--help",argv[I]))||(!strcmp("-h",argv[I]))){
991 		fprintf(stdout,"Example of usage: %s --nosound -l levelfile.lvl -d demo.dmo\n",argv[0]);
992 		fprintf(stdout," Switches:\n");
993 		fprintf(stdout,"   -f, --fullscreen    Toggle fullscreen/windowed\n");
994 		fprintf(stdout,"   -l  <file>          Load level from <file>\n");
995 		fprintf(stdout,"   -h, --help          Display this help screen\n");
996 		fprintf(stdout,"   --version           Display version no.\n");
997 		return 0;
998     }else if (!strcmp("-l",argv[I])){
999       strcpy(LFile,argv[++I]);
1000     }else if (!strcmp("-f",argv[I]) || !strcmp("--fullscreen",argv[I])){
1001       FULLSCR=!FULLSCR;
1002     }else if (!strcmp("--version",argv[I])){
1003 		fprintf(stdout,"%s ver. %s \n",APPNAME,VERSION);
1004 		return 0;
1005 	}
1006   }
1007 
1008 	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
1009 		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
1010 		exit(1);
1011 	}
1012 	atexit(SDL_Quit);
1013 
1014 	SDL_WM_SetCaption(APPNAME,APPNAME);
1015 
1016   sprintf(buf,"%s/img/icon.bmp",SHARE_DIR);
1017 
1018 	SDL_WM_SetIcon(IMG_Load(buf), NULL);
1019 	VIDEO_INIT();
1020 	SDL_ShowCursor(SDL_ENABLE);
1021 	SDL_SetEventFilter(E_FILTER);
1022 	SDL_EnableKeyRepeat(0,0);
1023 	SDL_EnableUNICODE(1);
1024 
1025 	LoadSprites();
1026 	LoadLevels(LFile);
1027 
1028 	if (Shades){
1029 		Sh=SDL_CreateRGBSurface(SDL_SRCALPHA,400,400,BPP,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,screen->format->Amask);
1030 		if (Sh==NULL) fprintf(stderr,"SH neni!!\n");
1031 		SDL_SetColorKey(Sh,SDL_SRCCOLORKEY,SDL_MapRGB(Sh->format,255,0,255));
1032 		SDL_SetAlpha(Sh,SDL_SRCALPHA,Shades);
1033 	}
1034 
1035 //--- MNU DEFS
1036 	M_Fg.X=400;
1037 	M_Fg.Top=0;
1038 	M_Fg.Akt=0;
1039 	M_Fg.L=7;
1040 	strcpy(M_Fg.Name,"Fg");
1041 	M_Fg.E[0].Spr=' ';
1042 	M_Fg.E[0].Typ=' ';
1043 	strcpy(M_Fg.E[0].Desc,"None");
1044 	M_Fg.E[1].Spr='X';
1045 	M_Fg.E[1].Typ='X';
1046 	strcpy(M_Fg.E[1].Desc,"Wall");
1047 	M_Fg.E[2].Spr='x';
1048 	M_Fg.E[2].Typ='x';
1049 	strcpy(M_Fg.E[2].Desc,"TinyWall");
1050 	M_Fg.E[3].Spr='c';
1051 	M_Fg.E[3].Typ='c';
1052 	strcpy(M_Fg.E[3].Desc,"Crate");
1053 	M_Fg.E[4].Spr='o';
1054 	M_Fg.E[4].Typ='o';
1055 	strcpy(M_Fg.E[4].Desc,"Barrel");
1056 	M_Fg.E[5].Spr='O';
1057 	M_Fg.E[5].Typ='O';
1058 	strcpy(M_Fg.E[5].Desc,"HiExplosive");
1059 	M_Fg.E[6].Spr='B';
1060 	M_Fg.E[6].Typ='B';
1061 	strcpy(M_Fg.E[6].Desc,"BEM");
1062 
1063 	M_Bg.X=420;
1064 	M_Bg.Top=0;
1065 	M_Bg.Akt=0;
1066 	M_Bg.L=8;
1067 	strcpy(M_Bg.Name,"Bg");
1068 	M_Bg.E[0].Spr=' ';
1069 	M_Bg.E[0].Typ=' ';
1070 	strcpy(M_Bg.E[0].Desc,"None");
1071 	M_Bg.E[1].Spr='*';
1072 	M_Bg.E[1].Typ='*';
1073 	strcpy(M_Bg.E[1].Desc,"Start");
1074 	M_Bg.E[2].Spr='+';
1075 	M_Bg.E[2].Typ='+';
1076 	strcpy(M_Bg.E[2].Desc,"Exit");
1077 	M_Bg.E[3].Spr='%';
1078 	M_Bg.E[3].Typ='%';
1079 	strcpy(M_Bg.E[3].Desc,"Retarder");
1080 	M_Bg.E[4].Spr='#';
1081 	M_Bg.E[4].Typ='#';
1082 	strcpy(M_Bg.E[4].Desc,"Ice");
1083 	M_Bg.E[5].Spr='&';
1084 	M_Bg.E[5].Typ='&';
1085 	strcpy(M_Bg.E[5].Desc,"Flamable");
1086 	M_Bg.E[6].Spr='@';
1087 	M_Bg.E[6].Typ='@';
1088 	strcpy(M_Bg.E[6].Desc,"Hot! ");
1089 	M_Bg.E[7].Spr='T';
1090 	M_Bg.E[7].Typ='T';
1091 	strcpy(M_Bg.E[7].Desc,"Teleport");
1092 
1093 	strcpy(M_Txt[0],"Name|");
1094 	strcpy(M_Txt[1],"Pw|");
1095 	strcpy(M_Txt[2],"Timer|");
1096 	strcpy(M_Txt[3],"BgImg|");
1097 	strcpy(M_Txt[4],"Msg|");
1098 	strcpy(M_Txt[5],"GoTo|");
1099 	strcpy(M_Txt[6],"Save|");
1100 	M_Txt[7][0]='\0';
1101 
1102 	strcpy(M_Msg[0],"T0|");
1103 	strcpy(M_Msg[1],"T1|");
1104 	strcpy(M_Msg[2],"T2|");
1105 	strcpy(M_Msg[3],"T3|");
1106 	strcpy(M_Msg[4],"T4|");
1107 	strcpy(M_Msg[5],"T5|");
1108 	strcpy(M_Msg[6],"T6|");
1109 	strcpy(M_Msg[7],"T7|");
1110 	strcpy(M_Msg[8],"T8|");
1111 	strcpy(M_Msg[9],"T9|");
1112 
1113 	Edit();
1114 
1115 	SDL_Quit();
1116 	return 0;
1117 }
1118