Merge pull request #1475 from xexyl/schnitzi2004

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-11-18 14:51:59 -07:00
commit c5a1123ab6
6 files changed
+55 -31

No files matched your search

+15 -27
View File
@@ -8,36 +8,20 @@ make
## To use:
```sh
./schnitzi
./schnitzi <foo | vi -n
```
### Try:
```sh
./schnitzi <schnitzi.inp0 2>/dev/null| vi
./schnitzi <schnitzi.inp1 2>/dev/null| vi
./try.sh
```
For others, create an output file and use your system
pasteboard/selection/cut buffer to "input" the output into vi:
```sh
./schnitzi <schnitzi.inp0 >schnitzi.out0
./schnitzi <schnitzi.inp1 >schnitzi.out1
```
NOTE: if you're one of those who don't know how to exit `vi` :-) don't worry as
it will exit for you.
NOTE: this entry will make vi(m) swap files in the current working directory.
You might wish to clean them up. We could say how but lest there is another file
that matches the glob we won't. In any event vi swap files start with a dot
followed by the file name followed by another dot followed by `s` and two more
letters like. If no file is opened it will not have the file name but just be
e.g. `.swp`. When a second letter has no remaining availabilities it goes to
another one e.g. `u`.
## Judges' remarks:
@@ -64,9 +48,10 @@ string contains cursor navigation commands, you can go back and
overwrite things that were already inserted earlier in string,
anywhere on the screen. Can you see where this is going?
### ANIMATION!
The program takes input from stdin which defines the animated
The program takes input from `stdin` which defines the animated
elements (sprites) that appear on the screen. For each sprite,
you can specify exactly when and how long it will appear, and which
direction it is moving. Also, the sprite can oscillate between
@@ -75,16 +60,17 @@ Forgive me, animators, if I'm mangling the terminology. Sprites
which appear later in the input file will be drawn in front of
sprites which appear earlier.
The output, to stdout, is a string which, when pasted into vi, will
perform the animation defined in the input. (The vi editor is a
common (and ancient) editor that should be available on most Unix,
Linux, Solaris, and Mac OS X machines; you can get it on Windows
by installing Cygwin, which is how I do it.)
The output, written to `stdout`, is a string which, when pasted into vi, will
perform the animation defined in the input. (The vi editor is a common (and
ancient) editor that should be available on most Unix, Linux, Solaris, and macOS
systems; you can get it on Windows by installing Cygwin, which is how I do
it.)
### THE INPUT
It's easiest to place the input in a file, so you can redirect it
to stdin when running the program. What follows is a detailed
to `stdin` when running the program. What follows is a detailed
description of the input file format.
The first line is specified thusly:
@@ -93,12 +79,12 @@ The first line is specified thusly:
[duration] [timefactor]
```
The first parameter, duration, defines how long the animation will run. The
The first parameter, `duration`, defines how long the animation will run. The
second, `timefactor`, is used as sort of a fudge factor for machines that run
too fast to see the animation. A `timefactor` of 0 means, "run the animation as
fast as you can". On a pretty fast machine, I've had to set it as high as 2000
to get the animation to slow down sufficiently. Note that the higher the
`timefactor`, the longer the output string that you'll have to copy- and-paste,
`timefactor`, the longer the output string that you'll have to copy and paste,
as extra characters are necessary to "waste time" between frames.
Following the first line parameters, you may have up to nine
@@ -139,6 +125,7 @@ Input is terminated by end of file. Duh.
Two samples input files are included; one a nice pastoral park
scene, the other a bit of scrolling text.
### RUNNING THE ANIMATION
Try one of these methods to get the animation to run:
@@ -164,6 +151,7 @@ is a right-click menu option on the top window bar.
3. Memorize the output, and type it into vi really really fast.
### A FINAL NOTE
I would like to remind the Pixar Animation Studios that I retain
+2 -1
View File
@@ -1,4 +1,5 @@
#include <stdio.h>
#define gets(x) fgets((x),100,stdin)
#define l "=================================================="
#define m " "
int _(
@@ -6,7 +7,7 @@ float x,
float y){
return x>=0&&x<50&&y>=0&&y<20;}
int main (){
char a[2][20][51],c[9][4][51][51],d[100];
char a[2][20][51],c[9][4][100][100],d[100];
int e,f,g,h=0,i,j=0,k,b=0,n[9],o[9],p[9],x[9],y[9],q[9],r,s,t;
float u[9],v[9],w[9],z[9];
printf ("i%s\033Yppppppppppppppppppp1G0",l);
+1 -1
View File
@@ -1,4 +1,4 @@
100 1000
100 2000
0 1000 0 10 0.0 0.0 50 2 1
------------------------------\~~~~~~~~~~~~~~~~~~~
\__________________
+1 -1
View File
@@ -1,4 +1,4 @@
30 2000
30 10000
0 100 10 25 0.0 -1.0 25 4 1
A long time
ago, in a
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2004/schnitzi
#
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
# this way allows us to have the user specify a different compiler in an easy
# way.
if [[ -z "$CC" ]]; then
CC="cc"
fi
make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "$ ./schnitzi <schnitzi.inp0 | vi -n" 1>&2
./schnitzi <schnitzi.inp0 | vi -n
read -r -n 1 -p "Press any key to continue: "
echo
echo "$ ./schnitzi <schnitzi.inp1 | vi -n" 1>&2
./schnitzi <schnitzi.inp1 | vi -n
+10 -1
View File
@@ -1818,7 +1818,7 @@ original buffer size. Cody explains this in the at [1994/schnitzi in
bugs.md](/bugs.md#1994-schnitzi).
The purpose for these versions it both demonstrate how the magic works behind it
and to help others, should they wish to, get the code to work with `fgets(3)`, with
and to help others, should they wish, get the code to work with `fgets(3)`, with
or without an increase in buffer size. See [1994/schnitzi in
bugs.md](/bugs.md#1994-schnitzi) where Cody also explains the magic for more
details. Later on, if nobody takes up the task, Cody might resume it, but for
@@ -2753,6 +2753,15 @@ get it to work, that being `kopczynski-10-rev`.
Cody and Landon individually fixed this to work with clang.
## [2004/schnitzi](2004/schnitzi/schnitzi.c) ([README.md](2004/schnitzi/README.md]))
Cody made this use `fgets(3)`.
He also changed the time factor in the data files as the animations went too
fast in modern systems, especially the scrolling text of
[schnitzi.inp1](schnitzi.inp1).
## [2004/vik2](2004/vik2/vik2.c) ([README.md](2004/vik2/README.md))
Cody fixed this to compile in Linux. Although it compiled cleanly in macOS (and