This message referes to "RetroROMs Door" in previous thread.
I make some changes in my code and instead of the old Mystic Library, i found some code on the Net, add some of my own and made some small Door Dev. Kit. I recompiled the RetroROMs door, with the new code and even if the big issues with Netrunner have gone, there are still some smaller glitches. The main problem is with the Save/Restore Screen code. It saves the screen fine, but when the screen is restored, there are some blank areas or areas with ANSI Escape codes present... :(
The code for the Linux version is below. Can you suggest any corrections or another way to save/restore screens in FPC?
procedure SaveScreen(var screenBuf: TScreenBuf);
var
X, Y: integer;
begin
for Y := 1 to 25 do
begin
for X := 1 to 80 do
begin
screenBuf[Y][X].Ch := GetCharAt(X, Y);
screenBuf[Y][X].Attr := GetAttrAt(X, Y);
end;
end;
end;
function GetCharAt(AX, AY: Byte): Char;
begin
{ Validate parameters }
if ((AX < 1) OR (AX > 80) OR (AY < 1) OR (AY > 25)) then
begin
GetCharAt := ' ';
Exit;
end;
GetCharAt := ConsoleBuf^[((AY - 1) * ScreenWidth) + (AX - 1)].ch;
end;
procedure RestoreScreen(var screenBuf: TScreenBuf);
var
X, Y: integer;
begin
for Y := 1 to 25 do
begin
for X := 1 to 80 do
begin
FastWrite(screenBuf[Y][X].Ch, X, Y, screenBuf[Y][X].Attr);
end;
end;
end;
procedure FastWrite(ALine: String; AX, AY, AAttr: Byte);
var
NeedWindow: Boolean;
SavedAttr: Integer;
SavedWindMinX: Integer;
SavedWindMinY: Integer;
SavedWindMaxX: Integer;
SavedWindMaxY: Integer;
SavedXY: Integer;
begin
{ Validate parameters }
if ((AX < 1) OR (AX > 80) OR (AY < 1) OR (AY > 25)) then Exit;
{ Trim to fit within 80 columns }
if (Length(ALine) > (80 - AX + 1)) then ALine := Copy(ALine, 1, 80 - AX + 1);
// Save
NeedWindow := ((WindMinX > 1) OR (WindMinY > 1) OR (WindMaxX < 80) OR (WindmaxY < 25));
SavedAttr := TextAttr;
SavedWindMinX := WindMinX;
SavedWindMinY := WindMinY;
SavedWindMaxX := WindMaxX;
SavedWindMaxY := WindMaxY;
SavedXY := WhereX + (WhereY SHL 8);
// Update
if (NeedWindow) then Window(1, 1, 80, 25);
GotoXY(AX, AY);
TextAttr := AAttr;
// Trim to fit within 79 columns if on line 25
if ((AY = 25) AND (Length(ALine) > (79 - AX + 1))) then ALine := Copy(ALine, 1, 79 - AX + 1);
// Output
Write(ALine);
// Restore
TextAttr := SavedAttr;
if (NeedWindow) then Window(SavedWindMinX, SavedWindMinY, SavedWindMaxX, SavedWindMaxY);
GotoXY(SavedXY AND $00FF, (SavedXY AND $FF00) SHR 8);
end;
.----- --- -- -
| Another Droid BBS
: Telnet : andr01d.zapto.org:9999 [UTC 11:00 - 20:00]
. Contact :
xqtr.xqtr@gmail.com
--- Mystic BBS v1.12 A34 (Raspberry Pi/32)
* Origin: Another Droid BBS (21:1/111)