💾 Archived View for mirrors.apple2.org.za › active › ftp.apple.asimov.net › images › gs › hardware ›… captured on 2024-07-09 at 08:38:42.

View Raw

More Information

-=-=-=-=-=-=-


  application,


Program JMinstall;

USES	Types,
		GSOS,
		TMLUtils,
		Locator,
		Memory,
		MiscTool;

VAR
	gMyMemoryID,
	gNewMemoryID		: integer;
	gStartStopRef		: ref;
	gDriverHndl			: Handle;
	F						: Str255;
	i						: integer;
	DriverFileName		: GSString255;
	parmsInfo				: FileInfoRecGS;
	parmsOpen			: OpenRecGS;
	parmsEOF				: EOFRecGS;
	parmsRead			: IORecGS;
	parmsClose			: RefNumRecGS;
	fake					: integer;
	location				: integer;

BEGIN
	gMyMemoryID := MMStartup;
	MTStartUp;

	F := '*:SYSTEM:DRIVERS:JOYMOUSE';
	DriverFileName.length := length(F);
	for i := 1 to length(F) do
		DriverFileName.text[i] := F[i];

	parmsInfo.pCount := 4;
	parmsInfo.pathname := @DriverFileName;
	GetFileInfoGS(parmsInfo);
	if (BAND(parmsInfo.auxType,$8000) = $8000) or (_ToolErr <> noError) 
    then Exit;
	{this checks to see if driver has been "inactivated" by the finder's
     Get Info}
	
	parmsOpen.pCount := 2;
	parmsOpen.pathname := @DriverFileName;
	OpenGS(parmsOpen);
	if _ToolErr <> noError then Exit;

	parmsEOF.pCount := 2;
	parmsEOF.refNum := parmsOpen.refNum;
	GetEOFGS(parmsEOF);
	if _ToolErr <> noError then begin
		parmsClose.pcount := 1;
		parmsClose.refNum := parmsOpen.refNum;
		CloseGS(parmsClose);
		Exit
	end;
	
	gNewMemoryID := GetNewID($dd00);
	gDriverHndl := NewHandle(parmsEOF.eof,gNewMemoryID,attrFixed+attrNoCross+
			attrLocked+attrNoSpec+attrNoPurge,nil);
	if _ToolErr <> noError then begin
		parmsClose.pcount := 1;
		parmsClose.refNum := parmsOpen.refNum;
		CloseGS(parmsClose);
		Exit
	end;
	
	parmsRead.pcount := 4;
	parmsRead.refNum := parmsOpen.refNum;
	parmsRead.dataBuffer := gDriverHndl^;
	parmsRead.requestCount := parmsEOF.eof;
	ReadGS(parmsRead);
	if _ToolErr <> noError then begin
		HUnlock(gDriverHndl);
		DisposeHandle(gDriverHndl);
		parmsClose.pcount := 1;
		parmsClose.refNum := parmsOpen.refNum;
		CloseGS(parmsClose);
		Exit
	end;

	parmsClose.pcount := 1;
	parmsClose.refNum := parmsOpen.refNum;
	CloseGS(parmsClose);

	SetHeartBeat(gDriverHndl^);
	if _ToolErr <> noError then Exit;

	MTShutDown;
	MMShutDown(gMyMemoryID)
END.