Recent

Author Topic: [SOLVED] Screen mode in Free Vision  (Read 6526 times)

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
[SOLVED] Screen mode in Free Vision
« on: May 11, 2014, 08:30:20 pm »
Hello gentlemen!

Does someone know how to set the screen mode in Free Vision? Is it possible to have the standard 25 lines screen?

Here is a piece of code that I have tested with FPC and with Virtual Pascal. With FPC the code has no effect : I always get a 58 (?) lines screen.

Code: [Select]
program test_screenmode;

{ How to set screen mode in Free Vision? How to get 25 lines?
 
  This code has been tested under Windows 8.1, with Free Pascal 2.6.2 and
  Virtual Pascal 2.1. With VP I get the expected result, but with FPC the code
  seems to have no effect: I always get a big screen.
}

{$IFDEF VPASCAL}
{$PMTYPE VIO}
{$ELSE}
{$APPTYPE CONSOLE}
{$ENDIF}

uses
  App, Drivers;

{.$DEFINE BIG_SCREEN}

type
  TTestApp = object(TApplication)
    constructor Init;
  end;

constructor TTestApp.Init;
begin
  inherited Init;
{$IFDEF BIG_SCREEN}
  SetScreenMode(smCO80 or smFont8x8);
{$ELSE}
  SetScreenMode(smCO80 and not smFont8x8);
{$ENDIF}
  Redraw;
end;

var
  a: TTestApp;

begin
  a.Init;
  a.Run;
  a.Done;
end.

I had a look into the FP IDE source code (I remembered that in the IDE you can switch between three different video modes), but it didn't help : the code is too big and too complicated for me.  %)
« Last Edit: May 12, 2014, 08:00:39 am by Roland Chastain »
My projects are on Gitlab and on Codeberg.

Tomas Hajny

  • Moderator
  • New Member
  • *****
  • Posts: 45
Re: Screen mode in Free Vision
« Reply #1 on: May 11, 2014, 11:58:55 pm »
Well, correct, it seems that you're the first one trying to do this with FreeVision... I suggest that you file a bug report, because the current implementation of TProgram SetScreenMode can indeed never change the resolution.

To be honest, usefulness of this compatibility method is very limited in a world without fixed screen mode numbers, but it should work at least for the modes for which predefined constants are supplied, which is exactly what you tried to do.

In the meantime, use TProgram.SetScreenVideoMode instead - it expects a TVideoMode record (see unit Video for its definition) which allows you to select the wanted number of rows and columns. Note that it does not support any arbitrary resolution - it knows some predefined modes available on all IBM PC machines (although even that is obviously not guaranteed to be available on all FPC supported platforms, which is the reason why the FP IDE code asks for confirmation whether it works correctly after trying to switch to the selected mode) plus it adds the resolution available on startup if it can detect it on the used platform and it is different from the predefined ones (this is obviously based on the assumption that if the resolution worked on startup of the FPC compiled program, it should be possible to change to this resolution later too). See unit Video for further information on how to walk through the recognized video modes / resolutions.

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: Screen mode in Free Vision
« Reply #2 on: May 12, 2014, 07:59:18 am »
Thank you for your instructive answer. Here is my code example.

Code: [Select]
program test_screenmode2;

// Free Pascal 2.6.2

uses
  App, Drivers;

type
  TTestApp = object(TApplication)
    constructor Init;
  end;

{ PVideoMode = ^TVideoMode;
  TVideoMode = record
    Col,Row : Word;
    Color   : Boolean;
  end;
}

constructor TTestApp.Init;
var
  vm: TVideoMode;
begin
  inherited Init;
 
  vm.col := 80;
  vm.row := 25;
  vm.color := TRUE;
 
  application^.SetScreenVideoMode(vm);
end;

var
  a: TTestApp;

begin
  a.Init;
  a.Run;
  a.Done;
end.

I am glad to have found a solution to  that problem.
My projects are on Gitlab and on Codeberg.

 

TinyPortal © 2005-2018