home *** CD-ROM | disk | FTP | other *** search
- #include "CVIDEO.H"
-
- int Scaler(int a,int b,int c);
- void CBuildScaleTable(int size,int tsize);
-
- // This table contains the translated x/y co-ordinates at this scaling size.
- static unsigned int ScaleTable[320];
-
- // C version of the assembly language putblit routine.
- // The algorithm is IDENTICAL to the assembly implementation.
- void far CPutBlit(char far *blit,int xloc,int yloc)
- {
- int far *temp;
- int width,height,i,j;
- char far *dest,far *base;
-
- temp = (int far *) blit;
- width = *temp++;
- height = *temp++;
- blit+=4;
-
- dest = 0xA0000000+yloc*320+xloc;
-
- for (i=0; i<height; i++)
- {
- base = dest;
- for (j=0; j<width; j++) *base++ = *blit++;
- dest+=320;
- }
- }
-
- int far CPutBlitSize(char far *blit,int xloc,int yloc,int size)
- {
- int far *temp;
- int width,height,i,j;
- int owidth,oheight,tsize;
- char far *dest,far *base;
- char far *blitbase;
-
- if ( size > FULLSIZE || size <= 0 ) return(0); // Unable to display blit.
- if ( size == FULLSIZE )
- CPutBlit(blit,xloc,yloc);
- else
- {
- temp = (int far *) blit;
- width = *temp++;
- height = *temp++;
- blit+=4;
-
- dest = 0xA0000000+(unsigned int)(yloc*320)+(unsigned int)xloc;
-
- owidth = Scaler(width,size,FULLSIZE); // Find the output width.
- oheight = Scaler(height,size,FULLSIZE); // Find the output width.
- if ( owidth > oheight )
- tsize = owidth;
- else
- tsize = oheight;
- CBuildScaleTable(size,tsize);
- for (i=0; i<oheight; i++)
- {
- base = dest;
- blitbase = blit+ScaleTable[i]*width;
- for (j=0; j<owidth; j++) *base++ = *(blitbase+ScaleTable[j]);
- dest+=320;
- }
-
- }
- return(1);
- }
-
- // Build scaling table of size passed for a total width of the table
- // size passed.
- void CBuildScaleTable(int size,int tsize)
- {
- long int accum;
- int i;
-
- size = 65536L/size;
- accum = 0;
- for (i=0; i<tsize; i++)
- {
- ScaleTable[i] = accum>>8; // Shift out fraction.
- accum+=size;
- }
- }
-
- int Scaler(int a,int b,int c)
- {
- return( (int) ( (long) a * (long) b / (long) c ) ) ;
- }
-