home *** CD-ROM | disk | FTP | other *** search
- unit
- eco_os2; { desqview, os/2, & 386 v86 machine interfaces }
-
-
- interface
-
-
- const
- in_dv : boolean = false; { are we in desqview? }
- in_vm : boolean = false; { are we in a 386+ virtual machine? }
- in_os2 : boolean = false; { are we in os/2? }
-
-
- function os2_getversion: word; { get os/2 version # }
- function dv_getversion: word; { update in_dv and get version # }
- function dv_get_video_buffer(vseg:word): word; { get the alt video buffer }
- procedure dv_pause; { give up time slice }
- procedure mt_pause; inline($cd/$28); { give up time in most multitaskers }
- procedure killtime; { release time in any situation }
- procedure dv_begin_critical; { don't slice away }
- procedure dv_end_critical; { allow slicing again }
- procedure dv_sound(freq,dur:integer); { create a sound in the bkg }
-
-
-
-
- implementation
-
-
-
-
-
- function os2_getversion: word; assembler; { *untested!!!* (under os/2) }
- asm
- mov ah, 30h { dos get version call }
- int 21h { al = major version * 10, ah = minor version }
- mov bh, ah { save minor version }
- xor ah, ah
- mov cl, 10
- div cl { divide major version by 10 }
- mov ah, bh { restore minor version }
- xchg ah, al { ah = major, al = minor }
- end;
-
-
-
- function dv_getversion: word; assembler;
- asm
- mov cx,'DE' { cx+dx to 'DESQ' (invalid date) }
- mov dx,'SQ'
- mov ax,02b01h { dos' set date funct. }
- int 21h { call dos }
- cmp al,0ffh { was it invalid? }
- je @no_dv { yep, no dv }
- mov ax,bx { ah=major al=minor }
- mov in_dv,1 { set in_dv flag }
- jmp @dvgv_x { other routines }
- @no_dv:
- xor ax,ax { return 0 or no dv }
- @dvgv_x:
- end; { dv_getversion }
-
-
-
- function dv_get_video_buffer(vseg:word): word; assembler;
- asm { modified by scott samet april 1992 }
- call dv_getversion { returns ax=0 if not in dv }
- mov es,vseg { put current segment into es }
- test ax,ax { in dv? }
- jz @dvgvb_x { jump if not }
- mov ah,0feh { dv's get video buffer function }
- int 10h { returns es:di of alt buffer }
- @dvgvb_x:
- mov ax,es { return video buffer }
- end; { dv_get_video_buffer }
-
-
-
- procedure dv_pause;
- begin
- if in_dv then asm
- mov ax, 1000h { pause function }
- int 15h
- end;
- end; { dv_pause }
-
-
-
- procedure killtime;
- begin
- if in_vm then asm
- mov ax, 1680h { give up vm time slice }
- int 2fh
- end else if in_dv then asm
- mov ax, 1000h { dv pause call }
- int 15h
- end else mt_pause; { dos idle call }
- end;
-
-
-
- procedure dv_begin_critical; assembler;
- asm
- mov ax,$101b { dv critical function }
- int 15h
- end; { dv_begin_critical }
-
-
-
- procedure dv_end_critical; assembler;
- asm
- mov ax,$101c { dv end critical }
- int 15h
- end; { dv_end_critical }
-
-
-
- procedure dv_sound(freq,dur:integer); assembler; { sound a tone }
- asm
- mov ax,1019h
- mov bx,freq { frequency above 20 hz }
- mov cx,dur { duration in clock ticks }
- int 15h
- end;
-
-
-
- { ** -- initalization -- ** }
-
- begin
- dv_getversion; { discard answer. just update in_dv }
- asm
- mov ax, 1680h
- int 2fh { gives up time slice in most 386+ virtual machines }
- not al { al = 00h if supported, remains 80h if not }
- mov cl, 7
- shr al, cl
- mov in_vm, al { update the flag }
- end;
- in_os2 := (os2_getversion >= $0100); { version 1.0 or greater }
- end.
-
-
- in_vm should always be true when in_os2 is true (afterall, os/2 runs dos in a
- vm). this unit will give up time slices to desqview, windows, and os/2, in
- addition to any other multitaskers which also monitor general int 28h calls.
-
-