git » fp-git.git » commit f713474

moved directory

author ecalot
2004-03-17 04:46:34 UTC
committer ecalot
2004-03-17 04:46:34 UTC
parent cf0c34b2ab498d1d5ee37ab6e9141a23293b0fce

moved directory

PR/doc/changelog.txt +113 -57
PR/doc/readme.coders.txt +110 -13
PR/doc/readme.txt +66 -70
PR/src/Makefile +117 -43
PR/src/Makefile.lcc +119 -51
PR/src/include/autodetect.h +100 -24
PR/src/include/bitmap.h +39 -4
PR/src/include/bmp.h +39 -4
PR/src/include/classify.h +34 -0
PR/src/include/common.h +67 -147
PR/src/include/compress.h +56 -9
PR/src/include/disk.h +69 -7
PR/src/include/export.h +32 -13
PR/src/include/filedir.h +23 -13
PR/src/include/idlist.h +100 -24
PR/src/include/image.h +56 -9
PR/src/include/import.h +33 -5
PR/src/include/memory.h +34 -3
PR/src/include/mid.h +34 -2
PR/src/include/pal.h +36 -8
PR/src/include/plv.h +68 -7
PR/src/include/png.h +39 -4
PR/src/include/pr.h +67 -147
PR/src/include/search.h +23 -13
PR/src/include/tree.h +100 -24
PR/src/include/unknown.h +100 -24
PR/src/include/wav.h +34 -2
PR/src/lib/formats/Attic/bmp.c +0 -209
PR/src/lib/formats/bmp.c +210 -0
PR/src/lib/formats/{Attic => }/mid.c +12 -11
PR/src/lib/formats/{Attic => }/pal.c +68 -52
PR/src/lib/formats/{Attic => }/plv.c +80 -36
PR/src/lib/formats/{Attic => }/wav.c +11 -10
PR/src/ports/getopt.c +1 -1
PR/src/ports/winfiles/pr.exe +0 -0
PR/src/pr.dsp +650 -596
PR/src/pr.dsw +29 -29

diff --git a/PR/doc/changelog.txt b/PR/doc/changelog.txt
index ca0a3b2..51ebef5 100644
--- a/PR/doc/changelog.txt
+++ b/PR/doc/changelog.txt
@@ -1,93 +1,149 @@
-Princed Resources V0.9
+Princed Resources v1.0
 (c) Copyright 2003 - Princed Development Team
 http://www.princed.com.ar
 This program is open source under the GNU General Public License terms
 
+
 1) Change Log
- * PG
-  - Added support to export .bmp files
-  - Added bitmap decompression
-  - Added static palette extraction
- * PS
-  - Added support to .mid files
-  - Added support to indexed dat files
- * PR 0.1 Alpha
+Legend:
+ + Format descovery first implementation
+    Previous versions didn't support this features
+    Format bug fixes
+ - Code improvement
+    Things that were supported before, but they have been improved
+    Code bug fixes
+
+Versions:
+ * PG (unreleased)
+  + Added support to export .bmp files
+  + Added bitmap decompression
+  + Added static palette extraction
+ * PS (unreleased)
+  + Added support to .mid files
+  + Added support to indexed dat files
+ * PR 0.1 alpha (2003-06-09)
   - Merged PS and PG into one extractor.
-  - Added dynamic palette extraction
+  + Added dynamic palette extraction
   - Added resource.txt parser.
-  - Added support to .wav files.
-  - Added support to export JASC palette for .pal files.
-  - Coded type header verification
+  + Added support to .wav files.
+  + Added support to export JASC palette for .pal files.
+  + Coded type header verification
   - Solved several bugs.
- * PR 0.2 Alpha
-  - Added classifying dat type feature
-  - Added support to import .bmp files
+ * PR 0.2 alpha (2003-06-17)
+  + Added classifying dat type feature
+  + Added support to import .bmp files
   - Implemented CGI output support for UNIX versions
   - Source files were abstracted
- * PR 0.3 beta
+ * PR 0.3 beta (2003-06-25)
   - Added modifiers -x[rnu] -c[r]
   - Added pr.dll compiling
-  - Bitmaps aren't upside down anymore 
-  - Images bigger than 256 pixels length or width now are recognized
-  - Improved decompression algorithm in bigger images
+  + Bitmaps aren't upside down anymore 
+  + Images bigger than 256 pixels length or width now are recognized
+  + Improved decompression algorithm in bigger images
   - Optimized bitmap handling
   - Solved bugs in bitmap format
-  - Solved segmentation fault in title.dat
- * PR 0.4 beta
+  + Solved segmentation fault in title.dat
+ * PR 0.4 beta (2003-06-27)
   - Fixed a memory bug since v0.3
-  - Pop2 DAT files detected (file type 11)
- * PR 0.5 beta
+  + Pop2 DAT files detected (file type 11)
+ * PR 0.5 beta (2003-07-03)
   - Abstracted format handling
   - Optimized bmp saving algorithm
-  - Solved and optimized decompression for big images
-  - Some Pop2 graphics are extracted (palettes aren't supported yet)
- * PR 0.6 alpha
-  - Coded full import/export bmp (in separate files not included in this distribution)
-  - Completed and tested bmp reading algorithm
+  + Solved and optimized decompression for big images
+  + Some Pop2 graphics are extracted (palettes aren't supported yet)
+ * PR 0.6 alpha (2003-10-08)
+  - Coded full import/export bmp (in separate files not included
+    in this distribution)
+  + Completed and tested bmp reading algorithm
   - Optimized PG algorithms and reserved memory sizes
- * PR 0.6 beta
-  - Added full import bmp support
-  - Solved palette import bug
- * PR 0.7
+ * PR 0.6 beta (2003-10-17)
+  + Added full import bmp support
+  + Solved palette import bug
+ * PR 0.7 (2003-10-23)
   - Added Makefile
   - Moved PG module to compress.c and bmp.c
   - Moved midi support to mid.c
-  - Solved corrupted images on compression bug
+  + Solved corrupted images on compression bug
   - Source ported to several compilers and platforms
- * PR 0.8 beta
+ * PR 0.8 beta (2003-11-04)
   - Abstracted disk functions into one module
-  - Added PC Speaker sound classification
-  - Added compression algorithms B0 and B2. Before that it was only working B1.
+  + Added PC Speaker sound classification
+  + Added compression algorithms B0 and B2. Before that it was only
+    working B1.
   - Coded a base directory creator for files
-  - Coded a parser and the resources tree in xml. 
+  - Coded a parser and the resources tree in xmlparse. 
   - Coded inheritance of owner's attributes to tag child
   - Coded linking from an id to a palette
-  - Coded the compression algorithm selector to optimize the bitmap compiled dat files
+  - Coded the compression algorithm selector to optimize the bitmap
+    compiled dat files
   - Coded unknown extracted files saved in unknown.xml
- * PR v0.9
+ * PR v0.9 Release 1 (unstable) (2003-12-22)
   - Abstracted output
   - Added pr.so dynamic library for unix versions
-  - Code full extractor that looks into directories and extract dat files
-  - Coded detector of dat file in relative path (e.g. pr dat/dungeon.dat -x l)
+  - Coded detector of dat file in relative path
+  - Coded full extractor that looks into directories
   - Coded new UNIX-style command line parsing and options
   - Defined and supported .plv format for RoomShaker & Princed. 
   - Dropped old code (txt parser and directory parsing functions)
   - Improved B1/B2 compressor (4% gained in big files, 1% in small files)
-  x Improved resources.xml
-  x Tested and stable
-  x Works in all dat files
-  x Set, if applicable, POP2 in the father folder of the unknown.xml file
-
-2) ToDo List
- i)   Add full pop2 support
- ii)  Code the compression algorithms (B3, B4) to optimize the bitmap compiled dat files
- iii) Add a C++ class to use PR
+  - Tested and more stable
+ * PR v0.9 Release 2 (stable) (2004-02-21)
+  - Added and improved PLV support
+  - Empty files automatically removed
+  - Fixed minor bugs
+  - Fixed wav quality bug
+  - Force and backup options are working
+  - Improved resources.xml. Now it works in digisnd1.dat, digisnd2.dat,
+    digisnd3.dat, fat.dat, guard.dat, guard1.dat, guard2.dat,
+    ibm_snd1.dat, ibm_snd2.dat, kid.dat, levels.dat, midisnd1.dat,
+    midisnd2.dat, prince.dat, pv.dat, shadow.dat, skel.dat, title.dat,
+    vdungeon.dat, vizier.dat and vpalace.dat
+  - Fixed lcc makefile
+  - Ported to BSD and SunOs
+  + Added monochrome format support for image types 00,01,02,03 and 04;
+    only stable in title.dat texts.
+  + Fixed palette bug
+ * PR v1.0 beta
+  - Added attribute "path" as an alias of "external" in XML
+  + Added full monochrome resource support
+  - Added the itemtype attribute "autodetect"
+  - Added XML handling primitives in DLL
+  - Better resource naming when unknown extraction is performed
+  - Changed tag name "itemtypes" to "resources"
+  - Code made a bit easy to read, abstracted dat handling library
+  - DAT File list recycle bug fix
+  - Directory ended in "/" bug
+  - Fixed backup bug. Implemented a file pointer dynamic table using the
+    LIFO philosophy for safe open files in the disk handling library
+  - Fixed bug in compressed image size (2 bytes bigger than the normal)
+  - Fixed memory freeing
+  - Improved and abstracted transposition in monochromatic images
+  - Lower memory allocation (getmemory & image compress size bugs fixed)
+  - Optimizations
+  - PLV Checksum not ignored anymore
+  - Removed support of numeric "itemtype" attributes
+  - Renamed xml module to xmlparse
+  - Unknown option bug fixed
+  o Coded partial importing and exporting feature
+  o Code in strict ANSI C (test with GCC pedantic)
+  x Checksum verification
+  x Full testing
+  x Other versions of POP 1 tested
+  x Set, if applicable, POP2 in the parent folder of the    unknown.xml file
 
+2) ToDo List & Future Plans:
 
-3) Future Versions:
-  PR v1.0:      First optimized & stable version for win32 and unix based systems
-  PR v1.1:      added iii
-  PR v1.5:      added ii
-  PR v2.0 beta: added i
-  PR v2.0:      Optimized & stable version for win32 and unix based systems
+ * PR v1.0:
+  x Optimization
+  x & stable version for win32 and unix
+    based systems
+ * PR v1.1:
+  x Add a C++ class to use PR
+ * PR v1.5:
+  x Code the compression algorithms Lzg to optimize compiled
+    bitmap dat files
+ * PR v2.0 beta:
+  x Add full pop2 support
+ * PR v2.0:
+  x Optimized & stable version for win32 and unix based systems
 
diff --git a/PR/doc/readme.coders.txt b/PR/doc/readme.coders.txt
index 12ceff2..02d2e27 100644
--- a/PR/doc/readme.coders.txt
+++ b/PR/doc/readme.coders.txt
@@ -28,27 +28,31 @@ Please read readme.txt for syntax information
 
 -shell-2.05b$ cd bin
 -shell-2.05b$ ./pr
-Princed resources (PR) V0.9
+Princed resources (PR) V0.9 Linux
 (c) Copyright 2003 - Princed Development Team
 http://www.princed.com.ar
 
-Syntax:
- pr datfile option [extract dir]
+Usage: 
+  pr [-x[EXTRACTDIR]|-c[COMPILEDIR]|-d] [DATFILEPATH]
+  pr [OPTIONS] [DATFILEPATH]
+
+  Mandatory arguments to long options are mandatory for short options too.
+
+   -c, --import[=DIRNAME]     imports from DIRNAME into given dat file
+(...)
+       --version              output version information and exit
 
-Valid options:
- -x[rn] for extract
-  r: raw extraction
-  n: don't extract
- -c[r] for compile
-  r: raw compiling
- -d for type
 -shell-2.05b$
 
 2) Dos/Win32 Console compiling
 
-You can use the VC workspace file: pr.dsw and build the project (selecting Build/Set active configuration...), setting up Dll or Release compilation modes and pressing F7.
+You can use the VC workspace file: pr.dsw and build the project (selecting
+Build/Set active configuration...), setting up Dll or Release compilation
+modes and pressing F7.
 
-LCC should also work, use Makefile.lcc.
+If you are using LCC, rename Makefile.lcc to Makefile and compile. Make sure
+you have added the lcc path in the system. For further information read the
+shell information in the program documentation at www.princed.com.ar
 
 3) CVS download
 
@@ -73,7 +77,8 @@ U PR/zip/prvbdll.zip
 -shell-2.05b$
 
 4) Need assistance?
- Just ask here http://sourceforge.net/tracker/?func=add&group_id=91915&atid=598846
+ Just ask here
+ http://sourceforge.net/tracker/?func=add&group_id=91915&atid=598846
 
 5) Bug reporting?
  http://sourceforge.net/tracker/?func=add&group_id=91915&atid=598845
@@ -83,3 +88,95 @@ U PR/zip/prvbdll.zip
 
 7) SourceForge project home page
  http://project.princed.com.ar
+
+8) UNIX Install HowTo sample
+
+-shell-2.05b$ ls -l
+total 64
+-rw-r--r--    1 ecalot   users       57667 dec  9 10:00 pr.09-dev3.tar.bz2
+-shell-2.05b$ bunzip2 pr.09-dev3.tar.bz2
+-shell-2.05b$ ls
+pr.09-dev3.tar
+-shell-2.05b$ tar -xvf pr.09-dev3.tar
+src/
+src/extract.c
+src/include/
+src/include/compile.h
+src/include/compress.h
+src/include/extract.h
+src/include/memory.h
+src/include/pr.h
+src/include/resources.h
+src/include/tasks.h
+src/include/bmp.h
+(...)
+src/formats/pal.c
+src/formats/wav.c
+src/formats/plv.c
+src/resources.c
+src/tasks.c
+src/xml.c
+src/xmlsearch.c
+src/pr.dsp
+src/pr.c
+-shell-2.05b$ cd src
+-shell-2.05b$ make
+Compiling import module...
+Compiling compression module...
+Compiling export module...
+Compiling main module in standard mode...
+Compiling resource manager module...
+Compiling extra tasks module...
+Compiling disk access functions...
+Compiling xml parsing module...
+Compiling xml search features...
+Compiling bitmap files support (bmp)...
+Compiling midi audio files support (mid)...
+Compiling JASC palette support (pal)...
+Compiling digital wave audio support (wav)...
+Compiling prince level files support (plv)...
+Compiling main module in library mode...
+Linking files...
+Making dynamic library...
+Program successfully compiled
+
+Please read readme.txt for syntax information
+
+-shell-2.05b$ cd bin
+-shell-2.05b$ ls -l
+total 76
+-rwxr-xr-x    1 ecalot   users       32656 dic  9 10:02 pr
+-rwxr-xr-x    1 ecalot   users       42941 dic  9 10:02 pr.so
+-shell-2.05b$ ./pr
+Princed resources (PR) V0.9 Linux
+(c) Copyright 2003 - Princed Development Team
+http://www.princed.com.ar
+
+Usage: 
+  pr [-x[EXTRACTDIR]|-c[COMPILEDIR]|-d] [DATFILEPATH]
+  pr [OPTIONS] [DATFILEPATH]
+
+  Mandatory arguments to long options are mandatory for short options too.
+
+   -c, --import[=DIRNAME]     imports from DIRNAME into given dat file
+   -d, --classify             returns the DAT file type
+   -x, -e, --export[=DIRNAME] extracts given dat file into DIRNAME
+
+   -a, --setauthor=NAME       sets your name in extracted PLV files
+   -b, --backup[=EXTENSION]   backup your files
+   -f, --force                default option, you cannot disable it,
+                              so please make a backup of your files
+   -g, --cgi                  run as CGI and output mime headers
+   -h, -?, --help             display this help and exit
+   -m, --resource=RESFILE     uses an user-specific resource xml file
+   -r, --raw                  uses raw format
+   -R, --recursive            searches for all dat files (only if DATFILEPATH
+                              is not a dat file)
+   -t, --datfile=DATFILE      specifies a dat file to read resources
+                              different that the original file
+       --unknown              generate the unknown file without performing
+                              any extraction
+   -v, --verbose              explain what is being done
+       --version              output version information and exit
+
+-shell-2.05b$
diff --git a/PR/doc/readme.txt b/PR/doc/readme.txt
index 63747b5..bc45eee 100644
--- a/PR/doc/readme.txt
+++ b/PR/doc/readme.txt
@@ -1,39 +1,44 @@
-Princed Resources V0.9
+Princed Resources v1.0
 (c) Copyright 2003 - Princed Development Team
 http://www.princed.com.ar
 This program is open source under the GNU General Public License terms
 
-Please read this readme file throughly before starting to use Princed Resource Editor.
+Please read this readme file throughly before starting to use Princed
+Resource Editor.
 
 1) Supported file formats:
 
-The extractor supports only a few file formats, it uses the
-most commonly supported versions of the formats to allow maximum compatibility. 
-As we haven't got enough time to code the program we decided to support only those kinds of formats, and let the user make the necessary conversions.
+ The extractor supports only a few file formats, it uses the most commonly
+ supported versions of the formats to allow maximum compatibility. 
+ As we haven't got enough time to code the program we decided to support
+ only those kinds of formats, and let the user make the necessary
+ conversions.
 
 Resource Types:
- 01 Levels
- 02 Bitmaps
- 03 Waves
- 04 Midis
- 05 Undefined
- 06 Palette
- 07 Internal PC Speaker Sounds
- 08 to 10 reserved
-
-Type 01:
- We decided to give Level files the extension ".pet".  These files can be  edited Princed V3.  PV3 can also edit the whole levels.dat file.
- Recommended editor: PV3.
-
-Type 02:
+ Name       Extension  Description
+
+ level      plv        Prince of Persia level
+ image      bmp        Graphic in windows bitmap format
+ wave       wav        Wave digital audio sounds
+ midi       mid        Game music in midi format
+ binary     bin        Binary files
+ palette    pal        Image palette in the Jasc format
+ pcspeaker  pcs        Internal PC Speaker Sounds
+
+Type "level":
+ We decided to give Level files the extension ".plv".  These files
+ can be edited in RoomShaker from version 1.66 and Princed V3.
+ PV3 can also edit the whole levels.dat file.
+ Recommended editor: RoomShaker.
+
+Type "image":
  We use Windows Bitmaps (BMP) to extract the files.
  The file specifications are:
-  - 16 color-palette.
+  - 16 color-palette in paletted images and a 2 color-palette in B/W images
   - No compression.
-  - Currently the images are saved upside down (We are going to change that).
- Recommended editor: Paint Shop Pro, perhaps even MS Paint.
+ Recommended editor: Paint Shop Pro, but even MS Paint works.
  
-Type 03:
+Type "wave":
  For digital audio we are using the standard .wav format.
  The file specifications are:
   - Size of Format: 16
