diff --git a/2005/sykes/Makefile b/2005/sykes/Makefile index e23cd4956..98365a9ee 100644 --- a/2005/sykes/Makefile +++ b/2005/sykes/Makefile @@ -137,6 +137,9 @@ all: data ${TARGET} ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} +test: ${PROG} test.sh + -./test.sh + # alternative executable # alt: data ${ALT_TARGET} diff --git a/2005/sykes/README.md b/2005/sykes/README.md index 4c1abf461..279993080 100644 --- a/2005/sykes/README.md +++ b/2005/sykes/README.md @@ -15,19 +15,9 @@ make ### Try: ```sh -./sykes pet.rom -# type in the following for an old Easter egg: -WAIT 6502,12 +./try.sh ``` -Also try: - -``` -./sykes chess -``` - -for some good [chess](https://en.wikipedia.org/wiki/Chess) fun. - ## Judges' remarks: @@ -57,7 +47,7 @@ dd bs=2k count=1 if=/dev/zero of=nullfill.bin ``` For your convenience, we have added the above mentioned files to this entry directory. -They are used to form the `pet.rom` file. +They were used to form the `pet.rom` file. ## Author's remarks: @@ -71,6 +61,7 @@ This is the second version of the same entry, but this one takes care to not include any possibly copyrighted items in the info files, to be sure to not infringe the rules. + ### Test Compile the program, then test the @@ -85,6 +76,7 @@ A basic test is done for each instruction and addressing mode, all tests should pass. At the end of the tests, it loops forever - break out with control-C. + ### PET EMULATION Cast your mind back to 1977... a little company called @@ -180,8 +172,8 @@ WAIT 6502,12 The program is basically a [6502](https://en.wikipedia.org/wiki/MOS_Technology_6502#Technical_description) [emulator](https://en.wikipedia.org/wiki/Emulator), and it does NOT need the -[commodore](https://en.wikipedia.org/wiki/Commodore_PET) -[rom](https://en.wikipedia.org/wiki/ROM_image) to work. +[Commodore](https://en.wikipedia.org/wiki/Commodore_PET) +[ROM](https://en.wikipedia.org/wiki/ROM_image) to work. Supplied as a demonstration is a compiled-for-[6502](https://en.wikipedia.org/wiki/MOS_Technology_6502#Technical_description) @@ -222,10 +214,11 @@ In the screen understands normal [ASCII](https://en.wikipedia.org/wiki/ASCII#Character_set). -Lastly, the before [emulation](https://en.wikipedia.org/wiki/Emulator) starts, -the low byte from a `time()` call is placed at address 0 - this can be used as a +Lastly, before [emulation](https://en.wikipedia.org/wiki/Emulator) starts, +the low byte from a `time(3)` call is placed at address 0 - this can be used as a random seed. + ### Technical description Most of the program comprises the @@ -241,7 +234,7 @@ the [PET](https://en.wikipedia.org/wiki/Commodore_PET) hardware for it to work. If the supplied file is exactly 16384 bytes, the [emulator](https://en.wikipedia.org/wiki/Emulator) assumes it is a [PET](https://en.wikipedia.org/wiki/Commodore_PET) -[rom](https://en.wikipedia.org/wiki/ROM_image), and goes into PET emulation +[ROM](https://en.wikipedia.org/wiki/ROM_image), and goes into PET emulation mode. Otherwise some PET specific features are skipped during normal [6502](https://en.wikipedia.org/wiki/MOS_Technology_6502#Technical_description) [emulation](https://en.wikipedia.org/wiki/Emulator). @@ -255,6 +248,7 @@ instructions according to a table and executes them. The addressing mode is decoded in a similar expression starting on line 53. + ### Bugs The machine emulated is an older 40 column @@ -268,8 +262,8 @@ The parameter controls the speed of the 60Hz "jiffy clock", and not the processor speed. This means many games may run too fast to be usable - it really depends on the speed of your machine. -Although the PET [emulator](https://en.wikipedia.org/wiki/Emulator) can do LOAD -and SAVE, it cannot VERIFY or OPEN and CLOSE files. +Although the PET [emulator](https://en.wikipedia.org/wiki/Emulator) can do `LOAD` +and `SAVE`, it cannot `VERIFY` or `OPEN` and `CLOSE` files. The [PET](https://en.wikipedia.org/wiki/Commodore_PET) hardware [emulation](https://en.wikipedia.org/wiki/Emulator) is not at all complete - @@ -281,6 +275,7 @@ The [emulation](https://en.wikipedia.org/wiki/Emulator) does not include the seldom used decimal mode, or any of the "undocumented" instructions. + ### IMPORTANT NOTE I think it is great fun to run the @@ -288,11 +283,12 @@ I think it is great fun to run the [emulation](https://en.wikipedia.org/wiki/Emulator) and mess around with [Microsoft](https://en.wikipedia.org/wiki/Microsoft) [BASIC](https://en.wikipedia.org/wiki/BASIC). However, this obviously needs the -[rom](https://en.wikipedia.org/wiki/ROM_image) file to work. My +[ROM](https://en.wikipedia.org/wiki/ROM_image) file to work. My program is original and completely free of any copyright, but, of course, the `pet.rom` is not my work. So I ask the user to download it from the Internet. This is to avoid directly infringing any copyright. + ### Finally What does this do? diff --git a/2005/sykes/test.sh b/2005/sykes/test.sh new file mode 100755 index 000000000..cdf451cbd --- /dev/null +++ b/2005/sykes/test.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# 2005/sykes/test.sh - run the test suite + +# 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 "NOTE: you will have to hit ctrl-c to exit after the test." 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 + +./sykes 6502test 6 2>&1 diff --git a/2005/sykes/try.sh b/2005/sykes/try.sh new file mode 100755 index 000000000..357cbf1eb --- /dev/null +++ b/2005/sykes/try.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# try.sh - demonstrate IOCCC winner 2005/sykes +# + +# 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 + +while true; do + echo "(0) Run demo" 1>&2 + echo "(1) Show Easter egg" 1>&2 + echo "(2) Play chess" 1>&2 + echo "(3) Run test-suite" 1>&2 + echo "(4) Run pet.rom with -1" 1>&2 + + echo "NOTE: you have to hit ctrl-c or whatever your interrupt combination is to" 1>&2 + echo "exit the program to continue here." 1>&2 + + read -rp "Make your selection (0 - 4 or any other key to exit): " mode + + echo 1>&2 + + case "${mode}" in + 0) # demo + printf "LOAD \"DEMO\"\nRUN\n" | ./sykes pet.rom 6 + ;; + 1) # show old Easter egg + echo "WAIT 6502,12" | ./sykes pet.rom 6 + ;; + 2) # chess + ./sykes chess 6 + ;; + 3) # test mode + make test + ;; + 4) # -1 + ./sykes pet.rom -1 + ;; + *) + exit 0 + esac + read -r -n 1 -p "Do you want to continue? " ans + + if [[ "$ans" != "y" && "$ans" != "Y" ]]; then + break; + fi + echo 1>&2 +done diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 1b78a8d02..345e375b2 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3023,6 +3023,19 @@ how https is set up, in which case just enjoy it for what it was. But there might be some command line that will let it work that way. +## [2005/sykes](2005/sykes/sykes.c) ([README.md](2005/sykes/README.md])) + +Cody added the [try.sh](2005/sykes/try.sh) script which runs in a loop with a +menu of things one might wish to try, asking if they wish to continue when done. + +Cody added the script [test.sh](2005/sykes/test.sh) and the make rule `test` to +run the test suite. The program will enter an infinite loop after it runs so you +have to hit ctrl-c to end it which the script tells you. + +The scripts note every time that one will have to send ctrl-c or whatever their +interrupt is set to in order to exit the program. + + ## [2005/timwi](2005/timwi/timwi.c) ([README.md](2005/timwi/README.md])) Cody added [try.sh](2005/timwi/try.sh). It only has one command as he doesn't