home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / PROG / NAPAPI10.ZIP / NAPLPS.DOC < prev    next >
Encoding:
Text File  |  1993-07-14  |  40.5 KB  |  1,247 lines

  1.  
  2. Greetings Programmer,
  3.  
  4. Thanks for using my NAPLPS interpreter for Turbo Pascal 7.0.  This
  5. product was designed to enable everyone to add support for the naplps
  6. standard, without having to spend a lot of time and money dealing with
  7. the complex nature of the standard.  The Turbo Pascal NAPLPS interpreter
  8. is a very powerful tool that adds NAPLPS displaying capabilities to your
  9. Turbo Pascal 7.0 programs.
  10.  
  11. Although the NAPLPS interpreter was initially designed for other
  12. products soon to be released, it quickly became a powerful and easy to
  13. use product, which I hope you'll like as much as I do.
  14.  
  15. With regards,
  16.  
  17.    John M. Beck
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.                    Turbo  Pascal 7.0  NAPLPS Interpreter
  30.  
  31.  
  32.                               User's Manual
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.                     (c) Copyright 1993 by John M. Beck
  40.                             All Rights Reserved
  41.  
  42.                           Version 1.00 / July 1993
  43.  
  44.  
  45.  
  46.  
  47.  
  48.                          Naplps Interpreter
  49.                Copyright (C) 1991-92 by John M. Beck
  50.  
  51. -----------------------------------------------------------------
  52. Contents                                              Line Number
  53. -----------------------------------------------------------------
  54. Introduction...................................................72
  55. Quick start for experts........................................96
  56. Quick start for beginners.....................................111
  57. Example program...............................................148
  58. What is NAPLPS?...............................................198
  59. NAPLPS API description........................................237
  60. Extending the API.............................................808
  61. Features on the addition list.................................821
  62. Licensing agreement...........................................836
  63. How to register...............................................864
  64. Support.......................................................912
  65. Credits.......................................................926
  66. Appendix 1: Guide to NAPLPS lingo.............................994
  67. Appendix 2: American National Standards Committees...........1176
  68. Appendix 3: Proposal for External Device Support.............1226
  69.  
  70.  
  71. ------------
  72. Introduction
  73. ------------
  74.  
  75.    At the moment, more and more programmers are becoming interested in
  76. adding NAPLPS support to their programs.  Anyone who intends to stay up
  77. to date has to deal with all of the different protocols like NAPLPS, RIP,
  78. ETGC, etc.  Unfortunately, the NAPLPS protocol is one of the most complex and
  79. takes a lot of time and research to program.  Only a few programmers will
  80. be able to implement it from scratch.
  81.  
  82.    At the time I began developing the NAPLPS interpreter, I was one of
  83. the many trying to keep up to date with the technology.  Now I'm in the
  84. position to save you the time and development troubles of designing your
  85. own interpreter from scratch.  In addition to that, the NAPLPS
  86. interpreter source code is also being made available to registered
  87. users so that you can extend and customize it to your needs.
  88.  
  89. -----------
  90. Quick Setup
  91. -----------
  92.  
  93.    If you're so excited that you can't wait to start, here are the basic
  94. steps to writing your first NAPLPS compatible program:
  95.  
  96. For experts:
  97.  
  98. 1.  Add "graph", "driver1", and "naplps" to your uses statement.
  99. 2.  Call the procedure register_drivers *before* calling          
  100.     initgraph. 
  101. 3.  Call initgraph with '' passed as "pathtodrivers" parameter.   
  102.     *Note: use the NAPLPS global variables "graphdriver" and      
  103.     "graphmode" to initialize the graphics, that way the API      
  104.     knows what you passed.  See sample program for example.
  105. 4.  Call the procedure nap_init.
  106. 5.  Send any string of NAPLPS data to the procedure               
  107.     interpret_naplps. 
  108. 6.  Call updateblinks during idle moments.
  109. 7.  Call the procedure nap_done at your program's closing. 
  110.  
  111. For beginners:
  112.  
  113. 1.  Towards the top of your program, right under the PROGRAM      
  114.     statement, add the following line:
  115.  
  116.     USES graph, driver1, naplps;
  117.  
  118. 2.  Add to the first line of your program, right below the main   
  119.     BEGIN statement, the following lines:
  120.  
  121.     register_drivers;
  122.     graphmode := detect;
  123.     initgraph(graphdriver,graphmode,'');
  124.     nap_init;
  125.  
  126. 3.  To print some naplps information, use the procedure
  127.     interpret_naplps, like so:
  128.  
  129.     { str = string of naplps data }
  130.     interpret_naplps(str);
  131.  
  132. 4.  When your program is waiting for a user to do something, or   
  133.     is in a loop that you'd like the animation to continue        
  134.     through, call the procedure updateblinks like in this         
  135.     example:
  136.  
  137.     repeat {until user types something}
  138.        updateblinks;
  139.     until keypressed;
  140.     readkey;
  141.  
  142. 5.  Add to your program, right before the main END statement, the 
  143.     following line:
  144.  
  145.     nap_done;
  146.  
  147. ---------------
  148. Working Example
  149. ---------------
  150.  
  151. {$I NAPFLAGS.INC}
  152.  
  153. program test;
  154.  
  155. uses crt,dos,graph,driver1,naplps,timer;
  156.  
  157. var
  158.    f       : file;
  159.    numread : word;
  160.    buf     : array[0..199] of char; {200 char buffer}
  161.    str     : string;
  162.    start,
  163.    stop    : longint;
  164.  
  165. begin
  166.    register_drivers;
  167.    graphdriver := vga;
  168.    graphmode   := vgahi;
  169.    initgraph(graphdriver,graphmode,'');
  170.    nap_init;
  171.  
  172.    assign(f,'d:\files\videograp.nap');
  173.    reset(f,1);
  174.  
  175.    start := readtimer;
  176.    repeat
  177.       blockread(f,buf,sizeof(buf),numread);
  178.       move(buf,str[1],numread);
  179.       str[0] := char(numread);
  180.       interpret_naplps(str);
  181.    until numread = 0;
  182.    stop := readtimer;
  183.  
  184.    repeat
  185.       updateblinks;
  186.    until keypressed;
  187.    readkey;
  188.  
  189.    nap_done;
  190.    close(f);
  191.    closegraph;
  192.  
  193.    writeln('Elapsed time = ',(elapsedtime(start,stop,0)):10:4,'seconds');
  194.    readln;
  195. end.
  196.  
  197. ---------------
  198. What is NAPLPS?
  199. ---------------
  200.  
  201.      NAPLPS is the videotex/teletext industry standard for
  202. presentation level graphics.  The word NAPLPS stands for North
  203. American Presentation Level Protocol Syntax.  The North American
  204. part is in there because the NAPLPS syntax was standardized by
  205. both the American National Standards Institute and the Canadian
  206. Standards Association.  ANSI is responsible for industry
  207. standards for the way we display images all the way down to the
  208. way two computers establish a hardware connection.  Everyone has
  209. noticed ANSI.SYS in their configuration file, which was also a
  210. standard.
  211.  
  212.      From the technical side, NAPLPS is a *very* compact and
  213. efficient way to transfer pictorial information.  Everything is
  214. at the bit level, without regard to byte boundaries in parts.  It
  215. is well thought out in the respects that a single command can
  216. perform different functions depending on the data following it. 
  217. NAPLPS is also resolution and machine independent.   The same
  218. images can be viewed on a Mac, Amiga, IBM, or any other computer
  219. with a display device.
  220.  
  221.      From the user side, NAPLPS is simply neat.  You can type in
  222. different sizes of text, at different spacing, and at different
  223. rotations-even upside down. You can columnate the text and scroll
  224. little regions of the screen.  Then you can switch to the
  225. supplementary character set and type in different languages
  226. making pictures out of the circumflex, ogonek, breve, upper case
  227. Icelandic thorn, or lower case Greenlandic K (the special K
  228. symbol).  And how about those measly five block characters that
  229. everyone used to draw with?  NAPLPS offers you a full character set
  230. full of them -- a tetris player's nightmare.  All of this with just
  231. the text aspects.  You also have a full set of drawing commands.
  232. Arcs, circles, lines, rectangles, and all the rest of the geometric
  233. primitives.  As far as color goes, you can mix and use from 2 bit
  234. to 24 bit color depending on your monitor and software.
  235.  
  236. ----------------------
  237. NAPLPS API Description
  238. ----------------------
  239.  
  240.      There's not much to say about using this API, it is all very
  241. straight forward.  There may be some procedures and functions that
  242. you might want to experiment with.  If you purchase the source
  243. code, you'll find that each major procedure is followed by
  244. comments describing its function. The following are the interface
  245. sections of all the units. 
  246.  
  247. **************
  248. * NAPLPS.TPU *
  249. **************
  250.  
  251. UNIT Naplps;
  252.  
  253. INTERFACE
  254.  
  255. USES crt,       { screen library              }
  256.      graph,     { graphics library            }
  257.      bits1,     { unit for bit manipulation   }
  258.      draw1,     { drawing routines            }
  259.      trig1,     { trig calculations routines  }
  260.      timer,     { timing routines             }
  261.      driver1,   { graphics modes drivers      }
  262.      output1,   { text output object          }
  263.      charset1,  { primary character set       }
  264.      charset2,  { supplementary character set }
  265.      charset3;  { mosaic character set        }
  266.  
  267. CONST
  268.    maxblinks   = 255;    { 255 active blinks max }
  269.    maxpalette  = 255;    { 255 max color palette }
  270.    grafbufsize = 6*1024; { 6K graphics buffer    }
  271.  
  272.    setpal      : boolean = true; {for fade in and fade out graphics}
  273.  
  274. TYPE
  275.    charsets     = (pri,supp,pdi,mosaic,macro,drcs,temp,null);
  276.  
  277.    temprec      = record    {record to keep track of single shifts}
  278.       oldset,
  279.       newset    : charsets;
  280.    end;
  281.  
  282.    paletterec   = record    {record for palette management}
  283.       cr,cg,cb  : byte;
  284.       used      : boolean;
  285.    end;
  286.  
  287.    paltype = array[0..maxpalette] of paletterec;
  288.  
  289.    blinkrec = record        {record for blink management}
  290.       bto,
  291.       bfrom,
  292.       sr,sg,sb : byte;
  293.       sdelay,
  294.       ontime,
  295.       offtime  : word;
  296.       elapsed,
  297.       start    : longint;
  298.       ison,
  299.       active   : boolean;
  300.    end;
  301.  
  302.    macrorec = record        {record for macro information}
  303.       length  : word;
  304.       macro   : pointer; {every macro is allow 1K max size}
  305.       trnsmit : boolean; {thats 1024 characters / macro   }
  306.    end;
  307.  
  308.    drcsrec  = record        {record for DRCS information}
  309.       image   : pointer;
  310.       size    : word;
  311.    end;
  312.  
  313. VAR
  314.    graphmode,                   {use these variables when initializing  }
  315.    graphdriver : integer;       {the bgi drivers                        }
  316.  
  317.    savestr   : string;          {command buffer}
  318.    masterstr : string;          {main chunk of NAPLPS code}
  319.    masterlen : byte absolute masterstr; {length of masterlen}
  320.  
  321.    napon    : boolean;          {in graphics mode?}
  322.  
  323.    extra    : string;           {extra code that got cut off}
  324.    textout  : vgawriteobj;      {text output object}
  325.  
  326.    cf       : byte;             {current font}
  327.  
  328.    xaspect,                     {ANSI aspect ratios}
  329.    yaspect  : real;
  330.  
  331.    maxx,                        {max x res}
  332.    maxy     : integer;          {max y res}
  333.  
  334.    nbits    : byte;             {num of bits of color in graphics mode}
  335.    dimen    : byte;             {dimensionality}
  336.    slen     : byte;             {single value operand length}
  337.    mlen     : byte;             {multi value operand length}
  338.    px,py    : integer;          {pel x and y positions}
  339.  
  340.    tset     : temprec;          {rec for SS's}
  341.    g0,g1,                       {virtual character tables}
  342.    g2,g3    : charsets;
  343.    gl,gr    : charsets;         {in use character tables}
  344.  
  345.    blinksize : byte;            {# of active blinks}
  346.    drcss     : array[0..95]  of drcsrec;      {drcs set}
  347.    macros    : array[0..95]  of macrorec;     {macro set}
  348.    polygon   : array[0..500] of pointtype;    {global var for polygon drawing}
  349.  
  350.    palette   : paltype;                         {palette info}
  351.    blinks    : array[0..maxblinks]  of blinkrec; {blinks info}
  352.  
  353. procedure nap_init;
  354. procedure nap_done;
  355.  
  356. function  checkwrap                     : boolean;
  357. function  nextisoper(theset : charsets) : boolean;
  358.  
  359. function  naptocartx (str : string) : real;
  360. function  naptocarty (str : string) : real;
  361.  
  362. function  naptocordx (str : string) : integer;
  363. function  naptocordy (str : string) : integer;
  364. function  naptosizex (str : string) : integer;
  365. function  naptosizey (str : string) : integer;
  366.  
  367. function  naptocordrx(str : string) : real;
  368. function  naptocordry(str : string) : real;
  369. function  naptosizerx(str : string) : real;
  370. function  naptosizery(str : string) : real;
  371.  
  372. procedure angtocolor(ang : integer; var cr,cg,cb : byte);
  373. procedure naptocolor(str : string ; var cr,cg,cb : byte);
  374.  
  375. function  get_g0        : charsets ; {virtual table}
  376. function  get_g1        : charsets ;
  377. function  get_g2        : charsets ;
  378. function  get_g3        : charsets ;
  379. procedure set_g0(newset : charsets);
  380. procedure set_g1(newset : charsets);
  381. procedure set_g2(newset : charsets);
  382. procedure set_g3(newset : charsets);
  383.  
  384. function  get_gl        : charsets ; {in-use table }
  385. function  get_gr        : charsets ;
  386. procedure set_gl(newset : charsets);
  387. procedure set_gr(newset : charsets);
  388.  
  389. function  getnapstatus      : boolean ; {nap mode on or off}
  390. procedure setnapstatus(ison : boolean);
  391.  
  392. procedure gettsetinfo(var olds,news : charsets); {temp char set}
  393. procedure settsetinfo(olds,news     : charsets);
  394.  
  395. function  getcf     : integer ;
  396. procedure setcf(ncf : integer);
  397. procedure setdif;
  398.  
  399. function  findfirstnotused                   : integer;
  400. function  findpalettecolor (cr,cg,cb : byte) : integer;
  401. procedure setnappalette(reg,cr,cg,cb : byte);
  402. procedure setrgbpalette_fast(color,red,green,blue: byte);
  403.  
  404. procedure assign_text_variables;
  405. procedure assign_default_colormap;
  406. procedure assign_texture_variables;
  407.  
  408. procedure reset_naplps ;
  409. procedure reset_domain ;
  410. procedure reset_colors ;
  411. procedure reset_text   ;
  412. procedure reset_blink  ;
  413. procedure reset_texture;
  414. procedure reset_macro  ;
  415. procedure reset_drcs   ;
  416.  
  417. procedure beep        ;
  418. procedure updateblinks;
  419. procedure remove_blink(num : byte);
  420. procedure check_blink (var a : blinkrec);
  421. function  findblink   (var a : blinkrec): integer;
  422.  
  423. procedure exec_si    ; {shift in              } {G0->GL }
  424. procedure exec_so    ; {shift out             } {G1->GL }
  425. procedure exec_ls1r  ; {locking shift 1 right } {G1->GR }
  426. procedure exec_ls2   ; {locking shift 2       } {G2->GL }
  427. procedure exec_ls2r  ; {locking shift 2 right } {G2->GR }
  428. procedure exec_ls3   ; {locking shift 3       } {G3->GL }
  429. procedure exec_ls3r  ; {locking shift 3 right } {G3->GR }
  430. procedure exec_ss2   ; {single shift two      } {G2 TEMP}
  431. procedure exec_ss3   ; {single shift three    } {G3 TEMP}
  432.  
  433. procedure exec_domain      ;
  434. procedure exec_text        ;
  435. procedure exec_texture     ;
  436. procedure exec_field       ;
  437. procedure exec_setcolor    ;
  438. procedure exec_selectcolor ;
  439. procedure exec_reset       ;
  440. procedure exec_line_abs    ;
  441. procedure exec_line_rel    ;
  442. procedure exec_setnline_abs;
  443. procedure exec_setnline_rel;
  444. procedure exec_incpoint    ;
  445. procedure exec_incline     ;
  446. procedure exec_incpoly     ;
  447. procedure exec_wait        ;
  448. procedure exec_blink       ;
  449.  
  450. procedure exec_pointset_abs(visible      : boolean);
  451. procedure exec_pointset_rel(visible      : boolean);
  452. procedure exec_arc         (setp, filled : boolean);
  453. procedure exec_poly        (setp, filled : boolean);
  454. procedure exec_rectangle   (setp, filled : boolean);
  455.  
  456. procedure exec_defdrcs;
  457. procedure exec_deftexture;
  458. procedure exec_defmacro(defp,transmittion : boolean);
  459.  
  460. procedure decode_control0_set;
  461. procedure decode_control1_set;
  462.  
  463. procedure decode_pri   ; {interpret command from primary set      }
  464. procedure decode_supp  ; {interpret command from supplementary set}
  465. procedure decode_pdi   ; {interpret command from PDI set          }
  466. procedure decode_mosaic; {interpret command from mosaic set       }
  467. procedure decode_macro ; {interpret command from macro set        }
  468. procedure decode_drcs  ; {interpret command from DRCS set         }
  469.  
  470. PROCEDURE INTERPRET_NAPLPS(str : string); {the main procedure}
  471.  
  472. IMPLEMENTATION
  473.  
  474. *************
  475. * BITS1.TPU *
  476. *************
  477.  
  478. unit bits1;
  479.  
  480. interface
  481.  
  482. function  biton     (position, testbyte    : byte  ) : boolean;
  483. function  bitval    (position,len,testbyte : byte  ) : byte   ;
  484. function  dectobin  (dec,sig               : byte  ) : string ;
  485. function  bintodec  (binstr                : string) : byte   ;
  486.  
  487. function  maxbinf       (len,dim : byte ) : real;
  488. function  binftodecf    (binstr : string) : real;
  489. function  int_binftodecf(binstr : string) : real;
  490.  
  491. function  decftobinf    (sig   : byte; decf   : real  ) : string;
  492. function  roundbinf     (place : byte; binstr : string) : string;
  493.  
  494. procedure setbit(position,value : byte; var changebyte : byte);
  495.  
  496. implementation
  497.  
  498. ****************
  499. * CHARSET1.TPU *
  500. ****************
  501.  
  502. unit charset1;
  503.  
  504. interface
  505.  
  506. var
  507.    p1,p2,p3,p4 : integer; {font numbers}
  508.  
  509. procedure register_primary;
  510.  
  511. procedure primarya_driver;
  512. procedure primaryb_driver;
  513. procedure primaryc_driver;
  514. procedure primaryd_driver;
  515.  
  516. implementation
  517.  
  518. ****************
  519. * CHARSET2.TPU *
  520. ****************
  521.  
  522. unit charset2;
  523.  
  524. interface
  525.  
  526. var
  527.    s1,s2,s3,s4 : integer; {font numbers}
  528.  
  529. procedure register_supplementary;
  530.  
  531. procedure supplementarya_driver ;
  532. procedure supplementaryb_driver ;
  533. procedure supplementaryc_driver ;
  534. procedure supplementaryd_driver ;
  535.  
  536. implementation
  537.  
  538. ****************
  539. * CHARSET3.TPU *
  540. ****************
  541.  
  542. unit charset3;
  543.  
  544. interface
  545.  
  546. var
  547.    m1,m2,m3,m4 : integer; {font numbers}
  548.  
  549. procedure register_mosaic;
  550.  
  551. procedure mosaica_driver;
  552. procedure mosaicb_driver;
  553. procedure mosaicc_driver;
  554. procedure mosaicd_driver;
  555.  
  556. implementation
  557.  
  558. *************
  559. * DRAW1.TPU *
  560. *************
  561.  
  562. unit draw1;
  563.  
  564. interface
  565.  
  566. uses graph, trig1;
  567.  
  568. var
  569.    cmode,                                      { color mode      }
  570.    pattern,                                    { fill pattern    }
  571.    highcolor,                                  { highlight color }
  572.    highlight : byte;                           { use highlight   }
  573.    patterns  : array[0..3] of fillpatterntype; { fill patterns   }
  574.  
  575.    ltexture : byte;
  576.    mdx,
  577.    mdy      : real;
  578.                            {logical pel dimensions}
  579.    pdxr,pdyr    : real;    { real width and height     }
  580.    pdx,pdy      : integer; { adjusted width and height }
  581.  
  582.    forecolor,           { foreground color register }
  583.    backcolor    : byte; { background color register }
  584.  
  585. procedure showpalette;
  586. procedure set_aspects;
  587.  
  588. procedure draw_pel     (wx,wy                       : integer);
  589. procedure clear_area   (x1,y1,x2,y2                 : integer);
  590. procedure draw_line_pas(start_x,start_y,end_x,end_y : integer);
  591. procedure draw_line_asm(start_x,start_y,end_x,end_y : integer);
  592.  
  593. procedure draw_circle   (wx,wy,rad           : integer; filled : boolean);
  594. procedure draw_rectangle(x1,y1,x2,y2         : integer; filled : boolean);
  595. procedure draw_arc      (cx,cy,ang1,ang2,rad : integer; filled : boolean);
  596.  
  597. procedure draw_poly(num : word; var points : array of pointtype; filled : boolean);
  598.  
  599. implementation
  600.  
  601. ***************
  602. * DRIVER1.TPU *
  603. ***************
  604.  
  605. unit driver1;
  606.  
  607. interface
  608.  
  609. const
  610.    drv1result   : integer = 0; {unit operations result variable}
  611.  
  612. (* Driver Installation Procedures *)
  613.  
  614. procedure att_driver     ;
  615. procedure cga_driver     ;
  616. procedure herc_driver    ;
  617. procedure egavga_driver  ;
  618. procedure pc3270_driver  ;
  619.  
  620. procedure register_drivers ;
  621.  
  622. implementation
  623.  
  624. ***************
  625. * OUTPUT1.TPU *
  626. ***************
  627.  
  628. unit output1;
  629.  
  630. interface
  631.  
  632. type
  633.    fieldrec     = record
  634.       x1,y1,
  635.       x2,y2     : integer;
  636.    end;
  637.  
  638.    vgawriteobjptr = ^vgawriteobj;
  639.  
  640.    vgawriteOBJ = object
  641.       constructor init;
  642.  
  643.       function  getseg        : word ;
  644.       procedure setseg(newseg : word);
  645.  
  646.       function  getprop       : boolean ;
  647.       procedure setprop(newp  : boolean);
  648.  
  649.       procedure setxadj(nx : integer);
  650.       procedure setyadj(ny : integer);
  651.  
  652.       function  getwidth  : integer;
  653.       function  getheight : integer;
  654.  
  655.       function  cordtorow  (cord : integer) : byte;
  656.       function  cordtocol  (cord : integer) : byte;
  657.  
  658.       function  getnumcols : integer;
  659.       function  getnumrows : integer;
  660.  
  661.       function  needswrap   : boolean;
  662.       function  getlastchar : char;
  663.  
  664.       procedure pel_to_text(    px,py : integer);
  665.       procedure text_to_pel(var px,py : integer);
  666.  
  667.       procedure do_apb;
  668.       procedure do_apf;
  669.       procedure do_apd;
  670.       procedure do_apu;
  671.       procedure do_apr;
  672.  
  673.       function  getxspacing     : real ;
  674.       function  getyspacing     : real ;
  675.       procedure setxspacing(new : real);
  676.       procedure setyspacing(new : real);
  677.  
  678.       function  getx    : byte ;
  679.       function  gety    : byte ;
  680.       procedure setx(nx : byte);
  681.       procedure sety(ny : byte);
  682.  
  683.       function  getxabs    : integer ;
  684.       function  getyabs    : integer ;
  685.       procedure setxabs(nx : integer);
  686.       procedure setyabs(ny : integer);
  687.  
  688.       function  gettdir     : byte ;
  689.       procedure settdir(dir : byte);
  690.  
  691.       function  getscroll    : boolean ;
  692.       procedure setscroll(on : boolean);
  693.  
  694.       function  getwrap    : boolean ;
  695.       procedure setwrap(on : boolean);
  696.  
  697.       procedure clear_area(x1,y1,x2,y2 : integer);
  698.  
  699.       procedure window(x1,y1,x2,y2 : byte);
  700.  
  701.       procedure scrollup   (x1,y1,x2,y2,num : integer);
  702.       procedure scrolldown (x1,y1,x2,y2,num : integer);
  703.       procedure scrollleft (x1,y1,x2,y2,num : integer);
  704.       procedure scrollright(x1,y1,x2,y2,num : integer);
  705.  
  706.       procedure writechar(ch : char; adv : boolean; cmode : byte);
  707.  
  708.       destructor  done;
  709.    private
  710.       lastchar  : char   ;
  711.       tdir      : byte   ; {text direction}
  712.       prop      : boolean;
  713.       scroll    : boolean; {scroll on/off}
  714.       wrap      : boolean; {integer wrap on/off}
  715.       xspace    : real   ; {intercharacter spacing}
  716.       yspace    : real   ; {interrow spacing}
  717.       tx,ty     : integer; {note: text cords start at zero!}
  718.       graphseg  : word   ; {graphics segment}
  719.    end;
  720.  
  721. VAR
  722.    field  : fieldrec;
  723.    sfield : fieldrec;
  724.  
  725.    rot      : byte;
  726.    cpath    : byte;
  727.    xspac    : byte;
  728.    yspac    : byte;
  729.    mparam   : byte;
  730.    cstyle   : byte;
  731.  
  732.    cdx  : integer;
  733.    cdy  : integer;
  734.    cdif : integer;
  735.  
  736.    rchar        : char;
  737.    rforecolor,
  738.    rbackcolor   : byte;
  739.    underlineon,
  740.    reverseon    : boolean;
  741.  
  742. implementation
  743.  
  744. *************
  745. * TIMER.TPU *
  746. *************
  747.  
  748. unit timer;
  749.  
  750. interface
  751.  
  752. function calibrate                   : longint;
  753. function readtimer                   : longint;
  754. function elapsedtime    (start, stop : longint; format : byte): real;
  755. function elapsedtime_int(start, stop : longint; format : byte): longint;
  756. function add_time       (time : longint; amount,format : byte): longint;
  757.  
  758. procedure init_timer;
  759. procedure done_timer;
  760.  
  761. implementation
  762.  
  763. *************
  764. * TRIG1.TPU *
  765. *************
  766.  
  767. unit trig1;
  768.  
  769. interface
  770.  
  771. { everything's in radians }
  772.  
  773. function rad_to_deg(r : real) : real;
  774. function deg_to_rad(d : real) : real;
  775.  
  776. function sign (var x : real): real;
  777. function logb (var b : real; var x : real): real;
  778.  
  779. function tan(var x : real): real;
  780. function cot(var x : real): real;
  781. function sec(var x : real): real;
  782. function csc(var x : real): real;
  783.  
  784. function arcsin(var x : real): real;
  785. function arccos(var x : real): real;
  786. function arcsec(var x : real): real;
  787. function arccsc(var x : real): real;
  788.  
  789. function sinh(var x : real): real;
  790. function cosh(var x : real): real;
  791. function tanh(var x : real): real;
  792. function coth(var x : real): real;
  793. function sech(var x : real): real;
  794. function csch(var x : real): real;
  795.  
  796. function arcsinh(var x : real): real;
  797. function arccosh(var x : real): real;
  798. function arctanh(var x : real): real;
  799. function arccoth(var x : real): real;
  800. function arcsech(var x : real): real;
  801. function arccsch(var x : real): real;
  802.  
  803. function find_angle(x1,y1,x2,y2 : real) : word;
  804.  
  805. implementation
  806.  
  807. -----------------
  808. Extending the API
  809. -----------------
  810.  
  811.      With the source code, you are free to make any changes that
  812. you wish. One such change that you may consider customizing is
  813. the text mode printing.  When NAPLPS mode is turned off, the API
  814. uses Turbo's internal write command to print the subsequent
  815. characters.  To modify this so that you may have ANSI color
  816. interpretation, or have the API filter the information to another
  817. layer in your program, simply change the line in the procedure
  818. interpret_naplps to pass the data where ever you wish. 
  819.  
  820. -----------------------------
  821. Features on the addition list
  822. -----------------------------
  823.  
  824.      The following features could not be implemented in time for
  825. this release, but will available for a free upgrade to registered
  826. users of the API.
  827.  
  828.   - Drawing core taken to assembly.
  829.   - Screen scrolling taken to assembly.
  830.   - DRCS set implemented.
  831.   - Four user definable fill patterns implemented.
  832.   - Line styles implemented at any pel size.
  833.   - Cursor support
  834.  
  835. -------------------
  836. Licensing Agreement
  837. -------------------
  838.  
  839.    The NAPLPS Interpreter (API) software is copyright by John M. Beck.
  840. You may use this software for free, without any notice to the users of
  841. any programs you create, only if the programs are for free.  If the
  842. program that you create is sold, distributed, or registered for money,
  843. you must register this software with the option of purchasing the source
  844. code.  After registration of this software, you may freely use it in any
  845. commercial programs you create without any notice to the users and
  846. without royalties.  You may not include this software in any tool kits or
  847. programmer utilities, and you may not release the source code if purchased.
  848.  
  849.    This license is non-transferrable.  By using this software, you agree
  850. to the terms of this license.  I support no warranties for this product,
  851. and disclaim any warranties either expressed or implied. I accept no
  852. liability for the use of this product, or any consequences or consequential
  853. damages resulting from the use of this product, even if I have advised of
  854. the possibility of such damages.
  855.  
  856.      This statement shall be construed, interpreted and governed by the
  857. laws of the State of Indiana.  Use, duplication or disclosure by the U.S.
  858. Government of this software and documentation shall be subject to
  859. restricted rights (under DFARS 52.227-7013) applicable to commercial
  860. computer software. All rights not specifically granted in this statement
  861. are reserved by John M. Beck.
  862.  
  863. ---------------
  864. How to Register
  865. ---------------
  866.  
  867.          Turbo Pascal 7.0 NAPLPS Interpreter Registration Form
  868.  
  869.  
  870. Name      ___________________________________________________ 
  871. Address   ___________________________________________________ 
  872.           ___________________________________________________ 
  873. City      ____________________   State _____  Zip   _________ 
  874. Country   ___________________________
  875.  
  876. Telephone ___________________________
  877.  
  878. Disk Size:  ( ) 360k   5 1/4"      ( ) 720k 3 1/2"
  879.             ( ) 1.2 Mb 5 1/4"      ( ) 1.44 3 1/2"
  880.  
  881. The prices below are effective July 10, 1993 and are subject to
  882. change. 
  883.  
  884.   No of copies required     :  _____     @ $100.00  =  $ _____ 
  885.   No of copies + source code:  _____     @ $200.00  =  $ _____ 
  886.  
  887. *Note: if you don't buy the source code now, but may buy it in
  888.        the future, save your return card.  Fill it out and send   
  889.        it back with the difference ($100) and we'll return send   
  890.        you the source code.                                       
  891.                   
  892.       Shipping (per copy) - This price includes upgrade shipping.
  893.  
  894.                   USA      + $5.00
  895.                   Canada   + $10.00
  896.                   Overseas + $15.00             =  $ _____ 
  897.  
  898.                                 Total enclosed  =  $ _____ 
  899.  
  900. - Make checks payable to John M. Beck.
  901.  
  902. *Note: Checks must be in US dollars from a US account with an     
  903.        American Banking Association routing number.
  904.  
  905. Send the above form to:
  906.  
  907.   John M. Beck
  908.   Futureware Co.
  909.   PO Box 9742
  910.   Ft. Wayne, IN 46899
  911.  
  912. -------
  913. Support
  914. -------
  915.  
  916.    If you encounter any problems that you cannot resolve, send a copy of
  917. the problematic software with a description of the problem, a copy of your
  918. config.sys and autoexec.bat files, and a description of your computer to:
  919.  
  920.           John M. Beck
  921.           Futureware Co.
  922.           P.O. Box 9742
  923.           Ft. Wayne, In 46899
  924.  
  925.    And I'll do my best to eradicate the problem.
  926.  
  927. -------
  928. Credits
  929. -------
  930.  
  931. The American National Standards Institute and the Canadian
  932. Standards Association for their development of this standard.
  933.  
  934. ANSI can be reached at:
  935.    American National Standards Institute, Inc.
  936.    1430 Broadway
  937.    New York, NY 10018
  938.  
  939. CSA can be reached at:
  940.    Canadian Standards Association
  941.    178 Rexdale Boulevard
  942.    Rexdale (Toronto), Ontario M9W 1R3
  943.  
  944. Turbopower Software for their public domain routine to read and
  945. calibrate the timer chip.  Turbopower Software can be reached at
  946. 1-800-333-4160.
  947.  
  948. Jordan Hargrave for his public domain super vga bgi drivers.  At
  949. last contact, Jordan could be reached at the following locations:
  950.  
  951. From September 1st to May 8th:
  952.      Jordan Hargrave
  953.      1000 Morewood Ave, Box #3277
  954.      Pittsburgh, PA 15213
  955.      (412) 268-4493
  956.  
  957. From May 8th to September 1st:
  958.      Jordan Hargrave
  959.      1615 Burnley Road
  960.      Charlotte, NC 28210
  961.      (704) 553-2332
  962.  
  963. Glen F. Marshall for his public domain math unit, illustrating
  964. the arcsin, arccos, arctan, tan, and csc (etc.) calculations.  In
  965. Glen's documentation dating back a few years, he could be reached
  966. at: 
  967.         Glen F. Marshall
  968.         1006 Gwilym Circle
  969.         Berwyn, PA 19312
  970.  
  971. Lithium artist Damion Junk for agreeing to be hired to hand draw
  972. all twelve stroked fonts and for his contribution to the three
  973. point on a circle problem.  Damion can be netmailed as:
  974.  
  975. Damion Junk
  976. Semper Fi BBS
  977. 1:236/21@fidonet.org
  978.  
  979. Victor J. Capton for a earlier binary fraction algorithm, the end
  980. angle -> start angle or start angle -> end angle if statement,
  981. his insightful discussions on the three point on a circle problem,
  982. and insight in general.
  983.  
  984. Shawn Rhoads for insightful discussions regarding different aspects
  985. of the standard.  Shawn can be reached at the following address:
  986.  
  987. Shawn Rhoads
  988. Software @ Work
  989. P.O. Box 566491
  990. Atlanta, GA 31156
  991.  
  992. Jeff Feightner, Damion Junk, and Lawrence Fraser for loyal and patient
  993. prototype work, ideas, and creative bitching.
  994.  
  995. ---------------------------------
  996. Appendix 1: Guide to NAPLPS lingo
  997. ---------------------------------
  998.  
  999.      NAPLPS (we pronounce it nap'lips), through the course of its
  1000. development, has accumulated quite a large repertoire of lingo. 
  1001. If you come across a word or phrase that you don't recognize, try
  1002. looking it up below (a good portion of the following is found at
  1003. the beginning of the NAPLPS document in a more technical form).
  1004.  
  1005. Absolute coordinates - an ordered pair of signed two's complement 
  1006.   numbers that specify the new location of the drawing point as a 
  1007.   displacement of the origin (0,0).  Note that only positive      
  1008.   coordinates appear on the unit screen.
  1009.  
  1010. Alphanumeric text - the written form of languages, comprising the 
  1011.   alphabetic letters with or without the respective symbols and   
  1012.   special characters such as space.
  1013.  
  1014. Attribute - a settable parameter that is to be applied to all     
  1015.   subsequent text or pictorial information.
  1016.  
  1017. Binary fraction - a string of binary digits that are just right   
  1018.   of the decimal point.  A binary fraction of 0.1 would be 0.5 in 
  1019.   decimal.
  1020.  
  1021. Bit combination - a ordered set of bits (binary digits).
  1022.  
  1023. Border area - the part of the physical display screen that lies   
  1024.   outside of the display area.
  1025.  
  1026. C-Set or Control Set - the two control sets, C0 and C1, each      
  1027.   comprising thirty-two character positions.
  1028.  
  1029. Character field - the rectangular region in which a character is  
  1030.   displayed.
  1031.  
  1032. Code extension - techniques for expanding the absolute character  
  1033.   address space into a larger virtual address space.
  1034.  
  1035. Code table - the set of unambiguous rules that defines the        
  1036.   mapping of received bit combinations to presentation level      
  1037.   characters. 
  1038.  
  1039. Coding interface - an interface through which coded bit sequences
  1040.   pass. 
  1041.  
  1042. Color map address - an ordinal number associated with each pixel  
  1043.   in a digital image which represents the address in the color    
  1044.   map at which the actual color value can be found.
  1045.  
  1046. Color map - a look-up table which is used during scan conversion  
  1047.   of the image to convert color map addresses into actual color   
  1048.   values. 
  1049.  
  1050. Color value - a entry in a color map.
  1051.  
  1052. Composite symbol - a symbol consisting of a combination of        
  1053.   multiple symbols in a single character field.  The umlaut or    
  1054.   diacritical mark combined with a basic letter is an example.
  1055.  
  1056. Consistent with the physical resolution - the position of the     
  1057.   display information is calculated to a sufficient precision so
  1058.   that it is displayed within one pixel of the actual location.
  1059.  
  1060. Cursor - a indicator having character field dimensions of the     
  1061.   screen position where the next character is to be placed.
  1062.  
  1063. Designate - to identify a given set from the repertory of G-Sets
  1064.   as a G0, G1, G2, or G3 set.
  1065.  
  1066. Display area - the rectangular part of the physical display
  1067.   screen in which information is visibly displayed.
  1068.  
  1069. Drawing point - a indicator (similar to the cursor) of the
  1070.   position at which the next geometric primitive will begin
  1071.   execution. 
  1072.  
  1073. DRCS Set - Dynamically redefinable character set.  A set
  1074.   containing definable characters whose patterns are downloaded
  1075.   from the host. 
  1076.  
  1077. Escape sequence - a string of two or more bit combinations
  1078.   beginning with the escape character.
  1079.  
  1080. Final character - the last character of an escape sequence. 
  1081.  
  1082. G-Set - one of the four sets, G0, G1, G2, and G3, which each
  1083.   comprises 94 or 96 character positions.
  1084.  
  1085. G-Set repertory - the collection of available character sets. 
  1086.  
  1087. Geometric graphic primitive - a picture drawing algorithm which
  1088.   can be executed via a opcode and associated operands.
  1089.  
  1090. Graphic character repertoire - the list of graphic characters. 
  1091.  
  1092. Implementation-dependent - a feature that may be specified more   
  1093.   completely by the implementor.
  1094.  
  1095. In-use - the code sets or attributes that will be used to
  1096.   interpret to subsequently received commands.
  1097.  
  1098. Intermediate character - any character that occurs between the 
  1099.   escape character and the final character.
  1100.  
  1101. Invoke - to cause a designated code set to be represented by the
  1102.   bit combinations of the in-use table.
  1103.  
  1104. Layer - an individual module of the reference model for open
  1105.   systems interconnection (OSI).
  1106.  
  1107. Locking shift - an invocation of a code set into the in-use table
  1108.   which remains in effect until another code set is invoked in
  1109. its place. 
  1110.  
  1111. Logical picture element or logical pel - a geometric construct   
  1112.   associated with the drawing point whose size determines the
  1113.   stroke width of graphic primitives.
  1114.  
  1115. Macro - a stored string of presentation code represented by a
  1116.   single character.
  1117.  
  1118. Mosaic - a rectangular matrix of predefined elements that can be
  1119.   used to construct block style images.
  1120.  
  1121. Nominal black - the color black (all zeros) in color mode zero,
  1122.   or the color that is at color map address zero in color modes
  1123.   one and two.
  1124.  
  1125. Nominal white - the color white (all ones) in color mode zero, or
  1126.   the color that is at color map address seven in color modes one
  1127.   and two.
  1128.  
  1129. Nonspacing - a character that does not automatically advance the
  1130.   cursor after being printed.
  1131.  
  1132. Opcode - a one-byte character that initiates execution of a
  1133.   operation. 
  1134.  
  1135. Operand - one or more bytes following a opcode.
  1136.  
  1137. Physical picture element or pixel - the smallest displayable unit
  1138.   on a display device.
  1139.  
  1140. Pictorial information - the display information.
  1141.  
  1142. PDI - picture description instruction.  A opcode followed by zero
  1143.   or more operands that constitutes an executable picture or
  1144.   control operation. 
  1145.  
  1146. Presentation layer - the sixth of seven layers defined by ISO's   
  1147.   reference model for open systems interconnection.
  1148.  
  1149. Protocol - a set of rules and procedures governing the exchange
  1150.   of information.
  1151.  
  1152. Receiving device - equipment capable of receiving coded bit   
  1153.   combinations.
  1154.  
  1155. Relative coordinates - an ordered pair of signed two's compliment 
  1156.   numbers between -1 and 1 that specifies the new drawing point
  1157.   location with respect to the old location.
  1158.  
  1159. Service reference model or SRM - a specification of the minimum
  1160.   set of features that must be implemented by the receiving
  1161.   device in order to meet the requirements for a particular
  1162.   service.
  1163.  
  1164. Signed - a number which may be either positive or negative. 
  1165.  
  1166. Single shift - an invocation of a code set into the in-use table
  1167.   that affects only the interpretation of the next bit
  1168.   combination received. 
  1169.  
  1170. Spacing - a character that causes the cursor to automatically
  1171.   advance. 
  1172.  
  1173. Unit screen - the logical display address space within which all
  1174.   drawing operation are executed and alphanumeric characters are
  1175.   deposited. 
  1176.  
  1177. --------------------------------------------------
  1178. Appendix 2: American National Standards Committees
  1179. --------------------------------------------------
  1180.  
  1181.      The NAPLPS standard was processed and approved for submittal
  1182. to ANSI by the American National Standards Committee on
  1183. Information Processing Systems, X3.  At the time of NAPLPS's
  1184. approval, this committee had the following members (note that not
  1185. necessarily all members voted for NAPLPS's approval):
  1186.  
  1187. Organization
  1188. -----------------------------------------------------------------
  1189. American Library Association.....................................
  1190. American Nuclear Society.........................................
  1191. AMP Incorporated.................................................
  1192. Association of American Railroads................................
  1193. Association for Computing Machinery..............................
  1194. Association of the Institute 
  1195. for Certification of Computer Professionals......................
  1196. AT&T Information Systems.........................................
  1197. Burroughs Corporation............................................
  1198. Control Data Corporation.........................................
  1199. Data General Corporation.........................................
  1200. Data Processing Management Association...........................
  1201. Digital Equipment Computer Users Society.........................
  1202. Digital Equipment Corporation....................................
  1203. Exxon Office Systems.............................................
  1204. General Services Administration..................................
  1205. GUIDE International..............................................
  1206. Harris Corporation...............................................
  1207. Hewlett-Packard..................................................
  1208. Honeywell Information Systems....................................
  1209. IBM Corporation..................................................
  1210. IEEE.............................................................
  1211. Lawrence Kerkeley Laboratory.....................................
  1212. Life Office Management Association...............................
  1213. Moore Business Forms, Inc........................................
  1214. National Bureau of Standards.....................................
  1215. National Communications Systems..................................
  1216. NCR Corporation..................................................
  1217. Perkin-Elmer Corporation.........................................
  1218. Prime Computer...................................................
  1219. Recognition Technology Users Association.........................
  1220. SHARE, Inc.......................................................
  1221. Sperry Corporation...............................................
  1222. Telephone Group..................................................
  1223. Texas Instruments, Inc...........................................
  1224. Travelers Insurance Companies, Inc...............................
  1225. 3M Company.......................................................
  1226. US Department of Defense.........................................
  1227. VIM..............................................................
  1228. Wang Laboratories, Inc...........................................
  1229. Xerox Corporation................................................
  1230.  
  1231. ------------------------------------------------
  1232. Appendix 3: Proposal for External Device Support
  1233. ------------------------------------------------
  1234.  
  1235.      The following section refers to knowledgeable NAPLPS developers,
  1236. and users of the Turbo Pascal 7.0 NAPLPS Interpreter.
  1237.  
  1238.      Futureware proposes that in order to implement mouse and
  1239. sound support into the NAPLPS syntax, that we create and agree to
  1240. support a new character set; the external device set.  This would
  1241. be enough to handle the load of mice, joysticks, sound cards,
  1242. printers, light pens, and whatever else--there's an entire
  1243. character set to fill up.  If you're a NAPLPS developer, I'd like
  1244. to hear any input you may have about this.  Please write to us at
  1245. the above listed address.
  1246.  
  1247.