Browse Source

Partial port from VTI to TiEmu.
WARNING: DOES NOT COMPILE!


git-svn-id: file:///var/svn/tigccpp/trunk/tigcc/ide@894 9552661e-59e3-4036-b4f2-dbe53926924f

kevinkofler 17 years ago
parent
commit
85be453ce5
4 changed files with 41 additions and 37 deletions
  1. 29 22
      MainUnit.pas
  2. 1 1
      MasterUnit.pas
  3. 2 2
      VTIStartUnit.dfm
  4. 9 12
      VTIStartUnit.pas

+ 29 - 22
MainUnit.pas

@@ -28,7 +28,8 @@ uses
 	MasterUnit, SourceFileUnit, FolderUnit, ToolsListUnit, LinkDLLUnit,
 	Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 	Menus, StdCtrls, ExtCtrls, ImgList, ComCtrls, Buttons, ActnList, ToolWin,
-	Printers, SourceEditUnit, HTMLHelpUnit, MemoComponentUnit, ScktComp;
+	Printers, SourceEditUnit, HTMLHelpUnit, MemoComponentUnit, ScktComp,
+	ComObj, ActiveX, TiEmuOLELib_TLB;
 
 type
   TPanel = class(ExtCtrls.TPanel)
@@ -466,7 +467,7 @@ type
 		procedure SortFiles;
 		procedure DisplayFolderMessage;
 		procedure ClearDebugInfo;
-		function GetVTIWindow: HWnd;
+		function GetTiEmuInterface: ITiEmuOLE;
 		procedure SendFiles(FNList: array of string);
 		procedure ExecuteCommandLine(const Line: string);
 		procedure SelectNode(Node: TTreeNode);
@@ -3019,8 +3020,8 @@ begin
 			end;
 			if ValueExists ('Transfer Target') then
 				TransferTarget := TTransferTarget (ReadInteger ('Transfer Target') + 1);
-			if ValueExists ('VTI Path') then
-				VTIPath := ReadString ('VTI Path');
+			if ValueExists ('TiEmu Path') then
+				VTIPath := ReadString ('TiEmu Path');
 			if ValueExists ('Link Port') then
 				LinkPort.PortNumber := ReadInteger ('Link Port') and $FF;
 			if ValueExists ('Link Cable') then begin
@@ -3189,7 +3190,7 @@ begin
 			WriteBool ('Flat Buttons', MainToolbar.Flat);
 			WriteBool ('Menu Bitmaps', Assigned (MainMenu.Images));
 			WriteInteger ('Transfer Target', Integer (TransferTarget) - 1);
-			WriteString ('VTI Path', VTIPath);
+			WriteString ('TiEmu Path', VTIPath);
 			WriteInteger ('Link Port', LinkPort.PortNumber);
 			case LinkCable of
 				lcBlack: WriteInteger ('Link Cable', 1);
@@ -4681,33 +4682,39 @@ begin
 	end;
 end;
 
-function TMainForm.GetVTIWindow: HWnd;
+function TMainForm.GetTiEmuInterface: ITiEmuOLE;
+var
+	ExitCode: Cardinal;
+	Unknown: IUnknown;
+	OLEResult: HResult;
 begin
-	CurVTIType := cvNone;
-	Result := FindWindow ('TEmuWnd', 'Virtual TI-89');
-	if Result = 0 then begin
-		Result := FindWindow ('TEmuWnd', 'Virtual TI-92+');
-		if Result = 0 then begin
-			Result := FindWindow ('TEmuWnd', 'Virtual TI-92');
-			if Result <> 0 then
-				CurVTIType := cvTI92;
-		end else
-			CurVTIType := cvTI92Plus;
-	end else
-		CurVTIType := cvTI89;
-	if Result = 0 then begin
+	OLEResult := GetActiveObject(CLASS_TiEmuOLE, nil, Unknown);
+	if OLEResult = S_OK then begin
+		OleCheck(Unknown.QueryInterface(ITiEmuOLE, Result));
+	end else begin
+		{ If no TiEmu path is set, try looking it up from the registry. }
+		if Length (VTIPath) = 0 then begin
+			with TRegistry.Create do try
+				RootKey := HKey_Classes_Root;
+				if OpenKeyReadOnly ('\CLSID\{B2A17B13-9D6F-4DD4-A2A9-6FE06ADC1D33}\LocalServer32') then try
+					if ValueExists (nil) then
+						VTIPath := ReadString (nil);
+				except end;
+			finally
+				Free;
+			end;
+		end;
 		if Length (VTIPath) > 0 then begin
 			with TVTIStartForm.Create (Self) do try
 				if ShowModal = mrOK then begin
