author | ecalot
<ecalot> 2003-10-10 05:38:39 UTC |
committer | ecalot
<ecalot> 2003-10-10 05:38:39 UTC |
parent | b30bc954452122f7590bd5cda171eb7f325269e2 |
PR/compile.bat | +2 | -0 |
PR/compile.c | +147 | -0 |
PR/compile.h | +18 | -0 |
PR/destroy.bat | +4 | -0 |
PR/doc/gpl.txt | +340 | -0 |
PR/doc/readme.coders.txt | +32 | -0 |
PR/doc/readme.txt | +211 | -0 |
PR/extract.bat | +9 | -0 |
PR/extract.c | +169 | -0 |
PR/extract.h | +31 | -0 |
PR/help.bat | +2 | -0 |
PR/levels.dat.txt | +6 | -0 |
PR/makedll.bat | +2 | -0 |
PR/memory.c | +6 | -0 |
PR/memory.h | +11 | -0 |
PR/parser.c | +136 | -0 |
PR/parser.h | +47 | -0 |
PR/pg.c | +217 | -0 |
PR/pg.h | +57 | -0 |
PR/pr.c | +214 | -0 |
PR/pr.def | +7 | -0 |
PR/pr.dll | +0 | -0 |
PR/pr.exe | +0 | -0 |
PR/pr.exp | +7 | -0 |
PR/pr.h | +27 | -0 |
PR/pr.lib | +0 | -0 |
PR/pr.obj | +0 | -0 |
PR/pr06-src-bin.zip | +0 | -0 |
PR/prunix | +0 | -0 |
PR/ps.h | +5 | -0 |
PR/realres.txt | +253 | -0 |
PR/resources.c | +299 | -0 |
PR/resources.h | +56 | -0 |
PR/resources.txt | +256 | -0 |
PR/src/addons/vb/pr.bas | +79 | -0 |
PR/src/addons/vb/samples/Text3 | +4 | -0 |
PR/src/addons/vb/samples/pr.dll | +0 | -0 |
PR/src/addons/vb/samples/prsample.exe | +0 | -0 |
PR/src/addons/vb/samples/prsample.vbp | +32 | -0 |
PR/src/addons/vb/samples/prsample.vbw | +2 | -0 |
PR/src/addons/vb/samples/prtest1.frm | +116 | -0 |
PR/src/addons/vb/samples/prvbdll.zip | +0 | -0 |
PR/src/lib/formats/Attic/bmp.c | +178 | -0 |
PR/src/lib/formats/Attic/mid.c | +0 | -0 |
PR/src/lib/formats/Attic/pal.c | +70 | -0 |
PR/src/lib/formats/Attic/wav.c | +42 | -0 |
PR/src/lib/formats/bmp.h | +18 | -0 |
PR/src/lib/formats/mid.h | +0 | -0 |
PR/src/lib/formats/pal.h | +24 | -0 |
PR/src/lib/formats/wav.h | +17 | -0 |
PR/tasks.c | +66 | -0 |
PR/tasks.h | +19 | -0 |
PR/title.dat.txt | +6 | -0 |
PR/vd.bat | +2 | -0 |
PR/vdr.bat | +3 | -0 |
PR/vdungeon.dat.txt | +6 | -0 |
PR/vp.bat | +2 | -0 |
diff --git a/PR/compile.bat b/PR/compile.bat new file mode 100755 index 0000000..2d15a2a --- /dev/null +++ b/PR/compile.bat @@ -0,0 +1,2 @@ +@echo off +pr comp\%1 -c ext \ No newline at end of file diff --git a/PR/compile.c b/PR/compile.c new file mode 100644 index 0000000..9ae666a --- /dev/null +++ b/PR/compile.c @@ -0,0 +1,147 @@ +/***************************************************************\ +| I M P L E M E N T A T I O N | +\***************************************************************/ + +#include "compile.h" + +/***************************************************************\ +| Dat compiling primitives | +\***************************************************************/ + +char mBeginDatFile(FILE* *fp,char* vFile) { + //opens a file and reserves space for the headers + *fp=fopen(vFile,"wb"); + if (*fp!=NULL) { + fseek(*fp,6,SEEK_SET); + return 1; + } else { + return 0; + } +} + +void mAddFileToDatFile(FILE* fp, char* data, int size) { + //calculates the checksum of a file + //unsigned char sndHeader[]={0,2}; + unsigned char checksum=0; + for (int k=0;k<size;k++) checksum+=data[k]; + checksum=~checksum; + + //writes the header and the midi sound + fwrite(&checksum,1,1,fp); + fwrite(data,size,1,fp); +} + +void mSetEndFile(FILE* fp,int sizeOfIndex) { + //sets the headers + short int size1,zero,size2; + fseek(fp,0,SEEK_END); + size1=ftell(fp)-(size2=sizeOfIndex); + zero=0; + fseek(fp,0,SEEK_SET); + fwrite(&size1,2,1,fp); + fwrite(&zero,2,1,fp); + fwrite(&size2,2,1,fp); + fclose(fp); +} + +int mCreateIndexInDatFile(FILE* fp, tResource* r[], char* vUpperFile) { + //Add extra text at the end of the file + int k=2; + unsigned short int tot=0; + unsigned short int junk=0; + int pos=ftell(fp); + + fwrite(&tot,2,1,fp); + for (unsigned short int i=0;i!=65535;i++) { + if (r[i]!=NULL) { + if (equals((*r[i]).file,vUpperFile)) { + //the file is in the archive, so I'll add it to the index + k+=8; + tot++; + fwrite(&i,2,1,fp); + fwrite(&((*r[i]).offset),2,1,fp); + fwrite(&junk,2,1,fp); + fwrite(&((*r[i]).size),2,1,fp); + } + } + } + fseek(fp,pos,SEEK_SET); + fwrite(&tot,2,1,fp); + return k; +} + +//Format detection function +void mAddCompiledFileToDatFile(FILE* fp,unsigned char* data, tResource *res) { + switch ((*res).type) { + case 2: //compile bitmap + mFormatCompileBmp(data,fp,res); + break; + case 3: //compile wave + mFormatCompileWav(data,fp,res); + break; + case 4: //compile midi + //send to mid + { + unsigned char* file; + file=getMemory(++(*res).size); + file[0]=(*res).type-2; + memcpy(file+1,data,(*res).size-1); + mAddFileToDatFile(fp,file,(*res).size); + free(file); + } + break; + case 6: + mImportPalette(&data,&((*res).size)); + case 1: + case 5: + default: + mAddFileToDatFile(fp,data,(*res).size); + break; + } +} + +/***************************************************************\ +| M A I N F U N C T I O N | +\***************************************************************/ + +/* + Return values: + -1 File couldn't be open for writing + 00 File succesfully compiled + positive number: number of missing files + + +*/ +int compile(char* vFiledat, char* vDirExt, tResource* r[], char opt) { + FILE* fp; + + if (!mBeginDatFile(&fp,vFiledat)) { + printf("Error opening the file.\r\n"); + return -1; + } + + char vUpperFile[200]; + char vFileext[200]; + unsigned char* data; + int ok=0; + + getUpperFolder(vUpperFile,vFiledat); + + for (unsigned short int i=0;i!=65535;i++) { + if (r[i]!=NULL) { + if (equals((*r[i]).file,vUpperFile)) { + getFileName(vFileext,vDirExt,(opt&1)?(*(r[i])).type:0,i); + //the file is in the archive, so I'll add it to the main dat body + if ((*r[i]).size=mLoadFileArray(vFileext,&data)) { + (*r[i]).offset=ftell(fp); + mAddCompiledFileToDatFile(fp,data,r[i]); + free(data); + } else { + ok++; + } + } + } + } + mSetEndFile(fp,mCreateIndexInDatFile(fp,r,vUpperFile)); + return ok; +} diff --git a/PR/compile.h b/PR/compile.h new file mode 100644 index 0000000..2ca0098 --- /dev/null +++ b/PR/compile.h @@ -0,0 +1,18 @@ +/***************************************************************\ +| I M P L E M E N T A T I O N | +\***************************************************************/ + +#ifndef _COMPILE_H_ +#define _COMPILE_H_ + +#include <stdio.h> +#include <stdlib.h> +#include "formats/wav.h" +#include "pg.h" +#include "resources.h" +#include "memory.h" +#include "parser.h" + +int compile(char* vFiledat, char* vDirExt, tResource* r[], char opt); + +#endif diff --git a/PR/destroy.bat b/PR/destroy.bat new file mode 100755 index 0000000..b1845cf --- /dev/null +++ b/PR/destroy.bat @@ -0,0 +1,4 @@ +@echo off +pr . -t +deltree /Y ext +mkdir ext \ No newline at end of file diff --git a/PR/doc/gpl.txt b/PR/doc/gpl.txt new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/PR/doc/gpl.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/PR/doc/readme.coders.txt b/PR/doc/readme.coders.txt new file mode 100644 index 0000000..00275f2 --- /dev/null +++ b/PR/doc/readme.coders.txt @@ -0,0 +1,32 @@ +Princed Resources Handler V0.5 beta +(c) Copyright 2003 - Princed Development Team +http://www.princed.com.ar + +1) Unix-based OS compiling: + +GCC with the C99 standard will work: + +-shell-2.05b$ gcc -std=c99 pr.c -o pr +-shell-2.05b$ ./pr +Princed resources (PR) V0.5 beta. +(c) Copyright 2003 - Princed Development Team +http://www.princed.com.ar + +Syntax: + pr datfile option [extract dir] + +Valid options: + -x[rnus] for extract + r: raw extraction + n: don't extract + u: update res file in case there were records + s: don't save res file + -c for compile + r: raw compiling + -d for type + -t to clear the resource file. +-shell-2.05b$ + +2) Dos/Win32 Console compiling + +LCC will work \ No newline at end of file diff --git a/PR/doc/readme.txt b/PR/doc/readme.txt new file mode 100644 index 0000000..e85ed8e --- /dev/null +++ b/PR/doc/readme.txt @@ -0,0 +1,211 @@ +Princed Resources Editor V0.6 beta +(c) Copyright 2003 - Princed Development Team +http://www.princed.com.ar + +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 nesessary conversions. + +Resource Types: + 01 Levels + 02 Bitmaps + 03 Waves + 04 Midis + 05 Undefined + 06 Palette + 07 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: + We use Windows Bitmaps (BMP) to extract the files. + The file specifications are: + - 16 color-palette. + - No compression. + - Currently the images are saved upside down (We are going to change that). + Recommended editor: Paint Shop Pro, perhaps even MS Paint. + +Type 03: + For digital audio we are using the standard .wav format. + The file specifications are: + - Size of Format: 16 + - Format: PCM + - Attributes: 8 bit, mono, unsigned + - Channels: 1 + - Samplerate: 11025 + - Bytes/Sec: 11025 + - Block Align: 1 + Recommended editors: GoldWave, CoolEdit. Standard Windows programs do not + understand the .wav format. + +Type 04: + 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. + 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) + Recommended editor: Paint Shop Pro. + +2) Bugs: + As Princed Resource Editor is still an Alpha version, bugs are very common, + and we are attempting to fix as many as possible. After that we will release + the beta version and after that the final version. + This program was published because lots of people asked for it in this + unstable state, so do not expect the program to be flexible with the + file format, program syntax, etc. + +3) Syntax: + The command syntax is very easy: + + pr -mainoption[suboptions] optionParameters + + where mainoption must be: + + -t [resFile] + to clear the resource file + -k [resFile] [optionalDirectory] + to kill an extracion + -x[rnuso] DatFile [optionalDirectory] [resFile] + for extract + r: raw extraction + n: don't extract + u: update res file in case there were records + s: don't save res file + o: to specify ResFile + -c[ro] DatFile [optionalDirectory] [resFile] + for compile + r: raw compiling + o: to specify ResFile + -d DatFile + for type + -h + for help + + This will perform the option to the datafile using the auxiliary files in + the optionalDirectory or current if not set. + + Available options are -x for extract, -c for compile and -t for clearing the resource file (it doesn't clear the extracted files). + + Syntax samples: + + C:\PRINCED\PR> pr -x dat\vdungeon.dat 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 vdungeon.dat -x + + This will extract all the bitmaps and palettes allocated in c:\prince\vdungeon.dat + into c:\prince. + + C:\PRINCE> pr -t + + This will clear resources in c:\prince\resources.txt + + C:\PRINCED\PR> pr compiled\vdungeon.dat -c ext + + 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. + Note: c:\princed\pr\compiled must exist. + +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) + +5) ToDo List + i) Fix bug in palette compiling + ii) Improve support of bitmap compiling + iii) Codify the compression algorithms (B1 to B4) to optimize the bitmap compiled dat files + iv) Move PG to bmp.c (only when all bitmaps are Ok) + v) Add full pop2 support + vi) Add resources tree in resources.txt with the following format: + [Prince of Persia 1] + [Sounds] + [Wave] + DIGISND1.DAT 10058 Door close + [Midi] + [Speaker] + [Images] + [Animations] + [Jaffar walking to princess] Palette: TITLE.DAT 11022 + TITLE.DAT 11023 Frame 1 + TITLE.DAT 11024 Frame 2 + TITLE.DAT 11025 Frame 3 + TITLE.DAT 11026 Frame 4 + [Titles] Palette: TITLE.DAT 200 + TITLE.DAT 203 Outside palace presentation + [Eviornment] + [Dungeon] + [Palace] + [Others] + [Prince of Persia 2] + +5.5) Versions: + PR v0.6 beta: unestable, added ii, iv, first full working version + PR v0.7: tested & stable + PR v0.8 beta: added i,iii,vi + PR v0.9: tested and stable + PR v1.0: First optimized & stable version for win32 and linux + +6) 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 + - Merged PS and PG into one extractor. + - Added resource.txt parser. + - Solved several bugs. + - Coded type header verification + - Added dynamic palette extraction + - Added support to export JASC palette for .pal files. + - Added support to .wav files. + * PR 0.2 Alpha + - Added support to import .bmp files + - Source files were abstracted + - Added classifing dat type feature + - Implemented CGI output support for UNIX versions + * PR 0.3 beta + - Added pr.dll compiling + - Added modifiers -x[rnu] -c[r] + - Solved bugs in bitmap format + - Solved segmentation fault in title.dat + - Images bigger than 256 pixels lenght or width now are recognized + - Improved decompression algorithm in bigger images + - Optimized bitmap handling + - Bitmaps aren't upside down anymore + * PR 0.4 beta + - Fixed a memory bug since v0.3 + - Pop2 DAT files detected (file type 11) + * PR 0.5 beta + - Optimized bmp saving algorithm + - Abstracted format handling + - Solved and optimized decompression for big images + - Some Pop2 graphics are extracted (palettes aren't supported yet) + * PR 0.6 beta + - Optimized PG algorithms and reserved memory sizes + - Completed and tested bmp reading algorithm + + +7) Platforms + Binary files are compiled in DOS/Win32 console (v0.5) and in Unix/Alpha versions (v0.5). The DOS executable is pr.exe and the Unix executable is prunix. The Unix version will be used to automate the classification of server uploaded files in our unix-based web server. + + +Please enjoy using Princed Resource Editor! \ No newline at end of file diff --git a/PR/extract.bat b/PR/extract.bat new file mode 100755 index 0000000..61c3b33 --- /dev/null +++ b/PR/extract.bat @@ -0,0 +1,9 @@ +@echo off +if not exist dat\%1 goto error +pr dat\%1 -x ext >%1.txt +dir ext\res*.* >realres.txt +goto end +:error +echo The file '%1' does not exist in dat folder +echo: +:end \ No newline at end of file diff --git a/PR/extract.c b/PR/extract.c new file mode 100644 index 0000000..23e2c2e --- /dev/null +++ b/PR/extract.c @@ -0,0 +1,169 @@ +/***************************************************************\ +| I M P L E M E N T A T I O N | +\***************************************************************/ + +#include "extract.h" + +/***************************************************************\ +| M A I N E X T R A C T | +\***************************************************************/ + +/* + Tasks: + 0 - none + 1 - extract + 2 - update resources (rebuild resources list) + 3 - 1&2 + 4 - use raw file if extraction + 5 - 1&4 +*/ + +int extract(char* vFiledat,char* vDirExt, tResource* r[], char task) { + + //Variables + char vFileext[260]; + FILE* fp; + char ok,pop1; + + if (ok=((fp=fopen(vFiledat,"rb"))!=NULL)) { + //loop variables + unsigned long int indexOffset; + unsigned short int indexSize,numberOfItems; + unsigned char* index; + //verify dat format + ok = fread(&indexOffset,4,1,fp); + //ok=ok&& fread(&val,2,1,fp); + //ok=ok&& (!val); + ok=ok&& fread(&indexSize,2,1,fp); + ok=ok&& !fseek(fp,indexOffset,SEEK_SET); + ok=ok&& fread(&numberOfItems,2,1,fp); + pop1=((numberOfItems*8+2)==indexSize); + int ofk=0; + + if (!pop1) { //verify if pop2 + ofk=numberOfItems*6+2+(numberOfItems-2)*13; + numberOfItems=((indexSize-6-(numberOfItems*6)-((numberOfItems-2)*13))/11); + //printf("verificando pop2: numberOfItems=%d, indexSize=%d\r\n",numberOfItems,indexSize); + } + if (!ok) { + fclose(fp); + return -3; //this is not a valid prince dat file + } + if ((index=getMemory(indexSize-2))==NULL) { + fclose(fp); + return -2; //no memory + } + ok=fread(index,indexSize-2,1,fp); + + //if header ok, new variables + unsigned short int id; + unsigned long int size,offset; + unsigned char* data; + FILE* target; + char type=0; + char recordSize=pop1?8:11; + char aux[260]; + tImage image; //this is used to make a persistent palette + char isntImageSet=1; + //parse folder and take dat filename in caps + getUpperFolder(aux,vFiledat); + + //main loop + for (int k=0;ok&&(k<numberOfItems);k++) { + //for each archived file + id=index[ofk+k*recordSize]+256*index[ofk+k*recordSize+1]; + offset=index[ofk+k*recordSize+2]+256*index[ofk+k*recordSize+3]+256*256*index[ofk+k*recordSize+4]+256*256*256*index[ofk+k*recordSize+5]; + size=index[ofk+k*recordSize+6]+256*index[ofk+k*recordSize+7]+1; + if (!pop1) { +// printf("jajaA %d\r\n",ok); +//printf("verificando pop2: %d, k=%d, record size=%d\r\n",size,k,recordSize); + ok=ok&&(index[ofk+k*recordSize+8]==0x40)&&(!index[ofk+k*recordSize+9])&&(!index[ofk+k*recordSize+10]); +// printf("jajaB %d\r\n",ok); + } + ok=ok&&((data=getMemory(size))!=NULL); +// printf("jajaB %d\r\n",ok); + ok=ok&&(!fseek(fp,offset,SEEK_SET)); +// printf("jajaB %d\r\n",ok); + ok=ok&&fread(data,size,1,fp); +// printf("jajaB %d\r\n",ok); + if (!ok) return -3; + + //If rebuild option has been chosen, destroy previous declaration + if ((r[id]!=NULL)&&(task&2)) { + if ((*(r[id])).coms!=NULL) free ((*(r[id])).coms); + if ((*(r[id])).desc!=NULL) free ((*(r[id])).desc); + free(r[id]); + } + + //set resource information on this index entry + if (r[id]==NULL) { + r[id]=(tResource*)malloc(sizeof(tResource)); + (*(r[id])).size=(unsigned short int)size; + (*(r[id])).offset=offset; + sprintf((*(r[id])).file,aux); + (*(r[id])).desc=NULL; + (*(r[id])).coms=NULL; + (*(r[id])).type=verifyHeader(data,(unsigned short int)size); + } + + if (task&1) { + //select type + if (task&4) (*(r[id])).type=0; + //save file + getFileName(vFileext,vDirExt,(*(r[id])).type,id); + switch ((*(r[id])).type) { + case 0: + ok=ok&&((target=fopen(vFileext,"wb"))!=NULL); + ok=ok&&fwrite(data+1,size-1,1,target); //Ignore checksum + ok=ok&&(!fclose(target)); + break; + case 6: + + if (1/*isntImageSet*/) { + mLoadPalette(data,&image); + isntImageSet=0; + } + //todo send to pal.c + mExportPalette(&data,&size); + //save palette + ok=ok&&((target=fopen(vFileext,"wb"))!=NULL); + ok=ok&&fwrite(data,size,1,target); + ok=ok&&(!fclose(target)); + + //until here + break; + case 1: + case 5: + case 4: + //save file + + //TODO send to mid.c + ok=ok&&((target=fopen(vFileext,"wb"))!=NULL); + ok=ok&&fwrite(data+2,size-2,1,target); //Ignore checksum & sound type + ok=ok&&(!fclose(target)); + + //until here + break; + case 3: //save wav file + ok=ok&&mFormatExtractWav(data,vFileext,size); + break; + case 2: + //save image + //Todo send to bmp.c + if ((mExpandGraphic(data,&image,size))>0) { + mWriteBitMap(image,vFileext); + free(image.pix); + } + + //until here + break; + } + } + if (data!=NULL) free(data); + } + fclose(fp); + return ok; + } else { + return -1; //file could not be open + } +} diff --git a/PR/extract.h b/PR/extract.h new file mode 100644 index 0000000..7e4cd2f --- /dev/null +++ b/PR/extract.h @@ -0,0 +1,31 @@ + +#ifndef _EXTARCT_H_ +#define _EXTRACT_H_ + +/***************************************************************\ +| I M P L E M E N T A T I O N | +\***************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include "formats/wav.h" +#include "pg.h" +#include "parser.h" +#include "resources.h" + +/***************************************************************\ +| M A I N E X T R A C T | +\***************************************************************/ + +/* + Tasks: + 1 - extract + 2 - update resources + 3 - 1&2 + 4 - use raw file if extraction + 8 - rebuild resources list +*/ + +int extract(char* vFiledat,char* vDirExt, tResource* r[], char task); + +#endif diff --git a/PR/help.bat b/PR/help.bat new file mode 100755 index 0000000..6e7c31b --- /dev/null +++ b/PR/help.bat @@ -0,0 +1,2 @@ +@echo off +type readme.txt |more \ No newline at end of file diff --git a/PR/levels.dat.txt b/PR/levels.dat.txt new file mode 100644 index 0000000..3b232a9 --- /dev/null +++ b/PR/levels.dat.txt @@ -0,0 +1,6 @@ +Princed resources (PR) V0.5 beta. +(c) Copyright 2003 - Princed Development Team +http://www.princed.com.ar + +Extracting 'dat\levels.dat' to 'ext' with 1 +Result: 1 diff --git a/PR/makedll.bat b/PR/makedll.bat new file mode 100755 index 0000000..be3dacd --- /dev/null +++ b/PR/makedll.bat @@ -0,0 +1,2 @@ +@echo off +c:\archiv~1\lcc\bin\lcclnk.exe -dll pr.obj pr.def \ No newline at end of file diff --git a/PR/memory.c b/PR/memory.c new file mode 100644 index 0000000..4fc465e --- /dev/null +++ b/PR/memory.c @@ -0,0 +1,6 @@ +#include "memory.h" + +//Reserves a memory space to allocate an image +unsigned char* getMemory(int size) { + return (unsigned char*)malloc(sizeof(unsigned char*)*size); +} diff --git a/PR/memory.h b/PR/memory.h new file mode 100644 index 0000000..a60d215 --- /dev/null +++ b/PR/memory.h @@ -0,0 +1,11 @@ + +#ifndef _MEMORY_H_ +#define _MEMORY_H_ + +#include <stdlib.h> + +//Reserves a memory space to allocate an image +unsigned char* getMemory(int size); + +#endif + diff --git a/PR/parser.c b/PR/parser.c new file mode 100644 index 0000000..41a0259 --- /dev/null +++ b/PR/parser.c @@ -0,0 +1,136 @@ +/****************************************************************\ +| Libreria de manejo de strings, conversiones y parsing | +\****************************************************************/ + +#ifndef PARSER_DEFINED + +#define PARSER_DEFINED + +//Letras a numeros +char num(char n) { + return ((0x2F<n)&&(n<0x3A))?(n-(0x30)):0; +} + +//Interprete de numeros en strings +unsigned long str2int(char r[]) { + char i = 0; + int valor = 0; + while(r[i]) { + valor=(10*valor)+num(r[i++]); + } + return valor; +} + +//Comparacion de strings +int equals(char s1[],char s2[]) { + int i=0; + for (;(s1[i]==s2[i])&&s1[i];i++); + return !(s1[i]||s2[i]); +} + +//Tokenizer simple +//Sintaxis: getToken(string texto,var string token,char caracterSeparador, +// var int startPosition, int sizeOfToken) +int getToken(char texto[],char token[],char tokenizer,int* i,int k) { + int j=0; + //Copiar el string hasta que se encuentre el token o se termine la linea. + //En caso de que no entre el texto en el token, lo deja truncado pero avanza i hasta el final + while (texto[*i]!=tokenizer && ((j<k)?(token[j++]=texto[(*i)++]):(texto[(*i)++]))); + token[j]='\0'; + return (texto[((*i)++)-1]); +} + +//Tokenizer simple +//Sintaxis: getNumberToken(string texto,var int token,char caracterSeparador, +// var int startPosition, int deprecated) +int getNumberToken(char texto[],unsigned short int *token,char tokenizer,int* i,int k) { + char a; + //Copiar el string hasta que se encuentre el token o se termine la linea. + //En caso de que no entre el texto en el token, lo deja truncado pero avanza i hasta el final + for (*token=0;(((a=texto[(*i)++])!=tokenizer)&&a);(*token)=(*token)*10+num(a)); + return (a); +} + +//Tokenizer + upperCase, muy bueno para interpretar comandos case insensitive +//Sintaxis: getUpperToken(string texto,var string token,char caracterSeparador, +// var int startPosition, int sizeOfToken) +int getUpperToken(char texto[],char token[],char tokenizer,int* i,int k) { + int j=0; + //Idem, pero si la letra esta entre 'a' y 'z' las pasa a mayusculas + while ((texto[*i]!=tokenizer) && ((j<k)?(token[j++]=(('a'>texto[(*i)])||(texto[(*i)]>'z'))?(texto[(*i)++]):(texto[(*i)++]&UPPER_CASE)):(texto[(*i)++]))); + token[j]='\0'; + return (texto[((*i)++)-1]); +} + +//Tokenizer complejo con soporte de comillas, optimizado para separar palabras +//Sintaxis: getToken(string texto,var string token, +// var int startPosition, int sizeOfToken) +int getMaskToken(char texto[],char token[],int* i,int k) { + int j=0; + //Copiar el string hasta que se encuentre el token Espacio o se termine la linea. + //En caso de que no entre el texto en el token, lo deja truncado pero avanza i hasta el final + char entreComillas=0; //flag que indica si se esta dentro de una cadena entre comillas, alterna entre 0 y 1 dependiendo de si se encuentran las comillas, en caso de valer 1 el while no se detiene + while ((((entreComillas^=(texto[(*i)]==34)) || (texto[*i]!=32)) && ((j<k)?(token[j++]=texto[(*i)++]):(texto[(*i)++])))); + //Seteo el caracter nulo al final del token, incremento i y devuelvo el siguiente caracter del texto o 0 en caso de que este sea el nulo. + token[j]='\0'; + return (texto[((*i)++)-1]); +} + +//Funcion privada +char matches1(char* text,char* mask,char ptext, char pmask) { + /* + Esta funcion verifica que el texto pertenezca a la mascara, + no verifica espacios ya que eso debe ser parseado en la funcion + que la llama. + En caso de poseer * la funcion se vuelve recursiva. + Optimizacion: + 1) Se contempla el caso del * multiple y se lo toma como simple + para evitar la ejecucion de recursividad de O(n cuadrado). + 2) Se contempla el caso del * al final de la mascara, en dicho caso + no ejecuta la recursividad y devuelve verdadero ya que, si se llego a + ese punto, el texto matchea. + En caso de poseer " las ignora. + En caso de poseer ? contempla cualquier caracter (incluso ? y *). + + Devuelve 1 en caso de que el caracter coincida y 0 en caso contrario. + */ + while (text[ptext]||mask[pmask]) { + if (mask[pmask]=='"') { + pmask++; + } else if (mask[pmask]=='?') { + pmask++; + if (!text[ptext]) return 0; + ptext++; + } else if (mask[pmask]=='*') { + while (mask[pmask++]=='*'); + pmask--; + if (!mask[pmask]) return 1; //acelera un poco el proceso para el caso particular de que termine en * + char aux; + while ((text[ptext]) && !(aux=matches1(text,mask,ptext++,pmask))); + return aux; + } else { + if (text[ptext]!=mask[pmask]) return 0; + ptext++; + pmask++; + } + } + return (text[ptext]==mask[pmask]); +} + +//Funcion publica +char matchesIn(char* text,char* mask) { + int i=0; + char token[PARSING_MAX_TOKEN_SIZE]; + char valor=0; + + /* + Esta funcion se encarga de partir los espacios de la mascara y + llamar a una comparacion por cada parte + */ + while (getMaskToken(mask,token,&i,PARSING_MAX_TOKEN_SIZE) && !(valor=(valor || matches1(text,token,0,0)))); + return valor?1:matches1(text,token,0,0); +} + +#endif + + diff --git a/PR/parser.h b/PR/parser.h new file mode 100644 index 0000000..35c1fb2 --- /dev/null +++ b/PR/parser.h @@ -0,0 +1,47 @@ +/****************************************************************\ +| Libreria de manejo de strings, conversiones y parsing | +\****************************************************************/ + +#ifndef _PARSER_H_ +#define _PARSER_H_ + +//Constantes del programa referentes al case +#define UPPER_CASE 0xDF +#define INSENSIBLE 0xFF + +//Constante que marca el maximo tamagno que puede medir una palabra +// separada por espacios en la funcion matchesIn (token) +#define PARSING_MAX_TOKEN_SIZE 200 + +//Letras a numeros +char num(char n); + +//Interprete de numeros en strings +unsigned long str2int(char r[]); + +//Comparacion de strings +int equals(char s1[],char s2[]); + +//Tokenizer simple +//Sintaxis: getToken(string texto,var string token,char caracterSeparador, +// var int startPosition, int sizeOfToken) +int getToken(char texto[],char token[],char tokenizer,int* i,int k); + +//Tokenizer simple +//Sintaxis: getNumberToken(string texto,var int token,char caracterSeparador, +// var int startPosition, int deprecated) +int getNumberToken(char texto[],unsigned short int *token,char tokenizer,int* i,int k); + +//Tokenizer + upperCase, muy bueno para interpretar comandos case insensitive +//Sintaxis: getUpperToken(string texto,var string token,char caracterSeparador, +// var int startPosition, int sizeOfToken) +int getUpperToken(char texto[],char token[],char tokenizer,int* i,int k); + +//Tokenizer complejo con soporte de comillas, optimizado para separar palabras +//Sintaxis: getToken(string texto,var string token, +// var int startPosition, int sizeOfToken) +int getMaskToken(char texto[],char token[],int* i,int k); + +#endif + + diff --git a/PR/pg.c b/PR/pg.c new file mode 100644 index 0000000..f73e76c --- /dev/null +++ b/PR/pg.c @@ -0,0 +1,217 @@ +/***************************************************************\ +| I M P L E M E N T A T I O N | +\***************************************************************/ + +//reserved memory for the Lzx algorithm +#define MAX_MOD_SIZE_IN_LZX 32001 +//38401 +//modulus to be used in the 10 bits of the algorithm +#define MAX_MXD_SIZE_IN_LZX 0x400 + +/***************************************************************\ +| Compression algorithm handling | +\***************************************************************/ + +//Determines where the transposed byte must be saved +int transpose(int x,int n,int m) { + return ((x%m)*((n+1)/2))+(int)(x/m); +} + +//B3 and B4 expansion algorithm sub function +unsigned char popBit(unsigned char *byte) { + unsigned char bit=(*byte)&1; + (*byte)>>=1; + return bit; +} + +//Expands B3/B4 algorithm +void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) { + int pos,h; + unsigned char maskbyte,rep; + for(pos=0;pos<MAX_MXD_SIZE_IN_LZX;(*img).pix[pos++]=0); //clean output garbage + while (cursor<virtualSize) { + maskbyte=array[(*i)++]; + for (char k=8;k&&(cursor<virtualSize);k--) { + if (popBit(&maskbyte)) { + (*img).pix[cursor++]=array[(*i)++]; + } else { + pos=66+((0x100)*((rep=array[(*i)++])&3))+(unsigned char)array[(*i)++]; + rep=(rep>>2)+3; + while (rep--) { //Be careful in big images + h=cursor/MAX_MXD_SIZE_IN_LZX-(pos%MAX_MXD_SIZE_IN_LZX>cursor%MAX_MXD_SIZE_IN_LZX); + (*img).pix[cursor++]=(*img).pix[((h<0)?0:h)*MAX_MXD_SIZE_IN_LZX+pos++%MAX_MXD_SIZE_IN_LZX]; + } + } + } + } +} + +//Compress B1/B2 algorithm +void compressRle(unsigned char* data,tImage* img,int *dataSize) { + int cursorPix=0; + int cursorData=0; + + int imgSize=((*img).size>>1)-1; + char enthropyBlock=1; + int count=0; + + while (cursorPix<imgSize) { + //Count different pixels + if (data[cursorPix++]==data[cursorPix]) { + if (enthropyBlock) { //TODO: add ||count>127 + enthropyBlock=0; + //Print count . enthropy block (data[cursorPix-count..cursorPix]) + + count=0; + } else { + count++; + } + } else { + if (enthropyBlock) { //TODO: add ||count>128 + count++; + } else { + enthropyBlock=1; + //Print -count . unenthropy byte (data[cursorPix-1]) + + count=0; + } + } + } + + +/* + + if ((signed char)array[i]<0) { + //negative + while (array[i]++) (*image).pix[(cursor++)%((*image).size)]=array[i+1]; + i+=2; + } else { + //Positive + char cx=array[i++]+1; + while (cx--) (*image).pix[(cursor++)%((*image).size)]=array[i++]; + } + } + */ +} + + + + + + +//Expands an array into an image +int mExpandGraphic(char* array,tImage *image, int virtualSize) { + /* + Reads array and extracts tImage + returns the next image address or -1 in case of error + + Header info: + char checksum, short int height, short int width, (char)0, char compressionType + normaly: (* ignored types) + checksum* - height - 00 - width - 00 - 00* - compression type + */ + + int cursor=0; + int i=1; + + //Get memory for the image + (*image).height=(unsigned char)array[i++]+256*(unsigned char)array[i++]; + (*image).width =(unsigned char)array[i++]+256*(unsigned char)array[i++]; + (*image).size =(*image).height*(*image).width; + virtualSize=((*image).height*((*image).width+((*image).width&1)))>>1; + i++; + + switch ((unsigned char)array[i++]) { + case PG_COMP_RAW: //No Compression Algorithm + if (((*image).pix=getMemory(virtualSize))==NULL) return -1; + while (cursor<virtualSize) { + (*image).pix[cursor++]=array[i++]; + } + break; + case PG_COMP_RLE_LR: //RLE Left to Right Compression Algorithm + if (((*image).pix=getMemory(virtualSize))==NULL) return -1; + while (cursor<virtualSize) { + if ((signed char)array[i]<0) { + //negative + while (array[i]++) (*image).pix[(cursor++)]=array[i+1]; + i+=2; + } else { + //Positive + char cx=array[i++]+1; + while (cx--) (*image).pix[(cursor++)]=array[i++]; + } + } + break; + case PG_COMP_RLE_UD: //RLE Up to Down Compression Algorithm + if (((*image).pix=getMemory(virtualSize))==NULL) return -1; + while (cursor<virtualSize) { + if ((signed char)array[i]<0) { + //negative + while (array[i]++) (*image).pix[(transpose(cursor++,(*image).width,(*image).height))]=array[i+1]; + i+=2; + } else { + //Positive + char cx=array[i++]+1; + while (cx--) (*image).pix[transpose(cursor++,(*image).width,(*image).height)]=array[i++]; + } + } + break; + case PG_COMP_LZX_LR: //LZ Groody Up to Down Version Compression Algorithm + if (((*image).pix=getMemory(MAX_MOD_SIZE_IN_LZX))==NULL) return -1; + expandLzx(array,image,&i,cursor,virtualSize); + break; + case PG_COMP_LZX_UD: //LZ Groody Left to Right Version Compression Algorithm + if (((*image).pix=getMemory(MAX_MOD_SIZE_IN_LZX))==NULL) return -1; + { + unsigned char* outputaux=getMemory(virtualSize); + expandLzx(array,image,&i,cursor,virtualSize); + //Transpose + while (cursor<virtualSize) outputaux[transpose(cursor,(*image).width,(*image).height)]=(*image).pix[cursor++]; + free((*image).pix); + (*image).pix=outputaux; + } + break; + default: + return -1; + } + return i; +} + +//Compress an image into an array in the most quick & dirty way +int mCompressGraphic(unsigned char* a,tImage i, int* size) { + *size=(i.size/2)+6; + a=getMemory(*size); + //height - 00 - width - 00 - 00 - compression type + a[2]=i.width; + a[3]=i.width>>8; + + a[0]=i.height; + a[1]=i.height>>8; + + a[4]=0; + a[5]=0xB0; // how q&d I am :) + + memcpy(i.pix,a+6,*size); + return 1; +} + +/***************************************************************\ +| File handling | +\***************************************************************/ + +//Deprecated +/* +char mLoadFilePalette(char* vFile,int address, char* pal) { + FILE *fp; + char aux; + + if ((fp=fopen(vFile,"rb"))==NULL) { + return 0; + } else { + fseek (fp, address, SEEK_SET); + aux=fread (pal,SIZE_OF_PALETTE,1,fp); + fclose(fp); + return aux; + } +} +*/ diff --git a/PR/pg.h b/PR/pg.h new file mode 100644 index 0000000..f23982d --- /dev/null +++ b/PR/pg.h @@ -0,0 +1,57 @@ + +#ifndef _PG_H_ +#define _PG_H_ + +#define SIZE_OF_FILE 64*1024 +#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 + +typedef struct { + int width; + int height; + int size; + unsigned char* pix; + unsigned char pal[SIZE_OF_PALETTE]; +}tImage; + +//Prototypes: + +int mCompressGraphic(unsigned char* a,tImage i, int* size); +int mExpandGraphic(char* array,tImage *image, int size); + +/* + Class future definitions + +public: + char cPrincedGraph::mOpenGraphDat (char* fileName); + char cPrincedGraph::mSaveGraphDat (char* fileName); + char cPrincedGraph::mGetGraphFull (int id, CBitmap &bitmap, CBitmap &mask); + char cPrincedGraph::mGetGraphMap (int id, CBitmap &bitmap); + char cPrincedGraph::mGetGraphMask (int id, CBitmap &bmask); + char cPrincedGraph::mSetGraph (int id, CBitmap &bitmap); + int cPrincedGraph::mGetGraphCount (); + char cPrincedGraph::mSaveImportBmp (int id, char* fileName); + char cPrincedGraph::mSaveExportBmp (int id, char* fileName); + +private: + unsigned char* file; + int fileSize; + tImage* imageArray[256]; + int imageArrayLength; + +*/ + +#include <stdio.h> +#include <stdlib.h> +#include "pg.h" +#include "formats/bmp.h" +#include "formats/pal.h" +#include "memory.h" + +#endif diff --git a/PR/pr.c b/PR/pr.c new file mode 100644 index 0000000..b8f325b --- /dev/null +++ b/PR/pr.c @@ -0,0 +1,214 @@ +/* + Princed Resources library V1 beta + (c) Copyright 2003, Princed Development Team + + Authors + Main routines + Enrique Calot + + Graphic compression algorithm + Tammo Jan Dijkema + Enrique Calot + + Graphic format development + Tammo Jan Dijkema + Anke Balderer + + MID Sound format development + Christian Lundheim + +*/ + +//Compilation options + +//#define UNIX +//#define DLL +#define PR_ABOUT "Princed resources (PR) V0.5 beta.\r\n(c) Copyright 2003 - Princed Development Team\r\nhttp://www.princed.com.ar\r\n\r\n" + +//Headers + +#include "pr.h" + +//Inclusion of implementations + +#include "compile.c" +#include "extract.c" +#include "memory.c" +#include "parser.c" +#include "pg.c" +#include "resources.c" +#include "tasks.c" + +//format support +#include "formats/wav.c" +#include "formats/bmp.c" +#include "formats/pal.c" + +//functions + +int prExportDat(char* vDatFile, char* vDirName, char* vResFile) { + return prExportDatOpt(vDatFile,vDirName,vResFile,3); +} + +int prExportDatOpt(char* vDatFile, char* vDirName, char* vResFile,char opt) { + /* + Options: + 0 - none + 1 - extract + 2 - update resources (rebuild resources list) + 3 - 1&2 + 4 - use raw file if extraction + 5 - 1&4 + 8 - Don't save + + Return values: + 00 Ok + -1 Error accesing the file + -2 Memory error + */ + tResource* r[65536]; + parseFile (vResFile,r); + int a=extract(vDatFile, vDirName,r,opt); + if (!(opt&8)) generateFile(vResFile,r); + return a; +} + +int prImportDat(char* vDatFile, char* vDirName, char* vResFile) { + return prImportDatOpt(vDatFile,vDirName,vResFile,1); +} + +int prImportDatOpt(char* vDatFile, char* vDirName, char* vResFile,char opt) { + /* + Options: + 0 - use raw files + 1 - read data type + + Return values: + -1 File couldn't be open for writing + 00 File succesfully compiled + positive number: number of missing files + */ + tResource* r[65536]; + parseFile (vResFile,r); + int a=compile (vDatFile, vDirName,r,opt); + generateFile (vResFile,r); + return a; +} + +int prClearRes(char* vResFile) { + /* + Return values: + 01 Ok + 00 Error + */ + tResource* r[65536]; + emptyTable(r); + return generateFile(vResFile,r); +} + + + +//Main program +#ifndef DLL +void syntax() { + printf("Syntax:\r\n pr datfile option [extract dir]\r\n\r\nValid options:\r\n -x[rnus] for extract\r\n r: raw extraction\r\n n: don't extract\r\n u: update res file in case there were records\r\n s: don't save res file\r\n -c for compile\r\n r: raw compiling\r\n -d for type\r\n -t to clear the resource file.\r\n"); +} + +int main(int argc, char* argv[]) { + +#ifdef UNIX + if (argc==2) { + printf("Content-Type:text/html\n\nRunning as a cgi\n"); + printf("Result: %d type\r\n",prVerifyDatType(argv[1])); + return 1; + } +#endif + + //declare variables + char dir[260]="."; + int returnValue=1; + int option; + + //TODO: send to defines + printf(PR_ABOUT); + + //Verify syntax + if ((argc<3)||(argc>4)||(argv[2][0])!='-') { + syntax(); + return -1; + } + if (argc==4) { + sprintf(dir,argv[3]); + } + + //do selected taskbars + switch (argv[2][1]) { + case 'e': + case 'x': // file.dat --> files.ext + resource.txt + option=1; + for (int i=2;argv[2][i];i++) { + switch (argv[2][i]) { + case 'n':option&=0xFE;break; + case 'r':option|=0x04;break; + case 'u':option|=0x02;break; + case 's':option|=0x08;break; + default:printf("Found invalid option '%c', skiping . . .\r\n",argv[2][i]);break; + } + } + printf("Extracting '%s' to '%s' with %d\r\n",argv[1],dir,option); + printf("Result: %d\r\n",returnValue=prExportDatOpt(argv[1],dir,"resources.txt",option)); + break; + case 'd': // get type of file.dat + printf("Classifing '%s'\r\n",argv[1]); + printf("Result: %d type\r\n",returnValue=prVerifyDatType(argv[1])); + break; + case 'i': + case 'c': // files.ext + resource.txt --> files.dat + option=1; + for (int i=2;argv[2][i];i++) { + switch (argv[2][i]) { + case 'r':option&=0xFE;break; + default:printf("Found invalid option '%c', skiping . . .\r\n",argv[2][i]);break; + } + } + printf("Compiling '%s' from '%s' with %d\r\n",argv[1],dir,option); + printf("Result: %d\r\n",returnValue=prImportDatOpt(argv[1],dir,"resources.txt",option)); + break; + case 't': // none --> resource.txt (destroy resource table) + printf("Clearing 'resources.txt'\r\n"); + printf("Result: %d\r\n",returnValue=prClearRes("resources.txt")); + break; + case 'b': // img.bmp --> img.ext + { + char vFileraw[100]; + char vFilebmp[100]; + unsigned char* data; + tImage img; + + sprintf(vFileraw,"%s%cres%s.raw",dir,DIR_SEPARATOR,argv[1]); + sprintf(vFilebmp,"%s%cres%s.bmp",dir,DIR_SEPARATOR,argv[1]); + + printf("Converting '%s' into '%s'\r\n",vFilebmp,vFileraw); + int size=mLoadFileArray(vFilebmp,&data); + if (size && mReadBitMap(&img,data,size)) { + free(data); + mCompressGraphic(data,img,&size); + free(img.pix); + mSaveRaw(vFileraw,data,size); + free(data); + + } else { + printf("No access to the file\r\n"); + break; + } + + } + break; + default: + syntax(); + return -1; + } + return returnValue; +} + +#endif diff --git a/PR/pr.def b/PR/pr.def new file mode 100644 index 0000000..a248c94 --- /dev/null +++ b/PR/pr.def @@ -0,0 +1,7 @@ +EXPORTS + prExportDat + prImportDat + prClearRes + prVerifyDatType + prExportDatOpt + prImportDatOpt \ No newline at end of file diff --git a/PR/pr.dll b/PR/pr.dll new file mode 100644 index 0000000..e849151 Binary files /dev/null and b/PR/pr.dll differ diff --git a/PR/pr.exe b/PR/pr.exe new file mode 100755 index 0000000..0302730 Binary files /dev/null and b/PR/pr.exe differ diff --git a/PR/pr.exp b/PR/pr.exp new file mode 100644 index 0000000..c287392 --- /dev/null +++ b/PR/pr.exp @@ -0,0 +1,7 @@ +pr.dll +_prClearRes _prClearRes +_prExportDat _prExportDat +_prExportDatOpt _prExportDatOpt +_prImportDat _prImportDat +_prImportDatOpt _prImportDatOpt +_prVerifyDatType _prVerifyDatType diff --git a/PR/pr.h b/PR/pr.h new file mode 100644 index 0000000..db90d6a --- /dev/null +++ b/PR/pr.h @@ -0,0 +1,27 @@ +#ifndef _PR_H_ +#define _PR_H_ + +//princed resource library + +#ifdef UNIX + #define DIR_SEPARATOR '/' +#else + #define DIR_SEPARATOR '\\' +#endif + +#include <string.h> +#include "extract.h" +#include "compile.h" +#include "tasks.h" + +//Main functions +int prExportDat(char* vDatFile, char* vDirName, char* vResFile); +int prImportDat(char* vDatFile, char* vDirName, char* vResFile); +int prClearRes(char* vResFile); +int prVerifyDatType(char* vFiledat); + +//Extra featured functions +int prExportDatOpt(char* vDatFile, char* vDirName, char* vResFile,char opt); +int prImportDatOpt(char* vDatFile, char* vDirName, char* vResFile,char opt); + +#endif diff --git a/PR/pr.lib b/PR/pr.lib new file mode 100644 index 0000000..0303e7d Binary files /dev/null and b/PR/pr.lib differ diff --git a/PR/pr.obj b/PR/pr.obj new file mode 100644 index 0000000..db76701 Binary files /dev/null and b/PR/pr.obj differ diff --git a/PR/pr06-src-bin.zip b/PR/pr06-src-bin.zip new file mode 100644 index 0000000..b4cb87b Binary files /dev/null and b/PR/pr06-src-bin.zip differ diff --git a/PR/prunix b/PR/prunix new file mode 100644 index 0000000..098d364 Binary files /dev/null and b/PR/prunix differ diff --git a/PR/ps.h b/PR/ps.h new file mode 100644 index 0000000..8ebecfe --- /dev/null +++ b/PR/ps.h @@ -0,0 +1,5 @@ + +#ifndef _PS_H_ +#define _PS_H_ + +#endif diff --git a/PR/realres.txt b/PR/realres.txt new file mode 100644 index 0000000..2180382 --- /dev/null +++ b/PR/realres.txt @@ -0,0 +1,253 @@ + + El volumen de la unidad C es KKX1 + El n\xa3mero de serie del volumen es 9336-E800 + Directorio de C:\WINDOWS\Escritorio\princed\pr\prlib\ext + +RES00200 PAL 194 08/07/03 12.49 res00200.pal +RES00201 EXT 1 08/07/03 12.49 res00201.ext +RES00202 EXT 1 08/07/03 12.49 res00202.ext +RES00203 EXT 1 08/07/03 12.49 res00203.ext +RES00204 EXT 1 08/07/03 12.49 res00204.ext +RES00205 EXT 1 08/07/03 12.49 res00205.ext +RES00206 EXT 1 08/07/03 12.49 res00206.ext +RES00207 EXT 1 08/07/03 12.49 res00207.ext +RES00208 EXT 1 08/07/03 12.49 res00208.ext +RES00209 EXT 1 08/07/03 12.49 res00209.ext +RES00210 EXT 1 08/07/03 12.49 res00210.ext +RES00211 EXT 1 08/07/03 12.49 res00211.ext +RES00212 EXT 1 08/07/03 12.49 res00212.ext +RES00213 EXT 1 08/07/03 12.49 res00213.ext +RES00214 EXT 1 08/07/03 12.49 res00214.ext +RES00215 EXT 1 08/07/03 12.49 res00215.ext +RES00216 EXT 1 08/07/03 12.49 res00216.ext +RES00217 EXT 1 08/07/03 12.49 res00217.ext +RES00218 EXT 1 08/07/03 12.49 res00218.ext +RES00219 EXT 1 08/07/03 12.49 res00219.ext +RES00220 EXT 1 08/07/03 12.49 res00220.ext +RES00221 EXT 1 08/07/03 12.49 res00221.ext +RES00222 EXT 1 08/07/03 12.49 res00222.ext +RES00223 EXT 1 08/07/03 12.49 res00223.ext +RES00224 EXT 1 08/07/03 12.49 res00224.ext +RES00225 EXT 1 08/07/03 12.49 res00225.ext +RES00226 EXT 1 08/07/03 12.49 res00226.ext +RES00227 EXT 1 08/07/03 12.49 res00227.ext +RES00228 EXT 1 08/07/03 12.49 res00228.ext +RES00229 EXT 1 08/07/03 12.49 res00229.ext +RES00230 EXT 1 08/07/03 12.49 res00230.ext +RES00231 EXT 1 08/07/03 12.49 res00231.ext +RES00232 BMP 214 08/07/03 12.49 res00232.bmp +RES00233 BMP 262 08/07/03 12.49 res00233.bmp +RES00234 BMP 262 08/07/03 12.49 res00234.bmp +RES00235 BMP 374 08/07/03 12.49 res00235.bmp +RES00236 BMP 166 08/07/03 12.49 res00236.bmp +RES00237 BMP 1.078 08/07/03 12.49 res00237.bmp +RES00238 BMP 374 08/07/03 12.49 res00238.bmp +RES00239 BMP 1.110 08/07/03 12.49 res00239.bmp +RES00240 BMP 374 08/07/03 12.49 res00240.bmp +RES00241 BMP 326 08/07/03 12.49 res00241.bmp +RES00242 BMP 358 08/07/03 12.49 res00242.bmp +RES00243 BMP 166 08/07/03 12.49 res00243.bmp +RES00244 BMP 550 08/07/03 12.49 res00244.bmp +RES00245 BMP 470 08/07/03 12.49 res00245.bmp +RES00246 BMP 1.078 08/07/03 12.49 res00246.bmp +RES00247 BMP 1.110 08/07/03 12.49 res00247.bmp +RES00248 BMP 326 08/07/03 12.49 res00248.bmp +RES00249 BMP 358 08/07/03 12.49 res00249.bmp +RES00250 BMP 262 08/07/03 12.49 res00250.bmp +RES00251 BMP 198 08/07/03 12.49 res00251.bmp +RES00252 BMP 214 08/07/03 12.49 res00252.bmp +RES00253 BMP 202 08/07/03 12.49 res00253.bmp +RES00254 BMP 190 08/07/03 12.49 res00254.bmp +RES00255 BMP 178 08/07/03 12.49 res00255.bmp +RES00256 BMP 166 08/07/03 12.49 res00256.bmp +RES00257 BMP 154 08/07/03 12.49 res00257.bmp +RES00258 BMP 142 08/07/03 12.49 res00258.bmp +RES00259 BMP 130 08/07/03 12.49 res00259.bmp +RES00260 BMP 226 08/07/03 12.49 res00260.bmp +RES00261 BMP 226 08/07/03 12.49 res00261.bmp +RES00262 BMP 226 08/07/03 12.49 res00262.bmp +RES00263 BMP 226 08/07/03 12.49 res00263.bmp +RES00264 BMP 226 08/07/03 12.49 res00264.bmp +RES00265 BMP 226 08/07/03 12.49 res00265.bmp +RES00266 BMP 226 08/07/03 12.49 res00266.bmp +RES00267 BMP 226 08/07/03 12.49 res00267.bmp +RES00268 EXT 23 08/07/03 12.49 res00268.ext +RES00269 BMP 342 08/07/03 12.49 res00269.bmp +RES00270 BMP 326 08/07/03 12.49 res00270.bmp +RES00271 BMP 374 08/07/03 12.49 res00271.bmp +RES00272 BMP 374 08/07/03 12.49 res00272.bmp +RES00273 BMP 166 08/07/03 12.49 res00273.bmp +RES00274 BMP 166 08/07/03 12.49 res00274.bmp +RES00275 EXT 1 08/07/03 12.49 res00275.ext +RES00276 EXT 1 08/07/03 12.49 res00276.ext +RES00277 EXT 1 08/07/03 12.49 res00277.ext +RES00278 EXT 1 08/07/03 12.49 res00278.ext +RES00279 EXT 1 08/07/03 12.49 res00279.ext +RES00280 EXT 1 08/07/03 12.49 res00280.ext +RES00281 EXT 1 08/07/03 12.49 res00281.ext +RES00282 EXT 1 08/07/03 12.49 res00282.ext +RES00283 EXT 1 08/07/03 12.49 res00283.ext +RES00284 EXT 1 08/07/03 12.49 res00284.ext +RES00285 BMP 182 08/07/03 12.49 res00285.bmp +RES00286 EXT 1 08/07/03 12.49 res00286.ext +RES00287 EXT 1 08/07/03 12.49 res00287.ext +RES00288 EXT 1 08/07/03 12.49 res00288.ext +RES00289 EXT 1 08/07/03 12.49 res00289.ext +RES00290 EXT 1 08/07/03 12.49 res00290.ext +RES00291 EXT 1 08/07/03 12.49 res00291.ext +RES00292 BMP 1.078 08/07/03 12.49 res00292.bmp +RES00293 BMP 1.110 08/07/03 12.49 res00293.bmp +RES00294 BMP 174 08/07/03 12.49 res00294.bmp +RES00295 BMP 838 08/07/03 12.49 res00295.bmp +RES00296 BMP 166 08/07/03 12.49 res00296.bmp +RES00297 BMP 326 08/07/03 12.49 res00297.bmp +RES00298 BMP 374 08/07/03 12.49 res00298.bmp +RES00299 BMP 214 08/07/03 12.49 res00299.bmp +RES00300 BMP 262 08/07/03 12.49 res00300.bmp +RES00301 EXT 1 08/07/03 12.49 res00301.ext +RES00302 EXT 1 08/07/03 12.49 res00302.ext +RES00303 EXT 1 08/07/03 12.49 res00303.ext +RES00304 EXT 1 08/07/03 12.49 res00304.ext +RES00305 EXT 1 08/07/03 12.49 res00305.ext +RES00306 EXT 1 08/07/03 12.49 res00306.ext +RES00307 EXT 1 08/07/03 12.49 res00307.ext +RES00308 EXT 1 08/07/03 12.49 res00308.ext +RES00309 EXT 1 08/07/03 12.49 res00309.ext +RES00310 EXT 1 08/07/03 12.49 res00310.ext +RES00311 EXT 1 08/07/03 12.49 res00311.ext +RES00312 EXT 1 08/07/03 12.49 res00312.ext +RES00313 EXT 1 08/07/03 12.49 res00313.ext +RES00314 EXT 1 08/07/03 12.49 res00314.ext +RES00315 EXT 1 08/07/03 12.49 res00315.ext +RES00316 EXT 1 08/07/03 12.49 res00316.ext +RES00317 EXT 1 08/07/03 12.49 res00317.ext +RES00318 EXT 1 08/07/03 12.49 res00318.ext +RES00319 EXT 1 08/07/03 12.49 res00319.ext +RES00320 EXT 1 08/07/03 12.49 res00320.ext +RES00321 EXT 1 08/07/03 12.49 res00321.ext +RES00322 EXT 1 08/07/03 12.49 res00322.ext +RES00323 EXT 1 08/07/03 12.49 res00323.ext +RES00324 BMP 630 08/07/03 12.49 res00324.bmp +RES00325 BMP 646 08/07/03 12.49 res00325.bmp +RES00326 BMP 950 08/07/03 12.49 res00326.bmp +RES00327 EXT 1 08/07/03 12.49 res00327.ext +RES00328 EXT 1 08/07/03 12.49 res00328.ext +RES00329 EXT 1 08/07/03 12.49 res00329.ext +RES00330 EXT 1 08/07/03 12.49 res00330.ext +RES00331 EXT 1 08/07/03 12.49 res00331.ext +RES00332 EXT 1 08/07/03 12.49 res00332.ext +RES00333 EXT 1 08/07/03 12.49 res00333.ext +RES00334 EXT 1 08/07/03 12.49 res00334.ext +RES00335 EXT 1 08/07/03 12.49 res00335.ext +RES00336 EXT 1 08/07/03 12.49 res00336.ext +RES00337 EXT 1 08/07/03 12.49 res00337.ext +RES00338 EXT 1 08/07/03 12.49 res00338.ext +RES00339 EXT 1 08/07/03 12.49 res00339.ext +RES00340 EXT 1 08/07/03 12.49 res00340.ext +RES00341 EXT 1 08/07/03 12.49 res00341.ext +RES00342 EXT 1 08/07/03 12.49 res00342.ext +RES00343 EXT 1 08/07/03 12.49 res00343.ext +RES00344 BMP 1.198 08/07/03 12.49 res00344.bmp +RES00345 EXT 1 08/07/03 12.49 res00345.ext +RES00346 BMP 358 08/07/03 12.49 res00346.bmp +RES00347 BMP 342 08/07/03 12.49 res00347.bmp +RES00348 BMP 342 08/07/03 12.49 res00348.bmp +RES00349 BMP 166 08/07/03 12.49 res00349.bmp +RES00350 BMP 238 08/07/03 12.49 res00350.bmp +RES00351 BMP 238 08/07/03 12.49 res00351.bmp +RES00360 PAL 194 08/07/03 12.49 res00360.pal +RES00361 BMP 1.110 08/07/03 12.49 res00361.bmp +RES00362 BMP 310 08/07/03 12.49 res00362.bmp +RES00363 BMP 166 08/07/03 12.49 res00363.bmp +RES00364 BMP 1.078 08/07/03 12.49 res00364.bmp +RES00365 BMP 166 08/07/03 12.49 res00365.bmp +RES00366 BMP 1.078 08/07/03 12.49 res00366.bmp +RES00367 BMP 166 08/07/03 12.49 res00367.bmp +RES00368 BMP 1.078 08/07/03 12.49 res00368.bmp +RES00369 BMP 166 08/07/03 12.49 res00369.bmp +RES00370 BMP 1.078 08/07/03 12.49 res00370.bmp +RES00371 BMP 286 08/07/03 12.49 res00371.bmp +RES00372 BMP 202 08/07/03 12.49 res00372.bmp +RES00373 BMP 454 08/07/03 12.49 res00373.bmp +RES00374 BMP 158 08/07/03 12.49 res00374.bmp +RES00375 BMP 158 08/07/03 12.49 res00375.bmp +RES00376 BMP 158 08/07/03 12.49 res00376.bmp +RES00377 BMP 158 08/07/03 12.49 res00377.bmp +RES01230 BMP 422 08/07/03 12.49 res01230.bmp +RES01231 BMP 454 08/07/03 12.49 res01231.bmp +RES01286 BMP 1.078 08/07/03 12.49 res01286.bmp +RES01287 BMP 1.110 08/07/03 12.49 res01287.bmp +RES01288 BMP 838 08/07/03 12.49 res01288.bmp +RES01289 BMP 622 08/07/03 12.49 res01289.bmp +RES01290 BMP 190 08/07/03 12.49 res01290.bmp +RES01291 BMP 874 08/07/03 12.49 res01291.bmp +RES01301 BMP 1.078 08/07/03 12.49 res01301.bmp +RES01302 BMP 1.078 08/07/03 12.49 res01302.bmp +RES01303 BMP 598 08/07/03 12.49 res01303.bmp +RES01304 BMP 454 08/07/03 12.49 res01304.bmp +RES01305 BMP 390 08/07/03 12.49 res01305.bmp +RES01306 BMP 598 08/07/03 12.49 res01306.bmp +RES01307 BMP 598 08/07/03 12.49 res01307.bmp +RES01308 BMP 598 08/07/03 12.49 res01308.bmp +RES01309 BMP 598 08/07/03 12.49 res01309.bmp +RES01310 BMP 598 08/07/03 12.49 res01310.bmp +RES01311 BMP 486 08/07/03 12.49 res01311.bmp +RES01312 BMP 274 08/07/03 12.49 res01312.bmp +RES01313 BMP 238 08/07/03 12.49 res01313.bmp +RES01314 EXT 33 08/07/03 12.49 res01314.ext +RES01315 EXT 30 08/07/03 12.49 res01315.ext +RES01316 EXT 23 08/07/03 12.49 res01316.ext +RES01317 EXT 14 08/07/03 12.49 res01317.ext +RES01318 EXT 10 08/07/03 12.49 res01318.ext +RES01319 EXT 17 08/07/03 12.49 res01319.ext +RES01320 EXT 21 08/07/03 12.49 res01320.ext +RES01321 EXT 21 08/07/03 12.49 res01321.ext +RES01322 EXT 12 08/07/03 12.49 res01322.ext +RES01323 EXT 9 08/07/03 12.49 res01323.ext +RES01327 BMP 326 08/07/03 12.49 res01327.bmp +RES01328 BMP 238 08/07/03 12.49 res01328.bmp +RES01329 BMP 438 08/07/03 12.49 res01329.bmp +RES01330 BMP 550 08/07/03 12.49 res01330.bmp +RES01331 BMP 534 08/07/03 12.49 res01331.bmp +RES01332 BMP 534 08/07/03 12.49 res01332.bmp +RES01333 BMP 358 08/07/03 12.49 res01333.bmp +RES01334 BMP 130 08/07/03 12.49 res01334.bmp +RES01335 BMP 238 08/07/03 12.49 res01335.bmp +RES01336 BMP 238 08/07/03 12.49 res01336.bmp +RES01337 BMP 278 08/07/03 12.49 res01337.bmp +RES01338 BMP 270 08/07/03 12.49 res01338.bmp +RES01339 BMP 158 08/07/03 12.49 res01339.bmp +RES01340 BMP 326 08/07/03 12.49 res01340.bmp +RES01341 BMP 502 08/07/03 12.49 res01341.bmp +RES01342 BMP 486 08/07/03 12.49 res01342.bmp +RES01343 BMP 454 08/07/03 12.49 res01343.bmp +RES00040 PAL 183 08/07/03 12.44 res00040.pal +RES00041 BMP 32.118 08/07/03 12.44 res00041.bmp +RES00042 EXT 1.656 08/07/03 12.44 res00042.ext +RES00043 EXT 1.620 08/07/03 12.44 res00043.ext +RES00044 EXT 1.822 08/07/03 12.44 res00044.ext +RES00045 EXT 1.459 08/07/03 12.44 res00045.ext +RES00050 PAL 188 08/07/03 12.44 res00050.pal +RES00051 BMP 32.118 08/07/03 12.44 res00051.bmp +RES00052 BMP 3.126 08/07/03 12.44 res00052.bmp +RES00053 BMP 2.038 08/07/03 12.44 res00053.bmp +RES00054 BMP 8.958 08/07/03 12.44 res00054.bmp +RES00055 BMP 1.350 08/07/03 12.44 res00055.bmp +RES02000 PET 2.304 16/04/03 20.35 res02000.pet +RES02001 PET 2.304 16/04/03 20.35 res02001.pet +RES02002 PET 2.304 16/04/03 20.35 res02002.pet +RES02003 PET 2.304 16/04/03 20.35 res02003.pet +RES02004 PET 2.304 16/04/03 20.35 res02004.pet +RES02005 PET 2.304 16/04/03 20.35 res02005.pet +RES02006 PET 2.304 16/04/03 20.35 res02006.pet +RES02007 PET 2.304 16/04/03 20.35 res02007.pet +RES02008 PET 2.304 16/04/03 20.35 res02008.pet +RES02009 PET 2.304 16/04/03 20.35 res02009.pet +RES02010 PET 2.304 16/04/03 20.35 res02010.pet +RES02011 PET 2.304 16/04/03 20.35 res02011.pet +RES02012 PET 2.304 16/04/03 20.35 res02012.pet +RES02013 PET 2.304 16/04/03 20.35 res02013.pet +RES02014 PET 2.304 16/04/03 20.35 res02014.pet +RES02015 PET 2.303 16/04/03 20.35 res02015.pet + 246 archivos 175.570 bytes + 0 directorios 26.423,94 MB libres diff --git a/PR/resources.c b/PR/resources.c new file mode 100644 index 0000000..9b439e0 --- /dev/null +++ b/PR/resources.c @@ -0,0 +1,299 @@ +//Needed files +#include <stdio.h> +#include <stdlib.h> +#include "parser.h" +#include "memory.h" + +/***************************************************************\ +| File format handling | +\***************************************************************/ + +char verifyLevelHeader(char* array, int size) { + return (((size==2306)||(size==2305))&&!(array[1698]&0x0F)&&!(array[1700]&0x0F)&&!(array[1702]&0x0F)); +} + +char verifyImageHeader(char* array, int size) { + //return (size>6) && (!(((!array[1])||(array[2])||(!array[3])||(array[4])||(array[5])||(((unsigned char)array[6]&0xF0)!=0xB0)))); + return (size>7) && (!array[5]) && (((unsigned char)array[6]&0xF0)==0xB0); + //todo: fix the expression +} + +char verifyPaletteHeader(char* array, int size) { + return ((size==101)&&(!array[2])&&(!array[3])&&(array[4]==0x10)); +} + +char verifyMidiHeader(char* array, int size) { + return + (size>6) && + (array[1]==0x02) && + (array[2]=='M') && + (array[3]=='T') && + (array[4]=='h') && + (array[5]=='d') + ; +} + +char verifyWaveHeader(char* array, int size) { + return + (size>1)&&(array[1]==0x01) + ; +} + +char verifyHeader(char* array, int size) { + if (verifyLevelHeader(array,size)) return 1; + if (verifyMidiHeader(array,size)) return 4; + if (verifyImageHeader(array,size)) return 2; + if (verifyPaletteHeader(array,size)) return 6; + if (verifyWaveHeader(array,size)) return 3; + return 05; +} + + +/***************************************************************\ +| Parsing resource file | +\***************************************************************/ + + +//Parse line +void parseResource(tResource* r[], char* line) { + //declare variables + int i=0; + unsigned short int id,ty; + int k=0; + + //Begin parsing + + for (;!(line[k]=='\r'||line[k]=='\n'||(!line[k]));k++); + line[k]=0; + + if (getNumberToken(line,&id,' ',&i,6)) { + r[id]=(tResource*)malloc(sizeof(tResource)); + getNumberToken(line,&(*(r[id])).size,' ',&i,6); + getNumberToken(line,&(*(r[id])).offset,' ',&i,6); + getUpperToken(line,(*(r[id])).file,' ',&i,12); + if (getNumberToken(line,&ty,' ',&i,3)) { + (*(r[id])).desc=(char*)malloc(255); + if (getToken(line,(*(r[id])).desc,'#',&i,255)) { + (*(r[id])).coms=(char*)malloc(1023); + if (!getToken(line,(*(r[id])).coms,0,&i,1023)) { + free ((*(r[id])).coms); + (*(r[id])).coms=NULL; + } + } + } else { + (*(r[id])).desc=NULL; + } + (*(r[id])).type=ty; + } +} + +void emptyTable(tResource* r[]) { + for (int i=0;i<65536;i++) r[i]=NULL; +} + +//parse file +char parseFile(char* vFile,tResource* r[]) { + //declare variables + char parsing=0; + char line[MAX_LINE_SIZE]; + char token[MAX_LINE_SIZE]; + char B[]=BEGIN_TABLE; + char E[]=END_TABLE; + FILE* fp; + + //empty resource array + emptyTable(r); + + //parse file + if ((fp=fopen(vFile,"rt"))!=NULL) { + while (fgets(line,MAX_LINE_SIZE,fp)!=NULL) { + if (parsing) { + if (equals(line,E)) { + parsing=0; + } else { + parseResource(r,line); + } + } else { + if (equals(line,B)) parsing=1; + } + } + fclose(fp); + return 1; + } else { + return 0; + } +} + +//generate file +char generateFile(char* vFile,tResource* r[]) { + //declare variables + char parsing=0; + char line[MAX_LINE_SIZE]; + char coms[MAX_LINE_SIZE]; + char B[]=BEGIN_TABLE; + char E[]=END_TABLE; + char none[]=""; + FILE* fp; + FILE* source; + + if ((fp=fopen("res.tmp","wt"))!=NULL) { + //insert headers + if ((source=fopen(vFile,"rt"))!=NULL) { + while ((parsing!=2)&&(fgets(line,MAX_LINE_SIZE,source)!=NULL)) { + if (parsing) { + if (equals(line,E)) { + parsing=2; + } + } else { + if (equals(line,B)) { + parsing=1; + } else { + fputs(line,fp); + } + } + } + } + + //insert main body file + fputs(B,fp); + fputs("\n",fp); + for (int id=0;id<65536;id++) { + if (r[id]!=NULL) { + if ((*(r[id])).desc==NULL) { + if ((*(r[id])).coms==NULL) { + sprintf(coms,none); + } else { + sprintf(coms," #",(*(r[id])).coms); + } + } else { + if ((*(r[id])).coms==NULL) { + sprintf(coms," %s",(*(r[id])).desc); + } else { + sprintf(coms," %s#%s",(*(r[id])).desc,(*(r[id])).coms); + } + } + sprintf(line,"%05d %05d %05d %s %02d%s\n", + id, + (*(r[id])).size, + (*(r[id])).offset, + (*(r[id])).file, + (*(r[id])).type, + coms); + fputs(line,fp); + } + } + fputs("\n",fp); + fputs(E,fp); + + //insert footers + if (source!=NULL) { + while ((parsing==2) && (fgets(line,MAX_LINE_SIZE,source)!=NULL)) { + fputs(line,fp); + } + fclose(source); + } + fclose(fp); + remove(vFile); + rename("res.tmp",vFile); + return 1; + } else { + return 0; + } +} + +//Resources extras + +void getFileName(char* vFileext,char* vDirExt,char type, unsigned short int id) { + char extMidi[] = "mid"; + char extWave[] = "wav"; + char extBmp[] = "bmp"; + char extLevel[] = "pet"; + char extExtra[] = "ext"; + char extRaw[] = "raw"; + char extPal[] = "pal"; + char* ext; + + switch (type) { + case 0: + ext=extRaw; + break; + case 1: + ext=extLevel; + break; + case 2: + ext=extBmp; + break; + case 4: + ext=extMidi; + break; + case 3: + ext=extWave; + break; + case 6: + ext=extPal; + break; + default: + ext=extExtra; + break; + } + + //set filename + sprintf(vFileext,"%s%cres%05d.%s",vDirExt,DIR_SEPARATOR,id,ext); +} + +void getUpperFolder(char* aux, char* vFiledat) { + int i=0; + while (getUpperToken(vFiledat,aux,DIR_SEPARATOR,&i,260)); + aux[12]=0; +} + + + + + + + + +//File handling functions + + + + +int mLoadFileArray(char* vFile,unsigned char** array) { + //declare variables + FILE *fp; + int aux; + + //Open the file + if ((fp=fopen(vFile,"rb"))==NULL) { + return 0; + } else { + //get file size + fseek(fp,0,SEEK_END); + aux=ftell(fp); + if ( !aux || (aux>SIZE_OF_FILE) || ( ((*array=(char*)malloc(sizeof(char)*aux))==NULL) ) ) { + //if the file was null or bigger than the max size or couldn't allocate the file in memory + fclose(fp); + return 0; + } else { + //if the filewas succesfully open + fseek(fp,0,SEEK_SET); + aux=fread (*array,1,aux,fp); + fclose(fp); + return aux; + } + } +} + +char mSaveRaw(char* vFile,unsigned char* output, int size) { + FILE * pFile; + if ((pFile = fopen (vFile , "wb"))==NULL) { + return 0; + } + if (!size) { + return 0; + } + fwrite (output, 1, size, pFile); + fclose (pFile); + return 1; +} diff --git a/PR/resources.h b/PR/resources.h new file mode 100644 index 0000000..2905db2 --- /dev/null +++ b/PR/resources.h @@ -0,0 +1,56 @@ + +#ifndef _RESOURCES_H_ +#define _RESOURCES_H_ + +#define HEADER "Princed V3.0 alpha game resources list\n(c) Copyright 2003 - Enrique P. Calot\n(c) Copyright 2003 - Princed Development Team\n\nSyntax:\nId Size Offset File Type Description Comments\nXXXXX YYYYY ZZZZZ SSSSSSSS.DAT TT Ddddddddddddd... #cccccccc....\n\nComments are optional\n\nNote:\n You can edit description and commets here in the file and\n they will be saved in the dat files.\n\nResource Types:\n 01 Levels\n 02 Bitmaps\n 03 Waves\n 04 Midis\n" +#define BEGIN_TABLE "BEGIN resources table\n" +#define END_TABLE "END resources table\n" + +#define MAX_LINE_SIZE 300 + +//types +typedef struct { + unsigned short int size; + unsigned short int offset; + char file[13]; + char type; + char* desc; + char* coms; +}tResource; + +//Verify header +char verifyHeader(char* array, int size); + +/* + Headers may be: + 01 Levels + 02 Bitmaps + 03 Waves + 04 Midis + 05 Undefined + 06 Palette +*/ + +/***************************************************************\ +| File format handling | +\***************************************************************/ + +//Empty resource table +void emptyTable(tResource* r[]); + +//parse file +char parseFile(char* vFile,tResource* r[]); + +//generate file +char generateFile(char* vFile,tResource* r[]); + +//Resources extras + +void getFileName(char* vFileext,char* vDirExt,char type, unsigned short int id); +void getUpperFolder(char* aux, char* vFiledat); + +//File handrling +int mLoadFileArray(char* vFile,unsigned char** array); +char mSaveRaw(char* vFile,unsigned char* output, int size); + +#endif diff --git a/PR/resources.txt b/PR/resources.txt new file mode 100644 index 0000000..37a18dd --- /dev/null +++ b/PR/resources.txt @@ -0,0 +1,256 @@ +Princed V3.0 alpha game resources list +(c) Copyright 2003 - Princed Development Team +http://www.princed.com.ar + +*** Game resources table + +Syntax: +Id Size Offset File Type Description Comments +XXXXX YYYYY ZZZZZ SSSSSSSS.DAT TT Ddddddddddddd... #cccccccc.... + +Comments are optional + +Note: + You can edit description and commets here in the file and + they will be saved in the dat files. + +Resource Types: + 01 Levels + 02 Bitmaps + 03 Waves + 04 Midis + 05 Undefined + 06 Palette + 07 to 10 reserved + +BEGIN resources table + +00200 00100 00006 VDUNGEON.DAT 00 +00201 00002 00107 VDUNGEON.DAT 00 +00202 00002 00110 VDUNGEON.DAT 00 +00203 00002 00113 VDUNGEON.DAT 00 +00204 00002 00116 VDUNGEON.DAT 00 +00205 00002 00119 VDUNGEON.DAT 00 +00206 00002 00122 VDUNGEON.DAT 00 +00207 00002 00125 VDUNGEON.DAT 00 +00208 00002 00128 VDUNGEON.DAT 00 +00209 00002 00131 VDUNGEON.DAT 00 +00210 00002 00134 VDUNGEON.DAT 00 +00211 00002 00137 VDUNGEON.DAT 00 +00212 00002 00140 VDUNGEON.DAT 00 +00213 00002 00143 VDUNGEON.DAT 00 +00214 00002 00146 VDUNGEON.DAT 00 +00215 00002 00149 VDUNGEON.DAT 00 +00216 00002 00152 VDUNGEON.DAT 00 +00217 00002 00155 VDUNGEON.DAT 00 +00218 00002 00158 VDUNGEON.DAT 00 +00219 00002 00161 VDUNGEON.DAT 00 +00220 00002 00164 VDUNGEON.DAT 00 +00221 00002 00167 VDUNGEON.DAT 00 +00222 00002 00170 VDUNGEON.DAT 00 +00223 00002 00173 VDUNGEON.DAT 00 +00224 00002 00176 VDUNGEON.DAT 00 +00225 00002 00179 VDUNGEON.DAT 00 +00226 00002 00182 VDUNGEON.DAT 00 +00227 00002 00185 VDUNGEON.DAT 00 +00228 00002 00188 VDUNGEON.DAT 00 +00229 00002 00191 VDUNGEON.DAT 00 +00230 00002 00194 VDUNGEON.DAT 00 +00231 00002 00197 VDUNGEON.DAT 00 +00232 00039 00200 VDUNGEON.DAT 00 +00233 00088 00240 VDUNGEON.DAT 00 +00234 00082 00329 VDUNGEON.DAT 00 +00235 00082 00412 VDUNGEON.DAT 00 +00236 00015 00495 VDUNGEON.DAT 00 +00237 00086 00511 VDUNGEON.DAT 00 +00238 00065 00598 VDUNGEON.DAT 00 +00239 00102 00664 VDUNGEON.DAT 00 +00240 00059 00767 VDUNGEON.DAT 00 +00241 00101 00827 VDUNGEON.DAT 00 +00242 00112 00929 VDUNGEON.DAT 00 +00243 00018 01042 VDUNGEON.DAT 00 +00244 00129 01061 VDUNGEON.DAT 00 +00245 00098 01191 VDUNGEON.DAT 00 +00246 00100 01290 VDUNGEON.DAT 00 +00247 00125 01391 VDUNGEON.DAT 00 +00248 00022 01517 VDUNGEON.DAT 00 +00249 00018 01540 VDUNGEON.DAT 00 +00250 00051 01559 VDUNGEON.DAT 00 +00251 00041 01611 VDUNGEON.DAT 00 +00252 00073 01653 VDUNGEON.DAT 00 +00253 00066 01727 VDUNGEON.DAT 00 +00254 00060 01794 VDUNGEON.DAT 00 +00255 00051 01855 VDUNGEON.DAT 00 +00256 00047 01907 VDUNGEON.DAT 00 +00257 00035 01955 VDUNGEON.DAT 00 +00258 00030 01991 VDUNGEON.DAT 00 +00259 00018 02022 VDUNGEON.DAT 00 +00260 00061 02041 VDUNGEON.DAT 00 +00261 00056 02103 VDUNGEON.DAT 00 +00262 00037 02160 VDUNGEON.DAT 00 +00263 00043 02198 VDUNGEON.DAT 00 +00264 00049 02242 VDUNGEON.DAT 00 +00265 00047 02292 VDUNGEON.DAT 00 +00266 00054 02340 VDUNGEON.DAT 00 +00267 00060 02395 VDUNGEON.DAT 00 +00268 00024 02456 VDUNGEON.DAT 00 +00269 00107 02481 VDUNGEON.DAT 00 +00270 00087 02589 VDUNGEON.DAT 00 +00271 00116 02677 VDUNGEON.DAT 00 +00272 00116 02794 VDUNGEON.DAT 00 +00273 00026 02911 VDUNGEON.DAT 00 +00274 00024 02938 VDUNGEON.DAT 00 +00275 00002 02963 VDUNGEON.DAT 00 +00276 00002 02966 VDUNGEON.DAT 00 +00277 00002 02969 VDUNGEON.DAT 00 +00278 00002 02972 VDUNGEON.DAT 00 +00279 00002 02975 VDUNGEON.DAT 00 +00280 00002 02978 VDUNGEON.DAT 00 +00281 00002 02981 VDUNGEON.DAT 00 +00282 00002 02984 VDUNGEON.DAT 00 +00283 00002 02987 VDUNGEON.DAT 00 +00284 00002 02990 VDUNGEON.DAT 00 +00285 00016 02993 VDUNGEON.DAT 00 +00286 00002 03010 VDUNGEON.DAT 00 +00287 00002 03013 VDUNGEON.DAT 00 +00288 00002 03016 VDUNGEON.DAT 00 +00289 00002 03019 VDUNGEON.DAT 00 +00290 00002 03022 VDUNGEON.DAT 00 +00291 00002 03025 VDUNGEON.DAT 00 +00292 00239 03028 VDUNGEON.DAT 00 +00293 00386 03268 VDUNGEON.DAT 00 +00294 00030 03655 VDUNGEON.DAT 00 +00295 00180 03686 VDUNGEON.DAT 00 +00296 00016 03867 VDUNGEON.DAT 00 +00297 00169 03884 VDUNGEON.DAT 00 +00298 00152 04054 VDUNGEON.DAT 00 +00299 00020 04207 VDUNGEON.DAT 00 +00300 00123 04228 VDUNGEON.DAT 00 +00301 00002 04352 VDUNGEON.DAT 00 +00302 00002 04355 VDUNGEON.DAT 00 +00303 00002 04358 VDUNGEON.DAT 00 +00304 00002 04361 VDUNGEON.DAT 00 +00305 00002 04364 VDUNGEON.DAT 00 +00306 00002 04367 VDUNGEON.DAT 00 +00307 00002 04370 VDUNGEON.DAT 00 +00308 00002 04373 VDUNGEON.DAT 00 +00309 00002 04376 VDUNGEON.DAT 00 +00310 00002 04379 VDUNGEON.DAT 00 +00311 00002 04382 VDUNGEON.DAT 00 +00312 00002 04385 VDUNGEON.DAT 00 +00313 00002 04388 VDUNGEON.DAT 00 +00314 00002 04391 VDUNGEON.DAT 00 +00315 00002 04394 VDUNGEON.DAT 00 +00316 00002 04397 VDUNGEON.DAT 00 +00317 00002 04400 VDUNGEON.DAT 00 +00318 00002 04403 VDUNGEON.DAT 00 +00319 00002 04406 VDUNGEON.DAT 00 +00320 00002 04409 VDUNGEON.DAT 00 +00321 00002 04412 VDUNGEON.DAT 00 +00322 00002 04415 VDUNGEON.DAT 00 +00323 00002 04418 VDUNGEON.DAT 00 +00324 00104 04421 VDUNGEON.DAT 00 +00325 00116 04526 VDUNGEON.DAT 00 +00326 00516 04643 VDUNGEON.DAT 00 +00327 00002 05160 VDUNGEON.DAT 00 +00328 00002 05163 VDUNGEON.DAT 00 +00329 00002 05166 VDUNGEON.DAT 00 +00330 00002 05169 VDUNGEON.DAT 00 +00331 00002 05172 VDUNGEON.DAT 00 +00332 00002 05175 VDUNGEON.DAT 00 +00333 00002 05178 VDUNGEON.DAT 00 +00334 00002 05181 VDUNGEON.DAT 00 +00335 00002 05184 VDUNGEON.DAT 00 +00336 00002 05187 VDUNGEON.DAT 00 +00337 00002 05190 VDUNGEON.DAT 00 +00338 00002 05193 VDUNGEON.DAT 00 +00339 00002 05196 VDUNGEON.DAT 00 +00340 00002 05199 VDUNGEON.DAT 00 +00341 00002 05202 VDUNGEON.DAT 00 +00342 00002 05205 VDUNGEON.DAT 00 +00343 00002 05208 VDUNGEON.DAT 00 +00344 00085 05211 VDUNGEON.DAT 00 +00345 00002 05297 VDUNGEON.DAT 00 +00346 00038 05300 VDUNGEON.DAT 00 +00347 00105 05339 VDUNGEON.DAT 00 +00348 00105 05445 VDUNGEON.DAT 00 +00349 00016 05551 VDUNGEON.DAT 00 +00350 00048 05568 VDUNGEON.DAT 00 +00351 00046 05617 VDUNGEON.DAT 00 +00360 00100 05664 VDUNGEON.DAT 00 +00361 00204 05765 VDUNGEON.DAT 00 +00362 00066 05970 VDUNGEON.DAT 00 +00363 00010 06037 VDUNGEON.DAT 00 +00364 00251 06048 VDUNGEON.DAT 00 +00365 00016 06300 VDUNGEON.DAT 00 +00366 00348 06317 VDUNGEON.DAT 00 +00367 00022 06666 VDUNGEON.DAT 00 +00368 00344 06689 VDUNGEON.DAT 00 +00369 00026 07034 VDUNGEON.DAT 00 +00370 00328 07061 VDUNGEON.DAT 00 +00371 00047 07390 VDUNGEON.DAT 00 +00372 00040 07438 VDUNGEON.DAT 00 +00373 00108 07479 VDUNGEON.DAT 00 +00374 00040 07588 VDUNGEON.DAT 00 +00375 00040 07629 VDUNGEON.DAT 00 +00376 00041 07670 VDUNGEON.DAT 00 +00377 00041 07712 VDUNGEON.DAT 00 +01230 00154 07754 VDUNGEON.DAT 00 +01231 00132 07909 VDUNGEON.DAT 00 +01286 00217 08042 VDUNGEON.DAT 00 +01287 00262 08260 VDUNGEON.DAT 00 +01288 00183 08523 VDUNGEON.DAT 00 +01289 00113 08707 VDUNGEON.DAT 00 +01290 00039 08821 VDUNGEON.DAT 00 +01291 00147 08861 VDUNGEON.DAT 00 +01301 00436 09009 VDUNGEON.DAT 00 +01302 00421 09446 VDUNGEON.DAT 00 +01303 00202 09868 VDUNGEON.DAT 00 +01304 00154 10071 VDUNGEON.DAT 00 +01305 00130 10226 VDUNGEON.DAT 00 +01306 00131 10357 VDUNGEON.DAT 00 +01307 00134 10489 VDUNGEON.DAT 00 +01308 00129 10624 VDUNGEON.DAT 00 +01309 00091 10754 VDUNGEON.DAT 00 +01310 00071 10846 VDUNGEON.DAT 00 +01311 00163 10918 VDUNGEON.DAT 00 +01312 00091 11082 VDUNGEON.DAT 00 +01313 00068 11174 VDUNGEON.DAT 00 +01314 00034 11243 VDUNGEON.DAT 00 +01315 00031 11278 VDUNGEON.DAT 00 +01316 00024 11310 VDUNGEON.DAT 00 +01317 00015 11335 VDUNGEON.DAT 00 +01318 00011 11351 VDUNGEON.DAT 00 +01319 00018 11363 VDUNGEON.DAT 00 +01320 00022 11382 VDUNGEON.DAT 00 +01321 00022 11405 VDUNGEON.DAT 00 +01322 00013 11428 VDUNGEON.DAT 00 +01323 00010 11442 VDUNGEON.DAT 00 +01327 00107 11453 VDUNGEON.DAT 00 +01328 00019 11561 VDUNGEON.DAT 00 +01329 00054 11581 VDUNGEON.DAT 00 +01330 00081 11636 VDUNGEON.DAT 00 +01331 00079 11718 VDUNGEON.DAT 00 +01332 00068 11798 VDUNGEON.DAT 00 +01333 00120 11867 VDUNGEON.DAT 00 +01334 00014 11988 VDUNGEON.DAT 00 +01335 00038 12003 VDUNGEON.DAT 00 +01336 00047 12042 VDUNGEON.DAT 00 +01337 00047 12090 VDUNGEON.DAT 00 +01338 00047 12138 VDUNGEON.DAT 00 +01339 00016 12186 VDUNGEON.DAT 00 +01340 00046 12203 VDUNGEON.DAT 00 +01341 00073 12250 VDUNGEON.DAT 00 +01342 00070 12324 VDUNGEON.DAT 00 +01343 00057 12395 VDUNGEON.DAT 00 + +END resources table + +BEGIN palette table +END palette table + +BEGIN block table +END block table + + +You can write notes here diff --git a/PR/src/addons/vb/pr.bas b/PR/src/addons/vb/pr.bas new file mode 100644 index 0000000..9e8e2cb --- /dev/null +++ b/PR/src/addons/vb/pr.bas @@ -0,0 +1,79 @@ +Attribute VB_Name = "Module1" +'pr.dll V2.0 declaration for Visual Basic +'PR is a Princed Development Team work +'check for the latest version at http://www.princed.com.ar + +'Enumerations + +'Resource type +enum prResourceType + prResMemoryError=-2 + prResFileNotFoundError=-1 + + prResInvalidDatFile=00 + + prResLevelFile=01 + prResGraphicExtFile=02 + prResWaveFile=03 + prResMidiFile=04 + prResValidUnknownFile=05 + prResGraphicFile=06 + +end + +'Export +enum prExportResult + prExpMemoryError=-2 + prExpAccessDenied=-1 + prExpOk=0 +end + +enum prExportOpt 'To use more than one option separate them with "+". + prExpExtract=1 'If this option is not given, the files won't be extracted + prExpUpdate=2 'This will update the resource file + prExpUseRaw=4 'This will extract to raw files + prExpDontSave=8 'Running the function using this option will perform all + ' commands but without saving the changes in resource file + ' (update option will be ignored) +end + +'Import +enum prImportResult + prImpAccessDenied=-1 + prImpOk=0 + 'Note: If the file was parcially compiled a positive number of files missing will be returned +end + +enum prImportOpt + prImpUseRaw=0 + prImpReadDataType=1 +end + +'This function will extract vDatFile into vDirName adding the extracted files in vResFilename +Public Declare Function prExportDat Lib "pr.dll" Alias "_prExportDat" (ByVal vDatFile As String, ByVal vDirName As String, ByVal vResFilename As String) As Integer +'This function will import the files located in vDirName into vDatFile acording to the information read in vResFilename +Public Declare Function prImportDat Lib "pr.dll" Alias "_prImportDat" (ByVal vDatFile As String, ByVal vDirName As String, ByVal vResFilename As String) As Integer +'This function will clear vResFilename information table but It will keep the file header and foot +Public Declare Function prClearRes Lib "pr.dll" Alias "_prClearRes" (ByVal vResFilename As String) As Integer +'This function will verify if the vDatFile exists, id it is a valid POP1 DAT file, and what kind of DAT file it is +Public Declare Function prVerifyDatType Lib "pr.dll" Alias "_prVerifyDatType" (ByVal vDatFile As String) As integer + +' verifyDatType return values may be: +' -2 PR internal Memory error (only if RAM is too low) +' -1 File not found +' +' 00 Not a valid POP1 DAT file +' +' 01 Levels file +' 02 Graphic file with an image in the first valid entry (not common) +' 03 Waves/Digital sound file +' 04 Midis file +' 05 Valid DAT file with Undefined content (example ibmsnd for the moment) +' 06 Graphic file with a palette in the first valid entry (common) + +' extended functions + +Public Declare Function prVerifyDatTypeRes Lib "pr.dll" Alias "_prVerifyDatType" (ByVal vDatFile As String) As prResourceType +Public Declare Function prClearResBool Lib "pr.dll" Alias "_prClearRes" (ByVal vResFilename As String) As Boolean +Public Declare Function prExportDatOpt Lib "pr.dll" Alias "_prExportDatOpt" (ByVal vDatFile As String, ByVal vDirName As String, ByVal vResFilename As String, ByVal vExportOpt as prExportOpt) As prExportResult +Public Declare Function prImportDatOpt Lib "pr.dll" Alias "_prImportDatOpt" (ByVal vDatFile As String, ByVal vDirName As String, ByVal vResFilename As String, ByVal vImportOpt as prImportOpt) As prImportResult diff --git a/PR/src/addons/vb/samples/Text3 b/PR/src/addons/vb/samples/Text3 new file mode 100644 index 0000000..3eab137 --- /dev/null +++ b/PR/src/addons/vb/samples/Text3 @@ -0,0 +1,4 @@ +BEGIN resources table + + +END resources table diff --git a/PR/src/addons/vb/samples/pr.dll b/PR/src/addons/vb/samples/pr.dll new file mode 100644 index 0000000..60f5994 Binary files /dev/null and b/PR/src/addons/vb/samples/pr.dll differ diff --git a/PR/src/addons/vb/samples/prsample.exe b/PR/src/addons/vb/samples/prsample.exe new file mode 100755 index 0000000..1d64181 Binary files /dev/null and b/PR/src/addons/vb/samples/prsample.exe differ diff --git a/PR/src/addons/vb/samples/prsample.vbp b/PR/src/addons/vb/samples/prsample.vbp new file mode 100644 index 0000000..8723e90 --- /dev/null +++ b/PR/src/addons/vb/samples/prsample.vbp @@ -0,0 +1,32 @@ +Type=Exe +Form=prtest1.frm +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\SYSTEM\Stdole2.tlb#OLE Automation +Module=Module1; pr.bas +IconForm="Form1" +Startup="Form1" +ExeName32="prsample.exe" +Command32="" +Name="Project1" +HelpContextID="0" +CompatibleMode="0" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="Princed Development Team" +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=0 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 diff --git a/PR/src/addons/vb/samples/prsample.vbw b/PR/src/addons/vb/samples/prsample.vbw new file mode 100644 index 0000000..71df962 --- /dev/null +++ b/PR/src/addons/vb/samples/prsample.vbw @@ -0,0 +1,2 @@ +Form1 = 110, 110, 485, 456, , 88, 88, 463, 434, C +Module1 = 132, 132, 507, 478, Z diff --git a/PR/src/addons/vb/samples/prtest1.frm b/PR/src/addons/vb/samples/prtest1.frm new file mode 100644 index 0000000..d732b0a --- /dev/null +++ b/PR/src/addons/vb/samples/prtest1.frm @@ -0,0 +1,116 @@ +VERSION 5.00 +Begin VB.Form Form1 + Caption = "PR sample program" + ClientHeight = 1860 + ClientLeft = 60 + ClientTop = 345 + ClientWidth = 6720 + LinkTopic = "Form1" + ScaleHeight = 1860 + ScaleWidth = 6720 + StartUpPosition = 3 'Windows Default + Begin VB.CommandButton Command4 + Caption = "Clear" + Height = 375 + Left = 5280 + TabIndex = 9 + Top = 120 + Width = 1335 + End + Begin VB.CommandButton Command3 + Caption = "Classify" + Height = 375 + Left = 3720 + TabIndex = 8 + Top = 120 + Width = 1455 + End + Begin VB.CommandButton Command2 + Caption = "Export" + Height = 375 + Left = 1920 + TabIndex = 7 + Top = 120 + Width = 1695 + End + Begin VB.TextBox Text3 + Height = 285 + Left = 1320 + TabIndex = 3 + Text = "Text3" + Top = 1440 + Width = 5295 + End + Begin VB.TextBox Text2 + Height = 285 + Left = 1320 + TabIndex = 2 + Text = "Text2" + Top = 1080 + Width = 5295 + End + Begin VB.TextBox Text1 + Height = 285 + Left = 1320 + TabIndex = 1 + Text = "Text1" + Top = 720 + Width = 5295 + End + Begin VB.CommandButton Command1 + Caption = "Import" + Height = 375 + Left = 0 + TabIndex = 0 + Top = 120 + Width = 1815 + End + Begin VB.Label Label3 + Caption = "resource file" + Height = 255 + Left = 120 + TabIndex = 6 + Top = 1440 + Width = 1095 + End + Begin VB.Label Label2 + Caption = "resources dir" + Height = 255 + Left = 120 + TabIndex = 5 + Top = 1080 + Width = 975 + End + Begin VB.Label d + Caption = "dat file" + Height = 255 + Left = 120 + TabIndex = 4 + Top = 720 + Width = 615 + End +End +Attribute VB_Name = "Form1" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = False +Private Sub Command1_Click() + result = prImportDat(Text1.Text, Text2.Text, Text3.Text) + MsgBox ("The given result was " & result) +End Sub + +Private Sub Command2_Click() + result = prExportDat(Text1.Text, Text2.Text, Text3.Text) + MsgBox ("The given result was " & result) +End Sub + +Private Sub Command3_Click() + result = prVerifyDatType(Text1.Text) + MsgBox ("The given result was " & result) +End Sub + +Private Sub Command4_Click() + result = prClearRes(Text3.Text) + MsgBox ("The given result was " & result) +End Sub diff --git a/PR/src/addons/vb/samples/prvbdll.zip b/PR/src/addons/vb/samples/prvbdll.zip new file mode 100644 index 0000000..991cb8b Binary files /dev/null and b/PR/src/addons/vb/samples/prvbdll.zip differ diff --git a/PR/src/lib/formats/Attic/bmp.c b/PR/src/lib/formats/Attic/bmp.c new file mode 100644 index 0000000..6ff45a4 --- /dev/null +++ b/PR/src/lib/formats/Attic/bmp.c @@ -0,0 +1,178 @@ +#if DIR_SEPARATOR=='/' +#include "bmp.h" +#else +#include "formats/bmp.h" +#endif + +char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res) { + int size; + tImage img; + if (!mReadBitMap(&img,data,(*res).size)) return 0; + free(data); + mCompressGraphic(data,img,&size); + free(img.pix); + mAddFileToDatFile(fp,data,size); + return 1; +} + +char mWriteBitMap(tImage img,char* vFile) { + //declare variables + unsigned char i=0; + unsigned char j=0; + FILE* bitmap; + if ((bitmap = fopen (vFile,"wb"))==NULL) return 0; + + unsigned long int filesize=((img.size+1)/2+118); + unsigned long int width=img.width; + unsigned long int height=img.height; + + 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 + }; + + //TODO: avoid using header array andwrite everithing in one run + + header[2]=filesize; + header[3]=filesize>>8; + header[4]=filesize>>16; + header[5]=filesize>>24; + + header[18]=width; + header[19]=width>>8; + + header[22]=height; + header[23]=height>>8; + +//BEGIN of format writing + //Write ColorTable + char b; + char c; + for (char a=0;a<16;a++) { + b=a*3; + c=a<<2; + header[54+c]=(img.pal[b+2])*4; //Red + header[55+c]=(img.pal[b+1])*4; //Green + header[56+c]=(img.pal[b])*4; //Blue + } + //Write header + fwrite(header,118,1,bitmap); + //Write data + char junk[3]={0,0,0}; + 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,char* data, int size) { + //add validations + //printf("tllego 1\r\n"); + + char ok; + unsigned short int width; + unsigned short int height; + + ok = size>118; + ok=ok&& data[0]=='B' && data[1]=='M'; + + width=data[18]; + width+=data[19]<<8; + + height=data[22]; + height+=data[23]<<8; + + (*img).width=width; + (*img).height=height; + (*img).size=height*width; + ok=ok&& (((((*img).size))/2)==(size-118)); + ok=ok&& ( + ( + (*img).pix=getMemory( + (((*img).size))/2 + ) + )!=NULL + ); + + if (!ok) { + if ((*img).pix!=NULL) free((*img).pix); + return 0; //this is not a valid bmp file format + } + + width=(width+1)>>1; + int width2=width+((-width)&3); + +/* while (img.height--) { + for (int x=0;x<width;x++) { + *(6+img.pix+height*img.width)=data+118+height*width2 + fwrite(img.pix+img.height*img.width,img.width,1,bitmap); + fwrite(junk,(-img.width)&3,1,bitmap); + } +*/ + int x=0; + while (height--) { + memcpy(6+(*img).pix+(x++)*(*img).width,data+118+height*width2,width); + } + + + +// printf("tllego 4 %d %d %d\r\n",((*img).size)/2,size-118,(*img).pix); +// memcpy(data+118,(*img).pix,(((*img).size)/2)); +/* +img.width=img.width+(img.width&1); +for (int h=img.height-1;h>=0;--h) { + for (int w=0;w<img.width;w++) { + mBmpWritePixel(bitmap,mBmpGetPixel(img,w,h),&i,&j); + } + //align by 4 + for (int w=img.width;w&7;w++) { + mBmpWritePixel(bitmap,5,&i,&j); + } + +} + +*/ + + +// printf("tllego 5\r\n"); + + + return 1; +} diff --git a/PR/src/lib/formats/Attic/mid.c b/PR/src/lib/formats/Attic/mid.c new file mode 100644 index 0000000..e69de29 diff --git a/PR/src/lib/formats/Attic/pal.c b/PR/src/lib/formats/Attic/pal.c new file mode 100644 index 0000000..c455b97 --- /dev/null +++ b/PR/src/lib/formats/Attic/pal.c @@ -0,0 +1,70 @@ + +#if DIR_SEPARATOR=='/' +#include "pal.h" +#else +#include "formats/pal.h" +#endif + +/***************************************************************\ +| Jasc Palette handling functions | +\***************************************************************/ + +char mImportPalette(unsigned char** data, unsigned short *size) { + //check size + if (*size<130) return 0; + + //declare variables + unsigned char palh[]=PAL_HEADER; + unsigned char pals[]=PAL_SAMPLE; + unsigned char* pal=getMemory(101); + unsigned short int parsed; + int i=0; + + //set palette with sample + memcpy(pal,pals,101); + + //set current values + while (palh[i]==(*data)[i++]); + if (i!=sizeof(palh)) return 0; + for (int k=0;k<16;k++) { + getNumberToken((*data),&parsed,' ',&i,4); + pal[(k*3)+5]=(parsed+2)>>2; + getNumberToken((*data),&parsed,' ',&i,4); + pal[(k*3)+6]=(parsed+2)>>2; + getNumberToken((*data),&parsed,'\r',&i,4); + pal[(k*3)+7]=(parsed+2)>>2; + i++; + } + + //free old data and set new + free(*data); + *data=pal; + *size=101; + return 1; +} + +void mExportPalette(unsigned char** data, unsigned long int *size) { + unsigned char* pal=getMemory(240); + unsigned char* aux=getMemory(240); + + sprintf(pal,PAL_HEADER); + + unsigned char i; + for (i=0;i<16;i++) { + sprintf(aux,pal); + sprintf(pal,"%s%d %d %d\r\n",aux,(*data)[(i*3)+5]<<2,(*data)[(i*3)+6]<<2,(*data)[(i*3)+7]<<2); + } + for (i=0;pal[i];i++); + free(*data); + free(aux); + (*data)=pal; + *size=i-1; +} + +void mLoadPalette(char* array,tImage *image) { + int k=0; + for (int i=5;i<5+16*3;i++) { + (*image).pal[k++]=array[i]; + } +} + diff --git a/PR/src/lib/formats/Attic/wav.c b/PR/src/lib/formats/Attic/wav.c new file mode 100644 index 0000000..e602b6e --- /dev/null +++ b/PR/src/lib/formats/Attic/wav.c @@ -0,0 +1,42 @@ +#if DIR_SEPARATOR=='/' +#include "wav.h" +#include "../compile.h" +#else +#include "formats/wav.h" +#include "compile.h" +#endif + +char mFormatExtractWav(unsigned char* data, char *vFileext,unsigned long int size) { + + unsigned char wav[]=WAVE_HEADER; + FILE* target; + char ok; + + size-=2; + ok=((target=fopen(vFileext,"wb"))!=NULL); + wav[4]=(size+36)&0xFF; + wav[5]=((size+36)>>8)&0xFF; + wav[6]=((size+36)>>16)&0xFF; + wav[7]=((size+36)>>24)&0xFF; + + wav[40]=(size)&0xFF; + wav[41]=((size)>>8)&0xFF; + wav[42]=((size)>>16)&0xFF; + wav[43]=((size)>>24)&0xFF; + ok=ok&&fwrite(wav,sizeof(wav),1,target); + ok=ok&&fwrite(data+2,size-2,1,target); + ok=ok&&(!fclose(target)); + + return ok; +} + +char mFormatCompileWav(unsigned char* data, FILE* fp, tResource *res) { + unsigned char wav[]=WAVE_HEADER; + int i=sizeof(wav); + 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; + if (i==-1) mAddFileToDatFile(fp,data+sizeof(wav)-1,(*res).size); + return 1; +} diff --git a/PR/src/lib/formats/bmp.h b/PR/src/lib/formats/bmp.h new file mode 100644 index 0000000..a4eaf59 --- /dev/null +++ b/PR/src/lib/formats/bmp.h @@ -0,0 +1,18 @@ + +#ifndef _BMP_H_ +#define _BMP_H_ + +#include <stdio.h> +#if DIR_SEPARATOR=='/' +#include "../pg.h" +#include "../resources.h" +#else +#include "pg.h" +#include "resources.h" +#endif + +char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res); +char mWriteBitMap(tImage img,char* vFile); +char mReadBitMap(tImage* img,char* data, int size); //Note: this will ignore the palette + +#endif diff --git a/PR/src/lib/formats/mid.h b/PR/src/lib/formats/mid.h new file mode 100644 index 0000000..e69de29 diff --git a/PR/src/lib/formats/pal.h b/PR/src/lib/formats/pal.h new file mode 100644 index 0000000..3ca6b80 --- /dev/null +++ b/PR/src/lib/formats/pal.h @@ -0,0 +1,24 @@ + +/***************************************************************\ +| Jasc Palette handling functions | +\***************************************************************/ + +#ifndef _PAL_H_ +#define _PAL_H_ + +#if DIR_SEPARATOR=='/' +#include "../pg.h" +#else +#include "pg.h" +#endif + +#define PAL_HEADER "JASC-PAL\r\n0100\r\n16\r\n" +#define PAL_SAMPLE {0xB4, 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 mImportPalette(unsigned char** data, unsigned short *size); +void mExportPalette(unsigned char** data, unsigned long int *size); + +//This function will be obsolete +void mLoadPalette(char* array,tImage *image); + +#endif diff --git a/PR/src/lib/formats/wav.h b/PR/src/lib/formats/wav.h new file mode 100644 index 0000000..592b21d --- /dev/null +++ b/PR/src/lib/formats/wav.h @@ -0,0 +1,17 @@ + +#ifndef _WAV_H_ +#define _WAV_H_ + +#include <stdio.h> +#if DIR_SEPARATOR=='/' +#include "../resources.h" +#else +#include "resources.h" +#endif + +#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} + +char mFormatExtractWav(unsigned char* data, char *vFileext,unsigned long int size); +char mFormatCompileWav(unsigned char* data, FILE* fp, tResource *res); + +#endif diff --git a/PR/tasks.c b/PR/tasks.c new file mode 100644 index 0000000..09ad553 --- /dev/null +++ b/PR/tasks.c @@ -0,0 +1,66 @@ + +#include "tasks.h" + +int prVerifyDatType(char* vFiledat) { + + //Variables + FILE* fp; + char ok; + + if (ok=((fp=fopen(vFiledat,"rb"))!=NULL)) { + //loop variables + unsigned long int indexOffset; + unsigned short int indexSize,val,numberOfItems; + unsigned char* index; + //verify dat format + ok = fread(&indexOffset,4,1,fp); + ok=ok&& fread(&indexSize,2,1,fp); + ok=ok&& !fseek(fp,indexOffset,SEEK_SET); + ok=ok&& fread(&numberOfItems,2,1,fp); + printf("jaaaj %d",ok); + if (!ok) { + fclose(fp); + return 0; //this is not a valid prince dat file + } + if ((numberOfItems*8+2)!=indexSize) { + printf("jajaj %d %d\r\n",indexOffset,indexSize); + indexOffset+=indexSize; + fseek(fp,0,SEEK_END); + printf("jaaaj %d %d\r\n",indexOffset,ftell(fp)); + char res=(ftell(fp)==indexOffset)?11:0; //see if it is a pop2 file + fclose(fp); + return res; //this is a pop2 dat file or invalid + } + if ((index=getMemory(indexSize-2))==NULL) { + fclose(fp); + return -2; //no memory + } + ok=fread(index,indexSize-2,1,fp); + + //if header ok, new variables + unsigned short int offset; + unsigned long int size; + unsigned char* data; + unsigned char type=5; + + //main loop + for (int k=0;ok&&(k<numberOfItems)&&(type==5);k++) { + //for each archived file + ok=ok&&!(index[k*8+4]||index[k*8+5]); + offset=index[k*8+2]+256*index[k*8+3]; + size=index[k*8+6]+256*index[k*8+7]+1; + ok=ok&&((data=getMemory(size))!=NULL); + ok=ok&&(!fseek(fp,offset,SEEK_SET)); + ok=ok&&fread(data,size,1,fp); + + //set resource information on this index entry + type=verifyHeader(data,(unsigned short int)size); + + } + fclose(fp); + return ok?type:-1; + } else { + return -1; //file could not be open + } +} + diff --git a/PR/tasks.h b/PR/tasks.h new file mode 100644 index 0000000..9360a76 --- /dev/null +++ b/PR/tasks.h @@ -0,0 +1,19 @@ + +//int verifyDatType(char* vFiledat); + +/* + Return values may be: + -2 Memory error + -1 File not found or no access error + + 00 Not a valid POP1 DAT file + + 01 Levels file + 02 Graphic file with an image in the first valid entry (not common) + 03 Waves/Digital sound file + 04 Midis file + 05 Valid DAT file with Undefined content + 06 Graphic file with a palette in the first valid entry (common) + + 11 Pop2 dat files +*/ diff --git a/PR/title.dat.txt b/PR/title.dat.txt new file mode 100644 index 0000000..9d9d683 --- /dev/null +++ b/PR/title.dat.txt @@ -0,0 +1,6 @@ +Princed resources (PR) V0.5 beta. +(c) Copyright 2003 - Princed Development Team +http://www.princed.com.ar + +Extracting 'dat\title.dat' to 'ext' with 1 +Result: 1 diff --git a/PR/vd.bat b/PR/vd.bat new file mode 100755 index 0000000..f3dda4c --- /dev/null +++ b/PR/vd.bat @@ -0,0 +1,2 @@ +@echo off +call extract vdungeon.dat \ No newline at end of file diff --git a/PR/vdr.bat b/PR/vdr.bat new file mode 100755 index 0000000..5ea614d --- /dev/null +++ b/PR/vdr.bat @@ -0,0 +1,3 @@ +@echo off +call destroy +call extract vdungeon.dat \ No newline at end of file diff --git a/PR/vdungeon.dat.txt b/PR/vdungeon.dat.txt new file mode 100644 index 0000000..259052b --- /dev/null +++ b/PR/vdungeon.dat.txt @@ -0,0 +1,6 @@ +Princed resources (PR) V0.5 beta. +(c) Copyright 2003 - Princed Development Team +http://www.princed.com.ar + +Extracting 'dat\vdungeon.dat' to 'ext' with 1 +Result: 1 diff --git a/PR/vp.bat b/PR/vp.bat new file mode 100755 index 0000000..35c9003 --- /dev/null +++ b/PR/vp.bat @@ -0,0 +1,2 @@ +@echo off +call extract vpalace.dat \ No newline at end of file