Last active
          May 7, 2020 13:22 
        
      - 
      
- 
        Save ryangraham/44e89c6f12725a665754bbaf5d0f2298 to your computer and use it in GitHub Desktop. 
    track2_encode
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // track2 4-bit BCD encode | |
| std::string track2 = ";4088490010739415=24082260007000?3"; | |
| std::string encoded = ""; | |
| uint8_t acc = 0; | |
| bool full = false; | |
| for (uint8_t c : track2) | |
| { | |
| if (!full) | |
| { | |
| acc = c - 0x30; | |
| acc <<= 4; | |
| full = !full; | |
| } | |
| else | |
| { | |
| acc |= c - 0x30; | |
| std::cout | |
| << unsigned(acc) << " "; | |
| encoded.append(1, acc); | |
| acc = 0; | |
| full = !full; | |
| } | |
| } | |
| // Output: 180 8 132 144 1 7 57 65 93 36 8 34 96 0 112 0 243 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment