Improve how to redefine macros in 2012/endoh1 alt
Now one can use variables SLEEP, TIMER, GRAVITY, PRESSURE and VISCOSITY,
rather than single letter variables. This is like other commits where
instead of having to redefine CDEFINE one can do something like
make clobber SLEEP=50 GRAVITY=I TIMER=15 alt
Notice that some can be set to I rather than a number. See the author's
remarks for details.
The try.alt.sh script was updated for this improvement.
This commit is contained in:
1 parent
26edb2a70a
commit
cca76ebe93
4 files changed
+29
-21
No files matched your search
+11
-6
@@ -57,7 +57,7 @@ ARCH=
|
||||
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
CDEFINE= -DG="$G" -DP="$P" -DV="$V" -DS=12321 -DA=10
|
||||
CDEFINE= -DG="${GRAVITY}" -DP="${PRESSURE}" -DV="${VISCOSITY}"
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
@@ -120,15 +120,15 @@ ALT_TARGET= ${PROG}.alt ${PROG}_color.alt
|
||||
|
||||
# The factor of gravity
|
||||
#
|
||||
G=1
|
||||
GRAVITY=1
|
||||
|
||||
# The factor of pressure
|
||||
#
|
||||
P=4
|
||||
PRESSURE=4
|
||||
|
||||
# The factor of viscosity
|
||||
#
|
||||
V=8
|
||||
VISCOSITY=8
|
||||
|
||||
|
||||
#################
|
||||
@@ -154,13 +154,18 @@ ${PROG}_color: ${PROG}_color.c
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
# Variables that control the alarm(3) timer and how much to sleep for alt code
|
||||
#
|
||||
TIMER= 10
|
||||
SLEEP= 12321
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
${CC} ${CFLAGS} -DS=${SLEEP} -DA=${TIMER} $< -o $@ ${LDFLAGS}
|
||||
|
||||
# this does NOT correspond to endoh1.alt2.c but rather endoh1.alt.c: it is NOT
|
||||
# deobfuscated.
|
||||
${PROG}_color.alt: ${PROG}_color.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
${CC} ${CFLAGS} -DS=${SLEEP} -DA=${TIMER} $< -o $@ ${LDFLAGS}
|
||||
|
||||
alt2: ${PROG}.alt2
|
||||
@${TRUE}
|
||||
|
||||
@@ -59,7 +59,7 @@ for fun. That is controlled by the variable `A`; 0 disables it.
|
||||
If you wish to change the speed you should do:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DS=N" alt
|
||||
make clobber SLEEP=N alt
|
||||
```
|
||||
|
||||
where `N` is number or the letter `I`.
|
||||
@@ -75,7 +75,7 @@ you wish to change the viscosity and pressure factors but leave the other macros
|
||||
alone:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DV=X -DP=Y" alt
|
||||
make clobber VISCOSITY=X PRESSURE=Y alt
|
||||
```
|
||||
|
||||
where `X` and `Y` are numbers or the letter `I` and which are, respectively, the
|
||||
@@ -88,7 +88,7 @@ it from being done.
|
||||
If you want to disable the alarm time, set `A` to 0:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DA=0" alt
|
||||
make clobber TIMER=0 alt
|
||||
```
|
||||
|
||||
It cannot be < 0 or > 60 (arbitrarily selected).
|
||||
@@ -97,7 +97,7 @@ Try slowing down the display by increasing the sleep time from `12321` to
|
||||
`50000`:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DS=50000" alt
|
||||
make clobber SLEEP=50000 alt
|
||||
```
|
||||
|
||||
Now try using both `endoh1.alt` and `endoh1_color.alt` as you would `endoh1` above.
|
||||
@@ -106,7 +106,7 @@ Also try speeding up the display by decreasing the sleep time from `12321` to
|
||||
`9999`:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DS=9999" alt2
|
||||
make clobber SLEEP=9999 alt2
|
||||
```
|
||||
|
||||
WARNING: again, be careful with too low a value if you're sensitive to flashing
|
||||
@@ -119,13 +119,13 @@ instance:
|
||||
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DG=5 -DP=5 -DV=5" alt
|
||||
make clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt
|
||||
```
|
||||
|
||||
You might try even:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DG=I" alt
|
||||
make clobber GRAVITY=I alt
|
||||
```
|
||||
|
||||
See the author's remarks for details on these macros.
|
||||
|
||||
@@ -13,11 +13,11 @@ fi
|
||||
|
||||
# unlike other try.sh/try.alt.sh scripts this one has two compiled binaries: one
|
||||
# which sets the gravity factor to I and the other that does not.
|
||||
make clobber CC="$CC" CDEFINE="-DA=10 -DG=I -DS=39000" alt >/dev/null || exit 1
|
||||
make clobber CC="$CC" TIMER=10 GRAVITY=I SLEEP=39000 alt >/dev/null || exit 1
|
||||
# we have to move the endoh1_color.alt to endoh1_color.alt3, not alt2, because
|
||||
# we have to use make clobber which would wipe out endoh1_color.alt2.
|
||||
mv endoh1_color.alt endoh1_color.alt3
|
||||
make clobber CC="$CC" CDEFINE="-DA=10 -DS=39000" alt >/dev/null || exit 1
|
||||
make clobber CC="$CC" TIMER=10 SLEEP=39000 alt >/dev/null || exit 1
|
||||
read -r -n 1 -p "Press any key run run slower fluid on endoh1_color.alt.c: "
|
||||
mv endoh1_color.alt3 endoh1_color.alt2
|
||||
# clear screen before continuing
|
||||
|
||||
+9
-6
@@ -3359,13 +3359,16 @@ Cody also added two [alt versions](/2012/endoh1/README.md#alternate-code) that
|
||||
let one control how fast the fluid moves (how long to sleep in between writes)
|
||||
and also the gravity factor, the pressure factor and the viscosity factor as
|
||||
well as an alarm that lets one run it in a loop without having to hit
|
||||
ctrl-c/intr in between (the alarm can be disabled, however). The two different
|
||||
versions is because there are two versions: the original and the colour version
|
||||
added by the author, [Yusuke](#yusuke), at the request of the judges.
|
||||
ctrl-c/intr in between (the alarm can be disabled, however). The Makefile allows
|
||||
one to easily do this with variable names rather than redefining `CDEFINE`.
|
||||
|
||||
Cody also added the [try.alt.sh](/2012/endoh1/try.alt.sh) script compiles the alt
|
||||
code in two ways, one with setting the gravity factor to `I` and another with
|
||||
the default, and which is run on the source file and each of the text files
|
||||
The two different alt versions is because there are two versions: the original
|
||||
and the colour version added by the author, [Yusuke](#yusuke), at the request of
|
||||
the judges.
|
||||
|
||||
Cody also added the [try.alt.sh](/2012/endoh1/try.alt.sh) script that compiles
|
||||
the alt code in two ways, one with setting the gravity factor to `I` and another
|
||||
with the default, and which is run on the source file and each of the text files
|
||||
supplied by the author. This code has an alarm set at 10 seconds so that one
|
||||
need not hit ctrl-c/intr in between .. say to make it more fluid :-)
|
||||
|
||||
|
||||
Reference in new issue
Block a user