Improve 1984/mullender alt code

Using 2018/mills (an amazing entry) with trial and error I was able to
determine the approximate speed that the :-) moved across the screen and
now the alt code moves at almost exactly (I believe, at least) that
speed.

The mullender.alt2.c was deleted; instead that became mullender.alt.c.
This is because (I believe but have not confirmed) that the original did
not exit after it timed out and there's no need to have two alt versions
when they're so similar. One is good enough and the obvious choice is
the one that can keep going on.

.gitignore updated.
This commit is contained in:
Cody Boone Ferguson committed 2023-12-15 04:52:39 -08:00
1 parent 36f452de33
commit 475b0beec7
6 files changed
+24 -28

No files matched your search

-1
View File
@@ -8,6 +8,5 @@ indent.c
indent.o
mullender
mullender.alt
mullender.alt2
mullender.orig
prog.orig
+2 -2
View File
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ= ${PROG}.alt.o ${PROG}.alt2.o
ALT_TARGET= ${PROG}.alt ${PROG}.alt2
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
+12 -14
View File
@@ -26,16 +26,18 @@ For more detailed information see [1984 mullender in bugs.md](/bugs.md#1984-mull
```sh
./mullender.alt [microseconds]
./mullender.alt2 [microseconds] # starts over after it times out
```
The default microseconds is 10000 and it is also the lowest it can be as any
lower doesn't work very well. This feature is so you can experiment with
different speeds in between writes. It can be useful if your CPU is too slow or
too fast (:-) ).
Hit ctrl-c/intr to exit the program.
The author stated that the original version also had a delay.
The default microseconds is 190000 as this is approximately how long it slept in
the original entry but it can be no lower than 5000 as any lower doesn't work
very well. This feature is so you can experiment with different speeds in
between writes. It can be useful if your CPU is too fast :-)
The author stated that the original version also had a delay but the difference
is it required one to hit enter for it to print another line; the alt code will
start over once it times out or if one hits a key.
Note that the microseconds is argc and it uses `atoi()` which does NOT check for
overflow!
@@ -49,15 +51,11 @@ which is probably not as uncommon as you think :-).
```sh
./mullender.alt
./mullender.alt 5000
./mullender.alt 5000 # wait for 5000 microseconds and see what happens
./mullender.alt 500
./mullender.alt 20000 # wait for 20000 microseconds and see what happens
./mullender.alt 20000
./mullender.alt 100000
./mullender.alt2 500 # wait for 500 microseconds and see what happens
./mullender.alt 100000 # wait for 100000 microseconds and see what happens
```
What happens if you hit enter after it reaches the end of the line? Why? What
+1 -1
View File
@@ -1 +1 @@
main(i,v)char**v;{i=v[1]?atoi(v[1]):10000;i=i<500?500:i;do write(1," :-)\b\b\b\b",9),usleep(i);while(--i);write(1,"\n",1);}
main(i,v)char**v;{j:i=v[1]?atoi(v[1]):190000;i=i<5000?5000:i;do write(1," :-)\b\b\b\b",9),usleep(i);while(--i);write(1,"\n",1);goto j;}
-1
View File
@@ -1 +0,0 @@
main(i,v)char**v;{j:i=v[1]?atoi(v[1]):10000;i=i<500?500:i;do write(1," :-)\b\b\b\b",9),usleep(i);while(--i);write(1,"\n",1);goto j;}