@@ -4,10 +4,13 @@ extern void _low_put_char(char c, unsigned char color, unsigned int xy);
44
55extern void _low_vga_copy_step (unsigned int xy1 , unsigned int xy2 , unsigned int count );
66
7+ extern _low_flush (unsigned short * buffer , int count );
8+
79static int location_xy = 0 ;
810
911int IO_CURRENT_X = 0 ;
1012int IO_CURRENT_Y = 0 ;
13+ unsigned short buffer [TEXT_WINDOW_HEIGHT * TEXT_WINDOW_WIDTH ] = {0 };
1114
1215int get_display_text_x () {
1316 return IO_CURRENT_X ;
@@ -38,40 +41,40 @@ void io_low_scroll_screen(char count, unsigned char color,
3841 int x2 , int y2 ) {
3942 if (count == 0 ) {
4043 for (int r = y1 ; r <= y2 ; ++ r ) {
41- int index = r * TEXT_WINDOW_WIDTH ;
42- for (int c = x1 ; c <= x2 ; ++ c , index ++ ) {
43- _low_put_char ( ' ' , color , index ) ;
44+ int d_index = r * TEXT_WINDOW_WIDTH + x1 ;
45+ for (int c = x1 ; c <= x2 ; ++ c ) {
46+ buffer [ d_index ++ ] = ( color << 8 )| ' ' ;
4447 }
4548 }
4649 } else if (count > 0 ) {
4750 // Not yet tested.
4851 int width = x2 - x1 + 1 ;
49- for (int r1 = y1 ,r2 = y1 + count ; r2 <= y2 ; r1 ++ ,r2 ++ ) {
50- _low_vga_copy_step (
51- r2 * TEXT_WINDOW_WIDTH + x1 ,
52- r1 * TEXT_WINDOW_WIDTH + x1 ,
53- width
54- );
55- io_low_scroll_screen (0 ,color ,
56- x1 , y2 - count ,
57- x2 , y2 );
52+ for (int r_dest = y1 ,r_src = y1 + count ; r_src <= y2 ; r_src ++ ,r_dest ++ ) {
53+ int s_index = r_src * TEXT_WINDOW_WIDTH + x1 ;
54+ int d_index = r_dest * TEXT_WINDOW_WIDTH + x1 ;
55+ for (int j = x1 ; j <= x2 ; ++ j ) {
56+ buffer [d_index ++ ]= buffer [s_index ++ ];
57+ }
5858 }
5959 } else {
6060 // Not yet tested.
6161 int width = x2 - x1 + 1 ;
62- for (int r1 = y2 ,r2 = y2 + count ; r2 >= y1 ; r1 -- ,r2 -- ) {
63- _low_vga_copy_step (
64- r2 * TEXT_WINDOW_WIDTH + x1 ,
65- r1 * TEXT_WINDOW_WIDTH + x1 ,
66- width
67- );
68- io_low_scroll_screen (0 ,color ,
69- x1 , y1 ,
70- x2 , y1 + count );
62+ for (int r_dest = y2 ,r_src = y2 + count ; r_src >= y1 ; r_src -- ,r_dest -- ) {
63+ int s_index = r_src * TEXT_WINDOW_WIDTH + x1 ;
64+ int d_index = r_dest * TEXT_WINDOW_WIDTH + x1 ;
65+ for (int j = x1 ; j <= x2 ; ++ j ) {
66+ buffer [d_index ++ ]= buffer [s_index ++ ];
67+ }
7168 }
7269 }
70+ io_low_flush ();
7371}
7472
7573void io_low_put_char (char c , unsigned char color ) {
7674 _low_put_char (c ,color , location_xy );
75+ buffer [location_xy ]= (color <<8 )|c ;
76+ }
77+
78+ void io_low_flush () {
79+ _low_flush (buffer , sizeof (buffer )/2 );
7780}
0 commit comments