Pella86

Bit Mask output final?

Oct 12th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.45 KB | None | 0 0
  1. vector<string> draw_card(const Carta& carta){
  2.  
  3.  
  4. /*
  5.     int16_t a0 = 0b 0000 0000 0000 0000;
  6.                  0x 0    0    0    0
  7.     int16_t a1 = 0b 0000 0100 0000 0000;
  8.                  0x 0    4    0    0
  9.     int16_t a2 = 0b 0000 1010 0000 0000;
  10.                  0x 0    A    0    0
  11.     int16_t a3 = 0b 0001 1111 0000 0000;
  12.                  0x 1    F    0    0
  13.     int16_t a4 = 0b 0010 0000 1000 0000;
  14.                  0x 2    0    8    0
  15.     int16_t a5 = 0b 0100 0000 0100 0000;
  16.                  0x 4    0    4    0
  17.     int16_t a6 = 0b 0000 0000 0000 0000;
  18.                  0x 0    0    0    0
  19. */
  20.  
  21.     vector<uint16_t> middle_matrix;
  22.  
  23.     middle_matrix.push_back(0x0000); //0
  24.     middle_matrix.push_back(0x0400); //1024
  25.     middle_matrix.push_back(0x0A00); //2560
  26.     middle_matrix.push_back(0x1F00); //7936
  27.     middle_matrix.push_back(0x2080); //8320
  28.     middle_matrix.push_back(0x4040); //16448
  29.     middle_matrix.push_back(0x0000); //0
  30.  
  31.     // first line of the matrix is
  32.     vector<string> v;
  33.     v.push_back("|-----------|");
  34.  
  35.     string nome_seme = create_semi(carta.seme);
  36.     string nome_valore = create_nome_valore(carta.valore);
  37.  
  38.     vector<string> carta_grafica;
  39.  
  40.     string init_string = "|           |";
  41.     for(unsigned int i = 0; i < init_string.size(); ++i){
  42.         unsigned int valore_offset = 1;
  43.         unsigned int seme_offset = nome_valore.size() + valore_offset + 1;
  44.         if(i >= valore_offset && i < nome_valore.size() + valore_offset){
  45.             init_string[i] = nome_valore[i-valore_offset];
  46.         }
  47.  
  48.         if(i >= seme_offset && i <= nome_seme.size() + seme_offset - 1){
  49.             init_string[i] = nome_seme[i-seme_offset];
  50.         }
  51.  
  52.     }
  53.  
  54.     v.push_back(init_string);
  55.  
  56.     for(unsigned int i = 0; i < middle_matrix.size(); ++i){
  57.         string line = "|";
  58.         for(uint16_t mask = 0x8000; mask != 0x0010; mask >>= 1){
  59.             cout << mask << " " << middle_matrix[i] << " ";
  60.             if(middle_matrix[i] & mask){
  61.                 line += "*";
  62.             }
  63.             else{
  64.                 line += " ";
  65.             }
  66.         }
  67.         line += "|";
  68.         v.push_back(line);
  69.     }
  70.  
  71.  
  72.     //for (string x : v){cout << x << endl;}
  73.     for(unsigned int i = 0; i < v.size(); ++i){
  74.         cout << v[i] << endl;
  75.     }
  76.    
  77.     return v;
  78. }
  79.  
  80. /*OUTPUT
  81. |Asso picche|
  82. |           |
  83. |     *     |
  84. |    * *    |
  85. |   *****   |
  86. |  *     *  |
  87. | *       * |
  88. |           |
  89. */
Add Comment
Please, Sign In to add comment