⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_wsconsvideo.c

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 C
📖 第 1 页 / 共 2 页
字号:
  if (private->shadowFB) {    private->shadowmem = (Uint8 *)SDL_malloc(len);    if (private->shadowmem == NULL) {      WSCONS_ReportError("No memory for shadow");      return -1;    }    private->fbstart = private->shadowmem;    private->fblinebytes = width * ((private->info.depth + 7) / 8);  } else {     private->fbstart = private->physmem;    private->fblinebytes = private->physlinebytes;  }    private->SDL_modelist[0] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));  private->SDL_modelist[0]->w = width;  private->SDL_modelist[0]->h = height;  vformat->BitsPerPixel = private->info.depth;  vformat->BytesPerPixel = private->info.depth / 8;    if (WSCONS_InitKeyboard(this) == -1) {    return -1;  }    return 0;}SDL_Rect **WSCONS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags){  if (format->BitsPerPixel == private->info.depth) {    return private->SDL_modelist;  } else {    return NULL;  }}SDL_Surface *WSCONS_SetVideoMode(_THIS, SDL_Surface *current,				 int width, int height, int bpp, Uint32 flags){  if (width != private->SDL_modelist[0]->w ||       height != private->SDL_modelist[0]->h) {    WSCONS_ReportError("Requested video mode %dx%d not supported.",		       width, height);    return NULL;  }  if (bpp != private->info.depth) {    WSCONS_ReportError("Requested video depth %d bpp not supported.", bpp);    return NULL;  }  if (!SDL_ReallocFormat(current, 			 bpp, 			 private->redMask,			 private->greenMask,			 private->blueMask,			 0)) {    WSCONS_ReportError("Couldn't allocate new pixel format");    return NULL;  }  current->flags &= SDL_FULLSCREEN;  if (private->shadowFB) {    current->flags |= SDL_SWSURFACE;  } else {    current->flags |= SDL_HWSURFACE;  }  current->w = width;  current->h = height;  current->pitch = private->fblinebytes;  current->pixels = private->fbstart;  SDL_memset(private->fbstart, 0, private->fbmem_len);  return current;}static int WSCONS_AllocHWSurface(_THIS, SDL_Surface *surface){  return -1;}static void WSCONS_FreeHWSurface(_THIS, SDL_Surface *surface){}static int WSCONS_LockHWSurface(_THIS, SDL_Surface *surface){  return 0;}static void WSCONS_UnlockHWSurface(_THIS, SDL_Surface *surface){}static void WSCONS_blit16(Uint8 *byte_src_pos,			  int srcRightDelta, 			  int srcDownDelta, 			  Uint8 *byte_dst_pos,			  int dst_linebytes,			  int width,			  int height){  int w;  Uint16 *src_pos = (Uint16 *)byte_src_pos;  Uint16 *dst_pos = (Uint16 *)byte_dst_pos;  while (height) {    Uint16 *src = src_pos;    Uint16 *dst = dst_pos;    for (w = width; w != 0; w--) {      *dst = *src;      src += srcRightDelta;      dst++;    }    dst_pos = (Uint16 *)((Uint8 *)dst_pos + dst_linebytes);    src_pos += srcDownDelta;    height--;  }}#define BLOCKSIZE_W 32#define BLOCKSIZE_H 32static void WSCONS_blit16blocked(Uint8 *byte_src_pos,				 int srcRightDelta, 				 int srcDownDelta, 				 Uint8 *byte_dst_pos,				 int dst_linebytes,				 int width,				 int height){  int w;  Uint16 *src_pos = (Uint16 *)byte_src_pos;  Uint16 *dst_pos = (Uint16 *)byte_dst_pos;  while (height > 0) {    Uint16 *src = src_pos;    Uint16 *dst = dst_pos;    for (w = width; w > 0; w -= BLOCKSIZE_W) {      WSCONS_blit16((Uint8 *)src,		    srcRightDelta,		    srcDownDelta,		    (Uint8 *)dst,		    dst_linebytes,		    min(w, BLOCKSIZE_W),		    min(height, BLOCKSIZE_H));      src += srcRightDelta * BLOCKSIZE_W;      dst += BLOCKSIZE_W;    }    dst_pos = (Uint16 *)((Uint8 *)dst_pos + dst_linebytes * BLOCKSIZE_H);    src_pos += srcDownDelta * BLOCKSIZE_H;    height -= BLOCKSIZE_H;  }}static void WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect *rects){  int width = private->SDL_modelist[0]->w;  int height = private->SDL_modelist[0]->h;  int bytesPerPixel = (private->info.depth + 7) / 8;  int i;  if (!private->shadowFB) {    return;  }  if (private->info.depth != 16) {    WSCONS_ReportError("Shadow copy only implemented for 16 bpp");    return;  }  for (i = 0; i < numrects; i++) {    int x1, y1, x2, y2;    int scr_x1, scr_y1, scr_x2, scr_y2;    int sha_x1, sha_y1;    int shadowRightDelta;  /* Address change when moving right in dest */    int shadowDownDelta;   /* Address change when moving down in dest */    Uint8 *src_start;    Uint8 *dst_start;    x1 = rects[i].x;     y1 = rects[i].y;    x2 = x1 + rects[i].w;     y2 = y1 + rects[i].h;    if (x1 < 0) {      x1 = 0;    } else if (x1 > width) {      x1 = width;    }    if (x2 < 0) {      x2 = 0;    } else if (x2 > width) {      x2 = width;    }    if (y1 < 0) {      y1 = 0;    } else if (y1 > height) {      y1 = height;    }    if (y2 < 0) {      y2 = 0;    } else if (y2 > height) {      y2 = height;    }    if (x2 <= x1 || y2 <= y1) {      continue;    }    switch (private->rotate) {      case WSCONS_ROTATE_NONE:	sha_x1 = scr_x1 = x1;	sha_y1 = scr_y1 = y1;	scr_x2 = x2;	scr_y2 = y2;	shadowRightDelta = 1;	shadowDownDelta = width;	break;      case WSCONS_ROTATE_CCW:	scr_x1 = y1;	scr_y1 = width - x2;	scr_x2 = y2;	scr_y2 = width - x1;	sha_x1 = x2 - 1;	sha_y1 = y1;	shadowRightDelta = width;	shadowDownDelta = -1;	break;      case WSCONS_ROTATE_UD:	scr_x1 = width - x2;	scr_y1 = height - y2;	scr_x2 = width - x1;	scr_y2 = height - y1;	sha_x1 = x2 - 1;	sha_y1 = y2 - 1;	shadowRightDelta = -1;	shadowDownDelta = -width;	break;      case WSCONS_ROTATE_CW:	scr_x1 = height - y2;	scr_y1 = x1;	scr_x2 = height - y1;	scr_y2 = x2;	sha_x1 = x1;	sha_y1 = y2 - 1;	shadowRightDelta = -width;	shadowDownDelta = 1;	break;      default:	WSCONS_ReportError("Unknown rotation");	return;    }    src_start = private->shadowmem + (sha_y1 * width + sha_x1) * bytesPerPixel;    dst_start = private->physmem + scr_y1 * private->physlinebytes +       scr_x1 * bytesPerPixel;    private->blitFunc(src_start,		      shadowRightDelta, 		      shadowDownDelta, 		      dst_start,		      private->physlinebytes,		      scr_x2 - scr_x1,		      scr_y2 - scr_y1);  }}int WSCONS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors){  return 0;}/* * Note: If we are terminated, this could be called in the middle of * another SDL video routine -- notably UpdateRects. */void WSCONS_VideoQuit(_THIS){  int mode = WSDISPLAYIO_MODE_EMUL;  if (private->shadowmem != NULL) {    SDL_free(private->shadowmem);    private->shadowmem = NULL;  }  private->fbstart = NULL;  if (this->screen != NULL) {    this->screen->pixels = NULL;  }  if (private->SDL_modelist[0] != NULL) {    SDL_free(private->SDL_modelist[0]);    private->SDL_modelist[0] = NULL;  }  if (ioctl(private->fd, WSDISPLAYIO_SMODE, &mode) == -1) {    WSCONS_ReportError("ioctl SMODE");  }  WSCONS_ReleaseKeyboard(this);  if (private->fd != -1) {    close(private->fd);    private->fd = -1;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -