home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Vectronix 2
/
VECTRONIX2.iso
/
FILES_07
/
LATTIC_3.ZIP
/
EXAMPLES
/
ROCP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-01-28
|
4KB
|
162 lines
/*
* rocp - fully configure the machine after the style of the control panel
*
* Started 1/3/89 Alex G. Kiernan
*
* Compile using:
*
* lc -v -w -csfm -O -Lavg rocp
*
* Copyright (c) 1990 HiSoft
*/
#include <aes.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
enum {EVD_GET,EVD_SET};
void rocp(const char *p)
{
char *q;
if (q=strstr(p,"#a")) /* find start of rs232 info */
{
int flowctl, parity, bits;
char speed;
unsigned long rsstat;
union
{
struct
{
unsigned u_d:1;
unsigned u_l:2;
unsigned u_as:2;
unsigned u_pe:1;
unsigned u_po:1;
unsigned :1;
} b;
short w;
} ucr;
/* We ignore the duplex and strip bits since these are the
preserve of the VT52 emulator */
sscanf(q,"#a%*1d%c%1d%1d%1d%*1d",
&speed,
&parity,
&bits,
&flowctl);
speed-='0'; /* adjust speed to give 0..15 */
rsstat=Rsconf(speed,flowctl,-1,-1,-1,-1);
ucr.w=(rsstat >> 24); /* fetch ucr value */
ucr.b.u_l=bits;
if (parity)
{
ucr.b.u_po=parity-2;
ucr.b.u_pe=1;
}
else
ucr.b.u_pe=0;
Rsconf(-1,-1,ucr.w,-1,-1,-1);
}
if (q=strstr(p,"#b")) /* find start of printer info */
{
int type, colour, density, quality, port, paper;
sscanf(q,"#b%1d%1d%1d%1d%1d%1d",
&type,
&colour,
&density,
&quality,
&port,
&paper);
/* Expand the bits into the right place in the word */
Setprt((((((((((((paper)<<1)|
port)<<1) |
quality)<<1) |
density)<<1) |
colour)<<1) |
type));
}
if (q=strstr(p,"#c")) /* find start of workstation info */
{
int dblclick, click, bell, delay, speed;
short col[16];
unsigned char oldconterm;
volatile unsigned char *conterm=0x484;
void *save_ssp;
/* col[] info is fetched in a funny order to allow for the
way the VDI maps logical to physical colours */
sscanf(q,"#c"
"%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx%3hx"
"%1d%1d%1d%2d%2d",
&col[0],&col[15],&col[1],&col[2],
&col[4],&col[6],&col[3],&col[5],
&col[7],&col[8],&col[9],&col[10],
&col[12],&col[14],&col[11],&col[13],
&dblclick,
&click,
&bell,
&delay,
&speed);
switch (Getrez()) /* fudge for different resolutions */
{
case 1: /* med res */
col[3]=col[15];
break;
case 2: /* hi res */
col[1]=col[15];
break;
}
Setpallete(col);
Vsync(); /* ensure palette set before stack is reused */
Kbrate(delay,speed);
evnt_dclick(dblclick,EVD_SET);
save_ssp=Super(NULL);
oldconterm=(*conterm)&~0x05;
if (click)
oldconterm|=0x01;
if (bell)
oldconterm|=0x04;
*conterm=oldconterm;
Super(save_ssp);
}
}
int main(void)
{
char *p,*q;
int result=EXIT_FAILURE;
int size=256;
if (appl_init()!=-1)
{
while (result!=EXIT_SUCCESS)
{
int cnt;
if ((size<<=1)<0) /* double memory allocation */
break; /* shell info >32K */
if (!(p=malloc(size))) /* get some memory */
break; /* failed so give up */
shel_get(p,size); /* fetch shell information */
for (q=p, cnt=size; cnt--; ) /* find terminator */
if (*q++=='\x1a') /* found the CTRL Z */
{
*--q='\0'; /* replace with a NUL */
rocp(p); /* setup desktop */
result=EXIT_SUCCESS;
break;
}
free(p); /* release memory */
}
appl_exit();
}
return result;
}