-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] ?

, 24 2017 . 18:23 +
( AP, ) - . , , . , , . , , UML Statechart, .. , ?. , , - .

, , . embedder, , Windows.


. , ( ), .

, , , , . , :



1.

:

  • () , . .. , .
  • I(n) ( ), S(n) . , , , , I(n) O(n). ( S(n)) .
  • O(n) , , , S(n+1) . , I(n) O(n), (.. I(n+1) ), . , , .
  • (, ) , . n n + 1 , , .. n , . , . , I.
  • , I

, , , . . , , . , / , /, , . , ,
_/________.



2.

, . . . , ___ . . , , .

- . ? :

  • .
  • , .
  • .

, , . , . . , .

1. .


, , , / . , , .

, , . .

. , . : . .. -, , ( ) , . , , , ALU FPU .


3.

- , . , , .. , , ( ) , . , .

/ . , . , , .


a)


)


)

4.

, , . , , . esc-, '\n', , .. . :

"Text 1 \033[7m Text 2  \033[27m  \033[1m Text 3 \033[21m \n Text 42"

, (.4, )

, (.4, ) . , , , . , , .

, ,

void Out_text(int x0, int y0, int x1, int y1, int x_shift, int y_shift, char * Text);

, : printf, , .

( ) , , . , , , , .

, ( ), , , , . , . , . , , , . , .

, : 1 1 2 2 3 3 4 4 5 \0
N esc-, . , ( ).

- . , . : , . , , . 5.


5.

, RAM , :

  • _ ( )
  • , , ,
  • .

, , . , , .

x,y( ), x_shift, y_shift x,y , , , , , , .



, . , , Text_begin Text_end.



6.

.

, , , , , ,





7.

-, , , . , , , . , , - , , , . , ( ), , , . , - . .



, . x, y.



8.

.

x_max, y_max
x0, y0, x1, y1 , Out_text
x_shift, y_shift , , .
x,y , esc . .

, , .

57, . , embedder . , , , .. .


9.

, : 3 , , 256 24

$$display$${Height_{ }* Width_{}/8} = 768 $$display$$


, . , , .

- , , .

. , . . , , . , Current_byte Current_shift, , , , .



10. .

. , , , , , .



11.

, , , :

) , , , . .
) , , Current_shift.
) , , x .
) , , .

, ( ).

:


12. , , .

:

  • (1) .
  • (2) 3 , . .



13. . .

  • (3) (2) , .



14.

, . , , 7 , 16*24 336 .


15.

, . .


16. .

, ( 2 3, ) .


17. 2 3.

, ( ), , .

, , , , , , , , Out_symbol. Start_line End_line, Out_text, Out_symbol.

, Display.h/Display.cpp. (Project1.exe). Builder 6



  class tShift_register Symbol_buffer;
  vector< tShift_register > Line_buffer;

  //        
  int Start_line, End_line;
  int Left_shift, Current_shift, Current_byte;
  //     Width  -    
  u1x * Symbol_array;
  int Width;
  int bytes_Width;
  //    bytes_Width,     
  int bytes_Width_after_shift;

  inline void Out_symbol ()
  {

    for(int Current_line = Start_line; Current_line <= End_line; Current_line++)
    {

      Symbol_buffer.Clear();

      ////////////////////////
      //   2  3    Out_symbol,     
      if(Left_shift)//  2
      {
        
        //     8         
        int Start_symbol_byte = Left_shift >> 3;

        // void tShift_register::Load(int Start_index_in_destination, u1x * Source, int Width);
        Symbol_buffer.Load(0,Symbol_array + bytes_Width * Current_line + Start_symbol_byte,\
                                                                  bytes_Width - Start_symbol_byte);

        // .15
        // void tShift_register::Shift(int Start, int End, int Amount);
        Symbol_buffer.Shift (0, bytes_Width_after_shift,   Current_shift - (Left_shift & 7)  );
        Symbol_buffer[0] &= Masks_array__left_for_line_buffer[ Current_shift ];

        // .16
        Line_buffer[Current_line].Or(Current_byte, &Symbol_buffer[0], bytes_Width_after_shift );

      }
      else //  3
      {
       
        Symbol_buffer.Load(0,Symbol_array + bytes_Width * Current_line, bytes_Width);

        // .14
        Symbol_buffer.Shift(0, bytes_Width_after_shift, Current_shift);

        // .16
        Line_buffer[Current_line].Or(Current_byte, &Symbol_buffer[0], bytes_Width_after_shift );

      }

    }// for(int Current_line = Start_line, Current_line <= End_line, Current_line++)

  }// inline void Out_symbol ()

. . , , , .


18. .

, . , , ( ). ( 1 3), . , , , . : -, , goto, . , goto , , . , . , , goto - , .. . . , , , , .

