TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Peter Fitzsimmons
from: hugo landsman
date: 1995-03-27 17:37:22
subject: screen mode

hi Peter,

 * Re:
   to   John Poltorak

 P!>>  {at}c:\cmd\mode 80,34

 JP>> I have tried this, and it works fine when I select a 
 JP>> command prompt from the command prompts folder, but 
 JP>> ignores os2init if I just run START. Is there any way 
 JP>> round this?

 PF> The only thing I can think of is to change COMSPEC to your own
 PF> program,which sets the mode and then calls cmd.exe (since you can't
 PF> pass arguments with the COMSPEC env var).

 PF> Keep in mind that other programs will be using the COMSPEC var to find
 PF> the command interpreter,  so you may run into side effects.

O, I'm playing with such a beast (not exactly finished yet), and don't
think it uses the command interpreter to start the program.  At least, the
4START.BTM's output doesn't show up.  But then, I don't touch COMSPEC, I
use it to set the mode for program sessions that don't need a command
interpreter otherwise.

-=--------------------=-
#include 
#include 
#include 
#include 

#include 
#include 
#include 

#define INCL_VIO
#define INCL_DOSMISC
#define INCL_DOSPROCESS
#include 

#define VRQ_OVERSCAN 1
#define DO_M (1<<0)
#define DO_F (1<<1)
#define DO_B (1<<2)
#define DO_X (1<<3)
#define DO_P (1<<4)
#define DO_C (1<<5)

HVIO hVio = 0;
int rc;

void usage( void ) __attribute__((noreturn));
void usage( void )
{
  puts( "Usage: VIOX [-m] [-c] [-f] [-b] [-p,]
program [args]" );
  exit( rc );
}

void rcheck( int err )
{
  static char *buf;
  ULONG ul;

  if (!err) return;
  if (NULL == buf) buf = _tmalloc( 1024 );
  DosGetMessage( NULL, 0, buf, 1024, err, "OSO001.MSG", &ul );
  fprintf( stderr, "%.*s", (int)ul, buf );
  rc = EPERM;
}

void SetMode( PVIOMODEINFO pVmi, BOOL cls )
{
  USHORT len = pVmi->buf_length;
  PCH buf = _tmalloc( len );

  VioReadCellStr( buf, &len, 0, 0, hVio );
  rcheck( VioSetMode( pVmi, hVio ));
  VioGetMode( pVmi, hVio );
  VioScrollDn( 0, 0, -1, -1, -1, " \7", hVio );
  if (!cls) VioWrtCellStr( buf, len, 0, 0, hVio );
  _tfree( buf );   
}

inline
int SetFont( PVIOFONTINFO pVfi, PVIOMODEINFO pVmi )
{
  struct { USHORT cb; USHORT adapter; } vci = { sizeof vci };
  USHORT rows = pVmi->vres / pVfi->cyCell;
  if (rows != pVmi->row)
  {
 pVmi->row = rows;
 SetMode( pVmi, FALSE );
  }
  VioGetConfig( VIO_CONFIG_CURRENT, (PVIOCONFIGINFO)&vci, hVio );
  pVfi->cxCell = 8 + (vci.adapter > DISPLAY_EGA);
  return VioSetFont( pVfi, hVio );
}

int main( int argc, char **argv)
{
  int opt, act = 0;
  VIOMODEINFO vmi = { sizeof vmi };
  VIOOVERSCAN vos = { sizeof vos, VRQ_OVERSCAN };
  VIOFONTINFO vfi = { sizeof vfi, VGFI_GETCURFONT };
  struct {
 ULONG class;
 LONG delta;
  } dsp = { 0, 1 };
  PTIB pTib;
  PPIB pPib;

  VioGetMode( &vmi, hVio );
  VioGetState( &vos, hVio );
  VioGetFont( &vfi, hVio );
  DosGetInfoBlocks(&pTib,&pPib);
  _envargs( &argc, &argv, "VIOX" );
  _response( &argc, &argv );
  while (EOF != (opt = getopt( argc, argv, "m:f:b:p:qc" )))
  {
 switch (opt)
 {
   short v1, v2;
   int fh;
   long fl;
   void *vp;
#define Ibreak { rc = errno = EINVAL; perror( optarg ); break; }
   case 'm': if (EOF == sscanf( optarg,
"%*[^0-9]%hu%*[^0-9]%hu%*[^0-9]%hu%*[^0-9]%hu%*[^0-9]%hu%*[^0-9]%hu",
&v1, &v2, &vmi.col, &vmi.row, &vmi.hres, &vmi.vres
)) Ibreak;
    act |= DO_M;
    vmi.fbType = (UCHAR)v1;
    vmi.color = (UCHAR)v2;
    break;
#define Pbreak { rc = EINVAL; perror( optarg ); break; }
   case 'f': if (-1 == (fh = open( optarg, O_RDONLY|O_BINARY ))) Pbreak;
    if (-1 == (fl = filelength( fh ))) Pbreak;
    if (NULL == (vp = _tmalloc( fl ))) Pbreak;
    if (-1 == read( fh, vp, fl )) Pbreak;
    vfi.cyCell = (USHORT) (fl / 256);
    vfi.cbData = (USHORT)fl;
    vfi.pbData = _emx_32to16( vp );
    act |= DO_F;
    break;
   case 'p': if (EOF == sscanf( optarg,
"%*[^0-9]%lu%*[^0-9+-]%ld", &dsp.class, &dsp.delta ))
Ibreak;
    act |= DO_P;
    break;
   case 'b': if (EOF == sscanf( optarg, "%*[^0-9]%hu",
&vos.color )) Ibreak;
    act |= DO_B;
    break;
   case 'c': act |= DO_C;
    break;
   case 'q': printf( "-m%u,%u,%u,%u,%u,%u\n-f(%ux%u)\n-b%u\n",
vmi.fbType, vmi.color, vmi.col, vmi.row, vmi.hres, vmi.vres, vfi.cxCell,
vfi.cyCell, vos.color );
    exit( EXIT_SUCCESS );
 }
  } /* while */;
  if (optind < argc) act |= DO_X;
  if (!act || rc) usage();
  if (act & DO_M || act & DO_C ) SetMode( &vmi, act & DO_C );
  if (act & DO_F) rcheck( SetFont( &vfi, &vmi ));
  if (act & DO_B) rcheck( VioSetState( &vos, hVio ));
  if (act & DO_P) rcheck( DosSetPriority( PRTYS_PROCESSTREE, dsp.class,
dsp.delta, pPib->pib_ulpid ));
  if (act & DO_X) if (-1 == execvp( argv[optind], (const char*
const*)&argv[ optind ])) { perror( argv[ optind ]); rc = errno; }
  return rc;
}
-=----------------=-

Lots of EMXisms:-), but the 5120 bytes large .EXE does what I want (more or
less: delta doesn't get set, and I want to add some environment stuffing
too).

One question though: when expanding the screen size, I got all junk - most
often blinking - on the new portion of the screen before I added the
ScrollDn stuff.  Is that normal OS/2 beheaviour?  Or a bug in the ET4000
driver?

regards,
         hugo
* Origin: (2:283/608.5)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 283/608 6 1 512 280/801 24/24 396/1 270/101 105/103 42 712/515 711/808
@PATH: 711/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™.