diff --git a/20230530/morse-05.c b/20230530/morse-05.c new file mode 100644 index 0000000000000000000000000000000000000000..f22db38e1beb08a62d818e03ddcf59757e418fa7 --- /dev/null +++ b/20230530/morse-05.c @@ -0,0 +1,120 @@ +#include <stdio.h> +#include <stdint.h> +#include <string.h> + +static const char *morse[256] = { + ['.'] = ".-.-.-", + [','] = "--..--", + [':'] = "---...", + [';'] = "-.-.-.", + ['?'] = "..--..", + ['!'] = "-.-.--", + ['-'] = "-....-", + ['_'] = "..--.-", + ['('] = "-.--.", + [')'] = "-.--.-", + ['\''] = ".----.", + ['='] = "-...-", + ['+'] = ".-.-.", + ['/'] = "-..-.", + ['@'] = ".--.-.", + ['"'] = ".-..-.", + [0x02] = "-.-.-", /* Spruchanfang */ + [0x03] = ".-.-.", /* Spruchende */ + [0x06] = "...-.", /* verstanden */ + [0x04] = "...-.-", /* Verkehrsende */ + [0x7f] = "........", /* Fehler */ + ['0'] = "-----", + ['1'] = ".----", + ['2'] = "..---", + ['3'] = "...--", + ['4'] = "....-", + ['5'] = ".....", + ['6'] = "-....", + ['7'] = "--...", + ['8'] = "---..", + ['9'] = "----.", + ['A'] = ".-", + ['B'] = "-...", + ['C'] = "-.-.", + ['D'] = "-..", + ['E'] = ".", + ['F'] = "..-.", + ['G'] = "--.", + ['H'] = "....", + ['I'] = "..", + ['J'] = ".---", + ['K'] = "-.-", + ['L'] = ".-..", + ['M'] = "--", + ['N'] = "-.", + ['O'] = "---", + ['P'] = ".--.", + ['Q'] = "--.-", + ['R'] = ".-.", + ['S'] = "...", + ['T'] = "-", + ['U'] = "..-", + ['V'] = "...-", + ['W'] = ".--", + ['X'] = "-..-", + ['Y'] = "-.--", + ['Z'] = "--..", + ['a'] = ".-", + ['b'] = "-...", + ['c'] = "-.-.", + ['d'] = "-..", + ['e'] = ".", + ['f'] = "..-.", + ['g'] = "--.", + ['h'] = "....", + ['i'] = "..", + ['j'] = ".---", + ['k'] = "-.-", + ['l'] = ".-..", + ['m'] = "--", + ['n'] = "-.", + ['o'] = "---", + ['p'] = ".--.", + ['q'] = "--.-", + ['r'] = ".-.", + ['s'] = "...", + ['t'] = "-", + ['u'] = "..-", + ['v'] = "...-", + ['w'] = ".--", + ['x'] = "-..-", + ['y'] = "-.--", + ['z'] = "--.." +}; + +int main (void) +{ + for (int c = 0; c < 128; c++) + { + uint8_t bits = 0; + uint8_t mask = 1; + const char *p = morse[c]; + if (p) + { + while (*p) + { + if (*p == '-') + bits |= mask; + mask <<= 1; + p++; + } + } + printf (" 0x%02x,", bits); + } + printf ("\n"); + for (int c = 0; c < 128; c++) + { + const char *p = morse[c]; + if (p) + printf (" %zu,", strlen (p)); + else + printf (" 0,"); + } + printf ("\n"); +} diff --git a/20230530/morse-06.c b/20230530/morse-06.c new file mode 100644 index 0000000000000000000000000000000000000000..dcec7ad8f1db04358346c9a80b0fe41416a8b2f8 --- /dev/null +++ b/20230530/morse-06.c @@ -0,0 +1,56 @@ +#include <stdio.h> +#include <stdint.h> + +uint8_t morse_bits[128] = +{ + 0x00, 0x00, 0x15, 0x0a, 0x28, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x35, 0x12, 0x00, 0x00, 0x00, 0x00, 0x1e, + 0x0d, 0x2d, 0x00, 0x0a, 0x33, 0x21, 0x2a, 0x09, + 0x1f, 0x1e, 0x1c, 0x18, 0x10, 0x00, 0x01, 0x03, + 0x07, 0x0f, 0x07, 0x15, 0x00, 0x11, 0x00, 0x0c, + 0x16, 0x02, 0x01, 0x05, 0x01, 0x00, 0x04, 0x03, + 0x00, 0x00, 0x0e, 0x05, 0x02, 0x03, 0x01, 0x07, + 0x06, 0x0b, 0x02, 0x00, 0x01, 0x04, 0x08, 0x06, + 0x09, 0x0d, 0x03, 0x00, 0x00, 0x00, 0x00, 0x2c, + 0x00, 0x02, 0x01, 0x05, 0x01, 0x00, 0x04, 0x03, + 0x00, 0x00, 0x0e, 0x05, 0x02, 0x03, 0x01, 0x07, + 0x06, 0x0b, 0x02, 0x00, 0x01, 0x04, 0x08, 0x06, + 0x09, 0x0d, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +uint8_t morse_length[128] = +{ + 0, 0, 5, 5, 6, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 6, 6, 0, 0, 0, 0, 6, 5, 6, 0, 5, 6, 6, 6, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 0, 5, 0, 6, + 6, 2, 4, 4, 3, 1, 4, 3, 4, 2, 4, 3, 4, 2, 2, 3, + 4, 4, 3, 3, 1, 3, 4, 3, 4, 4, 4, 0, 0, 0, 0, 6, + 0, 2, 4, 4, 3, 1, 4, 3, 4, 2, 4, 3, 4, 2, 2, 3, + 4, 4, 3, 3, 1, 3, 4, 3, 4, 4, 4, 0, 0, 0, 0, 8 +}; + +int main (void) +{ + for (int c = 0; c < 128; c++) + if (morse_length[c]) + { + printf (" ['%c'] = \"", c); + uint8_t bits = morse_bits[c]; + uint8_t mask = 1; + int l = morse_length[c]; + for (int i = 0; i < l; i++) + { + if (bits & mask) + printf ("-"); + else + printf ("."); + mask <<= 1; + } + printf ("\",\n"); + } + return 0; +} diff --git a/20230530/morse-07.c b/20230530/morse-07.c new file mode 100644 index 0000000000000000000000000000000000000000..32fc541935880ed6e9f72d428d49281a315f99c8 --- /dev/null +++ b/20230530/morse-07.c @@ -0,0 +1,83 @@ + [''] = "-.-.-", + [''] = ".-.-.", + [''] = "...-.-", + [''] = "...-.", + ['!'] = "-.-.--", + ['"'] = ".-..-.", + ['''] = ".----.", + ['('] = "-.--.", + [')'] = "-.--.-", + ['+'] = ".-.-.", + [','] = "--..--", + ['-'] = "-....-", + ['.'] = ".-.-.-", + ['/'] = "-..-.", + ['0'] = "-----", + ['1'] = ".----", + ['2'] = "..---", + ['3'] = "...--", + ['4'] = "....-", + ['5'] = ".....", + ['6'] = "-....", + ['7'] = "--...", + ['8'] = "---..", + ['9'] = "----.", + [':'] = "---...", + [';'] = "-.-.-.", + ['='] = "-...-", + ['?'] = "..--..", + ['@'] = ".--.-.", + ['A'] = ".-", + ['B'] = "-...", + ['C'] = "-.-.", + ['D'] = "-..", + ['E'] = ".", + ['F'] = "..-.", + ['G'] = "--.", + ['H'] = "....", + ['I'] = "..", + ['J'] = ".---", + ['K'] = "-.-", + ['L'] = ".-..", + ['M'] = "--", + ['N'] = "-.", + ['O'] = "---", + ['P'] = ".--.", + ['Q'] = "--.-", + ['R'] = ".-.", + ['S'] = "...", + ['T'] = "-", + ['U'] = "..-", + ['V'] = "...-", + ['W'] = ".--", + ['X'] = "-..-", + ['Y'] = "-.--", + ['Z'] = "--..", + ['_'] = "..--.-", + ['a'] = ".-", + ['b'] = "-...", + ['c'] = "-.-.", + ['d'] = "-..", + ['e'] = ".", + ['f'] = "..-.", + ['g'] = "--.", + ['h'] = "....", + ['i'] = "..", + ['j'] = ".---", + ['k'] = "-.-", + ['l'] = ".-..", + ['m'] = "--", + ['n'] = "-.", + ['o'] = "---", + ['p'] = ".--.", + ['q'] = "--.-", + ['r'] = ".-.", + ['s'] = "...", + ['t'] = "-", + ['u'] = "..-", + ['v'] = "...-", + ['w'] = ".--", + ['x'] = "-..-", + ['y'] = "-.--", + ['z'] = "--..", + [''] = "........",