:



  class tShift_register Symbol_buffer;
  vector< tShift_register > Line_buffer;
  tVideomemory Videomemory;
  
  //       
  int Start_line, End_line;
  //        
  int Left_shift, Current_shift, Current_byte;

  //       
  u1x * Text;
  u1x * Text_end;
  tFont * Current_font;

  //      Out_text_block 
  //     Width  -    
  u1x * Symbol_array;
  int Width;
  int bytes_Width;
  //    bytes_Width,     
  int bytes_Width_after_shift;

  //       
  //     
  int Line_width;


  ////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////
  inline void Out_text_block ()
  {

    Clear_line_buffer();

  ////////////////////////////////////////
  //       
  Type_1:

    //    
    while(Text < Text_end)
    {

      Width = Current_font->Width_for(*Text);
      
      //        
      if(Left_shift >= Width)
      {
        Left_shift  -= Width;
        Text++;
      }
      else
      
        goto Type_2;

    }// while(Text < Text_end)

    //  
    return;

  ////////////////////////////////////////
  Type_2:

    // 
    Current_byte  = Current_shift >> 3;
    Current_shift = Current_shift & 7;

    Symbol_array = Current_font->Image_for(*Text);
    bytes_Width  = (Width + 7) >> 3;
    bytes_Width_after_shift  = (Width + Current_shift + 7) >> 3;

    Line_width     -= (Width - Left_shift);

    //  ?
    if(Line_width <= 0)
    {

      Width -= Left_shift;
    
      goto Type_4;

    }

    Out_symbol();
    
    //  Left_shift
    Width -= Left_shift;
    Left_shift   =  0;

    //   
    Text++;

  ////////////////////////////////////////
  Type_3:

    //  ?
    while(Text < Text_end)
    {

      // Current_byte, Current_shift     .
      Current_shift += Width;
      Current_byte  += (Current_shift >> 3);
      Current_shift =  Current_shift & 0x7;

      //    
      Width        = Current_font->Width_for(*Text);
      Symbol_array = Current_font->Image_for(*Text);
      bytes_Width  = (Width + 7) >> 3;
      bytes_Width_after_shift  = (Width + Current_shift + 7) >> 3;

      Line_width     -= Width;

      //  ?
      if(Line_width <= 0)

        goto Type_4;

      Out_symbol();

      Text++;

    }// while(*Text < Text_end)

    Current_shift += Width;
    Current_byte  += (Current_shift >> 3);
    Current_shift =  Current_shift & 0x7;

    //  
    goto Finalize;

  ////////////////////////////////////////
  //   4     2'  3'   
Type_4:

    Out_symbol();

    Current_shift += (Width + Line_width);
    Current_byte  += (Current_shift >> 3);
    Current_shift =  Current_shift & 0x7;

    for(int Current_line = Start_line; Current_line <= End_line; Current_line++)
    {

      Line_buffer[Current_line][Current_byte] &= Masks_array__right_for_line_buffer[Current_shift];

    }

Finalize:

    Out_line_buffer_in_videomemory();

    return;

  }// inline void Out_text_block ()


, 1 1, .

Start_line, End_line, Left_shift, Current_shift, Current_byte . . . , , .8.

(x,y) (esc , ). (x0,y0,x1,y1). x_shift, y_shift . . , , .. . .

. 19


19.

x_shift , x. x_byte Start_shift , . 20


20. .

, :

  • , , ( ).
  • , , ( ).
  • , Start_line y , End_line y + End_line Start_line, , 20.

Start_line End_line
. 21.


. 21. .

20, 21



    //   

    //    
    ////////////////////////////////////////////////////////////////////////////////////
    if(x1 < x0)
    {
       int temp = x0;
       x0 = x1;
       x1 = temp;
    }

    if(y1 < y0)
    {
       int temp = y0;
       y0 = y1;
       y1 = temp;
    }

    if(x0 < 0)
    {
      x_shift += x0;
      x0 = 0;
    }

    if(y0 < 0)
    {
      y_shift += y0;
      y0 = 0;
    }

    if(x1 > x_max)
    {
      x1 = x_max;
    }

    if(y1 > y_max)
    {
      y1 = y_max;
    }
 
//   
inline bool Init_text_block()
{
    //  
    ////////////////////////////////////////////////////////////////////////////////////
    x += ( x0 + x_shift);
    y += ( y0 + y_shift);

    //  
    ////////////////////////////////////////////////////////////////////////////////////
    if (x < x0)
    {
      Left_shift = x - x0;
      x = x0;
    }
    else
    {
      Left_shift = 0;
    }

    if(x >= x1)

      return false;

    x_byte =  x >> 3;
    Start_shift = Current_shift = x & 7; 
    Current_byte = 0;

    Line_width = x1-x;

    //  
    ////////////////////////////////////////////////////////////////////////////////////
    if (y < y0)
    {
      Start_line = y0 - y;
      y = y0;
    }
    else

      Start_line = 0;

    if(Start_line >= Current_font->Height())

      return false;

    if( (Current_font->Height() - Start_line) < ( y1 - y) )

      End_line = Current_font->Height() - 1;

    else

      End_line = Start_line + (y1 - y) - 1;

    return true;

}

, , , x0,y0,x1,y1. .

.

.7 .


  ///////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////
  //  
  void Out_text_block ();

  inline void Control_processing ();
  

  void Out_text (int arg_x0, int arg_y0,
                 int arg_x1, int arg_y1,
                 int arg_x_shift, int arg_y_shift,
                 unsigned char * argText)
  {


    // 
    // ...

    while(*Text_end)
    {


//////////////////////////////////////
state__Inside_text_block:

      while(1)
      {

        switch(*Text_end)
        {

		  //           
          case '\0':
          case '\n':

            goto state__Out_text_block;

        } 

        Text_end++;

      }


//////////////////////////////////////
state__Out_text_block:

      if( (Text_begin != Text_end) && Init_text_block())

        Out_text_block();

      Text_begin = Text_end;

//////////////////////////////////////
state__Control_processing:

      if(*Text_end == 0)

        return;

      //     
      Control_processing();

    }//while(*Text_end)

  }//void Out_text (int arg_x0, int arg_y0,

. ( Project1.exe). , Control_processing, esc- . , , . .
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/331556/

:  

: [1] []
 

:
: 

: ( )

:

  URL