From dd4336d8727ff79125aa0f3a81b43a06120b169e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 9 Nov 2023 11:23:50 -0800 Subject: [PATCH] Updates to 1993/cmills - alt code + bugs + format The README.md file has been format/typo checked. The alt version uses usleep(3) with a configurable time (at compile time). This version is suggested first as it apparently goes too fast in modern systems. I say apparently as it doesn't appear to work with macOS. I don't know if it works in other platforms but it is in bugs.md, that there is a problem. --- 1993/cmills/.gitignore | 1 + 1993/cmills/Makefile | 11 +++++--- 1993/cmills/README.md | 50 +++++++++++++++++++++++++++++++---- 1993/cmills/cmills.alt.c | 56 ++++++++++++++++++++++++++++++++++++++++ bugs.md | 10 +++++++ thanks-for-fixes.md | 8 ++++++ 6 files changed, 127 insertions(+), 9 deletions(-) create mode 100644 1993/cmills/cmills.alt.c diff --git a/1993/cmills/.gitignore b/1993/cmills/.gitignore index 4dbfe182e..4ff19a740 100644 --- a/1993/cmills/.gitignore +++ b/1993/cmills/.gitignore @@ -1,3 +1,4 @@ cmills +cmills.alt cmills.orig prog.orig diff --git a/1993/cmills/Makefile b/1993/cmills/Makefile index 10e052da6..dd3eace9f 100644 --- a/1993/cmills/Makefile +++ b/1993/cmills/Makefile @@ -57,11 +57,11 @@ ARCH= # Defines that are needed to compile # -CDEFINE= +CDEFINE= -DZ=100 # Include files that are needed to compile # -CINCLUDE= -I ${X11_INCDIR} -I ${X11_INCDIR}/X11 +CINCLUDE= -I ${X11_INCDIR} -I ${X11_INCDIR}/X11 -include unistd.h # Optimization # @@ -113,8 +113,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -141,6 +141,9 @@ chris: ${PROG} alt: data ${ALT_TARGET} @${TRUE} +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + # data files # data: ${DATA} diff --git a/1993/cmills/README.md b/1993/cmills/README.md index 21fe003d5..15ad711c1 100644 --- a/1993/cmills/README.md +++ b/1993/cmills/README.md @@ -1,7 +1,18 @@ ## To build: +We recommend you try the alt version first as with modern systems the original +goes too fast. See the [original code](#original-code) section below to run the +original. + + ```sh -make all +make alt +``` + +To configure how many microseconds to sleep before updates try: + +```sh +make clobber CDEFINE="-DZ=200" alt ``` NOTE: this entry requires `X11/Xlib.h` header file and the X11 library to @@ -10,12 +21,24 @@ install [XQuartz](https://www.xquartz.org) in order to compile and run this entry. +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: known bug - please help us fix +``` + +For more detailed information see [1993 cmills in bugs.md](/bugs.md#1993-cmills). + + + ## To use: ```sh -DISPLAY="your_X_server_display"\ +DISPLAY="your_X_server_display" export DISPLAY -./cmills [speed] # must be run on an X11 server +./cmills.alt [speed] # must be run on an X11 server ``` where: @@ -23,9 +46,26 @@ where: `speed` is update speed from 1 to 9 (default is 9). +## Original code: + +We recommend the version that uses `usleep(3)` to more easily see what is going +on but you can use the original without any delays if you wish. + + +### Original build: + +```sh +make all +``` + +### Original use: + +Use `cmills` as you would `cmills.alt` above. + + ## Judges' remarks: -From the San Jose Mercury News (May 15, 1993 page 20A "West Hackers\ +From the San Jose Mercury News (May 15, 1993 page 20A "West Hackers trounce East in computer quiz game"): @@ -43,7 +83,7 @@ it brought down the house of Apple partisans... [The expression on Bill Gates' face was a sight to behold, as reported to us by several who were there]. -You must set `$DISPLAY` in your environment or the program will\ +You must set `$DISPLAY` in your environment or the program will dump core. This is not a bug as the author documented it as a feature. :-) diff --git a/1993/cmills/cmills.alt.c b/1993/cmills/cmills.alt.c new file mode 100644 index 000000000..2046aa92b --- /dev/null +++ b/1993/cmills/cmills.alt.c @@ -0,0 +1,56 @@ +long +z[7992],W,H,*t=z,j,k,*T=z,n,b; +#include +#include +Window*E,D,s,w[999],*e=w; +Display*d; +Pixmap +p; +m(w,h,x,y,u,v){ +#define C XCreateSimpleWindow(d, +XSetWindowBackgroundPixmap(d,s=C*e=C +#define l(n)t[n]=T[n]+ +D,l(0)x,l(1)y,t[2]=w,t[3]=h,1,b,0),l(6)-x,l(7)-y,W,H,0,0,0),p); +l(4)u; +l(5)v; +#define M XMapRaised(d, +M +s); +M*e++); +t+=8; +} +main(c,g)char**g; +{ +XSetWindowAttributes +a; +XGCValues +v; +n=DefaultScreen(d=XOpenDisplay(0)); +p=XCreatePixmap(d,D=RootWindow(d,n),W=DisplayWidth(d,n),H=DisplayHeight(d,n),DefaultDepth(d,n)); +v.subwindow_mode=IncludeInferiors; +XCopyArea(d,D,p,XCreateGC(d,D,GCSubwindowMode,&v),0,0,W,H,0,0); +a.override_redirect=True; +XChangeWindowAttributes(d,D=C +D,0,0,W,H,0,0,b=BlackPixel(d,n)),CWOverrideRedirect,&a); +M +D); +m(W,H,0,0,3,3); +for(c=c^1?atoi(g[1]):9; +; +)for(T=z,n=e-(E=w); +n--; +T+=8,++E){ +XMoveWindow(d,*E,*T+=T[4]*c,T[1]+=T[5]*c); +j=0; +#define F(n,o,s)o+T[n-4]s-0&&++j&&T[n]s!1&&(T[n]=0-T[n])|| +if((F(4,0,<)F(4,T[2]-W,>)F(5,0,<)F(5,T[3]-H,>)1)&&j&&(j=T[2]/2)&&(k=T[3]/2)&&e-w<997&&rand()%32768<=T[2]*T[3]*(T[4]*T[4]+T[5]*T[5])/999){ +m(T[2]-j,T[3]-k,j,k,2,2); +m(j,T[3]-k,0,k,-2,-2); +m(T[2]-j,k,j,0,2,-2); +T[7]-=2; +XResizeWindow(d,*E,T[2]=j,T[3]=k); +T[6]-=2; +} +usleep(Z); +} +} diff --git a/bugs.md b/bugs.md index b266aba92..1eb99916c 100644 --- a/bugs.md +++ b/bugs.md @@ -999,6 +999,16 @@ not a misunderstanding). # 1993 +### STATUS: known bug - please help us fix +### Source code: [1993/cmills/cmills.c](1993/cmills/cmills.c) +### Information: [1993/cmills/README.md](1993/cmills/README.md) + +We are unsure if this is a problem with multiple platforms but in macOS at least +the program appears to just shows a black screen. + +Can you fix it? We welcome your help. + + ## 1993 lmfjyh ### STATUS: INABIAF - please **DO NOT** fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 83c3f778a..3408c2a99 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1570,6 +1570,14 @@ args (2). And not that we need the help or anything for this :-) but we encourage you to try the original :-) +## [1993/cmills](1993/cmills/cmills.c) ([README.md](1993/cmills/README.md])) + +Yusuke suggested that with modern systems this goes too fast so he added a call +to `usleep(3)` in a patch he made. Cody made it configurable at compilation by +using a macro. This is in the alt version which is the recommended one to try +first. + + ## [1993/dgibson](1993/dgibson/dgibson.c) ([README.md](1993/dgibson/README.md])) Cody fixed the script to work which assumed that `.` is in the path.