Exemple #1
0
void
vgaputi(int16_t x, int16_t y, uint8_t * p, int16_t w, int16_t h)
{
    VGLBitmap      *tmp;
    struct PendNode tmpn;
    struct PendNode *newn;
    static int pending_match = 0;

    tmpn.realx = virt2scrx(x);
    tmpn.realy = virt2scry(y);
    tmpn.realw = virt2scrw(w * 4);
    tmpn.realh = virt2scrh(h);
    newn = find_pending(&tmpn);
    if (newn == NULL) {
        newn = malloc(sizeof (struct PendNode));
        memset(newn, 0x00, (sizeof (struct PendNode)));

        newn->realx = tmpn.realx;
        newn->realy = tmpn.realy;
        newn->realw = tmpn.realw;
        newn->realh = tmpn.realh;

        pendappend(newn);
    } else {
        rect_merge(newn, &tmpn);
        pending_match += 1;
        if (pending_match < 10 || pending_match % 50 == 0) {
            fprintf(stderr, "vgaputi: pending_match = %d\n", pending_match);
        }
    }
    memcpy(&tmp, p, (sizeof(VGLBitmap *)));
    VGLBitmapCopy(tmp, 0, 0, sVGLDisplay, tmpn.realx, tmpn.realy, tmpn.realw, tmpn.realh);
}
Exemple #2
0
void vgaputi(int16_t x, int16_t y, uint8_t *p, int16_t w, int16_t h)
{
    SDL_Surface *tmp;
    SDL_Palette *reserv;
    struct PendNode *newn, *ptr;

    newn = malloc(sizeof(struct PendNode));
    memset(newn, 0x00, (sizeof(struct PendNode)));
    newn->rect.x = virt2scrx(x);
    newn->rect.y = virt2scry(y);
    newn->rect.w = virt2scrw(w * 4);
    newn->rect.h = virt2scrh(h);

    memcpy(&tmp, p, (sizeof(SDL_Surface *)));
    reserv = tmp->format->palette;
    tmp->format->palette = screen->format->palette;
    SDL_BlitSurface(tmp, NULL, screen, &newn->rect);
    tmp->format->palette = reserv;
    /*
     * Following piece of code comparing already pending updates with current with
     * main goal to prevent redrawing overlapping rectangles several times.
     */

    for (ptr = First; ptr != NULL; ptr = ptr->nextnode)
    {
        if ((newn->rect.x >= ptr->rect.x) &&
                (newn->rect.y >= ptr->rect.y) &&
                ((newn->rect.x + newn->rect.w) <= (ptr->rect.x + ptr->rect.w)) &&
                ((newn->rect.y + newn->rect.h) <= (ptr->rect.y + ptr->rect.h)))
        {
            free(newn);
            return;
        }
        else if ((newn->rect.x <= ptr->rect.x) &&
                 (newn->rect.y <= ptr->rect.y) &&
                 ((newn->rect.x + newn->rect.w) >= (ptr->rect.x + ptr->rect.w)) &&
                 ((newn->rect.y + newn->rect.h) >= (ptr->rect.y + ptr->rect.h)))
        {
            ptr->rect.x = newn->rect.x;
            ptr->rect.y = newn->rect.y;
            ptr->rect.w = newn->rect.w;
            ptr->rect.h = newn->rect.h;
            free(newn);
            return;
        }
    }

    if (pendnum == 0)
        First = newn;
    else
    {
        Last->nextnode = newn;
        newn->prevnode = Last;
    }

    Last = newn;
    pendnum++;
}
Exemple #3
0
SDL_Surface *ch2bmap(Uint3 *sprite, Sint4 w, Sint4 h)
{
	Sint4 realw, realh;
	SDL_Surface *tmp;

	realw = virt2scrw(w*4);
	realh = virt2scrh(h);
	tmp = SDL_CreateRGBSurfaceFrom(sprite, realw, realh, 8, realw, 0, 0, 0, 0);
	SDL_SetPaletteColors(tmp->format->palette, screen->format->palette->colors, 0, screen->format->palette->ncolors);
	return(tmp);
}
Exemple #4
0
SDL_Surface *ch2bmap(uint8_t *sprite, int16_t w, int16_t h)
{
	int16_t realw, realh;
	SDL_Surface *tmp;

	realw = virt2scrw(w*4);
	realh = virt2scrh(h);
	tmp = SDL_CreateRGBSurfaceFrom(sprite, realw, realh, 8, realw, 0, 0, 0, 0);
	SDL_SetColors(tmp, screen->format->palette->colors, 0, screen->format->palette->ncolors);
	
	return(tmp);
}
Exemple #5
0
VGLBitmap      *
ch2bmap(uint8_t * sprite, int16_t w, int16_t h)
{
    int16_t           realw, realh;
    VGLBitmap      *tmp;

    realw = virt2scrw(w * 4);
    realh = virt2scrh(h);
    tmp = VGLBitmapCreate(MEMBUF, realw, realh, NULL);
    tmp->Bitmap = sprite;

    return (tmp);
}
Exemple #6
0
void vgageti(int16_t x, int16_t y, uint8_t *p, int16_t w, int16_t h)
{
	SDL_Surface *tmp;
	SDL_Rect src;
	
	memcpy(&tmp, p, (sizeof (SDL_Surface *)));
	if (tmp != NULL)
		SDL_FreeSurface(tmp); /* Destroy previously allocated bitmap */

	src.x = virt2scrx(x);
	src.y = virt2scry(y);
	src.w = virt2scrw(w*4);
	src.h = virt2scrh(h);

	tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, src.w, src.h, 8, 0, 0, 0, 0);
	SDL_SetColors(tmp, screen->format->palette->colors, 0, screen->format->palette->ncolors);	
	SDL_BlitSurface(screen, &src, tmp, NULL);
	memcpy(p, &tmp, (sizeof (SDL_Surface *)));
}
Exemple #7
0
void
vgageti(int16_t x, int16_t y, uint8_t * p, int16_t w, int16_t h)
{
    struct PendNode *ptr;
    VGLBitmap      *tmp;
    int16_t           realx, realy, realh, realw;

    memcpy(&tmp, p, (sizeof(VGLBitmap *)));
    if (tmp != NULL)
	VGLBitmapDestroy(tmp);	/* Destroy previously allocated bitmap */

    realx = virt2scrx(x);
    realy = virt2scry(y);
    realw = virt2scrw(w * 4);
    realh = virt2scrh(h);

    tmp = VGLBitmapCreate(MEMBUF, realw, realh, NULL);
    VGLBitmapAllocateBits(tmp);
    VGLBitmapCopy(sVGLDisplay, realx, realy, tmp, 0, 0, realw, realh);

    memcpy(p, &tmp, (sizeof(VGLBitmap *)));
}