00001
00002 #include "video.h"
00003 #include "termlib.h"
00004
00005 static void cpy_row ( int dest_row, int src_row, int left_col, int right_col );
00006 static void cpy_col ( int dest_col, int src_col, int top_row, int bot_row );
00007 static void clr_col ( int col, int attrib, int top_row, int bot_row );
00008 static void clr_row ( int row, int attrib, int left_col, int right_col );
00009
00010 static void cpy_row(int dest_row,int src_row,int left_col,int right_col )
00011 {
00012
00013
00014
00015
00016 CHARACTER *s ;
00017 CHARACTER *d ;
00018
00019 d = & SCREEN[ dest_row ][ left_col ];
00020 s = & SCREEN[ src_row ][ left_col ];
00021
00022 while( left_col++ <= right_col )
00023 *d++ = *s++;
00024 }
00025
00026
00027
00028 static void cpy_col(int dest_col,int src_col,int top_row,int bot_row )
00029 {
00030
00031
00032
00033
00034 CHARACTER *s = & SCREEN[ top_row ][ src_col ];
00035 CHARACTER *d = & SCREEN[ top_row ][ dest_col ];
00036
00037 while( top_row++ <= bot_row )
00038 {
00039 *d = *s;
00040 d += NUMCOLS;
00041 s += NUMCOLS;
00042 }
00043 }
00044
00045
00046
00047 static void clr_row(int row,int attrib,int left_col,int right_col )
00048 {
00049
00050
00051
00052
00053 CHARACTER *p = & SCREEN[ row ][ left_col ];
00054
00055 while( left_col++ <= right_col )
00056 {
00057 (p )->letter = ' ';
00058 (p++)->attribute = attrib ;
00059 }
00060 }
00061
00062
00063
00064 static void clr_col(int col,int attrib,int top_row,int bot_row )
00065 {
00066
00067
00068
00069
00070 CHARACTER *p = & SCREEN[ top_row ][ col ];
00071
00072 while( top_row++ <= bot_row )
00073 {
00074 p->letter = ' ';
00075 p->attribute = attrib ;
00076 p += NUMCOLS ;
00077 }
00078 }
00079
00080
00081
00082
00083
00084
00085 void dv_scroll_line (int x_left,int x_right,int y_top,int y_bottom,int dir,int attrib )
00086 {
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 int i;
00100
00101 if( dir == 'u' )
00102 {
00103 for( i = y_top; i < y_bottom ; i++ )
00104 cpy_row( i, i+1, x_left, x_right );
00105 clr_row( y_bottom, attrib, x_left, x_right );
00106 }
00107 else if( dir == 'd' )
00108 {
00109 for( i = y_bottom; --i >= y_top ; )
00110 cpy_row( i+1, i, x_left, x_right );
00111 clr_row( y_top, attrib, x_left, x_right );
00112 }
00113 else if( dir == 'l' )
00114 {
00115 for( i = x_left; i < x_right; i++ )
00116 cpy_col( i, i+1, y_top, y_bottom );
00117 clr_col( x_right, attrib, y_top, y_bottom );
00118 }
00119 else
00120 {
00121 for( i = x_right; --i >= x_left ; )
00122 cpy_col( i+1, i, y_top, y_bottom );
00123 clr_col( x_left, attrib, y_top, y_bottom );
00124 }
00125 }
00126
00127
00128
00129 void dv_scroll(int x_left,int x_right,int y_top,int y_bottom,int amt,int attrib )
00130 {
00131
00132
00133
00134
00135 int dir = 'u';
00136
00137 if( amt < 0 )
00138 {
00139 amt = -amt;
00140 dir = 'd' ;
00141 }
00142 while( --amt >= 0 )
00143 dv_scroll_line( x_left, x_right, y_top, y_bottom, dir, attrib );
00144 }