Add alt versions to 2004/gavin + format/typo check
There already was one alt version which I found from the author's website about the entry; they used the version for development and it's unobfuscated. But two new ones were added. The most important feature is that it allows one to change the image size along with the anti-alias setting at compile time. This is gavare.alt.c. The second version (which also has the size/anti-alias changes) should theoretically work for Windows. This is gavare.alt2.c and running make alt will not try and compile it as most it'll fail on sane systems. Instead try make alt2. Both of these versions have some form of protection with the size/anti-alias setting and one does not have to define all three to get it to compile due to '#ifndef..#elif..#endif' in the code. The README.md file has been format/typo fixed.
This commit is contained in:
1 parent
58bc8c1a8b
commit
1d8c7abf09
6 files changed
+164
-19
No files matched your search
@@ -1,4 +1,5 @@
|
||||
gavare
|
||||
gavare.alt
|
||||
ioccc_ray.ppm
|
||||
gavare.r3
|
||||
gavare.orig
|
||||
|
||||
+12
-3
@@ -58,7 +58,7 @@ ARCH=
|
||||
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
CDEFINE=
|
||||
CDEFINE= -DXX=1024 -DYY=768 -DAA=3
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
@@ -114,8 +114,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ= ${PROG}.r3.o
|
||||
ALT_TARGET= ${PROG}.r3
|
||||
ALT_OBJ= ${PROG}.r3.o ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.r3 ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
@@ -138,6 +138,15 @@ ${PROG}: ${PROG}.c
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
alt2: ${PROG}.alt2
|
||||
@${TRUE}
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
${PROG}.alt2: ${PROG}.alt2.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
|
||||
+53
-13
@@ -4,6 +4,9 @@
|
||||
make
|
||||
```
|
||||
|
||||
There are three alternate versions; see [alternate code](#alternate-code) below
|
||||
for more details.
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
@@ -18,27 +21,61 @@ make
|
||||
./gavare > ioccc_ray.ppm
|
||||
```
|
||||
|
||||
|
||||
## Alternate code:
|
||||
|
||||
The author provided [on their web page for the
|
||||
entry](https://gavare.se/ioccc/ioccc_gavare.c.html) an unobfuscated version that was used
|
||||
during development, which we have included in the file
|
||||
[gavare.r3.c](gavare.r3.c). To compile, try:
|
||||
The alt code, [gavare.alt.c](gavare.alt.c), allows you to change the size of the
|
||||
image as well as the anti-alias setting, when compiling.
|
||||
|
||||
The author also provided [on their web page for the
|
||||
entry](https://gavare.se/ioccc/ioccc_gavare.c.html) an unobfuscated version that
|
||||
was used during development, which we have included in the file
|
||||
[gavare.r3.c](gavare.r3.c).
|
||||
|
||||
Finally, there's an untested version for Windows,
|
||||
[gavare.alt2.c](gavare.alt2.c), that sets binary mode on `stdout`.
|
||||
|
||||
|
||||
### Alternate build:
|
||||
|
||||
To build the configurable and unobfuscated versions:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `gavare.r3` as you would `gavare` above.
|
||||
To change the default size from 1024x768 try:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DXX=640 -DYY=480" alt
|
||||
```
|
||||
|
||||
You might also wish to change the anti-alias setting:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DAA=2" alt
|
||||
```
|
||||
|
||||
This is not possible with the author's version but it is with the Windows
|
||||
version (see below).
|
||||
|
||||
As the Windows version will not compile on most viewers' systems we do not build
|
||||
it with `make alt`; instead try:
|
||||
|
||||
```sh
|
||||
make alt2
|
||||
```
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
Use `gavare.alt`, `gavare.r3` or `gavare.alt2` as you would `gavare` above.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
For users of systems that distinguish between text and binary mode
|
||||
(you know who you are), add a library call that specifies binary mode
|
||||
for stdout as the first statement of `main()`,
|
||||
for `stdout` as the first statement of `main()`,
|
||||
or use `freopen("ioccc_ray.ppm", "wb", stdout);` and do not use redirection.
|
||||
|
||||
A freely distributable command-line version of Microsoft Visual C
|
||||
@@ -55,15 +92,17 @@ It is possible to write some kinds of programs in C without using reserved
|
||||
words. For very short and trivial programs, it usually isn't very hard to
|
||||
write a variant using no reserved words, but with this program I want to
|
||||
show that also non-trivial programs can be written this way. This IOCCC
|
||||
entry contains no reserved words (I don't count 'main' as a reserved word,
|
||||
entry contains no reserved words (I don't count `main` as a reserved word,
|
||||
although the compiler gives it special meaning) and no preprocessor
|
||||
directives.
|
||||
|
||||
The program is a small ray-tracer. The first line of the source code may
|
||||
be modified if you want the resulting image to be of some other resolution
|
||||
than the predefined. The `A` value is an anti-alias factor. Setting it to
|
||||
`1` disables the anti-aliasing feature (this makes the output look bad), but
|
||||
setting it too high makes the trace take a lot more time to complete.
|
||||
The program is a small
|
||||
[ray-tracer](https://en.wikipedia.org/wiki/Ray_tracing_(graphics)). The first
|
||||
line of the source code may be modified if you want the resulting image to be of
|
||||
some other resolution than the predefined. The `A` value is an anti-alias
|
||||
factor. Setting it to `1` disables the anti-aliasing feature which makes the
|
||||
output look bad, but setting it too high makes the trace take a lot more time
|
||||
to complete.
|
||||
|
||||
The ppm image can then be viewed using an image viewer of your own choice.
|
||||
(Running the ray-tracer may take several minutes, even on fast machines,
|
||||
@@ -75,6 +114,7 @@ declarations are implicit. There will no doubt be _lots_ of warnings,
|
||||
no matter which compiler is used. Still, the source code should be word-
|
||||
length-independent and endianness-independent.
|
||||
|
||||
|
||||
### Humor
|
||||
|
||||
Another reason for writing code without using reserved words is that many
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef XX
|
||||
#define XX 1024
|
||||
#elif XX < 1
|
||||
#undef XX
|
||||
#define XX 1024
|
||||
#endif
|
||||
|
||||
#ifndef YY
|
||||
#define YY 768
|
||||
#elif YY < 1
|
||||
#undef YY
|
||||
#define YY 768
|
||||
#endif
|
||||
|
||||
#ifndef AA
|
||||
#define AA 3
|
||||
#elif AA < 1
|
||||
#define AA 3
|
||||
#endif
|
||||
|
||||
X=XX; Y=YY; A=AA;
|
||||
|
||||
J=0;K=-10;L=-7;M=1296;N=36;O=255;P=9;_=1<<15;E;S;C;D;F(b){E="1""111886:6:??AAF"
|
||||
"FHHMMOO55557799@@>>>BBBGGIIKK"[b]-64;C="C@=::C@@==@=:C@=:C@=:C5""31/513/5131/"
|
||||
"31/531/53"[b ]-64;S=b<22?9:0;D=2;}I(x,Y,X){Y?(X^=Y,X*X>x?(X^=Y):0, I (x,Y/2,X
|
||||
)):(E=X); }H(x){I(x, _,0);}p;q( c,x,y,z,k,l,m,a, b){F(c
|
||||
);x-=E*M ;y-=S*M ;z-=C*M ;b=x* x/M+ y*y/M+z
|
||||
*z/M-D*D *M;a=-x *k/M -y*l/M-z *m/M; p=((b=a*a/M-
|
||||
b)>=0?(I (b*M,_ ,0),b =E, a+(a>b ?-b:b)): -1.0);}Z;W;o
|
||||
(c,x,y, z,k,l, m,a){Z=! c? -1:Z;c <44?(q(c,x ,y,z,k,
|
||||
l,m,0,0 ),(p> 0&&c!= a&& (p<W ||Z<0) )?(W=
|
||||
p,Z=c): 0,o(c+ 1, x,y,z, k,l, m,a)):0 ;}Q;T;
|
||||
U;u;v;w ;n(e,f,g, h,i,j,d,a, b,V){o(0 ,e,f,g,h,i,j,a);d>0
|
||||
&&Z>=0? (e+=h*W/M,f+=i*W/M,g+=j*W/M,F(Z),u=e-E*M,v=f-S*M,w=g-C*M,b=(-2*u-2*v+w)
|
||||
/3,H(u*u+v*v+w*w),b/=D,b*=b,b*=200,b/=(M*M),V=Z,E!=0?(u=-u*M/E,v=-v*M/E,w=-w*M/
|
||||
E):0,E=(h*u+i*v+j*w)/M,h-=u*E/(M/2),i-=v*E/(M/2),j-=w*E/(M/2),n(e,f,g,h,i,j,d-1
|
||||
,Z,0,0),Q/=2,T/=2, U/=2,V=V<22?7: (V<30?1:(V<38?2:(V<44?4:(V==44?6:3))))
|
||||
,Q+=V&1?b:0,T +=V&2?b :0,U+=V &4?b:0) :(d==P?(g+=2
|
||||
,j=g>0?g/8:g/ 20):0,j >0?(U= j *j/M,Q =255- 250*U/M,T=255
|
||||
-150*U/M,U=255 -100 *U/M):(U =j*j /M,U<M /5?(Q=255-210*U
|
||||
/M,T=255-435*U /M,U=255 -720* U/M):(U -=M/5,Q=213-110*U
|
||||
/M,T=168-113*U / M,U=111 -85*U/M) ),d!=P?(Q/=2,T/=2
|
||||
,U/=2):0);Q=Q< 0?0: Q>O? O: Q;T=T<0? 0:T>O?O:T;U=U<0?0:
|
||||
U>O?O:U;}R;G;B ;t(x,y ,a, b){n(M*J+M *40*(A*x +a)/X/A-M*20,M*K,M
|
||||
*L-M*30*(A*y+b)/Y/A+M*15,0,M,0,P, -1,0,0);R+=Q ;G+=T;B +=U;++a<A?t(x,y,a,
|
||||
b):(++b<A?t(x,y,0,b):0);}r(x,y){R=G=B=0;t(x,y,0,0);x<X?(printf("%c%c%c",R/A/A,G
|
||||
/A/A,B/A/A),r(x+1,y)):0;}s(y){r(0,--y?s(y),y:y);}main(){printf("P6\n%i %i\n255"
|
||||
"\n",X,Y);s(Y);}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
X=XX; Y=YY; A=AA;
|
||||
|
||||
J=0;K=-10;L=-7;M=1296;N=36;O=255;P=9;_=1<<15;E;S;C;D;F(b){E="1""111886:6:??AAF"
|
||||
"FHHMMOO55557799@@>>>BBBGGIIKK"[b]-64;C="C@=::C@@==@=:C@=:C@=:C5""31/513/5131/"
|
||||
"31/531/53"[b ]-64;S=b<22?9:0;D=2;}I(x,Y,X){Y?(X^=Y,X*X>x?(X^=Y):0, I (x,Y/2,X
|
||||
)):(E=X); }H(x){I(x, _,0);}p;q( c,x,y,z,k,l,m,a, b){F(c
|
||||
);x-=E*M ;y-=S*M ;z-=C*M ;b=x* x/M+ y*y/M+z
|
||||
*z/M-D*D *M;a=-x *k/M -y*l/M-z *m/M; p=((b=a*a/M-
|
||||
b)>=0?(I (b*M,_ ,0),b =E, a+(a>b ?-b:b)): -1.0);}Z;W;o
|
||||
(c,x,y, z,k,l, m,a){Z=! c? -1:Z;c <44?(q(c,x ,y,z,k,
|
||||
l,m,0,0 ),(p> 0&&c!= a&& (p<W ||Z<0) )?(W=
|
||||
p,Z=c): 0,o(c+ 1, x,y,z, k,l, m,a)):0 ;}Q;T;
|
||||
U;u;v;w ;n(e,f,g, h,i,j,d,a, b,V){o(0 ,e,f,g,h,i,j,a);d>0
|
||||
&&Z>=0? (e+=h*W/M,f+=i*W/M,g+=j*W/M,F(Z),u=e-E*M,v=f-S*M,w=g-C*M,b=(-2*u-2*v+w)
|
||||
/3,H(u*u+v*v+w*w),b/=D,b*=b,b*=200,b/=(M*M),V=Z,E!=0?(u=-u*M/E,v=-v*M/E,w=-w*M/
|
||||
E):0,E=(h*u+i*v+j*w)/M,h-=u*E/(M/2),i-=v*E/(M/2),j-=w*E/(M/2),n(e,f,g,h,i,j,d-1
|
||||
,Z,0,0),Q/=2,T/=2, U/=2,V=V<22?7: (V<30?1:(V<38?2:(V<44?4:(V==44?6:3))))
|
||||
,Q+=V&1?b:0,T +=V&2?b :0,U+=V &4?b:0) :(d==P?(g+=2
|
||||
,j=g>0?g/8:g/ 20):0,j >0?(U= j *j/M,Q =255- 250*U/M,T=255
|
||||
-150*U/M,U=255 -100 *U/M):(U =j*j /M,U<M /5?(Q=255-210*U
|
||||
/M,T=255-435*U /M,U=255 -720* U/M):(U -=M/5,Q=213-110*U
|
||||
/M,T=168-113*U / M,U=111 -85*U/M) ),d!=P?(Q/=2,T/=2
|
||||
,U/=2):0);Q=Q< 0?0: Q>O? O: Q;T=T<0? 0:T>O?O:T;U=U<0?0:
|
||||
U>O?O:U;}R;G;B ;t(x,y ,a, b){n(M*J+M *40*(A*x +a)/X/A-M*20,M*K,M
|
||||
*L-M*30*(A*y+b)/Y/A+M*15,0,M,0,P, -1,0,0);R+=Q ;G+=T;B +=U;++a<A?t(x,y,a,
|
||||
b):(++b<A?t(x,y,0,b):0);}r(x,y){R=G=B=0;t(x,y,0,0);x<X?(printf("%c%c%c",R/A/A,G
|
||||
/A/A,B/A/A),r(x+1,y)):0;}s(y){r(0,--y?s(y),y:y);}main(){_setmode(_fileno(stdout),
|
||||
_O_BINARY );printf("P6\n%i %i\n255""\n",X,Y);s(Y);}
|
||||
+19
-3
@@ -2649,9 +2649,10 @@ described in the README.md, based on the author's remarks.
|
||||
|
||||
## [2004/arachnid](2004/arachnid/arachnid.c) ([README.md](2004/arachnid/README.md]))
|
||||
|
||||
Cody added an alternate version which allows those like himself used to `h`,
|
||||
`j`, `k` and `l` movement keys to not get lost. Non rogue players, vi users and
|
||||
Dvorak typists are invited to get lost (or use the original version)! :-)
|
||||
Cody added an [alternate version](2004/arachnid/README.md#alternate-code) which
|
||||
allows those like himself used to `h`, `j`, `k` and `l` movement keys to not get
|
||||
lost. Non rogue players, vi users and Dvorak typists are invited to get lost (or
|
||||
use the original version)! :-)
|
||||
|
||||
|
||||
## [2004/burley](2004/burley/burley.c) ([README.md](2004/burley/README.md]))
|
||||
@@ -2683,6 +2684,21 @@ Finally the optimiser cannot be enabled so the compiler flags were changed for
|
||||
this.
|
||||
|
||||
|
||||
## [2004/gavare](2004/gavare/gavare.c) ([README.md](2004/gavare/README.md]))
|
||||
|
||||
Cody added three different [alternate
|
||||
versions](2004/gavare/README.md#alternate-code):
|
||||
|
||||
- [gavare.alt.c](2004/gavare/gavare.alt.c): allows you to change the image size
|
||||
and anti-alias setting at compile time.
|
||||
- [gavare.alt2.c](2004/gavare/gavare.alt2.c): like
|
||||
[gavare.alt.c](2004/gavare/gavare.alt.c) but it should work for Windows as well
|
||||
(it sets binary mode on `stdout`).
|
||||
- [gavare.r3.c](2004/gavare/gavare.r3.c): the author's unobfuscated version that
|
||||
was used during development, found on their [website about the
|
||||
entry](https://gavare.se/ioccc/ioccc_gavare.c.html).
|
||||
|
||||
|
||||
## [2004/gavin](2004/gavin/gavin.c) ([README.md](2004/gavin/README.md]))
|
||||
|
||||
Yusuke provided the `kernel` and `fs.tar` files which can be used if you cannot
|
||||
|
||||
Reference in new issue
Block a user