Add save state option in 2018/mills, update bugs

The save state option is based on the author's remarks that one can
change the W macro to MAP_SHARED. This is defined in the Makefile so a
variable called 'SAVE' was added which if not 1 will result in
MAP_PRIVATE. This way one can run

    make clobber SAVE=1 all

and it'll save state, assuming that (if you add a file) you run 'sync'
before exiting. If you don't run sync(1) it's likely the file won't
exist or it'll be corrupt (like a.out from mullender.c). README.md file
updated for this update. Note that the setting the W macro to ${MAP} is
only done for the make targets that had it set to MAP_PRIVATE. This is
because I guess that if it's already set to MAP_SHARED in the Makefile
there is a good reason for this. This is noted in the Makefile.

The bug I discovered happens whether or not state is saved (this had to
be verified before I did the above change that I added when I was
working on this entry some days back but never committed it for this
reason). If you run ./prog and then exit (ctrl-e) if you then run ./prog
again it'll show a strange message as if the image was corrupt. You have
to hit enter at this point (that's important) and then hit ctrl-e again.
When you run it a third time it'll be okay. I did not look at this in
detail but it probably should be fixed.

The Makefile also tries to make the note about preserving images to be
the state of the file (downloaded) at the time the entry won and how any
updates are unofficial stand out more.
This commit is contained in:
Cody Boone Ferguson committed 2023-12-17 08:37:58 -08:00
1 parent 3a470289db
commit a76d3fde42
4 files changed
+84 -11

No files matched your search

+38 -9
View File
@@ -139,8 +139,16 @@ all: data ${TARGET}
clean clobber install love haste waste maker easter_egg \
sandwich supernova deep_magic magic charon pluto
# Variable to decide if the emulator should save state (default no)
#
SAVE=0
MAP=MAP_PRIVATE
ifneq ($((SAVE)),0)
MAP=MAP_SHARED
endif
${PROG}: ${PROG}.c rk05.bsd.fs
${CC} ${CFLAGS} -DI='"rk05.bsd.fs"' -DA=4096 -DS=0173030 -DW=MAP_PRIVATE -DT= -DX=5 -DY=128 \
${CC} ${CFLAGS} -DI='"rk05.bsd.fs"' -DA=4096 -DS=0173030 -DW=${MAP} -DT= -DX=5 -DY=128 \
-DV=270 -DP='"89!>@@89T=@@89\"89DQ@K89$$89Q1@H0@@@P@1@@"' ${PROG}.c -o $@ ${LDFLAGS}
rk05.bsd.fs: empty.fs.bz2 builddisk.bsd bsd.img.bz2
@@ -148,6 +156,10 @@ rk05.bsd.fs: empty.fs.bz2 builddisk.bsd bsd.img.bz2
${BZIP2} -dc empty.fs.bz2 > rk05.bsd.fs
${BZIP2} -dc bsd.img.bz2 | ./builddisk.bsd
# NOTE: we don't set -DW=${MAP} here because it's already set to MAP_SHARED and
# we don't want to break anything here. The default for the program itself is
# MAP_PRIVATE but it's possible that if MAP is set to MAP_PRIVATE then having W
# set to MAP_PRIVATE here could be a problem as it's meant to be MAP_SHARED.
builddisk.bsd: ${PROG}.c
${CC} ${CFLAGS} -DI='"rk05.bsd.fs"' -DA=4096 -DS=0 -DW=MAP_SHARED -DT= -DX=0 -DY=0 -DV=270 \
-DP='"Q@ 89D?A E@#?@$$D@H?<@E@$$8CA1@H8CJ4EH8CA1@L8CJ4FH)@!F@H%@$$1@H?@%89\"?<@89T89!Q@\"89$$89Q1@[%@#1@D<@ @EHO??@X@@@@@@@1@@"' \
@@ -158,6 +170,10 @@ rk05.v6.fs: empty.fs.bz2 builddisk.v6 v6.img.bz2
${BZIP2} -dc empty.fs.bz2 > rk05.v6.fs
${BZIP2} -dc v6.img.bz2 | ./builddisk.v6
# NOTE: we don't set -DW=${MAP} here because it's already set to MAP_SHARED and
# we don't want to break anything here. The default for the program itself is
# MAP_PRIVATE but it's possible that if MAP is set to MAP_PRIVATE then having W
# set to MAP_PRIVATE here could be a problem as it's meant to be MAP_SHARED.
builddisk.v6: ${PROG}.c
${CC} ${CFLAGS} -DI='"rk05.v6.fs"' -DA=4096 -DS=0 -DW=MAP_SHARED -DT= -DX=0 -DY=0 -DV=270 \
-DP='"Q@ 89D?A E@#?@$$D@H?<@E@$$8CA1@H8CJ4EH8CA1@L8CJ4FH)@!F@H%@$$1@H?@%89\"?<@89T89!Q@\"89$$89Q1@[%@#1@D<@ @EHO??@X@@@@@@@1@@"' \
@@ -170,24 +186,37 @@ empty.fs.bz2: boot.dat
${BZIP2} empty.fs
v0: ${PROG}.c Makefile v0.image.fs
@echo "This IOCCC25 Makefile preserves the state of v0.image.fs at the time it won."
@echo "If you want to look for v0.image.fs updates, try: ${CURL} ${IMAGE_FS_URL} -o v0.image.fs"
@echo "Warning: any updates from ${IMAGE_FS_URL} are unofficial and are not part of the IOCCC."
${CC} ${CFLAGS} -DI='"v0.image.fs"' -DA=4096 -DS=0 -DW=MAP_PRIVATE \
${CC} ${CFLAGS} -DI='"v0.image.fs"' -DA=4096 -DS=0 -DW=${MAP} \
-DT="INLCR|ICRNL,0,0,ECHO" -DX=5 -DY=128 -DV=200 \
-DP='"89!?@@89T=@@89\"Q@M89DQ@L89$$89Q1@I0A@@P@X@@1@@"' ${PROG}.c -o $@
@echo ""
@echo "This IOCCC25 Makefile preserves the state of v0.image.fs at the time it won."
@echo "If you want to look for v0.image.fs updates, try:"
@echo ""
@echo " ${CURL} ${IMAGE_FS_URL} -o v0.image.fs"
@echo ""
@echo "Warning: any updates from ${IMAGE_FS_URL}"
@echo "are unofficial and are not part of this IOCCC entry."
@echo ""
v6: empty.fs.bz2 builddisk.v6 v6.img.bz2 rk05.v6.fs
${CC} ${CFLAGS} -DI='"rk05.v6.fs"' -DA=4096 -DS=0173030 -DW=MAP_PRIVATE -DT= -DX=5 -DY=128 \
${CC} ${CFLAGS} -DI='"rk05.v6.fs"' -DA=4096 -DS=0173030 -DW=${MAP} -DT= -DX=5 -DY=128 \
-DV=270 -DP='"89!>@@89T=@@89\"89DQ@K89$$89Q1@H0@@@P@1@@"' ${PROG}.c -o $@ ${LDFLAGS}
v6.img.bz2: v6.tape.gz
@echo "This IOCCC25 Makefile preserves the state of v6.tape.gz at the time it won."
@echo "If you want to look for v6.tape.gz updates, try: ${CURL} ${V6_TAPE_URL} -o v6.tape.gz"
@echo "Warning: any updates from ${V6_TAPE_URL} are unofficial and are not part of the IOCCC."
${RM} -f v6.tape
${GZIP_PROG} -c -d v6.tape.gz | ${DD} of=v6.img count=4000 skip=100
${BZIP2} v6.img
@echo ""
@echo "This IOCCC25 Makefile preserves the state of v6.tape.gz at the time it won."
@echo "If you want to look for v6.tape.gz updates, try:"
@echo ""
@echo " ${CURL} ${V6_TAPE_URL} -o v6.tape.gz"
@echo ""
@echo "Warning: any updates from ${V6_TAPE_URL}"
@echo "are unofficial and are not part of this IOCCC entry."
@echo ""
# alternative executable
#
+13
View File
@@ -4,12 +4,25 @@
make
```
If you wish to save state so that you can run the program and keep files changed
(for instance you don't want to compile `mullender.c` again) you can compile it
like:
```sh
make clobber SAVE=1 all
```
Make sure that if you do add a file (including by compiling code) that before
you exit (ctrl-e) you type in `sync`! Otherwise the file might not exist or it
will be corrupt if it does.
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: known bug - please help us fix
STATUS: INABIAF - please **DO NOT** fix
```