• FPC Save/Restore screen

    From xqtr@21:1/111 to All on Fri Nov 24 20:12:02 2017
    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)
  • From dream master@21:1/163 to xqtr on Fri Nov 24 18:53:24 2017
    On 11/24/17, xqtr said the following...
    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?

    can you use in line asm?

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A36 2017/11/23 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From xqtr@21:1/111 to dream master on Sat Nov 25 19:01:50 2017
    can you use in line asm?

    FPC supports inline ASM, but its a little peculiar about it. The rule
    nowdays, is to avoid ASM, specially if you want to have a cross platform
    code. So i would prefer not to use ASM.

    .----- --- -- -
    | 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)