Merge pull request #1574 from xexyl/akari11-try

Format/typo check 2011/akari + improve try.sh
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-11-27 15:39:41 -07:00
commit 596b1604ee
15 files changed
+2904 -88

No files matched your search

+14 -5
View File
@@ -24,17 +24,26 @@ tested with Windows. See [alternate code](#alternate-code) below.
```
### Alternate code:
## Alternate code:
The author provided two additional versions, [toledo3-sbar.c](toledo3-sbar.c)
and [toledo3-txt.c](toledo3-txt.c). Respectively these create a status bar and
make the game text only. These are built by default.
make the game text only.
### Alternate build:
With the exception of the Windows version, these are built by default. To build
the Windows version, [toledo3.alt.c](toledo3.alt.c), you will have to figure out
how to compile Windows code.
### Alternate use:
Use `toledo3-sbar` and `toledo3-txt` as you would `toledo3` above.
The author also provided a version that was [tested for some compilers in
Windows](layer.c). As we have no Windows system to test with you will have to
figure out how to compile it but it did work at one time in some set ups.
As for the Windows version, `toledo3.alt`, we presume you can open it like any
other application.
## Judges' remarks:
+66
View File
@@ -0,0 +1,66 @@
#include "layer.c"
char *l="dbcefcbddabcddcba~WAB+ +BAW~ +-84HLSU?A6J57IKJT576,",
*F=" ,>>,> xl~w/? ,>>>,s m\177>>\177\177 mm2>>> >uk>>> ",*f;y,u;
#define v for (i=0,b=0;b>511?b=0,i+=64:0,i<512;b+=64) A=i/64*10+b/64+21,XCopy\
Plane(d, r[I[A]+7+14*(i+b>>6&1)+28*(A==z)],w,C,0,0,64,64,b,i,1); XFlush(d);
#define _(a) *f++=a&*F?-(z%14<7):"U\252U\0DDDD"[z/14*2|u&1],
#define G(p) p##Pixel(d,DefaultScreen(d))
#define R(a) |(a==O|p==a)*
#define P return y=~y,
#define a X(0,0,0,
#define H while(
#define D ;if(
long
I[304],b,i,z;main(x,W) char**W; { Display *d =
XOpenDisplay(""); Window w = XCreateSimpleWindow
(d, DefaultRootWindow(d), 64,64,512,512,2,G(Black)
,G(Black)); XGCValues g; XButtonEvent e; long A,r
[56],Z,* m = I , C ,Y; XSelectInput(d,w,32772);
XMapWindow( d, w); g. foreground = G(White);
C=XCreateGC(d,w,4,&g); F+=48; H f=I,i=0,z<56){
H u=0,i++<8){ H _(0)_( 64)_(16)_(8)_(4)_(2)_(1
)_(0)++u<8); F++; } F-= z%7-6?z%14<6?16:0:8; r[
z++]=XCreateBitmapFromData(d,w,I,64,64); } srand(
time(z=u=0)); H I[z]=-( z>98|z<21|(z+1)%10<2),
++z<120); H ++m<9+I) 80 [m]=-2,90[m]=~(20[m]=7&*
l++),30[m]=1; D 1<x) Z= *W[1]-45; D 2<x){ a u,1
,Z); a u,0,1); z=0; } H 1){ XNextEvent(d,&e); D
e.type==12){ v } D e. type==4){ b=e.y/64*10+e
.x/64+21; D(b[I]^y)<-1) { z=b; v} else{ i=(b<29
|b>90)&((z[I]^y)==-2)?- 6^y:z[I]; Y=y; a u,0,1);
z=0; v D 1<x&&Y-y){ a u ,1,Z); a u,0,1); } z=0;
v } } } }
X(w,c,h,e,S,s)
{ int p,O= *l,t,d,o,C ,*g,E,n,*m =I,N=-1e8,
A,L,r,x = 10,q; y=~y ; H--O>20)
{ o=I[p=O] D q=o^y,q> 0){ q+=(q< 2)*y,C=q
["51#/+++"], A=q["95+3/33"]; do { m=0,
r=I[p+=C[l ]-64] D !w |p==w&&q>1 |C+2<A|!r)
{ d=abs(O- p) D g=q<2 &e>>6==p+(
y?x:-x)?I+ (e>>6):0, !r&(q>1|d% x<1||g)|(r
^y)<-1){ n =o,t=q<2&( 89<p|30>p)
?n+=y|1,6^ y:o+(y|1) D (r^y)<-6 ) P 1e7-811
*h; H n-t) { O[I]=0,p [I]=n,m?*g
=*m,*m=0:g ?*g=0:0; E=e&63 R( 91)16 R(28)
4 R(21)2 R (98)32; L= (q>1?6-q?l
[p/x-1]-l[ O/x-1]-q+2 :(E|=y?8:1 ,!!m)*9:(E
|=20-d?0: 64*p,n-o?( l[15+n]-' '
)*9:d/8+!! g*99))+(l[ r+15]-' ') *9+l[p%x]-
h-l[O%x]; L-=s>h||s== h&L>49&1<s
?X(s>h?0:p ,L,h+1,E,N ,s):0 D !( z-O|i-n|h|
p-b|S|L<- 1e6))return u=E; O[I]=
o,p[I]=r,m ?*m=*g,*g= 0:g?*g=-2^ y:0 D S|h&&
(L>N||!h&N ==L&&rand( )&4)){ N=L
D !h&&s) i =n,z=O,b=p D h&&c-L<S ) P L; } q
>5&d<2&C+6 <A&&(g=I+p ,r=I[p+=p-
O],m=p<O?g -3:g+2,!(e &(p<O?3:5) <<3*-y|*g|
r|m[p<O?1: -1])&&L>- 1e6&&1e6>a
63,1,0))?d ++:(n+=y|1 );} } } C +=q<2&C+3>
A&((y?O<80 :39<O)||r) ; } H!r&q>
2&q<6||(p= O,++C<A)) ; } } P N+ 1e8?N:0; }
+2
View File
@@ -9,3 +9,5 @@ even_output.ppm
odd_output.ppm
akari.orig
prog.orig
rot13.c
expanded_and_rot13_output.txt
+7 -30
View File
@@ -14,30 +14,6 @@ make
### Try:
```sh
./akari < example.ppm > odd_output.ppm
./akari - - even < example.ppm > even_output.ppm
./akari example.ppm odd_output.ppm
make akari2
cat akari2.c
./akari2 < akari2.c
./akari2 rot13 < akari2.c
make akari3
cat akari3.c
./akari3
make akari4
cat akari4.c
./akari4
```
You can automate the above by running:
```sh
./try.sh
```
@@ -58,7 +34,7 @@ properly**_.
`PPM` files with the header `P6 <width> <height> 255` are accepted.
* [ASCII art](https://en.wikipedia.org/wiki/ASCII_art) (with [end of
lines](https://en.wikipedia.org/wiki/Newline) in LF bytes only, _**not** CRLF_!)
lines](https://en.wikipedia.org/wiki/Newline) in LF bytes only, _**not** CR-LF_!)
Anything that is not parsable as `PGM` or `PPM` will be downsampled as ASCII art.
@@ -68,15 +44,16 @@ Anything that is not parsable as `PGM` or `PPM` will be downsampled as ASCII art
`Akari` is an image downsampling utility. She accepts up to 3 arguments:
The first argument is the input image. If it's `-` or unspecified, `Akari`
will read from stdin.
will read from `stdin`.
The second argument is the output image. If it's `-` or unspecified,
`Akari` will write to stdout.
`Akari` will write to `stdout`.
The third argument, if specified, causes `Akari` to keep even pixels on even
[scanlines](https://en.wikipedia.org/wiki/Scan_line). By default `Akari` will
keep odd pixels on odd [scanlines](https://en.wikipedia.org/wiki/Scan_line).
### Examples:
```sh
@@ -110,8 +87,8 @@ natural to try:
```
`akari2.c` is also a valid C program, and accepts up to 1 argument.
By default, this second program reads text from stdin and writes
expanded output to stdout. If the extra argument is specified, the
By default, this second program reads text from `stdin` and writes
expanded output to `stdout`. If the extra argument is specified, the
output text will also pass through a rot13 filter.
```sh
@@ -142,7 +119,7 @@ We must go deeper:
`akari3.c` and `akari4.c` are still (mostly valid) C programs.
`gcc -Wall` will output a few warnings, but still produce output
executables. The output executables each print a message to stdout.
executables. The output executables each print a message to `stdout`.
It takes quite a bit of skill and obfuscation to interleave a
C program 4 levels deep, it's much easier to interleave something like
+29 -3
View File
@@ -24,18 +24,44 @@ clear
./akari - - even < example.ppm > even_output.ppm
./akari example.ppm odd_output.ppm
make akari2 || exit 1
make akari2 >/dev/null|| exit 1
read -r -n 1 -p "Press any key to cat akari2.c: "
cat akari2.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./akari2 < akari2.c: "
./akari2 < akari2.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari2.c: "
./akari2 rot13 < akari2.c
make akari3 || exit 1
make akari3 >/dev/null|| exit 1
read -r -n 1 -p "Press any key to cat akari3.c: "
cat akari3.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./akari3: "
./akari3
echo 1>&2
make akari4 || exit 1
make akari4 >/dev/null|| exit 1
read -r -n 1 -p "Press any key to cat akari4.c: "
cat akari4.c
read -r -n 1 -p "Press any key to run: ./akari4: "
./akari4
echo 1>&2
read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari.c | ./akari > rot13.c; cat rot13.c: "
./akari2 rot13 < akari.c | ./akari > rot13.c; cat rot13.c
read -r -n 1 -p "Press any key to run: ./akari2 < akari.c > expanded_output.txt: "
./akari2 < akari.c > expanded_output.txt
read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari.c > expanded_and_rot13_output.txt: "
./akari2 rot13 < akari.c > expanded_and_rot13_output.txt
read -r -n 1 -p "Press any key to cat expanded_and_rot13_output.txt: "
cat expanded_and_rot13_output.txt
+2
View File
@@ -1,3 +1,5 @@
toledo
toledo.alt
toledo.alt2
toledo.orig
prog.orig
+6 -2
View File
@@ -120,8 +120,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
@@ -139,11 +139,15 @@ all: data ${TARGET}
${PROG}: ${PROG}.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
# alternative executable
#
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
# data files
#
data: ${DATA}
+76 -25
View File
@@ -1,9 +1,15 @@
## To build:
If you have X11 installed:
```sh
make
```
There are two alternate versions, [one that lets you reconfigure the
controls and size](toledo.alt.c) and [another that should work for
Windows](toledo.alt2.c). See [Alternate code](#alternate-code) below.
## To use:
@@ -11,25 +17,58 @@ make
./toledo
```
NOTE: This requires X11 to run or modifications to use [layer.c](layer.c) on
Windows (see below).
## Alternate code:
The first alt version, [toledo.alt.c](toledo.alt.c), allows you to reconfigure
the controls and the dimensions more easily.
The second version, [toledo.alt2.c](toledo.alt2.c), should work for Windows but
does not allow you to reconfigure the keys or dimensions.
### Try:
### Alternate build:
For the one that lets you reconfigure the keys you will want to look at the
included header file, [keysym.h](keysym.h), to find the correct macros. Once you
have the right names you can define the macros `A`, `B`, `C`, `D` and/or `E`. It
will use the default for any you do not specify. For instance, to swap what `A`
and `B` are (see below for defaults of all keys):
```sh
echo "Do or do not. There is no try."
make clobber CDEFINE="-DA=XK_Left:XK_a -DB=XK_Up:XK_w" alt
```
but you can specify something completely else and you can pick and choose which
controls you wish to redefine. You might also wish to change the dimensions of
the game, `M` and `N` which have an arbitrarily selected lower limit as well as
the default values.
Here are the defaults:
```c
#define A XK_Up:XK_w
#define B XK_Left:XK_a
#define C XK_Right:XK_d
#define D XK_Down:XK_s
#define E XK_BackSpace:XK_Tab
#define M 512
#define N 288
```
Observe that each of the controls are a pair in the form of `player2:player1`.
## Judges' remarks:
This two player game uses X11. The control keys can be configured by
modifying the `A`, `B`, `C` and `D` macros at compilation.
modifying the `A`, `B`, `C`, `D` and `E` macros at compilation.
After a quick splash screen the objective should be clear. There
are Red, Green and Cyan tanks. A larger window can be made by altering
the source early on, right before the code gets hard to follow.
the source early on, right before the code gets hard to follow, or using the
[alternate version](#alternate-code).
Like Oscar's previous winning X11 program for the 19th IOCCC, if
you remove both the X11 include files and replace them with
@@ -37,8 +76,9 @@ you remove both the X11 include files and replace them with
```c
#include "layer.c"
```
\
you ought to be able to compile and run this program on Windows.
NOTE: this is what [toledo.alt2.c](toledo.alt2.c) is for.
## Author's remarks:
@@ -58,26 +98,29 @@ and run it without arguments.
You will see briefly a tank spinning before each level.
Left half of the window shows the red player view and right
half shows the green player view, the background will change to
The Left half of the window shows the red player view and the right
half shows the green player view; the background will change to
blue when the view goes inactive.
The objective is to chase and destroy the other player's tank,
there is also an aqua tank for testing your aim and getting
The objective is to chase and destroy the other player's tank.
There is also an aqua tank for testing your aim and getting
extra points.
> Caveat: You can shoot only 3 bullets at a time.
> Trick: You can fire faster if they explode on anything.
> Believe it or not, it has strategy!
Caveat: You can shoot only 3 bullets at a time.
\
Trick: You can fire faster if they explode on anything.
\
Believe it or not, it has strategy!
When only one tank remains on the field, the level will advance.
Don't forget to destroy the aqua tank.
The <strike>battle</strike>playground is surrounded by mountains and each level is
The <strike>battle</strike>playground is surrounded by mountains and each level is
filled with random obstacles (pyramids and cubes).
The bars show players energy and score, each bar shows energy
and indicates current player view (wider on the left), right
The bars show players energy and score; each bar shows energy
and indicates the current player view (wider on the left). The right
part grows with every point.
Keys for player 1 (lowercase):
@@ -96,18 +139,21 @@ Keys for player 2:
* Left arrow - Turn left
* Right arrow - Turn right
> Note: Numeric keys don't work.
Note: Numeric keys don't work.
If you don't like the keys assignment, you can change it in the
Makefile.
Makefile or use the [alternate version](#alternate-code).
### PARENTAL ADVISORY WARNING:
This game is highly violent, when the tank explodes you can
This game is highly violent: when the tank explodes you can
see the little stick man blowing in parts.
Not really, just kidding :D
### PLATFORMS TESTED:
* openSUSE 10.2 x86-32, X11R6 1024x768 32-bits color.
@@ -115,6 +161,7 @@ Not really, just kidding :D
* Fedora Core 11 x86-64, X11R6 1024x768 32-bits color.
* Fedora Core 14 x86-64, X11R6 1024x768 32-bits color.
### COMPLETE FEATURE SET:
* Multiplayer out of the box.
@@ -127,7 +174,8 @@ Not really, just kidding :D
* There is an infinite number of levels.
* Always different levels.
* Animated intro.
* It has color!.
* It has color!
### FEATURES THAT PROGRAMMERS WILL FIND APPEALING:
@@ -140,9 +188,9 @@ Not really, just kidding :D
x86-64 512 MB).
* It is written in the only true C: K&R, and no, that doesn't mean
Katherine & Rose.
* Vectorial scalable graphics, do you want a bigger viewport? Change variables M
`&` `N`.
* Half of the program is formatted as 3D cube. View with tabs at 8 columns and a\
* Vectorial scalable graphics: do you want a bigger viewport? Change variables
`M` and `N` (see the [alternate code](#alternate-code)).
* Half of the program is formatted as 3D cube. View with tabs at 8 columns and a
square font.
* The other half of the program is unprintable source code, so no typing from
paper, you have to write a converter of tabs and form-feeds to its C escaped
@@ -152,6 +200,7 @@ Not really, just kidding :D
* Virtual world with its own physics laws.
* When closing the window it will show an X11 error :P
### OBFUSCATION TRICKS:
* Loop code included inside loop test.
@@ -185,6 +234,7 @@ Not really, just kidding :D
```
### THE HISTORY OF THIS PROGRAM:
When I started working on this program, I figured that it would
@@ -203,7 +253,7 @@ the user.
And finally, the third "Thing" was growing and growing, and
growing, eating bytes for lunch... after endless rounds of
crunching I obtained three-hundred seventy-eight bytes of
crunching I obtained three-hundred seventy-eight bytes of
artwork and guess what? It doesn't fit.
So I had to integrate a decompressor based on the space, tabulators and other
@@ -229,6 +279,7 @@ exceeded the character limits. The crunched vectors were generated by another
special program and the tank that surrounds this text was generated by yet
another program.
*Have fun!*
+2501
View File
File diff suppressed because it is too large. Load diff
+95
View File
@@ -0,0 +1,95 @@
#include <X11/Xlib.h>
#include <X11/keysym.h>
#define I XDrawLine(W,X,Y,
#define l rand()%
#define R while(
#define n *h++
#define x _ c].
#define S if(
#define _ _[
#ifndef A
#define A XK_Up:XK_w
#endif
#ifndef B
#define B XK_Left:XK_a
#endif
#ifndef C
#define C XK_Right:XK_d
#endif
#ifndef D
#define D XK_Down:XK_s
#endif
#ifndef E
#define E XK_BackSpace:XK_Tab
#endif
#ifndef Q
#define Q XFillRectangle(W,X,Y,
#endif
#ifndef M
#define M 512
#elif M < 250
#undef M
#define M 512
#endif
#ifndef N
#define N 288
#elif N < 100
#undef N
#define N 288
#endif
*h ;
; i;
e; d; u; p; L[1
<<28]; float w=11.46; m; a ;
P; k[9304]; *j=k; c; f; q; r; t; v ;
* z; K(H,i) { t=u*+cos(H/w)-i*sin(H/w); p=i*
cos(H/w)+u*sin(H/w); u=t; } Display*W; GC Y; Pixmap
X; s(o,t,g,w,v) { h=v+k; q=2*n; R u=n, r=12+n, K(t,n), K(o,+
p+w,u+=g), d=1>p?1:p, u=u*N/d+M/2, d=N/2+r*N/d, u=u>
-M*2 ?u<M*2?u:2*M:-2*M, 1&q?i>0|p>0?I f,e,u,d):0: (i=p
,e=d,f=u ), --q); } struct{ int c,o,m,f,u,s,i ,e,r; }
_ 21 ] ; Window O; b(y) { XGCValues g ; g .
foreground=y; g. line_width = 2 ; XChangeGC(W,Y,20
,&g); } G(o) { z=x f + k; h=(x f= 381+193*c)+k; i=2*(n
=*z++); R--i&1?d=l 9-4,e =l 9 -4*(8>o):0,n=*z+++d,0<(n
=*z+++e)?h[-1]=0:0,n=*z+++d, i); } g(o) { u=0; K(x s,o<<9
); x u-=u; x r-=p; } F(m,c ) { f=5120*c; c=12; R +c--&&m
==+c |abs(x u-_ m].u)>f |x i <1|x c>2 |abs(x r-_ m].r)>f)
; return c+1; } T(o) { c=11; S!P){ a=++a%72; S!a){ P=1; R
c--){ x c=x m=0; x i=c>2?2:1 ; R x u=l 978-499<<8, x s= l
71, x r=l 979-501<<8, F(c,2) ); x f=c>2?l +2*+73:147; x o
=2>c?249<<16-c*8:64987<<8*(c >2); } } } S P){ c=11; R 4&x
i? ++x m-64&&x m-71? o=1,64> x m?(d=F(c,1))?x m=64,d<4?j[
x e]++,++_ --d].c:0:g(7):G(x m -65) :_ x i=0,x e].e-- :0,
20>++c); c=3; R c--) { S 1&x i) { o++; S x c>2) x m>15? x
i=0:G(x m++); else { S x m ) S x m-->6) g(4); S c<2) { x
s=(72+x s+L[c?B]-L[c?C])%72; S d=4*L[c?A]-L[c?D]*4) { g(d
); S F(c,2)) g(-d); } S L[c? E]&!x m&x e<3) { d=10; R _++
d].i) ; g(-4); _ d]=_ c]; _ d].e=c; x e++; x m=7; c=d; x
f = 122 ; x i=4; g(19); x o= 4092<<12; c=x e; } } } } } P
-=o<2; } v=2; R v--){ m=(108 - _ v].s)%72; b(3^_ v].c?0:
128); Q c=0,0,M,N); S!P) s(+ 36,54-a,0,-120,-+-+-+-+147,b
((1<<16)-1)); S P) { b(255); I 0,N/2,M,N/2); t=-.889*m; h
=k+340; R u=(t+=q=n)*M/32,d= n*N/48,q?I f,e,u,d):0,f=u,e=
+d,k+378>h); R x i&&c-v?s(m, x s,x u-_ v].u>>8,x r-_ v].r
>>8,x f,b(x o)):0,20>c++); c =0; R e=16+32*c,Q v^c?16:8,e
,(c^v?68:76)+c[b(x o),j] , 16), b(0,d=20*x c), Q
80-d,4+e,d,8),2>c++) ; } b(255); I M,0,M,
N); XCopyArea(W, X,O,Y,0,0,M,N,v*
M,0); } }
char*o="{ } { } { { } ; { } ; { ; { ; { ; { } ; { } ; { ; { ; } ; { ; { } } ; { ; } { } ; { ; { } ; { ; } { } { { } ; { } ; { ; { ; } { } { } } { } { } { } } { } } { } { } { } } { } { } { ; ; ; ; } { ; } { { } ; } } ; { ; } { ; } { { } ; { } ; { ; { ; } } { ; } { { } } } { ; } { ; { } ; } } } { } { } ; } } } } } { } ; } ; } ; { } { } ; { } ; } ; } } { } { } } { } { } } } } { { } } } } } { { } } { ; { { } ; { ; { { ; { ; { { } ; { ; { { ; ; } ; ; } ; ; } } { { } { { } { { { { } } } } } { { { { } { } { { } { { } { { { { } } ";
main(){
XEvent e; W=
XOpenDisplay(k);
XSelectInput(W,O=
XCreateSimpleWindow(W,DefaultRootWindow(W),64,64,M*2,N,2,P,r),3);
XMapWindow(W,O); srand(time(0)); Y=
XCreateGC(W,X=
XCreatePixmap(W,O,M,N,DefaultDepth(W,r)),P,r); R*o){ S*o^59)d=64&*o?'{'^*o++:3,
32^*o?d+=*o^9?2:1:0,*j+=P?d*9-43:d,j+=P,P=!P; else R*j=j[-3],j++,*++o^9); o++;
} R 7){ T(0);
XFlush(W); usleep(33367); R
XPending(W)) L[
XLookupKeysym(&e,
XNextEvent(W,&e)&0)]^=1==e.type/2; } }
+63
View File
@@ -0,0 +1,63 @@
#include "layer.h"
#define I XDrawLine(W,X,Y,
#define l rand()%
#define R while(
#define n *h++
#define x _ c].
#define S if(
#define _ _[
*h ;
M=512; i; N=
288; e; d; u; p; L[1
<<28]; float w=11.46; m; a ;
P; k[9304]; *j=k; c; f; q; r; t; v ;
* z; K(N,i) { t=u*+cos(N/w)-i*sin(N/w); p=i*
cos(N/w)+u*sin(N/w); u=t; } Display*W; GC Y; Pixmap
X; s(o,t,g,w,v) { h=v+k; q=2*n; R u=n, r=12+n, K(t,n), K(o,+
p+w,u+=g), d=1>p?1:p, u=u*N/d+M/2, d=N/2+r*N/d, u=u>
-M*2 ?u<M*2?u:2*M:-2*M, 1&q?i>0|p>0?I f,e,u,d):0: (i=p
,e=d,f=u ), --q); } struct{ int c,o,m,f,u,s,i ,e,r; }
_ 21 ] ; Window O; b(y) { XGCValues g ; g .
foreground=y; g. line_width = 2 ; XChangeGC(W,Y,20
,&g); } G(o) { z=x f + k; h=(x f= 381+193*c)+k; i=2*(n
=*z++); R--i&1?d=l 9-4,e =l 9 -4*(8>o):0,n=*z+++d,0<(n
=*z+++e)?h[-1]=0:0,n=*z+++d, i); } g(o) { u=0; K(x s,o<<9
); x u-=u; x r-=p; } F(m,c ) { f=5120*c; c=12; R +c--&&m
==+c |abs(x u-_ m].u)>f |x i <1|x c>2 |abs(x r-_ m].r)>f)
; return c+1; } T(o) { c=11; S!P){ a=++a%72; S!a){ P=1; R
c--){ x c=x m=0; x i=c>2?2:1 ; R x u=l 978-499<<8, x s= l
71, x r=l 979-501<<8, F(c,2) ); x f=c>2?l +2*+73:147; x o
=2>c?249<<16-c*8:64987<<8*(c >2); } } } S P){ c=11; R 4&x
i? ++x m-64&&x m-71? o=1,64> x m?(d=F(c,1))?x m=64,d<4?j[
x e]++,++_ --d].c:0:g(7):G(x m -65) :_ x i=0,x e].e-- :0,
20>++c); c=3; R c--) { S 1&x i) { o++; S x c>2) x m>15? x
i=0:G(x m++); else { S x m ) S x m-->6) g(4); S c<2) { x
s=(72+x s+L[c?B]-L[c?C])%72; S d=4*L[c?A]-L[c?D]*4) { g(d
); S F(c,2)) g(-d); } S L[c? E]&!x m&x e<3) { d=10; R _++
d].i) ; g(-4); _ d]=_ c]; _ d].e=c; x e++; x m=7; c=d; x
f = 122 ; x i=4; g(19); x o= 4092<<12; c=x e; } } } } } P
-=o<2; } v=2; R v--){ m=(108 - _ v].s)%72; b(3^_ v].c?0:
128); Q c=0,0,M,N); S!P) s(+ 36,54-a,0,-120,-+-+-+-+147,b
((1<<16)-1)); S P) { b(255); I 0,N/2,M,N/2); t=-.889*m; h
=k+340; R u=(t+=q=n)*M/32,d= n*N/48,q?I f,e,u,d):0,f=u,e=
+d,k+378>h); R x i&&c-v?s(m, x s,x u-_ v].u>>8,x r-_ v].r
>>8,x f,b(x o)):0,20>c++); c =0; R e=16+32*c,Q v^c?16:8,e
,(c^v?68:76)+c[b(x o),j] , 16), b(0,d=20*x c), Q
80-d,4+e,d,8),2>c++) ; } b(255); I M,0,M,
N); XCopyArea(W, X,O,Y,0,0,M,N,v*
M,0); } }
char*o="{ } { } { { } ; { } ; { ; { ; { ; { } ; { } ; { ; { ; } ; { ; { } } ; { ; } { } ; { ; { } ; { ; } { } { { } ; { } ; { ; { ; } { } { } } { } { } { } } { } } { } { } { } } { } { } { ; ; ; ; } { ; } { { } ; } } ; { ; } { ; } { { } ; { } ; { ; { ; } } { ; } { { } } } { ; } { ; { } ; } } } { } { } ; } } } } } { } ; } ; } ; { } { } ; { } ; } ; } } { } { } } { } { } } } } { { } } } } } { { } } { ; { { } ; { ; { { ; { ; { { } ; { ; { { ; ; } ; ; } ; ; } } { { } { { } { { { { } } } } } { { { { } { } { { } { { } { { { { } } ";
main(){
XEvent e; W=
XOpenDisplay(k);
XSelectInput(W,O=
XCreateSimpleWindow(W,DefaultRootWindow(W),64,64,M*2,N,2,P,r),3);
XMapWindow(W,O); srand(time(0)); Y=
XCreateGC(W,X=
XCreatePixmap(W,O,M,N,DefaultDepth(W,r)),P,r); R*o){ S*o^59)d=64&*o?'{'^*o++:3,
32^*o?d+=*o^9?2:1:0,*j+=P?d*9-43:d,j+=P,P=!P; else R*j=j[-3],j++,*++o^9); o++;
} R 7){ T(0);
XFlush(W); usleep(33367); R
XPending(W)) L[
XLookupKeysym(&e,
XNextEvent(W,&e)&0)]^=1==e.type/2; } }
+22 -22
View File
@@ -4,6 +4,9 @@
make
```
There is an alternate version that should work for Windows. See [alternate
code](#alternate-code) below.
### Bugs and (Mis)features:
@@ -22,20 +25,6 @@ For more detailed information see [2011 vik in bugs.md](/bugs.md#2011-vik).
./vik file.mod > audio_file.raw
```
An alternate version for Windows is available. See the Alternate code section
below.
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)) :-)
This is supposed to happen. As is written in the
[The Jargon File](http://catb.org/jargon/html/F/feature.html):
```
That's not a bug, that's a feature.
```
### Try:
@@ -47,10 +36,10 @@ That's not a bug, that's a feature.
Alternatively, you can use:
```sh
./vik file.mod > file.raw; ./raw2wav file.raw > file.wav\
./vik file.mod > file.raw; ./raw2wav file.raw > file.wav
```
It is possible to download a number of Mod files from [The Mod
It is possible to download a number of music module files from [The Mod
Archive](http://modarchive.org).
@@ -63,6 +52,8 @@ make alt
```
### Alternate use:
Use `vik.alt` as you would `vik` above.
@@ -75,13 +66,13 @@ Also it abuses the C compiler and/or assembler with a partially
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:
Does it take your system a long time to compile? You may want to do:
```sh
cc -S vik.c
```
and to examine the resulting assembly file vik.s. On some platforms
and examine the resulting assembly file `vik.s`. On some platforms
the assembly file is about 128MB in size!
NOTE: The [randowan.mod](randowan.mod) and [mad_world.mod](mad_world.mod) files were
@@ -103,6 +94,7 @@ 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
@@ -128,6 +120,7 @@ program supports most of them, including:
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 includes two songs composed by Henrik
@@ -147,19 +140,21 @@ gcc -o vik vik.c
### Usage
### Convert MOD file to raw 44.1kHz stereo audio file
#### Convert MOD file to raw 44.1kHz stereo audio file
```sh
./vik mad_world.mod > audio_file.raw
```
### Listen to the MOD file (streaming to mplayer)
#### Listen to the MOD file (streaming to mplayer)
```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
@@ -183,12 +178,14 @@ machine](https://en.wikipedia.org/wiki/Finite-state_machine) and all the
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 program is portable to most platforms. The only system dependency is
that the program relies on writing binary data to stdout.
that the program relies on writing binary data to `stdout`.
Microsoft compilers adds a carriage return to newlines, and to compile
the program with this platform, the following line can be added after
@@ -198,6 +195,9 @@ the main declaration in order for the program to run correctly:
_setmode(_fileno(stdout), 0x8000);
```
NOTE: this is what the [alternate version](#alternate-code) is for.
### Limitations
The program only runs when a valid MOD file is passed as argument. If
+2
View File
@@ -1,7 +1,9 @@
image.ppm
image.png
hello.ppm
image2.ppm
ioccc2011.ppm
ioccc2011.png
zucker
zucker.orig
prog.orig
+2 -1
View File
@@ -2471,7 +2471,8 @@ instead being something else entirely. The Internet Wayback Machine, although it
archived it, did not load scripts. Do you know if the domain was moved? Do you
have an archive or mirror? Please provide us it! Thank you.
### STATUS: known bug - please help us fix
### STATUS: INABIAF - please **DO NOT** fix
The author states the following:
+17
View File
@@ -3198,10 +3198,19 @@ lets it work in both linux and macOS. The problem was that it relied on 32-bits
so some `int`s were changed to `long`s. The display problem might or might not
have been a problem in linux with the old `int`s but this is no longer known.
Cody also added the code that _should_ work for Windows,
[toledo3.alt.c](2006/toledo3/toledo3.alt.c), based on the author's remarks.
We're not able to test this.
# <a name="2011"></a>2011
## [2011/akari](2011/akari/akari.c) ([README.md](2011/akari/README.md]))
Cody added the [try.sh](2011/akari/try.sh) script.
## [2011/borsanyi](2011/borsanyi/borsanyi.c) ([README.md](2011/borsanyi/README.md]))
Cody, out of an abundance of caution, added a second arg to `main()` as some
@@ -3255,6 +3264,14 @@ try. If they do they might want to look also at
not be worth.
## [2011/toledo](2011/toledo/toledo.c) ([README.md](2011/toledo/README.md]))
Cody added two [alternate versions](2011/toledo/README.md#alternate-code): one that
lets one reconfigure the controls and also the size of the game and another
version that should work in Windows, based on the author's remarks and support
file, `layer.c`.
## [2011/vik](2011/vik/vik.c) ([README.md](2011/vik/README.md]))
Cody added an [alternate version](2011/vik/README.md#alternate-code) for Windows