@@ -46,87 +51,78 @@ Type 03:
  Recommended editors: GoldWave, CoolEdit.  Standard Windows programs do not
  understand the .wav format.
 
-Type 04:
+Type "midi":
  For musical instrument digital interface we are using the standard midi
  format (mid) and type 0 midi format.
  The file specifications are:
   - Unknown (see standard MIDI specifications)
  Recommended editor: Power Tracks.
 
-Type 05:
- Some binary garbage stuff.
+Type "binary":
+ Some binary garbage or untested stuff.
  Recommended editor: xvi32 or any other hex editor.
 
-Type 06:
- For the bitmaps palettes we are using the Jasc Pal format (Not Microsoft pal format)
+Type "palette":
+ For the bitmap palettes we are using the Jasc Pal format (Not Microsoft
+  .pal format)
  Recommended editor: Paint Shop Pro.
 
-Type 07:
- For the internal PC Speaker sound we are using binary data saved in pcs format
+Type "pcspeaker":
+ For the internal PC Speaker sound we are using binary data saved in pcs
+  format
+ The formas is saved this way:
+  2 unique bytes for headers
+  3 bytes per note (2 for frequency and 1 for duration)
  Recommended editor: xvi32 or any other hex editor.
 
 2) Bugs:
- This version has lots of new features but we didn't have enough time to test it.
- There are lots known bugs. This program was only tested using vdungeon.dat and
- vpalace.dat.
- so we know there are bugs in other dat files but we can't solve them very fast.
- It is recommended to upgrade to the next stable when it is released.
- To report bugs please go to http://sourceforge.net/tracker/?func=add&group_id=91915&atid=598845.
+ All known bugs were solved. If you find a bug (program crashes, corrupted
+ resources, typos, etc), it's very probable that we haven't found it. So
+ please report it. To report bugs just post them in
+ http://sourceforge.net/tracker/?func=add&group_id=91915&atid=598845
 
 3) Usage: 
-   pr [-x [EXTRACTDIR]|-c [COMPILEDIR]|-d] [DATFILEPATH] 
-   pr [OPTIONS] [DATFILEPATH]
- 
-   Mandatory arguments to long options are mandatory for short options too.
- 
-    -c, --import[=DIRNAME]     imports from DIRNAME into given dat file
-    -d, --classify             returns the DAT file type
-    -x, -e, --export[=DIRNAME] extracts given dat file into DIRNAME
- 
-    -b, --backup[=EXTENSION]   backup your files
-    -f, --force                default option, you cannot disable it,
-                               so please make a backup of your files
-    -g, --cgi                  run as CGI and output mime headers
-    -h, --help                 display this help and exit
-    -m, --resource=RESFILE     uses an user-specific resource xml file
-    -r, --raw                  uses raw format
-    -R, --recursive            searches for all dat files (only if DATFILEPATH
-                               is not a dat file)
-    -t, --datfile=DATFILE      specifies a dat file to read resources
-                               different that the original file
-        --unknown              generate the unknown file without performing
-                               any extraction
-    -v, --verbose              explain what is being done
-        --version              output version information and exit
-
- Note: if DATFILEPATH is not provided or if it is a directory all dat files
-       that are set on resources.xml will be selected
+ Run the program without parameters to get the usage help.
  
  Syntax samples:
  
  C:\PRINCED\PR> pr -xext dat\vdungeon.dat
  
- This will extract the bitmaps and palettes allocated in   C:\princed\pr\dat\vdungeon.dat into the c:\princed\pr\ext. 
+ This will extract the bitmaps and palettes allocated in 
+ C:\princed\pr\dat\vdungeon.dat into the c:\princed\pr\ext. 
  Note: ext must exist.
  
  C:\PRINCE> pr -x vdungeon.dat
  
- This will extract all the bitmaps and palettes allocated in  c:\prince\vdungeon.dat
- into c:\prince.
+ This will extract all the bitmaps and palettes allocated in
+ c:\prince\vdungeon.dat into c:\prince.
  
  C:\PRINCED\PR> pr -cext compiled\vdungeon.dat
  
- This will compile the bitmaps and palettes that are in c:\princed\pr\ext and
- associated to vdungeon.dat in the resource file and generate the file
+ This will compile the bitmaps and palettes that are in c:\princed\pr\ext
+ and associated to vdungeon.dat in the resource file and generate the file
  c:\princed\pr\compiled\vdungeon.dat.
  
 4) New versions
- It's strongly recommended that you download a newer stable version of this program as soon as it comes available in the official url (http://www.princed.com.ar)
+ It's strongly recommended that you download a newer stable version of
+ this program as soon as it comes available in the official url
+ http://www.princed.com.ar
+
+5) Requirements
+  
+  25127199 bytes in ram are approx required for a normal full directory task
+  
+  Recomended:
+   AMD K6-II at 350Mhz or higher
+   32 Mb ram
 
-5) Credits
+6) Credits
 
  Coding & main routines
   Enrique Calot
+  
+ Coding Assistant
+  Santiago Zamora
 
  Graphic compression algorithms
   Tammo Jan Dijkema
diff --git a/PR/src/Makefile b/PR/src/Makefile
index ed60033..3702f50 100644
--- a/PR/src/Makefile
+++ b/PR/src/Makefile
@@ -1,75 +1,149 @@
-bin/pr: compile.o compress.o extract.o pr.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o prlib.o memory.o
-	
-	@echo Linking files...
+#Programs
+CC      = @gcc
+LINKER  = @ld
+INFO    = @echo
+MAKEDIR = @mkdir -p
+
+#Operating Systems
+OS      := $(shell uname)
+ifeq ($(OS),Linux)
+  LINUX = -DLINUX
+  OS    = GNU/Linux
+  SRC2  =
+else
+  LINUX = -DNOLINUX
+  SRC2  = getopt.o getopt1.o
+endif
+
+#Compiler options
+INCLUDE = -Iinclude/
+DEFINES = -DOS=\"$(OS)\" $(LINUX) 
+OPTIONS = $(INCLUDE) $(DEFINES)
+
+OBJFILES = compile.o compress.o extract.o resources.o tasks.o disk.o\
+           xmlparse.o xmlsearch.o dat.o bmp.o mid.o pal.o wav.o plv.o memory.o\
+           $(SRC2)
+
+SRC1     = pr.o
+SRC3     = prlib.o
+
+EXEFILE  = bin/pr
+
+#main file
+
+bin/pr: $(OBJFILES) $(SRC1) bin/resources.xml
+	$(INFO) Linking files...
+	$(MAKEDIR) bin
+	$(CC) -o bin/pr $(OBJFILES) $(SRC1) -s -O2
+	$(INFO) Program successfully compiled
+	$(INFO)
+	$(INFO) Please read readme.txt for syntax information
+	$(INFO)
+
+#command options
+
+clean:
+	$(INFO) Erasing temporary object files...
+	@rm -f *.o bin/pr
+
+build: clean bin/pr
+
+all: $(EXEFILE) lib
+
+lib: $(OBJFILES) $(SRC3)
+	$(MAKEDIR) bin
+	$(INFO) Making dynamic library...
+	$(CC) -o bin/pr.so $(OBJFILES) $(SRC3) -O2 -Llibc -shared -dynamic
+	$(INFO) Library successfully compiled
+	$(INFO)
+	$(INFO) Please read readme.coders.txt and pr.h for interfaces
+	$(INFO)
+
+#files
+
+bin/resources.xml: resources.xml.gz
+	$(INFO) Uncompressing resources...
 	@mkdir -p bin
-	@gcc -o bin/pr compile.o compress.o extract.o pr.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o memory.o -s -O2
-	@echo Making dynamic library...
-	@gcc -o bin/pr.so compile.o compress.o extract.o prlib.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o memory.o -O2 -Llibc -shared -dynamic
-	@echo Program successfully compiled
-	@echo
-	@echo Please read readme.txt for syntax information
-	@echo
+	@gunzip resources.xml.gz
+	@cp -f resources.xml bin
+	@gzip resources.xml
 
 compile.o: compile.c
-	@echo Compiling import module...
-	@gcc -c compile.c -Iinclude/
+	$(INFO) Compiling import module...
+	$(CC) -c compile.c $(OPTIONS)
 
 memory.o: memory.c
-	@echo Compiling memory manager...
-	@gcc -c memory.c -Iinclude/
+	$(INFO) Compiling memory manager...
+	$(CC) -c memory.c $(OPTIONS)
 
 extract.o: extract.c
-	@echo Compiling export module...
-	@gcc -c extract.c -Iinclude/
+	$(INFO) Compiling export module...
+	$(CC) -c extract.c $(OPTIONS)
 
 compress.o: compress.c
-	@echo Compiling compression module...
-	@gcc -c compress.c -Iinclude/
+	$(INFO) Compiling compression module...
+	$(CC) -c compress.c $(OPTIONS)
 
 pr.o: pr.c
-	@echo Compiling main module in standard mode...
-	@gcc -c pr.c -Iinclude/ -DOS=\"`uname`\" 
+	$(INFO) Compiling main module in standard mode...
+	$(CC) -c pr.c $(OPTIONS)
 
 prlib.o: pr.c
-	@echo Compiling main module in library mode...
-	@gcc -c pr.c -Iinclude/ -DDLL -o prlib.o
+	$(INFO) Compiling main module in library mode...
+	$(CC) -c pr.c $(OPTIONS) -DDLL -o prlib.o
 
 resources.o: resources.c
-	@echo Compiling resource manager module...
-	@gcc -c resources.c -Iinclude/
+	$(INFO) Compiling resource manager module...
+	$(CC) -c resources.c $(OPTIONS)
 
 tasks.o: tasks.c
-	@echo Compiling extra tasks module...
-	@gcc -c tasks.c -Iinclude/
+	$(INFO) Compiling extra tasks module...
+	$(CC) -c tasks.c $(OPTIONS)
 
-xml.o: xml.c
-	@echo Compiling xml parsing module...
-	@gcc -c xml.c -Iinclude/
+xmlparse.o: xmlparse.c
+	$(INFO) Compiling xml parsing module...
+	$(CC) -c xmlparse.c $(OPTIONS)
 
 xmlsearch.o: xmlsearch.c
-	@echo Compiling xml search features...
-	@gcc -c xmlsearch.c -Iinclude/
+	$(INFO) Compiling xml search features...
+	$(CC) -c xmlsearch.c $(OPTIONS)
 
 disk.o: disk.c
-	@echo Compiling disk access functions...
-	@gcc -c disk.c -Iinclude/
+	$(INFO) Compiling disk access library...
+	$(CC) -c disk.c $(OPTIONS)
+
+dat.o: dat.c
+	$(INFO) Compiling dat editing library...
+	$(CC) -c dat.c $(OPTIONS)
 
 bmp.o: formats/bmp.c
-	@echo Compiling bitmap files support \(bmp\)...
-	@gcc -c formats/bmp.c -Iinclude/
+	$(INFO) Compiling bitmap files support \(bmp\)...
+	$(CC) -c formats/bmp.c $(OPTIONS)
 
 mid.o: formats/mid.c
-	@echo Compiling midi audio files support \(mid\)...
-	@gcc -c formats/mid.c -Iinclude/
+	$(INFO) Compiling midi audio files support \(mid\)...
+	$(CC) -c formats/mid.c $(OPTIONS)
 
 plv.o: formats/plv.c
-	@echo Compiling prince level files support \(plv\)...
-	@gcc -c formats/plv.c -Iinclude/
+	$(INFO) Compiling prince level files support \(plv\)...
+	$(CC) -c formats/plv.c $(OPTIONS)
 
 pal.o: formats/pal.c
-	@echo Compiling JASC palette support \(pal\)...
-	@gcc -c formats/pal.c -Iinclude/
+	$(INFO) Compiling JASC palette support \(pal\)...
+	$(CC) -c formats/pal.c $(OPTIONS)
 
 wav.o: formats/wav.c
-	@echo Compiling digital wave audio support \(wav\)...
-	@gcc -c formats/wav.c -Iinclude/
+	$(INFO) Compiling digital wave audio support \(wav\)...
+	$(CC) -c formats/wav.c $(OPTIONS)
+
+dirent.o: ports/dirent.c
+	$(INFO) Porting the dirent structure...
+	$(CC) $(OPTIONS) -c ports/dirent.c
+	
+getopt.o: ports/getopt.c
+	$(INFO) Porting the Unix-like getopt function \(first part\)...
+	$(CC) $(OPTIONS) -c ports/getopt.c
+
+getopt1.o: ports/getopt1.c
+	$(INFO) Porting the Unix-like getopt function \(second part\)...
+	$(CC) $(OPTIONS) -c ports/getopt1.c
diff --git a/PR/src/Makefile.lcc b/PR/src/Makefile.lcc
index 98d86e5..1cd55d8 100644
--- a/PR/src/Makefile.lcc
+++ b/PR/src/Makefile.lcc
@@ -1,51 +1,119 @@
-pr.exe: compile.obj compress.obj extract.obj parser.obj pr.obj resources.obj tasks.obj formats/bmp.obj formats/mid.obj formats/pal.obj formats/wav.obj
-	@echo Linking files...
-	@lcclnk pr.obj compile.obj compress.obj extract.obj parser.obj resources.obj tasks.obj formats\bmp.obj formats/mid.obj formats/pal.obj formats/wav.obj
-	@echo Program succesfully compiled
-	@echo
-	@echo Please read readme.txt for syntax information
-	@echo
-	
-parser.obj: parser.c
-	@echo Compiling parsing library...
-	@lcc parser.obj parser.c -Iinclude
-
-compile.obj: compile.c
-	@echo Compiling import module...
-	@lcc compile.c -Iinclude
-
-extract.obj: extract.c
-	@echo Compiling export module...
-	@lcc extract.c -Iinclude
-
-compress.obj: compress.c
-	@echo Compiling compression module...
-	@lcc compress.c -Iinclude
-
-pr.obj: pr.c
-	@echo Compiling main module...
-	@lcc pr.c -Iinclude
-
-resources.obj: resources.c
-	@echo Compiling resource manager module...
-	@lcc resources.c -Iinclude
-
-tasks.obj: tasks.c
-	@echo Compiling extra tasks module...
-	@lcc tasks.c -Iinclude
-
-bmp.obj: formats\bmp.c
-	@echo Compiling bitmap files support (bmp)...
-	@lcc formats\bmp.c -Iinclude
-
-mid.obj: formats\mid.c
-	@echo Compiling midi audio files support (mid)...
-	@lcc formats\mid.c -Iinclude
-
-pal.obj: formats\pal.c
-	@echo Compiling JASC palette support (pal)...
-	@lcc formats\pal.c -Iinclude
-
-wav.obj: formats\wav.c
-	@echo Compiling digital wave audio support (wav)...
-	@lcc formats\wav.c -Iinclude
+CC=@lc
+LINKER=@lcclnk
+INFO=@echo
+
+INCLUDE = -Iinclude\ 
+DEFINES = -DWIN32 
+#-DDLL
+OPTIONS = $(INCLUDE) $(DEFINES)
+
+OBJFILES = compile.obj compress.obj extract.obj pr.obj dat.obj resources.obj\
+           tasks.obj disk.obj xmlparse.obj xmlsearch.obj bmp.obj mid.obj\
+           pal.obj wav.obj plv.obj memory.obj\
+           dirent.obj getopt.obj getopt1.obj
+
+EXEFILE  = pr.exe
+
+#main file
+
+$(EXEFILE): $(OBJFILES)
+	$(INFO) Linking files...
+	$(LINKER) $(OBJFILES) -o $(EXEFILE) -s
+	#$(INFO) Making dynamic library...
+	#$(LINKER) $(OBJFILES) -dll pr.def -s -o pr.dll
+	$(INFO) Program successfully compiled
+	$(INFO):
+	$(INFO) Please read readme.txt for syntax information
+	$(INFO):
+
+#command options
+
+clean:
+	$(INFO) Erasing temporary object files...
+	@del *.obj
+
+build: clean all
+
+all: $(EXEFILE)
+
+#files
+
+compile.obj: compile.c
+	$(INFO) Compiling import module...
+	$(CC) $(OPTIONS) -c compile.c
+
+memory.obj: memory.c
+	$(INFO) Compiling memory manager...
+	$(CC) $(OPTIONS) -c memory.c
+
+extract.obj: extract.c
+	$(INFO) Compiling export module...
+	$(CC) $(OPTIONS) -c extract.c
+
+compress.obj: compress.c
+	$(INFO) Compiling compression module...
+	$(CC) $(OPTIONS) -c compress.c
+
+pr.obj: pr.c
+	$(INFO) Compiling main module in standard mode...
+	$(CC) $(OPTIONS) -c pr.c
+
+prlib.obj: pr.c
+	$(INFO) Compiling main module in library mode...
+	$(CC) $(OPTIONS) -DDLL -o prlib.obj -c pr.c
+
+resources.obj: resources.c
+	$(INFO) Compiling resource manager module...
+	$(CC) $(OPTIONS) -c resources.c
+
+tasks.obj: tasks.c
+	$(INFO) Compiling classify module...
+	$(CC) $(OPTIONS) -c tasks.c
+
+dat.obj: dat.c
+	$(INFO) Compiling abstract dat handling library...
+	$(CC) $(OPTIONS) -c dat.c
+
+xmlparse.obj: xmlparse.c
+	$(INFO) Compiling xml parsing module...
+	$(CC) $(OPTIONS) -c xmlparse.c
+
+xmlsearch.obj: xmlsearch.c
+	$(INFO) Compiling xml search features...
+	$(CC) $(OPTIONS) -c xmlsearch.c
+
+disk.obj: disk.c
+	$(INFO) Compiling disk access functions...
+	$(CC) $(OPTIONS) -c disk.c
+
+bmp.obj: formats\bmp.c
+	$(INFO) Compiling bitmap files support (bmp)...
+	$(CC) $(OPTIONS) -c formats\bmp.c
+
+mid.obj: formats\mid.c
+	$(INFO) Compiling midi audio files support (mid)...
+	$(CC) $(OPTIONS) -c formats\mid.c
+
+plv.obj: formats\plv.c
+	$(INFO) Compiling prince level files support (plv)...
+	$(CC) $(OPTIONS) -c formats\plv.c
+
+pal.obj: formats\pal.c
+	$(INFO) Compiling JASC palette support (pal)...
+	$(CC) $(OPTIONS) -c formats\pal.c
+
+wav.obj: formats\wav.c
+	$(INFO) Compiling digital wave audio support (wav)...
+	$(CC) $(OPTIONS) -c formats\wav.c
+
+dirent.obj: ports\dirent.c
+	$(INFO) Porting the dirent structure...
+	$(CC) $(OPTIONS) -c ports\dirent.c
+	
+getopt.obj: ports\getopt.c
+	$(INFO) Porting the Unix-like getopt function (first part)...
+	$(CC) $(OPTIONS) -c ports\getopt.c
+
+getopt1.obj: ports\getopt1.c
+	$(INFO) Porting the Unix-like getopt function (second part)...
+	$(CC) $(OPTIONS) -c ports\getopt1.c
diff --git a/PR/src/include/autodetect.h b/PR/src/include/autodetect.h
index a5478dc..dddcdd2 100644
--- a/PR/src/include/autodetect.h
+++ b/PR/src/include/autodetect.h
@@ -1,34 +1,101 @@
+/*  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
+*/
+
+/*
+resources.h: Princed Resources : Resource Handler headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _RESOURCES_H_
 #define _RESOURCES_H_
 
-#define MAX_LINE_SIZE 300
+/* XML generation defines */
 
 #define RES_XML_UNKNOWN_PATH  "%s/unknown/%s/"
