]> bicyclesonthemoon.info Git - cpied/commitdiff
- Dialog boxes can now cancelled with Esc or empty string v1.3b
authorb <rowerynaksiezycu@gmail.com>
Sat, 3 Aug 2013 21:49:00 +0000 (23:49 +0200)
committerb <rowerynaksiezycu@gmail.com>
Sat, 3 Aug 2013 21:49:00 +0000 (23:49 +0200)
- Added warnings before deleting a font, a codepage or closing the program when a file is open

appinfo/cpied.lsm [new file with mode: 0644]
doc/cpied/COPYING.TXT [moved from DOC/COPYING.TXT with 100% similarity]
doc/cpied/readthis.txt [moved from DOC/readthis.txt with 87% similarity]
source/cpied/CPIED.CPP [moved from SRC/CPIED.CPP with 86% similarity]
source/cpied/cpitrick.asm [moved from SRC/cpitrick.asm with 100% similarity]
source/cpied/cpx2cpi.c [moved from SRC/cpx2cpi.c with 92% similarity]
source/cpied/makefile [moved from SRC/makefile with 100% similarity]

diff --git a/appinfo/cpied.lsm b/appinfo/cpied.lsm
new file mode 100644 (file)
index 0000000..9d9f3ce
--- /dev/null
@@ -0,0 +1,14 @@
+Begin3\r
+Title:          cpied\r
+Version:        1.3a\r
+Entered-date:   2013-08-01\r
+Description:    a GUI-driven CPI font editor\r
+Keywords:       cpi,cpx,font,editor\r
+Author:         Balthasar Szczepanski\r
+Maintained-by:  -\r
+Primary-site:   http://baltixy.w.interia.pl/cpied/index.htm\r
+Alternate-site: -\r
+Original-site:  -\r
+Platforms:      DOS\r
+Copying-policy: GNU/GPL\r
+End\r
similarity index 100%
rename from DOC/COPYING.TXT
rename to doc/cpied/COPYING.TXT
similarity index 87%
rename from DOC/readthis.txt
rename to doc/cpied/readthis.txt
index 6ebb2905614dd9e2e6336f40f905f3d2b7835875..cdd4a2a8ad091faaa11cd7dc1b68531a3dd461e6 100644 (file)
@@ -3,11 +3,11 @@
  ÛÛ  ÛÛ  ÛÛ  ÛÛ   ÛÛ     ÛÛ   Û  ÛÛ ÛÛ   ÛÛ      Û\r
 ÛÛ       ÛÛ  ÛÛ   ÛÛ     ÛÛ      ÛÛ  ÛÛ   Û     Û      \r
 ÛÛ       ÛÛÛÛÛ    ÛÛ     ÛÛÛÛ    ÛÛ  ÛÛ   Û      Û     \r
-ÛÛ       ÛÛ       ÛÛ     ÛÛ      ÛÛ  ÛÛ  ÛÛÛ Û ÛÛ  A   \r
+ÛÛ       ÛÛ       ÛÛ     ÛÛ      ÛÛ  ÛÛ  ÛÛÛ Û ÛÛ  B   \r
  ÛÛ  ÛÛ  ÛÛ       ÛÛ     ÛÛ   Û  ÛÛ ÛÛ\r
   ÛÛÛÛ  ÛÛÛÛ     ÛÛÛÛ   ÛÛÛÛÛÛÛ ÛÛÛÛÛ  Balthasar Szczepaäski\r
 \r
-       CPIED 1.3a - the CPI editor\r
+  CPIED 1.3b - the CPI editor\r
 \r
 ============================================================\r
 \r
@@ -53,7 +53,9 @@ Windows*** operating system or a DOS emulator****.
  MS-DOS  7.1  - no problems\r
  FreeDOS 1.0  - no problems\r
  FreeDOS 1.1  - no problems\r
- PTS-DOS 6.8  - a small display error in dialog boxes\r
+ PTS-DOS 6.8  - no problems, but in "safe mode" there is a\r
+                small display bug and cpx2cpi crashes the\r
+                system\r
 \r
 ***The program should run without problems on any DOS-based\r
 version of Windows. It was tested on following systems:\r
@@ -77,7 +79,9 @@ There can be problems in NT-based versions of windows:
 were no problems. The previous version of the program (1.0)\r
 does not run on DOSBox 0.63. No other emulators were tested.\r
 \r
-cpx2cpi was not tested on those systems yet!\r
+The program is not tested on all of the systemsafter every\r
+update!\r
+\r
 ============================================================\r
 \r
 3. Features and limitations\r
