git » fp-git.git » commit cd43340

tile grouping configuration parsing scripts

author ecalot
2004-10-19 06:06:20 UTC
committer ecalot
2004-10-19 06:06:20 UTC
parent 4353674d306ac086ab56939fc7a459d658dc8e5a

tile grouping configuration parsing scripts

FP/src/conf/awk/tiles_conf_groups.awk +64 -0
FP/src/conf/awk/tiles_conf_types.awk +40 -0
FP/src/include/map_defs.h +2 -32

diff --git a/FP/src/conf/awk/tiles_conf_groups.awk b/FP/src/conf/awk/tiles_conf_groups.awk
new file mode 100644
index 0000000..691f658
--- /dev/null
+++ b/FP/src/conf/awk/tiles_conf_groups.awk
@@ -0,0 +1,64 @@
+#   Princed V3 - Prince of Persia Level Editor for PC Version
+#   Copyright (C) 2003 Princed Development Team
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#   The authors of this program may be contacted at http://forum.princed.com.ar
+
+# tiles_conf_groups.awk: FreePrince : tiles.conf to tiles_conf_groups.h parser
+# \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+# Copyright 2004, 2003 Princed Development Team
+#  Created: 19 Oct 2004
+#
+#  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+#
+# Note:
+#  DO NOT remove this copyright notice
+#
+
+/^[ ]*tile .*$/ {
+	tile=sprintf("T_%s",$2)
+}
+
+$0 !~ /^[ ]*(#.*|tile .*|[ ]*)$/ {
+	for (i=1;i<=NF;i++) {
+		if (!total[$i]) total[$i]=0
+		groups[$i,total[$i]]=tile
+		total[$i]++;
+	}
+}
+
+END {
+	offset=0
+	coma=""
+	printf "#define TILES_GROUP_LIST {"
+	for (group in total) {
+		offsets[group]=offset
+		for (i=0;i<total[group];i++) {
+			printf "%s%s+1",coma,groups[group,i]
+			coma=","
+			offset++
+			if (offset%5==0) printf("\\\n")
+		}
+		printf ",0"
+		offset++
+		if (offset%5==0) printf("\\\n")
+	}
+	printf "}\n"
+	for (group in offsets) {
+		printf "#define TG_%s %d\n",group,offsets[group]
+	}
+}
+
diff --git a/FP/src/conf/awk/tiles_conf_types.awk b/FP/src/conf/awk/tiles_conf_types.awk
new file mode 100644
index 0000000..e82d32e
--- /dev/null
+++ b/FP/src/conf/awk/tiles_conf_types.awk
@@ -0,0 +1,40 @@
+#   Princed V3 - Prince of Persia Level Editor for PC Version
+#   Copyright (C) 2003 Princed Development Team
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#   The authors of this program may be contacted at http://forum.princed.com.ar
+
+# tiles_conf_types.awk: FreePrince : tiles.conf parser
+# \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+# Copyright 2004, 2003 Princed Development Team
+#  Created: 19 Oct 2004
+#
+#  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+#
+# Note:
+#  DO NOT remove this copyright notice
+#
+
+/^[ ]*tile .*$/ {
+	a=""
+	i=15-length($2)
+	while(i--) a=sprintf(" %s",a)
+	b=""
+	i=9-length($4)
+	while(i--) b=sprintf(" %s",b)
+	printf ("#define T_%s 0x%02x %s /* %2d %s%s */\n",$2,$3,a,$3,$4,b)
+}
+
diff --git a/FP/src/include/map_defs.h b/FP/src/include/map_defs.h
index 1f35e8b..f77c436 100644
--- a/FP/src/include/map_defs.h
+++ b/FP/src/include/map_defs.h
@@ -89,38 +89,8 @@ Len	Offs	BlockName & Description
 #define MAPS_sLeft		0
 #define MAPS_sRight		1
 
-#define T_EMPTY 0x00           /* 00000 free    */
-#define T_FLOOR 0x01           /* 00001 free    */
-#define T_SPIKES 0x02          /* 00010 spike   */
-#define T_PILLAR 0x03          /* 00011 none    */
-#define T_GATE 0x04            /* 00100 gate    */
-#define T_BTN_STUCK 0x05       /* 00101 none    */
-#define T_BTN_DROP 0x06        /* 00110 event   */
-#define T_TAPESTRY 0x07        /* 00111 tapest  */
-#define T_BP_BOTTOM 0x08       /* 01000 none    */
-#define T_BP_TOP 0x09          /* 01001 none    */
-#define T_POTION 0x0A          /* 01010 potion  */
-#define T_LOOSE 0x0B           /* 01011 none    */
-#define T_TAPESTRY_TOP 0x0C    /* 01100 ttop    */
-#define T_MIRROR 0x0D          /* 01101 none    */
-#define T_DEBRIS 0x0E          /* 01110 none    */
-#define T_BTN_RAISE 0x0F       /* 01111 event   */
-#define T_EXIT_LEFT 0x10       /* 10000 none    */
-#define T_EXIT_RIGHT 0x11      /* 10001 none    */
-#define T_CHOPPER 0x12         /* 10010 chomp   */
-#define T_TORCH 0x13           /* 10011 none    */
-#define T_WALL 0x14            /* 10100 wall    */
-#define T_SKELETON 0x15        /* 10101 none    */
-#define T_SWORD 0x16           /* 10110 none    */
-#define T_BALCONY_LEFT 0x17    /* 10111 none    */
-#define T_BALCONY_RIGHT 0x18   /* 11000 none    */
-#define T_LATTICE_PILLAR 0x19  /* 11001 none    */
-#define T_LATTICE_SUPPORT 0x1A /* 11010 none    */
-#define T_LATTICE_SMALL 0x1B   /* 11011 none    */
-#define T_LATTICE_LEFT 0x1C    /* 11100 none    */
-#define T_LATTICE_RIGHT 0x1D   /* 11101 none    */
-#define T_TORCH_DEBRIS 0x1E    /* 11110 none    */
-#define T_NULL 0x1F            /* 11111 none    */
+#include "tiles.h"
+
 /*
   none   0x00 This value is used allways for this group
   free   0x00 +Nothing -Blue line