-#define RES_XML_UNKNOWN_FILES "res%d.%s"
-#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<itemtypes version=\"0.6\">\n <folder name=\"unknown\" file=\"%s\" external=\"%s\" palette=\"%d\">\n"
-#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" external=\""RES_XML_UNKNOWN_FILES"\" itemtype=\"%s\">Unknown Resource number %d</item>\n"
-#define RES_XML_UNKNOWN_END   " </folder>\n</itemtypes>\n"
-
-#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","ext","pal","pcs"}
-#define RES_FILE_TYPES        {"raw","level","image","wave","midi","unknown","palette","pcspeaker"}
-//types
+#define RES_XML_UNKNOWN_FILES "%s%02d.%s"
+#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n <folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\">\n"
+#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" path=\""RES_XML_UNKNOWN_FILES"\" itemtype=\"%s\">Unknown %s %d</item>\n"
+#define RES_XML_UNKNOWN_END   " </folder>\n</resources>\n"
+
+/* File extensions */
+
+#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
+#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
+
+/* Item Types */
+
+#define RES_TYPE_RAW          0
+#define RES_TYPE_LEVEL        1
+#define RES_TYPE_IMAGE        2
+#define RES_TYPE_WAVE         3
+#define RES_TYPE_MIDI         4
+#define RES_TYPE_BINARY       5
+#define RES_TYPE_PALETTE      6
+#define RES_TYPE_PCSPEAKER    7
+
+#define RES_TYPECOUNT         8
+
+/* types */
 typedef struct {
 	unsigned short int palette;
 	unsigned short int size;
 	unsigned long int offset;
-	unsigned char number; //Used for level number
+	unsigned char number; /* Used for level number */
 	char      type;
 	char*     path;
 	char*     palAux;
-	char*     title;
+	char*     name;
 	char*     desc;
 }tResource;
 
+/* Id list for partial manipulation */
+typedef enum {eString,eValue}tResIdType;
+
+typedef struct {
+	tResIdType idType;
+	char*      value;
+}tResIdListItem;
+
+typedef struct {
+	int             count;
+	tResIdListItem* list;
+}tResIdList;
+
+void parseGivenPath(char* path);
+int isInThePartialList(const char* file, int value);
+void freePartialList();
+
+/* Includes */
 #include <stdio.h>
+#include "xmlparse.h"
 
-//Verify  header
-int verifyHeader(unsigned char* array, int size);
+/* Verify  header */
+int verifyHeader(const unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -36,7 +103,7 @@ int verifyHeader(unsigned char* array, int size);
 	 02 Bitmaps
 	 03 Waves
 	 04 Midis
-	 05 Undefined
+	 05 Binary
 	 06 Palette
 	 07 Internal Speaker Sounds
 */
@@ -45,25 +112,34 @@ int verifyHeader(unsigned char* array, int size);
 |                       File format handling                    |
 \***************************************************************/
 
-//Empty resource table
-void emptyTable(tResource* r[]);
-
+/* CheckSum verification */
+int checkSum(unsigned char* data,int size);
 
-//Resources extras
+/* Empty resource table */
+void emptyTable(tResource* r[]);
 
-void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat, const char* vDatFileName);
+/* Resources extras */
+void getFileName(char* vFileext,const char* vDirExt,tResource* r,unsigned short id,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension);
 void getUpperFolder(char* aux, char* vFiledat);
 
 const char* getExtDesc(int type);
 
-//parse file and free parsed structure
-char parseFile(const char* vFile, const char* datFile, tResource* r[]);
+/* parse file and free parsed structure */
+int parseFile(const char* vFile, const char* datFile, tResource* r[]);
 void freeParsedStructure();
+#ifdef DLL
+int parseStructure(const char* vFile);
+tTag* resourceTreeGetChild(tTag* whereAmI);
+tTag* resourceTreeGetNext (tTag* whereAmI);
+tTag* resourceTreeGetRoot ();
+int   resourceTreeGetInfo (tTag* whereAmI, char** tag, char** desc, char** path, char** file, char** itemtype, char** name, char** palette, char** type, char** value, char** version, char** number);
+#endif
 
-//In case there are unknown resources it closes the unknown XML output
+/* In case there are unknown resources it closes the unknown XML output */
 void endUnknownXml();
 
-//Search files for the Import feature
-int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+/* Search files for the Import feature */
+int importDir(const char* directory, const char* vResFile, int pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+int isntADatFile(const char* testFile, const char* vResFile);
 
 #endif
diff --git a/PR/src/include/bitmap.h b/PR/src/include/bitmap.h
index a870771..f896737 100644
--- a/PR/src/include/bitmap.h
+++ b/PR/src/include/bitmap.h
@@ -1,3 +1,36 @@
+/*  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
+*/
+
+/*
+bmp.h: Princed Resources : BMP file support headers
+\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+  Version: 1.10 (2004-Feb-17)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _BMP_H_
 #define _BMP_H_
@@ -5,9 +38,11 @@
 #include "resources.h"
 #include "compress.h"
 
-char mFormatExtractBmp(unsigned char* data, const char *vFileext,unsigned long int size,tImage image);
-char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res);
-char mWriteBitMap(tImage img,const char* vFile);
-char mReadBitMap(tImage* img,unsigned char* data, int size); //Note: this will ignore the palette
+#define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF"
+
+int mFormatExportBmp(const unsigned char* data, const char *vFileext,unsigned long int size,tImage image,int optionflag,const char* backupExtension);
+int mFormatImportBmp(unsigned char* data, tResource *res);
+int mWriteBitMap(tImage img,const char* vFile,int optionflag,const char* backupExtension);
+int mReadBitMap(tImage* img,unsigned char* data, int size); /* Note: this will ignore the palette */
 
 #endif
diff --git a/PR/src/include/bmp.h b/PR/src/include/bmp.h
index a870771..f896737 100644
--- a/PR/src/include/bmp.h
+++ b/PR/src/include/bmp.h
@@ -1,3 +1,36 @@
+/*  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
+*/
+
+/*
+bmp.h: Princed Resources : BMP file support headers
+\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+  Version: 1.10 (2004-Feb-17)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _BMP_H_
 #define _BMP_H_
@@ -5,9 +38,11 @@
 #include "resources.h"
 #include "compress.h"
 
-char mFormatExtractBmp(unsigned char* data, const char *vFileext,unsigned long int size,tImage image);
-char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res);
-char mWriteBitMap(tImage img,const char* vFile);
-char mReadBitMap(tImage* img,unsigned char* data, int size); //Note: this will ignore the palette
+#define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF"
+
+int mFormatExportBmp(const unsigned char* data, const char *vFileext,unsigned long int size,tImage image,int optionflag,const char* backupExtension);
+int mFormatImportBmp(unsigned char* data, tResource *res);
+int mWriteBitMap(tImage img,const char* vFile,int optionflag,const char* backupExtension);
+int mReadBitMap(tImage* img,unsigned char* data, int size); /* Note: this will ignore the palette */
 
 #endif
diff --git a/PR/src/include/classify.h b/PR/src/include/classify.h
index d82f2ab..07fe3b4 100644
--- a/PR/src/include/classify.h
+++ b/PR/src/include/classify.h
@@ -1,3 +1,35 @@
+/*  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
+*/
+
+/*
+tasks.h: Princed Resources : Other DAT file handling tasks headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _TASKS_H_
 #define _TASKS_H_
@@ -22,4 +54,6 @@
 
 int prVerifyDatType(const char* vFiledat);
 
+void compareFiles(const char* vModified,const char* vOriginal);
+
 #endif
diff --git a/PR/src/include/common.h b/PR/src/include/common.h
index f251681..c739651 100644
--- a/PR/src/include/common.h
+++ b/PR/src/include/common.h
@@ -29,8 +29,8 @@ pr.h: Princed Resources : Main header prototypes and definitions
 
   Modified by: Enrique Calot <ecalot.cod@princed.com.ar>
   Version: 1.10 (2003-Dec-03)
-  
-  Language: English
+
+  Language: Abstract
 
  Note:
   DO NOT remove this copyright notice
@@ -45,13 +45,14 @@ pr.h: Princed Resources : Main header prototypes and definitions
 
 #include <stdio.h>
 
-//User configuration defines
+/* User configuration defines */
 #ifndef WIN32
  #define UNIX
 #endif
 
 /* do not #define DLL, use -DDLL as a precompiler option instead */
 #ifdef DLL
+void prSetOutput(FILE* output);
  #ifdef UNIX
   #define SO
  #endif
@@ -65,11 +66,24 @@ pr.h: Princed Resources : Main header prototypes and definitions
  #endif
 #endif
 
-//Debug options
-#define DEB_FLAG
+/* Debug options */
+/* #define DEB_FLAG */
+/* #define MEM_CHECK */
+
+#ifdef MEM_CHECK
+
+#ifdef malloc
+#undef malloc
+#endif
+
+#include "memory.h"
+ #define malloc(a) mymalloc(a,__FILE__,__LINE__)
+ #define free(a) myfree(a,__FILE__,__LINE__)
+
+#endif
 
 #ifdef DEB_FLAG
- #define fld(a) printf(a "\n");
+ #define fld(a) printf(a "\n")
 #else
  #define fld(a)
 #endif
@@ -78,162 +92,67 @@ pr.h: Princed Resources : Main header prototypes and definitions
 |             M A I N   P R O G R A M   D E F I N E S           |
 \***************************************************************/
 
-
 /***************************************************************\
-|                           Text Defines                        |
+|                     PR Specific Defines                       |
 \***************************************************************/
 
-
-#define PR_ABOUT                  "Princed resources (PR) V0.9 "OS"\n(c) Copyright 2003 - Princed Development Team\n\
-http://www.princed.com.ar\n\n"
-
-#define PR_CGI_TEXT1              "Content-Type:text/html\n\nRunning as a cgi\n"
-#define PR_CGI_TEXT2              "Result: %02d type\n"
-
-#define PR_TEXT_SKIPING           "Found invalid option '%c', skiping . . .\n"
-#define PR_TEXT_RESULT            "Result: %s (%d)\n"
-#define PR_TEXT_RESULT_ERR        "Result: %d files with errors\n"
-
-#define PR_TEXT_FILE_NOT_FOUND    "Result: File or directory '%s' not found\n"
-
-#define PR_TEXT_SCANNING_CURRENT  "Scanning dat files in current directory\n"
-#define PR_TEXT_SCANNING_GIVEN    "Scanning dat files in given directory\n"
-
-#define PR_TEXT_IMPORTING_CURRENT "Importing all valid dat files from the currect directory\n"
-#define PR_TEXT_IMPORTING_GIVEN   "Importing all valid files from given directory\n"
-
-#define PR_TEXT_TASK_COMPILE      "Compiling '%s' from '%s' with %04x\n"
-#define PR_TEXT_TASK_CLASSIFY     "Classifing '%s'\n"
-#define PR_TEXT_TASK_EXTRACT      "Extracting '%s' to '%s' with %04x\n"
-
-/***************************************************************\
-|                        Text Output Arrays                     |
-\***************************************************************/
-
-#define PR_TEXT_EXPORT_ARRAY {\
-"Ok",\
-"Error accessing the file DAT", /* DAT or extracted */\
-"Memory error in extraction",\
-"Invalid DAT file",\
-"XML Parse error",\
-"Memory error in parsing",\
-"XML Attribute not recognized",\
-"XML File not found"}
-
-#define PR_TEXT_CLASSIFY_ARRAY {\
-"Memory error",\
-"File not found or no access error",\
-"Not a valid POP1 DAT file",\
-"Levels file",\
-"Graphic file with an image in the first valid entry (not common)",\
-"Waves/Digital sound file",\
-"Midis file",\
-"Valid DAT file with Undefined content",\
-"Graphic file with a palette in the first valid entry (common)",\
-"PC Speaker dat file",\
-"","","",\
-"Pop2 dat files"}
-
-#define PR_TEXT_IMPORT_ARRAY {\
-"File succesfully compiled",\
-"DAT File couldn't be open for writing",\
-"XML Parse error",\
-"No memory",\
-"XML Attribute not recognized",\
-"XML File not found"}
-
+#define PR_URL                    "http://www.princed.com.ar"
+#define PR_VERSION                "v1.0b-dev1"
+#define PR_COPY                   "(c) Copyright 2003, 2004 - Princed Development Team"
 /***************************************************************\
 |                         Other defines                         |
 \***************************************************************/
 
-
-//Default Files
-#define RES_XML_UNKNOWN_XML  "unknown.xml"
-#define RES_XML_RESOURC_XML  "resources.xml"
-
-//Define max & min's
-#define MAX_RES_COUNT 65000
-
-//Define max & min's
-#define MAX_FILENAME_SIZE  260
-#define MAX_EXTENSION_SIZE 10
+/* Default Files */
+#define RES_XML_UNKNOWN_XML      "unknown.xml"
+#define RES_XML_RESOURC_XML      "resources.xml"
 
 #define DEFAULT_BACKUP_EXTENSION "bak"
 
-//Path defines
+/* Define max & min's */
+#define MAX_RES_COUNT            25000
+#define MAX_FILENAME_SIZE        260
+
+/* Path defines */
 #ifdef UNIX
- #define DIR_SEPARATOR       '/'
+ #define DIR_SEPARATOR           '/'
 #else
- #define DIR_SEPARATOR       '\\'
+ #define DIR_SEPARATOR           '\\'
 #endif
 
 /***************************************************************\
-|                            Prototypes                         |
+|                        L A N G U A G E                        |
 \***************************************************************/
 
-//Main functions
+#include "english.h"
+
+/***************************************************************\
+|                           Prototypes                          |
+\***************************************************************/
+
+/* Main functions */
 int prExportDat(const char* vDatFile, const char* vDirName, const char* vResFile);
 int prImportDat(const char* vDatFile, const char* vDirName, const char* vResFile);
 int prVerifyDatType(const char* vFiledat);
 
-//Extra featured functions
+/* Extra featured functions */
 int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char * vDatFileName,const char* datAuthor, const char* backupExtension);
 int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char* vDatFileName, const char* backupExtension);
 
-//Recursive function
-int prMain(int* option, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output);
+/* Recursive function */
+int prMain(int option, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output);
 
 /***************************************************************\
 |                   Command Line specific options               |
 \***************************************************************/
 
-#define PARSING_HELP "Usage: \n\
-  pr [-x[EXTRACTDIR]|-c[COMPILEDIR]|-d] [DATFILEPATH]\n\
-  pr [OPTIONS] [DATFILEPATH]\n\
-\n\
-  Mandatory arguments to long options are mandatory for short options too.\n\
-\n\
-   -c, --import[=DIRNAME]     imports from DIRNAME into given dat file\n\
-   -d, --classify             returns the DAT file type\n\
-   -x, -e, --export[=DIRNAME] extracts given dat file into DIRNAME\n\
-\n\
-   -a, --setauthor=NAME       sets your name in extracted PLV files\n\
-   -b, --backup[=EXTENSION]   backup your files\n\
-   -f, --force                default option, you cannot disable it,\n\
-                              so please make a backup of your files\n\
-   -g, --cgi                  run as CGI and output mime headers\n\
-   -h, -?, --help             display this help and exit\n\
-   -m, --resource=RESFILE     uses an user-specific resource xml file\n\
-   -r, --raw                  uses raw format\n\
-   -R, --recursive            searches for all dat files (only if DATFILEPATH\n\
-                              is not a dat file)\n\
-   -t, --datfile=DATFILE      specifies a dat file to read resources\n\
-                              different that the original file\n\
-       --unknown              generate the unknown file without performing\n\
-                              any extraction\n\
-   -v, --verbose              explain what is being done\n\
-       --version              output version information and exit\n\
-\n"
-
-#define PARSING_ABOUT "Authors: \n\
-   Coding & main routines\n\
-    Enrique Calot\n\
-\n\
-   Graphic compression algorithms\n\
-    Tammo Jan Dijkema\n\
-    Enrique Calot\n\
-\n\
-   Graphic format development\n\
-    Tammo Jan Dijkema\n\
-    Anke Balderer\n\
-\n\
-   MID Sound format development\n\
-    Christian Lundheim\n\
-\n\
-   Resources.xml edition\n\
-    Steven Fayers\n\
-\n"
-
+#ifndef PR_IGNORE_RAW_OPTION
+#define PARSING_OPTRAW ,{"raw",         no_argument,       0,'r'},
+#define PARSING_CHRRAW "r"
+#else
+#define PARSING_OPTRAW ,
+#define PARSING_CHRRAW ""
+#endif
 #define PARSING_OPTIONS {\
 {"import",      optional_argument, 0,'c'},\
 {"classify",    no_argument,       0,'d'},\
