title: FreePascal console video rows and columns
body: <p>I'm looking for a method to get the number of console video rows and columns under FPC.  I'm looking for the most portable way, but at least one that will work under Windows (and preferably also under Linux) will do.</p>
  
  <p>From the old Turbo Pascal days, I had written below functions but they won't compile under FPC, and being in assembler they are not very portable.</p>
  
  <pre><code>//Return the number of video rows
  function GetVideoY: Byte; assembler;
  asm
    mov     ax,$40
    mov     es,ax
    mov     al,es:$84
    inc     al
  end; { GetVideoY }
  
  //Return the number of video columns
  function GetVideoX: Byte; assembler;
  asm
    mov     ax,$40
    mov     es,ax
    mov     al,es:$4A
  end; { GetVideoX }
  </code></pre>
  
  <p>UPDATE:
  Based on the correct answer's suggestions the above routines become:</p>
  
  <pre><code>//Return the number of video rows
  function GetVideoY: Byte;
  begin
    GetVideoY := WindMaxY - WindMinY + 1;
  end;
  
  //Return the number of video columns
  function GetVideoX: Byte;
  begin
    GetVideoX := WindMaxX - WindMinX + 1;
  end;
  </code></pre>
  
  <p>I tried them both on Windows and Linux and they seem to work OK. Thanks.</p>