Fix 2000/thadgavin for SDL + format README.md

The SDL version did not work for a number of reasons. First of all the
code requires that SDL is defined. Second the path wrong header file was
included. Third the SDL1 developers thought it would be a great idea
(but obviously it's a terrible idea) to redefine main() (!!) so that any
program that uses SDL1 has to have the same args as their definition.
This program had 'main()' so the error message was:

    thadgavin.c:60:1: error: conflicting types for 'SDL_main'
    main()
    ^
    /opt/local/include/SDL/SDL_main.h:34:14: note: expanded from macro 'main'
    #define main SDL_main
		 ^
    /opt/local/include/SDL/SDL_main.h:35:12: note: previous declaration is here
    extern int SDL_main(int argc, char *argv[]);
	       ^
    1 warning and 1 error generated.
    make: *** [thadgavin_sdl] Error 1

Thus main() was changed to 'int main(int argc, char **argv)'. I am not
sure if I want to know their thinking. I kind of do but I also don't.

Format fix README.md.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-20 12:59:06 -07:00
1 parent 43d4057682
commit dd0b26b5d6
3 files changed
+67 -34

No files matched your search

+4
View File
@@ -129,8 +129,12 @@ all: data ${TARGET}
supernova deep_magic magic charon pluto
${PROG}: ${PROG}.c
@echo "WARNING: if you are sensitive to rapid movement you should probably avoid this entry."
${CC} ${CFLAGS} $< -o $@ ${LIBS}
${PROG}_sdl: ${PROG}.c
${CC} ${CFLAGS} -DSDL `${SDL1_CONFIG} --cflags` $< -o $@ ${LIBS} `${SDL1_CONFIG} --libs`
# alternative executable
#
alt: data ${ALT_TARGET}
+61 -32
View File
@@ -1,16 +1,16 @@
# Most Portable Output
Thaddaeus Frogley
Creature Labs
164 Hornbeams,
Harlow, Essex,
UK
Gavin Buttimore
Creature Labs
9 Elizabeth Way,
Cambridge,
UK, CB4 1DE
Thaddaeus Frogley
Creature Labs
164 Hornbeams
Harlow, Essex
UK
Gavin Buttimore
Creature Labs
9 Elizabeth Way
Cambridge
UK, CB4 1DE
## To build:
@@ -18,12 +18,37 @@
make
```
NOTE: the author suggested `-O6` but at least some gcc versions support no more
than level 3 which is what the Makefile has.
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the code and
added an appropriate make rule so that the SDL version works independent from
the curses version (using the same code). To use it:
```sh
make thadgavin_sdl
```
Use `thadgavin_sdl` as you would `thadgavin` below.
Thank you Cody for your assistance!
## To run:
```sh
./thadgavin
```
WARNING: if you are sensitive to rapid movement you should probably avoid
this entry, both the SDL version and the curses version.
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
screen.
## Try:
```sh
@@ -37,45 +62,49 @@ SDL graphic library is not present, and is quite good at that,
but the colors used in graphic mode (16 bit depth) are unfortunately
less than dazzling. We could not test this entry in DOS mode.
## Author's remarks:
## Authors' remarks:
To run under DOS:
### To run under DOS:
Compile using DJGPP as follows:
Compile using DJGPP as follows:
gcc thadgavin.c -o thadgavin.exe -Wall -lm -O6 -mpentium -fomit-frame-pointer
-ffast-math
```sh
gcc thadgavin.c -o thadgavin.exe -Wall -lm -O6 -mpentium -fomit-frame-pointer -ffast-math
```
To run under Windows, X-Windows or MacOS using the
Simple DirectMedia Layer:
### To run under Windows, X-Windows or MacOS using the Simple DirectMedia Layer:
For example:
gcc -O6 -lpthread -g -o thadgavin thadgavin.c -lSDL -DSDL -lm
```sh
gcc -O6 -lpthread -g -o thadgavin thadgavin.c -lSDL -DSDL -lm
```
In gcc you may get the following warning:
### Warnings
prog.c:46: warning: passing arg 2 of `SDL_SetColors' from incompatible
pointer type
In gcc you might get the following warning:
```
thadgavin.c.c:46: warning: passing arg 2 of `SDL_SetColors' from incompatible pointer type
```
In Microsoft Visual Studio you may get warnings as follows:
prog.c(46) : warning C4133: 'function' : incompatible types - from 'unsigned
char *' to 'struct SDL_Color *'
prog.c(63) : warning C4026: function declared with formal parameter list
prog.c(77) : warning C4244: '=' : conversion from 'double ' to 'unsigned
char ', possible loss of data
```
thadgavin.c(46) : warning C4133: 'function' : incompatible types - from 'unsigned
char *' to 'struct SDL_Color *'
thadgavin.c(63) : warning C4026: function declared with formal parameter list
thadgavin.c(77) : warning C4244: '=' : conversion from 'double ' to 'unsigned
char ', possible loss of data
```
But don't worry, this is completely normal.
Recommended dosage:
At least 3 minutes taken 3 times a day when tired.
At least 3 minutes taken 3 times a day when tired.
Do not exceed 3 times recommended dose. May cause
sickness, dizziness, nausea.
Do not exceed 3 times recommended dose. May cause sickness, dizziness, nausea.
## Copyright and CC BY-SA 4.0 License:
+2 -2
View File
@@ -38,7 +38,7 @@
(v,X*Y,0xA0000 ); } else{ r.x.ax=
0x13; __dpmi_int( 0x10,&r); } }
#elif defined(SDL)
#include "SDL/SDL.h"
#include <SDL.h>
SDL_Surface *s; void
F(int i){ if (i){ SDL_SetColors(
s,h,0,256); SDL_UpdateRect
@@ -57,7 +57,7 @@
LINES &~1,Y=y<Y?y:Y; } }
#endif
main()
main(int argc, char **argv)
{
F(0);