Description: Debian diff as of version 0.62.dfsg2-3

--- a/MOGtypes.h
+++ b/MOGtypes.h
@@ -5,7 +5,6 @@
 
 #define min(a,b) ((a)<(b) ? (a) : (b))
 #define max(a,b) ((a)>(b) ? (a) : (b))
-#define abs(a) ((a)<0 ? (-(a)) : (a))
 
 #endif
 
--- a/Makefile
+++ b/Makefile
@@ -19,4 +19,10 @@
 
 clean:
 	rm -f mog mogs
-	rm -f *.o 
\ No newline at end of file
+	rm -f *.o
+
+install:
+	cp mog $(DESTDIR)/usr/games
+
+install-data:
+	cp sound rooms graphics -r $(DESTDIR)/usr/share/games/mazeofgalious/
--- /dev/null
+++ b/MoG.cfg
@@ -0,0 +1,5 @@
+113 97 111 112
+32 109 282 283
+graphics/naramura/
+sound/alternate/
+127 127
--- a/debug-report.cpp
+++ b/debug-report.cpp
@@ -30,7 +30,7 @@
 
 
 /* Gráficos: */ 
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp,*enemy2_bmp,*demon_bmp,*final_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp,*enemy2_bmp,*demon_bmp,*final_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 
@@ -192,7 +192,7 @@
 
 	fprintf(fp,"Graphic files:\n");
 	fprintf(fp,"konami: %p\nmenu: %p\ntiles: %p\nenemy: %p\nenemy2: %p\ndemon: %p\nfinal: %p\n",
-			konami_bmp,menu_bmp,tiles_bmp,enemy_bmp,enemy2_bmp,demon_bmp,final_bmp);
+			thegnu_bmp,menu_bmp,tiles_bmp,enemy_bmp,enemy2_bmp,demon_bmp,final_bmp);
 
 	fprintf(fp,"music_volume: %i\n",music_volume);
 	fprintf(fp,"sfx_volume: %i\n",sfx_volume);
--- a/demons.cpp
+++ b/demons.cpp
@@ -26,7 +26,7 @@
 
 /* Gráficos: */ 
 Bitmap *demon_bmp=0,*back_bmp=0;
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*tiles2_bmp,*enemy_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*tiles2_bmp,*enemy_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 
--- a/gameaux.cpp
+++ b/gameaux.cpp
@@ -1,6 +1,7 @@
 #include "math.h"
 #include "stdio.h"
 #include "stdlib.h" 
+#include "unistd.h" 
 #include "string.h"
 #include "SDL/SDL.h"
 #include "SDL_image.h"
@@ -26,9 +27,11 @@
 extern char **s_paths;
 extern int n_s_paths,act_s_path;
 extern char *s_path;
+
+extern char *datadir;
 
 /* Gráficos: */ 
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*tiles2_bmp,*enemy_bmp,*enemy2_bmp,*final_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*tiles2_bmp,*enemy_bmp,*enemy2_bmp,*final_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 extern SDL_Surface *screen;
@@ -214,8 +217,8 @@
 	tiles2_bmp=0;
 	delete menu_bmp;
 	menu_bmp=0;
-	delete konami_bmp;
-	konami_bmp=0;
+	delete thegnu_bmp;
+	thegnu_bmp=0;
 	delete final_bmp;
 	final_bmp=0;
 
@@ -1710,7 +1713,9 @@
 
 	sprintf(filename,"rooms/%s%.2i%.2i.txt",prefixes[map],map_x,map_y);
 
-	fp=fopen(filename,"r+");
+	chdir(datadir);
+	/* fp=fopen(filename,"r+"); */
+	fp=fopen(filename,"r");
 	if (fp==NULL) return false;
 
 	/* Leer fondo: */ 
@@ -3028,13 +3033,13 @@
 	/* Get the palette: */ 
 	SDL_Surface *img=0;
 