-					Result := VTIWindow;
-					CurVTIType := VTIType;
+					Result := TiEmuInterface;
 				end else
 					Abort;
 			finally
 				Free;
 			end;
 		end else begin
-			ShowDefaultMessageBox ('Virtual TI is not running.', 'Error', mtProgramError);
+			ShowDefaultMessageBox ('TiEmu is not running.', 'Error', mtProgramError);
 			Abort;
 		end;
 	end;

+ 1 - 1
MasterUnit.pas

@@ -62,7 +62,7 @@ type
 	TSpecialSupport = set of TSpecialSupportOption;
 	TProjectTarget = (ptRegular, ptFlashOS, ptFargo, ptArchive);
 	TTransferTarget = (ttNone, ttVTI, ttCalc);
-	TCurVTIType = (cvNone, cvTI89, cvTI92Plus, cvTI92);
+	TCurVTIType = (cvNone = 0, cvTI92 = 1, cvTI89 = 2, cvTI92Plus = 4, cvV200 = 8, cvTI89Ti = 16);
 	TKernelFormat = (kfUnknown, kfNone, kfStandard, kfCompressedTables);
 	TRelocFormat = (rfUnknown, rfNone, rfDirect, rfAMS, rfKernel, rfCompressed, rfMlink, rfFLine);
 

+ 2 - 2
VTIStartUnit.dfm

@@ -4,7 +4,7 @@ object VTIStartForm: TVTIStartForm
   ActiveControl = CancelButton
   BorderIcons = [biSystemMenu]
   BorderStyle = bsDialog
-  Caption = 'Starting Virtual TI...'
+  Caption = 'Starting TiEmu...'
   ClientHeight = 86
   ClientWidth = 241
   Color = clBtnFace
@@ -26,7 +26,7 @@ object VTIStartForm: TVTIStartForm
     Height = 13
     Alignment = taCenter
     AutoSize = False
-    Caption = 'Please wait while Virtual TI is being started...'
+    Caption = 'Please wait while TiEmu is being started...'
   end
   object CancelButton: TButton
     Left = 80

+ 9 - 12
VTIStartUnit.pas

@@ -25,7 +25,7 @@ interface
 uses
 	MasterUnit,
 	Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
-	StdCtrls, ExtCtrls;
+	StdCtrls, ExtCtrls, ComObj, ActiveX, TiEmuOLELib_TLB;
 
 type
 	TVTIStartForm = class(TForm)
@@ -38,8 +38,7 @@ type
 	private
 		ProcessHandle: THandle;
 	public
-		VTIWindow: HWnd;
-		VTIType: TCurVTIType;
+		TiEmuInterface: ITiEmuOLE;
 	end;
 
 implementation
@@ -60,7 +59,7 @@ begin
 		ProcessHandle := ProcessInfo.hProcess;
 		CloseHandle (ProcessInfo.hThread);
 	end else begin
-		ShowDefaultMessageBox ('An error occurred while trying to start Virtual TI.', 'Error', mtProgramError);
+		ShowDefaultMessageBox ('An error occurred while trying to start TiEmu.', 'Error', mtProgramError);
 		ModalResult := mrAbort;
 	end;
 end;
@@ -75,6 +74,8 @@ end;
 procedure TVTIStartForm.FindTimerTimer(Sender: TObject);
 var
 	ExitCode: Cardinal;
+	Unknown: IUnknown;
+	OLEResult: HResult;
 begin
 	if GetExitCodeProcess (ProcessHandle, ExitCode) then begin
 		if ExitCode <> STILL_ACTIVE then begin
@@ -82,15 +83,11 @@ begin
 			Exit;
 		end;
 	end;
-	VTIWindow := FindWindow ('TEmuWnd', 'Virtual TI-89');
-	if VTIWindow = 0 then begin
-		VTIWindow := FindWindow ('TEmuWnd', 'Virtual TI-92+');
-		if VTIWindow <> 0 then
-			VTIType := cvTI92Plus;
-	end else
-		VTIType := cvTI89;
-	if VTIWindow <> 0 then
+	OLEResult := GetActiveObject(CLASS_TiEmuOLE, nil, Unknown);
+	if OLEResult = S_OK then begin
+		OleCheck(Unknown.QueryInterface(ITiEmuOLE, TiEmuInterface));
 		ModalResult := mrOK;
+	end;
 end;
 
 end.