VIO Tutorial (Hello, World): Difference between revisions
Appearance
mNo edit summary |
mNo edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
By [[User:Myrkraverk|Johann Oskarsson]] | ''By [[User:Myrkraverk|Johann Oskarsson]]'' | ||
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 [[ | |||
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 15: | Line 13: | ||
{ | { | ||
APIRET rc = VioWrtTTY( "Hello, VIO\n", // string to write | APIRET rc = VioWrtTTY( "Hello, VIO\n", // string to write | ||
11, // lenght of string to write | |||
0 ); // VIO handle, must be 0 | |||
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. | ||
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) | |||
* 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) | |||
* Bit 4: Blue (0x10) | * Bit 4: Blue (0x10) | ||
* Bit 5: Green (0x20) | * Bit 5: Green (0x20) | ||
Line 39: | Line 35: | ||
==Color Example== | ==Color Example== | ||
<code> | |||
#define INCL_VIO | #define INCL_VIO | ||
#include <os2.h> | #include <os2.h> | ||
Line 45: | Line 41: | ||
int main( int argc, char *argv[] ) | 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; | |||
} | } | ||
</code> | |||
[[Category: | [[Category:C Articles]] |
Latest revision as of 16:04, 14 December 2017
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.
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;
}