| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Vio Screen Modes. |
PR> Is there a snippit or something with a very
PR> small example of switching screen resolutions. I need
PR> something to detect the current screen resolution,
PR> then switch to 43/50 line mode (other resolutions
PR> would also be nice, like 28, ... but *only* 80
PR> columns). If this is WAY too easy to bother with than
PR> don't. I am asking this question to save myself time.
Tip: if you are writing a text mode app, by default always be prepared to
use the video mode the user has set up. Setting the mode under os/2 can be
much more than just setting the number of rows&cols; the density of
the font can change too -- and a call to VioSetMode (even to set the same
number of rows & cols) can screw this up (especially if you are using
bvhsvga.dll).
If you are using bvhsvga (look for this word in config.sys), typing
"mode 80,34" (my fav mode) will pick a crappy font, whereas this
little program will select the correct font (and the one that
bvhVHA uses):
// usage: "mode2 34" (or 30, others).
#define INCL_VIO
#define INCL_NOPMAPI
#include
#include
#include
#include
void main(int argc, char **argv)
{
VIOMODEINFO vi, om;
USHORT rc;
VioSetCurPos(0, 0, 0);
memset(&vi, 0, sizeof(vi));
vi.cb = 12;
vi.fbType = 1;
vi.color = 4;
vi.col = 80;
vi.row = atoi(argv[1]);
vi.hres = 720;
vi.vres = 480;
rc = VioSetMode(&vi, 0);
if(!rc)
VioScrollUp(0, 0, -1, -1, -1, " \x7", 0);
printf("mode2 rc = %d\n", rc);
}
Moral of the story: don't call VioSetMode unless you absolutely have to;
call VetGetMode() instead, and use the size it returns.
Here is a program that will write a file named "out" with the
modes that your adapter supports:
#define INCL_VIO
#define INCL_NOPM
#include
#include
#include
#include
void main(void)
{
VIOMODEINFO vi, om;
int r, c;
USHORT rc;
FILE *of = fopen("out", "wt");
if(!of){
perror("out");
exit(3);
}
om.cb = sizeof(om);
VioGetMode(&om, 0);
VioScrollUp(0, 0, -1, -1, -1, " \x1b", 0);
VioSetCurPos(5, 0, 0);
memset(&vi, 0, sizeof(vi));
vi.cb = 8;
VioGetMode(&vi, 0);
for(c=1; c<201; c++){
for(r=1; r<66; r++){
printf("\t\t\t\t\t%3d, %3d\r", c, r);
vi.cb = 8; /*sizeof(vb);*/
/* vi.fbType = VGMT_OTHER;
vi.color = COLORS_16;*/
vi.col = c;
vi.row = r;
vi.hres = 720; // only seen if vi.cb == 12!!!
vi.vres = 480;
rc = VioSetMode(&vi, 0);
if(!rc){
vi.cb = sizeof(vi);
VioGetMode(&vi, 0);
fprintf(of, "%3d, %3d (%d x %d)\n", vi.col,
vi.row, vi.hres, vi.vres);
}
}
}
VioSetMode(&om, 0);
printf("om.cb = %d\n", om.cb );
printf("om.fbType = %d\n", om.fbType );
printf("om.color = %d\n", om.color );
printf("om.col = %d\n", om.col );
printf("om.row = %d\n", om.row );
printf("om.hres = %d\n", om.hres );
printf("om.vres = %d\n", om.vres );
printf("om.fmt_ID = %d\n", om.fmt_ID );
printf("om.attrib = %d\n", om.attrib );
printf("om.buf_addr = %Fp\n", om.buf_addr );
printf("om.buf_length = %ld\n", om.buf_length );
printf("om.full_length = %ld\n", om.full_length );
printf("om.partial_length = %ld\n", om.partial_length );
printf("om.ext_data_addr = %Fp\n", om.ext_data_addr );
}
nb: the sample programs above were written for a 16bit compiler, but I
can't see anything that would give you a problem for Watcom or Cset++.
--- Maximus/2 2.02p1
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 515 628 704 713/888 800/1 7877/2809 @PATH: 259/414 400 99 250/99 3615/50 396/1 270/101 105/103 42 712/515 @PATH: 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.