Source file: /~heha/messtech/motor.zip/VXDSRC/MPK3D.PAS

unit mpk3d;
{Unit zur Unterstützung des MPK3D.386 VxDs von Pascal aus}
{12/96: Unterstützung des dynamischen Geräte-Ladens und -Entladens}
{12/96: Umbenennung des Eintrittspunktes EntryPoint-->MPK3D_Entry}

interface

var
 MPK3D_Entry: Pointer;

{Universelle VxD-Aufrufroutinen}
function VxDsupC(AFunc, AUnit:Byte; lParam1,lParam2:LongInt):Byte;
function VxDsupV(AFunc, AUnit:Byte; var lParam1,lParam2:LongInt):Byte;

const
{Folgende Kommandos gibt es:}
 SM_Nop		=0;	{"NOP"-Kommando}
 SM_Free	=1;	{Motorspulen stromfrei schalten}
 SM_Sync	=2;	{Referenzfahrt}
 SM_MoveAbs	=3;	{Absolutbewegung}
 SM_MoveRel	=4;	{Relativbewegung}
 SM_Assign	=5;	{Belegung}
 SM_UnAssign	=6;	{Freigabe}
 SM_SetSA	=7;	{Geschwindigkeit und Beschleunigung festlegen}
 SM_GetSA	=8;	{...erfragen}
 SM_SetPostMsg	=9;	{PostMessage-Adresse + Fenster + Nachricht festlegen}
 SM_GetPostMsg	=10;	{...erfragen}
 SM_GetPosition	=11;	{Momentane Position ermitteln (nach EDX und Speed=ECX)}
 SM_SetBounds	=12;
 SM_GetBounds	=13;
 SM_Stop	=14;
 SM_SetGear	=15;	{Übersetzungsverhältnis setzen}
 SM_GetGear	=16;	{Übersetzungsverhältnis erfragen}
 SM_SetHWE	=17;	{Hardware-Endschalter-Maske setzen}
{Fehlercodes von Isel}
 ME_NoError	=0;
 ME_WrongFunction=1;
 ME_InMove	=4;
 ME_SoftEnd	=5;
 ME_HardEnd	=7;
 ME_NoRef	=9;
{Eigene Fehlercodes}
 ME_NothingAssigned=50;
 ME_AlreadyAssigned=51;
 ME_NoDriver	=52;
{Ungültige Position}
 InvPos		=$80000000;

implementation

const
 MPK3D_Device_ID=$378C;	{VxD-ID, von Microsoft zugewiesen}

function VxDsupC(AFunc,AUnit:Byte; lParam1,lParam2:LongInt):Byte; assembler;
 asm
  mov al,ME_NoDriver
  db $66; cmp word ptr [MPK3D_Entry],0
  jz @@1
  mov al,[AUnit]
  mov ah,[AFunc]
  db $66; mov dx,word ptr [lParam1]
  db $66; mov cx,word ptr [lParam2]
  call [MPK3D_Entry]
@@1:
 end;

function VxDsupV(AFunc,AUnit:Byte; var lParam1,lParam2:LongInt):Byte; assembler;
 asm
  les bx,[lParam1]
  db $66; mov dx,es:[bx]
  les bx,[lParam2]
  db $66; mov cx,es:[bx]
  mov al,ME_NoDriver
  db $66; cmp word ptr [MPK3D_Entry],0	{Einsprungpunkt vorhanden?}
  jz @@1				{nein - Kurve kratzen!}
  mov al,[AUnit]
  mov ah,[AFunc]
  call [MPK3D_Entry]
@@1:
  les bx,[lParam1]
  db $66; mov es:[bx],dx
  les bx,[lParam2]
  db $66; mov es:[bx],cx
 end;

const
 VxDName:array[0..9]of Char='MPK3D.386'#0;
var
 VXDLDR_Entry:Pointer;
 OldExit:Pointer;

{Deinstallation}
procedure NewExit; far; assembler;
 asm
	db	$66
	mov	ax,word ptr [OldExit]
	db	$66
	mov	word ptr [ExitProc],ax
	mov	ax,$0002	{Unload_VxD}
	mov	bx,MPK3D_Device_ID
	call	[VXDLDR_Entry]
 end;

function Get_MPK3D_Entry:Word; assembler;
 asm	xor	di,di
	mov	es,di
	mov	bx,MPK3D_Device_ID
	mov	ax,$1684	{Get Device API Entry Point}
	int	$2F
	mov	ax,es
	mov	word ptr [MPK3D_Entry],di
	mov	word ptr [MPK3D_Entry+2],ax
 end;

{Initialisierung}
begin
 asm	call	Get_MPK3D_Entry
	or	ax,ax		{<>0?}
	jnz	@@e		{ja, statisch geladen!}
	mov	bx,$0027	{VXDLDR-Device-ID}
	mov	ax,$1684
	int	$2F
	mov	ax,es
	or	ax,ax		{<>0?}
	jz	@@e		{nein, wohl kein Windows95?}
	mov	word ptr [VXDLDR_Entry],di
	mov	word ptr [VXDLDR_Entry+2],ax
	mov	dx,offset VxDName
	mov	ax,$0001	{Load_VxD}
	call	[VXDLDR_Entry]
	jc	@@e		{Fehler!}
	push	cs
	push	offset NewExit
	db	$66
	pop	ax
	db	$66
	xchg	word ptr [ExitProc],ax
	db	$66
	mov	word ptr [OldExit],ax
	call	Get_MPK3D_Entry	{Zweiter Versuch}
@@e: end;
end.
Detected encoding: OEM (CP437)1
Wrong umlauts? - Assume file is ANSI (CP1252) encoded