* Fixes from Gabor (merged)

This commit is contained in:
peter 2000-08-16 18:51:57 +00:00
parent e1a81165ac
commit 03b63234e4
2 changed files with 105 additions and 5 deletions

View File

@ -12,6 +12,7 @@ var
RealOfs : Word; { Real mode offset }
CurrentMask : word;
MouseCallback : Pointer; { Mouse call back ptr }
UnderNT: boolean;
{$ifdef DEBUG}
EntryEDI,EntryESI : longint;
EntryDS,EntryES : word;
@ -188,6 +189,57 @@ ASM
IRET; { Interrupt return }
END;
PROCEDURE Mouse_Trap_NT; ASSEMBLER;
ASM
PUSH %ES; { Save ES register }
PUSH %DS; { Save DS register }
PUSHL %EDI; { Save register }
PUSHL %ESI; { Save register }
{ ; caution : ds is not the selector for our data !! }
{$ifdef DEBUG}
MOVL %EDI,%ES:EntryEDI
MOVL %ESI,%ES:EntryESI
MOVW %DS,%AX
MOVW %AX,%ES:EntryDS
MOVW %ES,%AX
MOVW %AX,%ES:EntryES
{$endif DEBUG}
{ movw %cs:v2prt0_ds_alias,%ax v2prt0 is not locked !!
movw %ax,%ds
movw %ax,%es }
PUSH %ES; { Push data seg }
POP %DS; { Load data seg }
{$ifdef DEBUG}
incl callcounter
CMPL $ACTIONREGS,%edi
JE .L_ActionRegsOK
INCL MouseError
JMP .L_NoCallBack
.L_ActionRegsOK:
{$endif DEBUG}
MOVL MOUSECALLBACK, %EAX; { Fetch callback addr }
CMPL $0, %EAX; { Check for nil ptr }
JZ .L_NoCallBack; { Ignore if nil }
MOVL %EDI,%EAX; { %EAX = @actionregs }
MOVL (%EAX), %EDI; { EDI from actionregs }
MOVL 4(%EAX), %ESI; { ESI from actionregs }
MOVL 16(%EAX), %EBX; { EBX from actionregs }
MOVL 20(%EAX), %EDX; { EDX from actionregs }
MOVL 24(%EAX), %ECX; { ECX from actionregs }
MOVL 28(%EAX), %EAX; { EAX from actionregs }
CALL *MOUSECALLBACK; { Call callback proc }
.L_NoCallBack:
POPL %ESI; { Recover register }
POPL %EDI; { Recover register }
POP %DS; { Restore DS register }
POP %ES; { Restore ES register }
movzwl %si,%eax
MOVL %ds:(%Eax), %EAX;
MOVL %EAX, %ES:42(%EDI); { Set as return addr }
ADDW $4, %ES:46(%EDI); { adjust stack }
IRET; { Interrupt return }
END;
Function Allocate_mouse_bridge : boolean;
var
error : word;
@ -195,6 +247,10 @@ begin
ASM
LEAL ACTIONREGS, %EDI; { Addr of actionregs }
LEAL MOUSE_TRAP, %ESI; { Procedure address }
CMPB $0, UnderNT
JZ .LGo32
LEAL MOUSE_TRAP_NT, %ESI; { Procedure address }
.LGo32:
PUSH %DS; { Save DS segment }
PUSH %ES; { Save ES segment }
MOVW v2prt0_ds_alias,%ES; { ES now has dataseg alias that is never invalid }
@ -305,6 +361,7 @@ begin
exit;
FirstMouseInitDone:=false;
Unlock_Code(Pointer(@Mouse_Trap), 400); { Release trap code }
Unlock_Code(Pointer(@Mouse_Trap_NT), 400); { Release trap code }
Unlock_Code(Pointer(@MouseInt), 400); { Lock MouseInt code }
Unlock_Data(ActionRegs, SizeOf(TRealRegs)); { Release registers }
UnLock_Data(MouseCallBack,SizeOf(Pointer));
@ -335,9 +392,18 @@ begin
Release_mouse_bridge;
end;
function RunningUnderWINNT: boolean;
var r: trealregs;
begin
fillchar(r,sizeof(r),0);
r.ax:=$3306;
realintr($21,r);
RunningUnderWINNT:=(r.bx=$3205);
end;
procedure InitMouse;
begin
UnderNT:=RunningUnderWINNT;
if not MousePresent then
begin
if DetectMouse=0 then
@ -360,6 +426,7 @@ begin
StoredExit:=ExitProc;
ExitProc:=@MouseSafeExit;
Lock_Code(Pointer(@Mouse_Trap), 400); { Lock trap code }
Lock_Code(Pointer(@Mouse_Trap_NT), 400); { Lock trap code }
Lock_Code(Pointer(@MouseInt), 400); { Lock MouseInt code }
Lock_Data(ActionRegs, SizeOf(TRealRegs)); { Lock registers }
Lock_Data(MouseCallBack, SizeOf(pointer));
@ -642,7 +709,10 @@ end;
{
$Log$
Revision 1.2 2000-07-13 11:32:24 michael
Revision 1.3 2000-08-16 18:51:57 peter
* Fixes from Gabor (merged)
Revision 1.2 2000/07/13 11:32:24 michael
+ removed logs
}

View File

@ -29,6 +29,33 @@ begin
realintr($10,regs);
end;
function BIOSGetScreenMode(var Cols,Rows: word; var Color: boolean): boolean;
var r: trealregs;
L: longint;
LSel,LSeg: word;
B: array[0..63] of byte;
type TWord = word; PWord = ^TWord;
var Size: word;
OK: boolean;
begin
L:=global_dos_alloc(64);
LSeg:=(L shr 16);
LSel:=(L and $ffff);
r.ah:=$1b; r.bx:=0;
r.es:=LSeg; r.di:=0;
realintr($10,r);
OK:=(r.al=$1b);
if OK then
begin
dpmi_dosmemget(LSeg,0,B,64);
Cols:=PWord(@B[5])^; Rows:=B[$22];
Color:=PWord(@B[$27])^<>0;
end;
global_dos_free(LSel);
BIOSGetScreenMode:=OK;
end;
procedure InitVideo;
var
regs : trealregs;
@ -54,6 +81,7 @@ begin
regs.bx:=0;
realintr($10,regs);
ScreenHeight:=regs.dl+1;
BIOSGetScreenMode(ScreenWidth,ScreenHeight,ScreenColor);
end;
regs.ah:=$03;
regs.bh:=0;
@ -75,7 +103,6 @@ begin
SetCursorType(LastCursorType);
{ ClearScreen; removed here
to be able to catch the content of the monitor }
end;
@ -266,7 +293,10 @@ end;
{
$Log$
Revision 1.2 2000-07-13 11:32:24 michael
Revision 1.3 2000-08-16 18:51:57 peter
* Fixes from Gabor (merged)
Revision 1.2 2000/07/13 11:32:24 michael
+ removed logs
}