void switchmode(void) { uint32_t saved; SDL_Surface *tmp = NULL; SDL_Surface *oldscreen; vgageti(0, 0, (uint8_t *)&tmp, 80, 200); oldscreen = screen; saved = addflag; if(addflag == 0) addflag = SDL_FULLSCREEN; else addflag = 0; if(setmode() == false) { addflag = saved; if(setmode() == false) { fprintf(stderr, "Fatal: failed to change videomode and"\ "fallback mode failed as well. Exitting.\n"); exit(1); } } SDL_SetColors(screen, tmp->format->palette->colors, 0, \ tmp->format->palette->ncolors); vgaputi(0, 0, (uint8_t *)&tmp, 80, 200); SDL_FreeSurface(tmp); SDL_FreeSurface(oldscreen); }
void vgaputim(int16_t x, int16_t y, int16_t ch, int16_t w, int16_t h) { SDL_Surface *tmp; SDL_Surface *mask; SDL_Surface *scr = NULL; uint8_t *tmp_pxl, *mask_pxl, *scr_pxl; int16_t realsize; int16_t i; tmp = ch2bmap(sprites[ch*2], w, h); mask = ch2bmap(sprites[ch*2+1], w, h); vgageti(x, y, (uint8_t *)&scr, w, h); realsize = scr->w * scr->h; tmp_pxl = (uint8_t *)tmp->pixels; mask_pxl = (uint8_t *)mask->pixels; scr_pxl = (uint8_t *)scr->pixels; for(i=0;i<realsize;i++) if(tmp_pxl[i] != 0xff) scr_pxl[i] = (scr_pxl[i] & mask_pxl[i]) | \ tmp_pxl[i]; vgaputi(x, y, (uint8_t *)&scr, w, h); tmp->pixels = NULL; /* We should NULL'ify these ppointers, or the VGLBitmapDestroy */ mask->pixels = NULL; /* will shoot itself in the foot by trying to dellocate statically */ SDL_FreeSurface(tmp);/* allocated arrays */ SDL_FreeSurface(mask); SDL_FreeSurface(scr); }
void vgaputim(int16_t x, int16_t y, int16_t ch, int16_t w, int16_t h) { VGLBitmap *tmp; VGLBitmap *mask; VGLBitmap *scr = NULL; int16_t realsize; int16_t i; tmp = ch2bmap(sprites[ch * 2], w, h); mask = ch2bmap(sprites[ch * 2 + 1], w, h); vgageti(x, y, (uint8_t *) & scr, w, h); realsize = scr->Xsize * scr->Ysize; for (i = 0; i < realsize; i++) if (tmp->Bitmap[i] != 0xff) scr->Bitmap[i] = (scr->Bitmap[i] & mask->Bitmap[i]) | \ tmp->Bitmap[i]; vgaputi(x, y, (uint8_t *) & scr, w, h); tmp->Bitmap = NULL; /* We should NULL'ify these ppointers, or the * VGLBitmapDestroy */ mask->Bitmap = NULL; /* will shoot itself in the foot by trying to * dellocate statically */ VGLBitmapDestroy(tmp); /* allocated arrays */ VGLBitmapDestroy(mask); VGLBitmapDestroy(scr); }
void vgatitle(void) { SDL_Surface *tmp=NULL; vgageti(0, 0, (uint8_t *)&tmp, 80, 200); gettitle(tmp->pixels); vgaputi(0, 0, (uint8_t *)&tmp, 80, 200); SDL_FreeSurface(tmp); }
void vgaclear(void) { SDL_Surface *tmp = NULL; vgageti(0, 0, (uint8_t *)&tmp, 80, 200); memset(tmp->pixels, 0x00, tmp->w*tmp->h); vgaputi(0, 0, (uint8_t *)&tmp, 80, 200); SDL_FreeSurface(tmp); }
void vgatitle(void) { SDL_Surface *tmp=NULL; vgageti(0, 0, (Uint3 *)&tmp, 80, 200); gettitle((unsigned char*)tmp->pixels); vgaputi(0, 0, (Uint3 *)&tmp, 80, 200); SDL_FreeSurface(tmp); }
void vgatitle(void) { VGLBitmap *tmp = NULL; vgageti(0, 0, (uint8_t *) & tmp, 80, 200); gettitle(tmp->Bitmap); vgaputi(0, 0, (uint8_t *) & tmp, 80, 200); VGLBitmapDestroy(tmp); }
int16_t vgagetpix(int16_t x, int16_t y) { VGLBitmap *tmp = NULL; uint16_t xi, yi; uint16_t i = 0; int16_t rval = 0; if ((x > 319) || (y > 199)) return (0xff); vgageti(x, y, (uint8_t *) & tmp, 1, 1); for (yi = 0; yi < tmp->Ysize; yi++) for (xi = 0; xi < tmp->Xsize; xi++) if (tmp->Bitmap[i++]) rval |= 0x80 >> xi; VGLBitmapDestroy(tmp); return (rval & 0xee); }
int16_t vgagetpix(int16_t x, int16_t y) { SDL_Surface *tmp = NULL; uint16_t xi,yi; uint16_t i = 0; int16_t rval = 0; uint8_t *pixels; if ((x > 319) || (y > 199)) return (0xff); vgageti(x, y, (uint8_t *)&tmp, 1, 1); pixels = (uint8_t *)tmp->pixels; for (yi=0;yi<tmp->h;yi++) for (xi=0;xi<tmp->w;xi++) if (pixels[i++]) rval |= 0x80 >> xi; SDL_FreeSurface(tmp); return(rval & 0xee); }
Sint4 vgagetpix(Sint4 x, Sint4 y) { SDL_Surface *tmp = NULL; Uint4 xi,yi; Uint4 i = 0; Sint4 rval = 0; Uint8 *pixels; if ((x > 319) || (y > 199)) return (0xff); vgageti(x, y, (Uint3 *)&tmp, 1, 1); pixels = (Uint8 *)tmp->pixels; for (yi=0;yi<tmp->h;yi++) for (xi=0;xi<tmp->w;xi++) if (pixels[i++]) rval |= 0x80 >> xi; SDL_FreeSurface(tmp); return(rval & 0xee); }