ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ Û ÛÛ ÛÛ ÛÛ Û\r
ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ Û Û \r
ÛÛ ÛÛÛÛÛ ÛÛ ÛÛÛÛ ÛÛ ÛÛ Û Û \r
-ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛÛ Û ÛÛ B \r
+ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛÛ Û ÛÛ C \r
ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ Û ÛÛ ÛÛ\r
ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛ Balthasar Szczepaäski\r
\r
- CPIED 1.3b - the CPI editor\r
+ CPIED 1.3c - the CPI editor\r
\r
============================================================\r
\r
\r
The program should be able to run on any IBM-PC compatible\r
computer* with an IBM-VGA compatible video card and DOS** or\r
-Windows*** operating system or a DOS emulator****.\r
+Windows*** operating system or a DOS emulator****. To save\r
+CPX files UPX (upx.sourceforge.net) must be installed\r
\r
**The program should run on any DOS that is not older than\r
3.3. It was tested on following systems:\r
This format is not fully supported. Files can be loaded in\r
this format, but can only be saved in FONT format.\r
Windows supports both formats, so this is not a problem.\r
-3.CPX - used by FreeDOS. Files can be loaded in\r
- this format, but can only be saved in CPI format.\r
+3.CPX - used by FreeDOS. To save CPX files\r
+ UPX (upx.sourceforge.net) must be installed\r
\r
The following file formats are not supported:\r
\r
- Dialog boxes can now cancelled with Esc or empty string\r
- Added warnings before deleting a font, a codepage or\r
closing the program when a file is open\r
+1.3c\r
+ - Saving CPX files\r
\r
============================================================\r
\r
6. Planned features\r
\r
- - Saving CPX files\r
- Exporting codepages to CP files\r
- Importing codepages from CP flies\r
- Exporting fonts to bitmaps\r
Installing:\r
\r
cpied.exe and cpx2cpi.com should be copied to somwere in the\r
-%PATH%\r
+%PATH%.\r
\r
On Windows you may register *.cpi and*.cpx file extensions\r
to CPIED.\r
\r
9. Files\r
\r
-BIN:\r
CPIED .EXE The CPI editor\r
CPX2CPI .COM CPX to CPI converter\r
-SRC:\r
+\r
CPIED .CPP Source for the CPI editor\r
CPX2CPI .C Source for the CPX to CPI converter\r
CPITRICK.ASM Source for the CPX to CPI converter\r
MAKEFILE Makefile for both programs\r
-DOC:\r
+\r
COPYING .TXT License information\r
READTHIS.TXT This file\r
\r
- //CPIED version 1.3b\r
+ //CPIED version 1.3c\r
// Balthasar Szczepaäski Copyright 2013\r
//\r
// This file is part of CPIED\r
//You should have received a copy of the GNU General Public License along\r
// with CPIED (copying.txt). If not, see <http://www.gnu.org/licenses/>.\r
\r
+\r
#define BLACK 0\r
#define GRAY 8\r
#define BLUE 1\r
void otw3();\r
\r
int zap ();\r
-int zap2();\r
+int zap2(int format=0);\r
void zap3();\r
\r
void use3();\r
_clearscreen(_GCLEARSCREEN);\r
_setcolor(C_SEL);\r
_moveto(0,0);\r
- _outgtext("CPIED 1.3b±");\r
+ _outgtext("CPIED 1.3c±");\r
_moveto(0,8);\r
_outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±");\r
}\r
{\r
fclose(CPI);\r
deleteCPI(0);\r
- status=spawnlp(P_WAIT,"cpx2cpi","cpx2cpi",nazwap,"tempcpi","q",NULL);\r
- if(status)\r
- {\r
- sprintf(err,"101:Unsupported format, id0=0x81\n");\r
- if (status<3)\r
- remove("tempcpi");\r
- return 101;\r
- }\r
- CPX=true;\r
- CPI=fopen("tempcpi","rb");\r
- if(CPI==NULL)\r
+ //First, try using UPX\r
+ status=spawnlp(P_WAIT,"upx","upx","-d","-q","-o__TEMP__.com",nazwap,NULL);\r
+ if(status==-1)\r
+ //There is no UPX installed, try using cpx2cpi\r
{\r
- sprintf(err,"101:Unsupported format, id0=0x81\n");\r
- return 101;\r
- }\r
- FFH=new FontFileHeader;\r
- if(!FFH)\r
- {\r
- sprintf(err,"116:Not enough memory for FFH\n");\r
- fclose(CPI);\r
- remove("tempcpi");\r
- return 116;\r
+ status=spawnlp(P_WAIT,"cpx2cpi","cpx2cpi",nazwap,"__TEMP__.com","q",NULL);\r
+ if(status==-1)//and there is no cpx2cpi\r
+ {\r
+ sprintf(err,"150:CPX not supported, install cpx2cpi\n");\r
+ return 150;\r
+ }\r
+ if(status)//not converted\r
+ {\r
+ sprintf(err,"151:CPX decompression failed");\r
+ if (status<3)//but file is created\r
+ remove("__TEMP__.com");\r
+ return 151;\r
+ }\r
+ CPX=true;\r
+ CPI=fopen("__TEMP__.com","rb");\r
+ if(CPI==NULL)//converted to an unopenable file\r
+ {\r
+ sprintf(err,"152:Cannot open decompressed file");\r
+ return 152;\r
+ }\r
+ FFH=new FontFileHeader;\r
+ if(!FFH)\r
+ {\r
+ sprintf(err,"116:Not enough memory for FFH\n");\r
+ fclose(CPI);\r
+ remove("__TEMP__.com");\r
+ return 116;\r
+ }\r
+ fread(FFH,0x19,1,CPI);\r
+ if(FFH->id0!=0xff)\r
+ //converted to cpi but it's not a cpi\r
+ {\r
+ sprintf(err,"101:Unsupported format, id0=0x%02x\n",(short)(FFH->id0&0xff));\r
+ fclose(CPI);\r
+ remove("__TEMP__.com");\r
+ deleteCPI(0);\r
+ return 101;\r
+ }\r
}\r
- fread(FFH,0x19,1,CPI);\r
- if(FFH->id0!=0xff)\r
+ else//there is upx installed\r
{\r
- sprintf(err,"101:Unsupported format, id0=0x%02x\n",(short)(FFH->id0&0xff));\r
- fclose(CPI);\r
- remove("tempcpi");\r
- deleteCPI(0);\r
- return 101;\r
+ if(status)//not converted\r
+ {\r
+ sprintf(err,"151:CPX decompression failed");\r
+ //don't ktow if temp file created, delete anyway\r
+ remove("__TEMP__.com");\r
+ return 151;\r
+ }\r
+ CPX=true;\r
+ CPI=fopen("__TEMP__.com","rb");\r
+ if(CPI==NULL)//converted to an unopenable file\r
+ {\r
+ sprintf(err,"152:Cannot open decompressed file\n");\r
+ return 152;\r
+ }\r
+ FFH=new FontFileHeader;\r
+ if(!FFH)\r
+ {\r
+ sprintf(err,"116:Not enough memory for FFH\n");\r
+ fclose(CPI);\r
+ remove("__TEMP__.com");\r
+ return 116;\r
+ }\r
+ fread(FFH,0x19,1,CPI);\r
+ if(FFH->id0!=0xff)\r
+ //converted to cpi but it's not a cpi\r
+ {\r
+ sprintf(err,"101:Unsupported format, id0=0x%02x\n",(short)(FFH->id0&0xff));\r
+ fclose(CPI);\r
+ remove("__TEMP__.com");\r
+ deleteCPI(0);\r
+ return 101;\r
+ }\r
}\r
}\r
else\r
sprintf(err,"102:Unsupported format, id=\"%c%c%c%c%c%c%c\"\n",FFH->id[0],FFH->id[1],FFH->id[2],FFH->id[3],FFH->id[4],FFH->id[5],FFH->id[6]);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(0);\r
return 102;\r
}\r
sprintf(err,"103:Wrong no. of pointers (%u)\n",FFH->pnum);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(0);\r
return 103;\r
}\r
sprintf(err,"104:Wrong pointer type, (%u)\n",(short)(FFH->ptyp&0xff));\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(0);\r
return 104;\r
}\r
sprintf(err,"116:Not enough memory for FIH\n");\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(0);\r
return 116;\r
}\r
sprintf(err,"105:Too many codepages (%u)\n",FIH->num_codepages);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(1);\r
return 105;\r
}\r
sprintf(err,"117:No codepages\n");\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(1);\r
return 117;\r
}\r
sprintf(err,"116:Not enough memory for CPEH[%d]\n",a);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(1);\r
return 116;\r
}\r
sprintf(err,"106:Wrong CPEH[%u] size (0x%x)\n",a,CPEH[a]->cpeh_size);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(2,a);\r
return 106;\r
}\r
sprintf(err,"107:Wrong device type(%u) in cp%03u\n",CPEH[a]->device_type,CPEH[a]->codepage);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(2,a);\r
return 107;\r
}\r
sprintf(err,"114:cp%03u duplicated in this CPI\n",CPEH[a]->codepage);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(2,a);\r
return 114;\r
}\r
sprintf(err,"116:Not enough memory for CPIH[%d]\n",a);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(2,a);\r
return 116;\r
}\r
sprintf(err,"108:Wrong version of CPIH[%u] (%u)\n",a,CPIH[a]->version);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(3,a);\r
return 108;\r
}\r
sprintf(err,"109:Too many fonts in cp%03u (%u)\n",CPEH[a]->codepage,CPIH[a]->num_fonts);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(3,a);\r
return 109;\r
}\r
sprintf(err,"115:No fonts in cp%03u\n",CPEH[a]->codepage);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(3,a);\r
return 115;\r
}\r
sprintf(err,"116:Not enough memory for SFH[%d][%d]\n",a);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
if(b==0)\r
deleteCPI(3,a);\r
else\r
sprintf(err,"113:Height 8 duplicated in cp%03u\n",CPEH[a]->codepage);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 113;\r
}\r
sprintf(err,"113:Height 14 duplicated in cp%03u\n",CPEH[a]->codepage);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 113;\r
}\r
sprintf(err,"113:Height 16 duplicated in cp%03u\n",CPEH[a]->codepage);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 113;\r
}\r
sprintf(err,"110:Wrong height (%u) in cp%03u\n",(short)(SFH[a][b]->height&0xff),CPEH[a]->codepage);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 110;\r
}\r
sprintf(err,"111:Wrong width (%u) in cp%03u\n",(short)(SFH[a][b]->width&0xff),CPEH[a]->codepage);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 111;\r
}\r
sprintf(err,"112:Wrong no.of chars(%u)in cp%03ux%02u\n",SFH[a][b]->num_chars,CPEH[a]->codepage,SFH[a][b]->height);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 112;\r
}\r
sprintf(err,"116:Not enough memory for SFB16[%d] (%d)\n",a,b);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 116;\r
}\r
sprintf(err,"116:Not enough memory for SFB14[%d] (%d)\n",a,b);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 116;\r
}\r
sprintf(err,"116:Not enough memory for SFB8[%d] (%d)\n",a,b);\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
deleteCPI(4,a,b);\r
return 116;\r
}\r
}\r
fclose(CPI);\r
if(CPX)\r
- remove("tempcpi");\r
+ remove("__TEMP__.com");\r
offset();\r
return 0;\r
}\r
\r
int zap()\r
{\r
+ int c;\r
if(question("Filename",nazwap)==1)\r
return 1;\r
- return zap2();\r
+ int format;\r
+ c=strlen(nazwap)-4;\r
+ if(!strcmpi(nazwap+c,".cpx"))\r
+ format=1;\r
+ else if(!strcmpi(nazwap+c,".cpi"))\r
+ format=0;\r
+ else if(message("WARNING","Unknown extension,save in CPI format?\n",3)==1)\r
+ return 1;\r
+ else\r
+ format=0;\r
+ return zap2(format);\r
}\r
-int zap2()\r
+\r
+int zap2(int format)\r
{\r
+ //CPI - 0\r
+ //CPX - 1;\r
int a;\r
int b;\r
- //int c;\r
- //int d;\r
-\r
- CPI=fopen(nazwap,"wb");\r
- if(CPI==NULL)\r
+ if(format==1)\r
{\r
- sprintf(err,"200:Cannot create file at this path\n");\r
- return 200;\r
+ CPI=fopen("__TEMP__.com","wb");\r
+ if(CPI==NULL)\r
+ {\r
+ sprintf(err,"252:Cannot create temporary CPI file\n");\r
+ return 252;\r
+ }\r
}\r
else\r
- sprintf(err,"OK");\r
- \r
+ {\r
+ CPI=fopen(nazwap,"wb");\r
+ if(CPI==NULL)\r
+ {\r
+ sprintf(err,"200:Cannot create file at this path\n");\r
+ return 200;\r
+ }\r
+ }\r
fwrite(FFH,0x19,1,CPI);\r
\r
fseek(CPI,FFH->fih_offset,0);\r
}\r
}\r
\r
- fprintf(CPI,"\r\nThis file was created with the CPI editor version 1.3b",0x1a);\r
+ fprintf(CPI,"\r\nThis file was created with CPIED 1.3c.%c",0x1a);\r
fclose(CPI);\r
+ if(format==1)\r
+ {\r
+ status=spawnlp(P_WAIT,"upx","upx","-q","-o",nazwap,"__TEMP__.com",NULL);\r
+ if(status==-1)\r
+ {\r
+ sprintf(err,"250:CPX not supported, UPX required\n");\r
+ return 250;\r
+ }\r
+ if(status)\r
+ {\r
+ sprintf(err,"251:CPX compression failed\n");\r
+ remove("__TEMP__.com");\r
+ return 251;\r
+ }\r
+ remove("__TEMP__.com");\r
+ }\r
return 0;\r
}\r
void zap3()//\r
\r
int main(int argc,char* argv[])\r
{\r
+\r
nullpointers();\r
\r
if(argc>1)\r
//spacja\r
switch(wys)\r
{\r
- case 8: \r
+ case 8:\r
spc8();\r
lit8(1);\r
lin8(3);\r