From a76d3fde42268e090390a8b43af6298636e843f9 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 17 Dec 2023 08:25:57 -0800 Subject: [PATCH] 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. --- 2018/mills/Makefile | 47 +++++++++++++++++++++++++++++++++++--------- 2018/mills/README.md | 13 ++++++++++++ bugs.md | 23 ++++++++++++++++++++-- thanks-for-help.md | 12 +++++++++++ 4 files changed, 84 insertions(+), 11 deletions(-) diff --git a/2018/mills/Makefile b/2018/mills/Makefile index 1d3085fa8..f148d8edd 100644 --- a/2018/mills/Makefile +++ b/2018/mills/Makefile @@ -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 # diff --git a/2018/mills/README.md b/2018/mills/README.md index 1f0dfff8e..a2bf970e8 100644 --- a/2018/mills/README.md +++ b/2018/mills/README.md @@ -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 ``` diff --git a/bugs.md b/bugs.md index 6e1ea7d7c..8a5cd26b4 100644 --- a/bugs.md +++ b/bugs.md @@ -3185,10 +3185,25 @@ but this is expected and the file `ioccc.html` will be generated properly. ## 2018 mills -### STATUS: INABIAF - please **DO NOT** fix +### STATUS: known bug - please help us fix ### Source code: [2018/mills/prog.c](2018/mills/prog.c) ### Information: [2018/mills/README.md](2018/mills/README.md) +After exiting the program (with ctrl-e) if you try running it again you will +likely see: + +``` +>bootT5pw + ]h_ 8D3[] +``` + +where `[]` is the cursor. When this happens if you hit enter (this is necessary +or else it'll happen again) and then exit again (ctrl-e) and run `prog` again +it'll be okay. + + +### STATUS: INABIAF - please **DO NOT** fix + The author stated that if you make a typo it can happen that the boot loader can crash and halt. If this is the case type ctrl-e to quit the emulator and try again. @@ -3198,7 +3213,11 @@ do this you should type `make clobber all` and try again. Cody caused a funny problem where it showed `ERROR` after each command. The solution was to hit ctrl-e and start again. He does not know if this is what was -referred to by the author though he doesn't think he made a typo either. +referred to by the author but there was likely no typo involved. + +Cody notes that if you are using the saved mode you must type `sync` prior to +exiting the program or else the next time you run it the file will not exist (or +in the case of compiled code it won't be executable). ## 2018 vokes diff --git a/thanks-for-help.md b/thanks-for-help.md index fa1cb42f8..c6a66af9e 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4066,6 +4066,18 @@ that's probably true: let's just say that for the IOCCC I'm (Cody) a weasel! :-) Cody also added the [try.sh](/2018/hou/try.sh) script. +## [2018/mills](/2018/mills/prog.c) ([README.md](/2018/mills/README.md)) + +[Cody](#cody), based on the author's remarks, made it possible to save state +between runs of the program so that one can resume where they left off. It +should be noted that there is a bug in the entry (irrespective of save state +option) where running `./prog` twice in a row involves having to hit (the second +run) enter and then exit and then start the program again. Also if you do add a +file you should run `sync` prior to exiting or else the file might not exist or +it might be corrupt. See [2018/mills in bugs.md](/bugs.md#2018-mills) for more +details on the bug. + + ## [2018/poikola](/2018/poikola/prog.c) ([README.md[(/2018/poikola/README.md)) [Cody](#cody) added the missing `docs` rule to the Makefile that forms a PDF