From 322ca5a7e88d2b7b8540ff1416893e47ed8ae054 Mon Sep 17 00:00:00 2001 From: b Date: Thu, 4 Jul 2013 21:19:00 +0200 Subject: [PATCH] - Full FONT flie format support - FONT.NT file format support (read only) - Codepage limit set from 6 to 16 - Creating new CPI's - Creating new codepages - Creating new fonts - Removing codepages - Removing fonts - Failed file load no longer closes the program - Dynamic memory allocation - Optimized functions - Fixed bugs - Language changed to English --- NAPISY.CPP | 2213 +++++++++++++++++++++++++++++++++++++++++--------- NAPISY.PRJ | Bin 4540 -> 4607 bytes NAPISY.TXT | 231 ------ readthis.txt | 214 +++++ 4 files changed, 2045 insertions(+), 613 deletions(-) delete mode 100644 NAPISY.TXT create mode 100644 readthis.txt diff --git a/NAPISY.CPP b/NAPISY.CPP index 1dfc80a..5b8f4dd 100644 --- a/NAPISY.CPP +++ b/NAPISY.CPP @@ -1,7 +1,9 @@ #include #include #include +#include #include +#include #include #include @@ -16,10 +18,12 @@ struct FontFileHeader unsigned char ptyp; long fih_offset; }; + struct FontInfoHeader { short num_codepages; }; + struct CodePageEntryHeader { short cpeh_size; @@ -30,12 +34,14 @@ struct CodePageEntryHeader unsigned char reserved[6]; long cpih_offset; }; + struct CodePageInfoHeader { short version; short num_fonts; short size; }; + struct ScreenFontHeader { unsigned char height; @@ -44,18 +50,22 @@ struct ScreenFontHeader unsigned char xaspect; short num_chars; }; + struct char8 { unsigned char lin[8]; }; + struct char14 { unsigned char lin[14]; }; + struct char16 { unsigned char lin[16]; }; + struct ScreenFontBitmap16 { char16 lit[256]; @@ -73,28 +83,26 @@ struct ScreenFontBitmap8 int status; - char nazwap[40]="Nie_wybrano_pliku"; - char err[40]; -// int kart8=CGA; -// int kart14=EGA; + char nazwap[256]="Nie_wybrano_pliku"; + char err[51]; + int kart16=VGA; -// int tryb8=CGAC2; -// int tryb14=EGAHI; + int tryb16=VGAHI; FILE *CPI; - FontFileHeader FFH; - FontInfoHeader FIH; - CodePageEntryHeader CPEH[6]; - CodePageInfoHeader CPIH[6]; - ScreenFontHeader SFH[6][3]; - ScreenFontBitmap16 SFB16[6]; - ScreenFontBitmap14 SFB14[6]; - ScreenFontBitmap8 SFB8[6]; - - int byo8[6]; - int byo14[6]; - int byo16[6]; + FontFileHeader *FFH; + FontInfoHeader *FIH; + CodePageEntryHeader *CPEH[16]; + CodePageInfoHeader *CPIH[16]; + ScreenFontHeader *SFH[16][3]; + ScreenFontBitmap16 *SFB16[16]; + ScreenFontBitmap14 *SFB14[16]; + ScreenFontBitmap8 *SFB8[16]; + + int byo8[16]; + int byo14[16]; + int byo16[16]; int wys=8; int cp=0; int lit=0x42; @@ -102,39 +110,204 @@ struct ScreenFontBitmap8 int cury=2; int key; int tab=0; - char abc[16]="0123456789ABCDEF"; + int any=0; + char abc[17]="0123456789ABCDEF"; + +void nullpointers() +{ + short i,j; + CPI = NULL; + FFH = NULL; + FIH = NULL; + for(i=0;i<16;++i) + { + CPEH[i] = NULL; + CPIH[i] = NULL; + for(j=0;j<3;++j) + { + SFH[i][j] = NULL; + } + SFB8[i] = NULL; + SFB16[i] = NULL; + SFB14[i] = NULL; + byo8[i]=0; + byo14[i]=0; + byo16[i]=0; + + } +} +void offset() +{ + long off=0; + short i,j,s; + off+=sizeof(FontFileHeader); + FFH->fih_offset=off; + off+=sizeof(FontInfoHeader); + for(i=0,s=0;inum_codepages;++i,s=0) + { + off+=sizeof(CodePageEntryHeader); + CPEH[i]->cpih_offset=off; + off+=sizeof(CodePageInfoHeader); + for(j=0;jnum_fonts;++j) + { + s+=sizeof(ScreenFontHeader); + s+=SFH[i][j]->num_chars*SFH[i][j]->height*((SFH[i][j]->width+7)/8); + } + off+=s; + CPIH[i]->size=s; + if(i==FIH->num_codepages-1) + CPEH[i]->next_cpeh_offset=0; + else + CPEH[i]->next_cpeh_offset=off; + } +} +void deleteCPI(short st=6,short a=0,short b=0) +{ + short i,j; + switch(st) + { + case 6: + if(FIH==NULL) + return; + a=FIH->num_codepages-1; + b=CPIH[a]->num_fonts-1; + case 5: + switch(SFH[a][b]->height) + { + case 8: + delete SFB8[a]; + SFB8[a] = NULL; + byo8[a] = 0; + break; + case 14: + delete SFB14[a]; + SFB14[a] = NULL; + byo14[a] = 0; + break; + case 16: + delete SFB16[a]; + SFB16[a] = NULL; + byo16[a] = 0; + break; + //default: + //totally unexpected; + } + case 4: + delete SFH[a][b]; + SFH[a][b] = NULL; + for(j=0;jheight) + { + case 8: + delete SFB8[a]; + SFB8[a] = NULL; + byo8[a] = 0; + break; + case 14: + delete SFB14[a]; + SFB14[a] = NULL; + byo14[a] = 0; + break; + case 16: + delete SFB16[a]; + SFB16[a] = NULL; + byo16[a] = 0; + break; + //default: + //totally unexpected; + } + delete SFH[a][j]; + SFH[a][j] = NULL; + } + case 3: + delete CPIH[a]; + CPIH[a] = NULL; + case 2: + delete CPEH[a]; + CPEH[a] = NULL; + for(i=0;inum_fonts;++j) + { + switch(SFH[i][j]->height) + { + case 8: + delete SFB8[i]; + SFB8[i] = NULL; + byo8[i] = 0; + break; + case 14: + delete SFB14[i]; + SFB14[i] = NULL; + byo14[i] = 0; + break; + case 16: + delete SFB16[i]; + SFB16[i] = NULL; + byo16[i] = 0; + break; + //default: + //totally unexpected; + } + delete SFH[i][j]; + SFH[i][j] = NULL; + } + delete CPIH[i]; + delete CPEH[i]; + CPIH[i] = NULL; + CPEH[i] = NULL; + } + case 1: + delete FIH; + FIH = NULL; + case 0: + delete FFH; + FFH = NULL; + } +} -int pot(int a,int n) +/*t pot(int a,int n) { int y=1; for(int i=0;icodepage,wys,nazwap); + else + strcpy(cpw, "°No CPI open°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"); setcolor(GREEN); outtextxy(0x78,0,cpw); @@ -144,6 +317,8 @@ void cpwys() void ramka8() { + if(!any) + return; if(tab==0&&wys==8) setcolor(GREEN); else @@ -157,6 +332,8 @@ void ramka8() } void ramka14() { + if(!any) + return; if(tab==0&&wys==14) setcolor(GREEN); else @@ -170,6 +347,8 @@ void ramka14() } void ramka16() { + if(!any) + return; if(tab==0&&wys==16) setcolor(GREEN); else @@ -183,6 +362,8 @@ void ramka16() } void lin14() { + if(!any) + return; char ab[2]="X"; setcolor(RED); outtextxy(176,215,"0123456789ABCDEF"); @@ -203,6 +384,17 @@ void lin14() outtextxy(168,422,"E"); outtextxy(168,436,"F"); + if(byo14[cp]==0) + { + setcolor(RED); + setfillstyle(SOLID_FILL,BLACK); + rectangle(176,223,303,446); + floodfill(180,230,RED); + line(176,223,303,446); + line(303,223,176,446); + return; + } + for(int l=0;l<256;++l) { for(int a=0;a<14;++a) @@ -217,38 +409,46 @@ void lin14() ab[0]=abc[lit/16]; outtextxy(168,226+14*(lit/16),ab); - if(b>0) + /*if(b>0) { - if((SFB14[cp].lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB14[cp]->lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) putpixel(176+b+(l%16)*8,223+a+(l/16)*14,GREEN); else putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BLACK); } else { - if((SFB14[cp].lit[l].lin[a]/0x80)==1) + if((SFB14[cp]->lit[l].lin[a]/0x80)==1) putpixel(176+b+(l%16)*8,223+a+(l/16)*14,GREEN); else putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BLACK); - } + }*/ + if(SFB14[cp]->lit[l].lin[a]&(0x80>>b)) + putpixel(176+b+(l%16)*8,223+a+(l/16)*14,GREEN); + else + putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BLACK); } else { - if(b>0) + /*if(b>0) { - if((SFB14[cp].lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB14[cp]->lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BROWN); else putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BLACK); } else { - if((SFB14[cp].lit[l].lin[a]/0x80)==1) + if((SFB14[cp]->lit[l].lin[a]/0x80)==1) putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BROWN); else putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BLACK); - } + }*/ + if(SFB14[cp]->lit[l].lin[a]&(0x80>>b)) + putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BROWN); + else + putpixel(176+b+(l%16)*8,223+a+(l/16)*14,BLACK); } } } @@ -256,6 +456,8 @@ void lin14() } void lin8() { + if(!any) + return; char ab[2]="X"; setcolor(RED); outtextxy(176,24,"0123456789ABCDEF"); @@ -275,6 +477,16 @@ void lin8() outtextxy(168,136,"D"); outtextxy(168,144,"E"); outtextxy(168,152,"F"); + if(byo8[cp]==0) + { + setcolor(RED); + setfillstyle(SOLID_FILL,BLACK); + rectangle(176,32,303,159); + floodfill(180,40,RED); + line(176,32,303,159); + line(303,32,176,159); + return; + } for(int l=0;l<256;++l) { @@ -290,38 +502,46 @@ void lin8() ab[0]=abc[lit/16]; outtextxy(168,32+8*(lit/16),ab); - if(b>0) + /*if(b>0) { - if((SFB8[cp].lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB8[cp]->lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) putpixel(176+b+(l%16)*8,32+a+(l/16)*8,GREEN); else putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BLACK); } else { - if((SFB8[cp].lit[l].lin[a]/0x80)==1) + if((SFB8[cp]->lit[l].lin[a]/0x80)==1) putpixel(176+b+(l%16)*8,32+a+(l/16)*8,GREEN); else putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BLACK); - } + }*/ + if(SFB8[cp]->lit[l].lin[a]&(0x80>>b)) + putpixel(176+b+(l%16)*8,32+a+(l/16)*8,GREEN); + else + putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BLACK); } else { - if(b>0) + /*if(b>0) { - if((SFB8[cp].lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB8[cp]->lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BROWN); else putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BLACK); } else { - if((SFB8[cp].lit[l].lin[a]/0x80)==1) + if((SFB8[cp]->lit[l].lin[a]/0x80)==1) putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BROWN); else putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BLACK); - } + }*/ + if(SFB8[cp]->lit[l].lin[a]&(0x80>>b)) + putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BROWN); + else + putpixel(176+b+(l%16)*8,32+a+(l/16)*8,BLACK); } } } @@ -329,6 +549,8 @@ void lin8() } void lin16() { + if(!any) + return; char ab[2]="X"; setcolor(RED); outtextxy(496,103,"0123456789ABCDEF"); @@ -348,6 +570,17 @@ void lin16() outtextxy(488,323,"D"); outtextxy(488,339,"E"); outtextxy(488,355,"F"); + + if(byo16[cp]==0) + { + setcolor(RED); + setfillstyle(SOLID_FILL,BLACK); + rectangle(496,111,623,366); + floodfill(500,120,RED); + line(496,111,623,366); + line(623,111,496,366); + return; + } for(int l=0;l<256;++l) { @@ -363,38 +596,46 @@ void lin16() ab[0]=abc[lit/16]; outtextxy(488,115+16*(lit/16),ab); - if(b>0) + /*if(b>0) { - if((SFB16[cp].lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB16[cp]->lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) putpixel(496+b+(l%16)*8,111+a+(l/16)*16,GREEN); else putpixel(496+b+(l%16)*8,111+a+(l/16)*16,BLACK); } else { - if((SFB16[cp].lit[l].lin[a]/0x80)==1) + if((SFB16[cp]->lit[l].lin[a]/0x80)==1) putpixel(496+b+(l%16)*8,111+a+(l/16)*16,GREEN); else putpixel(496+b+(l%16)*8,111+a+(l/16)*16,BLACK); - } + }*/ + if(SFB16[cp]->lit[l].lin[a]&(0x80>>b)) + putpixel(496+b+(l%16)*8,111+a+(l/16)*16,GREEN); + else + putpixel(496+b+(l%16)*8,111+a+(l/16)*16,BLACK); } else { - if(b>0) + /*if(b>0) { - if((SFB16[cp].lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB16[cp]->lit[l].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) putpixel(496+b+(l%16)*8,111+a+(l/16)*16,BROWN); else putpixel(496+b+(l%16)*8,111+a+(l/16)*16,BLACK); } else { - if((SFB16[cp].lit[l].lin[a]/0x80)==1) + if((SFB16[cp]->lit[l].lin[a]/0x80)==1) putpixel(496+b+(l%16)*8,111+a+(l/16)*16,BROWN); else putpixel(496+b+(l%16)*8,111+a+(l/16)*16,EGA_BLACK); - } + }*/ + if(SFB16[cp]->lit[l].lin[a]&(0x80>>b)) + putpixel(496+b+(l%16)*8,111+a+(l/16)*16,BROWN); + else + putpixel(496+b+(l%16)*8,111+a+(l/16)*16,BLACK); } } } @@ -402,6 +643,8 @@ void lin16() } void lit8() { + if(!any) + return; setcolor(BLACK); for(int z=0;z<128;++z) line(16,32+z,143,32+z); @@ -415,6 +658,17 @@ void lit8() outtextxy(8,116,"5"); outtextxy(8,132,"6"); outtextxy(8,148,"7"); + + if(byo8[cp]==0) + { + setcolor(RED); + setfillstyle(SOLID_FILL,BLACK); + rectangle(16,32,143,159); + floodfill(20,40,RED); + line(16,32,143,159); + line(143,32,16,159); + return; + } for(int a=0;a<8;++a) { @@ -432,16 +686,18 @@ void lit8() ab[0]=abc[cury]; outtextxy(8,36+16*cury,ab); rectangle(0x10+b*0x10,0x20+a*0x10,0x1f+b*0x10,0x2f+a*0x10); - if(b>0) + /*if(b>0) { - if((SFB8[cp].lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB8[cp]->lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) floodfill(0x11+b*0x10,0x21+a*0x10,GREEN); } else { - if((SFB8[cp].lit[lit].lin[a]/0x80)==1) + if((SFB8[cp]->lit[lit].lin[a]/0x80)==1) floodfill(0x11+b*0x10,0x21+a*0x10,GREEN); - } + }*/ + if(SFB8[cp]->lit[lit].lin[a]&(0x80>>b)) + floodfill(0x11+b*0x10,0x21+a*0x10,GREEN); setcolor(BLACK); rectangle(0x11+b*0x10,0x21+a*0x10,0x1e+b*0x10,0x2e+a*0x10); } @@ -449,9 +705,9 @@ void lit8() { setcolor(BROWN); - if(b>0) + /*if(b>0) { - if((SFB8[cp].lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB8[cp]->lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) { rectangle(0x10+b*0x10,0x20+a*0x10,0x1f+b*0x10,0x2f+a*0x10); floodfill(0x11+b*0x10,0x21+a*0x10,BROWN); @@ -459,11 +715,16 @@ void lit8() } else { - if((SFB8[cp].lit[lit].lin[a]/0x80)==1) + if((SFB8[cp]->lit[lit].lin[a]/0x80)==1) { rectangle(0x10+b*0x10,0x20+a*0x10,0x1f+b*0x10,0x2f+a*0x10); floodfill(0x11+b*0x10,0x21+a*0x10,BROWN); } + }*/ + if(SFB8[cp]->lit[lit].lin[a]&(0x80>>b)) + { + rectangle(0x10+b*0x10,0x20+a*0x10,0x1f+b*0x10,0x2f+a*0x10); + floodfill(0x11+b*0x10,0x21+a*0x10,BROWN); } } } @@ -471,6 +732,8 @@ void lit8() } void lit14() { + if(!any) + return; setcolor(BLACK); for(int z=0;z<224;++z) line(16,223+z,143,223+z); @@ -491,6 +754,17 @@ void lit14() outtextxy(8,419,"C"); outtextxy(8,435,"D"); + if(byo14[cp]==0) + { + setcolor(RED); + setfillstyle(SOLID_FILL,BLACK); + rectangle(16,223,143,446); + floodfill(20,230,RED); + line(16,223,143,446); + line(143,223,16,446); + return; + } + for(int a=0;a<14;++a) { char ab[2]="q"; @@ -507,16 +781,18 @@ void lit14() ab[0]=abc[cury]; outtextxy(8,227+16*cury,ab); rectangle(16+b*16,223+a*16,31+b*16,238+a*16); - if(b>0) + /*if(b>0) { - if((SFB14[cp].lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB14[cp]->lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) floodfill(17+b*16,224+a*16,GREEN); } else { - if((SFB14[cp].lit[lit].lin[a]/0x80)==1) + if((SFB14[cp]->lit[lit].lin[a]/0x80)==1) floodfill(17+b*16,224+a*16,GREEN); - } + }*/ + if(SFB14[cp]->lit[lit].lin[a]&(0x80>>b)) + floodfill(17+b*16,224+a*16,GREEN); setcolor(BLACK); rectangle(17+b*16,224+a*16,30+b*16,237+a*16); } @@ -524,9 +800,9 @@ void lit14() { setcolor(BROWN); - if(b>0) + /*if(b>0) { - if((SFB14[cp].lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB14[cp]->lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) { rectangle(16+b*16,223+a*16,31+b*16,238+a*16); floodfill(17+b*16,224+a*16,BROWN); @@ -534,11 +810,16 @@ void lit14() } else { - if((SFB14[cp].lit[lit].lin[a]/0x80)==1) + if((SFB14[cp]->lit[lit].lin[a]/0x80)==1) { rectangle(16+b*16,223+a*16,31+b*16,238+a*16); floodfill(17+b*16,224+a*16,BROWN); } + }*/ + if(SFB14[cp]->lit[lit].lin[a]&(0x80>>b)) + { + rectangle(16+b*16,223+a*16,31+b*16,238+a*16); + floodfill(17+b*16,224+a*16,BROWN); } } } @@ -546,6 +827,8 @@ void lit14() } void lit16() { + if(!any) + return; setcolor(BLACK); for(int z=0;z<256;++z) line(336,111+z,463,111+z); @@ -568,6 +851,17 @@ void lit16() outtextxy(328,339,"E"); outtextxy(328,355,"F"); + if(byo16[cp]==0) + { + setcolor(RED); + setfillstyle(SOLID_FILL,BLACK); + rectangle(336,111,463,366); + floodfill(340,120,RED); + line(336,111,463,366); + line(463,111,336,366); + return; + } + for(int a=0;a<16;++a) { char ab[2]="q"; @@ -584,16 +878,18 @@ void lit16() ab[0]=abc[cury]; outtextxy(328,115+16*cury,ab); rectangle(336+b*16,111+a*16,351+b*16,126+a*16); - if(b>0) + /*if(b>0) { - if((SFB16[cp].lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB16[cp]->lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) floodfill(337+b*16,112+a*16,GREEN); } else { - if((SFB16[cp].lit[lit].lin[a]/0x80)==1) + if((SFB16[cp]->lit[lit].lin[a]/0x80)==1) floodfill(337+b*16,112+a*16,GREEN); - } + }*/ + if(SFB16[cp]->lit[lit].lin[a]&(0x80>>b)) + floodfill(337+b*16,112+a*16,GREEN); setcolor(BLACK); rectangle(337+b*16,112+a*16,350+b*16,125+a*16); } @@ -601,9 +897,9 @@ void lit16() { setcolor(BROWN); - if(b>0) + /*if(b>0) { - if((SFB16[cp].lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) + if((SFB16[cp]->lit[lit].lin[a]%(0x80/pot(2,b)*2))/(0x80/pot(2,b))==1) { rectangle(336+b*16,111+a*16,351+b*16,126+a*16); floodfill(337+b*16,112+a*16,BROWN); @@ -611,12 +907,17 @@ void lit16() } else { - if((SFB16[cp].lit[lit].lin[a]/0x80)==1) + if((SFB16[cp]->lit[lit].lin[a]/0x80)==1) { rectangle(336+b*16,111+a*16,351+b*16,126+a*16); floodfill(337+b*16,112+a*16,BROWN); } + }*/ + if(SFB16[cp]->lit[lit].lin[a]&(0x80>>b)) + { + rectangle(336+b*16,111+a*16,351+b*16,126+a*16); + floodfill(337+b*16,112+a*16,BROWN); } } } @@ -626,77 +927,92 @@ void lit16() void spc8() { - if(SFB8[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) - SFB8[cp].lit[lit].lin[cury]-=(0x80/pot(2,curx)); - else - SFB8[cp].lit[lit].lin[cury]+=(0x80/pot(2,curx)); + //if(SFB8[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) + // SFB8[cp]->lit[lit].lin[cury]-=(0x80/pot(2,curx)); + //else + // SFB8[cp]->lit[lit].lin[cury]+=(0x80/pot(2,curx)); + SFB8[cp]->lit[lit].lin[cury]^=0x80>>curx; } void bsp8() { - if(SFB8[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) - SFB8[cp].lit[lit].lin[cury]-=(0x80/pot(2,curx)); + //if(SFB8[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) + // SFB8[cp]->lit[lit].lin[cury]-=(0x80/pot(2,curx)); + SFB8[cp]->lit[lit].lin[cury]&=~(0x80>>curx); } void ent8() { - if(SFB8[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))!=1) - SFB8[cp].lit[lit].lin[cury]+=(0x80/pot(2,curx)); + //if(SFB8[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))!=1) + // SFB8[cp]->lit[lit].lin[cury]+=(0x80/pot(2,curx)); + SFB8[cp]->lit[lit].lin[cury]|=0x80>>curx; } void spc14() { - if(SFB14[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) - SFB14[cp].lit[lit].lin[cury]-=(0x80/pot(2,curx)); - else - SFB14[cp].lit[lit].lin[cury]+=(0x80/pot(2,curx)); + //if(SFB14[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) + // SFB14[cp]->lit[lit].lin[cury]-=(0x80/pot(2,curx)); + //else + // SFB14[cp]->lit[lit].lin[cury]+=(0x80/pot(2,curx)); + SFB14[cp]->lit[lit].lin[cury]^=0x80>>curx; } void bsp14() { - if(SFB14[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) - SFB14[cp].lit[lit].lin[cury]-=(0x80/pot(2,curx)); + //if(SFB14[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) + // SFB14[cp]->lit[lit].lin[cury]-=(0x80/pot(2,curx)); + SFB14[cp]->lit[lit].lin[cury]&=~(0x80>>curx); } void ent14() { - if(SFB14[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))!=1) - SFB14[cp].lit[lit].lin[cury]+=(0x80/pot(2,curx)); + //if(SFB14[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))!=1) + // SFB14[cp]->lit[lit].lin[cury]+=(0x80/pot(2,curx)); + SFB14[cp]->lit[lit].lin[cury]|=0x80>>curx; } void spc16() { - if(SFB16[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) - SFB16[cp].lit[lit].lin[cury]-=(0x80/pot(2,curx)); - else - SFB16[cp].lit[lit].lin[cury]+=(0x80/pot(2,curx)); + //if(SFB16[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) + // SFB16[cp]->lit[lit].lin[cury]-=(0x80/pot(2,curx)); + //else + // SFB16[cp]->lit[lit].lin[cury]+=(0x80/pot(2,curx)); + SFB16[cp]->lit[lit].lin[cury]^=0x80>>curx; } void bsp16() { - if(SFB16[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) - SFB16[cp].lit[lit].lin[cury]-=(0x80/pot(2,curx)); + //if(SFB16[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))==1) + // SFB16[cp]->lit[lit].lin[cury]-=(0x80/pot(2,curx)); + SFB16[cp]->lit[lit].lin[cury]&=~(0x80>>curx); } void ent16() { - if(SFB16[cp].lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))!=1) - SFB16[cp].lit[lit].lin[cury]+=(0x80/pot(2,curx)); + //if(SFB16[cp]->lit[lit].lin[cury]%(0x100/pot(2,curx))/(0x80/pot(2,curx))!=1) + // SFB16[cp]->lit[lit].lin[cury]+=(0x80/pot(2,curx)); + SFB16[cp]->lit[lit].lin[cury]|=0x80>>curx; } + + int otw2() { int a; int b; int c; int d; - for(int z=0;z<6;++z) - { - byo8[z]=0; - byo14[z]=0; - byo16[z]=0; - } + int NT; + + CPI=fopen(nazwap,"rb"); if(CPI==NULL) { - sprintf(err,"100: Bˆ¥d otwarcia pliku"); - return 1; + sprintf(err,"100:No valid file at this path"); + return 100; } else sprintf(err,"OK"); - fread(&FFH,0x19,1,CPI); + FFH=new FontFileHeader; + if(!FFH) + { + sprintf(err,"116:Not enough memory for FFH"); + fclose(CPI); + return 116; + } + fread(FFH,0x19,1,CPI); // printf("FFH:\n"); // printf("id0=%2x\n",FFH.id0); // printf("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]); @@ -705,47 +1021,85 @@ int otw2() // printf("ptyp=%2x\n",FFH.ptyp); // printf("fih_offset=%p\n\n",FFH.fih_offset); - if(FFH.id0!=0xff) + if(FFH->id0!=0xff) { - sprintf(err,"101: FFH.id0!=0xff"); + sprintf(err,"101:Unsupported format, id0=0x%02x",(short)(FFH->id0&0xff)); fclose(CPI); + deleteCPI(0); return 101; } - if(FFH.id[0]!='F'||FFH.id[1]!='O'||FFH.id[2]!='N'||FFH.id[3]!='T'||FFH.id[4]!=' '||FFH.id[5]!=' '||FFH.id[6]!=' ') + //if(FFH->id[0]!='F' || FFH->id[1]!='O' != FFH->id[2] != 'N'||FFH->id[3]!='T' || FFH->id[4]!=' '||FFH->id[5]!=' '||FFH->id[6]!=' ') + if(!strcmp("FONT ",FFH->id)) + NT=0; + else if(!strcmp("FONT.NT",FFH->id)) { - sprintf(err,"102: FFH.id!=\"FONT \""); + NT=1; + 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]); fclose(CPI); + deleteCPI(0); return 102; } - if(FFH.pnum!=1) + if(FFH->pnum!=1) { - sprintf(err,"103: FFH.pnum!=1\n"); + sprintf(err,"103:Wrong no. of pointers (%u)",FFH->pnum); fclose(CPI); + deleteCPI(0); return 103; } - if(FFH.ptyp!=1) + if(FFH->ptyp!=1) { - sprintf(err,"104: FFH.ptyp!=1\n"); + sprintf(err,"104:Wrong pointer type, (%u)",(short)(FFH->ptyp&0xff)); fclose(CPI); + deleteCPI(0); return 104; } - fseek(CPI,FFH.fih_offset,0); - fread(&FIH,0x2,1,CPI); + FIH=new FontInfoHeader; + if(!FIH) + { + sprintf(err,"116:Not enough memory for FIH"); + fclose(CPI); + deleteCPI(0); + return 116; + } + fseek(CPI,FFH->fih_offset,0); + fread(FIH,0x2,1,CPI); // printf("FFI:\n\n"); // printf("num_codepages=%d\n\n",FIH.num_codepages); - if(FIH.num_codepages>6) + if(FIH->num_codepages>16) { //FIH.num_codepages=6; - sprintf(err,"105: FIH.num_codepages>6\n"); + sprintf(err,"105:Too many codepages (%u)",FIH->num_codepages); fclose(CPI); + deleteCPI(1); return 105; } + + if(FIH->num_codepages==0) + { + sprintf(err,"117:No codepages"); + fclose(CPI); + deleteCPI(1); + return 117; + } - for(a=0; anum_codepages;++a) { if (a!=0) - fseek(CPI,CPEH[a-1].next_cpeh_offset,0); - fread(&CPEH[a],0x1c,1,CPI); + fseek(CPI,CPEH[a-1]->next_cpeh_offset,0); + CPEH[a] = new CodePageEntryHeader; + if(!CPEH[a]) + { + sprintf(err,"116:Not enough memory for CPEH[%d]",a); + deleteCPI(1); + return 116; + } + fread(CPEH[a],0x1c,1,CPI); // printf("CPEH[%d]:\n",a); // printf("cpeh_size=%x\n",CPEH[a].cpeh_size); // printf("next_cpeh_offset=%p\n",CPEH[a].next_cpeh_offset); @@ -754,101 +1108,194 @@ int otw2() // printf("codepage=%d\n",CPEH[a].codepage); // printf("reserved=%2x%2x%2x%2x%2x%2x\n",CPEH[a].reserved[0],CPEH[a].reserved[1],CPEH[a].reserved[2],CPEH[a].reserved[3],CPEH[a].reserved[4],CPEH[a].reserved[5]); // printf("cpih_offset=%p\n\n",CPEH[a].cpih_offset); - - if(CPEH[a].cpeh_size!=0x1c) + if(NT) { - sprintf(err,"106: CPEH.cpeh_size!=0x1c\n"); + CPEH[a]->next_cpeh_offset+=ftell(CPI)-sizeof(CodePageEntryHeader); + CPEH[a]->cpih_offset+=ftell(CPI)-sizeof(CodePageEntryHeader); + } + if(CPEH[a]->cpeh_size!=0x1c) + { + sprintf(err,"106:Wrong CPEH[%u] size (0x%x)",a,CPEH[a]->cpeh_size); fclose(CPI); + deleteCPI(2,a); return 106; } - if(CPEH[a].device_type!=1) + if(CPEH[a]->device_type!=1) { - sprintf(err,"107: CPEH.device_type!=1\n"); + sprintf(err,"107:Wrong device type(%u) in CPEH[%u]",CPEH[a]->device_type,a); fclose(CPI); + deleteCPI(2,a); return 107; } - - fseek(CPI,CPEH[a].cpih_offset,0); - fread(&CPIH[a],0x6,1,CPI); + for(short i=0;icodepage==CPEH[i]->codepage) + { + sprintf(err,"114:cp%03u (%u) already in CPEH[%u]",CPEH[a]->codepage,a,i); + fclose(CPI); + deleteCPI(2,a); + return 114; + } + } + fseek(CPI,CPEH[a]->cpih_offset,0); + CPIH[a] = new CodePageInfoHeader; + if(!CPIH[a]) + { + sprintf(err,"116:Not enough memory for CPIH[%d]",a); + fclose(CPI); + deleteCPI(2,a); + return 116; + } + fread(CPIH[a],0x6,1,CPI); // printf("CPIH[%d]:\n",a); // printf("version=%d\n",CPIH[a].version); // printf("num_fonts=%d\n",CPIH[a].num_fonts); // printf("size=%x\n\n",CPIH[a].size); - if(CPIH[a].version!=1) + if(CPIH[a]->version!=1) { - sprintf(err,"108: CPIH.version!=1\n"); + sprintf(err,"108:Wrong version of CPIH[%u] (%u)",a,CPIH[a]->version); fclose(CPI); + deleteCPI(3,a); return 108; } - if(CPIH[a].num_fonts>3) + if(CPIH[a]->num_fonts>3) { - sprintf(err,"109: CPIH.numfonts>3\n"); + sprintf(err,"109:Too many fonts in CPIH[%u] (%u)",a,CPIH[a]->num_fonts); fclose(CPI); + deleteCPI(3,a); return 109; } - for(b=0;bnum_fonts==0) { - fread(&SFH[a][b],0x6,1,CPI); + sprintf(err,"115:No fonts in CPIH[%u])",a); + fclose(CPI); + deleteCPI(3,a); + return 115; + } + for(b=0;bnum_fonts;++b) + { + SFH[a][b] = new ScreenFontHeader; + if(!SFH[a][b]) + { + sprintf(err,"116:Not enough memory for SFH[%d][%d]",a); + fclose(CPI); + if(b==0) + deleteCPI(3,a); + else + deleteCPI(5,a,b-1); + return 116; + } + fread(SFH[a][b],0x6,1,CPI); // printf("SFH[%d][%d]:\n",a,b); // printf("height=%d\n",SFH[a][b].height); // printf("width=%d\n",SFH[a][b].width); // printf("yaspect=%2x\n",SFH[a][b].yaspect); // printf("xaspect=%2x\n",SFH[a][b].xaspect); // printf("num_chars=%d\n\n",SFH[a][b].num_chars); - fseek(CPI,SFH[a][b].num_chars*SFH[a][b].height*((SFH[a][b].width+7)/8),1); - if(SFH[a][b].height==8) + //fseek(CPI,SFH[a][b].num_chars*SFH[a][b].height*((SFH[a][b].width+7)/8),1); + if(SFH[a][b]->height==8) { if (byo8[a]!=0) { - sprintf(err,"113: SFH.height==8 ju¾ byˆo"); + sprintf(err,"113:Height 8 already in cp%03u (%u;%u)",CPEH[a]->codepage,a,b); fclose(CPI); + deleteCPI(4,a,b); return 113; } byo8[a]=1; } - if(SFH[a][b].height==14) + if(SFH[a][b]->height==14) { if (byo14[a]!=0) { - sprintf(err,"114: SFH.height==14 ju¾ byˆo"); + sprintf(err,"113:Height 14 already in cp%03u (%u;%u)",CPEH[a]->codepage,a,b); fclose(CPI); - return 114; + deleteCPI(4,a,b); + return 113; } byo14[a]=1; } - if(SFH[a][b].height==16) + if(SFH[a][b]->height==16) { if (byo16[a]!=0) { - sprintf(err,"115: SFH.height==16 ju¾ byˆo"); + sprintf(err,"113:Height 16 already in cp%03u (%u;%u)",CPEH[a]->codepage,a,b); fclose(CPI); - return 115; + deleteCPI(4,a,b); + return 113; } byo16[a]=1; } - if(SFH[a][b].height!=8&&SFH[a][b].height!=14&&SFH[a][b].height!=16) + if(SFH[a][b]->height!=8&&SFH[a][b]->height!=14&&SFH[a][b]->height!=16) { - sprintf(err,"110: SFH.height!=(8 || 14 || 16)\n"); + sprintf(err,"110:Wrong height (%u) in SFH[%u][%u]",(short)(SFH[a][b]->height&0xff),a,b); fclose(CPI); + deleteCPI(4,a,b); return 110; } - if(SFH[a][b].width!=8) + if(SFH[a][b]->width!=8) { - sprintf(err,"111: SFH.width!=8\n"); + sprintf(err,"111:Wrong width (%u) in SFH[%u][%u]",(short)(SFH[a][b]->width&0xff),a,b); fclose(CPI); + deleteCPI(4,a,b); return 111; } - if(SFH[a][b].num_chars!=256) + if(SFH[a][b]->num_chars!=256) { - sprintf(err,"112: SFH.num_chars!=256\n"); + sprintf(err,"112:Wrong no.of chars(%u)in SFH[%u][%u]",SFH[a][b]->num_chars,a,b); fclose(CPI); + deleteCPI(4,a,b); return 112; } + + if(SFH[a][b]->height==16) + { + SFB16[a] = new ScreenFontBitmap16; + if(!SFB16[a]) + { + sprintf(err,"116:Not enough memory for SFB16[%d] (%d)",a,b); + fclose(CPI); + deleteCPI(4,a,b); + return 116; + } + //for(c=0;c<256;++c) + // fread(&SFB16[a].lit[c],0x10,1,CPI); + fread(SFB16[a],0x10,256,CPI); + } + if(SFH[a][b]->height==14) + { + SFB14[a] = new ScreenFontBitmap14; + if(!SFB14[a]) + { + sprintf(err,"116:Not enough memory for SFB14[%d] (%d)",a,b); + fclose(CPI); + deleteCPI(4,a,b); + return 116; + } + //for(c=0;c<256;++c) + // fread(&SFB14[a].lit[c],0x0e,1,CPI); + fread(SFB14[a],0x0e,256,CPI); + } + if(SFH[a][b]->height==8) + { + SFB8[a] = new ScreenFontBitmap8; + if(!SFB8[a]) + { + sprintf(err,"116:Not enough memory for SFB8[%d] (%d)",a,b); + fclose(CPI); + deleteCPI(4,a,b); + return 116; + } + //for(c=0;c<256;++c) + // fread(&SFB8[a].lit[c],0x08,1,CPI); + fread(SFB8[a],0x08,256,CPI); + } + //fseek(CPI,SFH[a][b]->num_chars*SFH[a][b]->height*((SFH[a][b]->width+7)/8),1); } - for(b=0;b0) @@ -871,10 +1318,11 @@ int otw2() for(c=0;c<256;++c) fread(&SFB8[a].lit[c],0x08,1,CPI); } - } + }*/ } fclose(CPI); + offset(); return 0; } int zap2() @@ -888,12 +1336,12 @@ int zap2() if(CPI==NULL) { - sprintf(err,"200: Bˆ¥d utworzenia pliku:"); + sprintf(err,"200:Cannot create file at this path"); return 200; } else sprintf(err,"OK"); - fwrite(&FFH,0x19,1,CPI); + fwrite(FFH,0x19,1,CPI); // printf("FFH:\n"); // printf("id0=%2x\n",FFH.id0); // printf("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]); @@ -926,8 +1374,8 @@ int zap2() fclose(CPI); return 104; }*/ - fseek(CPI,FFH.fih_offset,0); - fwrite(&FIH,0x2,1,CPI); + fseek(CPI,FFH->fih_offset,0); + fwrite(FIH,0x2,1,CPI); // printf("FFI:\n\n"); // printf("num_codepages=%d\n\n",FIH.num_codepages); /*if(FIH.num_codepages>6) @@ -938,11 +1386,11 @@ int zap2() return 105; }*/ - for(a=0; anum_codepages;++a) { if (a!=0) - fseek(CPI,CPEH[a-1].next_cpeh_offset,0); - fwrite(&CPEH[a],0x1c,1,CPI); + fseek(CPI,CPEH[a-1]->next_cpeh_offset,0); + fwrite(CPEH[a],0x1c,1,CPI); // printf("CPEH[%d]:\n",a); // printf("cpeh_size=%x\n",CPEH[a].cpeh_size); // printf("next_cpeh_offset=%p\n",CPEH[a].next_cpeh_offset); @@ -965,8 +1413,8 @@ int zap2() return 107; }*/ - fseek(CPI,CPEH[a].cpih_offset,0); - fwrite(&CPIH[a],0x6,1,CPI); + fseek(CPI,CPEH[a]->cpih_offset,0); + fwrite(CPIH[a],0x6,1,CPI); // printf("CPIH[%d]:\n",a); // printf("version=%d\n",CPIH[a].version); // printf("num_fonts=%d\n",CPIH[a].num_fonts); @@ -984,16 +1432,16 @@ int zap2() fclose(CPI); return 109; }*/ - for(b=0;bnum_fonts;++b) { - fwrite(&SFH[a][b],0x6,1,CPI); + fwrite(SFH[a][b],0x6,1,CPI); // printf("SFH[%d][%d]:\n",a,b); // printf("height=%d\n",SFH[a][b].height); // printf("width=%d\n",SFH[a][b].width); // printf("yaspect=%2x\n",SFH[a][b].yaspect); // printf("xaspect=%2x\n",SFH[a][b].xaspect); // printf("num_chars=%d\n\n",SFH[a][b].num_chars); - fseek(CPI,SFH[a][b].num_chars*SFH[a][b].height*((SFH[a][b].width+7)/8),1); + //fseek(CPI,SFH[a][b]->num_chars*SFH[a][b]->height*((SFH[a][b]->width+7)/8),1); /*if(SFH[a][b].height==8) { if (byo8[a]!=0) @@ -1044,8 +1492,27 @@ int zap2() fclose(CPI); return 112; }*/ + if(SFH[a][b]->height==16) + { + //for(c=0;c<256;++c) + // fread(&SFB16[a].lit[c],0x10,1,CPI); + fwrite(SFB16[a],0x10,256,CPI); + } + if(SFH[a][b]->height==14) + { + //for(c=0;c<256;++c) + // fread(&SFB14[a].lit[c],0x0e,1,CPI); + fwrite(SFB14[a],0x0e,256,CPI); + } + if(SFH[a][b]->height==8) + { + //for(c=0;c<256;++c) + // fread(&SFB8[a].lit[c],0x08,1,CPI); + fwrite(SFB8[a],0x08,256,CPI); + } + //fseek(CPI,SFH[a][b]->num_chars*SFH[a][b]->height*((SFH[a][b]->width+7)/8),1); } - for(b=0;bnum_fonts;++b) { fseek(CPI,CPEH[a].cpih_offset+0xc,0); if(b>0) @@ -1068,84 +1535,770 @@ int zap2() for(c=0;c<256;++c) fwrite(&SFB8[a].lit[c],0x08,1,CPI); } - } + }*/ } - fprintf(CPI,"\nTen plik zostaˆ wygenerowany za pomoc¥ Edytora napis¢w, wersja 1.0\n autor programu: Balthasar Szczepaäski%c",0x1a); + fprintf(CPI,"\nTen plik zostaˆ wygenerowany za pomoc¥ Edytora napis¢w, wersja 1.1\n autor programu: Balthasar Szczepaäski%c",0x1a); fclose(CPI); return 0; } -int otw() +int newF8(short CP) { - printf("\n\n\n\n\n\n\n\n\n\n\n\n "); - setcolor(BLACK); - - outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + if(byo8[CP]) + { + sprintf(err,"313:Height 8 already in cp%03u",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); + return 316; + } + if(!(SFB8[CP]=new ScreenFontBitmap8)) + { + sprintf(err,"316:Not enough memory for SFB8[%d]",CP); + delete SFH[CP][CPIH[CP]->num_fonts]; + SFH[CP][CPIH[CP]->num_fonts] = NULL; + return 316; + } + memset(SFB8[CP],0,0x800); + byo8[CP]=1; + SFH[CP][CPIH[CP]->num_fonts]->height=8; + SFH[CP][CPIH[CP]->num_fonts]->width=8; + SFH[CP][CPIH[CP]->num_fonts]->yaspect=0; + SFH[CP][CPIH[CP]->num_fonts]->xaspect=0; + SFH[CP][CPIH[CP]->num_fonts]->num_chars=256; + ++(CPIH[CP]->num_fonts); + offset(); + sprintf(err,"0:OK"); + return 0; +} - setcolor(GREEN); +int newF14(short CP) +{ + if(byo14[CP]) + { + sprintf(err,"313:Height 14 already in cp%03u",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); + return 316; + } + if(!(SFB14[CP]=new ScreenFontBitmap14)) + { + sprintf(err,"316:Not enough memory for SFB14[%d]",CP); + delete SFH[CP][CPIH[CP]->num_fonts]; + SFH[CP][CPIH[CP]->num_fonts] = NULL; + return 316; + } + memset(SFB14[CP],0,0xe00); + byo14[CP]=1; + SFH[CP][CPIH[CP]->num_fonts]->height=14; + SFH[CP][CPIH[CP]->num_fonts]->width=8; + SFH[CP][CPIH[CP]->num_fonts]->yaspect=0; + SFH[CP][CPIH[CP]->num_fonts]->xaspect=0; + SFH[CP][CPIH[CP]->num_fonts]->num_chars=256; + ++(CPIH[CP]->num_fonts); + offset(); + sprintf(err,"0:OK"); + return 0; +} - outtextxy(144,184," ±Nazwa pliku:±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); - outtextxy(144,192," ± ± "); - outtextxy(144,200," ± ± "); - outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); - scanf("%s",nazwap); +int newF16(short CP) +{ + if(byo16[CP]) + { + sprintf(err,"313:Height 16 already in cp%03u",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); + return 316; + } + if(!(SFB16[CP]=new ScreenFontBitmap16)) + { + sprintf(err,"316:Not enough memory for SFB16[%d]",CP); + delete SFH[CP][CPIH[CP]->num_fonts]; + SFH[CP][CPIH[CP]->num_fonts] = NULL; + return 316; + } + memset(SFB16[CP],0,0x1000); + byo16[CP]=1; + SFH[CP][CPIH[CP]->num_fonts]->height=16; + SFH[CP][CPIH[CP]->num_fonts]->width=8; + SFH[CP][CPIH[CP]->num_fonts]->yaspect=0; + SFH[CP][CPIH[CP]->num_fonts]->xaspect=0; + SFH[CP][CPIH[CP]->num_fonts]->num_chars=256; + ++(CPIH[CP]->num_fonts); + sprintf(err,"0:OK"); + return 0; +} - closegraph(); - initgraph(&kart16,&tryb16,""); - return otw2(); +int newF2(short h) +{ + switch(h) + { + case 8: + return newF8(cp); + case 14: + return newF14(cp); + case 16: + return newF16(cp); + default: + sprintf(err,"310:Wrong height (%u)",h); + return 310; + } } -int zap() +int delF8(short h) { - printf("\n\n\n\n\n\n\n\n\n\n\n\n "); - setcolor(BLACK); - - outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - - setcolor(GREEN); - - outtextxy(144,184," ±Nazwa pliku:±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); - outtextxy(144,192," ± ± "); - outtextxy(144,200," ± ± "); - outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); - scanf("%s",nazwap); - - closegraph(); - initgraph(&kart16,&tryb16,""); - return zap2(); + short i; + delete SFB8[cp]; + delete SFH[cp][h]; + byo8[cp]=0; + --(CPIH[cp]->num_fonts); + for(i=h;inum_fonts;++i) + { + SFH[cp][i] = SFH[cp][i+1]; + } + SFH[cp][CPIH[cp]->num_fonts] = NULL; + sprintf(err,"0:OK"); + return 0; } -int zmn() +int delF14(short h) { - printf("\n\n\n\n\n\n\n\n\n\n\n\n "); - setcolor(BLACK); - - outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); - - setcolor(GREEN); - - outtextxy(144,184," ±Numer strony kodowej:±±±±±±±±±±±±±±±±±±±± "); + short i; + delete SFB14[cp]; + delete SFH[cp][h]; + byo14[cp]=0; + --(CPIH[cp]->num_fonts); + for(i=h;inum_fonts;++i) + { + SFH[cp][i] = SFH[cp][i+1]; + } + SFH[cp][CPIH[cp]->num_fonts] = NULL; + sprintf(err,"0:OK"); + return 0; +} +int delF16(short h) +{ + short i; + delete SFB16[cp]; + delete SFH[cp][h]; + byo16[cp]=0; + --(CPIH[cp]->num_fonts); + for(i=h;inum_fonts;++i) + { + SFH[cp][i] = SFH[cp][i+1]; + } + SFH[cp][CPIH[cp]->num_fonts] = NULL; + sprintf(err,"0:OK"); + return 0; +} + +int delCP() +{ + short i; + if(FIH->num_codepages<=1) + { + sprintf(err,"317:Last codepage"); + return 317; + } + for(i=0;inum_fonts;++i) + { + switch(SFH[cp][i]->height) + { + case 16: + delete SFB16[cp]; + break; + case 14: + delete SFB14[cp]; + break; + case 8: + delete SFB8[cp]; + break; + //unxh! + } + delete SFH[cp][i]; + } + delete CPIH[cp]; + delete CPEH[cp]; + + --(FIH->num_codepages); + for(i=cp;inum_codepages;++i) + { + CPEH[i] = CPEH[i+1]; + CPIH[i] = CPIH[i+1]; + SFH[i][0] = SFH[i+1][0]; + SFH[i][1] = SFH[i+1][1]; + SFH[i][2] = SFH[i+1][2]; + SFB16[i] = SFB16[i+1]; + SFB14[i] = SFB14[i+1]; + SFB8[i] = SFB8[i+1]; + byo16[i] = byo16[i+1]; + byo14[i] = byo14[i+1]; + byo8[i] = byo8[i+1]; + } + CPEH[FIH->num_codepages] = NULL; + CPIH[FIH->num_codepages] = NULL; + SFH[FIH->num_codepages][0] = NULL; + SFH[FIH->num_codepages][1] = NULL; + SFH[FIH->num_codepages][2] = NULL; + SFB16[FIH->num_codepages] = NULL; + SFB14[FIH->num_codepages] = NULL; + SFB8[FIH->num_codepages] = NULL; + byo16[FIH->num_codepages] = 0; + byo14[FIH->num_codepages] = 0; + byo8[FIH->num_codepages] = 0; + + sprintf(err,"0:OK"); + return 0; +} + +int delF() +{ + short h; + if(CPIH[cp]->num_fonts<=1) + { + sprintf(err,"315:Last font in CPIH[%u]",cp); + return 315; + } + for(short i=0;inum_fonts;++i) + { + if(SFH[cp][i]->height==wys) + { + h=i; + break; + } + } + switch(wys) + { + case 8: + return delF8(h); + case 14: + return delF14(h); + case 16: + return delF16(h); + default: + sprintf(err,"510:%u WT*?",h); + return 510; + } +} +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); + 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); + return 316; + } + CPEH[FIH->num_codepages]->cpeh_size=0x1c; + CPEH[FIH->num_codepages]->device_type=1; + strcpy(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"); + CPIH[FIH->num_codepages]->version=1; + CPIH[FIH->num_codepages]->num_fonts=0; + switch(h) + { + case 8: + t= newF8(FIH->num_codepages); + break; + case 14: + t= newF14(FIH->num_codepages); + break; + case 16: + t = newF16(FIH->num_codepages); + break; + case 0: + t= newF16(FIH->num_codepages); + if(t!=0) + break; + t= newF14(FIH->num_codepages); + if(t!=0) + { + delete SFB16[FIH->num_codepages]; + delete SFH[FIH->num_codepages][0]; + SFB16[FIH->num_codepages] = NULL; + SFH[FIH->num_codepages][0] = NULL; + byo16[FIH->num_codepages] = 0; + break; + } + t= newF8(FIH->num_codepages); + if(t!=0) + { + delete SFB16[FIH->num_codepages]; + delete SFB14[FIH->num_codepages]; + delete SFH[FIH->num_codepages][0]; + delete SFH[FIH->num_codepages][1]; + SFB16[FIH->num_codepages] = NULL; + SFB14[FIH->num_codepages] = NULL; + SFH[FIH->num_codepages][0] = NULL; + SFH[FIH->num_codepages][1] = NULL; + byo16[FIH->num_codepages] = 0; + byo14[FIH->num_codepages] = 0; + break; + } + break; + default: + sprintf(err,"510:%u WT*?",h); + t = 510; + } + if(t!=0) + { + delete CPIH[FIH->num_codepages]; + delete CPEH[FIH->num_codepages]; + CPEH[FIH->num_codepages] = NULL; + CPEH[FIH->num_codepages] = NULL; + return t; + } + ++(FIH->num_codepages); + sprintf(err,"0:OK"); + return 0; +} + +int newCPI2(short CP, short h) +{ + int t; + FFH=new FontFileHeader; + if(!FFH) + { + sprintf(err,"316:Not enough memory for FFH"); + return 316; + } + FFH->id0=0xFF; + strcpy(FFH->id,"FONT "); + strcpy(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"); + deleteCPI(0); + return 316; + } + FIH->num_codepages=0; + t = newCP2(CP,h); + if (t!=0) + { + deleteCPI(1); + return t; + } + sprintf(err,"0:Ok"); + return 0; +} + +int newCPI() +{ + short CP,h; + char temp[51]; + + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(GREEN); + + outtextxy(144,184," ±First codepage number:±±±±±±±±±±±±±±±±±±± "); outtextxy(144,192," ± ± "); outtextxy(144,200," ± ± "); outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); - scanf("%d",&CPEH[cp].codepage); - closegraph(); - initgraph(&kart16,&tryb16,""); - return CPEH[cp].codepage; + scanf("%u",&CP); + + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(GREEN); + + outtextxy(144,184," ±Initial font Height(8,14,16,all)±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + + scanf("%s",temp); + h=atoi(temp); + if(h!=0&&h!=8&&h!=14&&h!=16) + { + sprintf(err,"310:Wrong height (%u)",h); + return 310; + } + return newCPI2(CP,h); +} + + + +int newCP() +{ + short CP,h; + char temp[51]; + if(FIH->num_codepages>=16) + { + sprintf(err,"305:Already 16 codepages in CPI"); + return 305; + } + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(GREEN); + + outtextxy(144,184," ±Codepage number:±±±±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + + scanf("%u",&CP); + for(short i=0;inum_codepages;++i) + { + if(CP==CPEH[i]->codepage) + { + sprintf(err,"314:cp%03u already in CPEH[%u]",CP,i); + return 314; + } + } + + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(GREEN); + + outtextxy(144,184," ±Initial font Height(8,14,16,all)±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + + scanf("%s",temp); + h=atoi(temp); + if(h!=0&&h!=8&&h!=14&&h!=16) + { + sprintf(err,"310:Wrong height (%u)",h); + return 310; + } + return newCP2(CP,h); +} +int newF() +{ + if(CPIH[cp]->num_fonts>=3) + { + sprintf(err,"309:Already 3 fonts in CPIH[%u]",cp); + return 309; + } + + short h; + + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(GREEN); + + outtextxy(144,184," ±Font Height(8,14,16)±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + scanf("%u",&h); + + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return newF2(h); +} + +int otw() +{ + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(GREEN); + + outtextxy(144,184," ±Filename:±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + scanf("%s",nazwap); + + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return otw2(); +} + +int zap() +{ + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(GREEN); + + outtextxy(144,184," ±Filename:±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + scanf("%s",nazwap); + + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return zap2(); +} +int zmn() +{ + short CP; + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(GREEN); + + outtextxy(144,184," ±Codepage number:±±±±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± "); + + scanf("%u",&CP); + for(short i=0;inum_codepages;++i) + { + if(CP==CPEH[i]->codepage&&i!=cp) + { + sprintf(err,"314:cp%03u already in CPEH[%u]",CP,i); + return 314; + } + } + CPEH[cp]->codepage=CP; + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return 0; +} +int bnd() +{ + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(BROWN); + + outtextxy(144,184," ±CPI file not loaded±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±again?(y/n)± "); + + printf("%s",err); + int a; + for(;;) + { + a=bioskey(_KEYBRD_READ); + if((a&0xFF)==0x59||(a&0xFF)==0x79) + { + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return 0; + } + if((a&0xFF)==0x4e||(a&0xff)==0x6e) + { + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return 1; + } + + } + + +} +int bnd2() +{ + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(BROWN); + + outtextxy(144,184," ±CPI file not saved±±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±again?(y/n)± "); + + printf("%s",err); + int a; + for(;;) + { + a=bioskey(_KEYBRD_READ); + if((a&0xFF)==0x59||(a&0xFF)==0x79) + { + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return 0; + } + if((a&0xFF)==0x4e||(a&0xff)==0x6e) + { + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return 1; + } + + } +} + +int bnd8() +{ + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(BROWN); + + outtextxy(144,184," ±CPI not created±±±±±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±again?(y/n)± "); + + printf("%s",err); + int a; + for(;;) + { + a=bioskey(_KEYBRD_READ); + if((a&0xFF)==0x59||(a&0xFF)==0x79) + { + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return 0; + } + if((a&0xFF)==0x4e||(a&0xff)==0x6e) + { + //closegraph(); + //initgraph(&kart16,&tryb16,""); + return 1; + } + + } +} + +int bnd3() +{ + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(BROWN); + + outtextxy(144,184," ±Font not created±±±±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey± "); + + printf("%s",err); + bioskey(_KEYBRD_READ); +// closegraph(); +// initgraph(&kart16,&tryb16,""); + return 0; + + + +} + +int bnd6() +{ + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(BROWN); + + outtextxy(144,184," ±Codepage not created±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey± "); + + printf("%s",err); + bioskey(_KEYBRD_READ); +// closegraph(); +// initgraph(&kart16,&tryb16,""); + return 0; } -int bnd() + +int bnd4() { - printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); setcolor(BLACK); outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); @@ -1155,36 +2308,22 @@ int bnd() setcolor(BROWN); - outtextxy(144,184," ±Nie wczytano pliku CPI±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,184," ±Font not deleted±±±±±±±±±±±±±±±±±±±±±±±±± "); outtextxy(144,192," ± ± "); outtextxy(144,200," ± ± "); - outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±jeszcze raz?(t/n)± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey± "); printf("%s",err); - int a; - for(;;) - { - a=bioskey(_KEYBRD_READ); - if(a/0x100==0x14) - { - closegraph(); - initgraph(&kart16,&tryb16,""); - return 0; - } - if(a/0x100==0x31) - { - closegraph(); - initgraph(&kart16,&tryb16,""); - return 1; - } - - } - - + bioskey(_KEYBRD_READ); +// closegraph(); +// initgraph(&kart16,&tryb16,""); + return 0; } -int bnd2() + +int bnd7() { - printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); setcolor(BLACK); outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); @@ -1194,36 +2333,48 @@ int bnd2() setcolor(BROWN); - outtextxy(144,184," ±Nie zapisano pliku CPI±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,184," ±Codepage not deleted±±±±±±±±±±±±±±±±±±±±± "); outtextxy(144,192," ± ± "); outtextxy(144,200," ± ± "); - outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±jeszcze raz?(t/n)± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey± "); printf("%s",err); - int a; - for(;;) - { - a=bioskey(_KEYBRD_READ); - if(a/0x100==0x14) - { - closegraph(); - initgraph(&kart16,&tryb16,""); - return 0; - } - if(a/0x100==0x31) - { - closegraph(); - initgraph(&kart16,&tryb16,""); - return 1; - } + bioskey(_KEYBRD_READ); +// closegraph(); +// initgraph(&kart16,&tryb16,""); + return 0; +} - } +int bnd5() +{ + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + setcolor(BLACK); + + outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,192," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,200," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + outtextxy(144,208," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); + + setcolor(BROWN); + + outtextxy(144,184," ±Number not changed±±±±±±±±±±±±±±±±±±±±±±± "); + outtextxy(144,192," ± ± "); + outtextxy(144,200," ± ± "); + outtextxy(144,208," ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey± "); + printf("%s",err); + bioskey(_KEYBRD_READ); +// closegraph(); +// initgraph(&kart16,&tryb16,""); + return 0; } + int pmc() { - printf("\n\n\n\n\n\n\n\n\n\n\n\n "); + gotoxy(21,13); + //printf("\n\n\n\n\n\n\n\n\n\n\n\n "); setcolor(BLACK); outtextxy(144,184," ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ "); @@ -1240,8 +2391,8 @@ int pmc() printf("%s",err); bioskey(_KEYBRD_READ); - closegraph(); - initgraph(&kart16,&tryb16,""); +// closegraph(); +// initgraph(&kart16,&tryb16,""); return 0; @@ -1252,48 +2403,51 @@ int pmc() int main(int argc,char* argv[]) { - - - - - + nullpointers(); // registerbgidriver(CGA_driver); registerbgidriver(EGAVGA_driver); initgraph(&kart16,&tryb16,""); wys=8; - new8(); - menu8(); - cpwys(); - ramka8(); - ramka14(); - ramka16(); - lit8(); - lit14(); - lit16(); - lin8(); - lin14(); - lin16(); + //new8(); + //menu8(); + //cpwys(); setcolor(RED); - outtextxy(184,472,"odczyt"); + outtextxy(136,472,"load"); if(argc>1) { + new8(); + menu8(); + cpwys(); sprintf(nazwap,"%s",argv[1]); status=otw2(); + + while(status!=0) + { + if (bnd()==0) + status=otw(); + else + { + break; + //closegraph(); + //deleteCPI(); + //return status; + } + } + any=!status; } else - status=otw(); - while(status!=0) - { - if (bnd()==0) - status=otw(); - else - return status; - } - - - + any=0; + + + if(byo8[0]) + wys=8; + else if(byo16[0]) + wys=16; + else if(byo14[0]) + wys=14; + new8(); menu8(); @@ -1313,13 +2467,15 @@ int main(int argc,char* argv[]) key=bioskey(_KEYBRD_READ); if(tab==0) { - if(key/0x100==0x48) + if((key&0xFF00)==0x4800&&any) { //w g¢r© - if(cury==0) - cury=wys-1; - else - --cury; + //if(cury==0) + // cury=wys-1; + //else + // --cury; + cury+=wys-1; + cury%=wys; if(wys==8) lit8(); if(wys==14) @@ -1327,13 +2483,15 @@ int main(int argc,char* argv[]) if(wys==16) lit16(); } - if(key/0x100==0x50) + if((key&0xFF00)==0x5000&&any) { //w d¢ˆ - if(cury==wys-1) - cury=0; - else - ++cury; + //if(cury==wys-1) + // cury=0; + //else + // ++cury; + ++cury; + cury%=wys; if(wys==8) lit8(); if(wys==14) @@ -1342,13 +2500,15 @@ int main(int argc,char* argv[]) lit16(); } - if(key/0x100==0x4b) + if((key&0xFF00)==0x4b00&&any) { //w lewo - if(curx==0) - curx=7; - else - --curx; + //if(curx==0) + // curx=7; + //else + // --curx; + --curx; + curx&=0x7; if(wys==8) lit8(); if(wys==14) @@ -1356,13 +2516,15 @@ int main(int argc,char* argv[]) if(wys==16) lit16(); } - if(key/0x100==0x4d) + if((key&0xFF00)==0x4d00&&any) { //w prawo - if(curx==7) - curx=0; - else - ++curx; + //if(curx==7) + // curx=0; + //else + // ++curx; + ++curx; + curx&=0x7; if(wys==8) lit8(); if(wys==14) @@ -1370,7 +2532,7 @@ int main(int argc,char* argv[]) if(wys==16) lit16(); } - if (key/0x100==0x39) + if ((key&0xFF00)==0x3900&&any) { //spacja if(wys==8) @@ -1392,7 +2554,7 @@ int main(int argc,char* argv[]) lin16(); } } - if (key/0x100==0x0e) + if ((key&0xFF00)==0x0e00&&any) { //backspace if(wys==8) @@ -1414,7 +2576,7 @@ int main(int argc,char* argv[]) lin16(); } } - if (key/0x100==0x1c) + if ((key&0xFF00)==0x1c00&&any) { //enter if(wys==8) @@ -1441,13 +2603,15 @@ int main(int argc,char* argv[]) } else { - if(key/0x100==0x48) + if((key&0xFF00)==0x4800&&any) { //w g¢r© l - if(lit<16) - lit=(0xf0+lit%16); - else - lit=((lit/16-1)*16+lit%16); + //if(lit<16) + // lit=(0xf0+lit%16); + //else + // lit=((lit/16-1)*16+lit%16); + lit-=16; + lit&=0xFF; lit8(); lit14(); lit16(); @@ -1459,13 +2623,15 @@ int main(int argc,char* argv[]) lin16(); } - if(key/0x100==0x50) + if((key&0xFF00)==0x5000&&any) { //w d¢ˆ l - if(lit>=0xf0) - lit=(0+lit%16); - else - lit=((lit/16+1)*16+lit%16); + //if(lit>=0xf0) + // lit=(0+lit%16); + //else + // lit=((lit/16+1)*16+lit%16); + lit+=16; + lit&=0xFF; lit8(); lit14(); lit16(); @@ -1476,13 +2642,15 @@ int main(int argc,char* argv[]) if (wys==16) lin16(); } - if(key/0x100==0x4b) + if((key&0xFF00)==0x4b00&&any) { //w lewo l - if(lit%16==0) - lit+=15; - else - --lit; + //if(lit%16==0) + // lit+=15; + //else + // --lit; + --lit; + lit&=0xFF; lit8(); lit14(); lit16(); @@ -1493,14 +2661,16 @@ int main(int argc,char* argv[]) if (wys==16) lin16(); } - if(key/0x100==0x4d) + if((key&0xFF00)==0x4d00&&any) { //w prawo l - if(lit%16==15) - lit-=15; - else - ++lit; + //if(lit%16==15) + // lit-=15; + //else + // ++lit; + ++lit; + lit&=0xFF; lit8(); lit14(); lit16(); @@ -1512,7 +2682,7 @@ int main(int argc,char* argv[]) lin16(); } } - if (key/0x100==0x0f) + if ((key&0xFF00)==0x0f00&&any) { //tab if(tab==0) @@ -1523,13 +2693,43 @@ int main(int argc,char* argv[]) ramka14(); ramka16(); } - if (key/0x100==0x51) + if ((key&0xFF00)==0x5100&&any) { //cp++ - if(cp==FIH.num_codepages-1) - cp=0; - else - ++cp; + //if(cp==FIH->num_codepages-1) + // cp=0; + //else + // ++cp; + ++cp; + cp%=FIH->num_codepages; + + if(wys==8&&byo8[cp]==0) + { + if(byo14[cp]!=0) + wys=14; + else if(byo16[cp]!=0) + wys=16; + } + + else if(wys==14&&byo14[cp]==0) + { + if(byo16[cp]!=0) + wys=16; + else if(byo8[cp]!=0) + wys=8; + } + + else if(wys==16&&byo16[cp]==0) + { + if(byo8[cp]!=0) + wys=8; + else if(byo14[cp]!=0) + wys=14; + } + cury&=0x7; + ramka8(); + ramka14(); + ramka16(); cpwys(); lin8(); lin14(); @@ -1537,15 +2737,45 @@ int main(int argc,char* argv[]) lit8(); lit14(); lit16(); - + } - if (key/0x100==0x49) + if ((key&0xFF00)==0x4900&&any) { //cp-- - if(cp==0) - cp=FIH.num_codepages-1; - else - --cp; + //if(cp==0) + // cp=FIH->num_codepages-1; + //else + // --cp; + cp+=FIH->num_codepages-1; + cp%=FIH->num_codepages; + + if(wys==8&&byo8[cp]==0) + { + if(byo14[cp]!=0) + wys=14; + else if(byo16[cp]!=0) + wys=16; + } + + else if(wys==14&&byo14[cp]==0) + { + if(byo16[cp]!=0) + wys=16; + else if(byo8[cp]!=0) + wys=8; + } + + else if(wys==16&&byo16[cp]==0) + { + if(byo8[cp]!=0) + wys=8; + else if(byo14[cp]!=0) + wys=14; + } + cury&=0x7; + ramka8(); + ramka14(); + ramka16(); cpwys(); lin8(); lin14(); @@ -1555,7 +2785,7 @@ int main(int argc,char* argv[]) lit16(); } - if (key/0x100==0x52) + if ((key&0xFF00)==0x4700&&any) { //wys-- if(wys==8) @@ -1619,8 +2849,11 @@ int main(int argc,char* argv[]) lit8(); lit14(); lit16(); + lin8(); + lin14(); + lin16(); } - if (key/0x100==0x53) + if ((key&0xFF00)==0x4f00&&any) { //wys++ if(wys==8) @@ -1684,14 +2917,43 @@ int main(int argc,char* argv[]) lit8(); lit14(); lit16(); + lin8(); + lin14(); + lin16(); } - if (key/0x100==0x3b) + + if ((key&0xFF00)==0x3b00) { - //pomoc + //new CPI setcolor(RED); - outtextxy(24,472,"pomoc"); - sprintf(err,"Przeczytaj plik \"napisy.txt\""); - pmc(); + outtextxy(16,472,"new"); + deleteCPI(); + status=newCPI(); + while(status!=0) + { + if (bnd8()==0) + status=newCPI(); + else + { + break; + //closegraph(); + //deleteCPI(); + //return status; + } + } + any=!status; + if(any) + { + strcpy(nazwap,"new CPI"); + cp=0; + if(byo8[0]) + wys=8; + else if(byo16[0]) + wys=16; + else if(byo14[0]) + wys=14; + cury%=8; + } new8(); menu8(); cpwys(); @@ -1704,15 +2966,13 @@ int main(int argc,char* argv[]) lit8(); lit14(); lit16(); - cury%=8; - - + } - if (key/0x100==0x3c) + if ((key&0xFF00)==0x3c00&&any) { //zapisz setcolor(RED); - outtextxy(104,472,"zapis"); + outtextxy(72,472,"save"); status=zap(); while(status!=0) { @@ -1739,19 +2999,35 @@ int main(int argc,char* argv[]) } - if (key/0x100==0x3d) + if ((key&0xFF00)==0x3d00) { //wczytaj setcolor(RED); - outtextxy(184,472,"odczyt"); + outtextxy(136,472,"load"); + deleteCPI(); status=otw(); while(status!=0) { if (bnd()==0) status=otw(); else - return status; + { + break; + //closegraph(); + //deleteCPI(); + //return status; + } } + any=!status; + cp=0; + if(byo8[0]) + wys=8; + else if(byo16[0]) + wys=16; + else if(byo14[0]) + wys=14; + cury%=8; + new8(); menu8(); cpwys(); @@ -1764,17 +3040,14 @@ int main(int argc,char* argv[]) lit8(); lit14(); lit16(); - cp=0; - cury%=8; - } - if(key/0x100==0x3e) + if((key&0xFF00)==0x3e00&&any) { { //zapisz+system setcolor(RED); - outtextxy(104,472,"zapis u¾ycie w systemie"); + outtextxy(72,472,"save use"); status=zap(); while(status!=0) { @@ -1785,10 +3058,15 @@ int main(int argc,char* argv[]) } if(status==0) { - sprintf(err,"mode con:cp prep=((%d) %s )",CPEH[cp].codepage,nazwap); + sprintf(err,"mode con:cp prep=((%u) %s)",CPEH[cp]->codepage,nazwap); + puts(err); system(err); - sprintf(err,"mode con:cp sel=%d",CPEH[cp].codepage); + sprintf(err,"mode con:cp sel=%u",CPEH[cp]->codepage); + puts(err); system(err); + delay(5000); + closegraph(); + initgraph(&kart16,&tryb16,""); } new8(); @@ -1811,13 +3089,14 @@ int main(int argc,char* argv[]) } - if (key/0x100==0x3f) + if ((key&0xFF00)==0x3f00&&any) { //zmiana numeru setcolor(RED); - outtextxy(448,472,"zmiana numeru"); - zmn(); - + outtextxy(256,472,"number"); + status=zmn(); + if(status!=0) + bnd5(); new8(); menu8(); cpwys(); @@ -1830,21 +3109,191 @@ int main(int argc,char* argv[]) lit8(); lit14(); lit16(); - cury%=8; - - } - if (key/0x100==0x40) + if ((key&0xFF00)==0x4000&&any) + { + //new font + setcolor(RED); + outtextxy(336,472,"newF"); + status=newF(); + if(status!=0) + bnd3(); + offset(); + new8(); + menu8(); + cpwys(); + ramka8(); + ramka14(); + ramka16(); + lin8(); + lin14(); + lin16(); + lit8(); + lit14(); + lit16(); + + } + if ((key&0xFF00)==0x4100&&any) + { + //new CP + setcolor(RED); + outtextxy(400,472,"newCP"); + status=newCP(); + if(status!=0) + bnd6(); + else + cp=FIH->num_codepages-1; + if(wys==8&&byo8[cp]==0) + { + if(byo14[cp]!=0) + wys=14; + else if(byo16[cp]!=0) + wys=16; + } + + else if(wys==14&&byo14[cp]==0) + { + if(byo16[cp]!=0) + wys=16; + else if(byo8[cp]!=0) + wys=8; + } + + else if(wys==16&&byo16[cp]==0) + { + if(byo8[cp]!=0) + wys=8; + else if(byo14[cp]!=0) + wys=14; + } + cury&=0x7; + offset(); + new8(); + menu8(); + cpwys(); + ramka8(); + ramka14(); + ramka16(); + lin8(); + lin14(); + lin16(); + lit8(); + lit14(); + lit16(); + + } + if ((key&0xFF00)==0x4200&&any) + { + //delete font + setcolor(RED); + outtextxy(472,472,"delF"); + status=delF(); + if(status!=0) + bnd4(); + offset(); + + if(wys==8&&byo8[cp]==0) + { + if(byo14[cp]!=0) + wys=14; + else if(byo16[cp]!=0) + wys=16; + } + + else if(wys==14&&byo14[cp]==0) + { + if(byo16[cp]!=0) + wys=16; + else if(byo8[cp]!=0) + wys=8; + } + + else if(wys==16&&byo16[cp]==0) + { + if(byo8[cp]!=0) + wys=8; + else if(byo14[cp]!=0) + wys=14; + } + cury&=0x7; + new8(); + menu8(); + cpwys(); + ramka8(); + ramka14(); + ramka16(); + lin8(); + lin14(); + lin16(); + lit8(); + lit14(); + lit16(); + + } + if ((key&0xFF00)==0x4300&&any) + { + //delete CP + setcolor(RED); + outtextxy(536,472,"delCP"); + status=delCP(); + if(status!=0) + bnd7(); + offset(); + + cp%=FIH->num_codepages; + + if(wys==8&&byo8[cp]==0) + { + if(byo14[cp]!=0) + wys=14; + else if(byo16[cp]!=0) + wys=16; + } + + else if(wys==14&&byo14[cp]==0) + { + if(byo16[cp]!=0) + wys=16; + else if(byo8[cp]!=0) + wys=8; + } + + else if(wys==16&&byo16[cp]==0) + { + if(byo8[cp]!=0) + wys=8; + else if(byo14[cp]!=0) + wys=14; + } + cury&=0x7; + new8(); + menu8(); + cpwys(); + ramka8(); + ramka14(); + ramka16(); + lin8(); + lin14(); + lin16(); + lit8(); + lit14(); + lit16(); + + } + if ((key&0xFF00)==0x4400) { //koniec setcolor(RED); - outtextxy(592,472,"koniec"); - delay(1000); + outtextxy(616,472,"end"); break; } + while(bioskey(_KEYBRD_READY)) + { + bioskey(_KEYBRD_READ); + } } - + deleteCPI(); closegraph(); return 0; } \ No newline at end of file diff --git a/NAPISY.PRJ b/NAPISY.PRJ index 7e450b1e16e06f92fbb5324b3563942beecf1b6c..8db5208dbaa19f940f9620535d42ab44194f9104 100644 GIT binary patch delta 296 zcmdm^{9k!P0SDiyrYBBZ4E}5kb?!l~0h1k>l{YWsn8GH)%)r3F#{iObPG?|1~BR~@-e<)IK{A-LE7yT?|ALHrg>=WwZ8sp^YAFSuW0M>v_-UYvOaEObK qrxV-&1uQl=`}=wN!&FRm7nEfIxn*(&jL`{WtP)gU0ej?}pdkQ!_)moZ diff --git a/NAPISY.TXT b/NAPISY.TXT deleted file mode 100644 index c3e00a3..0000000 --- a/NAPISY.TXT +++ /dev/null @@ -1,231 +0,0 @@ - Edytor napis¢w. wersja 1.0 Balthasar Szczepaäski - - 1.opis programu - 2.sterowanie - 3.zmiany - 4.co nie dziaˆa - 5.wyja˜nienie bˆ©d¢w - 6.kontakt - 7.lista plik¢w - - ============================================================== - - 1.Opis programu - - Program "Edytor napis¢w" sˆu¾y do edycji plik¢w .cpi, w - kt¢rych s¥ zapisane informacje o stronach kodowych i ksztaˆcie - liter na ekranie w trybie tekstowym. Za pomoc¥ tego programu - mo¾na wczytywa† i zapisywa† pliki cpi, zmienia† ksztaˆt liter, - i numer strony kodowej, oraz zaˆadowa† czcionk© do systemu. - Program zostaˆ skompilowany za pomoc¥ Turbo C++ 3.0. - - Program potrafi obsˆu¾y† format "FONT " wyst©puj¥cy w - systemach MS-DOS, IBM PC-DOS, Microsoft Windows 1.x, 2.x, 3.x, - 9x, ME i innych. Nie potrafi obsˆu¾y† formatu "DRFONT " - wyst©puj¥cego w systemie DR-DOS, ani "FONT.NT" wyst©puj¥cego w - systemach Microsoft Windows NT, 2000, XP, Vista, 7. Natomiast - w tych systemach b©d¥ dziaˆaˆy pliki w formacie "FONT ", - tak¾e te utworzone za pomoc¥ tego programu. Liczba stron - kodowych w pliku nie mo¾e przekroczy† 6, szeroko˜† liter musi - wynosi† 8, wysoko˜† liter nie mo¾e mie† innych warto˜ci ni¾ - 8,14,albo 16,przy czym wysoko˜ci nie mog¥ si© powtarza† w - obr©bie jednej strony kodowej, liczba znak¢w musi wynosi† 256. - - Program powinien dziaˆa† w systemach DOS* i Windows** na - komputerze z kart¥ graficzn¥ VGA lub p¢«niejsz¥. Mo¾e dziaˆa† - na emulatorze.*** - - *Nie wiem, czy zadziaˆa w DOSie starszym ni¾ 3.3, zreszt¥ nie - ma sensu u¾ywa† Edytora napis¢w w starszych wersjach DOSa, - poniewa¾ nie obsˆuguj¥ stron kodowych. - - **W systemie Windows 98 i poprzednich nie byˆo ¾adnych - problem¢w. - - W systemie Windows XP, przy niekt¢rych kartach graficznych - program wyˆ¥czaˆ si© natychmiast po wˆ¥czeniu, ale to byˆo w - wersji beta w trybie CGA, w tej wersji powinno dziaˆa†. Je¾eli - nie dziaˆa trzeba uruchomi† system w trybie awaryjnym. - - W systemie Windows Vista program mo¾e zosta† zamkni©ty przez - system z komentarzem "Ten system nie obsˆuguje trybu - peˆnoekranowego.OK". W takim razie nale¾y zast¥pi† sterownik - karty graficzej na wersj© przeznaczon¥ dla Windowsa XP, albo - u¾ywa† programu przy systemie wˆ¥czonym w trybie awaryjnym. - Je¾eli system nie pozwala zainstalowa† sterownika, trzeba - wˆ¥czy† system w trybie awaryjnym i zalogowa† si© jako - Administraktor, a dopiero wtedy instalowa† sterownik. Czasami - system potrafi podmieni† sterownik spowrotem na poprzedni¥, - je˜li ta jest jeszcze na dysku. - - W systemie Windows 7 sytuacja jest identyczna jak w Windowsie - Vista. - - ***Jedynym emulatorem, w kt¢rym pr¢bowaˆem uruchomi† program, - jest DOSBox w wersji 0.63. Program zawiesza si© w nim chwil© - po uruchomieniu, przed narysowaniem ekranu. Nie wiem czy i jak - dziaˆa w innych wersjach DOSBoxa/innych emulatorach. - - ============================================================== - - 2.Sterowanie - - kursor w g¢re: strzaˆka w g¢r© - kursor w d¢ˆ: strzaˆka w d¢ˆ - kursor w lewo: strzaˆka w lewo - kursor w prawo: strzaˆka w prawo - przeˆ¥cznik rysowania i wybierania: tabulator - zamalowanie kratki: enter - zmazanie kratki: backspace - zmiana stanu kratki: spacja - przeˆ¥czanie stron kodowych: page up/page down - przeˆ¥czanie wysoko˜ci liter: insert/delete - - klawisze F: - - F1: pomoc, w tej wersji nie dziaˆa. - - F2: zapis pliku pod podan¥ nazw¥, w razie bˆ©du zapisu mo¾na - spr¢bowa† kolejny raz pod inn¥ nazw¥. - - F3: wczytanie pliku z podanej nazwy, w razie bˆ¥du odczyt - mo¾na spr¢bowa† odczyta† inny plik. Je¾eli ¾aden plik nie - b©dzie wszytany,program zostanie zamkni©ty. - - F4: zapis pliku tak, jak przy F2 i wczytanie do systemu przy - u¾yciu polecenia systemowego MODE. Je¾eli zostanie - nadpisany plik u¾uwany domy˜lnie przez system do ˆadowania - liter zmiany w systemie b©d¥ trwaˆe, nawet przy zapisie za - pomoc¥ F2. w przeciwnym razie zmiany b©d¥ chwilowe. Na - przykˆad je¾eli program jest uruchomiony w DOSie, zmiany - b©d¥ widoczne do ponownego uruchomienia systemu. Je˜l - program zostaˆ uruchomiony w Windowsie z wiersza poleceä, - zmiany b©d¥ widoczne a¾ do zamkni©cia tego wiersza poleceä - i tylko w trybie peˆnoekranowym. Je¾eli program zostaˆ - uruchomiony przez klikni©cie na jego ikon©, albo na ikon© - pliku CPI, zmiany w systemie b©d¥ widoczne tylko do - wyˆ¥czenia programu. W emulatorze najprawdopodobniej nie - b©dzie wida† ¾adnych zmian. - - F5: zmiana numeru aktualnie wybranej strony kodowej. Numery - wi©ksze ni¾ trzycyfrowe mog¥ nie dziaˆa† w niekt¢rych - systemach. - - F6: koniec programu. - - ============================================================== - - 3. Zmiany - - beta: - To jest pierwsza dziaˆ¥j¥ca wersja. - 1.0: - -zmiana trybu CGA na VGA - -dziaˆa wysoko˜† 14 i 16 - -wszystkie wysoko˜ci s¥ widoczne na jednym ekranie - -mo¾na zapisywa† pliki i zaˆadowa† stron© do systemu - -mo¾na otworzy† poda† plik do otwarcia jako argument w - wierszu poleceä - -wczytywane dane nie s¥ ju¾ wypisywane na ekranie - -Funkcje klawiszy F zgadzaj¥ si© z opisem na dole ekranu - - ============================================================== - - 4. Co nie dziaˆa - - -przy przeˆ¥czaniu rozmiaru czcionki okna z zestawem - znak¢w nie s¥ aktualizowane - -nie ma pomocy wewn¥trz programu - -po wyˆ¥czeniu z powodu bˆ©du otwarcia pliku nie jest - wyˆ¥czany tryb graficzny - - ============================================================== - - 5. Wyja˜nienie bˆ©d¢w - - 100: bˆ¥d otwarcia pliku: - Nie da si© otworzy† pliku o podanej nazwie. - - 101: FFH.id0!=0xff - Identyfikator id0 ma inn¥ warto˜† ni¾ 0xff. Plik jest w - formacie "DRFONT " lub nie jest plikiem cpi. - - 102: FFH.id !="FONT " - Plik jest w formacie "FONT.NT" lub "DRFONT ", albo innym, - nieznanym formacie. - - 103: FFH.pnum!=1 - Jest wi©cej wska«nik¢w na FontInfoHeader - plik jest w - nowym, nieznanym formacie lub nie ma ¾adnego wska«nika - - plik nie zawiera danych. - - 104: FFH.ptyp!=1 - FontInfoHeader jest w nieznanym formacie. - - 105: FIH.num_codepages>6 - Plik zawiera wi©cej ni¾ 6 stron kodowych. - - 106: CPEH.cpeh_size!=0x1c - CodePageEntryHeader ma nieprawidˆow¥ dˆugo˜†. - - 107: CPEH.cpeh_device_type!=1 - Czcionka nie jest czcionk¥ ekranow¥, jest przeznaczona na - drukark© lub inne urz¥dzenie. - - 108: CPIH.version!=1 - W pliku w formacie "FONT " umieszczono czcionk© w - formacie "FONT.NT", "DRFONT ", albo innym, nieznanym - formacie. - - 109: CPIH.num_fonts>3 - Strona kodowa zawiera wi©cej ni¾ 3 czczionki. - - 110: SFH.height!=(8 || 14 || 16) - Czcionka ma nieodpowiedni¥ wysoko˜† znak¢w. - - 111: SFH.width!=8 - Czcionka ma nieodpowiedni¥ szeroko˜† znak¢w. - - 112: SFH.num_chars!=256 - Czcionka ma nieodpowiedni¥ ilo˜† znak¢w. - - 113: SFH.height==8 ju¾ byˆo - Wysoko˜† znak¢w==8 wyst©puje w tej stronie kodowej wi©cej - ni¾ raz - - 114: SFH.height==14 ju¾ byˆo - Wysoko˜† znak¢w==14 wyst©puje w tej stronie kodowej wi©cej - ni¾ raz. - - 115: SFH.height==16 ju¾ byˆo - Wysoko˜† znak¢w==16 wyst©puje w tej stronie kodowej wi©cej - ni¾ raz. - - 200: Bˆ¥d utworzenia pliku: - Nie da si© utworzy†/zmodyfikowa† pliku o podanej nazwie. - - Przeczytaj plik "napisy.txt" - Pomoc wewn¥trz programu nie dziaˆa, nale¾y przeczyta† ten - plik. - - ============================================================== - - 6. Kontakt - - e-mali: balthasar_s@interia.pl - telefon: +48664641394 - www: http://www.baltixy.w.interia.pl - - ============================================================== - - 7. Lista plik¢w - - nazwa |rozmiar - ----------+------- - EGAVGA.OBJ| 5658 - NAPISY.TXT| 9388 - NAPISY.EXE| 137623 - NAPISY.CPP| 37801 - NAPISY.PRJ| 4540 - - ============================================================== diff --git a/readthis.txt b/readthis.txt new file mode 100644 index 0000000..15e1089 --- /dev/null +++ b/readthis.txt @@ -0,0 +1,214 @@ +#### # # +# # # +### ### # # #### ## ### +# # # # # # # # # +#### ### ### ## ## # + # # + ## # # ## ### # ### ## # # + ## # # # # # # #__ # # # # + # ## #### ### # # # # # # # + # # # # # # ### ## # # + Balthasar Szczepaäski +Edytor napis¢w 1.1 - 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 + +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 + +============================================================ + +2. System requirements + +The program should be able to run on any IBM-PC compatible +computer* with an IBM-VGA compatible video card and DOS** or +Windows*** operating system or a DOS emulator****. + +**The program should run on any DOS that is not older than +MS-DOS-3.3. It was tested on following systems: + MS-DOS 5.0 - no problems + MS-DOS 7.1 - no problems + FreeDOS 1.0 - no problems + PTS-DOS - a small display error in dialog boxes + +***The program should run without problems on any DOS-based +version of Windows. It was tested on following systems: + Windows 3.11 for workgroups - no problems + Windows 98 SE - no problems + +There can be problems in NT-based versions of windows: + + On windows XP there can be display errors with some video + cards. It was tested on two computers with Windows XP SP3 + and on one there were display errors. Propably, the video + card drivers are responsible for this. + + On Windows Vista and 7, the system may refuse to launch + this program (or any other fullscreen DOS program) or not. + It depends on the video card driver. + + On 64 bit systems the program will not run. + +****The program was tested only on DOSBox 0.63 and there +were no problems. The previous version of the program (1.0) +did not run on DOSBox 0.63. No other emulators were tested. + +============================================================ + +3. Features and limitations + +The following file formats are supported: + +1.FONT - used by MS-DOS, PC-DOS, Windows 1.x, 2.x, 3.x. +2.FONT.NT - used by Windows NT, 2000, XP, Vista, 7. + 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. + +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. + +Loaded files must meet the following restrictions: +1.Number of all codepages cannot be 0 or bigger than 16. +2.Codepages must have different numbers. +3.Codepages cannot contain 0 or more than 3 fonts. +4.Width of characters in a font must be equal to 8. +5.Height of characters in font must be equal to 8, 14 or 16 +6.Fonts in a codepage must have different heights +7.Fonts must contain exactly 256 characters +8.All fonts must be screen fonts, not printer fonts. + +The following actions can be performed: + 1.creating a new CPI + 2.loading a CPI file + 3.saving a CPI file + 4.loading a codepage into VGAmemory using the mode command* + 5.editing the appearance of characters + 6.creating a new codepage + 7.changing a number of an existing codepage + 8.deleting an existing codepage + 9.creating a new font +10.deleting an existing font + +*4 a CPI file is saved and used as a parameter to the DOS + "mode" command which loads a codepage into the video card + memory. This will not work if mode.com or display.sys are + not installed on the system. It will also not work on + Windows XP or newer. DOS will not be able to load the + codepage if the CPI file is bigger than 64KB. Do not use + this option if the codepage is not finished because you + will not be able to read anything you type anymore. + +============================================================ + +4. Controls + +create a new CPI - F1 +save a CPI file F2 +load a CPI file F3 +CP into VGA memory F4 +change CP number F5 +new font F6 +new codepage F7 +delete a font F8 +delete a codepage F9 +close the program F10 + +move the cursor arrow keys +set a pixel Enter +unset a pixel Backspace +change a pixel Space +switch edit/select Tab +drawing and selecting +next codepage PageDown +previous codepage PageUp +next font End +previous font Home + +A file can also be opened using it's name as a command line +parameter or by clicking its icon in Windows GUI. + +============================================================ + +5. Changes + +beta: + First working version. +1.0 + - Change from CGA to VGA screen mode + - Support for character heights 14 and 16. + - Almost full FONT file format support + - Saving CPI files + - Command line parameter support + - Debug information removed from screen + - Fixed Function keys +1.1 + - Full FONT flie format support + - FONT.NT file format support (read only) + - Codepage limit set from 6 to 16 + - Creating new CPI's + - Creating new codepages + - Creating new fonts + - Removing codepages + - Removing fonts + - Failed file load no longer closes the program + - Dynamic memory allocation + - Optimized functions + - Fixed bugs + - Language changed to English + +============================================================ + +6. Planned features + + - Full FONT.NT file format support + - CPX file format support + - exporting codepages to CP files + - importing codepages from CP flies + - exporting fonts to bitmaps + - importing fonts from bitmaps + - warnings + +============================================================ + +7. Known bugs + +none. + +============================================================ + +8. Files + +EGAVGA .OBJ 5658 BGI driver compiled to OBJ +NAPISY .EXE 103140 The program +NAPISY .CPP 71108 Source for the program +NAPISY .PRJ 4607 Turbo C++ 3.0 project file +READTHIS.TXT 6641 This file + +============================================================ + +9. Contact information + +e-mali: balthasar_s@interia.pl +telefon: +48502745442 +www: http://www.baltixy.w.interia.pl + +============================================================ -- 2.30.2