home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / DESQVIEW / TECH / DVA_TCPP.ZIP / DVAWARE.DOC < prev    next >
Encoding:
Text File  |  1990-08-06  |  19.9 KB  |  487 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.                                                    DVAWARE TC++ Library
  13.  
  14.                                                             Release 1.0
  15.  
  16.                                                            August, 1990
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.         _______________________________________________________________
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.                                                          Copyright 1990
  45.  
  46.                                                             Mark Potter
  47.  
  48.               Purpose:  A library to be used in TC++ v1.0 in order to
  49.                         write C or C++ programs which are DESQview
  50.                         aware.  This library includes the ability of
  51.                         making the TC conio routines DESQview screen
  52.                         aware.
  53.  
  54.             File List:  BUILDALL BAT   123 Used to (re)build all the
  55.                                             library files.
  56.                         BUILDLIB BAT  1203 Used to (re)build one of the
  57.                                             library files based on a
  58.                                             given memory model letter.
  59.                         DVAWARE  DOC 20363 This Documentation file.
  60.                         DVAWARE  H    6450 Header file for DVAWARE
  61.                                             Library.
  62.                         DVAWAREC LIB  2560 DVAWARE Libraries.  Each for
  63.                         DVAWAREH LIB  2560  one of the six different 
  64.                         DVAWAREL LIB  2560  memory model.
  65.                         DVAWAREM LIB  2560
  66.                         DVAWARES LIB  2560
  67.                         DVAWARET LIB  2560
  68.                         DVA_TEST C    8093 A sample program in C.
  69.                         DVA_TEST CPP  7981 A sample program in C++.
  70.                         DVCONIO  C    1949 Source files for the DVAWARE
  71.                         DVCRIT   C    3139  Libraries.
  72.                         DVGETVER C    1861
  73.                         DVGETVID C    3470
  74.                         DVPAUSE  C    1412
  75.                         INDV     C    1342
  76.  
  77.           Description:  Routines found in the DVAWARE library are found
  78.                         on the following pages.  To use the libraries
  79.                         one should only have to include the DVAWARE.H
  80.                         file in your program, and the appropriate
  81.                         DVAWAREx.LIB file in the project or make file.
  82.                         One can then call the DVAWARE routines freely.
  83.  
  84.                  Note:  The inDV variable is set by dv_get_version() and
  85.                         only by dv_get_version().  Therefore if you
  86.                         wish to use the inDV variable in your program,
  87.                         make sure you call dv_get_version() near the
  88.                         beginning of the program.
  89.  
  90.                Inline:  If you are using the DVAWARE library in a C++
  91.                         program you may opt to have the DVAWARE routines
  92.                         inline.  One might have the routines inline for
  93.                         possible speed and size advantages, depending on
  94.                         how the DVAWARE routines are call.
  95.  
  96.                         To make the DVAWARE routine inline, simply
  97.                         define the macro DVAWARE_INLINE before you
  98.                         include the DVAWARE.H file.
  99.                            #define DVAWARE_INLINE
  100.                            #include "DVAWARE.H"
  101.                         This will make all the function in DVAWARE
  102.                         inline.  This will also make the need for the
  103.                         DVAWAREx.LIB file unnecessary in the project
  104.                         file, except for the possible need of the inDV
  105.                         variable.  This can be overcome by including the
  106.                         library anyway, or by defining the inDV variable
  107.                         in one of your own modules.  One will need the
  108.                         inDV variable if the dv_get_version() function
  109.                         is called.
  110.  
  111.         dv_beginc
  112.         ________________________________________________________________
  113.  
  114.              Function:  Begin critical Region.
  115.  
  116.                Syntax:  #include "dvaware.h"
  117.                         void dv_beginc( void );
  118.  
  119.          Prototype in:  dvaware.h
  120.  
  121.               Remarks:  The dv_beginc() call causes the current task to
  122.                         enter a critical region during which all
  123.                         multitasking is suspended.  The calling task is
  124.                         allowed to continue execution until it calls
  125.                         dv_endc() or voluntarily gives up control.  If
  126.                         it voluntarily gives up control (by waiting for
  127.                         keyboard input for instance) multitasking is
  128.                         allowed to resume until the task regains
  129.                         control, at which time multitasking is again
  130.                         suspended. This facility can be useful for
  131.                         executing time critical sections of code and for
  132.                         controlling access to common resources.  It
  133.                         should be used sparingly to avoid degrading
  134.                         overall system performance.
  135.  
  136.                         If another task is using DOS when the
  137.                         dv_beginc() call is made, the caller will be
  138.                         suspended until DOS is free. This means that you
  139.                         are free to call DOS from inside a critical
  140.                         region.  (From Quarterdeck's DESQview API
  141.                         manual)
  142.  
  143.          Return value:  None.
  144.  
  145.           Portability:  dv_beginc is unique to the dvaware or similar
  146.                         libraries.
  147.  
  148.              See also:  dv_endc, dv_pause
  149.  
  150.               Example:  #include <conio.h>
  151.                         #include "dvaware.h"
  152.  
  153.                         int main( void )
  154.                         {
  155.                            long i=0;
  156.                            dv_conio();
  157.                            dv_beginc();
  158.                               while( !kbhit() )
  159.                                  i++;
  160.                               getch();
  161.                            dv_endc();
  162.                            cprintf( "%ul\r\n", i );
  163.                            return 0;
  164.                         }
  165.  
  166.  
  167.  
  168.         dv_conio
  169.         ________________________________________________________________
  170.  
  171.              Function:  Sets up the TC conio system to be DESQview
  172.                         screen aware.
  173.  
  174.                Syntax:  #include "dvaware.h"
  175.                         void dv_conio( void );
  176.  
  177.          Prototype in:  dvaware.h
  178.  
  179.               Remarks:  It has been noted that during the TC++ start up
  180.                         code a program identifies the screen type of
  181.                         screen it is running on, and places the segment
  182.                         address of the screen display in the word
  183.                         directly before the directvideo.  Therefore,
  184.                         using this as the input to dv_get_video_buffer()
  185.                         and placing the return value in the same
  186.                         location this should make all the later conio
  187.                         calls use the DESQview video buffer.  This
  188.                         function should be called as close to the begin
  189.                         of the program's executions as possible.  It
  190.                         will no longer be required to set directvideo to
  191.                         0 for the program to be DESQview screen nice.
  192.  
  193.          Return value:  None.
  194.  
  195.           Portability:  dv_conio is unique to the dvaware or similar
  196.                         libraries.
  197.  
  198.              See also:  dv_get_video_buffer
  199.  
  200.               Example:  #include <conio.h>
  201.                         #include "dvaware.h"
  202.                         int main( void )
  203.                         {
  204.                            dv_conio();
  205.                            cputs( "Hello World\r\n" );
  206.                            return 0;
  207.                         }
  208.  
  209.         dv_endc
  210.         ________________________________________________________________
  211.  
  212.              Function:  End critical region.
  213.  
  214.                Syntax:  #include "dvaware.h"
  215.                         void dv_endc( void );
  216.  
  217.          Prototype in:  dvaware.h
  218.  
  219.               Remarks:  The dv_endc() call defines the end of a critical
  220.                         region of code.  Critical regions are entered
  221.                         via the dv_beginc() call.  Calls to dv_beginc()
  222.                         and dv_endc() may be nested. Multitasking does
  223.                         not resume until an dv_endc() call has been
  224.                         executed for every dv_beginc() call that has been
  225.                         made.  (From Quarterdeck's DESQview API manual)
  226.  
  227.          Return value:  None.
  228.  
  229.           Portability:  dv_endc is unique to the dvaware or similar
  230.                         libraries.
  231.  
  232.              See also:  dv_beginc, dv_pause.
  233.  
  234.               Example:  #include <conio.h>
  235.                         #include <stdlib.h>
  236.  
  237.                         #include "dvaware.h"
  238.  
  239.                         int main( void )
  240.                         {
  241.                            long i=0;
  242.                            dv_conio();
  243.                            dv_beginc();
  244.                               while( !kbhit() )
  245.                                  i++;
  246.                               getch();
  247.                            dv_endc();
  248.                            cprintf( "%ul\r\n", i );
  249.                            return 0;
  250.                         }
  251.  
  252.  
  253.         dv_get_version
  254.         ________________________________________________________________
  255.  
  256.              Function:  Get the version of DESQview that is running.
  257.  
  258.                Syntax:  #include "dvaware.h"
  259.                         unsigned int dv_get_version( void );
  260.  
  261.          Prototype in:  dvaware.h
  262.  
  263.               Remarks:  dv_get_version() can be used to test for the
  264.                         existence of DESQview such as in:
  265.                            if ( dv_get_version() )
  266.                               ...
  267.  
  268.                         dv_get_version() also sets the inDV flag, so
  269.                         that the version of DESQview running can be
  270.                         tested at a latter time.
  271.  
  272.          Return value:  Returns the version of DESQview running, or 0 if
  273.                         DESQview is not running.  The value returned is
  274.                         encoded as follows:  The high byte of the return
  275.                         value is the major version number; The low byte
  276.                         is the minor.
  277.  
  278.           Portability:  dv_get_version is unique to the dvaware or
  279.                         similar libraries.
  280.  
  281.              See also:  inDV
  282.  
  283.               Example:  #include <conio.h>
  284.                         #include "dvaware.h"
  285.                         int main( void )
  286.                         {
  287.                            unsigned int ver = dv_get_version();
  288.                            dv_conio();
  289.                            if ( ver )
  290.                               cprintf( "The version of DESQview running"
  291.                                        " is %u.%02u.\r\n",
  292.                                        ver >> 8, ver & 0xFF           );
  293.                            else
  294.                               cprintf( "DESQview is not running.\r\n" );
  295.                         }
  296.  
  297.  
  298.         dv_get_video_buffer
  299.         ________________________________________________________________
  300.  
  301.              Function:  Get the video buffer segment.
  302.  
  303.                Syntax:  #include "dvaware.h"
  304.                         char _seg* dv_get_video_buffer(
  305.                                       char _seg* assumed );
  306.  
  307.          Prototype in:  dvaware.h
  308.  
  309.               Remarks:  Return the address of the Logic Window buffer
  310.                         for the current task and begins "shadowing"
  311.                         changes to the buffer.  Programs that have been
  312.                         written to place text directly into the display
  313.                         memory can be easily converted to run in a small
  314.                         window by making this call and writing into the
  315.                         Logical Window Buffer instead.  DESQview checks
  316.                         periodically to see if the contents of the
  317.                         buffer have changed and, if so, updates the
  318.                         display accordingly.  The assumed value on entry
  319.                         should contain the address of display memory
  320.                         that the program would write into if running
  321.                         outside DESQview.  If this routine is called
  322.                         outside DESQview it does nothing but return with
  323.                         the assumed value. You can, therefore, make this
  324.                         call and trust the results either inside of
  325.                         outside DESQview.
  326.  
  327.                         There is no need to synchronize with video
  328.                         retrace when writing into the Logical Window
  329.                         Buffer.  (From Quarterdeck's DESQview API
  330.                         manual)
  331.  
  332.          Return value:  Segment of the video display buffer.
  333.  
  334.           Portability:  dv_get_video_buffer is unique to the dvaware or
  335.                         similar libraries.
  336.  
  337.              See also:  dv_conio()
  338.  
  339.               Example:  #include "dvaware.h"
  340.                         int main( void )
  341.                         {
  342.                            char *msg = "This is a test";
  343.                            char _seg* video = (char _seg*)0xB800;
  344.                                                  // B000 for mono
  345.                            unsigned   offset = 0;
  346.                            video = dv_get_video_buffer( video );
  347.                            while ( *msg ) {
  348.                               *(video+offset) = *msg;
  349.                               offset+=2;
  350.                               msg++;
  351.                            }
  352.                            return 0;
  353.                         }
  354.  
  355.  
  356.         dv_pause
  357.         ________________________________________________________________
  358.  
  359.              Function:  Give up the rest of time slice.
  360.  
  361.                Syntax:  #include "dvaware.h"
  362.                         void dv_pause( void );
  363.  
  364.          Prototype in:  dvaware.h
  365.  
  366.               Remarks:  The dv_pause call gives up control to the
  367.                         dispatcher so that other tasks can be run.  The
  368.                         calling task will regain control when its normal
  369.                         turn occurs. Applications should make this call
  370.                         within all busy-wait loops,  that is, loops that
  371.                         are doing nothing useful but looking for
  372.                         something to do.  (From Quarterdeck's DESQview
  373.                         API manual)
  374.  
  375.          Return value:  None.
  376.  
  377.           Portability:  dv_pause is unique to the dvaware or similar
  378.                         libraries.
  379.  
  380.              See also:  dv_beginc, dv_endc
  381.  
  382.               Example:  #include <conio.h>
  383.                         #include "dvaware.h"
  384.                         int main( void )
  385.                         {
  386.                            dv_conio();
  387.                            cputs( "Press a key to continue..." );
  388.                            while (!kbhit())
  389.                               dv_pause();
  390.                            getch();
  391.                            return 0;
  392.                         }
  393.  
  394.  
  395.         inDV
  396.         ________________________________________________________________
  397.  
  398.              Function:  Holds the version of DESQview running, or 0 if
  399.                         not in DESQview.
  400.  
  401.                Syntax:  extern unsigned int inDV;
  402.  
  403.           Declared in:  dvaware.h
  404.  
  405.               Remarks:  Set to 0 if DESQview is not running.  Set to the
  406.                         version of the DV API active if DESQview is
  407.                         running. The high byte of inDV is the major
  408.                         version number, the low byte is the minor.  The
  409.                         value of inDV is set by the dv_get_version
  410.                         function.
  411.  
  412.               Example:  #include <conio.h>
  413.                         #include <stdlib.h>
  414.  
  415.                         #include "dvaware.h"
  416.  
  417.                         int main( void )
  418.                         {
  419.                            long i=0;
  420.                            dv_get_version();
  421.                            dv_conio();
  422.                            if (inDV) dv_beginc();
  423.                               while( !kbhit() )
  424.                                  i++;
  425.                               getch();
  426.                            if (inDV) dv_endc();
  427.                            cprintf( "%ul\r\n", i );
  428.                            return 0;
  429.                         }
  430.  
  431.  
  432.           Restrictions:  Copyright 1987, Mark Potter.  All rights
  433.                          reserved by the author, except for those
  434.                          specifically granted as follows.
  435.  
  436.                          The author grants the right to copy and
  437.                          distribute this package providing no fee
  438.                          greater than $5.00 US (or equivalent) is
  439.                          charged for this package.
  440.  
  441.                          This package may be placed on public or private
  442.                          computer systems for distribution, providing
  443.                          that the $5.00 fee is not exceeded and that no
  444.                          extra copyright is proclaimed on this work.
  445.  
  446.                          Any other distribution of this package requires
  447.                          permission from the author.
  448.  
  449.                          Programmers may use this library with there own
  450.                          code without any worry of royalty requirements.
  451.                          See shareware notice below.
  452.  
  453.                          Users of this package may freely modify the
  454.                          program for personal use.  Such modified
  455.                          libraries may be distributed to close associates
  456.                          but not to the general public.  Such
  457.                          distributions must include the complete
  458.                          original package.
  459.  
  460.           Shareware:     This library is not shareware, nor is it public
  461.                          domain, this is a copyrighted package.  To call
  462.                          it freeware would be correct, it is a
  463.                          copyrighted package which I ask no monetary
  464.                          return for its use.  However freeware is a
  465.                          trademarked term, so I can't actually call it
  466.                          that.  I do ask that if you find this package
  467.                          of use, that you drop me a postcard saying so.
  468.                          That way I will know my work wasn't for not,
  469.                          and thus may come out with other libraries or
  470.                          programs.  Thank you.
  471.  
  472.           Author:        Suggestions and comments about this and other
  473.                          programs can be sent to:
  474.                             Mark Potter
  475.                             1407 Hillcrest Dr.
  476.                             Blacksburg, VA  24060-5523
  477.                          Or electronically on the following BBSs:
  478.                             MBT     (703)552-8767
  479.                             VTBBS   (703)231-7498
  480.  
  481.                          Note that the Author is a presently a MS
  482.                          student in CS at Virginia Tech and due to
  483.                          finish soon.  The electronic mail may have
  484.                          delayed response after this date.  Physical
  485.                          mail should be forwarded for may years to come.
  486.                          
  487.