欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

slvideo.c

一个C格式的脚本处理函数库源代码,可让你的C程序具有执行C格式的脚本文件
C
第 1 页 / 共 4 页
字号:
     asm  mov Attribute_Byte, ax     L2:   /* toggle the blink bit so we can use hi intensity background */   if (IsColor && !SLtt_Msdos_Cheap_Video)     {	asm  mov ax, 0x1003	  asm  mov bx, 0	  asm  int 0x10	  Blink_Killed = 1;     }   SLtt_Use_Ansi_Colors = IsColor;   SLtt_get_screen_size ();   SLtt_reset_scroll_region ();   fixup_colors ();   return 0;}void SLtt_beep (void){   int audible;			/* audible bell */   int special = 0;		/* first row to invert */   int visual = 0;		/* final row to invert */   if (!SLtt_Ignore_Beep) return;   audible = (SLtt_Ignore_Beep & 1);   if ( (SLtt_Ignore_Beep & 4) )     {	special = SLtt_Screen_Rows - 1;	visual = special--;	/* only invert bottom status line */     }   else if ( (SLtt_Ignore_Beep & 2) )     {	visual = SLtt_Screen_Rows;     }   if (visual) asm_video_invert_region (special, visual);   if (audible) sound (1500); delay (100); if (audible) nosound ();   if (visual) asm_video_invert_region (special, visual);}#endif				       /* IBMPC_ASM_VIDEO *//*}}}*/#ifdef GO32_VIDEO /*{{{*/# include <pc.h># define HAS_SAVE_SCREEN	1# ifdef HAS_SAVE_SCREENstatic void *Saved_Screen_Buffer;static int Saved_Cursor_Row;static void save_screen (void){   int row, col;   SLfree ((char *) Saved_Screen_Buffer);   Saved_Screen_Buffer = NULL;   Saved_Screen_Buffer = (short *) SLmalloc (sizeof (short) *				   ScreenCols () * ScreenRows ());   if (Saved_Screen_Buffer == NULL)     return;   ScreenRetrieve (Saved_Screen_Buffer);   ScreenGetCursor (&row, &col);   Saved_Cursor_Row = row;}static void restore_screen (void){   if (Saved_Screen_Buffer == NULL) return;   ScreenUpdate (Saved_Screen_Buffer);   goto_rc_abs (Saved_Cursor_Row, 0);}#endif				       /* HAS_SAVE_SCREEN */void SLtt_write_string (char *str){   while (Cursor_Col < SLtt_Screen_Cols)     {	char ch = *str++;	if (ch == 0)	  break;	ScreenPutChar (ch, Attribute_Byte, Cursor_Col, Cursor_Row);	Cursor_Col++;     }   goto_rc_abs (Cursor_Row, Cursor_Col);}void SLtt_goto_rc (int row, int col){   row += Scroll_r1;   if (row > SLtt_Screen_Rows) row = SLtt_Screen_Rows;   if (col > SLtt_Screen_Cols) col = SLtt_Screen_Cols;   ScreenSetCursor (row, col);   Cursor_Row = row;   Cursor_Col = col;}static void go32_video_getxy (void){   ScreenGetCursor (&Cursor_Row, &Cursor_Col);}static void go32_video_deleol (int x){   while (x < SLtt_Screen_Cols)     ScreenPutChar (32, Attribute_Byte, x++, Cursor_Row);}void SLtt_begin_insert (void){}void SLtt_end_insert (void){}void SLtt_delete_char (void){}void SLtt_erase_line (void){   Attribute_Byte = 0x07;   go32_video_deleol (0);   Current_Color = JNO_COLOR;		/* since we messed with attribute byte */}void SLtt_delete_nlines (int nlines){   union REGS r;   SLtt_normal_video ();   r.x.ax = nlines;   r.x.cx = 0;   r.h.ah = 6;   r.h.ch = Scroll_r1;   r.h.dl = SLtt_Screen_Cols - 1;   r.h.dh = Scroll_r2;   r.h.bh = Attribute_Byte;   int86 (0x10, &r, &r);}void SLtt_reverse_index (int nlines){   union REGS r;   SLtt_normal_video ();   r.h.al = nlines;   r.x.cx = 0;   r.h.ah = 7;   r.h.ch = Scroll_r1;   r.h.dl = SLtt_Screen_Cols - 1;   r.h.dh = Scroll_r2;   r.h.bh = Attribute_Byte;   int86 (0x10, &r, &r);}static void go32_video_invert_region (int top_row, int bot_row){   unsigned char buf [2 * 180 * 80];         /* 180 cols x 80 rows */   unsigned char *b, *bmax;   b    = buf + 1 + 2 * SLtt_Screen_Cols * top_row;   bmax = buf + 1 + 2 * SLtt_Screen_Cols * bot_row;   ScreenRetrieve (buf);   while (b < bmax)     {	*b ^= 0xFF;	b += 2;     }   ScreenUpdate (buf);}void SLtt_beep (void){   int audible;			/* audible bell */   int special = 0;		/* first row to invert */   int visual = 0;		/* final row to invert */   if (!SLtt_Ignore_Beep) return;   audible = (SLtt_Ignore_Beep & 1);   if ( (SLtt_Ignore_Beep & 4) )     {	special = SLtt_Screen_Rows - 1;	visual = special--;	/* only invert bottom status line */     }   else if ( (SLtt_Ignore_Beep & 2) )     {	visual = SLtt_Screen_Rows;     }   if (visual) go32_video_invert_region (special, visual);   if (audible) sound (1500); delay (100); if (audible) nosound ();   if (visual) go32_video_invert_region (special, visual);}void SLtt_del_eol (void){   if (Current_Color != JNO_COLOR) SLtt_normal_video ();   go32_video_deleol (Cursor_Col);}static voidwrite_attributes (SLsmg_Char_Type *src, unsigned int count){   register unsigned short pair;   unsigned int n;   /* write into a character/attribute pair */   n = Cursor_Col;   while (count)     {	pair = SLSMG_CHAR_TO_USHORT(*src);/* character/color pair */	src++;	SLtt_reverse_video (pair >> 8);	/* color change */	ScreenPutChar ((int)pair & 0xFF, Attribute_Byte, n, Cursor_Row);	n++;	count--;     }}/*----------------------------------------------------------------------*\ * Function:	void SLtt_cls (void);\*----------------------------------------------------------------------*/void SLtt_cls (void){   SLtt_normal_video ();   SLtt_reset_scroll_region ();   SLtt_goto_rc (0, 0);   SLtt_delete_nlines (SLtt_Screen_Rows);}void SLtt_putchar (char ch){   if (Current_Color) SLtt_normal_video ();   go32_video_getxy ();		/* get current position */   switch (ch)     {      case 7:			/* ^G - break */	SLtt_beep (); break;      case 8:			/* ^H - backspace */	goto_rc_abs (Cursor_Row, Cursor_Col - 1); break;      case 13:			/* ^M - carriage return */	goto_rc_abs (Cursor_Row, 0); break;      default:			/* write character to screen */	ScreenPutChar ((int) ch, Attribute_Byte, Cursor_Col, Cursor_Row);	goto_rc_abs (Cursor_Row, Cursor_Col + 1);     }}void SLtt_get_screen_size (void){   SLtt_Screen_Rows = ScreenRows ();   SLtt_Screen_Cols = ScreenCols ();}void SLtt_get_terminfo (void){   SLtt_get_screen_size ();}int SLtt_init_video (void){#ifdef HAS_SAVE_SCREEN   save_screen ();#endif   if (!Attribute_Byte) Attribute_Byte = 0x17;   IsColor = 1;			/* is it really? */   if (IsColor)     {	union REGS r;	r.x.ax = 0x1003; r.x.bx = 0;	int86 (0x10, &r, &r);	Blink_Killed = 1;     }   Cursor_Row = Cursor_Col = 0;   SLtt_Term_Cannot_Insert = 1;   SLtt_reset_scroll_region ();   SLtt_Use_Ansi_Colors = IsColor;   fixup_colors ();   return 0;}#endif				       /* GO32_VIDEO *//*}}}*/#ifdef EMX_VIDEO /*{{{*/# define INCL_VIO# define INCL_DOSPROCESS# include <os2.h># include <os2emx.h># include <sys/video.h>static VIOMODEINFO vioModeInfo;/* buffer to hold a line of character/attribute pairs */#define MAXCOLS 256static unsigned char Line_Buffer [MAXCOLS*2];/* this is how to make a space character */#define MK_SPACE_CHAR()	(((Attribute_Byte) << 8) | 0x20)void SLtt_write_string (char *str){   /* FIXME: Priority=medium    * This should not go to stdout. */   fputs (str, stdout);}void SLtt_goto_rc (int row, int col){   row += Scroll_r1;   if (row > SLtt_Screen_Rows) row = SLtt_Screen_Rows;   if (col > SLtt_Screen_Cols) col = SLtt_Screen_Cols;   v_gotoxy (col, row);   Cursor_Row = row;   Cursor_Col = col;}static void emx_video_getxy (void){   v_getxy (&Cursor_Col, &Cursor_Row);}static void emx_video_deleol (int x){   unsigned char *p, *pmax;   int count = SLtt_Screen_Cols - x;   int w = MK_SPACE_CHAR ();   p = Line_Buffer;   pmax = p + 2 * count;   while (p < pmax)     {	*p++ = (unsigned char) w;	*p++ = (unsigned char) (w >> 8);     }   v_putline (Line_Buffer, x, Cursor_Row, count);}void SLtt_begin_insert (void){   int n;   emx_video_getxy ();   n = SLtt_Screen_Cols - Cursor_Col;   v_getline (Line_Buffer, Cursor_Col, Cursor_Row, n);   v_putline (Line_Buffer, Cursor_Col+1, Cursor_Row, n - 1);}void SLtt_end_insert (void){}void SLtt_delete_char (void){   int n;   emx_video_getxy ();   n = SLtt_Screen_Cols - Cursor_Col - 1;   v_getline (Line_Buffer, Cursor_Col+1, Cursor_Row, n);   v_putline (Line_Buffer, Cursor_Col, Cursor_Row, n);}void SLtt_erase_line (void){   Attribute_Byte = 0x07;   emx_video_deleol (0);   Current_Color = JNO_COLOR;		/* since we messed with attribute byte */}void SLtt_delete_nlines (int nlines){   SLtt_normal_video ();   v_attrib (Attribute_Byte);   v_scroll (0, Scroll_r1, SLtt_Screen_Cols-1, Scroll_r2, nlines, V_SCROLL_UP);}void SLtt_reverse_index (int nlines){   SLtt_normal_video ();   v_attrib (Attribute_Byte);   v_scroll (0, Scroll_r1, SLtt_Screen_Cols-1, Scroll_r2, nlines,	     V_SCROLL_DOWN);}static void emx_video_invert_region (int top_row, int bot_row){   int row, col;   for (row = top_row; row < bot_row; row++)     {	v_getline (Line_Buffer, 0, row, SLtt_Screen_Cols);	for (col = 1; col < SLtt_Screen_Cols * 2; col += 2)	  Line_Buffer [col] ^= 0xff;	v_putline (Line_Buffer, 0, row, SLtt_Screen_Cols);     }}void SLtt_beep (void){   int audible;			/* audible bell */   int special = 0;		/* first row to invert */   int visual = 0;		/* final row to invert */   if (!SLtt_Ignore_Beep) return;   audible = (SLtt_Ignore_Beep & 1);   if ( (SLtt_Ignore_Beep & 4) )     {	special = SLtt_Screen_Rows - 1;	visual = special--;	/* only invert bottom status line */     }   else if ( (SLtt_Ignore_Beep & 2) )     {	visual = SLtt_Screen_Rows;     }   if (visual) emx_video_invert_region (special, visual);   if (audible) /*sound (1500)*/; _sleep2 (100); if (audible) /* nosound () */;   if (visual) emx_video_invert_region (special, visual);}void SLtt_del_eol (void){   if (Current_Color != JNO_COLOR) SLtt_normal_video ();   emx_video_deleol (Cursor_Col);}static voidwrite_attributes (SLsmg_Char_Type *src, unsigned int count){   register unsigned char *p = Line_Buffer;   register unsigned short pair;   int n = count;   /* write into a character/attribute pair */   while (n-- > 0)     {	pair = SLSMG_CHAR_TO_USHORT(*src);/* character/color pair */	src++;	SLtt_reverse_video (pair >> 8);	/* color change */	*(p++) = pair & 0xff;		/* character byte */	*(p++) = Attribute_Byte;	/* attribute byte */     }   v_putline (Line_Buffer, Cursor_Col, Cursor_Row, count);}void SLtt_cls (void){   SLtt_normal_video ();   SLtt_reset_scroll_region ();   SLtt_goto_rc (0, 0);   SLtt_delete_nlines (SLtt_Screen_Rows);}void SLtt_putchar (char ch){   if (Current_Color) SLtt_normal_video ();   emx_video_getxy ();		/* get current position */   switch (ch)     {      case 7:			/* ^G - break */	SLtt_beep (); break;      case 8:			/* ^H - backspace */	goto_rc_abs (Cursor_Row, Cursor_Col - 1); break;      case 13:			/* ^M - carriage return */	goto_rc_abs (Cursor_Row, 0); break;      default:			/* write character to screen */	v_putn (ch, 1);	goto_rc_abs (Cursor_Row, Cursor_Col + 1);     }}void SLtt_get_terminfo (void){   SLtt_get_screen_size ();}void SLtt_get_screen_size (void){   vioModeInfo.cb = sizeof(vioModeInfo);   VioGetMode (&vioModeInfo, 0);   SLtt_Screen_Cols = vioModeInfo.col;   SLtt_Screen_Rows = vioModeInfo.row;}int SLtt_init_video (void){   int OldCol, OldRow;   PTIB   ptib;   PPIB   ppib;   USHORT args[3] = { 6, 2, 1 };#ifdef HAS_SAVE_SCREEN   save_screen ();#endif   Cursor_Row = Cursor_Col = 0;   v_init ();   if ( v_hardware () != V_MONOCHROME ) IsColor = 1; else IsColor = 0;   v_getxy(&OldCol,&OldRow);   v_gotoxy (0, 0);   if (IsColor)     {	if (_osmode == OS2_MODE)	  {# if 0	     /* Enable high-intensity background colors */	     VIOINTENSITY RequestBlock;	     RequestBlock.cb = sizeof (RequestBlock);	     RequestBlock.type = 2; RequestBlock.fs = 1;	     VioSetState (&RequestBlock, 0);	/* nop if !fullscreen */# endif	  }     }   DosGetInfoBlocks (&ptib, &ppib);   if ((ppib->pib_ultype) == 2)        /* VIO */     Blink_Killed = 1;   else     {                              /* Fullscreen */        if (VioSetState (args, 0) == 0)	  Blink_Killed = 1;        else	  Blink_Killed = 0;     }   if (!Attribute_Byte)     {	/* find the attribute currently under the cursor */	v_getline (Line_Buffer, OldCol, OldRow, 1);	Attribute_Byte = Line_Buffer[1];	SLtt_set_color (JNORMAL_COLOR, NULL,			Color_Names[(Attribute_Byte) & 0xf],			Color_Names[(Attribute_Byte) >> 4]);     }   v_attrib (Attribute_Byte);   fixup_colors ();   SLtt_get_screen_size ();   SLtt_Use_Ansi_Colors = IsColor;   SLtt_reset_scroll_region ();   return 0;}#endif				       /* EMX_VIDEO *//*}}}*/#ifdef WIN32_VIDEO /*{{{*/

⌨️ 快捷键说明

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