diff --git a/2014/vik/.gitignore b/2014/vik/.gitignore index e36a12dc8..02a114255 100644 --- a/2014/vik/.gitignore +++ b/2014/vik/.gitignore @@ -1,4 +1,5 @@ audio_file.raw prog +prog.alt prog.raw prog.orig diff --git a/2014/vik/Makefile b/2014/vik/Makefile index 4f42954a7..dd7c55294 100644 --- a/2014/vik/Makefile +++ b/2014/vik/Makefile @@ -112,8 +112,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# diff --git a/2014/vik/README.md b/2014/vik/README.md index f46b04a30..f43c7f470 100644 --- a/2014/vik/README.md +++ b/2014/vik/README.md @@ -13,13 +13,15 @@ US make ``` - ## To run: ```sh ./prog > foo.c ``` +There is an alternate version that will theoretically work with Windows +compilers (if anything in Windows works :-) ). See the [Alternate +code](#alternate-code) section below. ## Try: @@ -29,6 +31,18 @@ echo 'Want to hear me beep?' | ./prog > audio_file.raw echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio - ``` +### Alternate code: + +The alternate code, [prog.alt.c](prog.alt.c), is based on the author's +instructions on how to get it to work with Windows. This has not been tested but +in order to use it you can do: + +```sh +make alt +``` + +Use `prog.alt` as you would `prog` above as well as below. + ## Judges' remarks: @@ -59,7 +73,7 @@ I can tell, there are at least six chocolate references in this program. This program can convert text to Morse to a raw 44.1kHz stereo audio file. Via streaming to mplayer, you can listen to the Morse audio. -Don't forget the last '-' as it makes mplayer read from stdin. +Don't forget the last '`-`' as it makes mplayer read from stdin. ## Convert audio file with Morse signals to text @@ -86,6 +100,8 @@ declaration in order for the program to run correctly: _setmode(_fileno(stdout), 0x8000); ``` +NOTE: see the [alternate code](prog.alt.c) for this. + ### Known Issues The program uses a quite simple algorithm for detecting tone on and off events diff --git a/2014/vik/prog.alt.c b/2014/vik/prog.alt.c new file mode 100644 index 000000000..9472cccf1 --- /dev/null +++ b/2014/vik/prog.alt.c @@ -0,0 +1,31 @@ +#include +#include +#include + +char X[] = + " ETIANMSURWDKGOHVF:L:PJBXCYZQ::54:3:::2&:+::::16=/:::(:7:::8:90" + "::::::::::::?_::::\"::.::::@:::'::-::::::::;!:):::::,:::::"; + +int j,w,h,f,u,d,g,e,n,i,l,a,r,p,c,m,o,t,s,Q=32,T[32],W[32],I=13000; + +int main(int v, char** b) { + + _setmode(_fileno(stdout), 0x8000); + for (i=0;v>0&&v<5&&(v*=t=fread(X,1,1,stdin));) + + for (v-1&&101==*1[b]?++g%1500?u+=(g&1^1)*(*X<0?-*X:*X):(f=e,e=w,w=d,d=u, + m=(1 - h%2* 2 )*(d -f)/ (d 5?T[ h%Q] =o+l , l=W[ + h++%Q]=o,o=0:m,o++,u=main(0,b)):(c=strrchr(X,~(Q&*X&*X/2)&*X)-X,j=255); + v==1&&(c*j||main(*X-Q?8:24,b));j/=2)c7&&j<13?s=c*s+T[i/Q]/2,s/=++c:0) + !(i++%Q)?a=c>a?u=s,c:a,c=s=0:0,j=T[i%Q],j=j?T[i/Q]*10/j:0,j*=(j<5)*2+1; + + for (r+=(h-r)/Q*Q;i5&&!v;r+t!=h+1?(W[r%Q]>2*u||r==h?p=n=n>6?0: + putchar(X[p-1+(1<6*u?putchar(Q):0):0) + *X=Q,p=r%2?++n,2*p+(W[r++%Q]>2*u):p; + + return 0; +} diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index d0cc797af..de53a0762 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1790,12 +1790,18 @@ implicitly (linux doesn't seem to but macOS does). Cody fixed the build for this entry: it does not require SDL2 but SDL1 so there were linking errors. +## [2014/vik](2014/vik/prog.c) ([README.md](2014/vik/README.md)) + +Cody added an alternate version that is based on the author's remarks that will +theoretically work for Microsoft Windows compilers (if anything works in Windows +:-) ). We have no way of testing this and if anything has changed since 2014 +that would break it we do not know. ## [2015/endoh3](2015/endoh3/prog.c) ([README.md](2015/endoh3/README.md])) Cody fixed this to compile with linux which was having a problem with duplicate -symbols of `main()`. The fix is through the option `-fcommon` which will let it -compile like it does with macOS. +symbols of `main()`. The fix is through the compiler option `-fcommon` which +will let it compile like it does with macOS. Cody also made it easier to enjoy the theme of [Back to the Future](https://en.wikipedia.org/wiki/Back_to_the_Future) using this entry by