tb1/svmwgraph/vmw_sprite.c

69 lines
1.9 KiB
C
Raw Normal View History

2000-09-16 04:49:00 +00:00
/* Sprite implementation for the Super VMW graphics library */
#include "svmwgraph.h"
#include <stdlib.h> /* for calloc/malloc */
vmwSprite *vmwGetSprite(int x, int y,
int xsize, int ysize,vmwVisual *screen) {
vmwSprite *temp_sprite;
int xtemp,ytemp;
temp_sprite=calloc(1,sizeof(vmwSprite));
temp_sprite->spritedata=calloc(1,xsize*ysize);
temp_sprite->xsize=xsize;
temp_sprite->ysize=ysize;
/* The following is very slow and can be easily optimized */
for(ytemp=0;ytemp<ysize;ytemp++)
for(xtemp=0;xtemp<xsize;xtemp++)
*((temp_sprite->spritedata)+ytemp*xsize+xtemp)=
vmwGetPixel(xtemp+x,ytemp+y,screen);
return temp_sprite;
}
2000-09-16 23:23:00 +00:00
void vmwPutSprite(vmwSprite *sprite,int x,int y,
2000-09-16 04:49:00 +00:00
vmwVisual *screen) {
unsigned char *temp_source,*temp_destination;
int xx,yy;
temp_source=sprite->spritedata;
2000-09-16 23:23:00 +00:00
temp_destination= (unsigned char *)(screen->memory)+(y*screen->xsize+x);
2000-09-16 04:49:00 +00:00
for (yy=0;yy<sprite->ysize;yy++) {
for (xx=0;xx<sprite->xsize;xx++) {
if (*temp_source!=0) {
*(temp_destination)=*(temp_source);
}
temp_source++;
temp_destination++;
}
temp_destination+=((screen->xsize-sprite->xsize));
}
}
void vmwPutPartialSprite(vmwVisual *destination,
vmwSprite *sprite,
int x_start,int y_start,
int x_stop, int y_stop)
{ /* x_start/stop not implemented yet */
// int xx,yy;
/*
* dest+=(dest_stride*y);
* for(yy=0;yy<h;yy++){
* for(xx=0;xx<w;xx++)
* if ((*(src+xx)) && ((yy>=y_start) && (yy<=y_stop)) )
* memcpy(dest+(stride_factor*(xx+x)),(src+xx),stride_factor);
* // **(dest+xx+x)=15;
* src+=w;
* dest+=dest_stride;
* }
* */
return;
}