@@ -244,8 +163,8 @@ int prMain(int* option, const char* extension,const char* dirName,const char* re
 {"force",       no_argument,       0,'f'},\
 {"cgi",         no_argument,       0,'g'},\
 {"help",        no_argument,       0,'?'},\
-{"resource",    required_argument, 0,'m'},\
-{"raw",         no_argument,       0,'r'},\
+{"resource",    required_argument, 0,'s'}\
+PARSING_OPTRAW\
 {"recursive",   no_argument,       0,'R'},\
 {"datfile",     required_argument, 0,'t'},\
 {"unknown",     no_argument,       0,2},\
@@ -254,7 +173,7 @@ int prMain(int* option, const char* extension,const char* dirName,const char* re
 {0, 0, 0, 0}\
 }
 
-#define PARSING_CHARS    "c::dx::e::b::a:fgm:t:rRv"
+#define PARSING_CHARS    "i::c::dx::e::b::a::fgs::t::Rvh?"PARSING_CHRRAW
 
 /* Flags */
 #define import_flag      0x0001
@@ -264,16 +183,17 @@ int prMain(int* option, const char* extension,const char* dirName,const char* re
 #define force_flag       0x0010
 #define cgi_flag         0x0020
 #define help_flag        0x0040
-#define first_flag       0x0080
-#define raw_flag         0x0100
-#define recursive_flag   0x0200
-#define verbose_flag     0x0400
-#define version_flag     0x0800
-#define unknown_flag     0x1000
-#define undef1_flag      0x2000
-#define undef2_flag      0x4000
-#define undef3_flag      0x8000
-
-#define optionflag (*pOption)
+#define raw_flag         0x0080
+#define recursive_flag   0x0100
+#define verbose_flag     0x0200
+#define version_flag     0x0400
+#define unknown_flag     0x0800
+#define undef1_flag      0x1000
+#define undef2_flag      0x2000
+#define undef3_flag      0x4000
+#define undef4_flag      0x8000
+
+#define hasFlag(a) (optionflag&(a))
+#define setFlag(a) optionflag|=(a)
 
 #endif
diff --git a/PR/src/include/compress.h b/PR/src/include/compress.h
index c57241e..19e8502 100644
--- a/PR/src/include/compress.h
+++ b/PR/src/include/compress.h
@@ -1,28 +1,75 @@
+/*  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
+*/
+
+/*
+compress.c: Princed Resources : Image Compressor headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _COMPRESS_H_
 #define _COMPRESS_H_
 
-#define SIZE_OF_ARRAY   1000
 #define SIZE_OF_PALETTE 3*16
 
-#define PG_COMP_RAW    0xB0
-#define PG_COMP_RLE_LR 0xB1
-#define PG_COMP_RLE_UD 0xB2
-#define PG_COMP_LZX_LR 0xB3
-#define PG_COMP_LZX_UD 0xB4
+#define COMPRESS_RAW    0x00
+#define COMPRESS_RLE_LR 0x01
+#define COMPRESS_RLE_UD 0x02
+#define COMPRESS_LZG_LR 0x03
+#define COMPRESS_LZG_UD 0x04
+
+#define COMPRESS_WORKING_ALGORITHMS 3
+
+#define COMPRESS_RESULT_FATAL   -2
+#define COMPRESS_RESULT_WARNING -1
+#define COMPRESS_RESULT_SUCCESS 0
+
+/* reserved memory for the Lzx algorithm */
+#define MAX_MOD_SIZE_IN_LZG    32001                /* 38401 */
+/* modulus to be used in the 10 bits of the algorithm */
+#define MAX_MXD_SIZE_IN_LZG    0x400
 
 typedef struct {
 	int width;
+	int widthInBytes;
 	int height;
-	int size;
+	//int sizeInBytes;
 	unsigned char* pix;
 	unsigned char pal[SIZE_OF_PALETTE];
+	unsigned char type; /* XY where X=B if 4 bits or X=0 if 1 bit; Y=algorithm */
 }tImage;
 
-//Prototypes:
+/* Prototypes */
 
 int mCompressGraphic(unsigned char* a,tImage* i, int* size);
-int mExpandGraphic(unsigned char* array,tImage *image, int size);
+int mExpandGraphic(const unsigned char* array,tImage *image, int size);
+
+#define getCarry(a) ((a)>>6)
+#define getAlgor(a) a&0x4F
 
 /*
 	Class future definitions
diff --git a/PR/src/include/disk.h b/PR/src/include/disk.h
index 8549541..20d2518 100644
--- a/PR/src/include/disk.h
+++ b/PR/src/include/disk.h
@@ -1,3 +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
+*/
+
+/*
+disk.h: Princed Resources : Disk Access & File handling functions headers
+\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 29 Oct 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.00 (2003-Oct-29)
+
+  Modified by: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.10 (2003-Dec-03)
+  Modified by: Santiago Zamora <drkzight@users.sourceforge.net>
+  Version: 1.20 (2004-Jan-06)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _DISK_H_
 #define _DISK_H_
@@ -5,18 +42,43 @@
 #include <stdio.h>
 
 /* 64 Kb */
-#define SIZE_OF_FILE    256*1024
+#define SIZE_OF_FILE     256*1024
+//#define COPY_BUFFER_SIZE 512
 
 typedef enum {eFile,eDirectory,eNotFound}whatIs;
 
+#define charToUpper(a) ((a)&0xDF)
+#define isDirSep(a,i) ((a[i]=='\\')||(a[i]=='/'))
+
+typedef struct tOpenFiles {
+	struct tOpenFiles* next;
+	FILE* file;
+	char* name;
+	unsigned char* content;
+	unsigned long int size;
+}tOpenFiles;
+
 char mDiskVealidateFileHeader(unsigned char* text, int size, FILE* fp);
-char mSaveRaw      (const char* vFile,const unsigned char* output, int size);
-char writeData     (const unsigned char* data, int ignoreChars, char* vFileext, int size);
-char writeOpen     (const char* vFileext, FILE* *fp);
+/* char mSaveRaw      (const char* vFile,const unsigned char* output, int size); */
+#define mSaveRaw(f,d,s,optionflag,backup) writeData(d,0,f,s,optionflag,backup)
+#define writeCloseOk(a,b,c) writeClose(a,0,b,c)
+#define writeCloseDelete(a,b,c) writeClose(a,1,b,c)
+int  writeData     (const unsigned char* data, int ignoreChars, char* vFileext, int size, int optionflag,const char* backupExtension);
+int  writeOpen     (const char* vFileext, FILE* *fp, int optionflag);
+int  writeClose    (FILE* fp,int dontSave,int optionflag,const char* backupExtension);
 int  mLoadFileArray(const char* vFile,unsigned char** array);
 int  makebase      (const char* p);
-const char *repairFolders(const char* a);
+const char* repairFolders(const char* a);
 const char* getFileNameFromPath(const char* path);
-int recurseDirectory(const char* path,int* pOption, const char* extension,const char* dirName,const char* resFile, const char* datfilename,const char* datAuthor,FILE* output);
+int recurseDirectory(const char* path,int optionflag, const char* extension,const char* dirName,const char* resFile, const char* datfilename,const char* datAuthor,FILE* output);
 whatIs isDir(const char *nombre);
-#endif
+int mCopy(const char* strSource, const char* strTarget);
+#define mRemoveFile(a) remove(repairFolders(a))
+
+/* array2vars*/
+
+#define array2short(a) ((*a))+((*(a+1))<<8)
+#define array2long(a)  ((*a))+((*(a+1))<<8)+((*(a+2))<<16)+((*(a+3))<<24)
+
+
+#endif
\ No newline at end of file
diff --git a/PR/src/include/export.h b/PR/src/include/export.h
index bba9158..dd78230 100644
--- a/PR/src/include/export.h
+++ b/PR/src/include/export.h
@@ -1,22 +1,41 @@
+/*  Princed V3 - Prince of Persia Level Editor for PC Version
+    Copyright (C) 2003 Princed Development Team
 
-#ifndef _EXTARCT_H_
-#define _EXTRACT_H_
+    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.
 
-#include "resources.h"
+    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.
 
-/***************************************************************\
-|                     M A I N   E X T R A C T                   |
-\***************************************************************/
+    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
+*/
 
 /*
-	Tasks:
-		1 - extract
-		2 - update resources
-		3 - 1&2
-		4 - use raw file if extraction
-		8 - rebuild resources list
+extract.h: Princed Resources : DAT Extractor headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
 */
 
-int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task, const char* vDatFileName, const char* vDatAuthor);
+#ifndef _EXTARCT_H_
+#define _EXTRACT_H_
+
+#include "resources.h"
+
+int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task, const char* vDatFileName, const char* vDatAuthor,const char* backupExtension);
 
 #endif
diff --git a/PR/src/include/filedir.h b/PR/src/include/filedir.h
index f8dcc3b..e537976 100644
--- a/PR/src/include/filedir.h
+++ b/PR/src/include/filedir.h
@@ -15,11 +15,11 @@
     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
+    The authors of this program may be contacted at http:/forum.princed.com.ar
 */
 
 /*
-xml.h: Princed Resources : xml handling functions header file
+xmlparse.h: Princed Resources : xml handling functions header file
 \xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 23 Oct 2003
@@ -38,33 +38,43 @@ xml.h: Princed Resources : xml handling functions header file
 #ifndef _XMLSEARCH_H_
 #define _XMLSEARCH_H_
 
-
-//Includes
-#include "xml.h"
+/* Includes */
+#include "xmlparse.h"
 #include "resources.h"
 
 /****************************************************************\
 |                   Tag Tree Searching Functions                 |
 \****************************************************************/
 
-tTag* searchTree(tTag* t,const char* datFile, const char* id);
-void workTag(const tTag* t, tResource* r[]);
-void workTree(const tTag* t,const char* datFile, tResource* r[]);
+const tTag* searchTree(const tTag* t,const char* datFile, const char* id);
+void workTag(const tTag* t,void* pass);
+
+/* Abstract function that runs all the tree and executes "function(tag,pass)" for each tag */
+void workTree(const tTag* t,void* pass, void (*function)(const tTag*,void*));
+
+void compareXmlFile(tTag* modified,tTag* original);
 
-//Searching Structures
+/* Searching Structures */
 
-//File List Structure
+/* File List Structure */
 typedef struct tListNode {
  char* file;
  struct tListNode* next;
 }tListNode;
 
-//File List Functions
-void addFileToList(const char* file);
-void getFiles(const tTag* t);
+/* File List Functions */
+void addFileToList(const tTag* t,void* junk);
 char* getFileFromList();
 
+/* Abstract passing structures */
+typedef struct tPassWork {
+	const char* datFile;
+	tResource** r;
+}tPassWork;
 
+typedef struct tPassCompare {
+	const tTag* tag;
+}tPassCompare;
 
 #endif
 
diff --git a/PR/src/include/idlist.h b/PR/src/include/idlist.h
index a5478dc..dddcdd2 100644
--- a/PR/src/include/idlist.h
+++ b/PR/src/include/idlist.h
@@ -1,34 +1,101 @@
+/*  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
+*/
+
+/*
+resources.h: Princed Resources : Resource Handler headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _RESOURCES_H_
 #define _RESOURCES_H_
 
-#define MAX_LINE_SIZE 300
+/* XML generation defines */
 
 #define RES_XML_UNKNOWN_PATH  "%s/unknown/%s/"
-#define RES_XML_UNKNOWN_FILES "res%d.%s"
-#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<itemtypes version=\"0.6\">\n <folder name=\"unknown\" file=\"%s\" external=\"%s\" palette=\"%d\">\n"
-#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" external=\""RES_XML_UNKNOWN_FILES"\" itemtype=\"%s\">Unknown Resource number %d</item>\n"
-#define RES_XML_UNKNOWN_END   " </folder>\n</itemtypes>\n"
-
-#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","ext","pal","pcs"}
-#define RES_FILE_TYPES        {"raw","level","image","wave","midi","unknown","palette","pcspeaker"}
-//types
+#define RES_XML_UNKNOWN_FILES "%s%02d.%s"
+#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n <folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\">\n"
+#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" path=\""RES_XML_UNKNOWN_FILES"\" itemtype=\"%s\">Unknown %s %d</item>\n"
+#define RES_XML_UNKNOWN_END   " </folder>\n</resources>\n"
+
+/* File extensions */
+
+#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
+#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
+
+/* Item Types */
+
+#define RES_TYPE_RAW          0
+#define RES_TYPE_LEVEL        1
+#define RES_TYPE_IMAGE        2
+#define RES_TYPE_WAVE         3
+#define RES_TYPE_MIDI         4
+#define RES_TYPE_BINARY       5
+#define RES_TYPE_PALETTE      6
+#define RES_TYPE_PCSPEAKER    7
+
+#define RES_TYPECOUNT         8
+
+/* types */
 typedef struct {
 	unsigned short int palette;
 	unsigned short int size;
 	unsigned long int offset;
-	unsigned char number; //Used for level number
+	unsigned char number; /* Used for level number */
 	char      type;
 	char*     path;
 	char*     palAux;
-	char*     title;
+	char*     name;
 	char*     desc;
 }tResource;
 
+/* Id list for partial manipulation */
+typedef enum {eString,eValue}tResIdType;
+
+typedef struct {
+	tResIdType idType;
+	char*      value;
+}tResIdListItem;
+
+typedef struct {
+	int             count;
+	tResIdListItem* list;
+}tResIdList;
+
+void parseGivenPath(char* path);
+int isInThePartialList(const char* file, int value);
+void freePartialList();
+
+/* Includes */
 #include <stdio.h>
+#include "xmlparse.h"
 
-//Verify  header
-int verifyHeader(unsigned char* array, int size);
+/* Verify  header */
+int verifyHeader(const unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -36,7 +103,7 @@ int verifyHeader(unsigned char* array, int size);
 	 02 Bitmaps
 	 03 Waves
 	 04 Midis
-	 05 Undefined
+	 05 Binary
 	 06 Palette
 	 07 Internal Speaker Sounds
 */
@@ -45,25 +112,34 @@ int verifyHeader(unsigned char* array, int size);
 |                       File format handling                    |
 \***************************************************************/
 
-//Empty resource table
-void emptyTable(tResource* r[]);
-
+/* CheckSum verification */
+int checkSum(unsigned char* data,int size);
 
-//Resources extras
+/* Empty resource table */
+void emptyTable(tResource* r[]);
 
-void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat, const char* vDatFileName);
+/* Resources extras */
+void getFileName(char* vFileext,const char* vDirExt,tResource* r,unsigned short id,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension);
 void getUpperFolder(char* aux, char* vFiledat);
 
 const char* getExtDesc(int type);
 
-//parse file and free parsed structure
-char parseFile(const char* vFile, const char* datFile, tResource* r[]);
+/* parse file and free parsed structure */
+int parseFile(const char* vFile, const char* datFile, tResource* r[]);
 void freeParsedStructure();
+#ifdef DLL
+int parseStructure(const char* vFile);
+tTag* resourceTreeGetChild(tTag* whereAmI);
+tTag* resourceTreeGetNext (tTag* whereAmI);
+tTag* resourceTreeGetRoot ();
+int   resourceTreeGetInfo (tTag* whereAmI, char** tag, char** desc, char** path, char** file, char** itemtype, char** name, char** palette, char** type, char** value, char** version, char** number);
+#endif
 
-//In case there are unknown resources it closes the unknown XML output
+/* In case there are unknown resources it closes the unknown XML output */
 void endUnknownXml();
 