-	sprintf(tmp,"%skonami.pcx",g_path);
+	sprintf(tmp,"%sthegnu.pcx",g_path);
 	img = IMG_Load(tmp);
 	if (img!=0) {
 		SDL_SetColors(screen, img->format->palette->colors, 0, img->format->palette->ncolors);
 		SDL_FreeSurface(img);
 	} else {
-		sprintf(tmp,"%skonami.pcx",default_g_path);
+		sprintf(tmp,"%sthegnu.pcx",default_g_path);
 		img = IMG_Load(tmp);
 		if (img!=0) {
 			SDL_SetColors(screen, img->format->palette->colors, 0, img->format->palette->ncolors);
--- a/gamecycle.cpp
+++ b/gamecycle.cpp
@@ -1,6 +1,7 @@
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <string.h>
 #include <ctype.h>
 #include "SDL/SDL.h"
@@ -46,9 +47,11 @@
 extern char **s_paths;
 extern int n_s_paths,act_s_path;
 extern char *s_path;
+extern char *datadir;
+extern char *confdir;
 
 /* Gráficos: */ 
-Bitmap *konami_bmp=0,*menu_bmp=0,*tiles_bmp=0,*tiles2_bmp=0,*enemy_bmp=0,*enemy2_bmp=0,*final_bmp=0;
+Bitmap *thegnu_bmp=0,*menu_bmp=0,*tiles_bmp=0,*tiles2_bmp=0,*enemy_bmp=0,*enemy2_bmp=0,*final_bmp=0;
 int n_tiles=0;
 CTile **tiles=0;
 
@@ -64,7 +67,7 @@
 /* Juego: */ 
 int inter_screen=0;
 int frame_counter=0;
-bool pause=false;
+bool pause2=false;
 
 int pause_state=0;
 int map=0;			/* En que mundo está el personaje			*/ 
@@ -331,32 +334,34 @@
 
 	switch(STATE) {
 
-	/* APARECIENDO SIMBOLO DE KONAMI: */ 
+	/* APARECIENDO SIMBOLO DE THEGNU: */ 
 	case 0:	{
 				int i;
 
 				if (SUBSTATE==0) {
 					init_paths();
+					chdir(confdir);
 					if (!cargar_configuracion("MoG.cfg")) {
 						configuracion_por_defecto();
 						guardar_configuracion("MoG.cfg");
 					} /* if */ 
+					chdir(datadir);
 					GameEnd();
 					GameInit(dx,dy);
 					HP_objs_reset();
 //					Mix_VolumeMusic(music_volume);
 					SetSFXVolume(sfx_volume);
 					/* Borrar la pantalla: */ 
-					memset(screen,konami_bmp->get_image()[0],dx*dy);
-//					set_palete((BYTE *)konami_bmp->get_palete());
+					memset(screen,thegnu_bmp->get_image()[0],dx*dy);
+//					set_palete((BYTE *)thegnu_bmp->get_palete());
 
 					for(;SUBSTATE<25;SUBSTATE++) {
-						konami_bmp->draw_sprite(0,SUBSTATE,konami_bmp->get_ancho(),1,0,SUBSTATE*(dy/200),dx,1,screen,dx,dy,dx);
+						thegnu_bmp->draw_sprite(0,SUBSTATE,thegnu_bmp->get_ancho(),1,0,SUBSTATE*(dy/200),dx,1,screen,dx,dy,dx);
 					} /* for */ 
 				} /* if */ 
 
 				for(i=0;i<SUBSTATE*(dy/200);i++) {
-					konami_bmp->draw_sprite(0,i,konami_bmp->get_ancho(),1,0,i,dx,1,screen,dx,dy,dx);
+					thegnu_bmp->draw_sprite(0,i,thegnu_bmp->get_ancho(),1,0,i,dx,1,screen,dx,dy,dx);
 				} /* for */ 
 				SUBSTATE++;
 				if (SUBSTATE>=200) {
@@ -371,7 +376,7 @@
 			}
 			break;
 	case 1:	SUBSTATE++;
-			konami_bmp->draw(0,0,dx,dy,screen,dx,dy,dx);
+			thegnu_bmp->draw(0,0,dx,dy,screen,dx,dy,dx);
 			if (SUBSTATE>100) {
 				SUBSTATE=0;
 				STATE=2;
@@ -474,7 +479,7 @@
 				in_ladder=-1;
 				previous_x_collision=false;
 				previous_y_collision=false;
-				pause=false;
+				pause2=false;
 			} /* if */ 
 
 			if (next_world>=10 && world10_door_x==-1) {
@@ -491,7 +496,7 @@
 
 			check_typed_word();
 
-			if (!pause) {
+			if (!pause2) {
 				if (room_demonroom) {
 					if ((next_world<=1 && fighting_demon==0 && map==1 && typed_word_p("yomar")) ||
 						(next_world<=2 && fighting_demon==0 && map==2 && typed_word_p("elohim")) ||
@@ -694,7 +699,7 @@
 				GameRoomEvents();
 				RoomChange();
 			} else {
-				if (typed_word_p("zeus") && map==0 && map_x==5 && map_y==12 && pause) {
+				if (typed_word_p("zeus") && map==0 && map_x==5 && map_y==12 && pause2) {
 					ZEUS_password=true;
 				} /* if */ 
 				if (pause_state<0) {
@@ -724,7 +729,7 @@
 				STATE=19;
 			} /* if */ 
 
-			if (keyboard[ITEM_KEY] && !old_keyboard[ITEM_KEY] && player_energy[character]>0 && !pause && to_enter_cut==0) {
+			if (keyboard[ITEM_KEY] && !old_keyboard[ITEM_KEY] && player_energy[character]>0 && !pause2 && to_enter_cut==0) {
 				Sound_play(S_F1);
 				currently_selecting=0;
 				STATE=5;
@@ -732,8 +737,8 @@
 			} /* if */ 
 
 			if (keyboard[PAUSE_KEY] && !old_keyboard[PAUSE_KEY]) {
-				pause=(pause ? false:true);
-				if (pause) {
+				pause2=(pause2 ? false:true);
+				if (pause2) {
 					pause_state=-256;
 					Sound_pause_music();
 					Sound_play(S_pause);
@@ -1377,7 +1382,9 @@
 					 (keyboard[SDLK_k] && !old_keyboard[SDLK_k]))) {
 					STATE=2;
 					SUBSTATE=0;
+					chdir(confdir);
 					guardar_configuracion("MoG.cfg");
+					chdir(datadir);
 				} /* if */ 
 			}
 			break;
@@ -1705,7 +1712,9 @@
 						FILE *fp;
 
 						sprintf(tmp,"sgame%.2i.txt",slot);
+						chdir(confdir);
 						fp=fopen(tmp,"r");
+						chdir(datadir);
 						if (fp!=0) {
 							int i;
 							for(i=0;i<48;i++) {
@@ -1953,6 +1962,7 @@
 				sprintf(filename,"rooms/%s%.2i%.2i.txt",prefixes[developer_start_map],
 														developer_start_x,
 														developer_start_y);
+				chdir(datadir);
 				fp=fopen(filename,"r");
 				if (fp!=0) {
 					tile_print("PRESS SPACE TO START",TILE_SIZE_X*9,TILE_SIZE_Y*8,screen,dx,dy);
@@ -2277,7 +2287,9 @@
 
 				if (keyboard[SDLK_ESCAPE] && !old_keyboard[SDLK_ESCAPE]) {
 					STATE=OLDSTATE;
+					chdir(confdir);
 					guardar_configuracion("MoG.cfg");
+					chdir(datadir);
 				} /* if */ 
 				if (keyboard[DOWN_KEY] && !old_keyboard[DOWN_KEY] && MENUOPTION<2) MENUOPTION++;
 				if (keyboard[UP_KEY] && !old_keyboard[UP_KEY] && MENUOPTION>0) MENUOPTION--;
@@ -2286,7 +2298,9 @@
 					Sound_release_music();
 					STATE=0;
 					SUBSTATE=0;
+					chdir(confdir);
 					guardar_configuracion("MoG.cfg");
+					chdir(datadir);
 				} /* if */ 
 
 				if (keyboard[RIGHT_KEY] && MENUOPTION==1 && music_volume<127) {
--- a/gameinteractions.cpp
+++ b/gameinteractions.cpp
@@ -16,7 +16,7 @@
 
 
 /* Gráficos: */ 
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 
--- a/gameobjects.cpp
+++ b/gameobjects.cpp
@@ -16,7 +16,7 @@
 
 
 /* Gráficos: */ 
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 
--- a/gametiles.cpp
+++ b/gametiles.cpp
@@ -24,7 +24,7 @@
 extern char *g_path;
 
 /* Gráficos: */ 
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*tiles2_bmp,*enemy_bmp,*enemy2_bmp,*final_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*tiles2_bmp,*enemy_bmp,*enemy2_bmp,*final_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 
@@ -126,7 +126,7 @@
 	int i;
 
 	/* Gráficos: */ 
-	konami_bmp=load_bitmap("konami.pcx");
+	thegnu_bmp=load_bitmap("thegnu.pcx");
 
 	menu_bmp=load_bitmap("start.pcx");
 	tiles_bmp=load_bitmap("tiles.pcx");
@@ -135,7 +135,7 @@
 	enemy2_bmp=load_bitmap("enemy2.pcx");
 	final_bmp=load_bitmap("final.pcx");
 
-	if (konami_bmp==0 ||
+	if (thegnu_bmp==0 ||
 		menu_bmp==0 ||
 		tiles_bmp==0 ||
 		tiles2_bmp==0 ||
@@ -146,7 +146,7 @@
 		return;
 	} /* if */ 
 
-	if (konami_bmp->get_image()==0 ||
+	if (thegnu_bmp->get_image()==0 ||
 		menu_bmp->get_image()==0 ||
 		tiles_bmp->get_image()==0 ||
 		tiles2_bmp->get_image()==0 ||
--- a/ingamecycle.cpp
+++ b/ingamecycle.cpp
@@ -18,7 +18,7 @@
 // FILE *fp2;
 
 /* Gráficos: */ 
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 
--- a/main.cpp
+++ b/main.cpp
@@ -8,6 +8,10 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #include "SDL/SDL.h"
 #include "SDL_mixer.h"
 #include "sound.h"
@@ -40,7 +44,7 @@
 int init_time=0;
 
 /* Paths: */ 
-char *default_g_path="graphics/original/";
+char *default_g_path="graphics/alternate/";
 char *default_s_path="sound/original/";
 char **g_paths=0;
 int n_g_paths=0,act_g_path=0;
@@ -48,6 +52,9 @@
 char **s_paths=0;
 int n_s_paths=0,act_s_path=0;
 char *s_path=0;
+
+char *confdir;
+char *datadir="/usr/share/games/mazeofgalious/";
 
 extern int music_volume,sfx_volume;
 extern int fighting_demon;
@@ -103,6 +110,18 @@
 int main(int argc, char** argv)
 {
 	setupTickCount();
+	mode_t mode;
+
+	confdir=(char*)malloc(strlen(getenv("HOME"))+50);
+	strcpy(confdir,getenv("HOME"));
+	strcat(confdir,"/.mog");
+	chdir(confdir);
+	mode=S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP;
+	mkdir(confdir,mode);
+
+	printf("Configuration: %s\n",confdir);
+	printf("Data: %s\n",datadir);
+	chdir(datadir);
 #endif
 
 	int time,act_time;
@@ -165,7 +184,9 @@
 						g_path=g_paths[act_g_path];
 						ReleaseGraphics();
 						ReloadGraphics(SCREEN_X,SCREEN_Y);
+						chdir(confdir);
 						guardar_configuracion("MoG.cfg");
+						chdir(datadir);
 						if (fighting_demon!=0) redo_demonintro(fighting_demon,0,SCREEN_X,SCREEN_Y);
 					} /* if */ 
 					if (event.key.keysym.sym==SDLK_F11) {
@@ -176,13 +197,17 @@
 						ReleaseSound(false);
 						ReloadSound();
 						music_recovery();
+						chdir(confdir);
 						guardar_configuracion("MoG.cfg");
+						chdir(datadir);
 						Mix_VolumeMusic(music_volume);
 						SetSFXVolume(sfx_volume);
 					} /* if */ 
 
 					if (event.key.keysym.sym==SDLK_d) {
+						chdir(confdir);
 						write_debug_report("debug-report.txt");
+						chdir(datadir);
 					} /* if */ 
                     break;
 
@@ -204,6 +229,7 @@
 
 			SDL_Flip(screen);
 		}
+		SDL_Delay(1);
 	}
 
 
--- a/roomchange.cpp
+++ b/roomchange.cpp
@@ -15,7 +15,7 @@
 
 
 /* Gráficos: */ 
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 
--- a/shrines.cpp
+++ b/shrines.cpp
@@ -1,6 +1,7 @@
 #include "math.h"
 #include "stdio.h"
 #include "stdlib.h"
+#include "unistd.h"
 #include "SDL/SDL.h"
 #include "SDL_mixer.h"
 #include "sound.h"
@@ -15,8 +16,11 @@
 const int MAX_FIRED_ARROWS[2]={2,3};
 
 
+extern char *datadir;
+extern char *confdir;
+
 /* Gráficos: */ 
-extern Bitmap *konami_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
+extern Bitmap *thegnu_bmp,*menu_bmp,*tiles_bmp,*enemy_bmp;
 extern int n_tiles;
 extern CTile **tiles;
 
@@ -264,7 +268,9 @@
 			generatepassword(passwd);
 
 			sprintf(tmp,"sgame%.2i.txt",slot);
+			chdir(confdir);
 			fp=fopen(tmp,"w");
+			chdir(datadir);
 			if (fp!=0) {
 				int i;
 				for(i=0;i<48;i++) {
--- a/sound.cpp
+++ b/sound.cpp
@@ -3,6 +3,7 @@
 #include "SDL_sound.h"
 #include "sound.h"
 #include "stdio.h"
+#include "unistd.h"
 #include "string.h"
 #include "stdlib.h"
 #include "MOGtypes.h"
@@ -20,6 +21,8 @@
 extern int n_s_paths,act_s_path;
 extern char *s_path;
 extern int music_volume;
+
+extern char *datadir;
 
 bool sound_enabled=false;
 
@@ -89,6 +92,8 @@
 {
 	FILE *fp;
 
+	/* printf("%s\n",fname); */
+	chdir(datadir);
 	if ((fp=fopen(fname,"r"))!=NULL) {
 		if (fseek(fp,0L, SEEK_END)==0 && ftell(fp)>0) {
   			fclose(fp);
@@ -107,7 +112,7 @@
 SOUNDT Sound_create_sound(char *file,int flags)
 {
 	int n_ext=6;
-	char *ext[6]={".WAV",".OGG",".MP3",".wav",".ogg",".mp3"};
+	char *ext[6]={".wav",".ogg",".mp3",".WAV",".OGG",".MP3"};
 	char name[256],name2[256];
 	int i;
 
@@ -124,6 +129,12 @@
 			sprintf(name2,"%s%s",default_s_path,name);
 			if (file_check(name2)) return Mix_LoadWAV(name2);
 		} /* for */ 
+/*		for(i=0;i<n_ext;i++) {
+			strcpy(name,file);
+			strcat(name,ext[i]);
+			sprintf(name2,"%s%s%s",datadir,"/sound/original/",name);
+			if (file_check(name2)) return Mix_LoadWAV(name2);
+		} */ 
 
 		fprintf(stderr,"ERROR in Sound_create_sound(): Could not load sound file: %s%s.(wav|ogg|mp3)\n",s_path, file);
 		exit(1);
