home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PIBMDOS.ZIP / TRYMDOS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-09-27  |  10.4 KB  |  238 lines

  1. (*$C-,U-,R-,V-,K-*)
  2. PROGRAM TryMDos;
  3.  
  4. (*----------------------------------------------------------------------*)
  5. (*               TryMDos --- Try multitaskers for DOS                   *)
  6. (*----------------------------------------------------------------------*)
  7. (*                                                                      *)
  8. (*  Author:   Philip R. Burns                                           *)
  9. (*                                                                      *)
  10. (*  Date:     September, 1986                                           *)
  11. (*  Version:  1.0                                                       *)
  12. (*                                                                      *)
  13. (*  Overview: This program demonstrates the routines contained in the   *)
  14. (*            file PIBMDOS.PAS, which provide Turbo Pascal interfaces   *)
  15. (*            to several popular multitasking programs for DOS:         *)
  16. (*                                                                      *)
  17. (*               - DesqView from QuarterDeck                            *)
  18. (*               - TaskView from Sunny Hill Software                    *)
  19. (*               - TopView from IBM                                     *)
  20. (*               - DoubleDos from SoftLogic                             *)
  21. (*                                                                      *)
  22. (*            Because MicroSoft Windows will emulate TopView, these     *)
  23. (*            routines are also useful for Windows.                     *)
  24. (*                                                                      *)
  25. (*            The TaskView interface assumes the program has been       *)
  26. (*            loaded using the LD-TVEM.EXE loader program provided      *)
  27. (*            as part of the TaskView release materials.                *)
  28. (*                                                                      *)
  29. (*  Remarks:  This sample program simply writes lines of text to the    *)
  30. (*            screen until a key is depressed.  Then, it loops waiting  *)
  31. (*            for input to show the difference between giving up and    *)
  32. (*            not giving up unused time to other partitions.            *)
  33. (*                                                                      *)
  34. (*            The include file PIBMDOS.PAS contains the actual          *)
  35. (*            multitasker interface routines.  In addition, a general   *)
  36. (*            purpose routine to write a string is included.  The       *)
  37. (*            string is written directly to screen memory if no         *)
  38. (*            multitasker is active, or to the virtual buffer if a      *)
  39. (*            multitasker is active.  It can also write the string      *)
  40. (*            using standard BIOS calls if desired.                     *)
  41. (*                                                                      *)
  42. (*            Global variables of importance:                           *)
  43. (*                                                                      *)
  44. (*               Virtual_Screen      --- address of real screen if no   *)
  45. (*                                       multitasker running, else      *)
  46. (*                                       address of virtual screen.     *)
  47. (*               MultiTasker         --- which multitasker is active.   *)
  48. (*               TimeSharingActive   --- TRUE if multitasker is active. *)
  49. (*               Wait_For_Retrace    --- Set this TRUE if your color    *)
  50. (*                                       graphics card produces snow    *)
  51. (*                                       when screen memory is accessed *)
  52. (*                                       (e.g., set TRUE for IBM's CGA  *)
  53. (*                                       but FALSE for Zeniths and      *)
  54. (*                                       Compaqs, among others).        *)
  55. (*               Write_Screen_Memory --- TRUE to write directly to      *)
  56. (*                                       screen memory -- either the    *)
  57. (*                                       genuine screen memory or the   *)
  58. (*                                       virtual buffer for a multi-    *)
  59. (*                                       tasker.  FALSE to use the BIOS *)
  60. (*                                       instead.                       *)
  61. (*                                                                      *)
  62. (*            I would appreciate it if anyone familiar with the other   *)
  63. (*            multitaskers for which no interface is provided would     *)
  64. (*            add the relevant code and upload a corrected copy         *)
  65. (*            for all of us to learn from.                              *)
  66. (*                                                                      *)
  67. (*----------------------------------------------------------------------*)
  68.  
  69. (*$I TRYMDOS.GLO *)
  70. (*$I PIBMDOS.PAS *)
  71. (*$I READKBD.PAS *)
  72. (*$I YESNO.PAS   *)
  73.  
  74. VAR
  75.    LineCount : REAL;
  76.    Ch        : CHAR;
  77.    S         : STRING[8];
  78.    Y         : INTEGER;
  79.  
  80. (*----------------------------------------------------------------------*)
  81. (*      Flush_Keyboard --- Flush pending keystrokes in keyboard         *)
  82. (*----------------------------------------------------------------------*)
  83.  
  84. PROCEDURE Flush_Keyboard;
  85.  
  86. VAR
  87.    Ch: CHAR;
  88.  
  89. BEGIN (* Flush_Keyboard    *)
  90.  
  91.    WHILE( KeyPressed ) DO
  92.       READ( Kbd, Ch );
  93.  
  94. END   (* Flush_Keyboard    *);
  95.  
  96. (*----------------------------------------------------------------------*)
  97. (*      Initialize --- Initialize multitasker demonstration             *)
  98. (*----------------------------------------------------------------------*)
  99.  
  100. PROCEDURE Initialize;
  101.  
  102. BEGIN (* Initialize *)
  103.                                    (* Clear screen *)
  104.    ClrScr;
  105.                                    (* Allow direct memory writes  *)
  106.    Write_Screen_Memory := TRUE;
  107.                                    (* Don't wait for retrace      *)
  108.    Wait_For_Retrace    := FALSE;
  109.  
  110.                                    (* See which multitasker active *)
  111.  
  112.    TimeSharingActive := IsTimeSharingActive;
  113.  
  114.                                    (* Indicate which is active     *)
  115.    CASE MultiTasker OF
  116.                                    (* No multitasker -- ask if we should *)
  117.                                    (* wait for retraces in direct screen *)
  118.                                    (* writes, or use BIOS.               *)
  119.       MultiTasker_None : BEGIN
  120.                             WRITELN('No multitasker active.');
  121.                             Wait_For_Retrace    := YesNo('Wait for retrace in direct screen writes?');
  122.                             Write_Screen_Memory := YesNo('Use BIOS instead of direct screen writes?');
  123.                             WRITELN;
  124.                          END;
  125.       TopView          : WRITELN('TopView active.');
  126.       DesqView         : WRITELN('DesqView active.');
  127.       TaskView         : WRITELN('TaskView active.');
  128.       DoubleDos        : WRITELN('DoubleDos active.');
  129.       ELSE;
  130.    END (* CASE *);
  131.  
  132. END   (* Initialize *);
  133.  
  134. (*----------------------------------------------------------------------*)
  135. (*      Try_Screen_Writes --- Try writing strings to screen memory      *)
  136. (*----------------------------------------------------------------------*)
  137.  
  138. PROCEDURE Try_Screen_Writes;
  139.  
  140. BEGIN (* Try_Screen_Writes *)
  141.                                    (* Write lines to screen until a key *)
  142.                                    (* is hit.                           *)
  143.  
  144.    WRITELN('First test is writing text to virtual buffer.');
  145.    WRITELN('A continuous series of lines will be written until');
  146.    WRITELN('a key is pressed.  You can switch to another partition');
  147.    WRITELN('and see that no bleed though occurs.');
  148.    WRITE  ('Hit a key to start test: ');
  149.  
  150.    Read_Kbd( Ch );
  151.  
  152.    Flush_Keyboard;
  153.  
  154.    LineCount := 0.0;
  155.    Y         := WhereY;
  156.  
  157.    WHILE( NOT KeyPressed ) DO
  158.       BEGIN
  159.          LineCount := LineCount + 1.0;
  160.          STR( LineCount:8:0 , S );
  161.          WriteSXY( 'Line ' + S + ' is now being displayed on the screen.', 1, Y, White );
  162.          Y         := Y + 1;
  163.          IF ( Y > 25 ) THEN
  164.             Y := 1;
  165.       END;
  166.                                    (* Flush keyboard buffer *)
  167.    Flush_Keyboard;
  168.  
  169. END   (* Try_Screen_Writes *);
  170.  
  171. (*----------------------------------------------------------------------*)
  172. (*      Try_GiveAway --- Try giving up time to other partitions         *)
  173. (*----------------------------------------------------------------------*)
  174.  
  175. PROCEDURE Try_GiveAway;
  176.  
  177. BEGIN (* Try_GiveAway *)
  178.  
  179.    ClrScr;
  180.  
  181.    WRITELN('Test of busy program in this partition.');
  182.    WRITELN('This program will loop here waiting until a key is struck.');
  183.    WRITELN('Time is NOT donated to the other partitions.');
  184.    WRITELN('After this starts, switch to another partition and use a program');
  185.    WRITELN('like CPU.COM to see the effective CPU speed for that partition.');
  186.  
  187.    WRITE  ('Hit a key to stop test: ');
  188.  
  189.    WHILE( NOT KeyPressed ) DO;
  190.  
  191.    Flush_Keyboard;
  192.  
  193.    WRITE('Key pressed, test ends.');
  194.    WRITELN;
  195.    WRITELN;
  196.  
  197.    WRITELN('Test of busy program in this partition, but now');
  198.    WRITELN('time IS donated to the other partitions.');
  199.    WRITELN('This program will loop here waiting until a key is struck.');
  200.    WRITELN('After this starts, switch to another partition and use a program');
  201.    WRITELN('like CPU.COM to see the effective CPU speed for that partition.');
  202.    WRITELN('You should see a notable increase in the effective CPU speed');
  203.    WRITELN('over the last test.');
  204.    WRITELN;
  205.    WRITE  ('Hit a key to stop test: ');
  206.  
  207.    WHILE( NOT KeyPressed ) DO
  208.       GiveAwayTime( 2 );
  209.  
  210.    Flush_Keyboard;
  211.  
  212.    WRITE('Key pressed, test ends.');
  213.  
  214. END   (* Try_GiveAway *);
  215.  
  216. (*----------------------------------------------------------------------*)
  217.  
  218. BEGIN (* TryMDos *)
  219.                                    (* Initialize *)
  220.    Initialize;
  221.                                    (* Try writing to virtual buffer *)
  222.    Try_Screen_Writes;
  223.                                    (* Try giving up idle time while *)
  224.                                    (* waiting for keyboard input    *)
  225.    IF TimeSharingActive THEN
  226.       Try_GiveAway
  227.    ELSE
  228.       BEGIN
  229.          ClrScr;
  230.          WRITELN('Test of giving up time not performed since');
  231.          WRITELN('multitasker not active.');
  232.       END;
  233.  
  234.    WRITELN;
  235.    WRITELN;
  236.    WRITELN('End of multitasker demonstration.');
  237.  
  238. END   (* TryMDos *).