mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-02 12:10:22 +02:00
rtl-console: support two extra builtin font sizes on Amiga-likes. makes it possible to use the IDE on a 640x256 PAL screen, or have VGA 80x50-alike mode on RTG/high-res screens. switching is possible via an ENV var for now. Also support turning off the SMARTREFRESH attribute of the IDE window
git-svn-id: trunk@36350 -
This commit is contained in:
parent
97f876c9d4
commit
b649db5004
@ -189,8 +189,8 @@ var
|
|||||||
ICode: Word; // save items from Message
|
ICode: Word; // save items from Message
|
||||||
IQual: Word;
|
IQual: Word;
|
||||||
IClass: Longword;
|
IClass: Longword;
|
||||||
MouseX: Integer;
|
MouseX: LongInt;
|
||||||
MouseY: Integer;
|
MouseY: LongInt;
|
||||||
KeyUp: Boolean; // Event is a key up event
|
KeyUp: Boolean; // Event is a key up event
|
||||||
Buff: array[0..19] of Char;
|
Buff: array[0..19] of Char;
|
||||||
ie: TInputEvent; // for mapchar
|
ie: TInputEvent; // for mapchar
|
||||||
@ -237,8 +237,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
IDCMP_INTUITICKS: begin
|
IDCMP_INTUITICKS: begin
|
||||||
ToggleCursor(false);
|
ToggleCursor(false);
|
||||||
MouseX := (MouseX - VideoWindow^.BorderLeft) div 8;
|
TranslateToCharXY(MouseX - VideoWindow^.BorderLeft, MouseY - VideoWindow^.BorderTop, MouseX, MouseY);
|
||||||
MouseY := (MouseY - VideoWindow^.BorderTop) div 16;
|
|
||||||
if (MouseX >= 0) and (MouseY >= 0) and
|
if (MouseX >= 0) and (MouseY >= 0) and
|
||||||
(MouseX < Video.ScreenWidth) and (MouseY < Video.ScreenHeight) and
|
(MouseX < Video.ScreenWidth) and (MouseY < Video.ScreenHeight) and
|
||||||
((MouseX <> OldMouseX) or (MouseY <> OldmouseY))
|
((MouseX <> OldMouseX) or (MouseY <> OldmouseY))
|
||||||
@ -268,8 +267,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
IDCMP_MOUSEBUTTONS: begin
|
IDCMP_MOUSEBUTTONS: begin
|
||||||
MouseEvent := True;
|
MouseEvent := True;
|
||||||
me.x := (MouseX - videoWindow^.BorderLeft) div 8; // calculate char position
|
TranslateToCharXY(MouseX - videoWindow^.BorderLeft, MouseY - videoWindow^.BorderTop, MouseX, MouseY);
|
||||||
me.y := (MouseY - videoWindow^.BorderTop) div 16;
|
me.x := MouseX;
|
||||||
|
me.y := MouseY;
|
||||||
case ICode of
|
case ICode of
|
||||||
SELECTDOWN: begin
|
SELECTDOWN: begin
|
||||||
//writeln('left down!');
|
//writeln('left down!');
|
||||||
@ -306,8 +306,7 @@ begin
|
|||||||
{ IDCMP_MOUSEMOVE is disabled now in the video unit,
|
{ IDCMP_MOUSEMOVE is disabled now in the video unit,
|
||||||
according to autodocs INTUITICKS should be enough
|
according to autodocs INTUITICKS should be enough
|
||||||
to handle most moves, esp. in a "textmode" app }
|
to handle most moves, esp. in a "textmode" app }
|
||||||
MouseX := (MouseX - VideoWindow^.BorderLeft) div 8;
|
TranslateToCharXY(MouseX - VideoWindow^.BorderLeft, MouseY - VideoWindow^.BorderTop, MouseX, MouseY);
|
||||||
MouseY := (MouseY - VideoWindow^.BorderTop) div 16;
|
|
||||||
if (MouseX >= 0) and (MouseY >= 0) and
|
if (MouseX >= 0) and (MouseY >= 0) and
|
||||||
(MouseX < Video.ScreenWidth) and (MouseY < Video.ScreenHeight) and
|
(MouseX < Video.ScreenWidth) and (MouseY < Video.ScreenHeight) and
|
||||||
((MouseX <> OldMouseX) or (MouseY <> OldmouseY))
|
((MouseX <> OldMouseX) or (MouseY <> OldmouseY))
|
||||||
|
@ -47,6 +47,7 @@ function HasActiveWindow: boolean;
|
|||||||
procedure GotInactiveWindow;
|
procedure GotInactiveWindow;
|
||||||
function HasInactiveWindow: boolean;
|
function HasInactiveWindow: boolean;
|
||||||
procedure SetWindowTitle(const winTitle: AnsiString; const screenTitle: AnsiString);
|
procedure SetWindowTitle(const winTitle: AnsiString; const screenTitle: AnsiString);
|
||||||
|
procedure TranslateToCharXY(const X,Y: LongInt; var CX,CY: LongInt);
|
||||||
|
|
||||||
var
|
var
|
||||||
VideoWindow: PWindow;
|
VideoWindow: PWindow;
|
||||||
@ -70,6 +71,8 @@ var
|
|||||||
var
|
var
|
||||||
VideoColorMap : PColorMap;
|
VideoColorMap : PColorMap;
|
||||||
VideoPens : array[0..15] of LongInt;
|
VideoPens : array[0..15] of LongInt;
|
||||||
|
VideoFont : PByte;
|
||||||
|
VideoFontHeight : DWord;
|
||||||
|
|
||||||
OldSH, OldSW : longint;
|
OldSH, OldSW : longint;
|
||||||
|
|
||||||
@ -160,7 +163,14 @@ const
|
|||||||
VIDEO_WFLG_DEFAULTS = WFLG_RMBTRAP or WFLG_SMART_REFRESH;
|
VIDEO_WFLG_DEFAULTS = WFLG_RMBTRAP or WFLG_SMART_REFRESH;
|
||||||
|
|
||||||
Function GetWindow: PWindow;
|
Function GetWindow: PWindow;
|
||||||
|
var
|
||||||
|
envBuf: array[0..15] of char;
|
||||||
|
videoDefaultFlags: PtrUInt;
|
||||||
begin
|
begin
|
||||||
|
videoDefaultFlags:=VIDEO_WFLG_DEFAULTS;
|
||||||
|
if GetVar('FPC_VIDEO_SIMPLEREFRESH',@envBuf,sizeof(envBuf),0) > -1 then
|
||||||
|
videoDefaultFlags:=videoDefaultFlags and not WFLG_SMART_REFRESH;
|
||||||
|
|
||||||
if FPC_VIDEO_FULLSCREEN then
|
if FPC_VIDEO_FULLSCREEN then
|
||||||
begin
|
begin
|
||||||
OS_Screen := GetScreen;
|
OS_Screen := GetScreen;
|
||||||
@ -190,7 +200,7 @@ begin
|
|||||||
WA_Left , LastL,
|
WA_Left , LastL,
|
||||||
WA_Top , LastT,
|
WA_Top , LastT,
|
||||||
WA_InnerWidth , LastW*8,
|
WA_InnerWidth , LastW*8,
|
||||||
WA_InnerHeight, LastH*16,
|
WA_InnerHeight, LastH*VideoFontHeight,
|
||||||
WA_MaxWidth , 32768,
|
WA_MaxWidth , 32768,
|
||||||
WA_MaxHeight , 32768,
|
WA_MaxHeight , 32768,
|
||||||
WA_Title , PtrUInt(PChar('FPC Video Window Output')),
|
WA_Title , PtrUInt(PChar('FPC Video Window Output')),
|
||||||
@ -229,6 +239,7 @@ var
|
|||||||
Counter2: LongInt;
|
Counter2: LongInt;
|
||||||
P: PWord;
|
P: PWord;
|
||||||
flags: DWord;
|
flags: DWord;
|
||||||
|
envBuf: array[0..15] of char;
|
||||||
begin
|
begin
|
||||||
{$IFDEF MORPHOS}
|
{$IFDEF MORPHOS}
|
||||||
InitGraphicsLibrary;
|
InitGraphicsLibrary;
|
||||||
@ -243,6 +254,27 @@ begin
|
|||||||
WriteLn('DEBUG: Recognized windowed mode');
|
WriteLn('DEBUG: Recognized windowed mode');
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
{ FIXME/TODO: next to the hardwired selection, there could be some heuristics,
|
||||||
|
which sets the font size correctly on screens according to the aspect
|
||||||
|
ratio. (KB) }
|
||||||
|
VideoFont:=@vgafont;
|
||||||
|
VideoFontHeight:=16;
|
||||||
|
if GetVar('FPC_VIDEO_BUILTINFONT',@envBuf,sizeof(envBuf),0) > -1 then
|
||||||
|
begin
|
||||||
|
case lowerCase(envBuf) of
|
||||||
|
'vga8':
|
||||||
|
begin
|
||||||
|
VideoFont:=@vgafont8;
|
||||||
|
VideoFontHeight:=8;
|
||||||
|
end;
|
||||||
|
'vga14':
|
||||||
|
begin
|
||||||
|
VideoFont:=@vgafont14;
|
||||||
|
VideoFontHeight:=14;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// fill videobuf and oldvideobuf with different bytes, to allow proper first draw
|
// fill videobuf and oldvideobuf with different bytes, to allow proper first draw
|
||||||
FillDword(VideoBuf^, VideoBufSize div 4, $1234D3AD);
|
FillDword(VideoBuf^, VideoBufSize div 4, $1234D3AD);
|
||||||
FillDword(OldVideoBuf^, VideoBufSize div 4, $4321BEEF);
|
FillDword(OldVideoBuf^, VideoBufSize div 4, $4321BEEF);
|
||||||
@ -263,7 +295,7 @@ begin
|
|||||||
// Can happen for instance when the window does not hide its
|
// Can happen for instance when the window does not hide its
|
||||||
// borders or titlebar as intended.
|
// borders or titlebar as intended.
|
||||||
ScreenWidth := VideoWindow^.GZZWidth div 8;
|
ScreenWidth := VideoWindow^.GZZWidth div 8;
|
||||||
ScreenHeight := VideoWindow^.GZZHeight div 16;
|
ScreenHeight := VideoWindow^.GZZHeight div VideoFontHeight;
|
||||||
ScreenColor := False;
|
ScreenColor := False;
|
||||||
|
|
||||||
{$ifdef VIDEODEBUG}
|
{$ifdef VIDEODEBUG}
|
||||||
@ -296,7 +328,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ Obtain Friend bitmap for font blitting }
|
{ Obtain Friend bitmap for font blitting }
|
||||||
FontBitmap:=AllocBitMap(16,16*256,1,0,VideoWindow^.RPort^.Bitmap);
|
FontBitmap:=AllocBitMap(16,VideoFontHeight*256,1,0,VideoWindow^.RPort^.Bitmap);
|
||||||
|
|
||||||
if (FontBitmap <> nil) then
|
if (FontBitmap <> nil) then
|
||||||
begin
|
begin
|
||||||
@ -312,9 +344,9 @@ begin
|
|||||||
miserably on classics (tested on 3.1 + AGA) }
|
miserably on classics (tested on 3.1 + AGA) }
|
||||||
p:=PWord(FontBitmap^.Planes[0]);
|
p:=PWord(FontBitmap^.Planes[0]);
|
||||||
for counter:=0 to 255 do
|
for counter:=0 to 255 do
|
||||||
for counter2:=0 to 15 do
|
for counter2:=0 to VideoFontHeight-1 do
|
||||||
begin
|
begin
|
||||||
p^:=vgafont[counter,counter2] shl 8;
|
p^:=VideoFont[counter * VideoFontHeight + counter2] shl 8;
|
||||||
inc(p);
|
inc(p);
|
||||||
end;
|
end;
|
||||||
Permit();
|
Permit();
|
||||||
@ -407,7 +439,7 @@ begin
|
|||||||
if not FPC_VIDEO_FULLSCREEN then
|
if not FPC_VIDEO_FULLSCREEN then
|
||||||
begin
|
begin
|
||||||
dx := (Mode.col * 8) - VideoWindow^.GZZWidth;
|
dx := (Mode.col * 8) - VideoWindow^.GZZWidth;
|
||||||
dy := (Mode.row * 16) - VideoWindow^.GZZHeight;
|
dy := (Mode.row * VideoFontHeight) - VideoWindow^.GZZHeight;
|
||||||
SizeWindow(videoWindow, dx, dy);
|
SizeWindow(videoWindow, dx, dy);
|
||||||
end;
|
end;
|
||||||
ScreenWidth := Mode.col;
|
ScreenWidth := Mode.col;
|
||||||
@ -440,7 +472,7 @@ begin
|
|||||||
TmpBGColor := (TmpCharData shr 12) and %00000111;
|
TmpBGColor := (TmpCharData shr 12) and %00000111;
|
||||||
|
|
||||||
sX := x * 8 + videoWindow^.borderLeft;
|
sX := x * 8 + videoWindow^.borderLeft;
|
||||||
sY := y * 16 + videoWindow^.borderTop;
|
sY := y * VideoFontHeight + videoWindow^.borderTop;
|
||||||
|
|
||||||
if crType <> crBlock then
|
if crType <> crBlock then
|
||||||
begin
|
begin
|
||||||
@ -453,15 +485,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if FontBitmap <> nil then
|
if FontBitmap <> nil then
|
||||||
BltTemplate(@(PWord(FontBitmap^.Planes[0])[tmpChar * 16]), 0, 2, rp, sX, sY, 8, 16)
|
BltTemplate(@(PWord(FontBitmap^.Planes[0])[tmpChar * VideoFontHeight]), 0, 2, rp, sX, sY, 8, VideoFontHeight)
|
||||||
else
|
else
|
||||||
BltTemplate(@Vgafont[tmpChar, 0], 0, 1, rp, sX, sY, 8, 16);
|
BltTemplate(@VideoFont[tmpChar * VideoFontHeight], 0, 1, rp, sX, sY, 8, VideoFontHeight);
|
||||||
|
|
||||||
if crType = crUnderLine then
|
if crType = crUnderLine then
|
||||||
begin
|
begin
|
||||||
{ draw two lines at the bottom of the char, in case of underline cursor }
|
{ draw two lines at the bottom of the char, in case of underline cursor }
|
||||||
GfxMove(rp, sX, sY + 14); Draw(rp, sX + 7, sY + 14);
|
if videoFontHeight = 8 then
|
||||||
GfxMove(rp, sX, sY + 15); Draw(rp, sX + 7, sY + 15);
|
begin
|
||||||
|
GfxMove(rp, sX, sY + 7); Draw(rp, sX + 7, sY + 7);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
GfxMove(rp, sX, sY + videoFontHeight - 2); Draw(rp, sX + 7, sY + videoFontHeight - 2);
|
||||||
|
GfxMove(rp, sX, sY + videoFontHeight - 1); Draw(rp, sX + 7, sY + videoFontHeight - 1);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -619,7 +658,7 @@ begin
|
|||||||
if Assigned(VideoWindow) then
|
if Assigned(VideoWindow) then
|
||||||
begin
|
begin
|
||||||
WinW := VideoWindow^.GZZWidth div 8;
|
WinW := VideoWindow^.GZZWidth div 8;
|
||||||
WinH := VideoWindow^.GZZHeight div 16;
|
WinH := VideoWindow^.GZZHeight div VideoFontHeight;
|
||||||
// writeln('resize', winw, ' ',winh);
|
// writeln('resize', winw, ' ',winh);
|
||||||
LastW := WinW;
|
LastW := WinW;
|
||||||
LastH := WinH;
|
LastH := WinH;
|
||||||
@ -720,6 +759,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TranslateToCharXY(const X,Y: LongInt; var CX,CY: LongInt);
|
||||||
|
begin
|
||||||
|
CX:=X div 8;
|
||||||
|
CY:=Y div VideoFontHeight;
|
||||||
|
end;
|
||||||
|
|
||||||
function SysGetVideoModeCount: Word;
|
function SysGetVideoModeCount: Word;
|
||||||
begin
|
begin
|
||||||
SysGetVideoModeCount := 2;
|
SysGetVideoModeCount := 2;
|
||||||
@ -738,7 +783,7 @@ begin
|
|||||||
1: begin
|
1: begin
|
||||||
Screen := LockPubScreen('Workbench');
|
Screen := LockPubScreen('Workbench');
|
||||||
Mode.Col := Screen^.Width div 8;
|
Mode.Col := Screen^.Width div 8;
|
||||||
Mode.Row := Screen^.Height div 16;
|
Mode.Row := Screen^.Height div VideoFontHeight;
|
||||||
UnlockPubScreen('Workbench', Screen);
|
UnlockPubScreen('Workbench', Screen);
|
||||||
Mode.Color := False;
|
Mode.Color := False;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user