Video display modes: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
m (→‎{{header|REXX}}: added 2nd REXX version. -- ~~~~)
Line 17: Line 17:
This method only works in ''DOS prompt'' either under (native) DOS or Microsoft WINDOWS.
This method only works in ''DOS prompt'' either under (native) DOS or Microsoft WINDOWS.


<br>DOS (under Windows) will support:
===no checking for which OS===
* columns &nbsp; of &nbsp; '''11 ──&gt; 32,766''' &nbsp; (inclusive)
* lines &nbsp; &nbsp; &nbsp; &nbsp; of &nbsp; '''1 ──&gt; 32,766''' &nbsp; (inclusive)

===version 1: no checking for which OS===
<lang rexx>/*REXX program to switch video display modes based on columns and lines.*/
<lang rexx>/*REXX program to switch video display modes based on columns and lines.*/


Line 23: Line 27:
'MODE' "CON: COLS="cols 'LINES='lines
'MODE' "CON: COLS="cols 'LINES='lines
/*stick a fork in it, we're done.*/</lang>
/*stick a fork in it, we're done.*/</lang>
===checks for which OS===
===version 2: checks for which OS===
The prologue code (at the bottom of the program) is a collection of some general-purpose subroutines which determine:
The prologue code (at the bottom of the program) is a collection of some general-purpose subroutines which determine:
* which environment (operating system) the REXX interpreter is running under
* which environment (operating system) the REXX interpreter is running under

Revision as of 22:45, 19 December 2012

Video display modes is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

The task is to demonstrate how to switch video display modes within the language. A brief description of the supported video modes would be useful.

Locomotive Basic

The Amstrad CPC464 supports three video modes:

  • Mode 0 - Graphics: 160x200 Text: 20x25 Colours: 16
  • Mode 1 - Graphics: 320x200 Text: 40x25 Colours: 4
  • Mode 2 - Graphics: 640x200 Text: 80x25 Colours: 2

Note that text can be displayed using conventional means in all display modes.

<lang locobasic>10 MODE 0: REM switch to mode 0</lang>

REXX

This method only works in DOS prompt either under (native) DOS or Microsoft WINDOWS.


DOS (under Windows) will support:

  • columns   of   11 ──> 32,766   (inclusive)
  • lines         of   1 ──> 32,766   (inclusive)

version 1: no checking for which OS

<lang rexx>/*REXX program to switch video display modes based on columns and lines.*/

parse arg cols lines . 'MODE' "CON: COLS="cols 'LINES='lines

                                      /*stick a fork in it, we're done.*/</lang>

version 2: checks for which OS

The prologue code (at the bottom of the program) is a collection of some general-purpose subroutines which determine:

  • which environment (operating system) the REXX interpreter is running under
  • if Windows/NT/XP/Vista/7/8 (the NT family) is running
  • which REXX is being executed
  • what literal to use to obtain the environmental variables (for the value bif)
  • what the fileName, fileType/fileExt, fileMode/path is of the REXX program
  • which command to use to clear the terminal screen
  • invokes $H to show general documentation (1st and only arg = ?)
  • invokes $H to show a flow diagram (1st and only arg = ?FLOW)
  • invokes $H to show sample uses (1st and only arg = ?SAMPLE)
  • invokes $H to show the author & contact info (1st and only arg = ?AUTHOR)

All the prologue was left intact to give a general feel of the scope of the boilerplate code.
The prologue code is in many REXX programs and it's easier to keep them on one line for copying purposes and sorting. <lang rexx>/*REXX program to switch video display modes based on columns and lines.*/ parse arg !; if !all() then exit /*exit if documentation specified*/ if \!dos & \!os2 then exit /*if this isn't DOS, then exit. */

parse arg cols lines . 'MODE' "CON: COLS="cols 'LINES='lines

exit /*stick a fork in it, we're done.*/ /*══════════════════════════════════general 1-line subs═════════════════*/ !all:!!=!;!=space(!);upper !;call !fid;!nt=right(!var('OS'),2)=='NT';!cls=word('CLS VMFCLEAR CLRSCREEN',1+!cms+!tso*2);if arg(1)\==1 then return 0;if wordpos(!,'? ?SAMPLES ?AUTHOR ?FLOW')==0 then return 0;!call=']$H';call '$H' !fn !;!call=;return 1 !cal:if symbol('!CALL')\=="VAR" then !call=;return !call !env:!env='ENVIRONMENT';if !sys=='MSDOS'|!brexx|!r4|!roo then !env='SYSTEM';if !os2 then !env='OS2'!env;!ebcdic=1=='f0'x;return !fid:parse upper source !sys !fun !fid . 1 . . !fn !ft !fm .;call !sys;if !dos then do;_=lastpos('\',!fn);!fm=left(!fn,_);!fn=substr(!fn,_+1);parse var !fn !fn '.' !ft;end;return word(0 !fn !ft !fm,1+('0'arg(1))) !rex:parse upper version !ver !vernum !verdate .;!brexx='BY'==!vernum;!kexx='KEXX'==!ver;!pcrexx='REXX/PERSONAL'==!ver|'REXX/PC'==!ver;!r4='REXX-R4'==!ver;!regina='REXX-REGINA'==left(!ver,11);!roo='REXX-ROO'==!ver;call !env;return !sys:!cms=!sys=='CMS';!os2=!sys=='OS2';!tso=!sys=='TSO'|!sys=='MVS';!vse=!sys=='VSE';!dos=pos('DOS',!sys)\==0|pos('WIN',!sys)\==0|!sys=='CMD';call !rex;return !var:call !fid;if !kexx then return space(dosenv(arg(1)));return space(value(arg(1),,!env))</lang>

UNIX Shell

If the system runs X11 and supports XRANDR, then

<lang bash>$ xrandr -q</lang>

lists the available modes, and

<lang bash>$ xrandr -s 1024x768</lang>

sets the screen to the given size.

With modern LCD monitors, this feature is not very useful. These monitors have a single best mode, and the X server discovers and uses that mode by default. Smaller screen modes might work, but make a blurry picture.