From 3f197122306362e64134956a74dae4898f3522b8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 4 Jul 2023 09:23:03 -0700 Subject: [PATCH] Add alt code for 2000/thadgavin This version allows for delaying between the writing of characters (for curses) or pixels (for SDL). I explained how to reconfigure it in the README.md file. This is useful for more modern systems as well as if you're sensitive to rapid swirling. Typo fixes in README.md. --- 2000/thadgavin/.gitignore | 2 + 2000/thadgavin/Makefile | 15 ++++-- 2000/thadgavin/README.md | 38 ++++++++++++-- 2000/thadgavin/thadgavin.alt.c | 93 ++++++++++++++++++++++++++++++++++ thanks-for-fixes.md | 6 +++ 5 files changed, 147 insertions(+), 7 deletions(-) create mode 100644 2000/thadgavin/thadgavin.alt.c diff --git a/2000/thadgavin/.gitignore b/2000/thadgavin/.gitignore index 5aeb20c6b..4b26fde7d 100644 --- a/2000/thadgavin/.gitignore +++ b/2000/thadgavin/.gitignore @@ -1,2 +1,4 @@ thadgavin thadgavin_sdl +thadgavin.alt +thadgavin.alt_sdl diff --git a/2000/thadgavin/Makefile b/2000/thadgavin/Makefile index 652f70d46..65e3070c0 100644 --- a/2000/thadgavin/Makefile +++ b/2000/thadgavin/Makefile @@ -57,11 +57,11 @@ ARCH= # Defines that are needed to compile # -CDEFINE= +CDEFINE= -DZ=30 -DZS=150000 # Include files that are needed to compile # -CINCLUDE= +CINCLUDE= -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 ################# @@ -140,6 +140,13 @@ ${PROG}_sdl: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + + +${PROG}.alt_sdl: ${PROG}.alt.c + ${CC} ${CFLAGS} -DSDL `${SDL1_CONFIG} --cflags` $< -o $@ ${LIBS} `${SDL1_CONFIG} --libs` + # data files # data: ${DATA} diff --git a/2000/thadgavin/README.md b/2000/thadgavin/README.md index d3360ffc3..b335a4c5a 100644 --- a/2000/thadgavin/README.md +++ b/2000/thadgavin/README.md @@ -22,7 +22,7 @@ make NOTE: the author suggested `-O6` but at least some gcc versions support no more than level 3 which is what the Makefile has. -To use the SDL version works independentlt from the cueses version: +To use the SDL version that works independently from the curses version: ```sh make thadgavin_sdl @@ -37,8 +37,8 @@ Use `thadgavin_sdl` as you would `thadgavin` below. ./thadgavin ``` -WARNING: if you are sensitive to rapid movement you should probably avoid -this entry, both the SDL version and the curses version. +WARNING: if you are sensitive to rapid movement or if you want to see better +what is going on then please see the Alternate code section. NOTE: in curses mode you might want to type `reset` after execution of this program as the program does not call `endwin()`. Using `reset` will clear the @@ -51,6 +51,38 @@ screen. echo "Do or do not. There is no try." ``` +## Alternate code: + +An alternate version exists which allows you to slow down the printing of the +characters, useful for those with modern systems or those who are sensitive to +rapid moving swirling. To use: + + +```sh +make alt +``` + +To make the SDL version: + +```sh +make thadgavin.alt_sdl +``` + +If you wish to reconfigure the delay you can do so like: + +```sh +make -DZ=50 clobber alt +make -DZS=5000 clobber thadgavin.alt_sdl +``` + +Use `thadgavin.alt` and `thadgavin.alt_sdl` as you would `thadgavin` and +`thadgavin_sdl` above. + +The default for the curses alt version is 30 and for SDL it is 150000. The +different macros is because the curses version is already slower but it's better +to not tie the two values together. The reason for such drastically different +numbers is because curses is already slower than SDL. + ## Judges' remarks: diff --git a/2000/thadgavin/thadgavin.alt.c b/2000/thadgavin/thadgavin.alt.c new file mode 100644 index 000000000..7432da25f --- /dev/null +++ b/2000/thadgavin/thadgavin.alt.c @@ -0,0 +1,93 @@ + + int + X=320 ,Y=200, + n=0,m, x,y, j=1024; + double T=44.0 /7,P[ + 333333 ],C[5] ={ 0,3, + 0,0,8} ,p=1, B=11.0 + /630, f=0,r = 3,g + =7,b =13,*q=P, D,*J; + unsigned char + U[66666],*v=U,*h,l[5555] + ,c=0,*e,*a,*z; + + #include + #define R1(t) t=(int)(t\ + *123456789 )%j; t/=j; + #define Rl(C,t)\ + n++[C] = t*n/12; + #define RI(C) B=-B; R1\ + (r)R1(g )R1(b )for(n\ + =0; n + #include + #include + #define Q(u,v) u##portb(0x3##v + #define W ; Q(out,C9),*h++/4) + void F(int i){ __dpmi_regs r + ; if(i){ for(; i>=0; i-=8)while( + ~Q(in,DA) + )&8^i); for(m=0,z + =h+j; h + SDL_Surface *s; void + F(int i){ if (i){ SDL_SetColors( + s,h,0,256); SDL_UpdateRect + (s,0,0,0, 0); usleep(ZS); } else { SDL_Init( + SDL_INIT_VIDEO); s=SDL_SetVideoMode + (X,Y,8,0); v=s->pixels; } } + #else + #include "curses.h" + void F(i){ if(i){ for(y=0; + y=X/2?x=-X/2,y++:4) + {*q++ = sqrt(x*x+y*y); + + *q++ = atan2(x,y); + + }for (;n1){p=2-p;RI(l+j)} + else if (p<0){p=-p;RI(l)} + + while(aT) + {C[1] += (f-T)/8; + + if (f>T*2) + C[0]=sin(f)+sin(f*2)/2; + } + } +} diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 614f3792e..542f28a9c 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -777,6 +777,12 @@ To see the craziness of the SDL fix (because of a terrible design choice of the SDL1 developers) see the log for commit dd0b26b5d6325e8b6fdef1232156c8bb8c66613f. Be prepared for a surprise! +Cody also added an alternate version to help see what is going on in more modern +systems and in case you're sensitive to rapidly moving swirling. See the +README.md for details on that. Note that this alternate version only will impact +the curses and the SDL versions as Cody does not have a DOS system to test the +other version in. + ## [2001/anonymous](2001/anonymous/anonymous.c) ([README.md](2001/anonymous/README.md]))