-//Search files for the Import feature
-int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+/* Search files for the Import feature */
+int importDir(const char* directory, const char* vResFile, int pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+int isntADatFile(const char* testFile, const char* vResFile);
 
 #endif
diff --git a/PR/src/include/image.h b/PR/src/include/image.h
index c57241e..19e8502 100644
--- a/PR/src/include/image.h
+++ b/PR/src/include/image.h
@@ -1,28 +1,75 @@
+/*  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
+*/
+
+/*
+compress.c: Princed Resources : Image Compressor headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _COMPRESS_H_
 #define _COMPRESS_H_
 
-#define SIZE_OF_ARRAY   1000
 #define SIZE_OF_PALETTE 3*16
 
-#define PG_COMP_RAW    0xB0
-#define PG_COMP_RLE_LR 0xB1
-#define PG_COMP_RLE_UD 0xB2
-#define PG_COMP_LZX_LR 0xB3
-#define PG_COMP_LZX_UD 0xB4
+#define COMPRESS_RAW    0x00
+#define COMPRESS_RLE_LR 0x01
+#define COMPRESS_RLE_UD 0x02
+#define COMPRESS_LZG_LR 0x03
+#define COMPRESS_LZG_UD 0x04
+
+#define COMPRESS_WORKING_ALGORITHMS 3
+
+#define COMPRESS_RESULT_FATAL   -2
+#define COMPRESS_RESULT_WARNING -1
+#define COMPRESS_RESULT_SUCCESS 0
+
+/* reserved memory for the Lzx algorithm */
+#define MAX_MOD_SIZE_IN_LZG    32001                /* 38401 */
+/* modulus to be used in the 10 bits of the algorithm */
+#define MAX_MXD_SIZE_IN_LZG    0x400
 
 typedef struct {
 	int width;
+	int widthInBytes;
 	int height;
-	int size;
+	//int sizeInBytes;
 	unsigned char* pix;
 	unsigned char pal[SIZE_OF_PALETTE];
+	unsigned char type; /* XY where X=B if 4 bits or X=0 if 1 bit; Y=algorithm */
 }tImage;
 
-//Prototypes:
+/* Prototypes */
 
 int mCompressGraphic(unsigned char* a,tImage* i, int* size);
-int mExpandGraphic(unsigned char* array,tImage *image, int size);
+int mExpandGraphic(const unsigned char* array,tImage *image, int size);
+
+#define getCarry(a) ((a)>>6)
+#define getAlgor(a) a&0x4F
 
 /*
 	Class future definitions
diff --git a/PR/src/include/import.h b/PR/src/include/import.h
index 6e5820f..bb80ef0 100644
--- a/PR/src/include/import.h
+++ b/PR/src/include/import.h
@@ -1,6 +1,35 @@
-/***************************************************************\
-|                  I M P L E M E N T A T I O N                  |
-\***************************************************************/
+/*  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
+*/
+
+/*
+compile.h: Princed Resources : DAT Compiler headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _COMPILE_H_
 #define _COMPILE_H_
@@ -8,7 +37,6 @@
 #include <stdio.h>
 #include "resources.h"
 
-void mAddFileToDatFile(FILE* fp, unsigned char* data, int size);
-int compile(const char* vFiledat, const char* vDirExt, tResource* r[], int opt, const char* vDatFileName);
+int compile(const char* vFiledat, const char* vDirExt, tResource* r[], int opt, const char* vDatFileName,const char* backupExtension);
 
 #endif
diff --git a/PR/src/include/memory.h b/PR/src/include/memory.h
index 47c1902..3e2bfe7 100644
--- a/PR/src/include/memory.h
+++ b/PR/src/include/memory.h
@@ -1,13 +1,44 @@
+/*  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
+*/
+
+/*
+memory.h: Princed Resources : Memory handling headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 20 Dec 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2004-Feb-13)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _MEMORY_H_
 #define _MEMORY_H_
 
 #include <stdlib.h>
 
-//Reserves a memory space to allocate an image
-//TODO change "unsigned char*" for "unsigned char" in sizeof
-#define getMemory(size) ((unsigned char*)malloc(sizeof(unsigned char*)*(size)))
+#define getMemory(size) ((unsigned char*)malloc(size))
 char* strallocandcopy(const char* text);
+#define freeAllocation(m) if ((m)!=NULL) free(m)
 
 #endif
 
diff --git a/PR/src/include/mid.h b/PR/src/include/mid.h
index b3fb46b..3bd8753 100644
--- a/PR/src/include/mid.h
+++ b/PR/src/include/mid.h
@@ -1,3 +1,35 @@
+/*  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
+*/
+
+/*
+mid.h: Princed Resources : MIDI files support headers
+\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _MID_H_
 #define _MID_H_
@@ -5,7 +37,7 @@
 #include <stdio.h>
 #include "resources.h"
 
-char mFormatCompileMid(unsigned char* data, FILE* fp, tResource *res);
-char mFormatExtractMid(unsigned char* data, char *vFileext,unsigned long int size);
+int mFormatImportMid(unsigned char* data, tResource *res);
+int mFormatExportMid(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension);
 
 #endif
diff --git a/PR/src/include/pal.h b/PR/src/include/pal.h
index d18f729..3662f3c 100644
--- a/PR/src/include/pal.h
+++ b/PR/src/include/pal.h
@@ -1,21 +1,49 @@
+/*  Princed V3 - Prince of Persia Level Editor for PC Version
+    Copyright (C) 2003 Princed Development Team
 
-/***************************************************************\
-|                 Jasc Palette handling functions               |
-\***************************************************************/
+    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
+*/
+
+/*
+pal.h: Princed Resources : JASC PAL files support headers
+\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _PAL_H_
 #define _PAL_H_
 
 #include "compress.h"
+#include "resources.h"
+#include <stdio.h>
 
 #define PAL_HEADER "JASC-PAL\r\n0100\r\n16\r\n"
 #define PAL_SAMPLE {0x97, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x08, 0x0F, 0x07, 0x0C, 0x13, 0x0C, 0x11, 0x16, 0x11, 0x17, 0x1C, 0x1E, 0x21, 0x25, 0x2F, 0x31, 0x33, 0x3F, 0x3F, 0x3F, 0x2A, 0x2A, 0x2A, 0x15, 0x15, 0x15, 0x17, 0x1C, 0x20, 0x07, 0x0C, 0x13, 0x0C, 0x12, 0x17, 0x15, 0x1A, 0x1F, 0x00, 0x1D, 0x13, 0x00, 0x29, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 
-char mFormatExtractPal(unsigned char** data, char *vFileext,unsigned long int size);
-char mImportPalette(unsigned char** data, unsigned short *size);
-void mExportPalette(unsigned char** data, unsigned long int *size);
+int mFormatExportPal(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtensio);
+int mFormatImportPal(unsigned char* data, tResource *res,const char* vFile);
 
-//This function will be obsolete
-void mLoadPalette(unsigned char* array,tImage *image);
+#define mLoadPalette(array,image)	memcpy(((image).pal),((array)+5),(16*3))
 
 #endif
diff --git a/PR/src/include/plv.h b/PR/src/include/plv.h
index ce52257..164f71d 100644
--- a/PR/src/include/plv.h
+++ b/PR/src/include/plv.h
@@ -1,22 +1,82 @@
+/*  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
+*/
+
+/*
+plv.h: Princed Resources : PLV prince level files support headers
+\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 29 Nov 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.00 (2003-Nov-29)
+
+ PLV file format:
+  Defined: 28 Nov 2003
+
+  Authors:
+   Brendon James <roomshaker@princed.com.ar>
+   Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.00 (2003-Nov-28)
+
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _PLV_H_
 #define _PLV_H_
 
+/*
+	PLV 1 SPECS:
+	bytes offset description                     content
+	    7      0 HAS FILE TAG OF 8 LETTERS       "POP_LVL"
+	    1      7 POP VERS                        0x01
+	    1      8 PLV VERS                        0x01
+	    1      9 LEV NUM
+	    4     10 FIELD-PAIR ( NAME / CONTENT ) COUNT
+	    4     14 BLOCK 1: LEVEL SIZE (B1)        2306 (including the checksum)
+	   B1     18 BLOCK 1: LEVEL CODE
+	    4  18+B1 BLOCK 2: USER DATA SIZE VALUE IN BYTES (B2)
+	   B2  22+B1 BLOCK 2: LEVEL CODE NEXT, REST OF FILE
+
+	Total size of file B1+B2+22.
+	All values are unsigned and in the intel x86 architecture
+*/
+
 #include <stdio.h>
 #include "resources.h"
+#include "pr.h" /* for PR_VERSION */
 
-char mFormatCompilePlv(unsigned char* data, FILE* fp, tResource *res);
-char mFormatExtractPlv(unsigned char* data, const char *vFileext,unsigned long int size,unsigned char level, const char* filename, const char* desc, const char* title, const char* vDatAuthor);
+int mFormatImportPlv(unsigned char* data, tResource *res);
+int mFormatExportPlv(const unsigned char* data, const char *vFileext,unsigned long int size,unsigned char level, const char* filename, const char* desc, const char* title, const char* vDatAuthor,int optionflag, const char* backupExtension);
 
-//Dias de la semana y meses del anio
+/* Weekdays and months */
 #define DATE_WEEKDAYS "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat"
 #define DATE_MONTHS   "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec"
 
+/* Format stuff */
 #define PLV_HEADER_A           "POP_LVL\x01\x01"
-#define PLV_HEADER_A_SIZE      sizeof(PLV_HEADER_A)-1
-#define PLV_HEADER_B           ":)"
-#define PLV_HEADER_B_SIZE      sizeof(PLV_HEADER_B)-1
-#define PLV_FOOT_EDITOR        "EDITORNAME\0PR\0EDITORVERS\0\x30.9\0AUTHOR"
+#define PLV_HEADER_A_SIZE      9
+#define PLV_HEADER_B           "\08x\0\0"
+#define PLV_HEADER_B_SIZE      4
+#define PLV_FOOT_EDITOR        "EDITORNAME\0PR\0EDITORVERS\0"PR_VERSION"\0AUTHOR"
 #define PLV_FOOT_TITLE         "TITLE"
 #define PLV_FOOT_DESC          "DESCRIPTION"
 #define PLV_FOOT_TCREAT        "TIMECREATED"
@@ -24,5 +84,6 @@ char mFormatExtractPlv(unsigned char* data, const char *vFileext,unsigned long i
 #define PLV_FOOT_ORIG_FILE     "ORIGINALFILENAME"
 #define PLV_HEADER_SIZE_OFFSET PLV_HEADER_A_SIZE+PLV_HEADER_B_SIZE
 
+#define PLV_DEFAULT_AUTHOR     "PR user"
 
 #endif
diff --git a/PR/src/include/png.h b/PR/src/include/png.h
index a870771..f896737 100644
--- a/PR/src/include/png.h
+++ b/PR/src/include/png.h
@@ -1,3 +1,36 @@
+/*  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
+*/
+
+/*
+bmp.h: Princed Resources : BMP file support headers
+\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+  Version: 1.10 (2004-Feb-17)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _BMP_H_
 #define _BMP_H_
@@ -5,9 +38,11 @@
 #include "resources.h"
 #include "compress.h"
 
-char mFormatExtractBmp(unsigned char* data, const char *vFileext,unsigned long int size,tImage image);
-char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res);
-char mWriteBitMap(tImage img,const char* vFile);
-char mReadBitMap(tImage* img,unsigned char* data, int size); //Note: this will ignore the palette
+#define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF"
+
+int mFormatExportBmp(const unsigned char* data, const char *vFileext,unsigned long int size,tImage image,int optionflag,const char* backupExtension);
+int mFormatImportBmp(unsigned char* data, tResource *res);
+int mWriteBitMap(tImage img,const char* vFile,int optionflag,const char* backupExtension);
+int mReadBitMap(tImage* img,unsigned char* data, int size); /* Note: this will ignore the palette */
 
 #endif
diff --git a/PR/src/include/pr.h b/PR/src/include/pr.h
index f251681..c739651 100644
--- a/PR/src/include/pr.h
+++ b/PR/src/include/pr.h
@@ -29,8 +29,8 @@ pr.h: Princed Resources : Main header prototypes and definitions
 
   Modified by: Enrique Calot <ecalot.cod@princed.com.ar>
   Version: 1.10 (2003-Dec-03)
-  
-  Language: English
+
+  Language: Abstract
 
  Note:
   DO NOT remove this copyright notice
@@ -45,13 +45,14 @@ pr.h: Princed Resources : Main header prototypes and definitions
 
 #include <stdio.h>
 
-//User configuration defines
+/* User configuration defines */
 #ifndef WIN32
  #define UNIX
 #endif
 
 /* do not #define DLL, use -DDLL as a precompiler option instead */
 #ifdef DLL
+void prSetOutput(FILE* output);
  #ifdef UNIX
   #define SO
  #endif
@@ -65,11 +66,24 @@ pr.h: Princed Resources : Main header prototypes and definitions
  #endif
 #endif
 
-//Debug options
-#define DEB_FLAG
+/* Debug options */
+/* #define DEB_FLAG */
+/* #define MEM_CHECK */
+
+#ifdef MEM_CHECK
+
+#ifdef malloc
+#undef malloc
+#endif
+
+#include "memory.h"
+ #define malloc(a) mymalloc(a,__FILE__,__LINE__)
+ #define free(a) myfree(a,__FILE__,__LINE__)
+
+#endif
 
 #ifdef DEB_FLAG
- #define fld(a) printf(a "\n");
+ #define fld(a) printf(a "\n")
 #else
  #define fld(a)
 #endif
@@ -78,162 +92,67 @@ pr.h: Princed Resources : Main header prototypes and definitions
 |             M A I N   P R O G R A M   D E F I N E S           |
 \***************************************************************/
 
-
 /***************************************************************\
-|                           Text Defines                        |
+|                     PR Specific Defines                       |
 \***************************************************************/
 
-
-#define PR_ABOUT                  "Princed resources (PR) V0.9 "OS"\n(c) Copyright 2003 - Princed Development Team\n\
-http://www.princed.com.ar\n\n"
-
-#define PR_CGI_TEXT1              "Content-Type:text/html\n\nRunning as a cgi\n"
-#define PR_CGI_TEXT2              "Result: %02d type\n"
-
-#define PR_TEXT_SKIPING           "Found invalid option '%c', skiping . . .\n"
-#define PR_TEXT_RESULT            "Result: %s (%d)\n"
-#define PR_TEXT_RESULT_ERR        "Result: %d files with errors\n"
-
-#define PR_TEXT_FILE_NOT_FOUND    "Result: File or directory '%s' not found\n"
-
-#define PR_TEXT_SCANNING_CURRENT  "Scanning dat files in current directory\n"
-#define PR_TEXT_SCANNING_GIVEN    "Scanning dat files in given directory\n"
-
-#define PR_TEXT_IMPORTING_CURRENT "Importing all valid dat files from the currect directory\n"
-#define PR_TEXT_IMPORTING_GIVEN   "Importing all valid files from given directory\n"
-
-#define PR_TEXT_TASK_COMPILE      "Compiling '%s' from '%s' with %04x\n"
-#define PR_TEXT_TASK_CLASSIFY     "Classifing '%s'\n"
-#define PR_TEXT_TASK_EXTRACT      "Extracting '%s' to '%s' with %04x\n"
-
-/***************************************************************\
-|                        Text Output Arrays                     |
-\***************************************************************/
-
-#define PR_TEXT_EXPORT_ARRAY {\
-"Ok",\
-"Error accessing the file DAT", /* DAT or extracted */\
-"Memory error in extraction",\
-"Invalid DAT file",\
-"XML Parse error",\
-"Memory error in parsing",\
-"XML Attribute not recognized",\
-"XML File not found"}
-
-#define PR_TEXT_CLASSIFY_ARRAY {\
-"Memory error",\
-"File not found or no access error",\
-"Not a valid POP1 DAT file",\
-"Levels file",\
-"Graphic file with an image in the first valid entry (not common)",\
-"Waves/Digital sound file",\
-"Midis file",\
-"Valid DAT file with Undefined content",\
-"Graphic file with a palette in the first valid entry (common)",\
-"PC Speaker dat file",\
-"","","",\
-"Pop2 dat files"}
-
-#define PR_TEXT_IMPORT_ARRAY {\
-"File succesfully compiled",\
-"DAT File couldn't be open for writing",\
-"XML Parse error",\
-"No memory",\
-"XML Attribute not recognized",\
-"XML File not found"}
-
+#define PR_URL                    "http://www.princed.com.ar"
+#define PR_VERSION                "v1.0b-dev1"
+#define PR_COPY                   "(c) Copyright 2003, 2004 - Princed Development Team"
 /***************************************************************\
 |                         Other defines                         |
 \***************************************************************/
 
-
-//Default Files
-#define RES_XML_UNKNOWN_XML  "unknown.xml"
-#define RES_XML_RESOURC_XML  "resources.xml"
-
-//Define max & min's
-#define MAX_RES_COUNT 65000
-
-//Define max & min's
-#define MAX_FILENAME_SIZE  260
-#define MAX_EXTENSION_SIZE 10
+/* Default Files */
+#define RES_XML_UNKNOWN_XML      "unknown.xml"
+#define RES_XML_RESOURC_XML      "resources.xml"
 
 #define DEFAULT_BACKUP_EXTENSION "bak"
 
-//Path defines
+/* Define max & min's */
+#define MAX_RES_COUNT            25000
+#define MAX_FILENAME_SIZE        260
+
+/* Path defines */
 #ifdef UNIX
- #define DIR_SEPARATOR       '/'
+ #define DIR_SEPARATOR           '/'
 #else
- #define DIR_SEPARATOR       '\\'
+ #define DIR_SEPARATOR           '\\'
 #endif
 
 /***************************************************************\
-|                            Prototypes                         |
+|                        L A N G U A G E                        |
 \***************************************************************/
 
-//Main functions
+#include "english.h"
+
+/***************************************************************\
+|                           Prototypes                          |
+\***************************************************************/
+
+/* Main functions */
 int prExportDat(const char* vDatFile, const char* vDirName, const char* vResFile);
 int prImportDat(const char* vDatFile, const char* vDirName, const char* vResFile);
 int prVerifyDatType(const char* vFiledat);
 
-//Extra featured functions
+/* Extra featured functions */
 int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char * vDatFileName,const char* datAuthor, const char* backupExtension);
 int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char* vDatFileName, const char* backupExtension);
 
-//Recursive function
-int prMain(int* option, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output);
+/* Recursive function */
+int prMain(int option, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output);
 
 /***************************************************************\
 |                   Command Line specific options               |
 \***************************************************************/
 
-#define PARSING_HELP "Usage: \n\
-  pr [-x[EXTRACTDIR]|-c[COMPILEDIR]|-d] [DATFILEPATH]\n\
-  pr [OPTIONS] [DATFILEPATH]\n\
-\n\
-  Mandatory arguments to long options are mandatory for short options too.\n\
-\n\
-   -c, --import[=DIRNAME]     imports from DIRNAME into given dat file\n\
-   -d, --classify             returns the DAT file type\n\
-   -x, -e, --export[=DIRNAME] extracts given dat file into DIRNAME\n\
-\n\
-   -a, --setauthor=NAME       sets your name in extracted PLV files\n\
-   -b, --backup[=EXTENSION]   backup your files\n\
-   -f, --force                default option, you cannot disable it,\n\
-                              so please make a backup of your files\n\
-   -g, --cgi                  run as CGI and output mime headers\n\
-   -h, -?, --help             display this help and exit\n\
-   -m, --resource=RESFILE     uses an user-specific resource xml file\n\
-   -r, --raw                  uses raw format\n\
-   -R, --recursive            searches for all dat files (only if DATFILEPATH\n\
-                              is not a dat file)\n\
-   -t, --datfile=DATFILE      specifies a dat file to read resources\n\
-                              different that the original file\n\
-       --unknown              generate the unknown file without performing\n\
-                              any extraction\n\
-   -v, --verbose              explain what is being done\n\
-       --version              output version information and exit\n\
-\n"
-
-#define PARSING_ABOUT "Authors: \n\
-   Coding & main routines\n\
-    Enrique Calot\n\
-\n\
-   Graphic compression algorithms\n\
-    Tammo Jan Dijkema\n\
-    Enrique Calot\n\
-\n\
-   Graphic format development\n\
-    Tammo Jan Dijkema\n\
-    Anke Balderer\n\
-\n\
-   MID Sound format development\n\
-    Christian Lundheim\n\
-\n\
-   Resources.xml edition\n\
-    Steven Fayers\n\
-\n"
-
+#ifndef PR_IGNORE_RAW_OPTION
+#define PARSING_OPTRAW ,{"raw",         no_argument,       0,'r'},
+#define PARSING_CHRRAW "r"
+#else
+#define PARSING_OPTRAW ,
+#define PARSING_CHRRAW ""
+#endif
 #define PARSING_OPTIONS {\
 {"import",      optional_argument, 0,'c'},\
 {"classify",    no_argument,       0,'d'},\