@@ -121,10 +125,10 @@ The following actions can be performed:
 *4 a CPI file is saved and used as a parameter to the DOS\r
    "mode" command which loads a codepage into the video card\r
    memory:\r
-       \r
-        mode con:cp prep=((number) path)\r
-        mode con:cp sel=number\r
-       \r
+\r
+   mode con:cp prep=((number) path)\r
+   mode con:cp sel=number\r
+  \r
    This will not work if mode.com or display.sys are\r
    not installed on the system. It will also not work on\r
    Windows XP or newer or DOS 3.3. DOS will not be able to\r
@@ -167,6 +171,12 @@ previous font      Home        right click the "8x__" text
 \r
 *The function of arrow keys is changed with Tab.\r
 \r
+Dialog boxes:\r
+  Some actions require user input. Type your answer and \r
+  press Enter. To cancel press Esc or leave an empty string.\r
+  When asked for a number everything that is not a number\r
+  will become 0.\r
+\r
 Command line:\r
 \r
 cpied [cpifile] - edir cpi or cpx files\r
@@ -174,8 +184,8 @@ cpied [cpifile] - edir cpi or cpx files
 \r
 cpx2cpi cpxfile cpifile [q] - convert cpx to cpi\r
   cpxfile - input file, cpx\r
-       cpxfile - output file, cpi\r
-       q       - no console output\r
+  cpxfile - output file, cpi\r
+  q       - no console output\r
 \r
 ============================================================\r
 \r
@@ -222,24 +232,29 @@ beta:
  - Added a list of codepages which is also clickable\r
  - Removed dependancy on Borland's EGAVGA driver:\r
    Code ported to Open Watcom, Borland's graphic functions\r
-        replaced with Open Watcom's equivalents\r
-        \r
+  replaced with Open Watcom's equivalents\r
+1.3b\r
+ - Dialog boxes can now cancelled with Esc or empty string\r
+ - Added warnings before deleting a font, a codepage or\r
+   closing the program when a file is open\r
\r
 ============================================================\r
 \r
 6. Planned features\r
 \r
- - Saving FONT.NT files \r
+ - Saving CPX files\r
  - Exporting codepages to CP files\r
  - Importing codepages from CP flies\r
  - Exporting fonts to bitmaps\r
  - Importing fonts from bitmaps\r
- - Warnings\r
 \r
 ============================================================\r
 \r
 7. Known bugs\r
 \r
-Dialog boxes need improving.\r
+Filename is not checked for reserved symbols\r
+\r
+Coordinates of a deleted font are sometimes displayed.\r
 \r
 ============================================================\r
 \r
@@ -249,10 +264,10 @@ Compiling:
 \r
 Requirements:\r
  cpx2cpi:\r
-       NASM\r
-       Turbo C\r
+  ASM\r
+  Turbo C\r
  cpied:\r
-       Open Watcom\r
+  Open Watcom\r
 \r
 The makefile should be processed by a make program.\r
 I used Borland's make, the real-mode version, makeR. Open\r
similarity index 86%
rename from SRC/CPIED.CPP
rename to source/cpied/CPIED.CPP
index 82f8859e6f7f16a21d95942d068af2a3be92d548..4f1d6376ee889ac7ac2bf507870501ac07d569ca 100644 (file)
@@ -1,4 +1,4 @@
-    //CPIED version 1.3a\r
+    //CPIED version 1.3b\r
    // Balthasar Szczepaäski Copyright 2013\r
   //\r
  //   This file is part of CPIED\r
@@ -197,10 +197,10 @@ void menu8 ();
 void cpwys (int mode=0);\r
 void redraw();\r
 \r
-void displayDialog(int  color, char *text,  int type=0);\r
-int      message  (char *text, char *value, int type=1);\r
-void     question (char *text, char *result);\r
-unsigned question (char *text);\r
+void displayDialog(int  color, char     *text,  int type=0);\r
+int      message  (char *text, char     *value, int type=1);\r
+unsigned question (char *text, char     *result);\r
+unsigned question (char *text, unsigned *result);\r
 \r
 void ramka8 ();\r
 void ramka14();\r
@@ -250,6 +250,7 @@ void nextCP();
 void prevCP();\r
 \r
 int  delCP ();\r
+int  delCP2();\r
 void delCP3();\r
 \r
 int  newF  ();\r
@@ -263,7 +264,8 @@ void prevF();
 void nextF();\r
 \r
 int  delF  ();\r
