Jump to content

VIO Tutorial (Hello, World): Difference between revisions

From EDM2
mNo edit summary
Ak120 (talk | contribs)
mNo edit summary
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_C_CPP_and_Fortran|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.


The following is a hello, world application for the eCS VIO API.
The following is a hello, world application for the eCS VIO API.
 
<code>
  #define INCL_VIO
  #define INCL_VIO
  #include <os2.h>
  #include <os2.h>
Line 19: Line 19:
  return rc;
  return rc;
  }
  }
   
</code>   
This can be compiled with OpenWatcom 1.3, as such: WCL386 vio.cpp, 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.


==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)
Line 31: Line 29:
* 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 39: Line 36:


==Color Example==
==Color Example==
 
<code>
  #define INCL_VIO
  #define INCL_VIO
  #include <os2.h>
  #include <os2.h>
Line 45: Line 42:
  int main( int argc, char *argv[] )
  int main( int argc, char *argv[] )
  {
  {
        char buffer[32] = {
    char buffer[32] = {
        'H', 12,      // intense red
        'H', 12,      // intense red
'e', 9,        // intense blue
        'e', 9,        // intense blue
        'l', 10,      // intense green
        'l', 10,      // intense green
                'l', 12,
        'l', 12,
                'o', 9,
        'o', 9,
                ',', 10,
        ',', 10,
                ' ', 0,
        ' ', 0,
                'i', 12,
        'i', 12,
                'n', 9,
        'n', 9,
                ' ', 0,
        ' ', 0,
                'c', 10,
        'c', 10,
                'o', 12,
        'o', 12,
                'l', 9,
        'l', 9,
                'o', 10,
        'o', 10,
                'r', 12,
        'r', 12,
                '!', 9 };
        '!', 9 };
   
   
        APIRET rc = VioWrtCellStr( buffer,
    APIRET rc = VioWrtCellStr( buffer,
                              32,        // Buffer length
        32,        // Buffer length
                              3,          // Row, 3 to allow some scrolling
        3,          // Row, 3 to allow some scrolling
                              0,          // Column
        0,          // Column
                              0 );        // VioHandle, must be 0
        0 );        // VioHandle, must be 0
   
   
        return rc;
    return rc;
  }
  }
</code>


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

Revision as of 18:39, 8 December 2016

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.

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;
}