@@ -244,8 +163,8 @@ int prMain(int* option, const char* extension,const char* dirName,const char* re
 {"force",       no_argument,       0,'f'},\
 {"cgi",         no_argument,       0,'g'},\
 {"help",        no_argument,       0,'?'},\
-{"resource",    required_argument, 0,'m'},\
-{"raw",         no_argument,       0,'r'},\
+{"resource",    required_argument, 0,'s'}\
+PARSING_OPTRAW\
 {"recursive",   no_argument,       0,'R'},\
 {"datfile",     required_argument, 0,'t'},\
 {"unknown",     no_argument,       0,2},\
@@ -254,7 +173,7 @@ int prMain(int* option, const char* extension,const char* dirName,const char* re
 {0, 0, 0, 0}\
 }
 
-#define PARSING_CHARS    "c::dx::e::b::a:fgm:t:rRv"
+#define PARSING_CHARS    "i::c::dx::e::b::a::fgs::t::Rvh?"PARSING_CHRRAW
 
 /* Flags */
 #define import_flag      0x0001
@@ -264,16 +183,17 @@ int prMain(int* option, const char* extension,const char* dirName,const char* re
 #define force_flag       0x0010
 #define cgi_flag         0x0020
 #define help_flag        0x0040
-#define first_flag       0x0080
-#define raw_flag         0x0100
-#define recursive_flag   0x0200
-#define verbose_flag     0x0400
-#define version_flag     0x0800
-#define unknown_flag     0x1000
-#define undef1_flag      0x2000
-#define undef2_flag      0x4000
-#define undef3_flag      0x8000
-
-#define optionflag (*pOption)
+#define raw_flag         0x0080
+#define recursive_flag   0x0100
+#define verbose_flag     0x0200
+#define version_flag     0x0400
+#define unknown_flag     0x0800
+#define undef1_flag      0x1000
+#define undef2_flag      0x2000
+#define undef3_flag      0x4000
+#define undef4_flag      0x8000
+
+#define hasFlag(a) (optionflag&(a))
+#define setFlag(a) optionflag|=(a)
 
 #endif
diff --git a/PR/src/include/search.h b/PR/src/include/search.h
index f8dcc3b..e537976 100644
--- a/PR/src/include/search.h
+++ b/PR/src/include/search.h
@@ -15,11 +15,11 @@
     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
+    The authors of this program may be contacted at http:/forum.princed.com.ar
 */
 
 /*
-xml.h: Princed Resources : xml handling functions header file
+xmlparse.h: Princed Resources : xml handling functions header file
 \xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 23 Oct 2003
@@ -38,33 +38,43 @@ xml.h: Princed Resources : xml handling functions header file
 #ifndef _XMLSEARCH_H_
 #define _XMLSEARCH_H_
 
-
-//Includes
-#include "xml.h"
+/* Includes */
+#include "xmlparse.h"
 #include "resources.h"
 
 /****************************************************************\
 |                   Tag Tree Searching Functions                 |
 \****************************************************************/
 
-tTag* searchTree(tTag* t,const char* datFile, const char* id);
-void workTag(const tTag* t, tResource* r[]);
-void workTree(const tTag* t,const char* datFile, tResource* r[]);
+const tTag* searchTree(const tTag* t,const char* datFile, const char* id);
+void workTag(const tTag* t,void* pass);
+
+/* Abstract function that runs all the tree and executes "function(tag,pass)" for each tag */
+void workTree(const tTag* t,void* pass, void (*function)(const tTag*,void*));
+
+void compareXmlFile(tTag* modified,tTag* original);
 
-//Searching Structures
+/* Searching Structures */
 
-//File List Structure
+/* File List Structure */
 typedef struct tListNode {
  char* file;
  struct tListNode* next;
 }tListNode;
 
-//File List Functions
-void addFileToList(const char* file);
-void getFiles(const tTag* t);
+/* File List Functions */
+void addFileToList(const tTag* t,void* junk);
 char* getFileFromList();
 
+/* Abstract passing structures */
+typedef struct tPassWork {
+	const char* datFile;
+	tResource** r;
+}tPassWork;
 
+typedef struct tPassCompare {
+	const tTag* tag;
+}tPassCompare;
 
 #endif
 
diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h
index a5478dc..dddcdd2 100644
--- a/PR/src/include/tree.h
+++ b/PR/src/include/tree.h
@@ -1,34 +1,101 @@
+/*  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
+*/
+
+/*
+resources.h: Princed Resources : Resource Handler headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _RESOURCES_H_
 #define _RESOURCES_H_
 
-#define MAX_LINE_SIZE 300
+/* XML generation defines */
 
 #define RES_XML_UNKNOWN_PATH  "%s/unknown/%s/"
-#define RES_XML_UNKNOWN_FILES "res%d.%s"
-#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<itemtypes version=\"0.6\">\n <folder name=\"unknown\" file=\"%s\" external=\"%s\" palette=\"%d\">\n"
-#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" external=\""RES_XML_UNKNOWN_FILES"\" itemtype=\"%s\">Unknown Resource number %d</item>\n"
-#define RES_XML_UNKNOWN_END   " </folder>\n</itemtypes>\n"
-
-#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","ext","pal","pcs"}
-#define RES_FILE_TYPES        {"raw","level","image","wave","midi","unknown","palette","pcspeaker"}
-//types
+#define RES_XML_UNKNOWN_FILES "%s%02d.%s"
+#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n <folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\">\n"
+#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" path=\""RES_XML_UNKNOWN_FILES"\" itemtype=\"%s\">Unknown %s %d</item>\n"
+#define RES_XML_UNKNOWN_END   " </folder>\n</resources>\n"
+
+/* File extensions */
+
+#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
+#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
+
+/* Item Types */
+
+#define RES_TYPE_RAW          0
+#define RES_TYPE_LEVEL        1
+#define RES_TYPE_IMAGE        2
+#define RES_TYPE_WAVE         3
+#define RES_TYPE_MIDI         4
+#define RES_TYPE_BINARY       5
+#define RES_TYPE_PALETTE      6
+#define RES_TYPE_PCSPEAKER    7
+
+#define RES_TYPECOUNT         8
+
+/* types */
 typedef struct {
 	unsigned short int palette;
 	unsigned short int size;
 	unsigned long int offset;
-	unsigned char number; //Used for level number
+	unsigned char number; /* Used for level number */
 	char      type;
 	char*     path;
 	char*     palAux;
-	char*     title;
+	char*     name;
 	char*     desc;
 }tResource;
 
+/* Id list for partial manipulation */
+typedef enum {eString,eValue}tResIdType;
+
+typedef struct {
+	tResIdType idType;
+	char*      value;
+}tResIdListItem;
+
+typedef struct {
+	int             count;
+	tResIdListItem* list;
+}tResIdList;
+
+void parseGivenPath(char* path);
+int isInThePartialList(const char* file, int value);
+void freePartialList();
+
+/* Includes */
 #include <stdio.h>
+#include "xmlparse.h"
 
-//Verify  header
-int verifyHeader(unsigned char* array, int size);
+/* Verify  header */
+int verifyHeader(const unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -36,7 +103,7 @@ int verifyHeader(unsigned char* array, int size);
 	 02 Bitmaps
 	 03 Waves
 	 04 Midis
-	 05 Undefined
+	 05 Binary
 	 06 Palette
 	 07 Internal Speaker Sounds
 */
@@ -45,25 +112,34 @@ int verifyHeader(unsigned char* array, int size);
 |                       File format handling                    |
 \***************************************************************/
 
-//Empty resource table
-void emptyTable(tResource* r[]);
-
+/* CheckSum verification */
+int checkSum(unsigned char* data,int size);
 
-//Resources extras
+/* Empty resource table */
+void emptyTable(tResource* r[]);
 
-void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat, const char* vDatFileName);
+/* Resources extras */
+void getFileName(char* vFileext,const char* vDirExt,tResource* r,unsigned short id,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension);
 void getUpperFolder(char* aux, char* vFiledat);
 
 const char* getExtDesc(int type);
 
-//parse file and free parsed structure
-char parseFile(const char* vFile, const char* datFile, tResource* r[]);
+/* parse file and free parsed structure */
+int parseFile(const char* vFile, const char* datFile, tResource* r[]);
 void freeParsedStructure();
+#ifdef DLL
+int parseStructure(const char* vFile);
+tTag* resourceTreeGetChild(tTag* whereAmI);
+tTag* resourceTreeGetNext (tTag* whereAmI);
+tTag* resourceTreeGetRoot ();
+int   resourceTreeGetInfo (tTag* whereAmI, char** tag, char** desc, char** path, char** file, char** itemtype, char** name, char** palette, char** type, char** value, char** version, char** number);
+#endif
 
-//In case there are unknown resources it closes the unknown XML output
+/* In case there are unknown resources it closes the unknown XML output */
 void endUnknownXml();
 
-//Search files for the Import feature
-int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+/* Search files for the Import feature */
+int importDir(const char* directory, const char* vResFile, int pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+int isntADatFile(const char* testFile, const char* vResFile);
 
 #endif
diff --git a/PR/src/include/unknown.h b/PR/src/include/unknown.h
index a5478dc..dddcdd2 100644
--- a/PR/src/include/unknown.h
+++ b/PR/src/include/unknown.h
@@ -1,34 +1,101 @@
+/*  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
+*/
+
+/*
+resources.h: Princed Resources : Resource Handler headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _RESOURCES_H_
 #define _RESOURCES_H_
 
-#define MAX_LINE_SIZE 300
+/* XML generation defines */
 
 #define RES_XML_UNKNOWN_PATH  "%s/unknown/%s/"
-#define RES_XML_UNKNOWN_FILES "res%d.%s"
-#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<itemtypes version=\"0.6\">\n <folder name=\"unknown\" file=\"%s\" external=\"%s\" palette=\"%d\">\n"
-#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" external=\""RES_XML_UNKNOWN_FILES"\" itemtype=\"%s\">Unknown Resource number %d</item>\n"
-#define RES_XML_UNKNOWN_END   " </folder>\n</itemtypes>\n"
-
-#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","ext","pal","pcs"}
-#define RES_FILE_TYPES        {"raw","level","image","wave","midi","unknown","palette","pcspeaker"}
-//types
+#define RES_XML_UNKNOWN_FILES "%s%02d.%s"
+#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n <folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\">\n"
+#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" path=\""RES_XML_UNKNOWN_FILES"\" itemtype=\"%s\">Unknown %s %d</item>\n"
+#define RES_XML_UNKNOWN_END   " </folder>\n</resources>\n"
+
+/* File extensions */
+
+#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
+#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
+
+/* Item Types */
+
+#define RES_TYPE_RAW          0
+#define RES_TYPE_LEVEL        1
+#define RES_TYPE_IMAGE        2
+#define RES_TYPE_WAVE         3
+#define RES_TYPE_MIDI         4
+#define RES_TYPE_BINARY       5
+#define RES_TYPE_PALETTE      6
+#define RES_TYPE_PCSPEAKER    7
+
+#define RES_TYPECOUNT         8
+
+/* types */
 typedef struct {
 	unsigned short int palette;
 	unsigned short int size;
 	unsigned long int offset;
-	unsigned char number; //Used for level number
+	unsigned char number; /* Used for level number */
 	char      type;
 	char*     path;
 	char*     palAux;
-	char*     title;
+	char*     name;
 	char*     desc;
 }tResource;
 
+/* Id list for partial manipulation */
+typedef enum {eString,eValue}tResIdType;
+
+typedef struct {
+	tResIdType idType;
+	char*      value;
+}tResIdListItem;
+
+typedef struct {
+	int             count;
+	tResIdListItem* list;
+}tResIdList;
+
+void parseGivenPath(char* path);
+int isInThePartialList(const char* file, int value);
+void freePartialList();
+
+/* Includes */
 #include <stdio.h>
+#include "xmlparse.h"
 
-//Verify  header
-int verifyHeader(unsigned char* array, int size);
+/* Verify  header */
+int verifyHeader(const unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -36,7 +103,7 @@ int verifyHeader(unsigned char* array, int size);
 	 02 Bitmaps
 	 03 Waves
 	 04 Midis
-	 05 Undefined
+	 05 Binary
 	 06 Palette
 	 07 Internal Speaker Sounds
 */
@@ -45,25 +112,34 @@ int verifyHeader(unsigned char* array, int size);
 |                       File format handling                    |
 \***************************************************************/
 
-//Empty resource table
-void emptyTable(tResource* r[]);
-
+/* CheckSum verification */
+int checkSum(unsigned char* data,int size);
 
-//Resources extras
+/* Empty resource table */
+void emptyTable(tResource* r[]);
 
-void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat, const char* vDatFileName);
+/* Resources extras */
+void getFileName(char* vFileext,const char* vDirExt,tResource* r,unsigned short id,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension);
 void getUpperFolder(char* aux, char* vFiledat);
 
 const char* getExtDesc(int type);
 
-//parse file and free parsed structure
-char parseFile(const char* vFile, const char* datFile, tResource* r[]);
+/* parse file and free parsed structure */
+int parseFile(const char* vFile, const char* datFile, tResource* r[]);
 void freeParsedStructure();
+#ifdef DLL
+int parseStructure(const char* vFile);
+tTag* resourceTreeGetChild(tTag* whereAmI);
+tTag* resourceTreeGetNext (tTag* whereAmI);
+tTag* resourceTreeGetRoot ();
+int   resourceTreeGetInfo (tTag* whereAmI, char** tag, char** desc, char** path, char** file, char** itemtype, char** name, char** palette, char** type, char** value, char** version, char** number);
+#endif
 
-//In case there are unknown resources it closes the unknown XML output
+/* In case there are unknown resources it closes the unknown XML output */
 void endUnknownXml();
 
-//Search files for the Import feature
-int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+/* Search files for the Import feature */
+int importDir(const char* directory, const char* vResFile, int pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+int isntADatFile(const char* testFile, const char* vResFile);
 
 #endif
diff --git a/PR/src/include/wav.h b/PR/src/include/wav.h
index f634997..8ca71bf 100644
--- a/PR/src/include/wav.h
+++ b/PR/src/include/wav.h
@@ -1,3 +1,35 @@
+/*  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
+*/
+
+/*
+wav.h: Princed Resources : WAV files support headers
+\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
 
 #ifndef _WAV_H_
 #define _WAV_H_
@@ -7,7 +39,7 @@
 
 #define WAVE_HEADER {0x52, 0x49, 0x46, 0x46, 0x12, 0x16, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x2B, 0x00, 0x00, 0x11, 0x2B, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61, 0xA3, 0x15, 0x00, 0x00}
 
-int mFormatExtractWav(unsigned char* data, char *vFileext,unsigned long int size);
-int mFormatCompileWav(unsigned char* data, FILE* fp, tResource *res);
+int mFormatExportWav(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension);
+int mFormatImportWav(unsigned char* data, tResource *res);
 
 #endif
diff --git a/PR/src/lib/formats/Attic/bmp.c b/PR/src/lib/formats/Attic/bmp.c
deleted file mode 100644
index 6ac44b2..0000000
--- a/PR/src/lib/formats/Attic/bmp.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*  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
-*/
-
-/*
-bmp.c: Princed Resources : BMP file support
-\xaf\xaf\xaf\xaf\xaf
- Copyright 2003 Princed Development Team
-  Created: 24 Aug 2003
-
-  Author: Enrique Calot <ecalot.cod@princed.com.ar>
-  Version: 1.01 (2003-Oct-23)
-
- Note:
-  DO NOT remove this copyright notice
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "bmp.h"
-#include "disk.h"
-#include "memory.h"
-#include "compile.h"
-
-char mFormatExtractBmp(unsigned char* data, const char *vFileext,unsigned long int size,tImage image) {
-	/*
-		This function will expand the data into an image structure,
-		then the bitmap structure will be saved to disk
-
-		Note: The old structure is passed by paremeters in order to
-		      keep the right palette.
-	*/
-
-	if ((mExpandGraphic(data,&image,size))>0) {
-		//Write bitmap
-		mWriteBitMap(image,vFileext);
-		//free bitmap
-		free(image.pix);
-		return 1;
-	} else {
-		return 0;
-	}
-}
-
-
-char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res) {
-	int size;
-	tImage img;
-	unsigned char aux[32700];
-
-	if (!mReadBitMap(&img,data,res->size)) return 0;
-	mCompressGraphic(aux,&img,&size);
-
-	free(img.pix);
-
-	mAddFileToDatFile(fp,aux,size);
-	res->size=(unsigned short)size; //this was a bug (added to debug ;) ironic, don't you think?
-	/* Note: after the debugging we realized this line was missing so this is not a bug anymore*/
-	return 1;
-}
-
-char mWriteBitMap(tImage img,const char* vFile) {
-
-	//declare variables
-	char b;
-	char c;
-	char a;
-	FILE* bitmap;
-	unsigned long int filesize;
-	unsigned long int width;
-	unsigned long int height;
-	char junk[3]={0,0,0};
-
-	unsigned char header[]={
-		'B','M',
-		0x22,0x22,0x22,0x22,
-		0,0,0,0,
-		0x76,0,0,0,
-
-		40,0,0,0,
-		0x22,0x22,0,0,
-		0x22,0x22,0,0,
-		1,0,
-		4,0,
-		0,0,0,0,
-		0,0,0,0,
-		0xE8,0x03,0,0,
-		0xE8,0x03,0,0,
-		0x10,0,0,0,
-		0,0,0,0,
-
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0,
-		0x22,0x22,0x22,0
-	};
-
-	if (!writeOpen(vFile, &bitmap)) return 0;
-
-	filesize=((img.size+1)/2+118);
-	width=img.width;
-	height=img.height;
-
-
-	//TODO: avoid using header array andwrite everithing in one run
-
-	header[2]=(unsigned char)(filesize);
-	header[3]=(unsigned char)(filesize>>8);
-	header[4]=(unsigned char)(filesize>>16);
-	header[5]=(unsigned char)(filesize>>24);
-
-	header[18]=(unsigned char)(width);
-	header[19]=(unsigned char)(width>>8);
-
-	header[22]=(unsigned char)(height);
-	header[23]=(unsigned char)(height>>8);
-
-	//BEGIN of format writing
-	//Write ColorTable
-	for (a=0;a<16;a++) {
-		b=(char)(a*3);
-		c=(char)(a<<2);
-		header[54+c]=(unsigned char)(img.pal[b+2]*4);  //Red
-		header[55+c]=(unsigned char)(img.pal[b+1]*4);  //Green
-		header[56+c]=(unsigned char)(img.pal[b]*4);    //Blue
-	}
-	//Write header
-	fwrite(header,118,1,bitmap);
-	//Write data
-	img.width=(img.width+1)>>1;
-	while (img.height--) {
-		fwrite(img.pix+img.height*img.width,img.width,1,bitmap);
-		fwrite(junk,(-img.width)&3,1,bitmap);
-	}
-	//END of format writing
-
-	fclose(bitmap);
-	return 1;
-}
-
-
-char mReadBitMap(tImage* img,unsigned char* data, int size) {
-	int ok;
-	unsigned short int width;
-	unsigned short int height;
-	int width2;
-	int x=0;
-
-	//Validate if there is header and if it starts in BM
-	ok    = size>118;
-	ok=ok&& data[0]=='B' && data[1]=='M';
-
-	//Read sizes from header
-	width=(unsigned short)(data[18]+(data[19]<<8));
-	height=(unsigned short)(data[22]+(data[23]<<8));
-
-	//Save sizes into image
-	(*img).width=width;            //width in pixels
-	(*img).height=height;
-	(*img).size=height*width;      //total of pixels
-
-	//Calculate serialized widths
-	width=(unsigned short)((width+1)>>1); //raw serialized width
-	width2=width+((-width)&3);            //bmp serialized width
-
-	//Validate image and file size; get memory to allocate the image
-	ok=ok&& ((img->height*width2)==(size-118));
-	ok=ok&& (	((*img).pix=getMemory((*img).size/2)) != NULL	);
-
-	//if validations==wrong
-	if (!ok) {
-		if ((*img).pix!=NULL) free((*img).pix);
-		return 0; //this is not a valid bmp file format or memory too low
-	}
-
-	//Serialize bitmap-->raw array
-	while (height--) memcpy((*img).pix+(x++)*width,data+118+height*width2,width);
-
-	return 1;
-}
diff --git a/PR/src/lib/formats/bmp.c b/PR/src/lib/formats/bmp.c
new file mode 100644
index 0000000..7293ab4
--- /dev/null
+++ b/PR/src/lib/formats/bmp.c
@@ -0,0 +1,210 @@
+/*  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
+*/
+
+/*
+bmp.c: Princed Resources : BMP file support
+\xaf\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2003-Oct-23)
+  Version: 1.10 (2004-Feb-17)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "pr.h"
+#include "bmp.h"
+#include "disk.h"
+#include "memory.h"
+#include "dat.h"
+
+int mFormatExportBmp(const unsigned char* data, const char *vFileext,unsigned long int size,tImage image,int optionflag, const char* backupExtension) {
+	/*
+		This function will expand the data into an image structure,
+		then the bitmap structure will be saved to disk
+
+		Note: The old structure is passed by paremeters in order to
+		      keep the right palette.
+	*/
+	int result;
+
+	/* Expand graphic and check results */
+	result=mExpandGraphic(data,&image,size);
+	if ((result==COMPRESS_RESULT_WARNING)&&hasFlag(verbose_flag))
+		printf (PR_TEXT_EXPORT_BMP_WARN);
+	if (result==COMPRESS_RESULT_FATAL) return 0;
+
+	/* Write bitmap */
+	mWriteBitMap(image,vFileext,optionflag,backupExtension);
+
+	/* free bitmap */
+	free(image.pix);
+	return 1;
+}
+
+
+int mFormatImportBmp(unsigned char* data, tResource *res) {
+	int size;
+	tImage img;
+	unsigned char aux[32700];
+
+	if (!mReadBitMap(&img,data,res->size)) return 0;
+	mCompressGraphic(aux,&img,&size);
+	free(img.pix);
+	mWriteSetFileInDatFile(aux,size);
+	res->size=(unsigned short)size; /* this was a bug (added to debug ;) ironic, don't you think? */
+	/* Note: after the debugging we realized this line was missing so this is not a bug anymore*/
+	return 1;
+}
+
+int mWriteBitMap(tImage img,const char* vFile,int optionflag,const char* backupExtension) {
+
+	/* declare variables */
+	int a;
+	int x;
+//	unsigned char carry;
+	unsigned char* b;
+	unsigned char* g;
+	unsigned char* r;
+	unsigned short int bits;
+	unsigned short int planes=1;
+	unsigned long int colours;
+	unsigned long int extra=1000;
+	unsigned long int filesize;
+	unsigned long int headerSize;
+	unsigned long int height;
+	unsigned long int offset;
+	unsigned long int width;
+	const unsigned long int zero=0;
+	char lineSerialization;
+	FILE* bitmap;
+
+	/* open file */
+	if (!writeOpen(vFile,&bitmap,optionflag)) return 0;
+
+	/* initialize variables */
+	width=img.width;
+	height=img.height;
+	bits=1<<getCarry(img.type);
+	colours=1<<bits;
+	headerSize=40;
+	offset=54+(colours<<2);
+	r=(g=(b=(unsigned char*)&extra)+1)+1;
+	lineSerialization=(-img.widthInBytes)&3;
+	filesize=offset+(img.widthInBytes+lineSerialization)*height;
+
+	/* Write header */
+	fwrite("BM"       ,2,1,bitmap);    /* Magic identifier            */
+	fwrite(&filesize  ,4,1,bitmap);    /* File size in bytes          */
+	fwrite(&zero      ,4,1,bitmap);    /* reserved                    */
+	fwrite(&offset    ,4,1,bitmap);    /* Offset to image data, bytes */
+	fwrite(&headerSize,4,1,bitmap);    /* Header size in bytes        */
+	fwrite(&width     ,4,1,bitmap);    /* Width of image              */
+	fwrite(&height    ,4,1,bitmap);    /* Height of image             */
+	fwrite(&planes    ,2,1,bitmap);    /* Number of colour planes     */
+	fwrite(&bits      ,2,1,bitmap);    /* Bits per pixel              */
+	fwrite(&zero      ,4,1,bitmap);    /* Compression type (0=none)   */
+	fwrite(&zero      ,4,1,bitmap);    /* Image size in bytes         */
+	fwrite(&extra     ,4,1,bitmap);    /* Pixels per meter x          */
+	fwrite(&extra     ,4,1,bitmap);    /* Pixels per meter y          */
+	fwrite(&colours   ,4,1,bitmap);    /* Number of colours           */
+	fwrite(&zero      ,4,1,bitmap);    /* Important colours           */
+
+	/* Write ColorTable */
+	if (colours==2) {
+		/* Black & White */
+		fwrite(FORMATS_BMP_PALETTE_BW,8,1,bitmap);    /* 24-bit palette: #000000, #FFFFFF */
+	} else {
+		/* Colours */
+		for (a=0,x=0;a<colours;a++) {
+			*r=(unsigned char)(img.pal[x++]<<2);  /* Red   */
+			*g=(unsigned char)(img.pal[x++]<<2);  /* Green */
+			*b=(unsigned char)(img.pal[x++]<<2);  /* Blue  */
+			fwrite(&extra,4,1,bitmap);    /* 24-bit Color value */
+		}
+	}
+
+	/* Write data */
+	while (img.height--) {
+		fwrite(img.pix+img.height*img.widthInBytes,img.widthInBytes,1,bitmap);
+		fwrite(&zero,lineSerialization,1,bitmap);
+	}
+
+	writeCloseOk(bitmap,optionflag,backupExtension);
+	return 1;
+}
+
+int mReadBitMap(tImage* image,unsigned char* data, int size) {
+	char lineSerialization;
+//	int image->widthInBytes;
+	int ok;
+	int serializedWidth;
+	int x=0;
+	unsigned char carry;
+	unsigned long int colours;
+	unsigned long int filesize;
+	unsigned long int offset;
+	unsigned short int bits;
+	unsigned short int height;
+	unsigned short int width;
+
+	/* Validate if there is header and if it starts in BM */
+	ok    = size>50;
+	ok=ok&& data[0]=='B' && data[1]=='M';
+	/* Read sizes from header */
+	width=(unsigned short)(data[18]+(data[19]<<8));
+	height=(unsigned short)(data[22]+(data[23]<<8));
+	bits=(unsigned short)(data[28]);
+
+	/* Save sizes into image */
+	image->width=width;            /* width in pixels */
+	image->height=height;
+
+	/* Calculate serialized widths */
+	carry=(bits==1)?0:2;
+	image->type=(bits==1)?0:0xB0;
+	colours=1<<bits;
+	offset=54+(colours<<2);
+	width=(width+1)>>1;
+	image->widthInBytes=(width+(0x07>>(1+carry)))>>(2-carry); /* this is an optimization of /(8/bits) : image->widthInBytes=imageWidthInPixels*bitsPerPixel/(8 bits/byte) */
+	lineSerialization=(-image->widthInBytes)&3;
+	serializedWidth=image->widthInBytes+lineSerialization;
+	filesize=offset+serializedWidth*height;
+
+	/* Validate image and file size; get memory to allocate the image */
+	ok=ok&& (filesize==size);
+	ok=ok&& (	(image->pix=getMemory(height*image->widthInBytes)) != NULL	);
+	/* if validations==wrong */
+	if (!ok) {
+		freeAllocation(image->pix);
+		return 0; /* this is not a valid bmp file format or memory too low */
+	}
+
+	/* Serialize bitmap-->raw array */
+	while (height--) memcpy(image->pix+(x++)*image->widthInBytes,data+offset+height*serializedWidth,image->widthInBytes);
+
+	return 1;
+}
diff --git a/PR/src/lib/formats/Attic/mid.c b/PR/src/lib/formats/mid.c
similarity index 67%
rename from PR/src/lib/formats/Attic/mid.c
rename to PR/src/lib/formats/mid.c
index 1eb1bcf..5e895f4 100644
--- a/PR/src/lib/formats/Attic/mid.c
+++ b/PR/src/lib/formats/mid.c
@@ -31,26 +31,27 @@ mid.c: Princed Resources : MIDI files support
   DO NOT remove this copyright notice
 */
 
-//Includes
+/* Includes */
 #include "mid.h"
 #include "disk.h"
-#include "compile.h"
+#include "pr.h"
+#include "dat.h"
 #include "memory.h"
 #include <string.h>
 
-char mFormatExtractMid(unsigned char* data, char *vFileext,unsigned long int size) {
-	//Mid files are saved as raw except you must ignore checksum & sound type
-	return writeData(data,2,vFileext,size);
+int mFormatExportMid(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension) {
+	/* Mid files are saved as raw except you must ignore checksum & sound type */
+	return writeData(data,2,vFileext,size,optionflag,backupExtension);
 }
 
-char mFormatCompileMid(unsigned char* data, FILE* fp, tResource *res) {
+int mFormatImportMid(unsigned char* data, tResource *res) {
 	unsigned char* file;
 
-	file=getMemory((*res).size);
-	file[0]=(unsigned char)((res->type==4)?2:0); //Now should be 0x02 //First character must be a 0x01 (wav type in dat)
-	memcpy(file+1,data,(*res).size);
-	(*res).size++;
-	mAddFileToDatFile(fp,file,(*res).size);
+	file=getMemory(res->size+1);
+	file[0]=(unsigned char)((res->type==4)?2:0); /* Now should be 0x02: First character must be a 0x01 (wav type in dat) */
+	memcpy(file+1,data,res->size);
+	res->size++;
+	mWriteSetFileInDatFile(file,res->size);
 	free(file);
 	return 1;
 }
diff --git a/PR/src/lib/formats/Attic/pal.c b/PR/src/lib/formats/pal.c
similarity index 56%
rename from PR/src/lib/formats/Attic/pal.c
rename to PR/src/lib/formats/pal.c
index 70ad2f4..382d033 100644
--- a/PR/src/lib/formats/Attic/pal.c
+++ b/PR/src/lib/formats/pal.c
@@ -31,14 +31,16 @@ pal.c: Princed Resources : JASC PAL files support
   DO NOT remove this copyright notice
 */
 
-//Includes
+/* Includes */
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include "pal.h"
+#include "pr.h" /* for MAX_FILENAME_SIZE */
 #include "memory.h"
 #include "disk.h"
 #include "resources.h"
+#include "dat.h"
 
 /***************************************************************\
 |                 Jasc Palette handling functions               |
@@ -46,82 +48,96 @@ pal.c: Princed Resources : JASC PAL files support
 
 static const char* enter="\r\n";
 
-//Public functions
-char mFormatExtractPal(unsigned char** data, char *vFileext,unsigned long int size) {
-	//Convert palette from POP format to JASC format
-	mExportPalette(data,&size);
-	//save JASC palette
-	return writeData(*data,0,vFileext,size);
+/* Public functions */
+int mFormatExportPal(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension ) {
+	unsigned char* pal=getMemory(240);
+	unsigned char* aux=getMemory(MAX_FILENAME_SIZE);
+	int i;
+
+	/* Export extra palette information */
+	sprintf(aux,"%s.more",vFileext);
+	writeData(data,1,aux,size,optionflag,backupExtension);
+
+	/* Convert palette from POP format to JASC format */
+	strcpy((char*)pal,PAL_HEADER);
+	for (i=0;i<16;i++) {
+		strcpy((char*)aux,(char*)pal);
+		sprintf((char*)pal,"%s%d %d %d%s",
+			aux,
+			data[(i*3)+5]<<2,
+			data[(i*3)+6]<<2,
+			data[(i*3)+7]<<2,
+			enter
+		);
+	}
+	for (i=0;pal[i];i++);
+	size=i-1;
+
+	/* save JASC palette */
+	i=writeData(pal,0,vFileext,size,optionflag,backupExtension);
+
+	free(pal);
+	free(aux);
+	return i;
 }
 
-char mImportPalette(unsigned char** data, unsigned short *size) {
+int mFormatImportPal(unsigned char* data, tResource *res,const char* vFile) {
 
-	//declare variables
-	unsigned char palh[]=PAL_HEADER;
-	unsigned char pals[]=PAL_SAMPLE;
+	/* declare variables */
+	unsigned char* pals;
+	unsigned char* pals1;
+	unsigned char  pals2[]=PAL_SAMPLE;
+	unsigned char  palh []=PAL_HEADER;
 	unsigned char* pal;
 	unsigned char* pal2;
 	char* data2;
-	//unsigned short int parsed;
+	char aux[MAX_FILENAME_SIZE];
 	unsigned int r;
 	unsigned int g;
 	unsigned int b;
 	int i=0;
 	int k=16;
+	int sample1;
+
+	/* check size */
+	if ((res->size)<130) return 0;
+
+	/* verify jasc pal header */
+	while (palh[i]==(data)[i++]);
+	if (i!=sizeof(palh)) return 0; /* palette differs with headers */
+
+	/* Read sample */
+	sprintf(aux,"%s.more",vFile);
+	sample1=mLoadFileArray(aux,&pals1);
+	if (sample1==100) {
+		pals=pals1;
+	} else {
+		pals=pals2;
+	}
 
-	//check size
-	if (*size<130) return 0;
-
-	//verify jasc pal header
-	while (palh[i]==(*data)[i++]);
-	if (i!=sizeof(palh)) return 0; //palette differs with headers
-
-	//Allocate palette
+	/* Allocate palette */
 	pal=getMemory(100);
 
-	//set palette with sample
+	/* set palette with sample */
 	memcpy(pal,pals,100);
 	pal2=pal+4;
+	if (sample1) free(pals1);
 
-	//set current values
-	data2=strtok((char*)(*data)+sizeof(palh)-1,enter);
+	/* set current values */
+	data2=strtok((char*)(data)+sizeof(palh)-1,enter);
 	while (k--) {
-		printf("%s -",data2);
 		if (!sscanf(data2,"%d %d %d",&r,&g,&b)) return 0;
-		/* Those lines mean a loss of data (palettes colors are saved in the nearest multiple of 4) */
+		/* Those lines mean a loss of data (palette colors are saved in the nearest multiple of 4) */
 		*(pal2++)=(unsigned char)((r+2)>>2);
 		*(pal2++)=(unsigned char)((g+2)>>2);
 		*(pal2++)=(unsigned char)((b+2)>>2);
-		//printf("-> %03d %03d %03d \n",r,g,b);
 		data2=strtok(NULL,enter);
 	}
 
-	//free old data and set new
-	free(*data);
-	*data=pal;
-	*size=100;
-	return 1;
-}
-
-void mExportPalette(unsigned char** data, unsigned long int *size) {
-	unsigned char* pal=getMemory(240);
-	unsigned char* aux=getMemory(240);
-	unsigned char i;
+	/* save and free palette */
+	mWriteSetFileInDatFile(pal,res->size=100);
+	free(pal);
 
-	strcpy((char*)pal,PAL_HEADER);
-
-	for (i=0;i<16;i++) {
-		strcpy((char*)aux,(char*)pal);
-		sprintf((char*)pal,"%s%d %d %d%s",aux,(*data)[(i*3)+5]<<2,(*data)[(i*3)+6]<<2,(*data)[(i*3)+7]<<2,enter);
-	}
-	for (i=0;pal[i];i++);
-	free(*data);
-	free(aux);
-	(*data)=pal;
-	*size=i-1;
+	return 1;
 }
 
-//TODO: use a macro
-void mLoadPalette(unsigned char* array,tImage *image) {
-	memcpy(image->pal,array+5,16*3);
-}
diff --git a/PR/src/lib/formats/Attic/plv.c b/PR/src/lib/formats/plv.c
similarity index 52%
rename from PR/src/lib/formats/Attic/plv.c
rename to PR/src/lib/formats/plv.c
index 1503e28..08fdac6 100644
--- a/PR/src/lib/formats/Attic/plv.c
+++ b/PR/src/lib/formats/plv.c
@@ -40,31 +40,34 @@ plv.c: Princed Resources : PLV prince level files support
   DO NOT remove this copyright notice
 */
 
-//Includes
+/* Includes */
 #include "plv.h"
 #include "disk.h"
-#include "compile.h"
+#include "dat.h"
 #include "memory.h"
 #include <string.h>
 #include <time.h>
 
-//Private function to get the currect date/time
+/* Private function to get the currect date/time */
 char* getDate() {
-	//Code taken from RDR 1.4.1a coded by Enrique Calot
-	//TODO: define date string format for plv
+	/* Code taken from RDR 1.4.1a coded by Enrique Calot */
 
-	//Declare variables
+	/* Declare variables */
+#ifdef PLV_FULL_FORMAT
 	static char weeks   []   = DATE_WEEKDAYS;
 	static char months  []   = DATE_MONTHS;
+#endif
 	static char formated [37];
 	time_t      datet;
 	struct tm*  date;
 
+	/* get GMT time from the system clock */
 	time(&datet);
-	date   = gmtime(&datet);
+	date=gmtime(&datet);
 
-	//Format: "Tue, 26 Nov 2002 22:16:39 GMT"
-	sprintf(formated,"%s, %d %s %.4d %.2d:%.2d:%.2d GMT",
+#ifdef PLV_FULL_FORMAT
+	/* Format: "Tue, 26 Nov 2002 22:16:39" */
+	sprintf(formated,"%s, %d %s %.4d %.2d:%.2d:%.2d",
 		weeks+4*(date->tm_wday),
 		date->tm_mday,
 		months+4*(date->tm_mon),
@@ -73,48 +76,72 @@ char* getDate() {
 		date->tm_min,
 		date->tm_sec
 	);
+#else
+	/* Format: "2002-11-26 22:16:39" */
+	sprintf(formated,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d",
+		date->tm_year+1900,
+		date->tm_mon+1,
+		date->tm_mday,
+		date->tm_hour,
+		date->tm_min,
+		date->tm_sec
+	);
+#endif
 	return formated;
 }
 
+int mFormatExportPlv(const unsigned char* data, const char *vFileext,unsigned long int size,unsigned char level, const char* filename, const char* desc, const char* title, const char* vDatAuthor,int optionflag,const char* backupExtension) {
+	/* Plv files are saved as raw except you must ignore the checksum and add the plv constant file header */
 
-char mFormatExtractPlv(unsigned char* data, const char *vFileext,unsigned long int size,unsigned char level, const char* filename, const char* desc, const char* title, const char* vDatAuthor) {
-	//Plv files are saved as raw except you must ignore the checksum and add the plv constant file header
-
-	//Variables
+	/* Variables */
 	FILE* target;
 	int ok;
 	unsigned char sizeOfNow;
 	char* now;
 	const char* nullString="";
-	static const char* author="PR user";
+	static const char* author=PLV_DEFAULT_AUTHOR;
+	unsigned long int block2size;
+	const unsigned long int numberOfFieldPairs=8;
 
-	//Get current time
+	/* Get current time */
 	now=getDate();
 	sizeOfNow=(unsigned char)(strlen(now)+1);
 
-	//Ignore checksum
-	size--;
+	/* Ignore checksum */
+	/* size--; */
 
-	//Validate null strings when no description is set
+	/* Validate null strings when no description is set */
 	if (desc==NULL) desc=nullString;
 	if (title==NULL) title=nullString;
 	if (vDatAuthor==NULL) vDatAuthor=author;
 
 	/* Writing file */
 
-	//Safe open for writing mode
-	ok=writeOpen(vFileext,&target);
+	/* Safe open for writing mode */
+	ok=writeOpen(vFileext,&target,optionflag);
 
-	//Write headers
+	/* Write headers */
 	ok=ok&&fwrite(PLV_HEADER_A,PLV_HEADER_A_SIZE,1,target);
 	ok=ok&&fwrite(&level,1,1,target);
-	ok=ok&&fwrite(PLV_HEADER_B,PLV_HEADER_B_SIZE,1,target);
-	ok=ok&&fwrite(&size,1,sizeof(size),target);
+	ok=ok&&fwrite(&numberOfFieldPairs,4,1,target);
+	ok=ok&&fwrite(&size,1,4,target);
+
+	/* Write block 1: raw data without ignoring checksum */
+	ok=ok&&fwrite(data,size,1,target);
+
+	/* Write footers */
+	block2size=(
+		sizeof(PLV_FOOT_EDITOR)+	strlen(vDatAuthor)+1+
+		sizeof(PLV_FOOT_TITLE)+	strlen(title)+1+
+		sizeof(PLV_FOOT_DESC)+	strlen(desc)+1+
+		sizeof(PLV_FOOT_TCREAT)+	sizeOfNow+
+		sizeof(PLV_FOOT_TMODIF)+	sizeOfNow+
+		sizeof(PLV_FOOT_ORIG_FILE)+	strlen(filename)+1
+	);
 
-	//Write raw data ignoring checksum
-	ok=ok&&fwrite(data+1,size,1,target);
+	ok=ok&&fwrite(&block2size,4,1,target);
 
-	//Write footers
+	/* Write block 2 */
 	ok=ok&&fwrite(PLV_FOOT_EDITOR,sizeof(PLV_FOOT_EDITOR),1,target);
 	ok=ok&&fwrite(vDatAuthor,strlen(vDatAuthor)+1,1,target);
 	ok=ok&&fwrite(PLV_FOOT_TITLE,sizeof(PLV_FOOT_TITLE),1,target);
@@ -128,19 +155,36 @@ char mFormatExtractPlv(unsigned char* data, const char *vFileext,unsigned long i
 	ok=ok&&fwrite(PLV_FOOT_ORIG_FILE,sizeof(PLV_FOOT_ORIG_FILE),1,target);
 	ok=ok&&fwrite(filename,strlen(filename)+1,1,target);
 
-	//Close file and return
-	ok=ok&&(!fclose(target));
-	return (char)ok;
+	/* Close file and return */
+	ok=ok&&(!writeCloseOk(target,optionflag,backupExtension));
+	return ok;
 }
 
-char mFormatCompilePlv(unsigned char* data, FILE* fp, tResource *res) {
+int mFormatImportPlv(unsigned char* data, tResource *res) {
+	/* declare variables */
+	unsigned char* pos;
+	unsigned long int oldSize=res->size;
+
+	/* integrity check 1 */
+	if (oldSize<=PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE) return 0;
+	/* if (memcmp(data,PLV_HEADER_A,PLV_HEADER_A_SIZE)) return 0; */
+
+	/* jump to size */
+	pos=data+PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE;
+	/* read size and jump to data */
+	res->size=*(pos++);
+	res->size+=(*(pos++))<<8;
+	res->size+=(*(pos++))<<16;
+	res->size+=(*(pos++))<<24;
+
+	/* integrity check 2 */
+	if (oldSize<=PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE+res->size) return 0;
+
+	/* verify checksum */
+	if (!checkSum(pos,res->size)) return 0;
 
-	unsigned long int size;
-	//This is ignoring all kind of verifications and assuming (res->size)>PLV_HEADER_SIZE !!!
-	//TODO: must verify the plv format version, if not 1, then PR is too old!
+	/* save data */
+	mWriteSetFileInDatFileIgnoreChecksum(pos,res->size--);
 
-	//memcpy(&size,data+PLV_HEADER_SIZE_OFFSET,4); //Only when longs are 4 bytes
-//	mAddFileToDatFile(fp,data+PLV_HEADER_A_SIZE+PLV_HEADER_B_SIZE+1+4,size);
-//	free(file);
 	return 1;
 }
diff --git a/PR/src/lib/formats/Attic/wav.c b/PR/src/lib/formats/wav.c
similarity index 77%
rename from PR/src/lib/formats/Attic/wav.c
rename to PR/src/lib/formats/wav.c
index 01ab224..d5ec6fb 100644
--- a/PR/src/lib/formats/Attic/wav.c
+++ b/PR/src/lib/formats/wav.c
@@ -31,18 +31,19 @@ wav.c: Princed Resources : WAV files support
   DO NOT remove this copyright notice
 */
 
-//Includes
+/* Includes */
+#include "pr.h"
 #include "wav.h"
-#include "compile.h"
+#include "dat.h"
 #include "disk.h"
 
-int mFormatExtractWav(unsigned char* data, char *vFileext,unsigned long int size) {
+int mFormatExportWav(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension) {
 	FILE*         target;
 	int ok;
 	unsigned char wav[]=WAVE_HEADER;
 
 	size-=2;
-	ok=writeOpen(vFileext,&target);
+	ok=writeOpen(vFileext,&target,optionflag);
 
 	wav[4]=(unsigned char)((size+36)&0xFF);
 	wav[5]=(unsigned char)(((size+36)>>8)&0xFF);
@@ -55,20 +56,20 @@ int mFormatExtractWav(unsigned char* data, char *vFileext,unsigned long int size
 	wav[43]=(unsigned char)(((size)>>24)&0xFF);
 
 	ok=ok&&fwrite(wav,sizeof(wav),1,target);
-	ok=ok&&fwrite(data+2,size-2,1,target);
-	ok=ok&&(!fclose(target));
+	ok=ok&&fwrite(data+2,size,1,target);
+	ok=ok&&(!writeCloseOk(target,optionflag,backupExtension));
 
 	return ok;
 }
 
-int mFormatCompileWav(unsigned char* data, FILE* fp, tResource *res) {
+int mFormatImportWav(unsigned char* data, tResource *res) {
 	unsigned char wav[]=WAVE_HEADER;
 	int i=sizeof(wav);
 
-	if ((*res).size<=i) return 0;
+	if (res->size<=i) return 0;
 	res->size-=(--i);
 	while ((i==4||i==5||i==6||i==7||i==40||i==41||i==42||i==43||(data[i]==wav[i]))&&(i--));
-	data[sizeof(wav)-1]=1; //First character must be a 0x01 (wav type in dat)
-	if (i==-1) mAddFileToDatFile(fp,data+sizeof(wav)-1,(*res).size);
+	data[sizeof(wav)-1]=1; /* First character must be a 0x01 (wav type in dat) */
+	if (i==-1) mWriteSetFileInDatFile(data+sizeof(wav)-1,res->size);
 	return 1;
 }
diff --git a/PR/src/ports/getopt.c b/PR/src/ports/getopt.c
index 8cefdfc..4335e32 100644
--- a/PR/src/ports/getopt.c
+++ b/PR/src/ports/getopt.c
@@ -288,7 +288,7 @@ _getopt_initialize (optstring)
 
   nextchar = NULL;
 
-  posixly_correct = "permute";//getenv ("POSIXLY_CORRECT");
+  posixly_correct = "permute";/* getenv ("POSIXLY_CORRECT"); */
 
   /* Determine how to handle the ordering of options and nonoptions.  */
 
diff --git a/PR/src/ports/winfiles/pr.exe b/PR/src/ports/winfiles/pr.exe
index 31be3a0..c081677 100755
Binary files a/PR/src/ports/winfiles/pr.exe and b/PR/src/ports/winfiles/pr.exe differ
diff --git a/PR/src/pr.dsp b/PR/src/pr.dsp
index 2f39aa3..ec88ec0 100644
--- a/PR/src/pr.dsp
+++ b/PR/src/pr.dsp
@@ -1,596 +1,650 @@
-# Microsoft Developer Studio Project File - Name="tasks" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=tasks - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "pr.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "pr.mak" CFG="tasks - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "tasks - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "tasks - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "tasks - Win32 Dynamic Link Library" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W2 /GX /O2 /I "include\\" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /c
-# ADD BASE RSC /l 0x2c0a /d "NDEBUG"
-# ADD RSC /l 0x2c0a /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"bin/pr.exe"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=del winbins\pr.exe	copy bin\pr.exe winbins\pr.exe >nul	scripts\upx.exe winbins\pr.exe
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /I "include\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
-# ADD BASE RSC /l 0x2c0a /d "_DEBUG"
-# ADD RSC /l 0x2c0a /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "tasks___Win32_Dynamic_Link_Library"
-# PROP BASE Intermediate_Dir "tasks___Win32_Dynamic_Link_Library"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Dll"
-# PROP Intermediate_Dir "Dll"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /I "include\\" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /c
-# ADD CPP /nologo /W3 /GX /O2 /I "include\\" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DLL" /FR /YX /c
-# ADD BASE RSC /l 0x2c0a /d "NDEBUG"
-# ADD RSC /l 0x2c0a /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"bin/pr.exe"
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /dll /machine:I386 /def:"winbins/pr.def" /out:"winbins/pr.dll" /implib:"winbins/pr.lib"
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=scripts\upx.exe winbins\pr.dll
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "tasks - Win32 Release"
-# Name "tasks - Win32 Debug"
-# Name "tasks - Win32 Dynamic Link Library"
-# Begin Group "src"
-
-# PROP Default_Filter ""
-# Begin Group "formats"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\formats\bmp.c
-DEP_CPP_BMP_C=\
-	".\include\bmp.h"\
-	".\include\compile.h"\
-	".\include\compress.h"\
-	".\include\disk.h"\
-	".\include\resources.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\formats\mid.c
-DEP_CPP_MID_C=\
-	".\include\compile.h"\
-	".\include\disk.h"\
-	".\include\mid.h"\
-	".\include\resources.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\formats\pal.c
-DEP_CPP_PAL_C=\
-	".\include\compress.h"\
-	".\include\disk.h"\
-	".\include\pal.h"\
-	".\include\resources.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\formats\plv.c
-DEP_CPP_PLV_C=\
-	".\include\compile.h"\
-	".\include\disk.h"\
-	".\include\plv.h"\
-	".\include\resources.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\formats\wav.c
-DEP_CPP_WAV_C=\
-	".\include\compile.h"\
-	".\include\resources.h"\
-	".\include\wav.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# End Group
-# Begin Group "ports"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\ports\dirent.c
-DEP_CPP_DIREN=\
-	".\include\direntwin.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ports\getopt.c
-DEP_CPP_GETOP=\
-	".\include\getopt.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\ports\getopt1.c
-DEP_CPP_GETOPT=\
-	".\include\getopt.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\compile.c
-DEP_CPP_COMPI=\
-	".\include\bmp.h"\
-	".\include\compile.h"\
-	".\include\compress.h"\
-	".\include\disk.h"\
-	".\include\mid.h"\
-	".\include\pal.h"\
-	".\include\plv.h"\
-	".\include\pr.h"\
-	".\include\resources.h"\
-	".\include\wav.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\compress.c
-DEP_CPP_COMPR=\
-	".\include\compress.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\disk.c
-DEP_CPP_DISK_=\
-	".\include\direntwin.h"\
-	".\include\disk.h"\
-	".\include\pr.h"\
-	".\include\xml.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\extract.c
-DEP_CPP_EXTRA=\
-	".\include\bmp.h"\
-	".\include\compress.h"\
-	".\include\disk.h"\
-	".\include\extract.h"\
-	".\include\mid.h"\
-	".\include\pal.h"\
-	".\include\plv.h"\
-	".\include\pr.h"\
-	".\include\resources.h"\
-	".\include\wav.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory.c
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\pr.c
-DEP_CPP_PR_C18=\
-	".\include\compile.h"\
-	".\include\compress.h"\
-	".\include\disk.h"\
-	".\include\extract.h"\
-	".\include\getopt.h"\
-	".\include\pr.h"\
-	".\include\resources.h"\
-	".\include\tasks.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\resources.c
-DEP_CPP_RESOU=\
-	".\include\compress.h"\
-	".\include\disk.h"\
-	".\include\pr.h"\
-	".\include\resources.h"\
-	".\include\xml.h"\
-	".\include\xmlsearch.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\tasks.c
-DEP_CPP_TASKS=\
-	".\include\resources.h"\
-	".\include\tasks.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\xml.c
-DEP_CPP_XML_C=\
-	".\include\disk.h"\
-	".\include\pr.h"\
-	".\include\xml.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\xmlsearch.c
-DEP_CPP_XMLSE=\
-	".\include\resources.h"\
-	".\include\xml.h"\
-	".\include\xmlsearch.h"\
-	
-
-!IF  "$(CFG)" == "tasks - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
-
-!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
-
-!ENDIF 
-
-# End Source File
-# End Group
-# Begin Group "include"
-
-# PROP Default_Filter ""
-# Begin Group "include formats"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\include\bmp.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\mid.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\pal.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\plv.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\wav.h
-# End Source File
-# End Group
-# Begin Group "include ports"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\include\direntwin.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\getopt.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\include\compile.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\compress.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\disk.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\extract.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\memory.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\pr.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\resources.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\tasks.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\xml.h
-# End Source File
-# Begin Source File
-
-SOURCE=include\xmlsearch.h
-# End Source File
-# End Group
-# Begin Group "Text Files"
-
-# PROP Default_Filter "*.txt"
-# Begin Source File
-
-SOURCE=..\changelog.txt
-# End Source File
-# Begin Source File
-
-SOURCE=..\gpl.txt
-# End Source File
-# Begin Source File
-
-SOURCE=..\readme.coders.txt
-# End Source File
-# Begin Source File
-
-SOURCE=..\readme.txt
-# End Source File
-# End Group
-# Begin Group "Other Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Makefile
-# End Source File
-# Begin Source File
-
-SOURCE=.\Makefile.lcc
-# End Source File
-# Begin Source File
-
-SOURCE=.\winbins\pr.def
-# End Source File
-# Begin Source File
-
-SOURCE=.\bin\resources.sample.xml
-# End Source File
-# Begin Source File
-
-SOURCE=.\bin\resources.xml
-# End Source File
-# End Group
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="tasks" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=tasks - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "pr.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "pr.mak" CFG="tasks - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "tasks - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "tasks - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "tasks - Win32 Dynamic Link Library" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W2 /GX /O2 /I "include\\" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /c
+# ADD BASE RSC /l 0x2c0a /d "NDEBUG"
+# ADD RSC /l 0x2c0a /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"bin/pr.exe"
+# SUBTRACT LINK32 /pdb:none
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=del winbins\pr.exe	copy bin\pr.exe winbins\pr.exe >nul	scripts\upx.exe winbins\pr.exe
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /I "include\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x2c0a /d "_DEBUG"
+# ADD RSC /l 0x2c0a /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "tasks___Win32_Dynamic_Link_Library"
+# PROP BASE Intermediate_Dir "tasks___Win32_Dynamic_Link_Library"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Dll"
+# PROP Intermediate_Dir "Dll"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /I "include\\" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /I "include\\" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DLL" /FR /YX /c
+# ADD BASE RSC /l 0x2c0a /d "NDEBUG"
+# ADD RSC /l 0x2c0a /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"bin/pr.exe"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /dll /machine:I386 /def:"winbins/pr.def" /out:"winbins/pr.dll" /implib:"winbins/pr.lib"
+# SUBTRACT LINK32 /pdb:none
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=scripts\upx.exe winbins\pr.dll
+# End Special Build Tool
+
+!ENDIF 
+
+# Begin Target
+
+# Name "tasks - Win32 Release"
+# Name "tasks - Win32 Debug"
+# Name "tasks - Win32 Dynamic Link Library"
+# Begin Group "src"
+
+# PROP Default_Filter ""
+# Begin Group "formats"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\formats\bmp.c
+DEP_CPP_BMP_C=\
+	".\include\bmp.h"\
+	".\include\compress.h"\
+	".\include\dat.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\formats\mid.c
+DEP_CPP_MID_C=\
+	".\include\dat.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\mid.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\formats\pal.c
+DEP_CPP_PAL_C=\
+	".\include\compress.h"\
+	".\include\dat.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\pal.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\formats\plv.c
+DEP_CPP_PLV_C=\
+	".\include\dat.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\plv.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\formats\wav.c
+DEP_CPP_WAV_C=\
+	".\include\dat.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\wav.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# End Group
+# Begin Group "ports"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\ports\dirent.c
+DEP_CPP_DIREN=\
+	".\include\direntwin.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\ports\getopt.c
+DEP_CPP_GETOP=\
+	".\include\getopt.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\ports\getopt1.c
+DEP_CPP_GETOPT=\
+	".\include\getopt.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\compile.c
+DEP_CPP_COMPI=\
+	".\include\bmp.h"\
+	".\include\compile.h"\
+	".\include\compress.h"\
+	".\include\dat.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\mid.h"\
+	".\include\pal.h"\
+	".\include\plv.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\wav.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\compress.c
+DEP_CPP_COMPR=\
+	".\include\compress.h"\
+	".\include\english.h"\
+	".\include\pr.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\dat.c
+DEP_CPP_DAT_C=\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\disk.c
+DEP_CPP_DISK_=\
+	".\include\direntwin.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\pr.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\extract.c
+DEP_CPP_EXTRA=\
+	".\include\bmp.h"\
+	".\include\compress.h"\
+	".\include\dat.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\extract.h"\
+	".\include\mid.h"\
+	".\include\pal.h"\
+	".\include\plv.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\wav.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\memory.c
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\pr.c
+DEP_CPP_PR_C1a=\
+	".\include\compile.h"\
+	".\include\compress.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\extract.h"\
+	".\include\getopt.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\tasks.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\resources.c
+DEP_CPP_RESOU=\
+	".\include\compress.h"\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\xmlparse.h"\
+	".\include\xmlsearch.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\tasks.c
+DEP_CPP_TASKS=\
+	".\include\dat.h"\
+	".\include\english.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\tasks.h"\
+	".\include\xmlparse.h"\
+	".\include\xmlsearch.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\xmlparse.c
+DEP_CPP_XMLPA=\
+	".\include\disk.h"\
+	".\include\english.h"\
+	".\include\pr.h"\
+	".\include\xmlparse.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\xmlsearch.c
+DEP_CPP_XMLSE=\
+	".\include\english.h"\
+	".\include\pr.h"\
+	".\include\resources.h"\
+	".\include\xmlparse.h"\
+	".\include\xmlsearch.h"\
+	
+
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# End Group
+# Begin Group "include"
+
+# PROP Default_Filter ""
+# Begin Group "include formats"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\include\bmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\mid.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\pal.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\plv.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\wav.h
+# End Source File
+# End Group
+# Begin Group "include ports"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\include\direntwin.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\getopt.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\include\compile.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\compress.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\disk.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\extract.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\memory.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\pr.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\resources.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\tasks.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\xml.h
+# End Source File
+# Begin Source File
+
+SOURCE=include\xmlsearch.h
+# End Source File
+# End Group
+# Begin Group "Text Files"
+
+# PROP Default_Filter "*.txt"
+# Begin Source File
+
+SOURCE=..\changelog.txt
+# End Source File
+# Begin Source File
+
+SOURCE=..\gpl.txt
+# End Source File
+# Begin Source File
+
+SOURCE=..\readme.coders.txt
+# End Source File
+# Begin Source File
+
+SOURCE=..\readme.txt
+# End Source File
+# End Group
+# Begin Group "Other Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Makefile
+# End Source File
+# Begin Source File
+
+SOURCE=.\Makefile.lcc
+# End Source File
+# Begin Source File
+
+SOURCE=.\bin\resources.sample.xml
+# End Source File
+# Begin Source File
+
+SOURCE=.\bin\resources.xml
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/PR/src/pr.dsw b/PR/src/pr.dsw
index 1810d75..a66b4b0 100644
--- a/PR/src/pr.dsw
+++ b/PR/src/pr.dsw
@@ -1,29 +1,29 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "pr"=.\pr.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "pr"=.\pr.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+