* try to enhance graph mode

This commit is contained in:
pierre 2002-05-31 12:37:47 +00:00
parent 1fe0c05ec2
commit 0d49332896
4 changed files with 224 additions and 18 deletions

View File

@ -1329,8 +1329,10 @@ if Not TextmodeGFV then
if assigned(Video.OldVideoBuf) then if assigned(Video.OldVideoBuf) then
FreeMem(Video.OldVideoBuf); FreeMem(Video.OldVideoBuf);
GetMem(Video.OldVideoBuf,sizeof(word)*ScreenWidth*ScreenHeight); GetMem(Video.OldVideoBuf,sizeof(word)*ScreenWidth*ScreenHeight);
GetMem(GFVGraph.SpVideoBuf,sizeof(pextrainfo)*(ScreenWidth+1)*(ScreenHeight+1));
FillChar(Video.VideoBuf^,sizeof(word)*ScreenWidth*ScreenHeight,#0); FillChar(Video.VideoBuf^,sizeof(word)*ScreenWidth*ScreenHeight,#0);
FillChar(Video.OldVideoBuf^,sizeof(word)*ScreenWidth*ScreenHeight,#0); FillChar(Video.OldVideoBuf^,sizeof(word)*ScreenWidth*ScreenHeight,#0);
FillChar(GFVGraph.SpVideoBuf^,sizeof(pextrainfo)*(ScreenWidth+1)*(ScreenHeight+1),#0);
ScreenMode.color:=true; ScreenMode.color:=true;
ScreenMode.col:=ScreenWidth; ScreenMode.col:=ScreenWidth;
ScreenMode.row:=ScreenHeight; ScreenMode.row:=ScreenHeight;
@ -1380,6 +1382,7 @@ BEGIN
Video.VideoBuf:=nil; Video.VideoBuf:=nil;
FreeMem(Video.OldVideoBuf,sizeof(word)*ScreenWidth*ScreenHeight); FreeMem(Video.OldVideoBuf,sizeof(word)*ScreenWidth*ScreenHeight);
Video.OldVideoBuf:=nil; Video.OldVideoBuf:=nil;
FreeExtraInfo;
{$endif USE_VIDEO_API} {$endif USE_VIDEO_API}
CloseGraph; CloseGraph;
{$ifdef win32} {$ifdef win32}
@ -1626,7 +1629,10 @@ BEGIN
END. END.
{ {
$Log$ $Log$
Revision 1.22 2002-05-29 21:21:54 pierre Revision 1.23 2002-05-31 12:38:37 pierre
* try to enhance graph mode
Revision 1.22 2002/05/29 21:21:54 pierre
* Use VGAHi for go32v2 graph version for now * Use VGAHi for go32v2 graph version for now
Revision 1.21 2002/05/29 19:36:12 pierre Revision 1.21 2002/05/29 19:36:12 pierre

View File

@ -133,6 +133,17 @@ CONST
SolidFill = Graph.SolidFill; SolidFill = Graph.SolidFill;
LowAscii : boolean = true; LowAscii : boolean = true;
type
textrainfo = array[0..0] of byte;
pextrainfo = ^textrainfo;
TSpVideoBuf = array [0..0] of pextrainfo;
PSpVideoBuf = ^TSpVideoBuf;
const
SpVideoBuf : PSpVideoBuf = nil;
{$ELSE not GRAPH_API } {$ELSE not GRAPH_API }
CONST CONST
SolidFill = 0; SolidFill = 0;
@ -209,7 +220,11 @@ PROCEDURE Line(X1, Y1, X2, Y2: Integer);
PROCEDURE Rectangle(X1, Y1, X2, Y2: Integer); PROCEDURE Rectangle(X1, Y1, X2, Y2: Integer);
PROCEDURE OutTextXY(X,Y: Integer; TextString: String); PROCEDURE OutTextXY(X,Y: Integer; TextString: String);
{$IFDEF GRAPH_API}
procedure GraphUpdateScreen(Force: Boolean); procedure GraphUpdateScreen(Force: Boolean);
procedure SetExtraInfo(x,y,xi,yi : longint; shouldskip : boolean);
procedure FreeExtraInfo;
{$ENDIF GRAPH_API}
{***************************************************************************} {***************************************************************************}
{ INITIALIZED PUBLIC VARIABLES } { INITIALIZED PUBLIC VARIABLES }
@ -435,30 +450,88 @@ BEGIN
END; END;
PROCEDURE OutTextXY(X,Y: Integer; TextString: string); PROCEDURE OutTextXY(X,Y: Integer; TextString: string);
{$IFDEF GRAPH_API}
var
i,j,xi,yj : longint;
Ts: Graph.ViewPortType;
{$ENDIF GRAPH_API}
BEGIN BEGIN
{$IFDEF GRAPH_API} {$IFDEF GRAPH_API}
Graph.OutTextXY(X, Y, TextString); { Call graph proc } Graph.OutTextXY(X, Y, TextString); { Call graph proc }
if true then
begin
Graph.GetViewSettings(Ts);
For j:=0 to TextWidth(TextString) -1 do
For i:=0 to TextHeight(TextString)-1 do
begin
xi:=x+i+Ts.x1;
yj:=y+j+Ts.y1;
SetExtraInfo(xi div SysFontWidth,yj div SysFontHeight,
xi mod SysFontWidth,yj mod SysFontHeight, true);
end;
end;
{$ENDIF GRAPH_API} {$ENDIF GRAPH_API}
END; END;
{$IFDEF GRAPH_API}
const
SetExtraInfoCalled : boolean = false;
procedure SetExtraInfo(x,y,xi,yi : longint; shouldskip : boolean);
var
i,k,l : longint;
extrainfo : pextrainfo;
begin
i:=y*TextScreenWidth+x;
if not assigned(SpVideoBuf^[i]) then
begin
GetMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
FillChar(SpVideoBuf^[i]^,SysFontHeight*((SysFontWidth +7) div 8),#0);
end;
extrainfo:=SpVideoBuf^[i];
k:=xi mod 8;
l:=yi*((SysFontWidth +7) div 8) + xi div 8;
if l>=SysFontHeight*((SysFontWidth +7) div 8) then
RunError(219);
if shouldskip then
extrainfo^[l]:=extrainfo^[l] or (1 shl k)
else
extrainfo^[l]:=extrainfo^[l] and not (1 shl k);
SetExtraInfoCalled:=true;
end;
procedure FreeExtraInfo;
var
i : longint;
begin
if assigned(SpVideoBuf) then
begin
for i:=0 to (TextScreenWidth+1)*(TextScreenHeight+1) - 1 do
if assigned(SpVideoBuf^[i]) then
FreeMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
FreeMem(SpVideoBuf,sizeof(pextrainfo)*(TextScreenWidth+1)*(TextScreenHeight+1));
SpVideoBuf:=nil;
end;
end;
procedure GraphUpdateScreen(Force: Boolean); procedure GraphUpdateScreen(Force: Boolean);
{$IFDEF GRAPH_API}
var var
smallforce : boolean; smallforce : boolean;
i,x,y : longint; i,x,y : longint;
xi,yi,k,l : longint;
ch : char; ch : char;
attr : byte; attr : byte;
SavedColor,SavedBkColor : longint; SavedColor,SavedBkColor : longint;
CurColor,CurBkColor : longint; CurColor,CurBkColor : longint;
NextColor,NextBkColor : longint; NextColor,NextBkColor : longint;
StoreFillSettings: FillSettingsType; StoreFillSettings: FillSettingsType;
{$ENDIF GRAPH_API} Ts: Graph.ViewPortType;
begin begin
{$IFDEF GRAPH_API}
{$ifdef USE_VIDEO_API} {$ifdef USE_VIDEO_API}
if force then if force or SetExtraInfoCalled then
smallforce:=true smallforce:=true
else else
begin begin
@ -477,10 +550,13 @@ begin
end; end;
if SmallForce then if SmallForce then
begin begin
SetExtraInfoCalled:=false;
SavedColor:=Graph.GetColor; SavedColor:=Graph.GetColor;
SavedBkColor:=Graph.GetBkColor; SavedBkColor:=Graph.GetBkColor;
CurColor:=SavedColor; CurColor:=SavedColor;
CurBkColor:=SavedBkColor; CurBkColor:=SavedBkColor;
Graph.GetViewSettings(Ts);
Graph.SetViewPort(0,0,Graph.GetMaxX,Graph.GetMaxY,false);
Graph.GetFillSettings(StoreFillSettings); Graph.GetFillSettings(StoreFillSettings);
Graph.SetFillStyle(EmptyFill,0); Graph.SetFillStyle(EmptyFill,0);
for y := 0 to TextScreenHeight - 1 do for y := 0 to TextScreenHeight - 1 do
@ -488,7 +564,7 @@ begin
for x := 0 to TextScreenWidth - 1 do for x := 0 to TextScreenWidth - 1 do
begin begin
i:=y*TextScreenWidth+x; i:=y*TextScreenWidth+x;
if OldVideoBuf^[i]<>VideoBuf^[i] then if (OldVideoBuf^[i]<>VideoBuf^[i]) or assigned(SpVideoBuf^[i]) then
begin begin
ch:=chr(VideoBuf^[i] and $ff); ch:=chr(VideoBuf^[i] and $ff);
if ch<>#0 then if ch<>#0 then
@ -502,7 +578,19 @@ begin
CurBkColor:=NextBkColor; CurBkColor:=NextBkColor;
end; end;
Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth,(y+1)*SysFontHeight); if not assigned(SpVideoBuf^[i]) then
Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth-1,(y+1)*SysFontHeight-1)
else
begin
For yi:=0 to SysFontHeight-1 do
For xi:=0 to SysFontWidth-1 do
begin
k:=xi mod 8;
l:=yi*((SysFontWidth +7) div 8) + xi div 8;
if SpVideoBuf^[i]^[l] and (1 shl k) = 0 then
Graph.PutPixel(x*SysfontWidth+xi,y*SysFontHeight+yi,CurBkColor);
end;
end;
if NextColor<>CurColor then if NextColor<>CurColor then
begin begin
Graph.SetColor(NextColor); Graph.SetColor(NextColor);
@ -518,24 +606,33 @@ begin
Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight,ch); Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight,ch);
end; end;
OldVideoBuf^[i]:=VideoBuf^[i]; OldVideoBuf^[i]:=VideoBuf^[i];
if assigned(SpVideoBuf^[i]) then
begin
FreeMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
SpVideoBuf^[i]:=nil;
end;
end; end;
end; end;
end; end;
Graph.SetFillStyle(StoreFillSettings.pattern,StoreFillSettings.color); Graph.SetFillStyle(StoreFillSettings.pattern,StoreFillSettings.color);
Graph.SetColor(SavedColor); Graph.SetColor(SavedColor);
Graph.SetBkColor(SavedBkColor); Graph.SetBkColor(SavedBkColor);
Graph.SetViewPort(TS.X1,Ts.Y1,ts.X2,ts.Y2,ts.Clip);
end; end;
{$else not USE_VIDEO_API} {$else not USE_VIDEO_API}
RunError(219); RunError(219);
{$endif USE_VIDEO_API} {$endif USE_VIDEO_API}
{$ENDIF GRAPH_API}
end; end;
{$ENDIF GRAPH_API}
END. END.
{ {
$Log$ $Log$
Revision 1.14 2002-05-29 22:15:57 pierre Revision 1.15 2002-05-31 12:37:47 pierre
* try to enhance graph mode
Revision 1.14 2002/05/29 22:15:57 pierre
* fix build failure in non graph mode * fix build failure in non graph mode
Revision 1.13 2002/05/29 19:35:31 pierre Revision 1.13 2002/05/29 19:35:31 pierre

View File

@ -1329,8 +1329,10 @@ if Not TextmodeGFV then
if assigned(Video.OldVideoBuf) then if assigned(Video.OldVideoBuf) then
FreeMem(Video.OldVideoBuf); FreeMem(Video.OldVideoBuf);
GetMem(Video.OldVideoBuf,sizeof(word)*ScreenWidth*ScreenHeight); GetMem(Video.OldVideoBuf,sizeof(word)*ScreenWidth*ScreenHeight);
GetMem(GFVGraph.SpVideoBuf,sizeof(pextrainfo)*(ScreenWidth+1)*(ScreenHeight+1));
FillChar(Video.VideoBuf^,sizeof(word)*ScreenWidth*ScreenHeight,#0); FillChar(Video.VideoBuf^,sizeof(word)*ScreenWidth*ScreenHeight,#0);
FillChar(Video.OldVideoBuf^,sizeof(word)*ScreenWidth*ScreenHeight,#0); FillChar(Video.OldVideoBuf^,sizeof(word)*ScreenWidth*ScreenHeight,#0);
FillChar(GFVGraph.SpVideoBuf^,sizeof(pextrainfo)*(ScreenWidth+1)*(ScreenHeight+1),#0);
ScreenMode.color:=true; ScreenMode.color:=true;
ScreenMode.col:=ScreenWidth; ScreenMode.col:=ScreenWidth;
ScreenMode.row:=ScreenHeight; ScreenMode.row:=ScreenHeight;
@ -1380,6 +1382,7 @@ BEGIN
Video.VideoBuf:=nil; Video.VideoBuf:=nil;
FreeMem(Video.OldVideoBuf,sizeof(word)*ScreenWidth*ScreenHeight); FreeMem(Video.OldVideoBuf,sizeof(word)*ScreenWidth*ScreenHeight);
Video.OldVideoBuf:=nil; Video.OldVideoBuf:=nil;
FreeExtraInfo;
{$endif USE_VIDEO_API} {$endif USE_VIDEO_API}
CloseGraph; CloseGraph;
{$ifdef win32} {$ifdef win32}
@ -1626,7 +1629,10 @@ BEGIN
END. END.
{ {
$Log$ $Log$
Revision 1.22 2002-05-29 21:21:54 pierre Revision 1.23 2002-05-31 12:38:37 pierre
* try to enhance graph mode
Revision 1.22 2002/05/29 21:21:54 pierre
* Use VGAHi for go32v2 graph version for now * Use VGAHi for go32v2 graph version for now
Revision 1.21 2002/05/29 19:36:12 pierre Revision 1.21 2002/05/29 19:36:12 pierre

View File

@ -133,6 +133,17 @@ CONST
SolidFill = Graph.SolidFill; SolidFill = Graph.SolidFill;
LowAscii : boolean = true; LowAscii : boolean = true;
type
textrainfo = array[0..0] of byte;
pextrainfo = ^textrainfo;
TSpVideoBuf = array [0..0] of pextrainfo;
PSpVideoBuf = ^TSpVideoBuf;
const
SpVideoBuf : PSpVideoBuf = nil;
{$ELSE not GRAPH_API } {$ELSE not GRAPH_API }
CONST CONST
SolidFill = 0; SolidFill = 0;
@ -209,7 +220,11 @@ PROCEDURE Line(X1, Y1, X2, Y2: Integer);
PROCEDURE Rectangle(X1, Y1, X2, Y2: Integer); PROCEDURE Rectangle(X1, Y1, X2, Y2: Integer);
PROCEDURE OutTextXY(X,Y: Integer; TextString: String); PROCEDURE OutTextXY(X,Y: Integer; TextString: String);
{$IFDEF GRAPH_API}
procedure GraphUpdateScreen(Force: Boolean); procedure GraphUpdateScreen(Force: Boolean);
procedure SetExtraInfo(x,y,xi,yi : longint; shouldskip : boolean);
procedure FreeExtraInfo;
{$ENDIF GRAPH_API}
{***************************************************************************} {***************************************************************************}
{ INITIALIZED PUBLIC VARIABLES } { INITIALIZED PUBLIC VARIABLES }
@ -435,30 +450,88 @@ BEGIN
END; END;
PROCEDURE OutTextXY(X,Y: Integer; TextString: string); PROCEDURE OutTextXY(X,Y: Integer; TextString: string);
{$IFDEF GRAPH_API}
var
i,j,xi,yj : longint;
Ts: Graph.ViewPortType;
{$ENDIF GRAPH_API}
BEGIN BEGIN
{$IFDEF GRAPH_API} {$IFDEF GRAPH_API}
Graph.OutTextXY(X, Y, TextString); { Call graph proc } Graph.OutTextXY(X, Y, TextString); { Call graph proc }
if true then
begin
Graph.GetViewSettings(Ts);
For j:=0 to TextWidth(TextString) -1 do
For i:=0 to TextHeight(TextString)-1 do
begin
xi:=x+i+Ts.x1;
yj:=y+j+Ts.y1;
SetExtraInfo(xi div SysFontWidth,yj div SysFontHeight,
xi mod SysFontWidth,yj mod SysFontHeight, true);
end;
end;
{$ENDIF GRAPH_API} {$ENDIF GRAPH_API}
END; END;
{$IFDEF GRAPH_API}
const
SetExtraInfoCalled : boolean = false;
procedure SetExtraInfo(x,y,xi,yi : longint; shouldskip : boolean);
var
i,k,l : longint;
extrainfo : pextrainfo;
begin
i:=y*TextScreenWidth+x;
if not assigned(SpVideoBuf^[i]) then
begin
GetMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
FillChar(SpVideoBuf^[i]^,SysFontHeight*((SysFontWidth +7) div 8),#0);
end;
extrainfo:=SpVideoBuf^[i];
k:=xi mod 8;
l:=yi*((SysFontWidth +7) div 8) + xi div 8;
if l>=SysFontHeight*((SysFontWidth +7) div 8) then
RunError(219);
if shouldskip then
extrainfo^[l]:=extrainfo^[l] or (1 shl k)
else
extrainfo^[l]:=extrainfo^[l] and not (1 shl k);
SetExtraInfoCalled:=true;
end;
procedure FreeExtraInfo;
var
i : longint;
begin
if assigned(SpVideoBuf) then
begin
for i:=0 to (TextScreenWidth+1)*(TextScreenHeight+1) - 1 do
if assigned(SpVideoBuf^[i]) then
FreeMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
FreeMem(SpVideoBuf,sizeof(pextrainfo)*(TextScreenWidth+1)*(TextScreenHeight+1));
SpVideoBuf:=nil;
end;
end;
procedure GraphUpdateScreen(Force: Boolean); procedure GraphUpdateScreen(Force: Boolean);
{$IFDEF GRAPH_API}
var var
smallforce : boolean; smallforce : boolean;
i,x,y : longint; i,x,y : longint;
xi,yi,k,l : longint;
ch : char; ch : char;
attr : byte; attr : byte;
SavedColor,SavedBkColor : longint; SavedColor,SavedBkColor : longint;
CurColor,CurBkColor : longint; CurColor,CurBkColor : longint;
NextColor,NextBkColor : longint; NextColor,NextBkColor : longint;
StoreFillSettings: FillSettingsType; StoreFillSettings: FillSettingsType;
{$ENDIF GRAPH_API} Ts: Graph.ViewPortType;
begin begin
{$IFDEF GRAPH_API}
{$ifdef USE_VIDEO_API} {$ifdef USE_VIDEO_API}
if force then if force or SetExtraInfoCalled then
smallforce:=true smallforce:=true
else else
begin begin
@ -477,10 +550,13 @@ begin
end; end;
if SmallForce then if SmallForce then
begin begin
SetExtraInfoCalled:=false;
SavedColor:=Graph.GetColor; SavedColor:=Graph.GetColor;
SavedBkColor:=Graph.GetBkColor; SavedBkColor:=Graph.GetBkColor;
CurColor:=SavedColor; CurColor:=SavedColor;
CurBkColor:=SavedBkColor; CurBkColor:=SavedBkColor;
Graph.GetViewSettings(Ts);
Graph.SetViewPort(0,0,Graph.GetMaxX,Graph.GetMaxY,false);
Graph.GetFillSettings(StoreFillSettings); Graph.GetFillSettings(StoreFillSettings);
Graph.SetFillStyle(EmptyFill,0); Graph.SetFillStyle(EmptyFill,0);
for y := 0 to TextScreenHeight - 1 do for y := 0 to TextScreenHeight - 1 do
@ -488,7 +564,7 @@ begin
for x := 0 to TextScreenWidth - 1 do for x := 0 to TextScreenWidth - 1 do
begin begin
i:=y*TextScreenWidth+x; i:=y*TextScreenWidth+x;
if OldVideoBuf^[i]<>VideoBuf^[i] then if (OldVideoBuf^[i]<>VideoBuf^[i]) or assigned(SpVideoBuf^[i]) then
begin begin
ch:=chr(VideoBuf^[i] and $ff); ch:=chr(VideoBuf^[i] and $ff);
if ch<>#0 then if ch<>#0 then
@ -502,7 +578,19 @@ begin
CurBkColor:=NextBkColor; CurBkColor:=NextBkColor;
end; end;
Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth,(y+1)*SysFontHeight); if not assigned(SpVideoBuf^[i]) then
Graph.Bar(x*SysFontWidth,y*SysFontHeight,(x+1)*SysFontWidth-1,(y+1)*SysFontHeight-1)
else
begin
For yi:=0 to SysFontHeight-1 do
For xi:=0 to SysFontWidth-1 do
begin
k:=xi mod 8;
l:=yi*((SysFontWidth +7) div 8) + xi div 8;
if SpVideoBuf^[i]^[l] and (1 shl k) = 0 then
Graph.PutPixel(x*SysfontWidth+xi,y*SysFontHeight+yi,CurBkColor);
end;
end;
if NextColor<>CurColor then if NextColor<>CurColor then
begin begin
Graph.SetColor(NextColor); Graph.SetColor(NextColor);
@ -518,24 +606,33 @@ begin
Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight,ch); Graph.OutTextXY(x*SysFontWidth,y*SysFontHeight,ch);
end; end;
OldVideoBuf^[i]:=VideoBuf^[i]; OldVideoBuf^[i]:=VideoBuf^[i];
if assigned(SpVideoBuf^[i]) then
begin
FreeMem(SpVideoBuf^[i],SysFontHeight*((SysFontWidth +7) div 8));
SpVideoBuf^[i]:=nil;
end;
end; end;
end; end;
end; end;
Graph.SetFillStyle(StoreFillSettings.pattern,StoreFillSettings.color); Graph.SetFillStyle(StoreFillSettings.pattern,StoreFillSettings.color);
Graph.SetColor(SavedColor); Graph.SetColor(SavedColor);
Graph.SetBkColor(SavedBkColor); Graph.SetBkColor(SavedBkColor);
Graph.SetViewPort(TS.X1,Ts.Y1,ts.X2,ts.Y2,ts.Clip);
end; end;
{$else not USE_VIDEO_API} {$else not USE_VIDEO_API}
RunError(219); RunError(219);
{$endif USE_VIDEO_API} {$endif USE_VIDEO_API}
{$ENDIF GRAPH_API}
end; end;
{$ENDIF GRAPH_API}
END. END.
{ {
$Log$ $Log$
Revision 1.14 2002-05-29 22:15:57 pierre Revision 1.15 2002-05-31 12:37:47 pierre
* try to enhance graph mode
Revision 1.14 2002/05/29 22:15:57 pierre
* fix build failure in non graph mode * fix build failure in non graph mode
Revision 1.13 2002/05/29 19:35:31 pierre Revision 1.13 2002/05/29 19:35:31 pierre