home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ECO30603.ZIP / ECO30603.LZH / ECOLIBII / ECO_OS2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-09-14  |  3.9 KB  |  148 lines

  1. unit
  2.   eco_os2;  { desqview, os/2, & 386 v86 machine interfaces }
  3.  
  4.  
  5. interface
  6.  
  7.  
  8. const
  9.   in_dv  : boolean = false; { are we in desqview? }
  10.   in_vm  : boolean = false; { are we in a 386+ virtual machine? }
  11.   in_os2 : boolean = false; { are we in os/2? }
  12.  
  13.  
  14.   function  os2_getversion: word; { get os/2 version # }
  15.   function  dv_getversion: word; { update in_dv and get version # }
  16.   function  dv_get_video_buffer(vseg:word): word; { get the alt video buffer }
  17.   procedure dv_pause; { give up time slice }
  18.   procedure mt_pause; inline($cd/$28); { give up time in most multitaskers }
  19.   procedure killtime; { release time in any situation }
  20.   procedure dv_begin_critical; { don't slice away }
  21.   procedure dv_end_critical; { allow slicing again }
  22.   procedure dv_sound(freq,dur:integer); { create a sound in the bkg }
  23.  
  24.  
  25.  
  26.  
  27. implementation
  28.  
  29.  
  30.  
  31.  
  32.  
  33.   function os2_getversion: word; assembler; { *untested!!!* (under os/2) }
  34.   asm
  35.     mov    ah, 30h  { dos get version call }
  36.     int    21h      { al = major version * 10, ah = minor version }
  37.     mov    bh, ah   { save minor version }
  38.     xor    ah, ah
  39.     mov    cl, 10
  40.     div    cl       { divide major version by 10 }
  41.     mov    ah, bh   { restore minor version }
  42.     xchg   ah, al   { ah = major, al = minor }
  43.   end;
  44.  
  45.  
  46.  
  47.   function dv_getversion: word; assembler;
  48.   asm
  49.     mov    cx,'DE'     { cx+dx to 'DESQ' (invalid date) }
  50.     mov    dx,'SQ'
  51.     mov    ax,02b01h   { dos' set date funct. }
  52.     int    21h         { call dos }
  53.     cmp    al,0ffh     { was it invalid? }
  54.     je     @no_dv      { yep, no dv }
  55.     mov    ax,bx       { ah=major al=minor }
  56.     mov    in_dv,1     { set in_dv flag }
  57.     jmp    @dvgv_x     { other routines }
  58.   @no_dv:
  59.     xor    ax,ax       { return 0 or no dv }
  60.   @dvgv_x:
  61.   end; { dv_getversion }
  62.   
  63.  
  64.   
  65.   function dv_get_video_buffer(vseg:word): word; assembler;
  66.   asm                      { modified by scott samet april 1992 }
  67.     call   dv_getversion   { returns ax=0 if not in dv }
  68.     mov    es,vseg         { put current segment into es }
  69.     test   ax,ax           { in dv? }
  70.     jz     @dvgvb_x        { jump if not }
  71.     mov    ah,0feh         { dv's get video buffer function }
  72.     int    10h             { returns es:di of alt buffer }
  73.   @dvgvb_x:
  74.     mov    ax,es           { return video buffer }
  75.   end; { dv_get_video_buffer }
  76.  
  77.  
  78.  
  79.   procedure dv_pause;
  80.   begin
  81.     if in_dv then asm
  82.       mov ax, 1000h    { pause function }
  83.       int 15h
  84.     end;
  85.   end; { dv_pause }
  86.   
  87.  
  88.   
  89.   procedure killtime;
  90.   begin
  91.     if in_vm then asm
  92.       mov ax, 1680h    { give up vm time slice }
  93.       int 2fh
  94.     end else if in_dv then asm
  95.       mov ax, 1000h    { dv pause call }
  96.       int 15h
  97.     end else mt_pause;      { dos idle call }
  98.   end;
  99.  
  100.  
  101.  
  102.   procedure dv_begin_critical; assembler;
  103.   asm
  104.     mov ax,$101b       { dv critical function }
  105.     int 15h
  106.   end; { dv_begin_critical }
  107.  
  108.  
  109.   
  110.   procedure dv_end_critical; assembler;
  111.   asm
  112.     mov ax,$101c       { dv end critical }
  113.     int 15h
  114.   end; { dv_end_critical }
  115.  
  116.  
  117.  
  118.   procedure dv_sound(freq,dur:integer); assembler; { sound a tone }
  119.   asm
  120.     mov   ax,1019h
  121.     mov   bx,freq  { frequency above 20 hz }
  122.     mov   cx,dur   { duration in clock ticks }
  123.     int   15h
  124.   end;
  125.  
  126.  
  127.  
  128. { ** -- initalization -- ** }
  129.  
  130. begin
  131.   dv_getversion; { discard answer.  just update in_dv }
  132.   asm
  133.     mov ax, 1680h
  134.     int 2fh          { gives up time slice in most 386+ virtual machines }
  135.     not al           { al = 00h if supported, remains 80h if not }
  136.     mov cl, 7
  137.     shr al, cl
  138.     mov in_vm, al    { update the flag }
  139.   end;
  140.   in_os2 := (os2_getversion >= $0100); { version 1.0 or greater }
  141. end.
  142.  
  143.  
  144. in_vm should always be true when in_os2 is true (afterall, os/2 runs dos in a
  145. vm).  this unit will give up time slices to desqview, windows, and os/2, in
  146. addition to any other multitaskers which also monitor general int 28h calls.
  147.  
  148.