(The base version is the source code included on the floppy disk
    supplied with the 1995 printing of THE FAX MODEM SOURCEBOOK.)

   List I issued 16th August 2000  (Item 14 is new)

   (The source code and object code included on the CD supplied with
    the 2000 printing of the book incorporates all these fixes.)


1. To ensure compatability with fax modems that only run at
   19200 bps :

   In ..\FAX\FAX.C
   Change line 119  "sess.speed=38400u"  to  "sess.speed=19200u"

2. To fix a serious low-level programming error affecting serial ports
   causing intermittent failures on unbuffered UARTs :


   Change line 314  "mov al,11100001b" to "mov al,10000111b"
   Change line 317  "in al,dx" to "call pin"
   Change line 318  "and al,00000011b" to "and al,11000000b"

3. To reduce the size of the fax code, amend the lines that require
   floating point libraries :


   Change line 345 "oures=(((float)Hres/(float)Vres)+0.5)"
                to "oures=(2*Hres)/Vres"
   Change line 346 "if (oures<2) image->options|=0x80"
                to "if (oures<3) image->options|=0x80"

   and if using a compiler (like Turbo C) that defines CLK_TCK as
   being 18.2, you should either explicitly cast all uses of the
   macro as (short), or else redefine it as integer 18. The fax
   timing tolerances of +-10% allow for the errors this would

4. For safety, ensure correct initialization of serial ports :


   Change line 176 "iniflag db 1 dup (?)" to "iniflag db 0"

5. In order to allow the modem autodetection routine in
   to correctly identify a class 2.0 modem :


   Insert "else" at the start of line 134

6. For compatability with a wider range of class 1 modems in
   error correcting mode (ECM) :


   Duplicate the existing check for a modem result code in lines
   248-251 immediately before the transmission of the three RCP
   frames. This means inserting the following 4 lines before line

   x=(import(result,64,10)) ;
   if (x==0) return (69) ;
   PRINTF (logfile,"%s\n",result) ;
   if ((strstr(result,"CONNECT"))==0) return (62) ;

7. To fix a bug affecting class 1 modems which stops T4 scan lines
   being padded out to the correct minimum scan line time :


   Change the loop control in line 535 from
   "for (x=(x*20/8) ; x ; x--)" to "for (i=(x*20/8) ; i ; i--)"

8. To enable the T.6 MMR encoder to correctly handle graphics characters
   when their fonts have no inter-line gap :


   Change line 135 from "unsigned char ref_line [MAXDOTS/8] ;"
   to "unsigned char ref_line [MAXDOTS/8], temp_line [MAXDOTS/8] ;"

   Change line 219 from "fax.thisline=&(bit_image[0]) ;"
   to "fax.thisline=temp_line ;"

   Change line 318 from "fax.thisline=&(bit_image[i]) ;"
   to "memcpy(fax.thisline,&(bit_image[i]),MAXDOTS/8) ;"

9. For safety, ensure correct initialization of modems :


   Change the modem initialization string in lines 104 and 123 from

   "ATH&D2E0X0\r" to "ATH&D2E0X0Q0V1\r"

10. To avoid attemting to reset modems on non-existent ports :

   In ..\FAX\FAX.C

   Change line 255 from "modemreset (&sess) ;"
   to "if (state!=1) modemreset (&sess) ;"

11. A cast is needed to enable detection of the modem cancelling a
    transmission when using a class 2.0 modem :

   In ..\FAX\FAXOUT20.C

   Change line 256 from "if (rxstat()!=0) if (rxchar()==can)"
   to "if (rxstat()!=0) if ((char)rxchar()==can)"

12. The code in the book has a bug whereby the calculation of minimum 
    scan line times when using class 1 modems gets repeated for each
    page sent, with the result than this time increases for each page. 
    A suitable fix is to declare a static variable initialized to zero 
    somewhere suitable in the code, for example in FAX.H :

    static int pagenumber = 0 ;

    and then amend the code as follows :

    In ..\FAX\FAXCLAS1.C insert at the start of line 538 

   "if (minscan!=0) minscan=(((x*100)/(1000/minscan))/8)+1 ;"

   a test such as 

   "if (pagenumber == 0) {if (minscan!=0) minscan=(((x*100)/(1000/minscan))/8)+1;} "

13. The 2-D decoder fails to trap negative run lengths when in vertical 
    mode and pass mode.  This means that received 2-D faxes with reception 
    errors can fail to display properly. The fixes are quite straightforward :


    Change line 372 from "code= ((b1-a0)+(code-VTMODE0)) ;"
    to "code= ((b1-a0)+(code-VTMODE0)) ; if (code <0) resync=1;"
    Change line 393 from "code=(b2-a0)" ; to "code=(b2-a0) ; if (code < 0) resync=1;" 

14. This is a book rather than a code error.  On page 31 in table 2.3,
    the makeup code for a black run length of 1088 is wrongly given as 
    000000111010. There should be an extra trailing 1 on the end: the 
    correct code is 0000001110101. Thanks to for pointing 
    this out.  Please note that the code table given on disk as part of 
    the encoding program in the HUFF.DAT file is quite correct and that
    this is a text misprint confined to the printed table in the book.

  • Margolis & Co
  • Fax Toolkit
  • Download
  • Fax Modem Sourcebook