Recent

Author Topic: Using the CRT unit in a console program -- GoToXY(24,80) scrolls up.  (Read 4084 times)

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 750
I'm using linux/ubuntu and the CRT unit in a console program.  The terminal accessed with CRT iprovides 24 lines with 80 characters per line.  If I execute

Code: Pascal  [Select][+][-]
  1. GoToXY(24,80); //Wrong -- should be 80,24 as marcov noted!
  2. write('X');
  3.  

the terminal displays an X on line 24, column 80, but it also causes the terminal to scroll up one line.  Is there a way to defeat the scrolling action?  It's been a long time since I played with the CRT unit -- I'm sure this is an ancient problem, but I can't remember the solution.  Hoping someone here remembers it  :)
« Last Edit: August 21, 2025, 05:06:41 pm by Curt Carpenter »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12845
  • FPC developer.
Re: Using the CRT unit in a console program -- GoToXY(24,80) scrolls up.
« Reply #1 on: August 21, 2025, 08:56:44 am »
Not really (and it is gotoxy(80,24) btw).  Typically if you want to do fullscreen drawing, the video unit is recommended.

cdbc

  • Hero Member
  • *****
  • Posts: 2776
    • http://www.cdbc.dk
Re: Using the CRT unit in a console program -- GoToXY(24,80) scrolls up.
« Reply #2 on: August 21, 2025, 09:14:58 am »
Hi Curt
I fiddled with 'crt' a while ago, you're welcome to have my findings...
I do seem to remember, having the terminal-window 1 line bigger than the "crt-viewport" to avoid the scrolling...
Attached you'll find some stuff to play with ;)
eta: for the demo to run un-garbled, you'll have to make your terminal window 97x31 cols/lines...  :D
Regards Benny
« Last Edit: August 21, 2025, 10:05:12 am by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 750
Re: Using the CRT unit in a console program -- GoToXY(24,80) scrolls up.
« Reply #3 on: August 21, 2025, 05:05:14 pm »
Not really (and it is gotoxy(80,24) btw).  Typically if you want to do fullscreen drawing, the video unit is recommended.
Yes, (80,24) -- sorry.  I'll look into the video unit.

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 750
Re: Using the CRT unit in a console program -- GoToXY(24,80) scrolls up.
« Reply #4 on: August 21, 2025, 05:08:17 pm »
Hi Curt
I fiddled with 'crt' a while ago, you're welcome to have my findings...
I do seem to remember, having the terminal-window 1 line bigger than the "crt-viewport" to avoid the scrolling...
Attached you'll find some stuff to play with ;)
eta: for the demo to run un-garbled, you'll have to make your terminal window 97x31 cols/lines...  :D
Regards Benny
I'll look at the code Benny, thanks.  Had forgotten how much fun it was to work with a text-only CRT screen!

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12845
  • FPC developer.
Re: Using the CRT unit in a console program -- GoToXY(24,80) scrolls up.
« Reply #5 on: August 21, 2025, 05:43:26 pm »
Not really (and it is gotoxy(80,24) btw).  Typically if you want to do fullscreen drawing, the video unit is recommended.
Yes, (80,24) -- sorry.  I'll look into the video unit.

There is a tetris in the FPC demoes, and of course the turbo/free vision (including the textmode IDE) also uses it.

Warfley

  • Hero Member
  • *****
  • Posts: 2056
Re: Using the CRT unit in a console program -- GoToXY(24,80) scrolls up.
« Reply #6 on: August 21, 2025, 05:50:52 pm »
You can also check out my LazTermUtils library, you can take a look at the color example, which prints the whole screen at like 60-100 fps (on linux, on windows only 30, because the windows terminal is very slow). So you can use it to make games if you want to 😅

https://github.com/Warfley/LazTermUtils/blob/master/example/Colortest.lpr

 

TinyPortal © 2005-2018