* merged windows mode saving stuff from fixes branch

This commit is contained in:
Jonas Maebe 2001-09-10 16:15:52 +00:00
parent fca264a025
commit 19913b716c
2 changed files with 69 additions and 9 deletions

View File

@ -139,6 +139,7 @@ const
var var
ScrWidth : word absolute $40:$4a; ScrWidth : word absolute $40:$4a;
inWindows: boolean;
{$ifndef tp} {$ifndef tp}
procedure seg_bytemove(sseg : word;source : longint;dseg : word;dest : longint;count : longint); procedure seg_bytemove(sseg : word;source : longint;dseg : word;dest : longint;count : longint);
@ -1569,9 +1570,18 @@ const CrtAddress: word = 0;
{ Get the video mode } { Get the video mode }
asm asm
mov ah,0fh mov ah,0fh
{$ifdef fpc}
push ebp
{$endif fpc}
int 10h int 10h
{$ifdef fpc}
pop ebp
{$endif fpc}
mov [VideoMode], al mov [VideoMode], al
end; end;
{ saving/restoring video state screws up Windows (JM) }
if inWindows then
exit;
{ Prepare to save video state...} { Prepare to save video state...}
asm asm
mov ax, 1C00h { get buffer size to save state } mov ax, 1C00h { get buffer size to save state }
@ -1660,6 +1670,7 @@ const CrtAddress: word = 0;
regs.es := RealStateSeg; regs.es := RealStateSeg;
regs.ebx := 0; regs.ebx := 0;
RealIntr($10,regs); RealIntr($10,regs);
(*
{$ifndef fpc} {$ifndef fpc}
if GlobalDosFree(longint(SavePtr) shr 16)<>0 then if GlobalDosFree(longint(SavePtr) shr 16)<>0 then
{$else fpc} {$else fpc}
@ -1668,6 +1679,7 @@ const CrtAddress: word = 0;
RunError(216); RunError(216);
SavePtr := nil; SavePtr := nil;
*)
end; end;
end; end;
@ -1743,7 +1755,8 @@ const CrtAddress: word = 0;
mov bx, WORD PTR [SavePtr] mov bx, WORD PTR [SavePtr]
int 10h int 10h
end; end;
FreeMem(SavePtr, 64*StateSize); { done in exitproc (JM)
FreeMem(SavePtr, 64*StateSize);}
SavePtr := nil; SavePtr := nil;
end; end;
end; end;
@ -1855,14 +1868,8 @@ const CrtAddress: word = 0;
_graphresult := grnoinitgraph; _graphresult := grnoinitgraph;
exit exit
end; end;
{$ifdef logging}
LogLn('calling RestoreVideoState at '+strf(longint(RestoreVideoState)));
{$endif logging}
if not assigned(RestoreVideoState) then if not assigned(RestoreVideoState) then
RunError(216); RunError(216);
{$ifdef logging}
LogLn('actual call of RestoreVideoState');
{$endif logging}
RestoreVideoState; RestoreVideoState;
isgraphmode := false; isgraphmode := false;
end; end;
@ -2652,12 +2659,59 @@ const CrtAddress: word = 0;
end; end;
end; end;
var
go32exitsave: pointer;
procedure freeSaveStateBuffer; {$ifndef fpc}far; {$endif}
begin begin
if savePtr <> nil then
begin
{$ifdef dpmi}
{$ifndef fpc}
if GlobalDosFree(longint(SavePtr) shr 16)<>0 then;
{$else fpc}
if Not Global_Dos_Free(longint(SavePtr) shr 16) then;
{$endif fpc}
{$else dpmi}
FreeMem(SavePtr, 64*StateSize);
{$endif dpmi}
SavePtr := nil;
end;
exitproc := go32exitsave;
end;
begin
{ must be done *before* initialize graph is called, because the save }
{ buffer can be used in the normal exit_proc (which is hooked in }
{ initializegraph and as such executed first) (JM) }
go32exitsave := exitproc;
exitproc := @freeSaveStateBuffer;
{ windows screws up the display if the savestate/restore state }
{ stuff is used (or uses an abnormal amount of cpu time after }
{ such a problem has exited), so detect its presense and do not }
{ use those functions if it's running. I'm really tired of }
{ working around Windows bugs :( (JM) }
asm
mov ax,$160a
{$ifdef fpc}
push ebp
{$endif fpc}
int $2f
{$ifdef fpc}
pop ebp
{$endif fpc}
test ax,ax
sete al
mov inWindows,al
end;
InitializeGraph; InitializeGraph;
end. end.
{ {
$Log$ $Log$
Revision 1.7 2001-06-06 17:20:22 jonas Revision 1.8 2001-09-10 16:15:52 jonas
* merged windows mode saving stuff from fixes branch
Revision 1.7 2001/06/06 17:20:22 jonas
* fixed wrong typed constant procvars in preparation of my fix which will * fixed wrong typed constant procvars in preparation of my fix which will
disallow them in FPC mode (plus some other unmerged changes since disallow them in FPC mode (plus some other unmerged changes since
LAST_MERGE) LAST_MERGE)

View File

@ -2473,6 +2473,9 @@ Const
{$endif fpc} {$endif fpc}
mov [VideoMode], al mov [VideoMode], al
end; end;
{ saving/restoring video state screws up Windows (JM) }
if inWindows then
exit;
{$ifdef logging} {$ifdef logging}
LogLn('Prepare to save VESA video state'); LogLn('Prepare to save VESA video state');
{$endif logging} {$endif logging}
@ -2715,7 +2718,10 @@ Const
{ {
$Log$ $Log$
Revision 1.6 2000-12-16 15:57:17 jonas Revision 1.7 2001-09-10 16:15:52 jonas
* merged windows mode saving stuff from fixes branch
Revision 1.6 2000/12/16 15:57:17 jonas
* removed 64bit evaluations when range checking is on * removed 64bit evaluations when range checking is on
Revision 1.5 2000/08/12 12:27:13 jonas Revision 1.5 2000/08/12 12:27:13 jonas