From ba108e1f651a4994755fdcd320a5d6c6e889d317 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 3 May 2023 09:26:23 -0700 Subject: [PATCH] Format fix README.md + add alt code to 2011/vik The alternate code is based on the author's statements on how to get it to work for Windows. I then looked at MS docs to find out what header files are needed. The only reason I did this is because the purpose of the issue #1 is to get the entries to compile under as many systems as possible and since the author gave instructions ... Obviously I didn't test this as I have no way to do so. It's 'as is'. In the famous words of Douglas Adams: 'Don't share and don't enjoy! :-)' Updated bugs.md with INABIAF noted by the author. Format fix README.md. --- 2011/vik/.gitignore | 2 + 2011/vik/Makefile | 4 +- 2011/vik/README.md | 153 ++++++++++++++++++++++++++------------------ 2011/vik/vik.alt.c | 93 +++++++++++++++++++++++++++ bugs.md | 8 +++ 5 files changed, 197 insertions(+), 63 deletions(-) create mode 100644 2011/vik/vik.alt.c diff --git a/2011/vik/.gitignore b/2011/vik/.gitignore index c28f954b2..2b2875d14 100644 --- a/2011/vik/.gitignore +++ b/2011/vik/.gitignore @@ -1 +1,3 @@ vik +audio_file.raw +vik.alt diff --git a/2011/vik/Makefile b/2011/vik/Makefile index 375081a9b..4fe7bbd4d 100644 --- a/2011/vik/Makefile +++ b/2011/vik/Makefile @@ -112,8 +112,8 @@ OBJ= ${PROG}.o DATA= mad_world.mod randowan.mod raw2wav TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# diff --git a/2011/vik/README.md b/2011/vik/README.md index 0c683eac0..8dc72df8d 100644 --- a/2011/vik/README.md +++ b/2011/vik/README.md @@ -1,10 +1,8 @@ # Most sound - Daniel Vik - 802 Durshire Way - Sunnyvale, Ca 94087 - - +Daniel Vik + + ## To build: @@ -18,6 +16,15 @@ make ./vik file.mod > audio_file.raw ``` +An alternate version for Windows is available. See the Alternate code section +below. + +### INABIAF - it's not a bug it's a feature! :-) + +The author stated that the program will crash if no argument is passed tot he +program though we note that your computer might also [halt and catch +fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)) :-) + ## Try: ```sh @@ -31,22 +38,31 @@ Alternatively, you can use: ./vik file.mod > file.raw; ./raw2wav file.raw > file.wav ``` -It is possible to download a number of Mod files from [The Mod Archive](http://modarchive.org). +It is possible to download a number of Mod files from [The Mod +Archive](http://modarchive.org). + +### Alternate code: + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson), though he feels +slightly sick :-), added a version for Windows based on the author's comments +(along with looking up the function for the right header file). To build try the +alt rule of the Makefile. Assuming that `make` is similar enough try: + +```sh +make alt + +``` + +Use `vik.alt` as you would `vik` above. ## Judges' remarks: -The randowan.mod and mad_world.mod files were created by -[Henrik Bertilsson](http://www.translucentboy.com) and -are included with his permission. - -### Selected Judges Remarks: - This entry converts .MOD audio files to a playable stream in a most pleasing manner if you don't like tremolo or vibrato. Also it abuses the C compiler and/or assembler with a partially -initialized 32 MByte array. Can you tell what is that partial -initilzation for? +initialized 32MB array. Can you tell what that partial +initialization for? Does it take your system a long time to compile? You may want to do try: @@ -55,100 +71,115 @@ cc -S vik.c ``` and to examine the resulting assembly file vik.s. On some platforms -the assembly file is about 128 MBytes in size! +the assembly file is about 128MB in size! + +NOTE: The [randowan.mod](randowan.mod) and [mad_world.mod](mad_world.mod) files were +created by [Henrik Bertilsson](http://www.translucentboy.com) and are included +with his permission. ## Author's remarks: ### Introduction -In 1987, Karsten Obarski changed the way music was handled in games and -demos with the introducton of the MOD file format on Commodore Amiga. +In 1987, [Karsten +Obarski](http://www.vgmpf.com/Wiki/index.php?title=Karsten_Obarski) [changed the +way](https://en.wikipedia.org/wiki/Ultimate_Soundtracker) music was handled in games and +demos with the introduction of the MOD file format on [Commodore +Amiga](https://en.wikipedia.org/wiki/Amiga) -A MOD file contains a set of samples, a number of patterns indicating -how and when the samples are to be played, a list of what patterns to -play in what order, and a number of effects. +A MOD file contains a set of samples, a number of patterns indicating how and +when the samples are to be played, a list of what patterns to play in what +order, and a number of effects. ### Features -This program converts MOD files created with the standard trackers for -Amiga, e.g. Pro Tracker, Noise Tracker and Sound Tracker to raw 16 bit -44.1kHz stereo audio. The program supports MOD music with 4, 6, and 8 +This program converts MOD files created with the standard trackers for +Amiga, e.g. Pro Tracker, Noise Tracker and Sound Tracker to raw 16 bit +44.1kHz stereo audio. The program supports MOD music with 4, 6, and 8 channels MOD files with up to 31 samples. -The MOD format includes many effects for each audio channel and this +The MOD format includes many effects for each audio channel and this program supports most of them, including: - * Arpeggio - * Slide and fine slide up/down/to note - * Set sample offset - * Volume slide - * Pattern break - * Filter on/off - * Set volume - * Cut sample - * Delay sample - * Delay pattern - * Set speed +* Arpeggio +* Slide and fine slide up/down/to note +* Set sample offset +* Volume slide +* Pattern break +* Filter on/off +* Set volume +* Cut sample +* Delay sample +* Delay pattern +* Set speed -Due to size constraints tremolo and vibrato is not supported. Also, to +Due to size constraints tremolo and vibrato is not supported. Also, to avoid infinite long songs, the position jump feature is ignored. ### Songs -With his permission, the package incldues two songs composed by Henrik +With his permission, the package includes two songs composed by Henrik Bertilsson, also known as Deelite: - 1. Mad World - 2. Randowan +1. Mad World +2. Randowan ### Build -Compiling for *nix systems (including cygwin) is straight forward: +Compiling for Unix systems (including cygwin) is straight forward: - $ gcc -o vik vik.c +```sh +gcc -o vik vik.c +``` ### Usage ### Convert MOD file to raw 44.1kHz stereo audio file - $ ./vik mad_world.mod > audio_file.raw +```sh +./vik mad_world.mod > audio_file.raw +``` ### Listen to the MOD file (streaming to mplayer) - $ ./vik randowan.mod | mplayer -demuxer rawaudio - +```sh +./vik randowan.mod | mplayer -demuxer rawaudio - +``` -(Don't forget the last '-' as it makes mplayer read from stdin.) +(Don't forget the last `-` as it makes mplayer read from stdin.) ### Obfuscation -The IOCCC rules did not put a limit on the entropy of the source code, -and it appears that the general entropy rules doesn't apply. An estimate -is that the code density entropy of this entry is ~1.2 which means that +The IOCCC rules did not put a limit on the entropy of the source code, +and it appears that the general entropy rules don't apply. An estimate +is that the code density entropy of this entry is `~1.2` which means that there are around 2500 characters of code carrying information, yet there -are only 2037 IOCCC characters of actual code. Most of the additional -characters are encoded with non-counting characters in the frequency -table. But there are also ~50 or so white space characters spread out +are only 2037 IOCCC characters of actual code. Most of the additional +characters are encoded with non-counting characters in the frequency +table. But there are also `~50` or so white space characters spread out through the source code that carry information. -The use of macros certainly adds to the obfuscation but the reason for +The use of macros certainly adds to the obfuscation but the reason for using them is mainly to fit as many features as possible within the size limits. So please excuse the use of them. -Once the preprocessor is run, the code gets more interesting. The MOD -player is basically a register based state machine and all the magic is -hidden in a fog of short statements. Many of the register updates are -conditional and the program uses the ? operator (sigh) mainly to save -space, but also to leverage the comma operator and precedence more -efficiently. +Once the preprocessor is run, the code gets more interesting. The MOD player is +basically a register based [state +machine](https://en.wikipedia.org/wiki/Finite-state_machine) and all the +[magic][] is hidden in a fog of short statements. Many of the register updates +are conditional and the program uses the `?:` operator (sigh) mainly to save +space, but also to leverage the comma operator and precedence more efficiently. + +[magic]: https://en.wikipedia.org/wiki/Magic_(programming)#Variants ### Portability -The progam is portable to most platforms. The only system dependency is +The program is portable to most platforms. The only system dependency is that the program relies on writing binary data to stdout. -Microsoft compilers adds a carriges return to newlines, and to compile -the program with this platform, the following line can be added after +Microsoft compilers adds a carriage return to newlines, and to compile +the program with this platform, the following line can be added after the main declaration in order for the program to run correctly: ```c @@ -157,7 +188,7 @@ _setmode(_fileno(stdout), 0x8000); ### Limitations -The program only runs when a valid MOD file is passed as argument. If +The program only runs when a valid MOD file is passed as argument. If no argument is passed, the program crashes. ## Copyright and CC BY-SA 4.0 License: diff --git a/2011/vik/vik.alt.c b/2011/vik/vik.alt.c new file mode 100644 index 000000000..82b71aa9e --- /dev/null +++ b/2011/vik/vik.alt.c @@ -0,0 +1,93 @@ +#include +#include +#include + +char E[1<<25]=" ; } } { { } { { ; ; { } } { { ; { { { { { } ; } { { ; { { { ; { } ; ; ; { ; ; ; } } ; } { { ; } } ; } } ; ; } { ; } } { } } } } } ; { { } } } ; } } } { } ; ; ; { } ; { { { ; { ; } } { { { } { { ; ; { { } } { { ; { { { { { } ; } { { ; { { { ; { } ; ; ; ; ; } } ; } { { ; } } ; } ; ; } { ; } } } } } } } ; { { } ; ; } ; { } ; ; ; { } ; { { ; { ; } } { { { } { ; ; { { } } { { { { { { { { ; { ; { { ; { { ; ; { } ; ", +*a[40],*q=E+20,*T=E+1080; +int i=1,j,k,l,u,w,I,J,K,h,H,G,R=4,U,e[999],*p=e+5,*r,*s,*v,b[999],L[1<<16], +F=882,n[99]; +FILE*f; + +#define Y(a,b) (a)<(b)?(a):(b) +#define Z(a,b) (a)>(b)?(a):(b) +#define X(x,a,b)Z(a,Y(b,x)) +#define O [s] +#define N [v] +#define M [r] +#define C ++ +#define m :0 +#define g m, +#define d u== +#define z(o) 32 O?n[X(32 O+o+(35 O-24)/256,0,59)]m +#define y(o) 32 O?8 O=z(o)m +#define x (p=e+5*34 O,2 M-3 && 2 M-5?y(0),l=p[4],a[i]=a[8+34 O],3 N=l>1?\ + 2*(p[3]+l):2*p[0],4 N=l>1?2*l:1,0 N=Y(2 M-9?0:9 O<<8,3 N-1) m) +#define W(t,i) (u=t[i]>>4,w=t[i]&15), +#define Q(e) ((1 N+=13200)>=5 N?1 N-=5 N, C 0 N>=3 N?0 N-=4 N m g e*6 N*q[0\ + N]/34)+ +#define D(b,i) T[i]==*#b&&T[i+2]==#b[1] +#define A ((unsigned char*)q) +#define V *p C= +#define S(a) V(A[a]<<8)|A[a+1], +#define P 2 M== +#define B ,putchar +#define o for( + +int main(int t,char**c) +{ + _setmode(_fileno(stdout), 0x8000); + o; w=E[u]; C u)n[u/10]+=(w-59?w-125?w-32?1 m:2:3)<15?132:128; + k<128; + k C) G=X(G,T[k]+1,128); + o p=L; j Cl?8 O=Z(8 O-3 O,l):8 O>4)-13))?32 O=1 M,x g + 0 O=P 12?X(3 M,0,64) m O , + P 15?(l=3 M)?l<33?t=l:(F=110250/l) m g + P 14? + W(r,3) + j?(16+u) O=j g + 8 O=d 1?Z(113,8 O-17 O):d 2?Y(856,8 O+18 O):8 O, + d 5?35 O=(j&7)-2*(j&8) g + d 9?39 O=25 O&&!1 M?x,0 m g + 0 O=d 10?Y(0 O+26 O,64):d 11?Z(0 O-27 O,0):0 O, + d 14?h=30 O m m), + 6 N =X(0 O,0,64), + 5 N =999*8 O, + i C); + o C I>=t+t*h?I=h=0,C J>=64?J=0,U|=C K>=H m g j=F; j--; 0 + B(u)B(u>>8)B(w)B(w>>8)) + o i=u=w=0; i