Jump to content

VIO Tutorial (Hello, World): Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
Ak120 (talk | contribs)
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
By [[User:Myrkraverk|Johann Oskarsson]]
''By [[User:Myrkraverk|Johann Oskarsson]]''
__TOC__
 
This is a short tutorial on writing text to the console, the basics, and then with some color and cursor positioning.
This is a short tutorial on writing text to the console, the basics, and then with some color and cursor positioning.
* All examples have been compiled with [[OpenWatcom]].
* All examples have been compiled with [[OpenWatcom]].
VIO is short for Video Input/Output, and is the console interface to eCS.
VIO is short for Video Input/Output, and is the console interface to eCS.


Line 21: Line 19:
</code>     
</code>     
This can be compiled with OpenWatcom 1.3, as such: <tt>WCL386 vio.cpp</tt>, assuming the file name of vio.cpp.
This can be compiled with OpenWatcom 1.3, as such: <tt>WCL386 vio.cpp</tt>, assuming the file name of vio.cpp.
Because of the non-standard style comments (double slash format) the option for the IBM C compiler should be: <tt>icc /Ss+ vio.c</tt>


==Character Attributes==
==Character Attributes==
===Lower Nibble: Character===
;Lower Nibble (Character)
* Bit 0: Blue (0x01)
* Bit 0: Blue (0x01)
* Bit 1: Green (0x02)
* Bit 1: Green (0x02)
* Bit 2: Red (0x04)
* Bit 2: Red (0x04)
* Bit 3: Intensity (0x08)
* Bit 3: Intensity (0x08)
 
;Higher Nibble (Background)
===Higher Nibble: Background===
* Bit 4: Blue (0x10)
* Bit 4: Blue (0x10)
* Bit 5: Green (0x20)
* Bit 5: Green (0x20)
Line 70: Line 69:
</code>
</code>


[[Category:Languages Articles]]
[[Category:C Articles]]

Latest revision as of 16:04, 14 December 2017

By Johann Oskarsson

This is a short tutorial on writing text to the console, the basics, and then with some color and cursor positioning.

VIO is short for Video Input/Output, and is the console interface to eCS.

The following is a hello, world application for the eCS VIO API.

#define INCL_VIO
#include <os2.h>

int main( int argc, char *argv[] )
{
	APIRET rc = VioWrtTTY( "Hello, VIO\n", // string to write
	                       11,             // lenght of string to write
	                       0 );            // VIO handle, must be 0
	return rc;
}

This can be compiled with OpenWatcom 1.3, as such: WCL386 vio.cpp, assuming the file name of vio.cpp.

Because of the non-standard style comments (double slash format) the option for the IBM C compiler should be: icc /Ss+ vio.c

Character Attributes

Lower Nibble (Character)
  • Bit 0: Blue (0x01)
  • Bit 1: Green (0x02)
  • Bit 2: Red (0x04)
  • Bit 3: Intensity (0x08)
Higher Nibble (Background)
  • Bit 4: Blue (0x10)
  • Bit 5: Green (0x20)
  • Bit 6: Red (0x40)
  • Bit 7: Blink/Intensity (0x80) (VioSetState)

Color Example

#define INCL_VIO
#include <os2.h>

int main( int argc, char *argv[] )
{
   char buffer[32] = {
       'H', 12,       // intense red
       'e', 9,        // intense blue
       'l', 10,       // intense green
       'l', 12,
       'o', 9,
       ',', 10,
       ' ', 0,
       'i', 12,
       'n', 9,
       ' ', 0,
       'c', 10,
       'o', 12,
       'l', 9,
       'o', 10,
       'r', 12,
       '!', 9 };

    APIRET rc = VioWrtCellStr( buffer,
        32,         // Buffer length
        3,          // Row, 3 to allow some scrolling
        0,          // Column
        0 );        // VioHandle, must be 0

    return rc;
}