home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
cxlxplod.zip
/
WXOPEN.C
< prev
Wrap
Text File
|
1989-06-11
|
2KB
|
81 lines
/* WXOPEN.C - opens an exploding window */
#include <stdlib.h>
#include "cxldef.h"
#include "cxlvid.h"
#include "cxlwin.h"
#include "cxlxwin.h"
static void error_exit (int errnum);
/* error message table */
static char *error_text[]= {
NULL, /* errnum = 0, no error */
NULL, /* errnum == 1, windowing error */
"Syntax: CXLDEMO [-switches]\n\n"
"\t -c = CGA snow reduction\n"
"\t -b = BIOS screen writing\n"
"\t -m = force monochrome text attributes",
"Memory allocation error"
};
WINDOW wxopen(int srow,int scol,int erow,int ecol,int btype,int battr,int wattr)
{
struct _wxrec_t *wxrec;
register int count;
int tone = 500;
int xsrow, xscol, xerow, xecol, delta;
WINDOW xwindow;
/* allocate memory for new record */
wxrec = malloc(sizeof(struct _wxrec_t));
if(wxrec == NULL) {
return(0);
}
/* add new record to linked list */
if(_wxinfo.active != NULL)_wxinfo.active->next = wxrec;
wxrec->prev = _wxinfo.active;
wxrec->next = NULL;
_wxinfo.active = wxrec;
_wxinfo.total++;
_wxinfo.active->wxnum = 0;
/* calculate number of windows to explode */
count = (erow - srow)/2;
delta = (ecol - scol)/(count * 2);
/* explode each window */
for(--count;count > 0 ;count--) {
xsrow = srow + count;
xscol = scol + (delta * count);
xerow = erow - count;
xecol = ecol - (delta * count);
if(!wopen(xsrow,xscol,xerow,xecol,btype,battr,wattr))error_exit(1);
sound_(tone+=100,1);
_wxinfo.active->wxnum++;
}
if(!(xwindow=wopen(srow,scol,erow,ecol,btype,battr,wattr)))error_exit(1);
_wxinfo.active->wxnum++;
_wxinfo.active->wxtone = tone;
sound_(tone,1);
/* Normal return */
return(xwindow);
}
/*---------------------------------------------------------------------------*/
/* this function handles abnormal termination. If it is passed an */
/* error code of 1, then it is a windowing system error. Otherwise */
/* the error message is looked up in the error message table. */
static void error_exit(int errnum)
{
if(errnum) {
printf("\n%s\n",(errnum==1)?werrmsg():error_text[errnum]);
exit(errnum);
}
}