added support for alternate varicode librray from fdmdv1, smaller char set, but uses...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 1 Jun 2014 04:19:47 +0000 (04:19 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 1 Jun 2014 04:19:47 +0000 (04:19 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1621 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/varicode.c
fdmdv2/src/varicode.h
fdmdv2/src/varicode_table.h

index 95ffc8a515ce33f3d79237751383c97653be0e05..c7b6d676f677786e27e4953a52e1f9a878107ce8 100644 (file)
@@ -24,6 +24,7 @@
 //==========================================================================
 
 #include <assert.h>
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 /*
   output is an unpacked array of bits of maximum size max_out.  Note
   unpacked arrays are a more suitable form for modulator input.
+
+  longcode == 1 varicode table that covers entire ASCII char set
+  longcode == 0 is the short, more efficient table, which covers a subset of the ASCII char set. Unknown
+              chars are replaced with spaces.  This mode works with two bits at a time.
 */
 
-int varicode_encode(short varicode_out[], char ascii_in[], int max_out, int n_in) {
-    int            n_out, index, n_zeros, v_len;
+int varicode_encode(short varicode_out[], char ascii_in[], int max_out, int n_in, int long_code) {
+    int            n_out, index, n_zeros, v_len, i;
     unsigned short byte1, byte2, packed;
 
     n_out = 0;
 
     while(n_in && (n_out < max_out)) {
 
-        assert((unsigned int)(*ascii_in) < 128);
+        if (long_code) {
+            assert((unsigned int)(*ascii_in) < 128);
+
+            index = 2*(unsigned int)(*ascii_in);
+            byte1 = long_varicode_table[index];
+            byte2 = long_varicode_table[index+1];
+            packed = (byte1 << 8) + byte2;
+        }
+        else {
+
+            packed = short_varicode_table[0]; // default to space if char not found
+          
+            // see if our character exists
+            for(i=0; i<sizeof(short_varicode_table); i+=2) {
+                if (short_varicode_table[i] == *ascii_in)
+                    packed = (unsigned short)short_varicode_table[i+1] << 8;
+            }
+        }
 
-        index = 2*(unsigned int)(*ascii_in);
-        byte1 = varicode_table[index];
-        byte2 = varicode_table[index+1];
-        packed = (byte1 << 8) + byte2;
         //printf("n_in: %d ascii_in: %c index: %d packed 0x%x\n", n_in, *ascii_in, index, packed);
         ascii_in++;
 
         n_zeros = 0;
         v_len = 0;
         while ((n_zeros < 2) && (n_out < max_out) && (v_len <= VARICODE_MAX_BITS)) {
-            if (packed & 0x8000) {
-                *varicode_out = 1;
-                n_zeros = 0;
+            if (long_code) {
+                if (packed & 0x8000) {
+                    *varicode_out = 1;
+                    n_zeros = 0;
+                }
+                else {
+                    *varicode_out = 0;
+                    n_zeros++;
+                }
+                //printf("packed: 0x%x *varicode_out: %d n_zeros: %d v_len: %d\n", packed, *varicode_out, n_zeros,v_len );
+                packed <<= 1;
+                varicode_out++;
+                n_out++;
+                v_len++;
             }
             else {
-                *varicode_out = 0;
-                n_zeros++;
-            }
-            //printf("packed: 0x%x *varicode_out: %d n_zeros: %d v_len: %d\n", packed, *varicode_out, n_zeros,v_len );
-            packed <<= 1;
-            varicode_out++;
-
-            n_out++;
-            v_len++;
+                if (packed & 0x8000)
+                    varicode_out[0] = 1;
+                else
+                    varicode_out[0] = 0;
+                    
+                if (packed & 0x4000)
+                    varicode_out[1] = 1;
+                else
+                    varicode_out[1] = 0;
+                
+                if (packed & 0xc000)
+                    n_zeros = 0;
+                else
+                    n_zeros += 2;
+
+                //printf("packed: 0x%x *varicode_out: %d n_zeros: %d v_len: %d\n", packed, *varicode_out, n_zeros,v_len );
+                packed <<= 2;
+                varicode_out +=2;
+                n_out += 2;
+                v_len += 2;
+           }
+                
         }
         assert(v_len <= VARICODE_MAX_BITS);
 
-        n_in--;
-            
+        n_in--;            
     }
 
     return n_out;
@@ -88,7 +129,7 @@ void varicode_decode_init(struct VARICODE_DEC *dec_states)
     dec_states->packed = 0;
 }
 
-static int decode_one_bit(struct VARICODE_DEC *s, char *single_ascii, short varicode_in)
+static int decode_one_bit(struct VARICODE_DEC *s, char *single_ascii, short varicode_in1, short varicode_in2, int long_code)
 {
     int            found, i;
     unsigned short byte1, byte2;
@@ -97,21 +138,44 @@ static int decode_one_bit(struct VARICODE_DEC *s, char *single_ascii, short vari
     //       s->state, varicode_in, s->packed, s->n_zeros);
 
     if (s->state == 0) {
-        if (!varicode_in)
-            return 0;
-        else 
-            s->state = 1;
+        if (long_code) {
+            if (!varicode_in1)
+                return 0;
+            else 
+                s->state = 1;
+        }
+        else {
+            if (!(varicode_in1 || varicode_in2))
+                return 0;
+            else 
+                s->state = 1;
+       }
+
     }
 
     if (s->state == 1) {
-        if (varicode_in) {
-            s->packed |= (0x8000 >> s->v_len);
-            s->n_zeros = 0;
+        if (long_code) {
+            if (varicode_in1) {
+                s->packed |= (0x8000 >> s->v_len);
+                s->n_zeros = 0;
+            }
+            else {
+                s->n_zeros++;
+            }
+            s->v_len++;
         }
         else {
-            s->n_zeros++;
+            if (varicode_in1)
+                s->packed |= (0x8000 >> s->v_len);
+            if (varicode_in2)
+                s->packed |= (0x4000 >> s->v_len);
+            if (varicode_in1 || varicode_in2)
+                s->n_zeros = 0;
+            else
+                s->n_zeros+=2;
+
+            s->v_len+=2;            
         }
-        s->v_len++;
 
         found = 0;
 
@@ -119,18 +183,31 @@ static int decode_one_bit(struct VARICODE_DEC *s, char *single_ascii, short vari
 
         if (s->n_zeros == 2) {
             if (s->v_len) {
-                byte1 = s->packed >> 8;
-                byte2 = s->packed & 0xff;
-
-                /* run thru table but note with bit errors means we might
-                   not actually find a match */
+                /* run thru table but note with bit errors we might not actually find a match */
 
-                for(i=0; i<128; i++) {
-                    if ((byte1 == varicode_table[2*i]) && (byte2 == varicode_table[2*i+1])) {
-                        found = 1;
-                        *single_ascii = i;
+                byte1 = s->packed >> 8;
+                //printf("looking for byte1 : 0x%x ... ", byte1);
+                if (long_code) {
+                    byte2 = s->packed & 0xff;
+
+                    for(i=0; i<128; i++) {
+                        if ((byte1 == long_varicode_table[2*i]) && (byte2 == long_varicode_table[2*i+1])) {
+                            found = 1;
+                            *single_ascii = i;
+                        }
+                    }
+                }
+                else {
+                    for(i=0; i<sizeof(short_varicode_table); i+=2) {
+                        //printf("byte1: 0x%x 0x%x\n", byte1, (unsigned char)short_varicode_table[i+1]);
+                        if (byte1 == (unsigned char)short_varicode_table[i+1]) {
+                            found = 1;
+                            *single_ascii = short_varicode_table[i];
+                            //printf("found: %d i=%d char=%c ", found, i, *single_ascii);
+                        }
                     }
                 }
+                //printf("\n");
             }
             varicode_decode_init(s);
         }
@@ -144,7 +221,7 @@ static int decode_one_bit(struct VARICODE_DEC *s, char *single_ascii, short vari
     return found;
 }
 
-int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in) {
+int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in, int long_code) {
     int            output, n_out;
     char           single_ascii;
 
@@ -153,9 +230,17 @@ int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short var
     //printf("varicode_decode: n_in: %d\n", n_in);
 
     while(n_in && (n_out < max_out)) {
-        output = decode_one_bit(dec_states, &single_ascii, *varicode_in);
-        varicode_in++;
-        n_in--;
+        if (long_code) {
+            output = decode_one_bit(dec_states, &single_ascii, varicode_in[0], 0, long_code);
+            varicode_in++;
+            n_in--;
+        }
+        else {
+            output = decode_one_bit(dec_states, &single_ascii, varicode_in[0], varicode_in[1], long_code);
+            varicode_in +=2;
+            n_in -= 2;
+        }
+
         if (output) {
             *ascii_out++ = single_ascii;
             n_out++;
@@ -167,76 +252,97 @@ int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short var
 
 
 #ifdef VARICODE_UNITTEST
-int main(void) {
+void test_varicode(int long_code) {
     char *ascii_in;
     short *varicode;
     int  i, n_varicode_bits_out, n_ascii_chars_out, length, half;
     char *ascii_out;
     struct VARICODE_DEC dec_states;
 
-    length = sizeof(varicode_table)/2;
-
+    if (long_code) {
+        printf("long code:\n");
+        length = sizeof(long_varicode_table)/2;
+    }
+    else {
+        printf("short code:\n");
+        length = sizeof(short_varicode_table)/2;
+    }
+    //length = 10;
     ascii_in = (char*)malloc(length);
     varicode = (short*)malloc(VARICODE_MAX_BITS*sizeof(short)*length);
     ascii_out = (char*)malloc(length);
-    
+
     // 1. test all Varicode codes -------------------------------------------------------------
 
-    for(i=0; i<length; i++)
-        ascii_in[i] = (char)i;
-    n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, length);
+    if (long_code) {
+        for(i=0; i<length; i++)
+            ascii_in[i] = (char)i;
+    }
+    else {
+        for(i=0; i<length; i++)
+            ascii_in[i] = short_varicode_table[2*i];
+    }
+    //printf("  ascii_in: %s\n", ascii_in);
+    n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, length, long_code);
 
-    //printf("n_varicode_bits_out: %d\n", n_varicode_bits_out);
+    printf("  n_varicode_bits_out: %d\n", n_varicode_bits_out);
+    //for(i=0; i<n_varicode_bits_out; i++) {
+    //    printf("%d \n", varicode[i]);
+    //}
 
     // split decode in half to test how it preseves state between calls 
 
     varicode_decode_init(&dec_states);
     half = n_varicode_bits_out/2;
-    n_ascii_chars_out  = varicode_decode(&dec_states, ascii_out, varicode, length, half);
-    //printf("n_ascii_chars_out: %d\n", n_ascii_chars_out);
+    n_ascii_chars_out  = varicode_decode(&dec_states, ascii_out, varicode, length, half, long_code);
+    // printf("  n_ascii_chars_out: %d\n", n_ascii_chars_out);
 
     n_ascii_chars_out += varicode_decode(&dec_states, &ascii_out[n_ascii_chars_out], 
-                                         &varicode[half], length-n_ascii_chars_out, n_varicode_bits_out - half);
+                                         &varicode[half], length-n_ascii_chars_out, n_varicode_bits_out - half, long_code);
     //printf("n_ascii_chars_out: %d\n", n_ascii_chars_out);
 
     assert(n_ascii_chars_out == length);
 
-    //for(i=0; i<n_varicode_bits_out; i++) {
-    //    printf("%d \n", varicode[i]);
-    //}
-
     //printf("ascii_out: %s\n", ascii_out);
 
     if (memcmp(ascii_in, ascii_out, length) == 0)
-        printf("Test 1 Pass\n");
+        printf("  Test 1 Pass\n");
     else
-        printf("Test 1 Fail\n");
+        printf("  Test 1 Fail\n");
 
     // 2. Test some ascii with a run of zeros -----------------------------------------------------
 
     sprintf(ascii_in, "CQ CQ CQ, this is VK5DGR");
+        
     assert(strlen(ascii_in) < length);
+    if (long_code == 0)
+        for(i=0; i<strlen(ascii_in); i++)
+            ascii_in[i] = tolower(ascii_in[i]);
 
     for(i=0; i<3; i++) {
-        n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, strlen(ascii_in));
-        n_ascii_chars_out   = varicode_decode(&dec_states, ascii_out, varicode, length, n_varicode_bits_out);
+        n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, strlen(ascii_in), long_code);
+        n_ascii_chars_out   = varicode_decode(&dec_states, ascii_out, varicode, length, n_varicode_bits_out, long_code);
         ascii_out[n_ascii_chars_out] = 0;
 
         printf("ascii_out: %s\n", ascii_out);
         if (strcmp(ascii_in, ascii_out) == 0)
-            printf("Test 2 Pass\n");
+            printf("  Test 2 Pass\n");
         else
-            printf("Test 2 Fail\n");
+            printf("  Test 2 Fail\n");
 
         memset(varicode, 0, sizeof(short)*20);
-        n_ascii_chars_out = varicode_decode(&dec_states, ascii_out, varicode, length, 20);
+        n_ascii_chars_out = varicode_decode(&dec_states, ascii_out, varicode, length, 20, long_code);
         assert(n_ascii_chars_out == 0);
     }
 
     free(ascii_in);
     free(ascii_out);
     free(varicode);
+}
 
+int main(void) {
+    test_varicode(0);
+    test_varicode(1);
     return 0;
 }
 #endif
index e49d476e46c96db36fc6430b6d8f8ea56224a8e1..ac189af2d33abf44f1ce24ea72c0866aa02d0d58 100644 (file)
@@ -37,9 +37,9 @@ struct VARICODE_DEC {
     unsigned short packed;
 };
     
-int varicode_encode(short varicode_out[], char ascii_in[], int max_out, int n_in);
+int varicode_encode(short varicode_out[], char ascii_in[], int max_out, int n_in, int longcode);
 void varicode_decode_init(struct VARICODE_DEC *dec_states);
-int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in);
+int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in, int longcode);
 
 #ifdef __cplusplus
 }
index 75155a8fe11748d12ce30e04dbc931764b506648..f27efbf77838c719da2aceab667c2fb3cc2d282c 100644 (file)
@@ -31,261 +31,305 @@ sent before the next character is sent.
 This file is constructed with information from the article "PSK31 Fundamentals"
 by Peter Martinez, G3PLX by Clint Turner, KA7OEI
 */
-unsigned char const varicode_table[256] =      {
-0b10101010,
-0b11000000, // 0 NUL
-0b10110110,
-0b11000000, // 1 SOH
-0b10111011,
-0b01000000, // 2 STX
-0b11011101,
-0b11000000, // 3 ETX
-0b10111010,
-0b11000000, // 4 EOT
-0b11010111,
-0b11000000, // 5 ENQ
-0b10111011,
-0b11000000, // 6 ACK
-0b10111111,
-0b01000000, // 7 BEL
-0b10111111,
-0b11000000, // 8 BS
-0b11101111,
-0b00000000, // 9 HT
-0b11101000,
-0b00000000, // 10 LF
-0b11011011,
-0b11000000, // 11 VT
-0b10110111,
-0b01000000, // 12 FF
-0b11111000,
-0b00000000, // 13 CR
-0b11011101,
-0b01000000, // 14 SO
-0b11101010,
-0b11000000, // 15 SI
-0b10111101,
-0b11000000, // 16 DLE
-0b10111101,
-0b01000000, // 17 DC1
-0b11101011,
-0b01000000, // 18 DC2
-0b11101011,
-0b11000000, // 19 DC3
-0b11010110,
-0b11000000, // 20 DC4
-0b11011010,
-0b11000000, // 21 NAK
-0b11011011,
-0b01000000, // 22 SYN
-0b11010101,
-0b11000000, // 23 ETB
-0b11011110,
-0b11000000, // 24 CAN
-0b11011111,
-0b01000000, // 25 EM
-0b11101101,
-0b11000000, // 26 SUB
-0b11010101,
-0b01000000, // 27 ESC
-0b11010111,
-0b01000000, // 28 FS
-0b11101110,
-0b11000000, // 29 GS
-0b10111110,
-0b11000000, // 30 RS
-0b11011111,
-0b11000000, // 31 US
-0b10000000,
-0b00000000, // 32 SP
-0b11111111,
-0b10000000, // 33 !
-0b10101111,
-0b10000000, // 34 "
-0b11111010,
-0b10000000, // 35 #
-0b11101101,
-0b10000000, // 36 $
-0b10110101,
-0b01000000, // 37 %
-0b10101110,
-0b11000000, // 38 &
-0b10111111,
-0b10000000, // 39 '
-0b11111011,
-0b00000000, // 40 (
-0b11110111,
-0b00000000, // 41 )
-0b10110111,
-0b10000000, // 42 *
-0b11101111,
-0b10000000, // 43 +
-0b11101010,
-0b00000000, // 44 ,
-0b11010100,
-0b00000000, // 45 -
-0b10101110,
-0b00000000, // 46 .
-0b11010111,
-0b10000000, // 47 /
-0b10110111,
-0b00000000, // 48 0
-0b10111101,
-0b00000000, // 49 1
-0b11101101,
-0b00000000, // 50 2
-0b11111111,
-0b00000000, // 51 3
-0b10111011,
-0b10000000, // 52 4
-0b10101101,
-0b10000000, // 53 5
-0b10110101,
-0b10000000, // 54 6
-0b11010110,
-0b10000000, // 55 7
-0b11010101,
-0b10000000, // 56 8
-0b11011011,
-0b10000000, // 57 9
-0b11110101,
-0b00000000, // 58 :
-0b11011110,
-0b10000000, // 59 ;
-0b11110110,
-0b10000000, // 60 <
-0b10101010,
-0b00000000, // 61 =
-0b11101011,
-0b10000000, // 62 >
-0b10101011,
-0b11000000, // 63 ?
-0b10101111,
-0b01000000, // 64 @
-0b11111010,
-0b00000000, // 65 A
-0b11101011,
-0b00000000, // 66 B
-0b10101101,
-0b00000000, // 67 C
-0b10110101,
-0b00000000, // 68 D
-0b11101110,
-0b00000000, // 69 E
-0b11011011,
-0b00000000, // 70 F
-0b11111101,
-0b00000000, // 71 G
-0b10101010,
-0b10000000, // 72 H
-0b11111110,
-0b00000000, // 73 I
-0b11111110,
-0b10000000, // 74 J
-0b10111110,
-0b10000000, // 75 K
-0b11010111,
-0b00000000, // 76 L
-0b10111011,
-0b00000000, // 77 M
-0b11011101,
-0b00000000, // 78 N
-0b10101011,
-0b00000000, // 79 O
-0b11010101,
-0b00000000, // 80 P
-0b11101110,
-0b10000000, // 81 Q
-0b10101111,
-0b00000000, // 82 R
-0b11011110,
-0b00000000, // 83 S
-0b11011010,
-0b00000000, // 84 T
-0b10101011,
-0b10000000, // 85 U
-0b11011010,
-0b10000000, // 86 V
-0b10101110,
-0b10000000, // 87 W
-0b10111010,
-0b10000000, // 88 X
-0b10111101,
-0b10000000, // 89 Y
-0b10101011,
-0b01000000, // 90 Z
-0b11111011,
-0b10000000, // 91 [
-0b11110111,
-0b10000000, // 92 "\"
-0b11111101,
-0b10000000, // 93 ]
-0b10101111,
-0b11000000, // 94 ^
-0b10110110,
-0b10000000, // 95 _ (underline)
-0b10110111,
-0b11000000, // 96 `
-0b10110000,
-0b00000000, // 97 a
-0b10111110,
-0b00000000, // 98 b
-0b10111100,
-0b00000000, // 99 c
-0b10110100,
-0b00000000, // 100 d
-0b11000000,
-0b00000000, // 101 e
-0b11110100,
-0b00000000, // 102 f
-0b10110110,
-0b00000000, // 103 g
-0b10101100,
-0b00000000, // 104 h
-0b11010000,
-0b00000000, // 105 i
-0b11110101,
-0b10000000, // 106 j
-0b10111111,
-0b00000000, // 107 k
-0b11011000,
-0b00000000, // 108 l
-0b11101100,
-0b00000000, // 109 m
-0b11110000,
-0b00000000, // 110 n
-0b11100000,
-0b00000000, // 111 o
-0b11111100,
-0b00000000, // 112 p
-0b11011111,
-0b10000000, // 113 q
-0b10101000,
-0b00000000, // 114 r
-0b10111000,
-0b00000000, // 115 s
-0b10100000,
-0b00000000, // 116 t
-0b11011100,
-0b00000000, // 117 u
-0b11110110,
-0b00000000, // 118 v
-0b11010110,
-0b00000000, // 119 w
-0b11011111,
-0b00000000, // 120 x
-0b10111010,
-0b00000000, // 121 y
-0b11101010,
-0b10000000, // 122 z
-0b10101101,
-0b11000000, // 123 {
-0b11011101,
-0b10000000, // 124 |
-0b10101101,
-0b01000000, // 125 }
-0b10110101,
-0b11000000, // 126 ~
-0b11101101,
-0b01000000, // 127 (del)
+unsigned char const long_varicode_table[256] = {
+    0b10101010,
+    0b11000000, // 0 NUL
+    0b10110110,
+    0b11000000, // 1 SOH
+    0b10111011,
+    0b01000000, // 2 STX
+    0b11011101,
+    0b11000000, // 3 ETX
+    0b10111010,
+    0b11000000, // 4 EOT
+    0b11010111,
+    0b11000000, // 5 ENQ
+    0b10111011,
+    0b11000000, // 6 ACK
+    0b10111111,
+    0b01000000, // 7 BEL
+    0b10111111,
+    0b11000000, // 8 BS
+    0b11101111,
+    0b00000000, // 9 HT
+    0b11101000,
+    0b00000000, // 10 LF
+    0b11011011,
+    0b11000000, // 11 VT
+    0b10110111,
+    0b01000000, // 12 FF
+    0b11111000,
+    0b00000000, // 13 CR
+    0b11011101,
+    0b01000000, // 14 SO
+    0b11101010,
+    0b11000000, // 15 SI
+    0b10111101,
+    0b11000000, // 16 DLE
+    0b10111101,
+    0b01000000, // 17 DC1
+    0b11101011,
+    0b01000000, // 18 DC2
+    0b11101011,
+    0b11000000, // 19 DC3
+    0b11010110,
+    0b11000000, // 20 DC4
+    0b11011010,
+    0b11000000, // 21 NAK
+    0b11011011,
+    0b01000000, // 22 SYN
+    0b11010101,
+    0b11000000, // 23 ETB
+    0b11011110,
+    0b11000000, // 24 CAN
+    0b11011111,
+    0b01000000, // 25 EM
+    0b11101101,
+    0b11000000, // 26 SUB
+    0b11010101,
+    0b01000000, // 27 ESC
+    0b11010111,
+    0b01000000, // 28 FS
+    0b11101110,
+    0b11000000, // 29 GS
+    0b10111110,
+    0b11000000, // 30 RS
+    0b11011111,
+    0b11000000, // 31 US
+    0b10000000,
+    0b00000000, // 32 SP
+    0b11111111,
+    0b10000000, // 33 !
+    0b10101111,
+    0b10000000, // 34 "
+    0b11111010,
+    0b10000000, // 35 #
+    0b11101101,
+    0b10000000, // 36 $
+    0b10110101,
+    0b01000000, // 37 %
+    0b10101110,
+    0b11000000, // 38 &
+    0b10111111,
+    0b10000000, // 39 '
+    0b11111011,
+    0b00000000, // 40 (
+    0b11110111,
+    0b00000000, // 41 )
+    0b10110111,
+    0b10000000, // 42 *
+    0b11101111,
+    0b10000000, // 43 +
+    0b11101010,
+    0b00000000, // 44 ,
+    0b11010100,
+    0b00000000, // 45 -
+    0b10101110,
+    0b00000000, // 46 .
+    0b11010111,
+    0b10000000, // 47 /
+    0b10110111,
+    0b00000000, // 48 0
+    0b10111101,
+    0b00000000, // 49 1
+    0b11101101,
+    0b00000000, // 50 2
+    0b11111111,
+    0b00000000, // 51 3
+    0b10111011,
+    0b10000000, // 52 4
+    0b10101101,
+    0b10000000, // 53 5
+    0b10110101,
+    0b10000000, // 54 6
+    0b11010110,
+    0b10000000, // 55 7
+    0b11010101,
+    0b10000000, // 56 8
+    0b11011011,
+    0b10000000, // 57 9
+    0b11110101,
+    0b00000000, // 58 :
+    0b11011110,
+    0b10000000, // 59 ;
+    0b11110110,
+    0b10000000, // 60 <
+    0b10101010,
+    0b00000000, // 61 =
+    0b11101011,
+    0b10000000, // 62 >
+    0b10101011,
+    0b11000000, // 63 ?
+    0b10101111,
+    0b01000000, // 64 @
+    0b11111010,
+    0b00000000, // 65 A
+    0b11101011,
+    0b00000000, // 66 B
+    0b10101101,
+    0b00000000, // 67 C
+    0b10110101,
+    0b00000000, // 68 D
+    0b11101110,
+    0b00000000, // 69 E
+    0b11011011,
+    0b00000000, // 70 F
+    0b11111101,
+    0b00000000, // 71 G
+    0b10101010,
+    0b10000000, // 72 H
+    0b11111110,
+    0b00000000, // 73 I
+    0b11111110,
+    0b10000000, // 74 J
+    0b10111110,
+    0b10000000, // 75 K
+    0b11010111,
+    0b00000000, // 76 L
+    0b10111011,
+    0b00000000, // 77 M
+    0b11011101,
+    0b00000000, // 78 N
+    0b10101011,
+    0b00000000, // 79 O
+    0b11010101,
+    0b00000000, // 80 P
+    0b11101110,
+    0b10000000, // 81 Q
+    0b10101111,
+    0b00000000, // 82 R
+    0b11011110,
+    0b00000000, // 83 S
+    0b11011010,
+    0b00000000, // 84 T
+    0b10101011,
+    0b10000000, // 85 U
+    0b11011010,
+    0b10000000, // 86 V
+    0b10101110,
+    0b10000000, // 87 W
+    0b10111010,
+    0b10000000, // 88 X
+    0b10111101,
+    0b10000000, // 89 Y
+    0b10101011,
+    0b01000000, // 90 Z
+    0b11111011,
+    0b10000000, // 91 [
+    0b11110111,
+    0b10000000, // 92 "\"
+    0b11111101,
+    0b10000000, // 93 ]
+    0b10101111,
+    0b11000000, // 94 ^
+    0b10110110,
+    0b10000000, // 95 _ (underline)
+    0b10110111,
+    0b11000000, // 96 `
+    0b10110000,
+    0b00000000, // 97 a
+    0b10111110,
+    0b00000000, // 98 b
+    0b10111100,
+    0b00000000, // 99 c
+    0b10110100,
+    0b00000000, // 100 d
+    0b11000000,
+    0b00000000, // 101 e
+    0b11110100,
+    0b00000000, // 102 f
+    0b10110110,
+    0b00000000, // 103 g
+    0b10101100,
+    0b00000000, // 104 h
+    0b11010000,
+    0b00000000, // 105 i
+    0b11110101,
+    0b10000000, // 106 j
+    0b10111111,
+    0b00000000, // 107 k
+    0b11011000,
+    0b00000000, // 108 l
+    0b11101100,
+    0b00000000, // 109 m
+    0b11110000,
+    0b00000000, // 110 n
+    0b11100000,
+    0b00000000, // 111 o
+    0b11111100,
+    0b00000000, // 112 p
+    0b11011111,
+    0b10000000, // 113 q
+    0b10101000,
+    0b00000000, // 114 r
+    0b10111000,
+    0b00000000, // 115 s
+    0b10100000,
+    0b00000000, // 116 t
+    0b11011100,
+    0b00000000, // 117 u
+    0b11110110,
+    0b00000000, // 118 v
+    0b11010110,
+    0b00000000, // 119 w
+    0b11011111,
+    0b00000000, // 120 x
+    0b10111010,
+    0b00000000, // 121 y
+    0b11101010,
+    0b10000000, // 122 z
+    0b10101101,
+    0b11000000, // 123 {
+    0b11011101,
+    0b10000000, // 124 |
+    0b10101101,
+    0b01000000, // 125 }
+    0b10110101,
+    0b11000000, // 126 ~
+    0b11101101,
+    0b01000000, // 127 (del)
 };
+
+char const short_varicode_table[] = {
+
+    ' ' ,0b11000000,
+    ',' ,0b01000000,
+    '=' ,0b10000000, // (Start of message)
+    '1' ,0b11110000,
+    '2' ,0b01110000,
+    '3' ,0b10110000,
+    '4' ,0b11010000,
+    '5' ,0b01010000,
+    '6' ,0b10010000,
+    '7' ,0b11100000,
+    '8' ,0b01100000,
+    '9' ,0b10100000,
+    'a' ,0b11111100,
+    'b' ,0b01111100,
+    'c' ,0b10111100,
+    'd' ,0b11011100,
+    'e' ,0b01011100,
+    'f' ,0b10011100,
+    'g' ,0b11101100,
+    'h' ,0b01101100,
+    'i' ,0b10101100,
+    'j' ,0b11110100,
+    'k' ,0b01110100,
+    'l' ,0b10110100,
+    'm' ,0b11010100,
+    'n' ,0b01010100,
+    'o' ,0b10010100,
+    'p' ,0b11100100,
+    'q' ,0b01100100,
+    'r' ,0b10100100,
+    's' ,0b11111000,
+    't' ,0b01111000,
+    'u' ,0b10111000,
+    'v' ,0b11011000,
+    'w' ,0b01011000,
+    'x' ,0b10011000,
+    'y' ,0b11101000,
+    'z' ,0b01101000,
+    '0' ,0b10101000
+};
+