-void delF3();\r
+int  delF2 ();\r
+void delF3 ();\r
 int  delF8 (short h);\r
 int  delF14(short h);\r
 int  delF16(short h);\r
@@ -350,7 +352,7 @@ void new8()
        _clearscreen(_GCLEARSCREEN);\r
        _setcolor(C_SEL);\r
        _moveto(0,0);\r
-       _outgtext("CPIED     1.3a±");\r
+       _outgtext("CPIED     1.3b±");\r
        _moveto(0,8);\r
        _outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±");\r
 }\r
@@ -462,23 +464,27 @@ void displayDialog(int color,char *text,int type)
        _outgtext("±                                        ±");\r
        _moveto(152,200);\r
        _outgtext("±                                        ±");\r
+       _moveto(152,208);\r
        switch(type)\r
        {\r
+       case 3:\r
+               _outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±y/n±");\r
+               break;\r
        case 2:\r
-               _moveto(152,208);_outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±again?(y/n)±");\r
+               _outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±again?(y/n)±");\r
                break;\r
        case 1:\r
-               _moveto(152,208);_outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey±");\r
+               _outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±anykey±");\r
                break;\r
        case 0:\r
        default:\r
-               _moveto(152,208);_outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±");\r
+               _outgtext("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±");\r
                break;\r
        }\r
 }\r
 int message(char *text, char *value, int type)\r
 {\r
-       if (type!=2)\r
+       if (type<2)\r
        {\r
                displayDialog(C_SET,text,1);\r
                printf("%s",value);\r
@@ -487,29 +493,61 @@ int message(char *text, char *value, int type)
        }\r
        else\r
        {\r
-               displayDialog(C_SET,text,2);\r
+               displayDialog(C_SET,text,type);\r
                printf("%s",value);\r
                unsigned short a;\r
                for(;;)\r
                {\r
                        a=_bios_keybrd(_KEYBRD_READ);\r
-                       if((a&0xFF)==0x59||(a&0xFF)==0x79)\r
+                       if((a&0xFF)==0x59||(a&0xFF)==0x79)//y\r
                                return 0;\r
-                       if((a&0xFF)==0x4e||(a&0xff)==0x6e)\r
+                       if((a&0xFF)==0x4e||(a&0xff)==0x6e)//n\r
                                return 1;\r
                }\r
        }\r
 }\r
-inline void question(char *text, char *result)\r
+unsigned question(char *text, char *result)\r
 {\r
+       unsigned short p=0;\r
        displayDialog(C_SEL,text);\r
-       scanf("%s",result);\r
+       for(;;)\r
+       {\r
+               key=_bios_keybrd(_KEYBRD_READ);\r
+               switch(key&0xFF00)\r
+               {\r
+               case 0x0100: //esc\r
+                       return 1;\r
+               case 0x1c00: //enter\r
+                       if(!p)\r
+                               return 1;\r
+                       result[p]=0;\r
+                       return 0;\r
+               case 0x0e00: //backspace\r
+                       if(p)\r
+                       {\r
+                               putch(8);\r
+                               putch(32);\r
+                               putch(8);\r
+                               --p;\r
+                       }\r
+                       break;\r
+               default:\r
+                       if(key&=0x00FF)\r
+                       {\r
+                               result[p++]=key;\r
+                               putch(key);\r
+                       }\r
+               }\r
+       }\r
 }\r
-inline unsigned question(char *text)\r
+unsigned question(char *text, unsigned short *result)\r
 {\r
        char temp[256];\r
-       question(text,temp);\r
-       return atoi(temp);\r
+       unsigned st;\r
+       st=question(text,temp);\r
+       if(!st)\r
+               *result=atoi(temp);\r
+       return st;\r
 }\r
 \r
 void ramka8()\r
@@ -1264,7 +1302,9 @@ inline void ent16()
 \r
 int otw()\r
 {\r
-       question("Filename",nazwap);\r
+       if(question("Filename",nazwap)==1)\r
+               return 1;\r
+       //deleteCPI();\r
        return otw2();\r
 }\r
 int otw2()\r
@@ -1282,9 +1322,7 @@ int otw2()
                sprintf(err,"100:No valid file at this path\n");\r
                return 100;\r
        }\r
-       else\r
-               sprintf(err,"OK");\r
-\r
+       deleteCPI();\r
        FFH=new FontFileHeader;\r
        if(!FFH)\r
        {\r
@@ -1295,7 +1333,7 @@ int otw2()
        fread(FFH,0x19,1,CPI);\r
        if(FFH->id0!=0xff)\r
        {\r
-               if(FFH->id0==0x81&&FFH->id[0]==0xfc)//maybe it's a CPX?\r
+               if(FFH->id0==0x81&&FFH->id[0]==0xfc)//Looks like a CPX\r
                {\r
                        fclose(CPI);\r
                        deleteCPI(0);\r
@@ -1439,7 +1477,7 @@ int otw2()
                }\r
                if(CPEH[a]->device_type!=1)\r
                {\r
-                       sprintf(err,"107:Wrong device type(%u) in CPEH[%u]\n",CPEH[a]->device_type,a);\r
+                       sprintf(err,"107:Wrong device type(%u) in cp%03u\n",CPEH[a]->device_type,CPEH[a]->codepage);\r
                        fclose(CPI);\r
                        if(CPX)\r
                                remove("tempcpi");\r
@@ -1450,7 +1488,7 @@ int otw2()
                {\r
                        if(CPEH[a]->codepage==CPEH[i]->codepage)\r
                        {\r
-                               sprintf(err,"114:cp%03u (%u) already in CPEH[%u]\n",CPEH[a]->codepage,a,i);\r
+                               sprintf(err,"114:cp%03u duplicated in this CPI\n",CPEH[a]->codepage);\r
                                fclose(CPI);\r
                                if(CPX)\r
                                        remove("tempcpi");\r
@@ -1482,7 +1520,7 @@ int otw2()
                }\r
                if(CPIH[a]->num_fonts>3)\r
                {\r
-                       sprintf(err,"109:Too many fonts in CPIH[%u] (%u)\n",a,CPIH[a]->num_fonts);\r
+                       sprintf(err,"109:Too many fonts in cp%03u (%u)\n",CPEH[a]->codepage,CPIH[a]->num_fonts);\r
                        fclose(CPI);\r
                        if(CPX)\r
                                remove("tempcpi");\r
@@ -1491,7 +1529,7 @@ int otw2()
                }\r
                if(CPIH[a]->num_fonts==0)\r
                {\r
-                       sprintf(err,"115:No fonts in CPIH[%u])\n",a);\r
+                       sprintf(err,"115:No fonts in cp%03u\n",CPEH[a]->codepage);\r
                        fclose(CPI);\r
                        if(CPX)\r
                                remove("tempcpi");\r
@@ -1519,7 +1557,7 @@ int otw2()
                        {\r
                                if (byo8[a]!=0)\r
                                {\r
-                                       sprintf(err,"113:Height 8 already in cp%03u (%u;%u)\n",CPEH[a]->codepage,a,b);\r
+                                       sprintf(err,"113:Height 8 duplicated in cp%03u\n",CPEH[a]->codepage);\r
                                        fclose(CPI);\r
                                        if(CPX)\r
                                                remove("tempcpi");\r
@@ -1532,7 +1570,7 @@ int otw2()
                        {\r
                                if (byo14[a]!=0)\r
                                {\r
-                                       sprintf(err,"113:Height 14 already in cp%03u (%u;%u)\n",CPEH[a]->codepage,a,b);\r
+                                       sprintf(err,"113:Height 14 duplicated in cp%03u\n",CPEH[a]->codepage);\r
                                        fclose(CPI);\r
                                        if(CPX)\r
                                                remove("tempcpi");\r
@@ -1545,7 +1583,7 @@ int otw2()
                        {\r
                                if (byo16[a]!=0)\r
                                {\r
-                                       sprintf(err,"113:Height 16 already in cp%03u (%u;%u)\n",CPEH[a]->codepage,a,b);\r
+                                       sprintf(err,"113:Height 16 duplicated in cp%03u\n",CPEH[a]->codepage);\r
                                        fclose(CPI);\r
                                        if(CPX)\r
                                                remove("tempcpi");\r
@@ -1556,7 +1594,7 @@ int otw2()
                        }\r
                        if(SFH[a][b]->height!=8&&SFH[a][b]->height!=14&&SFH[a][b]->height!=16)\r
                        {\r
-                               sprintf(err,"110:Wrong height (%u) in SFH[%u][%u]\n",(short)(SFH[a][b]->height&0xff),a,b);\r
+                               sprintf(err,"110:Wrong height (%u) in cp%03u\n",(short)(SFH[a][b]->height&0xff),CPEH[a]->codepage);\r
                                fclose(CPI);\r
                                if(CPX)\r
                                        remove("tempcpi");\r
@@ -1565,7 +1603,7 @@ int otw2()
                        }\r
                        if(SFH[a][b]->width!=8)\r
                        {\r
-                               sprintf(err,"111:Wrong width (%u) in SFH[%u][%u]\n",(short)(SFH[a][b]->width&0xff),a,b);\r
+                               sprintf(err,"111:Wrong width (%u) in cp%03u\n",(short)(SFH[a][b]->width&0xff),CPEH[a]->codepage);\r
                                fclose(CPI);\r
                                if(CPX)\r
                                        remove("tempcpi");\r
@@ -1574,7 +1612,7 @@ int otw2()
                        }\r
                        if(SFH[a][b]->num_chars!=256)\r
                        {\r
-                               sprintf(err,"112:Wrong no.of chars(%u)in SFH[%u][%u]\n",SFH[a][b]->num_chars,a,b);\r
+                               sprintf(err,"112:Wrong no.of chars(%u)in cp%03ux%02u\n",SFH[a][b]->num_chars,CPEH[a]->codepage,SFH[a][b]->height);\r
                                fclose(CPI);\r
                                if(CPX)\r
                                        remove("tempcpi");\r
@@ -1636,29 +1674,37 @@ void otw3()//
        _setcolor(C_NON);\r
        _moveto(136,472);\r
        _outgtext("load");\r
-       deleteCPI();\r
        status=otw();\r
-       while(status!=0)\r
+       switch(status)\r
        {\r
-               if (message("CPI file not loaded",err,2)==0)\r
-                       status=otw();\r
-               else\r
-                       break;\r
+       case 100: //not loaded but nothing is lost\r
+               message("CPI file not loaded",err);\r
+       case 1: //cancelled\r
+               redraw();\r
+               return;\r
+       case 0: //success\r
+               any=1;\r
+               cp=0;\r
+               if(byo8[0])\r
+                       wys=8;\r
+               else if(byo16[0])\r
+                       wys=16;\r
+               else if(byo14[0])\r
+                       wys=14;\r
+               redraw();\r
+               return;\r
+       default: //fail\r
+               message("CPI file not loaded",err);\r
+               any=0;\r
+               redraw();\r
+               return;\r
        }\r
-       any=!status;\r
-       cp=0;\r
-       if(byo8[0])\r
-               wys=8;\r
-       else if(byo16[0])\r
-               wys=16;\r
-       else if(byo14[0])\r
-               wys=14;\r
-       redraw();\r
 }\r
 \r
 int zap()\r
 {\r
-       question("Filename",nazwap);\r
+       if(question("Filename",nazwap)==1)\r
+               return 1;\r
        return zap2();\r
 }\r
 int zap2()\r
@@ -1707,7 +1753,7 @@ int zap2()
                }\r
        }\r
 \r
-       fprintf(CPI,"\r\nThis file was created with the CPI editor version 1.3a",0x1a);\r
+       fprintf(CPI,"\r\nThis file was created with the CPI editor version 1.3b",0x1a);\r
        fclose(CPI);\r
        return 0;\r
 }\r
@@ -1717,39 +1763,30 @@ void zap3()//
        _moveto(72,472);\r
        _outgtext("save");\r
        status=zap();\r
-       while(status!=0)\r
-       {\r
-               if (message("CPI file not saved",err,2)==0)\r
-                       status=zap();\r
-               else\r
-                       break;\r
-       }\r
+       if(status>1)\r
+               message("CPI file not saved",err);\r
        redraw();\r
        return;\r
 }\r
 \r
-void use3()///\r
+void use3()///needs to be improved\r
 {\r
        _setcolor(C_NON);\r
        _moveto(72,472);\r
        _outgtext("save            use");\r
        status=zap();\r
-       while(status!=0)\r
-       {\r
-               if (message("CPI file not saved",err,2)==0)\r
-                       status=zap();\r
-               else\r
-                       break;\r
-       }\r
+       if(status>1)\r
+               message("CPI file not saved",err);\r
        if(status==0)\r
        {\r
+               _setvideomode(_DEFAULTMODE);\r
                sprintf(err,"mode con:cp prep=((%u) %s)",CPEH[cp]->codepage,nazwap);\r
                puts(err);\r
                system(err);\r
                sprintf(err,"mode con:cp sel=%u",CPEH[cp]->codepage);\r
                puts(err);\r
                system(err);\r
-               delay(5000);\r
+               //delay(5000);\r
                //closegraph();\r
                //initgraph(&kart16,&tryb16,"");\r
                _setvideomode(_VRES16COLOR);\r
@@ -1761,13 +1798,14 @@ void use3()///
 \r
 int zmn()\r
 {\r
-       short CP;\r
-       CP=question("Codepage number");\r
+       unsigned short CP;\r
+       if(question("Codepage number",&CP)==1)\r
+               return 1;\r
        for(short i=0;i<FIH->num_codepages;++i)\r
        {\r
                if(CP==CPEH[i]->codepage&&i!=cp)\r
                {\r
-                       sprintf(err,"314:cp%03u already in CPEH[%u]\n",CP,i);\r
+                       sprintf(err,"314:cp%03u already in this CPI\n",CP);\r
                        return 314;\r
                }\r
        }\r
@@ -1780,17 +1818,19 @@ void zmn3()//
        _moveto(256,472);\r
        _outgtext("number");\r
        status=zmn();\r
-       if(status!=0)\r
+       if(status>1)\r
                message("Number not changed",err);\r
        redraw();\r
 }\r
 \r
 int newCPI()\r
 {\r
-       short CP,h;\r
+       unsigned short CP,h;\r
        //char temp[51];\r
-       CP=question("First codepage number:");\r
-       h=question("Initial font height(8,14,16,all)");\r
+       if(question("First codepage number:",&CP)==1)\r
+               return 1;\r
+       if(question("Initial font height(8,14,16,all)",&h)==1)\r
+               return 1;\r
        if(h!=0&&h!=8&&h!=14&&h!=16)\r
        {\r
                sprintf(err,"310:Wrong height (%u)\n",h);\r
@@ -1801,6 +1841,7 @@ int newCPI()
 int newCPI2(short CP, short h)\r
 {\r
        int t;\r
+       deleteCPI();\r
        FFH=new FontFileHeader;\r
        if(!FFH)\r
        {\r
@@ -1834,18 +1875,16 @@ void newCPI3()//
        _setcolor(C_NON);\r
        _moveto(16,472);\r
        _outgtext("new");\r
-       deleteCPI();\r
        status=newCPI();\r
-       while(status!=0)\r
-       {\r
-               if (message("CPI not created",err,2)==0)\r
-                       status=newCPI();\r
-               else\r
-                       break;\r
-       }\r
-       any=!status;\r
-       if(any)\r
+       switch(status)\r
        {\r
+       case 310: //not created but nothing is lost\r
+               message("CPI not created",err);\r
+       case 1: //cancelled\r
+               redraw();\r
+               return;\r
+       case 0: //success\r
+               any=1;\r
                strcpy(nazwap,"new CPI");\r
                cp=0;\r
                if(byo8[0])\r
@@ -1855,8 +1894,14 @@ void newCPI3()//
                else if(byo14[0])\r
                        wys=14;\r
                cury&=7;\r
+               redraw();\r
+               return;\r
+       default: //fail\r
+               message("CPI not created",err);\r
+               any=0;\r
+               redraw();\r
+               return;\r
        }\r
-       redraw();\r
 }\r
 \r
 void deleteCPI(short st,short a,short b)\r
@@ -1961,23 +2006,25 @@ void deleteCPI(short st,short a,short b)
 \r
 int newCP()\r
 {\r
-       short CP,h;\r
+       unsigned short CP,h;\r
        //char temp[51];\r
        if(FIH->num_codepages>=16)\r
        {\r
-               sprintf(err,"305:Already 16 codepages in CPI\n");\r
+               sprintf(err,"305:Already 16 codepages in this CPI\n");\r
                return 305;\r
        }\r
-       CP=question("Codepage number:");\r
+       if(question("Codepage number:",&CP)==1)\r
+               return 1;\r
        for(short i=0;i<FIH->num_codepages;++i)\r
        {\r
                if(CP==CPEH[i]->codepage)\r
                {\r
-                       sprintf(err,"314:cp%03u already in CPEH[%u]\n",CP,i);\r
+                       sprintf(err,"314:cp%03u already in this CPI\n",CP);\r
                        return 314;\r
                }\r
        }\r
-       h=question("Initial font height(8,14,16,all)");\r
+       if(question("Initial font height(8,14,16,all)",&h)==1)\r
+               return 1;\r
        if(h!=0&&h!=8&&h!=14&&h!=16)\r
        {\r
                sprintf(err,"310:Wrong height (%u)\n",h);\r
@@ -2071,16 +2118,28 @@ void newCP3()//
        _moveto(400,472);\r
        _outgtext("newCP");\r
        status=newCP();\r
-       if(status!=0)\r
+       switch(status)\r
+       {\r
+       case 305:\r
+       case 310:\r
+       case 314:\r
                message("Codepage not created",err);\r
-       else\r
+       case 1:\r
+               redraw();\r
+               return;\r
+       case 0:\r
                cp=FIH->num_codepages-1;\r
-       offset();\r
-       new8();\r
-       menu8();\r
-       \r
-       normCP();\r
-       return;\r
+               offset();\r
+               new8();\r
+               menu8();\r
+               normCP();\r
+               return;\r
+       default:\r
+               message("Codepage not created",err);\r
+               offset();\r
+               redraw();\r
+               return;         \r
+       }\r
 }\r
 \r
 void normCP()//\r
@@ -2138,14 +2197,22 @@ void prevCP()//
        return;\r
 }\r
 \r
-int delCP()\r
+int  delCP()\r
 {\r
-       short i;\r
+       char temp[41];\r
        if(FIH->num_codepages<=1)\r
        {\r
                sprintf(err,"317:Last codepage\n");\r
                return 317;\r
        }\r
+       sprintf(temp,"Delete cp%03u?\n",CPEH[cp]->codepage);\r
+       if(message("WARNING",temp,3)==1)\r
+               return 1;\r
+       return delCP2();\r
+}\r
+int delCP2()\r
+{\r
+       short i;\r
        for(i=0;i<CPIH[cp]->num_fonts;++i)\r
        {\r
                switch(SFH[cp][i]->height)\r
@@ -2201,8 +2268,13 @@ void delCP3()//
        _moveto(536,472);\r
        _outgtext("delCP");\r
        status=delCP();\r
-       if(status!=0)\r
-               message("Codepage not deleted",err);\r
+       if(status)\r
+       {\r
+               if(status>1)\r
+                       message("Codepage not deleted",err);\r
+               redraw();\r
+               return;\r
+       }       \r
        offset();\r
        cp%=FIH->num_codepages;\r
        new8();\r
@@ -2213,20 +2285,21 @@ void delCP3()//
 \r
 int newF()\r
 {\r
-       short h;\r
+       unsigned short h;\r
        if(CPIH[cp]->num_fonts>=3)\r
        {\r
-               sprintf(err,"309:Already 3 fonts in CPIH[%u]\n",cp);\r
+               sprintf(err,"309:Already 3 fonts in cp%03u\n",CPEH[cp]->codepage);\r
                return 309;\r
        }\r
-       h=question("Font height(8,14,16)");\r
+       if(question("Font height(8,14,16)",&h)==1)\r
+               return 1;\r
        return newF2(h);\r
 }\r
 int newF2(short h)\r
 {\r
        switch(h)\r
        {\r
-       case 8:\r
+       case 8: \r
                return newF8(cp);\r
        case 14:\r
                return newF14(cp);\r
@@ -2243,11 +2316,25 @@ void newF3()//
        _moveto(336,472);\r
        _outgtext("newF");\r
        status=newF();\r
-       if(status!=0)\r
+       switch(status)\r
+       {\r
+       case 309:\r
+       case 310:\r
+       case 313:\r
                message("Font not created",err);\r
-       offset();\r
-       redraw();\r
-       return;\r
+       case 1:\r
+               redraw();\r
+               return;\r
+       case 0:\r
+               offset();\r
+               redraw();\r
+               return;\r
+       default:\r
+               message("Font not created",err);\r
+               offset();\r
+               redraw();\r
+               return;\r
+       }\r
 }\r
 int newF8(short CP)\r
 {\r
@@ -2485,12 +2572,21 @@ void nextF()//
 \r
 int delF()\r
 {\r
-       short h;\r
+       char temp[41];\r
        if(CPIH[cp]->num_fonts<=1)\r
        {\r
-               sprintf(err,"315:Last font in CPIH[%u]\n",cp);\r
+               sprintf(err,"315:Last font in cp%03u\n",CPEH[cp]->codepage);\r
                return 315;\r
        }\r
+       sprintf(temp,"Delete 8x%02u in cp%03u?\n",wys,CPEH[cp]->codepage);\r
+       if(message("WARNING",temp,3)==1)\r
+               return 1;\r
+       return delF2();\r
+}\r
+int delF2()\r
+{\r
+       short h;\r
+       \r
        for(short i=0;i<CPIH[cp]->num_fonts;++i)\r
        {\r
                if(SFH[cp][i]->height==wys)\r
@@ -2518,8 +2614,13 @@ void delF3()//
        _moveto(472,472);\r
        _outgtext("delF");\r
        status=delF();\r
-       if(status!=0)\r
-       message("Font not deleted",err);\r
+       if(status)\r
+       {\r
+               if(status>1)\r
+                       message("Font not deleted",err);\r
+               redraw();\r
+               return;\r
+       }\r
        offset();\r
        new8();\r
        menu8();\r
@@ -2932,9 +3033,20 @@ int main(int argc,char* argv[])
                                _setcolor(C_NON);\r
                                _moveto(616,472);\r
                                _outgtext("end");\r
-                               if(maus)\r
-                                       resetMaus();\r
-                               break;\r
+                               if(!any)\r
+                               {\r
+                                       if(maus)\r
+                                               resetMaus();\r
+                                       break;\r
+                               }\r
+                               else if(!message("WARNING","A CPI is open; continue anyway?\n",3))\r
+                               {\r
+                                       if(maus)\r
+                                               resetMaus();\r
+                                       break;\r
+                               }\r
+                               else\r
+                                       redraw();\r
                        }\r
                        while(kbhit())\r
                        {\r
@@ -3478,8 +3590,18 @@ int main(int argc,char* argv[])
                                _setcolor(C_NON);\r
                                _moveto(616,472);\r
                                _outgtext("end");\r
-                               resetMaus();\r
-                               break;\r
+                               if(!any)\r
+                               {\r
+                                       resetMaus();\r
+                                       break;\r
+                               }\r
+                               else if(!message("WARNING","A CPI is open; continue anyway?\n",3))\r
+                               {\r
+                                       resetMaus();\r
+                                       break;\r
+                               }\r
+                               else\r
+                                       redraw();\r
                        }\r
                        \r
                        else\r
similarity index 100%
rename from SRC/cpitrick.asm
rename to source/cpied/cpitrick.asm
similarity index 92%
rename from SRC/cpx2cpi.c
rename to source/cpied/cpx2cpi.c
index e8cfe14c534b3748b7404848a9c832e7c1ddc28c..21e8060b56952553d51f8b2a52e7aa0830387a2e 100644 (file)
@@ -98,7 +98,8 @@ int main(int argc,char* argv[])
        }\r
 \r
        /* we do NOT free malloced buf later - happens on exit anyway. */\r
-\r
+ //Not so sure about that, got memory errors from command.com\r
\r
        /** Read the buffer **/\r
 \r
        /* if memory model is TINY (.com file), we need our */\r
@@ -114,6 +115,7 @@ int main(int argc,char* argv[])
                if(con)\r
                        printf("%s read error, code %u.\n",argv[1], r.x.ax);\r
     close (cpf);\r
+               farfree(buf);\r
                return 6;\r
        \r
        }\r
@@ -128,6 +130,7 @@ int main(int argc,char* argv[])
        {\r
                if(con)\r
                        puts("Not a CPI or CPX");\r
+               farfree(buf);\r
                return 5;\r
        }\r
        else if (m == 1)\r
@@ -139,6 +142,7 @@ int main(int argc,char* argv[])
                if(con)\r
                        printf("%s is already a CPI\n",argv[1]);\r
                close (cpf);\r
+               farfree(buf);\r
                return 4;\r
        }\r
        //create the cpi \r
@@ -146,6 +150,7 @@ int main(int argc,char* argv[])
        {\r
                if(con)\r
                        printf("could not create %s\n",argv[2]);\r
+               farfree(buf);\r
                return 3;\r
        }\r
        close (cpf);\r
@@ -154,6 +159,7 @@ int main(int argc,char* argv[])
        {\r
                if(con)\r
                        printf("could not open %s\n",argv[2]);\r
+               farfree(buf);\r
                return 2;\r
        }\r
        sregs.ds = FP_SEG(buf);\r
@@ -166,11 +172,13 @@ int main(int argc,char* argv[])
        {\r
                if(con)\r
                        printf("%s write error, code %u.\n",argv[2], r.x.ax);\r
+               farfree(buf);\r
                close (cpf);\r
                return 1;\r
        }\r
        close (cpf);\r
        if(con)\r
                printf("%s converted to %s\n",argv[1],argv[2]);\r
+       farfree(buf);\r
        return 0;\r
 }\r
similarity index 100%
rename from SRC/makefile
rename to source/cpied/makefile