author | ecalot
<ecalot> 2006-02-17 03:23:23 UTC |
committer | ecalot
<ecalot> 2006-02-17 03:23:23 UTC |
parent | 06529e6950581c6a724917079d64ad5d709c8682 |
PR/src/Makefile | +7 | -2 |
PR/src/include/object.h | +46 | -0 |
PR/src/lib/actions/export.c | +4 | -55 |
PR/src/lib/object/object.c | +71 | -0 |
diff --git a/PR/src/Makefile b/PR/src/Makefile index 453e7ae..6e3edc9 100644 --- a/PR/src/Makefile +++ b/PR/src/Makefile @@ -56,11 +56,12 @@ XML = .parse.o .search.o .unknown.o .translate.o .tree.o COMPRESS = .compress.o .lzg_compress.o .lzg_uncompress.o .rle_compress.o .rle_uncompress.o .rlec_uncompress.o LAYERS = .dat.o .memory.o .list.o .reslist.o .pallist.o .disk.o .idlist.o .autodetect.o .stringformat.o .resourcematch.o .palette.o FORMAT = .bmp.o .mid.o .pal.o .wav.o .plv.o +OBJECT = .object.o CONSOLE = .main.o .filedir.o MAIN = .pr.o -EXEOBJ = $(MAIN) $(XML) $(COMPRESS) $(ACTIONS) $(LAYERS) $(FORMAT) $(PORTS) $(CONSOLE) -LIBOBJ = $(MAIN) $(XML) $(COMPRESS) $(ACTIONS) $(LAYERS) $(FORMAT) $(PORTS) +EXEOBJ = $(MAIN) $(XML) $(COMPRESS) $(ACTIONS) $(LAYERS) $(OBJECT) $(FORMAT) $(PORTS) $(CONSOLE) +LIBOBJ = $(MAIN) $(XML) $(COMPRESS) $(ACTIONS) $(LAYERS) $(OBJECT) $(FORMAT) $(PORTS) EXEFILE = bin/pr XMLFILE = bin/resources.xml @@ -157,6 +158,10 @@ $(XMLFILE): xml/resources.xml $(INFO) Compiling palette list module... $(CC) $(OPTIONS) -c lib/layers/pallist.c -o $@ +.object.o: lib/object/main.c include/object.h + $(INFO) Compiling main item class... + $(CC) $(OPTIONS) -c lib/object/main.c -o $@ + .compress.o: lib/compression/main.c include/compress.h include/disk.h include/memory.h $(INFO) Compiling main compression library... $(CC) $(OPTIONS) -c lib/compression/main.c -o $@ diff --git a/PR/src/include/object.h b/PR/src/include/object.h new file mode 100644 index 0000000..208ffb4 --- /dev/null +++ b/PR/src/include/object.h @@ -0,0 +1,46 @@ +/* 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 +*/ + +/* +object.h: Princed Resources : Main item class types and prototypes +\xaf\xaf\xaf\xaf\xaf\xaf + Copyright 2006 Princed Development Team + Created: 16 Feb 2006 + + Author: Enrique Calot <ecalot.cod@princed.com.ar> + + Note: + DO NOT remove this copyright notice +*/ + +#ifndef _OBJECT_H_ +#define _OBJECT_H_ + +#include "reslist.h" +#include "common.h" + +typedef struct { + tResourceType type; + void* obj; +}tObject; + +tObject getObject(tResource* r, int* error); + +#endif diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c index d9485d5..147420c 100644 --- a/PR/src/lib/actions/export.c +++ b/PR/src/lib/actions/export.c @@ -44,9 +44,10 @@ export.c: Princed Resources : DAT Extractor #include "disk.h" #include "idlist.h" #include "memory.h" +#include "object.h" +#include "palette.h" #include "pallist.h" #include "unknown.h" -#include "palette.h" #include "bmp.h" #include "mid.h" @@ -101,8 +102,8 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti if (isInTheItemMatchingList(res.path,res.id)) { /* If the resource was specified do the tasks */ if ((!res.type)&&(!hasFlag(raw_flag))) res.type=verifyHeader(res.data,res.size); if (!(hasFlag(unknown_flag))) { /* If unknown flag is set do nothing but generate the unknown.xml file */ + tObject o; if (hasFlag(raw_flag)) res.type=0; /* If "extract as raw" is set, type is 0 */ - /*tObject o;*/ /* get save file name (if unknown document is in the XML) */ getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,format); @@ -140,60 +141,8 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti break; } - /*o=getObject(&res,&ok);*/ + o=getObject(&res,&ok); - switch (res.type) { - case eResTypeLevel: - ok=mFormatExportPlv(res.data,vFileext,res.size,res.number,vDatFileName,res.name,res.desc,vDatAuthor,optionflag,backupExtension); - break; - case eResTypeBinary: /* Binary files */ - case eResTypeText: /* Text files */ - case eResTypeRaw: /* Raw files */ - ok=writeData(res.data,1,vFileext,res.size,optionflag,backupExtension); /* Ignore checksum */ - break; - case eResTypePop1Palette4bits: { /* save and remember palette file */ - tPaletteListItem e; - /* Remember the palette for the next images - * (because it's more probable to get all the images after its palette) */ - e.bits=readPalette(&e.pal,res.data,res.size); - applyPalette(&e.pal,&image); - bufferedPalette=res.id; - e.id=res.id; - list_insert(&paletteBuffer,(void*)&e); - /* Export the palette */ - ok=mFormatExportPal(&e.pal,e.bits,vFileext,optionflag,backupExtension); - } break; - case eResTypePcspeaker: /* save pcs file */ - case eResTypeMidi: /* save midi file */ - ok=mFormatExportMid(res.data,vFileext,res.size,optionflag,backupExtension); - break; - case eResTypeWave: /* save wav file */ - ok=mFormatExportWav(res.data,vFileext,res.size,optionflag,backupExtension); - break; - case eResTypeImage: /* save image */ - /* Palette handling */ - if (resourceListCompareId(res.palette,bufferedPalette)) { /* The palette isn't in the buffer */ - tResource otherPalette; - otherPalette.id=res.palette; - /* Read the palette and load it into memory */ - if (mReadFileInDatFileId(&otherPalette)==PR_RESULT_SUCCESS) { - /* All right, it's not so bad, I can handle it! I'll buffer the new palette */ - tPaletteListItem e; - e.bits=readPalette(&e.pal,otherPalette.data,otherPalette.size); - applyPalette(&e.pal,&image); - bufferedPalette=otherPalette.id; - e.id=res.id; - list_insert(&paletteBuffer,(void*)&e); - } /* else, that's bad, I'll have to use the previous palette, even if it is the default */ - } /* else, good, the palette is buffered */ - /* Export bitmap */ - - ok=mFormatExportBmp(res.data,vFileext,res.size,image,optionflag,backupExtension); - - break; - default: - break; - } /* Verbose information */ if (hasFlag(verbose_flag)) { if (ok) { diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c new file mode 100644 index 0000000..7fec815 --- /dev/null +++ b/PR/src/lib/object/object.c @@ -0,0 +1,71 @@ +/* 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 +*/ + +/* +main.c: Princed Resources : Main item class implementation +\xaf\xaf\xaf\xaf\xaf\xaf + Copyright 2006 Princed Development Team + Created: 16 Feb 2006 + + Author: Enrique Calot <ecalot.cod@princed.com.ar> + + Note: + DO NOT remove this copyright notice +*/ + +#include "object.h" + +tObject getObject(tResource* r, int* error) { + tObject o; + + o.type=r->type; + switch (o.type) { + case eResTypeLevel: + /*o.obj=objLevelCreate(res->data,res->size,res->number,vDatFileName,res->name,res->desc,res->datAuthor,error); */ + break; + case eResTypeBinary: /* Binary files */ + case eResTypeText: /* Text files */ + case eResTypeRaw: /* Raw files */ + /*o.obj=objBinaryCreate(res->data,res->size,error); */ + break; + case eResTypePop1Palette4bits: /* save and remember palette file */ + /*o.obj=objPalette_pop1_4bitsCreate(res->data,res->size,error); */ + break; + case eResTypePcspeaker: /* save pcs file */ + /*o.obj=objPcspeakerCreate(res->data,res->size,error); */ + break; + case eResTypeMidi: /* save midi file */ + /*o.obj=objMidiCreate(res->data,res->size,error); */ + break; + case eResTypeWave: /* save wav file */ + /*o.obj=objWaveCreate(res->data,res->size,error); */ + break; + case eResTypeImage: /* save image */ + /*o.obj=objImageCreate(res->data,res->size,res->pal,error); */ + break; + default: + break; + } + + return o; +} + + +