diff options
author | H. Peter Anvin <hpa@zytor.com> | 2012-08-12 09:50:39 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2012-08-12 09:50:39 -0700 |
commit | 45033f02acc25cf483e23aadc4bdb093baa98eab (patch) | |
tree | c01a1d7129c1915988deac19afbd8666ee1377bc | |
parent | 19f9717284a852044700c9f9b6bbb21b1504d47d (diff) | |
download | mfmdecode-45033f02acc25cf483e23aadc4bdb093baa98eab.tar.gz mfmdecode-45033f02acc25cf483e23aadc4bdb093baa98eab.tar.xz mfmdecode-45033f02acc25cf483e23aadc4bdb093baa98eab.zip |
-rw-r--r-- | mfmdecode.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/mfmdecode.c b/mfmdecode.c index 7cee0e4..87d19b3 100644 --- a/mfmdecode.c +++ b/mfmdecode.c @@ -1,8 +1,7 @@ /* * Decode ABC80 cassette files * - * Convert to 44100 Hz single channel 16-bit with appropriate endianness - * and normalized gain first: + * Convert to single channel 16-bit with appropriate endianness first: * * sox muzak.wav --endian little -c 1 -s muzak.raw */ @@ -11,44 +10,46 @@ #include <stdlib.h> #include <string.h> #include <math.h> +#include <locale.h> #include <inttypes.h> static unsigned int xtime; -static const char my_tolower[256] = - "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017" - "\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" - " !\"#$%&'()*+,-./0123456789:;<=>?" - "\351abcdefghijklmnopqrstuvwxyz\344\366\345\374_" - "\351abcdefghijklmnopqrstuvwxyz\344\366\345\374\377" - "\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217" - "\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237" - "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" - "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" - "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" - "\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337" - "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357" - "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"; +static const wchar_t my_tolower[256] = + L"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017" + L"\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" + L" !\"#¤%&'()*+,-./0123456789:;<=>?" + L"éabcdefghijklmnopqrstuvwxyzäöåü_" + L"éabcdefghijklmnopqrstuvwxyzäöåü\377" + L"\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217" + L"\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237" + L"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" + L"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" + L"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" + L"\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337" + L"\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357" + L"\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"; static void unmangle_filename(char *out, const uint8_t *in) { int i; + wctomb(NULL, 0); + for (i = 0; i < 8; i++) { if (*in != ' ') - *out++ = my_tolower[*in]; + out += wctomb(out, my_tolower[*in]); in++; } if (memcmp(in, " ", 3)) { - *out++ = '.'; + out += wctomb(out, L'.'); for (i = 0; i < 3; i++) { if (*in != ' ') - *out++ = my_tolower[*in]; + out += wctomb(out, my_tolower[*in]); in++; } } - *out = '\0'; } @@ -58,7 +59,7 @@ static void output_block(uint8_t *buf, uint8_t *csum) int i; static FILE *f; static uint16_t block; - static char filename[12]; + static char filename[64]; int err = 0; if (!buf) { @@ -224,6 +225,8 @@ int main(int argc, char *argv[]) unsigned int state; unsigned int time, ptime; + setlocale(LC_ALL, ""); + f = fopen(argv[1], "rb"); frequency = (argc > 2) ? strtoul(argv[2], NULL, 0) : 44100; |