home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Bila Vrana
/
BILA_VRANA.iso
/
007A
/
SVGACC24.ZIP
/
SVGADEM1.C
< prev
next >
Wrap
Text File
|
1996-01-30
|
38KB
|
1,443 lines
/****************************************************************************
'SVGACC' A Super Vga Graphics Library for use with Microsoft compatible
C/C++ compilers
Copyright 1993-1996 by Stephen L. Balkum and Daniel A. Sill
**************** UNREGISTERD SHAREWARE VERSION ***********************
* FOR EVUALATION ONLY. NOT FOR RESALE IN ANY FORM. SOFTWARE WRITTEN *
* USING THIS UNREGISTERED SHAREWARE GRAPHICS LIBRARY MAY NOT BY SOLD *
* OR USED FOR ANY PURPOSE OTHER THAN THE EVUALTION OF THIS LIBRARY. *
**********************************************************************
**************** NO WARRANTIES AND NO LIABILITY **********************
* Stephen L. Balkum and Daniel A. Sill provide no warranties, either *
* expressed or implied, of merchantability, or fitness, for a *
* particular use or purpose of this SOFTWARE and documentation. *
* In no event shall Stephen L. Balkum or Daniel A. Sill be held *
* liable for any damages resulting from the use or misuse of the *
* SOFTWARE and documentation. *
**********************************************************************
************** U.S. GOVERNMENT RESTRICTED RIGHTS *********************
* Use, duplication, or disclosure of the SOFTWARE and documentation *
* by the U.S. Government is subject to the restictions as set forth *
* in subparagraph (c)(1)(ii) of the Rights in Technical Data and *
* Computer Software cluse at DFARS 252.227-7013. *
* Contractor/manufacturer is Stephen L. Balkum and Daniel A. Sill, *
* P.O. Box 7704, Austin, Texas 78713-7704 *
**********************************************************************
**********************************************************************
* By using this SOFTWARE or documentation, you agree to the above *
* terms and conditions. *
**********************************************************************
***************************************************************************/
#define MODULE
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <math.h>
#include "svgacc.h"
#include "svgademo.h"
#define randnum(size) (rand() % (int)(size))
/***********
* DOBLOCK *
***********/
char doblock(void)
{
int i, colr;
int xinc, yinc, x1, y1, x2, y2;
int cntx, cnty;
char ret;
char title[TITLEN];
char buf[TITLEN];
RasterBlock far *gfxblk;
RasterBlock far *gfxblk2;
RasterBlock far *spritebkgnd;
/*
* Set up the Title
*/
sprintf(title,"DEMO 5: Block function and Sprites");
palset(pal,0,255);
/*
* Show Block Get (draw some circles and "get a chunk of them")
*/
fillscreen(0);
setview(0,0,maxx,maxy);
drwstring(SET,7,0,title,10,0);
sprintf(buf,"blkget(x1,y1,x2,y2,GfxBlock);");
drwstring(SET,7,0,buf,10,16);
colr = 16;
for(i=0;i<=maxx/2;i++) {
drwcircle(SET,colr,maxx/4+i,maxy/2,maxy/5);
colr+=2;
if(colr>255)
colr = 16;
}
xinc = maxx/20;
yinc = maxy/20;
x1 = maxx/2-xinc;
y1 = maxy/2-yinc;
x2 = maxx/2+xinc;
y2 = maxy/2+yinc;
i = (x2-x1+1)*(y2-y1+1)+4;
gfxblk = _fmalloc(i);
if (!gfxblk) {
restext();
printf("ERROR: Allocating memory for gfxblk: %d bytes\n",i);
exit(1);
}
drwbox(SET,0,x1,y1,x2,y2);
blkget(x1,y1,x2,y2,gfxblk);
ret = getkey();
if ((ret == 's') || (ret == 'q')) {
fillscreen(0);
_ffree(gfxblk);
return(ret);
}
/*
* Show Block Rotate and Sprite Stuff
*/
drwstring(SET,7,0,title,10,0);
sprintf(buf,"blkrotate(angle,backfill,GfxBlockSrc,GfxBlockDst);");
drwstring(SET,7,0,buf,10,16);
sprintf(buf,"spritegap(transcolor,x,y,SpriteArray,BkGndArray);");
drwstring(SET,7,0,buf,10,32);
sprintf(buf,"spriteput(transcolor,x,y,SpriteArray);");
drwstring(SET,7,0,buf,10,48);
cntx = (x2-x1) / 2 + x1;
cnty = (y2-y1) / 2 + y1;
fillarea(x1+2,y1+2,0,0);
i = blkrotatesize(45,gfxblk);
spritebkgnd = _fmalloc(i);
if (!spritebkgnd) {
restext();
printf("ERROR: Allocating memory for spritebkgnd: %d bytes\n",i);
exit(1);
}
gfxblk2 = _fmalloc(i);
if (!gfxblk2) {
restext();
printf("ERROR: Allocating memory for gfxblk2: %d bytes\n",i);
exit(1);
}
blkget(x1,y1,x2,y2,spritebkgnd);
setview(0,64,maxx,maxy);
for(i=0;i<=360;i+=4) {
blkrotate(i,1,gfxblk,gfxblk2);
spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-(spritebkgnd->height)/2,spritebkgnd);
spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2->height)/2,gfxblk2,spritebkgnd);
sdelay(4);
}
spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-(spritebkgnd->height)/2,spritebkgnd);
blkput(SET,x1,y1,gfxblk);
setview(0,0,maxx,maxy);
ret = getkey();
if ((ret == 's') || (ret == 'q')) {
fillscreen(0);
palset(pal,16,255);
_ffree(gfxblk);
_ffree(gfxblk2);
_ffree(spritebkgnd);
return(ret);
}
/*
* Show Block Resize and Sprite Stuff
*/
drwstring(SET,7,0,title,10,0);
sprintf(buf,"blkresize(Width,Height,GfxBlockSrc,GfxBlockDst);");
drwstring(SET,7,0,buf,10,16);
sprintf(buf,"spritegap(transcolor,x,y,SpriteArray,BkGndArray);");
drwstring(SET,7,0,buf,10,32);
sprintf(buf,"spriteput(transcolor,x,y,SpriteArray);");
drwstring(SET,7,0,buf,10,48);
fillarea(x1+2,y1+2,0,0);
blkget(x1,y1,x2,y2,spritebkgnd);
setview(0,64,maxx,maxy);
i = (x2-x1+1+xinc)*(y2-y1+1+xinc)+4;
spritebkgnd = _frealloc(spritebkgnd,i);
if (!spritebkgnd) {
restext();
printf("ERROR: reallocating memory for spritebkgnd: %d bytes\n",i);
exit(1);
}
gfxblk2 = _frealloc(gfxblk2,i);
if (!gfxblk2) {
restext();
printf("ERROR: reallocating memory for gfxblk2: %d bytes\n",i);
exit(1);
}
for(i=0;i<=xinc;i++) {
blkresize((gfxblk->width)-i,(gfxblk->height)-i,gfxblk,gfxblk2);
spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-(spritebkgnd->height)/2,spritebkgnd);
spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2->height)/2,gfxblk2,spritebkgnd);
sdelay(3);
}
spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-(spritebkgnd->height)/2,spritebkgnd);
for(i=xinc;i>=0;i--) {
blkresize((gfxblk->width)-i,(gfxblk->height)-i,gfxblk,gfxblk2);
spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-(spritebkgnd->height)/2,spritebkgnd);
spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2->height)/2,gfxblk2,spritebkgnd);
sdelay(3);
}
spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-(spritebkgnd->height)/2,spritebkgnd);
blkput(SET,x1,y1,gfxblk);
ret = getkey();
if ((ret == 's') || (ret == 'q')) {
fillscreen(0);
palset(pal,16,255);
setview(0,0,maxx,maxy);
_ffree(gfxblk);
_ffree(gfxblk2);
_ffree(spritebkgnd);
return(ret);
}
/*
* Show Block Put (put the "chunks" randomly around the screen)
*/
setview(0,16,maxx,32);
fillview(0);
sprintf(buf,"blkput(mode,x,y,GfxBlock);");
drwstring(SET,7,0,buf,10,16);
xinc = maxx/10;
yinc = maxy/10;
setview(0,32,maxx,maxy);
for(i=0;i<=maxx/2;i++) {
x1 = randnum(maxx + xinc) - xinc;
y1 = randnum(maxy + yinc) - yinc;
blkput(SET,x1,y1,gfxblk);
}
_ffree(gfxblk);
_ffree(gfxblk2);
_ffree(spritebkgnd);
setview(0,0,maxx,maxy);
ret = getkey();
if ((ret == 's') || (ret == 'q')) {
fillscreen(0);
return(ret);
}
return(ret);