VIO Tutorial (Hello, World): Difference between revisions
Appearance
mNo edit summary |
mNo edit summary |
||
Line 16: | Line 16: | ||
APIRET rc = VioWrtTTY( "Hello, VIO\n", // string to write | APIRET rc = VioWrtTTY( "Hello, VIO\n", // string to write | ||
11, // lenght of string to write | 11, // lenght of string to write | ||
0 ); // VIO handle, must be 0 | |||
return rc; | return rc; | ||
} | } |
Revision as of 15:20, 22 May 2012
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.
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; }