From: b Date: Thu, 1 Aug 2013 20:54:00 +0000 (+0200) Subject: - Added CPX support (read only) X-Git-Tag: v1.3a X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=0287fe0a70abda9dfa43b63852d9a8a2d8bc9d68;p=cpied - Added CPX support (read only) - Added a list of codepages which is also clickable - Removed dependancy on Borland's EGAVGA driver: Code ported to Open Watcom, Borland's graphic functions replaced with Open Watcom's equivalents --- diff --git a/CPIED.PRJ b/CPIED.PRJ deleted file mode 100644 index d32e214..0000000 Binary files a/CPIED.PRJ and /dev/null differ diff --git a/COPYING.TXT b/DOC/COPYING.TXT similarity index 100% rename from COPYING.TXT rename to DOC/COPYING.TXT diff --git a/readthis.txt b/DOC/readthis.txt similarity index 72% rename from readthis.txt rename to DOC/readthis.txt index aab821d..6ebb290 100644 --- a/readthis.txt +++ b/DOC/readthis.txt @@ -1,27 +1,26 @@ -#### # # -# # # -### ### # # #### ## ### -# # # # # # # # # -#### ### ### ## ## # - # # - ## # # ## ### # ### ## # # - ## # # # # # # #__ # # # # - # ## #### ### # # # # # # # - # # # # # # ### ## # # - Balthasar Szczepaäski -Edytor napis¢w 1.2b - the cpi editor + + ÛÛÛÛ ÛÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛ Û ÛÛ + ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ Û ÛÛ ÛÛ ÛÛ Û +ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ Û Û +ÛÛ ÛÛÛÛÛ ÛÛ ÛÛÛÛ ÛÛ ÛÛ Û Û +ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ ÛÛÛ Û ÛÛ A + ÛÛ ÛÛ ÛÛ ÛÛ ÛÛ Û ÛÛ ÛÛ + ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛ Balthasar Szczepaäski + + CPIED 1.3a - the CPI editor ============================================================ -1. Description -2. System requirements -3. Features and limitations -4. Controls -5. Changes -6. Planned features -7. Known bugs -8. Files -9. Contact information + 1. Description + 2. System requirements + 3. Features and limitations + 4. Controls + 5. Changes + 6. Planned features + 7. Known bugs + 8. Compiling, installing + 9. Files +10. Contact information ============================================================ @@ -29,7 +28,7 @@ Edytor napis This program is a CPI file editor. It can edit CPI files which are used by DOS to store codepage information. -Compiled with Turbo C++ 3.0. Released under the terms of the +Released under the terms of the GPL 3 license (see ccopying.txt) ============================================================ @@ -78,6 +77,7 @@ There can be problems in NT-based versions of windows: were no problems. The previous version of the program (1.0) does not run on DOSBox 0.63. No other emulators were tested. +cpx2cpi was not tested on those systems yet! ============================================================ 3. Features and limitations @@ -89,12 +89,12 @@ The following file formats are supported: This format is not fully supported. Files can be loaded in this format, but can only be saved in FONT format. Windows supports both formats, so this is not a problem. +3.CPX - used by FreeDOS. Files can be loaded in + this format, but can only be saved in CPI format. The following file formats are not supported: -3.DRFONT - used by DR-DOS -4.CPX - used by FreeDOS. FreeDOS also supports the FONT - file format. +4.DRFONT - used by DR-DOS Loaded files must meet the following restrictions: 1.Number of all codepages cannot be 0 or bigger than 16. @@ -140,7 +140,7 @@ The following actions can be performed: Everything can be controlled by the keyboard or mouse (if there is a mouse installed). -Action Keyboard Mouse +Action Keyboard Mouse create a new CPI F1 click the "1.new" text save a CPI file F2 click the "2.save" text @@ -161,15 +161,21 @@ change a pixel Space middle click the pixel switch edit/select Tab changes automatically next codepage PageDown left click the "cp___" text previous codepage PageUp right click the "cp___" text +select a codepage click the number on the list next font End left click the "8x__" text previous font Home right click the "8x__" text *The function of arrow keys is changed with Tab. -A file can also be opened using it's name as a command line -parameter or by clicking its icon in Windows GUI. If a wrong -path is given the program closes without entering graphic -mode. +Command line: + +cpied [cpifile] - edir cpi or cpx files + cpifile - file to be loaded CPI or CPX + +cpx2cpi cpxfile cpifile [q] - convert cpx to cpi + cpxfile - input file, cpx + cpxfile - output file, cpi + q - no console output ============================================================ @@ -211,13 +217,18 @@ beta: - Further optimization of graphic procedures - Fixed a bug that placed the cursor outside the edited character when switching between heights with the mouse. +1.3a + - Added CPX support (read only) + - Added a list of codepages which is also clickable + - Removed dependancy on Borland's EGAVGA driver: + Code ported to Open Watcom, Borland's graphic functions + replaced with Open Watcom's equivalents ============================================================ 6. Planned features - Saving FONT.NT files - - CPX file format support - Exporting codepages to CP files - Importing codepages from CP flies - Exporting fonts to bitmaps @@ -228,20 +239,54 @@ beta: 7. Known bugs +Dialog boxes need improving. + ============================================================ -8. Files +8. Compiling, installing + +Compiling: + +Requirements: + cpx2cpi: + NASM + Turbo C + cpied: + Open Watcom + +The makefile should be processed by a make program. +I used Borland's make, the real-mode version, makeR. Open +Watcom's wmake doesn't compile cpx2cpi. + +Installing: + +cpied.exe and cpx2cpi.com should be copied to somwere in the +%PATH% + +On Windows you may register *.cpi and*.cpx file extensions +to CPIED. + +============================================================ + +9. Files + +BIN: + CPIED .EXE The CPI editor + CPX2CPI .COM CPX to CPI converter +SRC: + CPIED .CPP Source for the CPI editor + CPX2CPI .C Source for the CPX to CPI converter + CPITRICK.ASM Source for the CPX to CPI converter + MAKEFILE Makefile for both programs +DOC: + COPYING .TXT License information + READTHIS.TXT This file -EGAVGA .OBJ 5658 BGI driver compiled to OBJ -CPIED .EXE 101275 The program -CPIED .CPP 60912 Source for the program -CPIED .PRJ 4608 Turbo C++ 3.0 project file -COPYING .TXT 35821 License information -READTHIS.TXT 8443 This file +cpitrick.asm and cpx2cpi.c contain code from FreeDOS mode. ============================================================ -9. Contact information +10. Contact information e-mail: balthasar_s@interia.pl rowerynaksiezycu@gmail.com diff --git a/EGAVGA.OBJ b/EGAVGA.OBJ deleted file mode 100644 index 9098132..0000000 Binary files a/EGAVGA.OBJ and /dev/null differ diff --git a/CPIED.CPP b/SRC/CPIED.CPP similarity index 63% rename from CPIED.CPP rename to SRC/CPIED.CPP index 94c5ca6..82f8859 100644 --- a/CPIED.CPP +++ b/SRC/CPIED.CPP @@ -1,7 +1,7 @@ - //CPI EDITOR vresion 1.2b + //CPIED version 1.3a // Balthasar Szczepaäski Copyright 2013 // - // This file is part of CPIED also known as the CPI EDITOR or EDYTOR NAPISàW + // This file is part of CPIED // //CPIED is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -15,10 +15,30 @@ // //You should have received a copy of the GNU General Public License along // with CPIED (copying.txt). If not, see . - // - // -// Compiled with Turbo C++ 3.0 -#include + +#define BLACK 0 +#define GRAY 8 +#define BLUE 1 +#define LBLUE 9 +#define GREEN 2 +#define LGREEN 10 +#define CYAN 3 +#define LCYAN 11 +#define RED 4 +#define LRED 12 +#define MAGEN 5 +#define LMAGEN 13 +#define BROWN 6 +#define YELLOW 14 +#define LGRAY 7 +#define WHITE 15 + +//#define C_BACK BLACK +#define C_SET BROWN +#define C_NON RED +#define C_SEL GREEN + +#include #include #include #include @@ -26,10 +46,11 @@ #include #include #include +#include #define resetMaus setMaus -//Strustures in the CPI file format +//Structures in the CPI file format struct FontFileHeader { unsigned char id0; @@ -105,11 +126,25 @@ struct ScreenFontBitmap8 int status; char nazwap[256]="Nie_wybrano_pliku"; char err[256]; - - int kart16=VGA; - - int tryb16=VGAHI; - + unsigned char NOFONT[8]={ + 0x80, + 0x00, + 0x08, + 0x00, + 0x80, + 0x00, + 0x08, + 0x00}; + unsigned char FULLF[8]={ + 0xff, + 0xff, + 0xff, + 0xff, + 0xff, + 0xff, + 0xff, + 0xff}; + FILE *CPI; FontFileHeader *FFH; FontInfoHeader *FIH; @@ -159,7 +194,7 @@ void offset (); void new8 (); void menu8 (); -void cpwys (); +void cpwys (int mode=0); void redraw(); void displayDialog(int color, char *text, int type=0); @@ -312,29 +347,39 @@ void offset() } void new8() { - cleardevice(); - setcolor(GREEN); - - outtextxy(0,0, "CPI editor 1.2±"); - outtextxy(0,8, "±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±"); - //outtextxy(600,16,"v1.2b"); + _clearscreen(_GCLEARSCREEN); + _setcolor(C_SEL); + _moveto(0,0); + _outgtext("CPIED 1.3a±"); + _moveto(0,8); + _outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±"); } void menu8() { - setcolor(GREEN); - outtextxy(609,449,","); - outtextxy(472,456,"Balthasar Szczepanski"); - outtextxy(0,464,"±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±"); + _setcolor(C_SEL); + _moveto(609,449); + _outgtext(","); + _moveto(472,456); + _outgtext("Balthasar Szczepanski"); + _moveto(0,464); + _outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±"); if(any) - outtextxy(0,472,"1.new°°2.save°°3.load°°4.use°°5.number°°6.newF°°7.newCP°°8.delF°°9.delCP°°10.end"); + { + _moveto(0,472); + _outgtext("1.new°°2.save°°3.load°°4.use°°5.number°°6.newF°°7.newCP°°8.delF°°9.delCP°°10.end"); + } else - outtextxy(0,472,"1.new°°°°°°°°°°3.load°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°10.end"); + { + _moveto(0,472); + _outgtext("1.new°°°°°°°°°°3.load°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°10.end"); + } } -void cpwys() +void cpwys(int mode) { char cpw[256]; - setfillstyle(EMPTY_FILL,BLACK); - bar(120,0,639,7); + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,120,0,639,7); if(any) { if((unsigned)(CPEH[cp]->codepage)>=1000) @@ -364,9 +409,24 @@ void cpwys() } else strcpy(cpw, "°No CPI open°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"); - setcolor(GREEN); - - outtextxy(120,0,cpw); + _setcolor(C_SEL); + _moveto(120,0); + _outgtext(cpw); + if(mode||!any) + return; + for(short i=0;inum_codepages;++i) + { + if(i==cp) + _setcolor(C_SEL); + else + _setcolor(C_NON); + _moveto(328+(i%6)*48,16+(i/6)*8); + if((unsigned)(CPEH[i]->codepage)>=1000) + sprintf(cpw,"%5u",CPEH[i]->codepage); + else + sprintf(cpw," %03u",CPEH[i]->codepage); + _outgtext(cpw); + } } void redraw()// { @@ -388,27 +448,31 @@ void redraw()// void displayDialog(int color,char *text,int type) { - gotoxy(21,13); + _settextposition(13,21); char t1[43]="±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±"; strcpy(t1+1,text); t1[strlen(t1)]='±'; - setfillstyle(EMPTY_FILL,BLACK); - bar(152,184,487,215); - setcolor(color); - outtextxy(152,184,t1); - outtextxy(152,192,"± ±"); - outtextxy(152,200,"± ±"); + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,152,184,487,215); + _setcolor(color); + _moveto(152,184); + _outgtext(t1); + _moveto(152,192); + _outgtext("± ±"); + _moveto(152,200); + _outgtext("± ±"); switch(type) { case 2: - outtextxy(152,208,"±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±again?(y/n)±"); + _moveto(152,208);_outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±again?(y/n)±"); break; case 1: - outtextxy(152,208,"±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey±"); + _moveto(152,208);_outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey±"); break; case 0: default: - outtextxy(152,208,"±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±"); + _moveto(152,208);_outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±"); break; } } @@ -416,19 +480,19 @@ int message(char *text, char *value, int type) { if (type!=2) { - displayDialog(BROWN,text,1); + displayDialog(C_SET,text,1); printf("%s",value); - bioskey(_KEYBRD_READ); + _bios_keybrd(_KEYBRD_READ); return 0; } else { - displayDialog(BROWN,text,2); + displayDialog(C_SET,text,2); printf("%s",value); - int a; + unsigned short a; for(;;) { - a=bioskey(_KEYBRD_READ); + a=_bios_keybrd(_KEYBRD_READ); if((a&0xFF)==0x59||(a&0xFF)==0x79) return 0; if((a&0xFF)==0x4e||(a&0xff)==0x6e) @@ -438,7 +502,7 @@ int message(char *text, char *value, int type) } inline void question(char *text, char *result) { - displayDialog(GREEN,text); + displayDialog(C_SEL,text); scanf("%s",result); } inline unsigned question(char *text) @@ -453,45 +517,45 @@ void ramka8() if(!any) return; if(tab==0&&wys==8) - setcolor(GREEN); + _setcolor(C_SEL); else - setcolor(RED); - rectangle(15,31,144,160); + _setcolor(C_NON); + _rectangle(_GBORDER,15,31,144,160); if(tab!=0&&wys==8) - setcolor(GREEN); + _setcolor(C_SEL); else - setcolor(RED); - rectangle(175,31,304,160); + _setcolor(C_NON); + _rectangle(_GBORDER,175,31,304,160); } void ramka14() { if(!any) return; if(tab==0&&wys==14) - setcolor(GREEN); + _setcolor(C_SEL); else - setcolor(RED); - rectangle(15,223,144,448); + _setcolor(C_NON); + _rectangle(_GBORDER,15,223,144,448); if(tab!=0&&wys==14) - setcolor(GREEN); + _setcolor(C_SEL); else - setcolor(RED); - rectangle(175,223,304,448); + _setcolor(C_NON); + _rectangle(_GBORDER,175,223,304,448); } void ramka16() { if(!any) return; if(tab==0&&wys==16) - setcolor(GREEN); + _setcolor(C_SEL); else - setcolor(RED); - rectangle(335,111,464,368); + _setcolor(C_NON); + _rectangle(_GBORDER,335,111,464,368); if(tab!=0&&wys==16) - setcolor(GREEN); + _setcolor(C_SEL); else - setcolor(RED); - rectangle(495,111,624,368); + _setcolor(C_NON); + _rectangle(_GBORDER,495,111,624,368); } void lin8(int mode) { @@ -500,83 +564,96 @@ void lin8(int mode) if(mode==3) { if(SFB8[cp]->lit[lit].lin[cury]&(0x80>>curx)) - putpixel(176+curx+((lit&15)<<3),32+cury+((lit>>4)<<3),GREEN); + _setcolor(C_SEL); else - putpixel(176+curx+((lit&15)<<3),32+cury+((lit>>4)<<3),BLACK); + _setcolor(BLACK); + _setpixel(176+curx+((lit&15)<<3),32+cury+((lit>>4)<<3)); return; } char ab[2]="X"; - int color1,color2; + short color1,color2; if(byo8[cp]==0) { - setfillstyle(WIDE_DOT_FILL,RED); - bar(176,32,303,159); + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,176,32,303,159); + _setfillmask(NOFONT); + _setcolor(C_NON); + _rectangle(_GFILLINTERIOR,176,32,303,159); return; } if(wys==8) { - color1=GREEN; - color2=GREEN; + color1=C_SEL; + color2=C_SEL; } else { - color1=BROWN; - color2=RED; + color1=C_SET; + color2=C_NON; } int l; switch(mode) { case 2: - setcolor(RED); + _setcolor(C_NON); if((pre&15)!=(lit&15)) { ab[0]=abc[pre&15]; - outtextxy(176+((pre&15)<<3),24,ab); + _moveto(176+((pre&15)<<3),24); + _outgtext(ab); } if(pre>>4!=lit>>4) { ab[0]=abc[pre>>4]; - outtextxy(168,32+((pre>>4)<<3),ab); + _moveto(168,32+((pre>>4)<<3)); + _outgtext(ab); } - setfillpattern(SFB8[cp]->lit[pre].lin,BROWN); - bar(176+((pre&15)<<3),32+((pre>>4)<<3),183+((pre&15)<<3),39+((pre>>4)<<3)); + _setfillmask(SFB8[cp]->lit[pre].lin); + _setcolor(C_SET); + _rectangle(_GFILLINTERIOR,176+((pre&15)<<3),32+((pre>>4)<<3),183+((pre&15)<<3),39+((pre>>4)<<3)); case 3: case 1: - setcolor(color2); + _setcolor(color2); ab[0]=abc[lit&15]; - outtextxy(176+((lit&15)<<3),24,ab); + _moveto(176+((lit&15)<<3),24); + _outgtext(ab); ab[0]=abc[lit>>4]; - outtextxy(168,32+((lit>>4)<<3),ab); - setfillpattern(SFB8[cp]->lit[lit].lin,color1); - bar(176+((lit&15)<<3),32+((lit>>4)<<3),183+((lit&15)<<3),39+((lit>>4)<<3)); - - + _moveto(168,32+((lit>>4)<<3)); + _outgtext(ab); + _setfillmask(SFB8[cp]->lit[lit].lin); + _setcolor(color1); + _rectangle(_GFILLINTERIOR,176+((lit&15)<<3),32+((lit>>4)<<3),183+((lit&15)<<3),39+((lit>>4)<<3)); break; case 0: default: + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,176,32,303,159); for(l=0;l<16;++l) { ab[0]=abc[l]; if((lit&15)==l) - setcolor(color2); + _setcolor(color2); else - setcolor(RED); - outtextxy(176+(l<<3),24,ab); + _setcolor(C_NON); + _moveto(176+(l<<3),24);_outgtext(ab); if(lit>>4==l) - setcolor(color2); + _setcolor(color2); else - setcolor(RED); - outtextxy(168,32+(l<<3),ab); + _setcolor(C_NON); + _moveto(168,32+(l<<3));_outgtext(ab); } for(l=0;l<256;++l) { if(l==lit) - setfillpattern(SFB8[cp]->lit[l].lin,color1); + _setcolor(color1); else - setfillpattern(SFB8[cp]->lit[l].lin,BROWN); - bar(176+((l&15)<<3),32+((l>>4)<<3),183+((l&15)<<3),39+((l>>4)<<3)); + _setcolor(C_SET); + _setfillmask(SFB8[cp]->lit[l].lin); + _rectangle(_GFILLINTERIOR,176+((l&15)<<3),32+((l>>4)<<3),183+((l&15)<<3),39+((l>>4)<<3)); } break; } @@ -588,127 +665,126 @@ void lin14(int mode) if(mode==3) { if(SFB14[cp]->lit[lit].lin[cury]&(0x80>>curx)) - putpixel(176+curx+((lit&15)<<3),224+cury+(lit>>4)*14,GREEN); + _setcolor(C_SEL); else - putpixel(176+curx+((lit&15)<<3),224+cury+(lit>>4)*14,BLACK); + _setcolor(BLACK); + _setpixel(176+curx+((lit&15)<<3),224+cury+(lit>>4)*14); return; } char ab[2]="X"; - int color1,color2; + short color1,color2; if(byo14[cp]==0) { - setfillstyle(WIDE_DOT_FILL,RED); - bar(176,224,303,447); + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,176,224,303,447); + _setfillmask(NOFONT); + _setcolor(C_NON); + _rectangle(_GFILLINTERIOR,176,224,303,447); return; } if(wys==14) { - color1=GREEN; - color2=GREEN; + color1=C_SEL; + color2=C_SEL; } else { - color1=BROWN; - color2=RED; + color1=C_SET; + color2=C_NON; } int a,l; switch(mode) { case 2: - setcolor(RED); + _setcolor(C_NON); if((pre&15)!=(lit&15)) { ab[0]=abc[pre&15]; - outtextxy(176+((pre&15)<<3),216,ab); + _moveto(176+((pre&15)<<3),216);_outgtext(ab); } if(pre>>4!=lit>>4) { ab[0]=abc[pre>>4]; - outtextxy(168,227+(pre>>4)*14,ab); + _moveto(168,227+(pre>>4)*14);_outgtext(ab); } a=(pre>>4)&3; + _setcolor(C_SET); if(a) { - setfillpattern(SFB14[cp]->lit[pre].lin+(a<<1)-8,BROWN); - bar(176+((pre&15)<<3),224+(pre>>4)*14,183+((pre&15)<<3),223+(a<<1)+(pre>>4)*14); + _setfillmask(SFB14[cp]->lit[pre].lin+(a<<1)-8); + _rectangle(_GFILLINTERIOR,176+((pre&15)<<3),224+(pre>>4)*14,183+((pre&15)<<3),223+(a<<1)+(pre>>4)*14); } - setfillpattern(SFB14[cp]->lit[pre].lin+(a<<1),BROWN); - bar(176+((pre&15)<<3),224+(a<<1)+(pre>>4)*14,183+((pre&15)<<3),231+(a<<1)+(pre>>4)*14); + _setfillmask(SFB14[cp]->lit[pre].lin+(a<<1)); + _rectangle(_GFILLINTERIOR,176+((pre&15)<<3),224+(a<<1)+(pre>>4)*14,183+((pre&15)<<3),231+(a<<1)+(pre>>4)*14); if(a!=3) { - setfillpattern(SFB14[cp]->lit[pre].lin+(a<<1)+8,BROWN); - bar(176+((pre&15)<<3),232+(a<<1)+(pre>>4)*14,183+((pre&15)<<3),237+(pre>>4)*14); + _setfillmask(SFB14[cp]->lit[pre].lin+(a<<1)+8); + _rectangle(_GFILLINTERIOR,176+((pre&15)<<3),232+(a<<1)+(pre>>4)*14,183+((pre&15)<<3),237+(pre>>4)*14); } case 3: case 1: - setcolor(color2); + _setcolor(color2); ab[0]=abc[lit&15]; - outtextxy(176+((lit&15)<<3),216,ab); + _moveto(176+((lit&15)<<3),216);_outgtext(ab); ab[0]=abc[lit>>4]; - outtextxy(168,227+(lit>>4)*14,ab); + _moveto(168,227+(lit>>4)*14);_outgtext(ab); a=(lit>>4)&3; + _setcolor(color1); if(a) { - setfillpattern(SFB14[cp]->lit[lit].lin+(a<<1)-8,color1); - bar(176+((lit&15)<<3),224+(lit>>4)*14,183+((lit&15)<<3),223+(a<<1)+(lit>>4)*14); + _setfillmask(SFB14[cp]->lit[lit].lin+(a<<1)-8); + _rectangle(_GFILLINTERIOR,176+((lit&15)<<3),224+(lit>>4)*14,183+((lit&15)<<3),223+(a<<1)+(lit>>4)*14); } - setfillpattern(SFB14[cp]->lit[lit].lin+(a<<1),color1); - bar(176+((lit&15)<<3),224+(a<<1)+(lit>>4)*14,183+((lit&15)<<3),231+(a<<1)+(lit>>4)*14); + _setfillmask(SFB14[cp]->lit[lit].lin+(a<<1)); + _rectangle(_GFILLINTERIOR,176+((lit&15)<<3),224+(a<<1)+(lit>>4)*14,183+((lit&15)<<3),231+(a<<1)+(lit>>4)*14); if(a!=3) { - setfillpattern(SFB14[cp]->lit[lit].lin+(a<<1)+8,color1); - bar(176+((lit&15)<<3),232+(a<<1)+(lit>>4)*14,183+((lit&15)<<3),237+(lit>>4)*14); + _setfillmask(SFB14[cp]->lit[lit].lin+(a<<1)+8); + _rectangle(_GFILLINTERIOR,176+((lit&15)<<3),232+(a<<1)+(lit>>4)*14,183+((lit&15)<<3),237+(lit>>4)*14); } break; case 0: default: + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,176,224,303,447); for(l=0;l<16;++l) { ab[0]=abc[l]; if((lit&15)==l) - setcolor(color2); + _setcolor(color2); else - setcolor(RED); - outtextxy(176+(l<<3),216,ab); + _setcolor(C_NON); + _moveto(176+(l<<3),216); + _outgtext(ab); if(lit>>4==l) - setcolor(color2); + _setcolor(color2); else - setcolor(RED); - outtextxy(168,227+l*14,ab); + _setcolor(C_NON); + _moveto(168,227+l*14); + _outgtext(ab); } for(l=0;l<256;++l) { a=(l>>4)&3; if(l==lit) + _setcolor(color1); + else + _setcolor(C_SET); + if(a) { - if(a) - { - setfillpattern(SFB14[cp]->lit[l].lin+(a<<1)-8,color1); - bar(176+((l&15)<<3),224+(l>>4)*14,183+((l&15)<<3),223+(a<<1)+(l>>4)*14); - } - setfillpattern(SFB14[cp]->lit[l].lin+(a<<1),color1); - bar(176+((l&15)<<3),224+(a<<1)+(l>>4)*14,183+((l&15)<<3),231+(a<<1)+(l>>4)*14); - if(a!=3) - { - setfillpattern(SFB14[cp]->lit[l].lin+(a<<1)+8,color1); - bar(176+((l&15)<<3),232+(a<<1)+(l>>4)*14,183+((l&15)<<3),237+(l>>4)*14); - } + _setfillmask(SFB14[cp]->lit[l].lin+(a<<1)-8); + _rectangle(_GFILLINTERIOR,176+((l&15)<<3),224+(l>>4)*14,183+((l&15)<<3),223+(a<<1)+(l>>4)*14); } - else + _setfillmask(SFB14[cp]->lit[l].lin+(a<<1)); + _rectangle(_GFILLINTERIOR,176+((l&15)<<3),224+(a<<1)+(l>>4)*14,183+((l&15)<<3),231+(a<<1)+(l>>4)*14); + if(a!=3) { - if(a) - { - setfillpattern(SFB14[cp]->lit[l].lin+(a<<1)-8,BROWN); - bar(176+((l&15)<<3),224+(l>>4)*14,183+((l&15)<<3),223+(a<<1)+(l>>4)*14); - } - setfillpattern(SFB14[cp]->lit[l].lin+(a<<1),BROWN); - bar(176+((l&15)<<3),224+(a<<1)+(l>>4)*14,183+((l&15)<<3),231+(a<<1)+(l>>4)*14); - if(a!=3) - { - setfillpattern(SFB14[cp]->lit[l].lin+(a<<1)+8,BROWN); - bar(176+((l&15)<<3),232+(a<<1)+(l>>4)*14,183+((l&15)<<3),237+(l>>4)*14); - } + _setfillmask(SFB14[cp]->lit[l].lin+(a<<1)+8); + _rectangle(_GFILLINTERIOR,176+((l&15)<<3),232+(a<<1)+(l>>4)*14,183+((l&15)<<3),237+(l>>4)*14); } + } break; } @@ -720,92 +796,100 @@ void lin16(int mode) if(mode==3) { if(SFB16[cp]->lit[lit].lin[cury]&(0x80>>curx)) - putpixel(496+curx+((lit&15)<<3),112+cury+((lit>>4)<<4),GREEN); + _setcolor(C_SEL); else - putpixel(496+curx+((lit&15)<<3),112+cury+((lit>>4)<<4),BLACK); + _setcolor(BLACK); + _setpixel(496+curx+((lit&15)<<3),112+cury+((lit>>4)<<4)); return; } char ab[2]="X"; - int color1,color2; + short color1,color2; if(byo16[cp]==0) { - setfillstyle(WIDE_DOT_FILL,RED); - bar(496,112,623,367); + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,496,112,623,367); + _setfillmask(NOFONT); + _setcolor(C_NON); + _rectangle(_GFILLINTERIOR,496,112,623,367); return; } if(wys==16) { - color1=GREEN; - color2=GREEN; + color1=C_SEL; + color2=C_SEL; } else { - color1=BROWN; - color2=RED; + color1=C_SET; + color2=C_NON; } int l; switch(mode) { case 2: - setcolor(RED); + _setcolor(C_NON); if((pre&15)!=(lit&15)) { ab[0]=abc[pre&15]; - outtextxy(496+((pre&15)<<3),104,ab); + _moveto(496+((pre&15)<<3),104); + _outgtext(ab); } if(pre>>4!=lit>>4) { ab[0]=abc[pre>>4]; - outtextxy(488,116+((pre>>4)<<4),ab); - } - setfillpattern(SFB16[cp]->lit[pre].lin,BROWN); - bar(496+((pre&15)<<3),112+((pre>>4)<<4),503+((pre&15)<<3),119+((pre>>4)<<4)); - setfillpattern(SFB16[cp]->lit[pre].lin+8,BROWN); - bar(496+((pre&15)<<3),120+((pre>>4)<<4),503+((pre&15)<<3),127+((pre>>4)<<4)); + _moveto(488,116+((pre>>4)<<4)); + _outgtext(ab); + } + _setcolor(C_SET); + _setfillmask(SFB16[cp]->lit[pre].lin); + _rectangle(_GFILLINTERIOR,496+((pre&15)<<3),112+((pre>>4)<<4),503+((pre&15)<<3),119+((pre>>4)<<4)); + _setfillmask(SFB16[cp]->lit[pre].lin+8); + _rectangle(_GFILLINTERIOR,496+((pre&15)<<3),120+((pre>>4)<<4),503+((pre&15)<<3),127+((pre>>4)<<4)); case 3: case 1: - setcolor(color2); + _setcolor(color2); ab[0]=abc[lit&15]; - outtextxy(496+((lit&15)<<3),104,ab); + _moveto(496+((lit&15)<<3),104); + _outgtext(ab); ab[0]=abc[lit>>4]; - outtextxy(488,116+((lit>>4)<<4),ab); - setfillpattern(SFB16[cp]->lit[lit].lin,color1); - bar(496+((lit&15)<<3),112+((lit>>4)<<4),503+((lit&15)<<3),119+((lit>>4)<<4)); - setfillpattern(SFB16[cp]->lit[lit].lin+8,color1); - bar(496+((lit&15)<<3),120+((lit>>4)<<4),503+((lit&15)<<3),127+((lit>>4)<<4)); + _moveto(488,116+((lit>>4)<<4)); + _outgtext(ab); + _setcolor(color1); + _setfillmask(SFB16[cp]->lit[lit].lin); + _rectangle(_GFILLINTERIOR,496+((lit&15)<<3),112+((lit>>4)<<4),503+((lit&15)<<3),119+((lit>>4)<<4)); + _setfillmask(SFB16[cp]->lit[lit].lin+8); + _rectangle(_GFILLINTERIOR,496+((lit&15)<<3),120+((lit>>4)<<4),503+((lit&15)<<3),127+((lit>>4)<<4)); break; case 0: default: + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,496,112,623,367); for(l=0;l<16;++l) { ab[0]=abc[l]; if((lit&15)==l) - setcolor(color2); + _setcolor(color2); else - setcolor(RED); - outtextxy(496+(l<<3),104,ab); + _setcolor(C_NON); + _moveto(496+(l<<3),104);_outgtext(ab); if(lit>>4==l) - setcolor(color2); + _setcolor(color2); else - setcolor(RED); - outtextxy(488,116+(l<<4),ab); + _setcolor(C_NON); + _moveto(488,116+(l<<4));_outgtext(ab); } for(l=0;l<256;++l) { if(l==lit) - { - setfillpattern(SFB16[cp]->lit[l].lin,color1); - bar(496+((l&15)<<3),112+((l>>4)<<4),503+((l&15)<<3),119+((l>>4)<<4)); - setfillpattern(SFB16[cp]->lit[l].lin+8,color1); - bar(496+((l&15)<<3),120+((l>>4)<<4),503+((l&15)<<3),127+((l>>4)<<4)); - } + _setcolor(color1); else - { - setfillpattern(SFB16[cp]->lit[l].lin,BROWN); - bar(496+((l&15)<<3),112+((l>>4)<<4),503+((l&15)<<3),119+((l>>4)<<4)); - setfillpattern(SFB16[cp]->lit[l].lin+8,BROWN); - bar(496+((l&15)<<3),120+((l>>4)<<4),503+((l&15)<<3),127+((l>>4)<<4)); - } + _setcolor(C_SET); + _setfillmask(SFB16[cp]->lit[l].lin); + _rectangle(_GFILLINTERIOR,496+((l&15)<<3),112+((l>>4)<<4),503+((l&15)<<3),119+((l>>4)<<4)); + _setfillmask(SFB16[cp]->lit[l].lin+8); + _rectangle(_GFILLINTERIOR,496+((l&15)<<3),120+((l>>4)<<4),503+((l&15)<<3),127+((l>>4)<<4)); } break; } @@ -814,72 +898,69 @@ void lit8(int mode) { if(!any) return; - int color; - setcolor(RED); + short color; + _setcolor(C_NON); if(byo8[cp]==0) { - setfillstyle(WIDE_DOT_FILL,RED); - bar(16,32,143,159); + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,16,32,143,159); + _setfillmask(NOFONT); + _setcolor(C_NON); + _rectangle(_GFILLINTERIOR,16,32,143,159); return; } char ab[2]="q"; if(wys==8) - color=GREEN; + color=C_SEL; else - color=RED; + color=C_NON; + _setfillmask(FULLF); switch(mode) { case 2: - setcolor(RED); + _setcolor(C_NON); if(curx!=prex) { ab[0]=abc[prex]; - outtextxy(20+(prex<<4),24,ab); + _moveto(20+(prex<<4),24); + _outgtext(ab); } if(prey<8) { if(cury!=prey) { ab[0]=abc[prey]; - outtextxy(8,36+(prey<<4),ab); + _moveto(8,36+(prey<<4)); + _outgtext(ab); } if(SFB8[cp]->lit[lit].lin[prey]&(0x80>>prex)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(16+(prex<<4),32+(prey<<4),31+(prex<<4),47+(prey<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,16+(prex<<4),32+(prey<<4),31+(prex<<4),47+(prey<<4)); } case 1: - setcolor(color); + _setcolor(color); ab[0]=abc[curx]; - outtextxy(20+(curx<<4),24,ab); + _moveto(20+(curx<<4),24); + _outgtext(ab); if(cury<8) - { + { ab[0]=abc[cury]; - outtextxy(8,36+(cury<<4),ab); + _moveto(8,36+(cury<<4)); + _outgtext(ab); if(SFB8[cp]->lit[lit].lin[cury]&(0x80>>curx)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(16+(curx<<4),32+(cury<<4),31+(curx<<4),47+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,16+(curx<<4),32+(cury<<4),31+(curx<<4),47+(cury<<4)); if(wys==8) { - setcolor(GREEN); - rectangle(16+(curx<<4),32+(cury<<4),31+(curx<<4),47+(cury<<4)); - setcolor(BLACK); - rectangle(17+(curx<<4),33+(cury<<4),30+(curx<<4),46+(cury<<4)); + _setcolor(C_SEL); + _rectangle(_GBORDER,16+(curx<<4),32+(cury<<4),31+(curx<<4),47+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GBORDER,17+(curx<<4),33+(cury<<4),30+(curx<<4),46+(cury<<4)); } } break; @@ -888,42 +969,38 @@ void lit8(int mode) for(int l=0;l<8;++l) { if(l==curx) - setcolor(color); + _setcolor(color); else - setcolor(RED); + _setcolor(C_NON); ab[0]=abc[l]; - outtextxy(20+(l<<4),24,ab); + _moveto(20+(l<<4),24); + _outgtext(ab); if(l==cury) - setcolor(color); + _setcolor(color); else - setcolor(RED); + _setcolor(C_NON); ab[0]=abc[l]; - outtextxy(8,36+(l<<4),ab); + _moveto(8,36+(l<<4)); + _outgtext(ab); } for(int a=0;a<8;++a) { for(int b=0;b<8;++b) { if(SFB8[cp]->lit[lit].lin[a]&(0x80>>b)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(16+(b<<4),32+(a<<4),31+(b<<4),47+(a<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,16+(b<<4),32+(a<<4),31+(b<<4),47+(a<<4)); } } if(wys==8) { - setcolor(GREEN); - rectangle(16+(curx<<4),32+(cury<<4),31+(curx<<4),47+(cury<<4)); - setcolor(BLACK); - rectangle(17+(curx<<4),33+(cury<<4),30+(curx<<4),46+(cury<<4)); + _setcolor(C_SEL); + _rectangle(_GBORDER,16+(curx<<4),32+(cury<<4),31+(curx<<4),47+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GBORDER,17+(curx<<4),33+(cury<<4),30+(curx<<4),46+(cury<<4)); } break; } @@ -932,72 +1009,69 @@ void lit14(int mode) { if(!any) return; - int color; - setcolor(RED); + short color; + _setcolor(C_NON); if(byo14[cp]==0) { - setfillstyle(WIDE_DOT_FILL,RED); - bar(16,224,143,447); + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,16,224,143,447); + _setfillmask(NOFONT); + _setcolor(C_NON); + _rectangle(_GFILLINTERIOR,16,224,143,447); return; } char ab[2]="q"; if(wys==14) - color=GREEN; + color=C_SEL; else - color=RED; + color=C_NON; + _setfillmask(FULLF); switch(mode) { case 2: - setcolor(RED); + _setcolor(C_NON); if(curx!=prex) { ab[0]=abc[prex]; - outtextxy(20+(prex<<4),216,ab); + _moveto(20+(prex<<4),216); + _outgtext(ab); } if(prey<14) { if(cury!=prey) { ab[0]=abc[prey]; - outtextxy(8,228+(prey<<4),ab); + _moveto(8,228+(prey<<4)); + _outgtext(ab); } if(SFB14[cp]->lit[lit].lin[prey]&(0x80>>prex)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(16+(prex<<4),224+(prey<<4),31+(prex<<4),239+(prey<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,16+(prex<<4),224+(prey<<4),31+(prex<<4),239+(prey<<4)); } case 1: - setcolor(color); + _setcolor(color); ab[0]=abc[curx]; - outtextxy(20+(curx<<4),216,ab); + _moveto(20+(curx<<4),216); + _outgtext(ab); if(cury<14) { ab[0]=abc[cury]; - outtextxy(8,228+(cury<<4),ab); + _moveto(8,228+(cury<<4)); + _outgtext(ab); if(SFB14[cp]->lit[lit].lin[cury]&(0x80>>curx)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(16+(curx<<4),224+(cury<<4),31+(curx<<4),239+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,16+(curx<<4),224+(cury<<4),31+(curx<<4),239+(cury<<4)); if(wys==14) { - setcolor(GREEN); - rectangle(16+(curx<<4),224+(cury<<4),31+(curx<<4),239+(cury<<4)); - setcolor(BLACK); - rectangle(17+(curx<<4),225+(cury<<4),30+(curx<<4),238+(cury<<4)); + _setcolor(C_SEL); + _rectangle(_GBORDER,16+(curx<<4),224+(cury<<4),31+(curx<<4),239+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GBORDER,17+(curx<<4),225+(cury<<4),30+(curx<<4),238+(cury<<4)); } } break; @@ -1006,42 +1080,40 @@ void lit14(int mode) for(int l=0;l<14;++l) { if(l==curx) - setcolor(color); + _setcolor(color); else - setcolor(RED); + _setcolor(C_NON); ab[0]=abc[l]; if(l<8) - outtextxy(20+(l<<4),216,ab); + { + _moveto(20+(l<<4),216); + _outgtext(ab); + } if(l==cury) - setcolor(color); + _setcolor(color); else - setcolor(RED); + _setcolor(C_NON); ab[0]=abc[l]; - outtextxy(8,228+(l<<4),ab); + _moveto(8,228+(l<<4)); + _outgtext(ab); } for(int a=0;a<14;++a) { for(int b=0;b<8;++b) { if(SFB14[cp]->lit[lit].lin[a]&(0x80>>b)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(16+(b<<4),224+(a<<4),31+(b<<4),239+(a<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,16+(b<<4),224+(a<<4),31+(b<<4),239+(a<<4)); } } if(wys==14) { - setcolor(GREEN); - rectangle(16+(curx<<4),224+(cury<<4),31+(curx<<4),239+(cury<<4)); - setcolor(BLACK); - rectangle(17+(curx<<4),225+(cury<<4),30+(curx<<4),238+(cury<<4)); + _setcolor(C_SEL); + _rectangle(_GBORDER,16+(curx<<4),224+(cury<<4),31+(curx<<4),239+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GBORDER,17+(curx<<4),225+(cury<<4),30+(curx<<4),238+(cury<<4)); } break; } @@ -1050,67 +1122,64 @@ void lit16(int mode) { if(!any) return; - int color; - setcolor(RED); + short color; + _setcolor(C_NON); if(byo16[cp]==0) { - setfillstyle(WIDE_DOT_FILL,RED); - bar(336,112,463,367); + _setfillmask(FULLF); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,336,112,463,367); + _setfillmask(NOFONT); + _setcolor(C_NON); + _rectangle(_GFILLINTERIOR,336,112,463,367); return; } char ab[2]="q"; if(wys==16) - color=GREEN; + color=C_SEL; else - color=RED; + color=C_NON; + _setfillmask(FULLF); switch(mode) { case 2: - setcolor(RED); + _setcolor(C_NON); if(curx!=prex) { ab[0]=abc[prex]; - outtextxy(340+(prex<<4),104,ab); + _moveto(340+(prex<<4),104); + _outgtext(ab); } if(cury!=prey) { ab[0]=abc[prey]; - outtextxy(328,116+(prey<<4),ab); + _moveto(328,116+(prey<<4)); + _outgtext(ab); } if(SFB16[cp]->lit[lit].lin[prey]&(0x80>>prex)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(336+(prex<<4),112+(prey<<4),351+(prex<<4),127+(prey<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,336+(prex<<4),112+(prey<<4),351+(prex<<4),127+(prey<<4)); case 1: - setcolor(color); + _setcolor(color); ab[0]=abc[curx]; - outtextxy(340+(curx<<4),104,ab); + _moveto(340+(curx<<4),104); + _outgtext(ab); ab[0]=abc[cury]; - outtextxy(328,116+(cury<<4),ab); + _moveto(328,116+(cury<<4)); + _outgtext(ab); if(SFB16[cp]->lit[lit].lin[cury]&(0x80>>curx)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(336+(curx<<4),112+(cury<<4),351+(curx<<4),127+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,336+(curx<<4),112+(cury<<4),351+(curx<<4),127+(cury<<4)); if(wys==16) { - setcolor(GREEN); - rectangle(336+(curx<<4),112+(cury<<4),351+(curx<<4),127+(cury<<4)); - setcolor(BLACK); - rectangle(337+(curx<<4),113+(cury<<4),350+(curx<<4),126+(cury<<4)); + _setcolor(C_SEL); + _rectangle(_GBORDER,336+(curx<<4),112+(cury<<4),351+(curx<<4),127+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GBORDER,337+(curx<<4),113+(cury<<4),350+(curx<<4),126+(cury<<4)); } break; case 0: @@ -1118,42 +1187,40 @@ void lit16(int mode) for(int l=0;l<16;++l) { if(l==curx) - setcolor(color); + _setcolor(color); else - setcolor(RED); + _setcolor(C_NON); ab[0]=abc[l]; if(l<8) - outtextxy(340+(l<<4),104,ab); + { + _moveto(340+(l<<4),104); + _outgtext(ab); + } if(l==cury) - setcolor(color); + _setcolor(color); else - setcolor(RED); + _setcolor(C_NON); ab[0]=abc[l]; - outtextxy(328,116+(l<<4),ab); + _moveto(328,116+(l<<4)); + _outgtext(ab); } for(int a=0;a<16;++a) { for(int b=0;b<8;++b) { if(SFB16[cp]->lit[lit].lin[a]&(0x80>>b)) - { - setcolor(BROWN); - setfillstyle(SOLID_FILL,BROWN); - } + _setcolor(C_SET); else - { - setcolor(BLACK); - setfillstyle(SOLID_FILL,BLACK); - } - bar(336+(b<<4),112+(a<<4),351+(b<<4),127+(a<<4)); + _setcolor(BLACK); + _rectangle(_GFILLINTERIOR,336+(b<<4),112+(a<<4),351+(b<<4),127+(a<<4)); } } if(wys==16) { - setcolor(GREEN); - rectangle(336+(curx<<4),112+(cury<<4),351+(curx<<4),127+(cury<<4)); - setcolor(BLACK); - rectangle(337+(curx<<4),113+(cury<<4),350+(curx<<4),126+(cury<<4)); + _setcolor(C_SEL); + _rectangle(_GBORDER,336+(curx<<4),112+(cury<<4),351+(curx<<4),127+(cury<<4)); + _setcolor(BLACK); + _rectangle(_GBORDER,337+(curx<<4),113+(cury<<4),350+(curx<<4),126+(cury<<4)); } } } @@ -1204,14 +1271,15 @@ int otw2() { int a; int b; - int c; - int d; - int NT; + //int c; + //int d; + bool NT=false; + bool CPX=false; CPI=fopen(nazwap,"rb"); if(CPI==NULL) { - sprintf(err,"100:No valid file at this path"); + sprintf(err,"100:No valid file at this path\n"); return 100; } else @@ -1220,45 +1288,91 @@ int otw2() FFH=new FontFileHeader; if(!FFH) { - sprintf(err,"116:Not enough memory for FFH"); + sprintf(err,"116:Not enough memory for FFH\n"); fclose(CPI); return 116; } fread(FFH,0x19,1,CPI); if(FFH->id0!=0xff) { - sprintf(err,"101:Unsupported format, id0=0x%02x",(short)(FFH->id0&0xff)); - fclose(CPI); - deleteCPI(0); - return 101; + if(FFH->id0==0x81&&FFH->id[0]==0xfc)//maybe it's a CPX? + { + fclose(CPI); + deleteCPI(0); + status=spawnlp(P_WAIT,"cpx2cpi","cpx2cpi",nazwap,"tempcpi","q",NULL); + if(status) + { + sprintf(err,"101:Unsupported format, id0=0x81\n"); + if (status<3) + remove("tempcpi"); + return 101; + } + CPX=true; + CPI=fopen("tempcpi","rb"); + if(CPI==NULL) + { + sprintf(err,"101:Unsupported format, id0=0x81\n"); + return 101; + } + FFH=new FontFileHeader; + if(!FFH) + { + sprintf(err,"116:Not enough memory for FFH\n"); + fclose(CPI); + remove("tempcpi"); + return 116; + } + fread(FFH,0x19,1,CPI); + if(FFH->id0!=0xff) + { + sprintf(err,"101:Unsupported format, id0=0x%02x\n",(short)(FFH->id0&0xff)); + fclose(CPI); + remove("tempcpi"); + deleteCPI(0); + return 101; + } + } + else + { + sprintf(err,"101:Unsupported format, id0=0x%02x\n",(short)(FFH->id0&0xff)); + fclose(CPI); + deleteCPI(0); + return 101; + } } - if(!strcmp("FONT ",FFH->id)) - NT=0; - else if(!strcmp("FONT.NT",FFH->id)) + if(!strcmp("FONT ",(char *)(FFH->id))) + ; + else if(!strcmp("FONT.NT",(char *)(FFH->id))) { - NT=1; + NT=true; FFH->id[4]=' '; FFH->id[5]=' '; FFH->id[6]=' '; } else { - sprintf(err,"102:Unsupported format, id=\"%c%c%c%c%c%c%c\"",FFH->id[0],FFH->id[1],FFH->id[2],FFH->id[3],FFH->id[4],FFH->id[5],FFH->id[6]); + 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]); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(0); return 102; } if(FFH->pnum!=1) { - sprintf(err,"103:Wrong no. of pointers (%u)",FFH->pnum); + sprintf(err,"103:Wrong no. of pointers (%u)\n",FFH->pnum); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(0); return 103; } if(FFH->ptyp!=1) { - sprintf(err,"104:Wrong pointer type, (%u)",(short)(FFH->ptyp&0xff)); + sprintf(err,"104:Wrong pointer type, (%u)\n",(short)(FFH->ptyp&0xff)); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(0); return 104; } @@ -1266,8 +1380,10 @@ int otw2() FIH=new FontInfoHeader; if(!FIH) { - sprintf(err,"116:Not enough memory for FIH"); + sprintf(err,"116:Not enough memory for FIH\n"); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(0); return 116; } @@ -1275,15 +1391,19 @@ int otw2() fread(FIH,0x2,1,CPI); if(FIH->num_codepages>16) { - sprintf(err,"105:Too many codepages (%u)",FIH->num_codepages); + sprintf(err,"105:Too many codepages (%u)\n",FIH->num_codepages); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(1); return 105; } if(FIH->num_codepages==0) { - sprintf(err,"117:No codepages"); + sprintf(err,"117:No codepages\n"); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(1); return 117; } @@ -1295,7 +1415,10 @@ int otw2() CPEH[a] = new CodePageEntryHeader; if(!CPEH[a]) { - sprintf(err,"116:Not enough memory for CPEH[%d]",a); + sprintf(err,"116:Not enough memory for CPEH[%d]\n",a); + fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(1); return 116; } @@ -1307,15 +1430,19 @@ int otw2() } if(CPEH[a]->cpeh_size!=0x1c) { - sprintf(err,"106:Wrong CPEH[%u] size (0x%x)",a,CPEH[a]->cpeh_size); + sprintf(err,"106:Wrong CPEH[%u] size (0x%x)\n",a,CPEH[a]->cpeh_size); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(2,a); return 106; } if(CPEH[a]->device_type!=1) { - sprintf(err,"107:Wrong device type(%u) in CPEH[%u]",CPEH[a]->device_type,a); + sprintf(err,"107:Wrong device type(%u) in CPEH[%u]\n",CPEH[a]->device_type,a); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(2,a); return 107; } @@ -1323,8 +1450,10 @@ int otw2() { if(CPEH[a]->codepage==CPEH[i]->codepage) { - sprintf(err,"114:cp%03u (%u) already in CPEH[%u]",CPEH[a]->codepage,a,i); + sprintf(err,"114:cp%03u (%u) already in CPEH[%u]\n",CPEH[a]->codepage,a,i); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(2,a); return 114; } @@ -1334,30 +1463,38 @@ int otw2() CPIH[a] = new CodePageInfoHeader; if(!CPIH[a]) { - sprintf(err,"116:Not enough memory for CPIH[%d]",a); + sprintf(err,"116:Not enough memory for CPIH[%d]\n",a); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(2,a); return 116; } fread(CPIH[a],0x6,1,CPI); if(CPIH[a]->version!=1) { - sprintf(err,"108:Wrong version of CPIH[%u] (%u)",a,CPIH[a]->version); + sprintf(err,"108:Wrong version of CPIH[%u] (%u)\n",a,CPIH[a]->version); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(3,a); return 108; } if(CPIH[a]->num_fonts>3) { - sprintf(err,"109:Too many fonts in CPIH[%u] (%u)",a,CPIH[a]->num_fonts); + sprintf(err,"109:Too many fonts in CPIH[%u] (%u)\n",a,CPIH[a]->num_fonts); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(3,a); return 109; } if(CPIH[a]->num_fonts==0) { - sprintf(err,"115:No fonts in CPIH[%u])",a); + sprintf(err,"115:No fonts in CPIH[%u])\n",a); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(3,a); return 115; } @@ -1367,8 +1504,10 @@ int otw2() SFH[a][b] = new ScreenFontHeader; if(!SFH[a][b]) { - sprintf(err,"116:Not enough memory for SFH[%d][%d]",a); + sprintf(err,"116:Not enough memory for SFH[%d][%d]\n",a); fclose(CPI); + if(CPX) + remove("tempcpi"); if(b==0) deleteCPI(3,a); else @@ -1380,8 +1519,10 @@ int otw2() { if (byo8[a]!=0) { - sprintf(err,"113:Height 8 already in cp%03u (%u;%u)",CPEH[a]->codepage,a,b); + sprintf(err,"113:Height 8 already in cp%03u (%u;%u)\n",CPEH[a]->codepage,a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 113; } @@ -1391,8 +1532,10 @@ int otw2() { if (byo14[a]!=0) { - sprintf(err,"113:Height 14 already in cp%03u (%u;%u)",CPEH[a]->codepage,a,b); + sprintf(err,"113:Height 14 already in cp%03u (%u;%u)\n",CPEH[a]->codepage,a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 113; } @@ -1402,8 +1545,10 @@ int otw2() { if (byo16[a]!=0) { - sprintf(err,"113:Height 16 already in cp%03u (%u;%u)",CPEH[a]->codepage,a,b); + sprintf(err,"113:Height 16 already in cp%03u (%u;%u)\n",CPEH[a]->codepage,a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 113; } @@ -1411,22 +1556,28 @@ int otw2() } if(SFH[a][b]->height!=8&&SFH[a][b]->height!=14&&SFH[a][b]->height!=16) { - sprintf(err,"110:Wrong height (%u) in SFH[%u][%u]",(short)(SFH[a][b]->height&0xff),a,b); + sprintf(err,"110:Wrong height (%u) in SFH[%u][%u]\n",(short)(SFH[a][b]->height&0xff),a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 110; } if(SFH[a][b]->width!=8) { - sprintf(err,"111:Wrong width (%u) in SFH[%u][%u]",(short)(SFH[a][b]->width&0xff),a,b); + sprintf(err,"111:Wrong width (%u) in SFH[%u][%u]\n",(short)(SFH[a][b]->width&0xff),a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 111; } if(SFH[a][b]->num_chars!=256) { - sprintf(err,"112:Wrong no.of chars(%u)in SFH[%u][%u]",SFH[a][b]->num_chars,a,b); + sprintf(err,"112:Wrong no.of chars(%u)in SFH[%u][%u]\n",SFH[a][b]->num_chars,a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 112; } @@ -1435,8 +1586,10 @@ int otw2() SFB16[a] = new ScreenFontBitmap16; if(!SFB16[a]) { - sprintf(err,"116:Not enough memory for SFB16[%d] (%d)",a,b); + sprintf(err,"116:Not enough memory for SFB16[%d] (%d)\n",a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 116; } @@ -1447,8 +1600,10 @@ int otw2() SFB14[a] = new ScreenFontBitmap14; if(!SFB14[a]) { - sprintf(err,"116:Not enough memory for SFB14[%d] (%d)",a,b); + sprintf(err,"116:Not enough memory for SFB14[%d] (%d)\n",a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 116; } @@ -1459,8 +1614,10 @@ int otw2() SFB8[a] = new ScreenFontBitmap8; if(!SFB8[a]) { - sprintf(err,"116:Not enough memory for SFB8[%d] (%d)",a,b); + sprintf(err,"116:Not enough memory for SFB8[%d] (%d)\n",a,b); fclose(CPI); + if(CPX) + remove("tempcpi"); deleteCPI(4,a,b); return 116; } @@ -1469,13 +1626,16 @@ int otw2() } } fclose(CPI); + if(CPX) + remove("tempcpi"); offset(); return 0; } void otw3()// { - setcolor(RED); - outtextxy(136,472,"load"); + _setcolor(C_NON); + _moveto(136,472); + _outgtext("load"); deleteCPI(); status=otw(); while(status!=0) @@ -1505,13 +1665,13 @@ int zap2() { int a; int b; - int c; - int d; + //int c; + //int d; CPI=fopen(nazwap,"wb"); if(CPI==NULL) { - sprintf(err,"200:Cannot create file at this path"); + sprintf(err,"200:Cannot create file at this path\n"); return 200; } else @@ -1547,14 +1707,15 @@ int zap2() } } - fprintf(CPI,"\r\nThis file was created with the CPI editor version 1.2b",0x1a); + fprintf(CPI,"\r\nThis file was created with the CPI editor version 1.3a",0x1a); fclose(CPI); return 0; } void zap3()// { - setcolor(RED); - outtextxy(72,472,"save"); + _setcolor(C_NON); + _moveto(72,472); + _outgtext("save"); status=zap(); while(status!=0) { @@ -1569,8 +1730,9 @@ void zap3()// void use3()/// { - setcolor(RED); - outtextxy(72,472,"save use"); + _setcolor(C_NON); + _moveto(72,472); + _outgtext("save use"); status=zap(); while(status!=0) { @@ -1588,8 +1750,9 @@ void use3()/// puts(err); system(err); delay(5000); - closegraph(); - initgraph(&kart16,&tryb16,""); + //closegraph(); + //initgraph(&kart16,&tryb16,""); + _setvideomode(_VRES16COLOR); } redraw(); @@ -1604,7 +1767,7 @@ int zmn() { if(CP==CPEH[i]->codepage&&i!=cp) { - sprintf(err,"314:cp%03u already in CPEH[%u]",CP,i); + sprintf(err,"314:cp%03u already in CPEH[%u]\n",CP,i); return 314; } } @@ -1613,8 +1776,9 @@ int zmn() } void zmn3()// { - setcolor(RED); - outtextxy(256,472,"number"); + _setcolor(C_NON); + _moveto(256,472); + _outgtext("number"); status=zmn(); if(status!=0) message("Number not changed",err); @@ -1624,12 +1788,12 @@ void zmn3()// int newCPI() { short CP,h; - char temp[51]; + //char temp[51]; CP=question("First codepage number:"); h=question("Initial font height(8,14,16,all)"); if(h!=0&&h!=8&&h!=14&&h!=16) { - sprintf(err,"310:Wrong height (%u)",h); + sprintf(err,"310:Wrong height (%u)\n",h); return 310; } return newCPI2(CP,h); @@ -1640,18 +1804,18 @@ int newCPI2(short CP, short h) FFH=new FontFileHeader; if(!FFH) { - sprintf(err,"316:Not enough memory for FFH"); + sprintf(err,"316:Not enough memory for FFH\n"); return 316; } FFH->id0=0xFF; - strcpy(FFH->id,"FONT "); - strcpy(FFH->reserved,"\0\0\0\0\0\0\0"); + strcpy((char *)(FFH->id),"FONT "); + strcpy((char *)(FFH->reserved),"\0\0\0\0\0\0\0"); FFH->pnum=1; FFH->ptyp=1; FIH=new FontInfoHeader; if(!FIH) { - sprintf(err,"316:Not enough memory for FIH"); + sprintf(err,"316:Not enough memory for FIH\n"); deleteCPI(0); return 316; } @@ -1667,8 +1831,9 @@ int newCPI2(short CP, short h) } void newCPI3()// { - setcolor(RED); - outtextxy(16,472,"new"); + _setcolor(C_NON); + _moveto(16,472); + _outgtext("new"); deleteCPI(); status=newCPI(); while(status!=0) @@ -1797,10 +1962,10 @@ void deleteCPI(short st,short a,short b) int newCP() { short CP,h; - char temp[51]; + //char temp[51]; if(FIH->num_codepages>=16) { - sprintf(err,"305:Already 16 codepages in CPI"); + sprintf(err,"305:Already 16 codepages in CPI\n"); return 305; } CP=question("Codepage number:"); @@ -1808,14 +1973,14 @@ int newCP() { if(CP==CPEH[i]->codepage) { - sprintf(err,"314:cp%03u already in CPEH[%u]",CP,i); + sprintf(err,"314:cp%03u already in CPEH[%u]\n",CP,i); return 314; } } h=question("Initial font height(8,14,16,all)"); if(h!=0&&h!=8&&h!=14&&h!=16) { - sprintf(err,"310:Wrong height (%u)",h); + sprintf(err,"310:Wrong height (%u)\n",h); return 310; } return newCP2(CP,h); @@ -1825,22 +1990,22 @@ int newCP2(short CP,short h) int t; if(!(CPEH[FIH->num_codepages] = new CodePageEntryHeader)) { - sprintf(err,"316:Not enough memory for CPEH[%d]",FIH->num_codepages); + sprintf(err,"316:Not enough memory for CPEH[%d]\n",FIH->num_codepages); return 316; } if(!(CPIH[FIH->num_codepages] = new CodePageInfoHeader)) { delete CPEH[FIH->num_codepages]; CPEH[FIH->num_codepages] = NULL; - sprintf(err,"316:Not enough memory for CPIH[%d]",FIH->num_codepages); + sprintf(err,"316:Not enough memory for CPIH[%d]\n",FIH->num_codepages); return 316; } CPEH[FIH->num_codepages]->cpeh_size=0x1c; CPEH[FIH->num_codepages]->device_type=1; - strcpy(CPEH[FIH->num_codepages]->device_name,"EGA "); + strcpy((char *)(CPEH[FIH->num_codepages]->device_name),"EGA "); CPEH[FIH->num_codepages]->device_name[7]=' '; CPEH[FIH->num_codepages]->codepage=CP; - strcpy(CPEH[FIH->num_codepages]->reserved,"\0\0\0\0\0"); + strcpy((char *)(CPEH[FIH->num_codepages]->reserved),"\0\0\0\0\0"); CPIH[FIH->num_codepages]->version=1; CPIH[FIH->num_codepages]->num_fonts=0; switch(h) @@ -1885,7 +2050,7 @@ int newCP2(short CP,short h) } break; default: - sprintf(err,"510:%u WT*?",h); + sprintf(err,"510:%u ***?",h); t = 510; } if(t!=0) @@ -1902,8 +2067,9 @@ int newCP2(short CP,short h) } void newCP3()// { - setcolor(RED); - outtextxy(400,472,"newCP"); + _setcolor(C_NON); + _moveto(400,472); + _outgtext("newCP"); status=newCP(); if(status!=0) message("Codepage not created",err); @@ -1977,7 +2143,7 @@ int delCP() short i; if(FIH->num_codepages<=1) { - sprintf(err,"317:Last codepage"); + sprintf(err,"317:Last codepage\n"); return 317; } for(i=0;inum_fonts;++i) @@ -2031,8 +2197,9 @@ int delCP() } void delCP3()// { - setcolor(RED); - outtextxy(536,472,"delCP"); + _setcolor(C_NON); + _moveto(536,472); + _outgtext("delCP"); status=delCP(); if(status!=0) message("Codepage not deleted",err); @@ -2049,7 +2216,7 @@ int newF() short h; if(CPIH[cp]->num_fonts>=3) { - sprintf(err,"309:Already 3 fonts in CPIH[%u]",cp); + sprintf(err,"309:Already 3 fonts in CPIH[%u]\n",cp); return 309; } h=question("Font height(8,14,16)"); @@ -2066,14 +2233,15 @@ int newF2(short h) case 16: return newF16(cp); default: - sprintf(err,"310:Wrong height (%u)",h); + sprintf(err,"310:Wrong height (%u)\n",h); return 310; } } void newF3()// { - setcolor(RED); - outtextxy(336,472,"newF"); + _setcolor(C_NON); + _moveto(336,472); + _outgtext("newF"); status=newF(); if(status!=0) message("Font not created",err); @@ -2085,17 +2253,17 @@ int newF8(short CP) { if(byo8[CP]) { - sprintf(err,"313:Height 8 already in cp%03u",CPEH[CP]->codepage); + sprintf(err,"313:Height 8 already in cp%03u\n",CPEH[CP]->codepage); return 313; } if(!(SFH[CP][CPIH[CP]->num_fonts]=new ScreenFontHeader)) { - sprintf(err,"316:Not enough memory for SFH[%d][%d]",CP,CPIH[CP]->num_fonts); + sprintf(err,"316:Not enough memory for SFH[%d][%d]\n",CP,CPIH[CP]->num_fonts); return 316; } if(!(SFB8[CP]=new ScreenFontBitmap8)) { - sprintf(err,"316:Not enough memory for SFB8[%d]",CP); + sprintf(err,"316:Not enough memory for SFB8[%d]\n",CP); delete SFH[CP][CPIH[CP]->num_fonts]; SFH[CP][CPIH[CP]->num_fonts] = NULL; return 316; @@ -2116,17 +2284,17 @@ int newF14(short CP) { if(byo14[CP]) { - sprintf(err,"313:Height 14 already in cp%03u",CPEH[CP]->codepage); + sprintf(err,"313:Height 14 already in cp%03u\n",CPEH[CP]->codepage); return 313; } if(!(SFH[CP][CPIH[CP]->num_fonts]=new ScreenFontHeader)) { - sprintf(err,"316:Not enough memory for SFH[%d][%d]",CP,CPIH[CP]->num_fonts); + sprintf(err,"316:Not enough memory for SFH[%d][%d]\n",CP,CPIH[CP]->num_fonts); return 316; } if(!(SFB14[CP]=new ScreenFontBitmap14)) { - sprintf(err,"316:Not enough memory for SFB14[%d]",CP); + sprintf(err,"316:Not enough memory for SFB14[%d]\n",CP); delete SFH[CP][CPIH[CP]->num_fonts]; SFH[CP][CPIH[CP]->num_fonts] = NULL; return 316; @@ -2147,17 +2315,17 @@ int newF16(short CP) { if(byo16[CP]) { - sprintf(err,"313:Height 16 already in cp%03u",CPEH[CP]->codepage); + sprintf(err,"313:Height 16 already in cp%03u\n",CPEH[CP]->codepage); return 313; } if(!(SFH[CP][CPIH[CP]->num_fonts]=new ScreenFontHeader)) { - sprintf(err,"316:Not enough memory for SFH[%d][%d]",CP,CPIH[CP]->num_fonts); + sprintf(err,"316:Not enough memory for SFH[%d][%d]\n",CP,CPIH[CP]->num_fonts); return 316; } if(!(SFB16[CP]=new ScreenFontBitmap16)) { - sprintf(err,"316:Not enough memory for SFB16[%d]",CP); + sprintf(err,"316:Not enough memory for SFB16[%d]\n",CP); delete SFH[CP][CPIH[CP]->num_fonts]; SFH[CP][CPIH[CP]->num_fonts] = NULL; return 316; @@ -2241,7 +2409,7 @@ void prevF()// ramka16(); break; } - cpwys(); + cpwys(1); return; } void nextF()// @@ -2311,7 +2479,7 @@ void nextF()// ramka16(); break; } - cpwys(); + cpwys(1); return; } @@ -2320,7 +2488,7 @@ int delF() short h; if(CPIH[cp]->num_fonts<=1) { - sprintf(err,"315:Last font in CPIH[%u]",cp); + sprintf(err,"315:Last font in CPIH[%u]\n",cp); return 315; } for(short i=0;inum_fonts;++i) @@ -2340,14 +2508,15 @@ int delF() case 16: return delF16(h); default: - sprintf(err,"510:%u WT*?",h); + sprintf(err,"510:%u ***?\n",h); return 510; } } void delF3()// { - setcolor(RED); - outtextxy(472,472,"delF"); + _setcolor(C_NON); + _moveto(472,472); + _outgtext("delF"); status=delF(); if(status!=0) message("Font not deleted",err); @@ -2369,7 +2538,7 @@ int delF8(short h) SFH[cp][i] = SFH[cp][i+1]; } SFH[cp][CPIH[cp]->num_fonts] = NULL; - sprintf(err,"0:OK"); + sprintf(err,"0:OK\n"); return 0; } int delF14(short h) @@ -2384,7 +2553,7 @@ int delF14(short h) SFH[cp][i] = SFH[cp][i+1]; } SFH[cp][CPIH[cp]->num_fonts] = NULL; - sprintf(err,"0:OK"); + sprintf(err,"0:OK\n"); return 0; } int delF16(short h) @@ -2399,7 +2568,7 @@ int delF16(short h) SFH[cp][i] = SFH[cp][i+1]; } SFH[cp][CPIH[cp]->num_fonts] = NULL; - sprintf(err,"0:OK"); + sprintf(err,"0:OK\n"); return 0; } @@ -2421,21 +2590,12 @@ int main(int argc,char* argv[]) } else any=0; - - status=registerbgidriver(EGAVGA_driver); - if (status < 0) + if(!_setvideomode(_VRES16COLOR)) { - printf("g%d:%s\n",status,grapherrormsg(status)); - return status; + printf("400:Cannot enter graphic mode\n");//change number + return 400; } - initgraph(&kart16,&tryb16,""); - status=graphresult(); - if (status != grOk) - { - printf("g%d:%s\n",status,grapherrormsg(status)); - return status; - } - + _setplotaction(_GPSET); if(byo8[0]) wys=8; else if(byo16[0]) @@ -2449,9 +2609,9 @@ int main(int argc,char* argv[]) showMaus(); for(;;) { - if(bioskey(_KEYBRD_READY)) + if(/*_bios_keybrd(_KEYBRD_READY)*/kbhit()) { - key=bioskey(_KEYBRD_READ); + key=_bios_keybrd(_KEYBRD_READ); if(maus) hideMaus(); if(tab==0) @@ -2769,15 +2929,16 @@ int main(int argc,char* argv[]) if ((key&0xFF00)==0x4400) { //koniec - setcolor(RED); - outtextxy(616,472,"end"); + _setcolor(C_NON); + _moveto(616,472); + _outgtext("end"); if(maus) resetMaus(); break; } - while(bioskey(_KEYBRD_READY)) + while(kbhit()) { - bioskey(_KEYBRD_READ); + _bios_keybrd(_KEYBRD_READ); } if(maus&&mausv) showMaus(); @@ -3157,7 +3318,7 @@ int main(int argc,char* argv[]) wys=16; cury&=0xf; tab=1; - lit=((mausy-111)/16)*16+((mausx-496)/8); + lit=((mausy-112)/16)*16+((mausx-496)/8); if (pre==lit) { switch(prew) @@ -3214,7 +3375,18 @@ int main(int argc,char* argv[]) } } } - + else if(any&&klik&&!prek&&mausx>=328&&mausx<616&&mausy>=16&&mausy<40) + { + int selcp; + hideMaus(); + mausv=0; + selcp=(mausx-328)/48+((mausy-16)/8)*6; + if(selcpnum_codepages) + { + cp=selcp; + normCP(); + } + } else if(any&&klik&&!prek&&mausx>=128&&mausx<184&&mausy<8) { hideMaus(); @@ -3303,21 +3475,25 @@ int main(int argc,char* argv[]) { hideMaus(); mausv=0; - setcolor(RED); - outtextxy(616,472,"end"); + _setcolor(C_NON); + _moveto(616,472); + _outgtext("end"); resetMaus(); break; } else { - mausv=1; - showMaus(); + //if(!mausv) + //{ + mausv=1; + showMaus(); + //} } } } deleteCPI(); - closegraph(); + _setvideomode(_DEFAULTMODE); return 0; -} \ No newline at end of file +} diff --git a/SRC/cpitrick.asm b/SRC/cpitrick.asm new file mode 100644 index 0000000..50406a9 --- /dev/null +++ b/SRC/cpitrick.asm @@ -0,0 +1,179 @@ +;; CPITRICK.ASM +;; This file is part of CPIED +;; +;; CPIED 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 3 of the License, or +;; (at your option) any later version. +;; +;; CPIED 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 CPIED (copying.txt). If not, see . +;; +;; This file is cpitrick.asm from FreeDOS mode without any change. +;; +%if 0 +Open UPXed (!) CPI files - for the FreeDOS MODE C utility +Copyright (C) 2003, 2004 Eric Auer +[This file itself became part of MODE C on 29apr2004] + +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. Or check http://www.gnu.org/licenses/gpl.txt on the internet. +%endif + +SEGMENT _TEXT ALIGN=4 CLASS=CODE +GLOBAL _cpx2cpi + +; int cpx2cpi(void far * buffer), returns 0 plain 1 upxed -1 error +_cpx2cpi: + push bp + mov bp,sp + ; no need to save AX, as AX will hold the return value + push bx + push cx + push dx + push si + push di + push es + push ds + pushf + ; first argument can be found at BP+4 on stack now + + lds si,[bp+4] ; get that pointer + cld + lodsb + cmp al,-1 ; check CPI header (ff,"FONT ") + jnz noplaincpi + lodsw + cmp ax,'FO' + jnz noplaincpi + lodsw + cmp ax,'NT' + jnz noplaincpi + jmp cpi_okay ; it is an uncompressed CPI file! Will be 49100 + ; or more likely 58880 bytes in size, I think. + +noupxcpi: + jmp cpi_error + +noplaincpi: + lds si,[bp+4] ; get that pointer + or si,si ; pointer must be normalized to allow deUPXing + jnz noupxcpi + + ; Next assumption: CPI file got renamed to COM and then + ; UPXed and renamed again. Then it should start with + ; cmp sp,0x100+cpisize+stubsize+stacksize (roughly 0x200+cpisize) + ; ja enoughram + ; int 20 + ; enoughram: ... (here follows the "copy decompressor and compressed + ; data to end-of-the segment code, then the UPX header) + ; Binary: 81 fc xx xx 77 02 cd 20 ... + ; Because we have SS/SP somewhere else, we zap the test! + + lodsw + cmp ax,0xfc81 ; cmp sp, ... ("check if enough free RAM") + jnz noupxcpi ; does not look like an UPXed ".com" file + lodsw ; ignore the something + mov al,0xeb ; opcode: jmp short unconditionally + mov [si],al ; make the test succeed all the time + ; (the code must be: "cmp... jcc okay...") + mov bx,'UP' +scan_upx: ; find "UPX!" signature + dec si + lodsw + cmp si,100 ; first stub part must be smaller than this + ja noupxcpi ; give up + cmp ax,bx + jnz scan_upx + lodsw + cmp ax,'X!' + jnz noupxcpi ; no second try + lodsw + cmp al,10 + jb noupxcpi ; not accepting ancient versions + add si,16+2 ; skip over rest of the header plus 1 word + ; first word of compressed data is one of + ; the bitstream words which are mixed with the + ; literal bytes and low-byte-of-distance bytes + ; which are the ingredients of an UPXed data stream + mov al,0xcb ; opcode for RETF + mov [si],al ; overwrite first byte of CPI file to make it a + inc si ; "program" ;-) + lodsw + cmp ax,'FO' ; pointer and buffer contents correct? + jnz noupxcpi ; give up, bad luck. + + ; header starts with the first byte of the UPX! string and + ; contains in UPX 1.something versions: + ; [4] version (e.g. 0B) [5] format (1 for COM) [6] method (4) + ; [7] compressionlevel (8) [8] adler32u [C] adler32c + ; (32bit checksums of uncompressed / compressed data) + ; [10] sizeu (16bit, e.g. EC00/58880) [12] sizec (16bit) + ; (sizes are 16bit for COM and SYS, 32bit otherwise...) + ; [14] "filter" [15?] headerchecksum [16] compressed data... + + ; If version is below 0A, header is 20 instead of 22 bytes + ; for COM, and if version is below 03, it is 24 bytes, But + ; internal version 09 means UPX 0.7x which is very old. + ; Find UPX source code at http://upx.sourceforge.net/ ... + ; Some of the UPX compression libs are closed source. + + push bp + mov ax,[bp+6] ; get the buffer SEGMENT + sub ax,byte 0x10 ; move to allow offset 0x100 + mov [bp+6],ax ; denormalize pointer to .COM style + mov word [bp+4],0x100 ; denormalize pointer to .COM style + mov es,ax ; deUPXing stub requires ES=CS + mov ds,ax ; deUPXing stub requires DS=CS + + call far [bp+4] ; "run the COM file" + ; this will deUPX the CPI and then run the RETF + ; command which we patched into the byte which + ; will become the first byte of the deUPXed ".COM"! + + pop bp + xor ax,ax + mov [bp+4],ax ; renormalize pointer + add word [bp+6], byte 0x10 + lds si,[bp+4] ; get that pointer + mov byte [si],-1 ; restore first byte to FF + ; buffer now contains the contents of the deUPXed CPI file + +cpi_upxed: + mov ax,1 + jmp short cpi_fetched +cpi_okay: + xor ax,ax + jmp short cpi_fetched +cpi_error: + mov ax,-1 +cpi_fetched: + + popf + pop ds + pop es + pop di + pop si + pop dx + pop cx + pop bx + pop bp + ret ; ret or retf depending on memory model! + diff --git a/SRC/cpx2cpi.c b/SRC/cpx2cpi.c new file mode 100644 index 0000000..e8cfe14 --- /dev/null +++ b/SRC/cpx2cpi.c @@ -0,0 +1,176 @@ + //CPX2CPI.C + // Balthasar Szczepaäski Copyright 2013 + // + // //This file is part of CPIED +// // + // CPIED 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 3 of the License, or + // (at your option) any later version. + // +// // CPIED 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 CPIED (copying.txt). If not, see . + // + // //This file contains code from FreeDOS mode's modecp.c +// // + // + //modecp.c: +/* This code can be used under the terms of GNU Public License */ +/* (GPL) version 2 or later. Written for FreeDOS MODE by Eric */ +/* Auer (eric@coli.uni-sb.de) (c) 2003-2005. GPL -> www.gnu.org */ + +/* Modified 2005 by Eric Auer to model MODECON by Aitor Merino! */ +/* MODE command: CODEPAGE related parts */ + +#include +#include +#include +#include +#include +#include + +static union REGS r; + +#define BYTE unsigned char +#define WORD unsigned int + +#define UPXoverhead 320 /* actually even less: UPX stub has */ + /* 2 parts - 1. relocate 2. decompress - and uses almost no */ + /* stack. We do not even use stack inside the buffer at all, */ + /* makes no difference for the UPX stub. Actual overhead is */ + /* therefore only part 2 of the stub plus no extra stack... */ +#define MaxBufSize (58880U + UPXoverhead) + /* "CPX" support decompresses data in place in the buffer. */ + + BYTE far * buf; /* made pointer far */ + +extern int cpx2cpi(void far * buffer); /* returns 0 plain 1 upxed -1 error */ + /* this part is written in NASM Assembly language, compile */ + /* it with NASM -fobj -o cpitrick.obj cpitrick.asm */ + +int main(int argc,char* argv[]) +{ + unsigned char con=1; + unsigned int cpf; /* file handle */ + unsigned long m; /* filelen is (FAT16: signed) long! */ + struct SREGS sregs; + + if(argc<3) + { + puts("cpx2cpi *.cpx *.cpi [q]"); + return 1; + } + if(argc>3) + { + if(argv[3][0]=='q'||argv[3][0]=='Q') + con=0; + else + con=1; + } + else + con=1; + + /** Check that the file exists **/ + if ((cpf = open(argv[1], O_RDONLY | O_BINARY)) == 0xffffU) + { + if(con) + printf("could not open %s\n",argv[1]); + return 8; + } + + buf = farmalloc(MaxBufSize+15); /* changed malloc to farmalloc */ + if (buf == NULL) { + if(con) + puts ("Out of memory!"); + return 7; + } + + /* for UPXed CPI file (CPX file) support, buffer must be aligned */ + while (FP_OFF(buf) % 16) /* "move" buf to next paragraph */ + buf++; + while (FP_OFF(buf)) { /* normalize buf to "someseg:0" */ + buf = MK_FP(FP_SEG(buf)+1, FP_OFF(buf)-16); + } + + /* we do NOT free malloced buf later - happens on exit anyway. */ + + /** Read the buffer **/ + + /* if memory model is TINY (.com file), we need our */ + /* OWN read( handle, FAR buffer pointer, size ) ... */ + sregs.ds = FP_SEG(buf); + r.x.dx = FP_OFF(buf); + r.h.ah = 0x3f; /* read from file handle */ + r.x.cx = MaxBufSize - UPXoverhead; + r.x.bx = cpf; /* handle */ + + int86x (0x21, &r, &r, &sregs); + if ( r.x.cflag ) { + if(con) + printf("%s read error, code %u.\n",argv[1], r.x.ax); + close (cpf); + return 6; + + } + + + + close (cpf); + + m = cpx2cpi(buf); /* ret: 0 plain 1 upxed -1 error */ /* new 29apr2004 */ + + if (m == -1) + { + if(con) + puts("Not a CPI or CPX"); + return 5; + } + else if (m == 1) + { + if(con) + printf("%s is a cpx\n",argv[1]); + } + else { + if(con) + printf("%s is already a CPI\n",argv[1]); + close (cpf); + return 4; + } + //create the cpi + if ((cpf = (unsigned)(creat(argv[2],S_IWRITE)))==0xffffU) + { + if(con) + printf("could not create %s\n",argv[2]); + return 3; + } + close (cpf); + //for some reason open doesn't want to create a new file + if ((cpf = open(argv[2], O_WRONLY | O_BINARY | O_CREAT | O_TRUNC)) == 0xffffU) + { + if(con) + printf("could not open %s\n",argv[2]); + return 2; + } + sregs.ds = FP_SEG(buf); + r.x.dx = FP_OFF(buf); + r.h.ah = 0x40; /* write to file handle */ + r.x.cx = MaxBufSize - UPXoverhead; + r.x.bx = cpf; /* handle */ + int86x (0x21, &r, &r, &sregs); + if ( r.x.cflag ) + { + if(con) + printf("%s write error, code %u.\n",argv[2], r.x.ax); + close (cpf); + return 1; + } + close (cpf); + if(con) + printf("%s converted to %s\n",argv[1],argv[2]); + return 0; +} diff --git a/SRC/makefile b/SRC/makefile new file mode 100644 index 0000000..3e78133 --- /dev/null +++ b/SRC/makefile @@ -0,0 +1,24 @@ +ASM=nasm +CCX=tcc +CFLAGSX=-w -M -f- -mt -lt -e + +CC=wpp +CL=wlink +CFLAGS=-w4 -e25 -zp1 -zq -ot -d2 -bt=dos -fo=.obj -ml -xs -xr +LFLAGS=name cpied d all sys dos op m op maxe=25 op q op symf f cpied + +all: cpx2cpi.com cpied.exe + +cpied.obj: cpied.cpp makefile + $(CC) cpied.cpp $(CFLAGS) + +cpied.exe: cpied.obj makefile + $(CL) $(LFLAGS) + +cpitrick.obj: cpitrick.asm makefile + $(ASM) -fobj -o cpitrick.obj cpitrick.asm + +cpx2cpi.com: cpitrick.obj cpx2cpi.c makefile + $(CCX) $(CFLAGSX)cpx2cpi cpx2cpi.c cpitrick.obj + +