Hello community, here is the log from the commit of package SDL_bgi for openSUSE:Factory checked in at 2018-08-18 00:02:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/SDL_bgi (Old) and /work/SRC/openSUSE:Factory/.SDL_bgi.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "SDL_bgi" Sat Aug 18 00:02:41 2018 rev:11 rq:629390 version:2.2.1 Changes: -------- --- /work/SRC/openSUSE:Factory/SDL_bgi/SDL_bgi.changes 2018-08-03 12:38:34.735683443 +0200 +++ /work/SRC/openSUSE:Factory/.SDL_bgi.new/SDL_bgi.changes 2018-08-18 00:03:01.822883122 +0200 @@ -1,0 +2,9 @@ +Wed Aug 15 10:47:45 UTC 2018 - [email protected] + +- Update to new upstream release 2.2.1 + * renamed getch() to bgi_getch() and added the macro getch() + to avoid Mingw bug + * delay() rewritten to take care of key presses + * added ALPHA_VALUE() + +------------------------------------------------------------------- Old: ---- SDL_bgi-2.2.0.tar.gz New: ---- SDL_bgi-2.2.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ SDL_bgi.spec ++++++ --- /var/tmp/diff_new_pack.sETo86/_old 2018-08-18 00:03:02.558885320 +0200 +++ /var/tmp/diff_new_pack.sETo86/_new 2018-08-18 00:03:02.566885344 +0200 @@ -17,8 +17,8 @@ Name: SDL_bgi -%define lname libSDL_bgi1 -Version: 2.2.0 +%define lname libSDL_bgi2 +Version: 2.2.1 Release: 0 Summary: BGI-compatible 2D graphics C library with SDL backend License: Zlib AND GPL-2.0-or-later @@ -91,7 +91,7 @@ %files -n %lname %doc LICENSE -%_libdir/libSDL_bgi.so.* +%_libdir/libSDL_bgi.so.2* %files -n libSDL_bgi-devel %doc README.md doc/* ++++++ SDL_bgi-2.2.0.tar.gz -> SDL_bgi-2.2.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/BUGS new/SDL_bgi-2.2.1/BUGS --- old/SDL_bgi-2.2.0/BUGS 2018-07-17 17:40:40.000000000 +0200 +++ new/SDL_bgi-2.2.1/BUGS 2018-07-31 08:23:06.000000000 +0200 @@ -1,6 +1,7 @@ BUGS ---- -In MSYS2 + Mingw64, the getch() function hangs; use getevent() instead. +In MSYS2 + Mingw64, the getch() function may hang. As far as I can +tell, it's a problem in Mingw console handling. Please report bugs if you find any. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/CMakeLists.txt new/SDL_bgi-2.2.1/CMakeLists.txt --- old/SDL_bgi-2.2.0/CMakeLists.txt 2018-07-13 14:08:51.000000000 +0200 +++ new/SDL_bgi-2.2.1/CMakeLists.txt 2018-07-26 12:06:47.000000000 +0200 @@ -5,7 +5,7 @@ cmake_minimum_required (VERSION 3.5.0) -set (SDL_BGI_VERSION 2.2.0) +set (SDL_BGI_VERSION 2.2.1) # Project name project (SDL_bgi VERSION ${SDL_BGI_VERSION} LANGUAGES C) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/ChangeLog new/SDL_bgi-2.2.1/ChangeLog --- old/SDL_bgi-2.2.0/ChangeLog 2018-07-18 10:43:42.000000000 +0200 +++ new/SDL_bgi-2.2.1/ChangeLog 2018-08-10 08:36:13.000000000 +0200 @@ -1,6 +1,15 @@ Changelog --------- +v. 2.2.1, 2018-08-08 +- renamed getch() to bgi_getch() and added the macro getch() + to avoid Mingw bug +- delay() rewritten to take care of key presses +- fixed bug in BLUE_VALUE(), GREEN_VALUE(), RED_VALUE(), setalpha() +- added ALPHA_VALUE() +- added test/psychedelia.c +- code revision and cleanup + v. 2.2.0, 2018-07-18 - added setwinoptions() for window title, position, and SDL flags - added support for multiple windows: extended initwindow(), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/INSTALL.md new/SDL_bgi-2.2.1/INSTALL.md --- old/SDL_bgi-2.2.0/INSTALL.md 2018-07-17 12:55:30.000000000 +0200 +++ new/SDL_bgi-2.2.1/INSTALL.md 2018-08-10 08:37:05.000000000 +0200 @@ -1,25 +1,24 @@ # Installing `SDL_bgi` -To install `SDL_bgi`, you normally compile it from sources. Windows +To install `SDL_bgi`, you normally compile it from sources; Windows users may use the provided binaries. -## Installing for MSYS2 Mingw-w64 +## Installing the MSYS2 Mingw-w64 Binaries -To install the precompiled binary for Mingw-w64: +Let's assume you installed the native package `mingw-w64-x86_64-SDL2`. - $ cd bin/Mingw64 - $ make install - -which will copy `graphics.h` to `/mingw64/include/`, `SDL_bgi.h` -to `/mingw64/include/SDL2/`, and `SDL_bgi.dll` to `/mingw64/bin`. +Start the MSYS2 shell, unzip the archive, then copy +`src/graphics.h` to `/mingw64/include/`, `src/SDL_bgi.h` +to `/mingw64/include/SDL2/`, and `bin/Mingw64/SDL_bgi.dll` +to `/mingw64/bin`. Please note that to run a program compiled with `SDL_bgi` outside of the MSYS2 environment, you will need `SDL_bgi.dll` and `SDL2.dll` -in the same directory. +in the same directory as the program. -## Installing for Code::Blocks +## Installing the Code::Blocks Binaries Let's assume that you installed CodeBlocks in `C:\CodeBlocks` and SDL2 in `C:\SDL2-2.0.8`. Change the following instructions as needed for @@ -32,7 +31,7 @@ To see how to compile programs, please see `howto_CodeBlocks.md`. -## Installing for Dev-C++ +## Installing the Dev-C++ Binaries Let's assume that you installed Dev-C++ `C:\DevCpp` and SDL2 in `C:\SDL2-2.0.8`. Change the following instructions as needed for @@ -48,7 +47,8 @@ # Compiling from sources The main `SDL_bgi` development platform is GNU/Linux, but Windows -(MSYS2 + Mingw-w64 toolchain) and Mac OS X are also supported. +(MSYS2 + Mingw-w64 toolchain, CodeBlocks, Dev-C++) and Mac OS X are +also supported. Please make sure you have SDL2 development packages. On Debian, Mint, Ubuntu and similar distributions, please install `libsdl2-dev` and its @@ -68,10 +68,10 @@ $ ./build.sh -which creates a subdirectory called `build`, cd's to it, runs `cmake`, -then `cpack`. In a few seconds, in `build` you will find a package -that should be suitable for your system (`.deb` or `.rpm`). You'll -want to install that. +which creates a subdirectory called `build/`, cd's to it, runs +`cmake`, then `cpack`. In a few seconds, in directory `build/` will +find a package that should be suitable for your system (`.deb` or +`.rpm`). You'll want to install that. If you prefer the usual way: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/VERSION new/SDL_bgi-2.2.1/VERSION --- old/SDL_bgi-2.2.0/VERSION 2018-07-13 14:08:42.000000000 +0200 +++ new/SDL_bgi-2.2.1/VERSION 2018-07-26 12:06:47.000000000 +0200 @@ -1 +1 @@ -2.2.0 +2.2.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/doc/functions.md new/SDL_bgi-2.2.1/doc/functions.md --- old/SDL_bgi-2.2.0/doc/functions.md 2018-07-16 09:38:20.000000000 +0200 +++ new/SDL_bgi-2.2.1/doc/functions.md 2018-08-08 11:47:20.000000000 +0200 @@ -7,238 +7,240 @@ Standard BGI ------------ -void arc (int x, int y, int stangle, int endangle, int radius); +void `arc` (int x, int y, int stangle, int endangle, int radius); -void bar3d (int left, int top, int right, int bottom, int depth, int topflag); +void `bar3d` (int left, int top, int right, int bottom, int depth, int topflag); -void bar (int left, int top, int right, int bottom); +void `bar` (int left, int top, int right, int bottom); -void circle (int x, int y, int radius); +void `circle` (int x, int y, int radius); -void cleardevice (void); +void `cleardevice` (void); -void clearviewport (void); +void `clearviewport` (void); -void closegraph (void); +void `closegraph` (void); -void delay(int millisec) +void `delay` (int millisec) -void detectgraph (int *graphdriver, int *graphmode); +void `detectgraph` (int \*graphdriver, int \*graphmode); -void drawpoly (int numpoints, int *polypoints); +void `drawpoly` (int numpoints, int \*polypoints); -void ellipse (int x, int y, int stangle, int endangle, int xradius, int yradius); +void `ellipse` (int x, int y, int stangle, int endangle, int xradius, int yradius); -void fillellipse (int x, int y, int xradius, int yradius); +void `fillellipse` (int x, int y, int xradius, int yradius); -void fillpoly (int numpoints, int *polypoints); +void `fillpoly` (int numpoints, int \*polypoints); -void floodfill (int x, int y, int border); +void `floodfill` (int x, int y, int border); -int getactivepage (void); +int `getactivepage` (void); -void getarccoords (struct arccoordstype *arccoords); +void `getarccoords` (struct arccoordstype \*arccoords); -void getaspectratio (int *xasp, int *yasp); +void `getaspectratio` (int \*xasp, int \*yasp); -int getbkcolor (void); +int `getbkcolor` (void); -int getch (void); +int `getch` (void); -int getcolor (void); +int `getcolor` (void); -struct palettetype* getdefaultpalette (void); +struct palettetype\* `getdefaultpalette` (void); -char* getdrivername (void); +char\* `getdrivername` (void); -void getfillpattern (char *pattern); +void `getfillpattern` (char \*pattern); -void getfillsettings (struct fillsettingstype *fillinfo); +void `getfillsettings` (struct fillsettingstype \*fillinfo); -void getimage (int left, int top, int right, int bottom, void *bitmap); +void `getimage` (int left, int top, int right, int bottom, void \*bitmap); -int getgraphmode (void); +int `getgraphmode` (void); -void getlinesettings (struct linesettingstype *lineinfo); +void `getlinesettings` (struct linesettingstype \*lineinfo); -int getmaxcolor (void); +int `getmaxcolor` (void); -int getmaxmode (void); +int `getmaxmode` (void); -int getmaxx (void); +int `getmaxx` (void); -int getmaxy (void); +int `getmaxy` (void); -char* getmodename (int mode_number); +char\* `getmodename` (int mode_number); -void getmoderange (int graphdriver, int *lomode, int *himode); +void `getmoderange` (int graphdriver, int \*lomode, int \*himode); -void getpalette (struct palettetype *palette); +void `getpalette` (struct palettetype \*palette); -int getpalettesize (void); +int `getpalettesize` (void); -unsigned int getpixel (int x, int y); +unsigned `int` getpixel (int x, int y); -void gettextsettings (struct textsettingstype *texttypeinfo); +void `gettextsettings` (struct textsettingstype \*texttypeinfo); -void getviewsettings (struct viewporttype *viewport); +void `getviewsettings` (struct viewporttype \*viewport); -int getvisualpage (void); +int `getvisualpage` (void); -int getx (void); +int `getx` (void); -int gety (void); +int `gety` (void); -void graphdefaults (void); +void `graphdefaults` (void); -char* grapherrormsg (int errorcode); +char\* `grapherrormsg` (int errorcode); -int graphresult(void); +int `graphresult`(void); -unsigned imagesize (int left, int top, int right, int bottom); +unsigned `imagesize` (int left, int top, int right, int bottom); -void initgraph (int *graphdriver, int *graphmode, char *pathtodriver); +void `initgraph` (int \*graphdriver, int \*graphmode, char \*pathtodriver); -int installuserdriver (char *name, int huge (*detect)(void)); +int `installuserdriver` (char \*name, int huge (\*detect)(void)); -int installuserfont (char *name); +int `installuserfont` (char \*name); -int kbhit (void); +int `kbhit` (void); -void line (int x1, int y1, int x2, int y2); +void `line` (int x1, int y1, int x2, int y2); -void linerel (int dx, int dy); +void `linerel` (int dx, int dy); -void lineto (int x, int y); +void `lineto` (int x, int y); -void moverel (int dx, int dy); +void `moverel` (int dx, int dy); -void moveto (int x, int y); +void `moveto` (int x, int y); -void outtext (char *textstring); +void `outtext` (char \*textstring); -void outtextxy (int x, int y, char *textstring); +void `outtextxy` (int x, int y, char \*textstring); -void pieslice (int x, int y, int stangle, int endangle, int radius); +void `pieslice` (int x, int y, int stangle, int endangle, int radius); -void putimage (int, int, void *, int); +void `putimage` (int, int, void \*, int); -void putpixel (int x, int y, int color); +void `putpixel` (int x, int y, int color); -int random (int range) (macro) +int `random` (int range) (macro) -void readimagefile (char *filename, int left, int top, int right, int bottom); +void `readimagefile` (char \*filename, int left, int top, int right, int bottom); -void rectangle (int left, int top, int right, int bottom); +void `rectangle` (int left, int top, int right, int bottom); -int registerbgidriver (void (*driver)(void)); +int `registerbgidriver` (void (\*driver)(void)); -int registerbgifont (void (*font)(void)); +int `registerbgifont` (void (\*font)(void)); -void restorecrtmode (void); +void `restorecrtmode` (void); -void sector (int x, int y, int stangle, int endangle, int xradius, int yradius); +void `sector` (int x, int y, int stangle, int endangle, int xradius, int yradius); -void setactivepage (int page); +void `setactivepage` (int page); -void setallpalette (struct palettetype *palette); +void `setallpalette` (struct palettetype \*palette); -void setaspectratio (int xasp, int yasp); +void `setaspectratio` (int xasp, int yasp); -void setbkcolor (int color); +void `setbkcolor` (int color); -void setcolor (int color); +void `setcolor` (int color); -void setfillpattern (char *upattern, int color); +void `setfillpattern` (char \*upattern, int color); -void setfillstyle (int pattern, int color); +void `setfillstyle` (int pattern, int color); -unsigned setgraphbufsize (unsigned bufsize); +unsigned `setgraphbufsize` (unsigned bufsize); -void setgraphmode (int mode); +void `setgraphmode` (int mode); -void setlinestyle (int linestyle, unsigned upattern, int thickness); +void `setlinestyle` (int linestyle, unsigned upattern, int thickness); -void setpalette (int colornum, int color); +void `setpalette` (int colornum, int color); -void settextjustify (int horiz, int vert); +void `settextjustify` (int horiz, int vert); -void settextstyle (int font, int direction, int charsize); +void `settextstyle` (int font, int direction, int charsize); -void setusercharsize (int multx, int divx, int multy, int divy); +void `setusercharsize` (int multx, int divx, int multy, int divy); -void setviewport (int left, int top, int right, int bottom, int clip); +void `setviewport` (int left, int top, int right, int bottom, int clip); -void setvisualpage (int page); +void `setvisualpage` (int page); -void setwritemode (int mode); +void `setwritemode` (int mode); -int textheight (char *textstring); +int `textheight` (char \*textstring); -int textwidth (char *textstring); +int `textwidth` (char \*textstring); -void writeimagefile (char *filename, int left, int top, int right, int bottom); +void `writeimagefile` (char \*filename, int left, int top, int right, int bottom); SDL_bgi extensions ------------------ -int BLUE_VALUE (int color); +int `ALPHA_VALUE` (int color); -void closewindow (int); +int `BLUE_VALUE` (int color); -int COLOR(int r, int g, int b); +void `closewindow` (int); -int event (void); +int `COLOR`(int r, int g, int b); -int eventtype (void); +int `event` (void); -int getcurrentwindow (void); +int `eventtype` (void); -int getevent (void); +int `getcurrentwindow` (void); -void getmouseclick (int kind, int *x, int *y); +int `getevent` (void); -int GREEN_VALUE(int color); +void `getmouseclick` (int kind, int \*x, int \*y); -int initwindow (int width, int height); +int `GREEN_VALUE`(int color); -int IS_BGI_COLOR (int color); +int `initwindow` (int width, int height); -int ismouseclick (int kind); +int `IS_BGI_COLOR` (int color); -int IS_RGB_COLOR(int color); +int `ismouseclick` (int kind); -int mouseclick(void); +int `IS_RGB_COLOR`(int color); -int mousex (void); +int `mouseclick`(void); -int mousey (void); +int `mousex` (void); -void _putpixel (int x, int y); +int `mousey` (void); -int RED_VALUE (int color); +void `_putpixel` (int x, int y); -void readimagefile (char *filename, int x1, int y1, int x2, int y2); +int `RED_VALUE` (int color); -void refresh (void); +void `readimagefile` (char \*filename, int x1, int y1, int x2, int y2); -void sdlbgifast (void); +void `refresh` (void); -void sdlbgislow (void); +void `sdlbgifast` (void); -void setalpha (int col, Uint32 alpha); +void `sdlbgislow` (void); -void setbkrgbcolor (int color); +void `setalpha` (int col, Uint32 alpha); -void setcurrentwindow (int id); +void `setbkrgbcolor` (int color); -void setrgbcolor (int color); +void `setcurrentwindow` (int id); -void setrgbpalette (int colornum, int red, int green, int blue); +void `setrgbcolor` (int color); -void setwinoptions (char *title, int x, int y, Uint32 flags); +void `setrgbpalette` (int colornum, int red, int green, int blue); -void swapbuffers (void); +void `setwinoptions` (char \*title, int x, int y, Uint32 flags); -int xkbhit (void); +void `swapbuffers` (void); + +int `xkbhit` (void); Binary files old/SDL_bgi-2.2.0/doc/functions.pdf and new/SDL_bgi-2.2.1/doc/functions.pdf differ Binary files old/SDL_bgi-2.2.0/doc/sdl_bgi-quickref.pdf and new/SDL_bgi-2.2.1/doc/sdl_bgi-quickref.pdf differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/doc/sdl_bgi-quickref.tex new/SDL_bgi-2.2.1/doc/sdl_bgi-quickref.tex --- old/SDL_bgi-2.2.0/doc/sdl_bgi-quickref.tex 2018-07-17 11:59:46.000000000 +0200 +++ new/SDL_bgi-2.2.1/doc/sdl_bgi-quickref.tex 2018-08-08 11:48:38.000000000 +0200 @@ -1,7 +1,7 @@ % sdl_bgi-quickref.tex % % Guido Gonzato, PhD -% July 17, 2018 +% August 8, 2018 \documentclass[a4paper,11pt]{article} \usepackage{graphicx} @@ -18,7 +18,7 @@ \newcommand{\SDLbgi}{\texttt{SDL\_bgi}} -\newcommand{\version}{2.2.0} % !!! <<<=== Change here !!! +\newcommand{\version}{2.2.1} % !!! <<<=== Change here !!! \newcommand{\V}{\texttt{void}} % void \newcommand{\I}{\texttt{int}} % int @@ -131,7 +131,7 @@ #ifndef _SDL_BGI_H #define _SDL_BGI_H -#define SDL_BGI_VERSION 2.2.0 +#define SDL_BGI_VERSION 2.2.1 #define NOPE 0 #define YEAH 1 @@ -280,7 +280,6 @@ #define KEY_SCR_LOCK SDLK_SCROLLOCK #define KEY_ESC SDLK_ESCAPE -// SDL_QUIT #define QUIT SDL_QUIT // graphics modes @@ -1226,7 +1225,8 @@ \end{bgi} Waits for \A{millisec} milliseconds. In ``slow mode'', a screen -refresh is performed. +refresh is performed. Key presses during the delay are passed on to +\func{kbhit} and \func{xkbhit}. % ----- @@ -1261,7 +1261,16 @@ \section{\SDLbgi{} Additions} \begin{bgi} -\I{} BLUE\_VALUE (\I{} \A{color}) +\I{} \func{ALPHA\_VALUE} (\I{} \A{color}) +\end{bgi} + +Returns the alpha (transparency) component of an RGB color. + +% ----- + + +\begin{bgi} +\I{} \func{BLUE\_VALUE} (\I{} \A{color}) \end{bgi} Returns the blue component of an RGB color. @@ -1289,8 +1298,8 @@ \I{} \func{IS\_BGI\_COLOR} (\I{} \A{color}); \end{bgi} -Returns 1 if the current color is a standard BGI color (not RGB). The -argument is actually redundant. +Returns 1 if the current drawing color is a standard BGI color (that +is, not RGB). The argument is actually redundant. % ----- @@ -1298,7 +1307,7 @@ \I{} \func{IS\_RGB\_COLOR} (\I{} \A{color}); \end{bgi} -Returns 1 if the current color is in RGB mode. The argument is +Returns 1 if the current drawing color is RGB. The argument is actually redundant. % ----- @@ -1323,7 +1332,7 @@ \V{} \func{event} (\V{}); \end{bgi} -Returns 1 if an event (mouse click or key press) has occurred. +Returns 1 if an event (mouse click, key press, or \T{QUIT}) has occurred. % ----- @@ -1429,8 +1438,7 @@ \end{bgi} Plots a point at (\A{x},\A{y}) using the current drawing color. This -function is faster than \func{putpixel()}, since it is not immediately -displayed. +function may be faster than \func{putpixel()}. % ----- @@ -1535,7 +1543,7 @@ values \T{SDL\_WINDOW\_FULLSCREEN}, \T{SDL\_WINDOW\_FULLSCREEN\_DESKTOP}, \T{SDL\_WINDOW\_SHOWN}, \T{SDL\_WINDOW\_HIDDEN}, \T{SDL\_WINDOW\-\_BORDERLESS}, and -\T{SDL\_WINDOW\_MINIMIZED} are applied. +\T{SDL\_WINDOW\_MINIMIZED} can be applied. % ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/doc/using.md new/SDL_bgi-2.2.1/doc/using.md --- old/SDL_bgi-2.2.0/doc/using.md 2018-07-18 10:40:53.000000000 +0200 +++ new/SDL_bgi-2.2.1/doc/using.md 2018-08-08 11:46:17.000000000 +0200 @@ -36,12 +36,14 @@ Dev-C++ users should read the file `howto_Dev-Cpp.md`. -Windows users **must** provide the `main ()` function as: +Windows users **must** declare the `main()` function as: - int main (int argc, char **argv) + int main (int argc, char *argv[]) -even if `argc` and `argv` are not used. Your program will not compile -if you use `int main (void)`. +even if `argc` and `argv` will not be used. Your program will not +compile if you use a different `main()` definition (i.e. `int main +(void)`), because of conflict with the `WinMain()` definition. +Please consult <https://wiki.libsdl.org/FAQWindows> for details. Most old programs that use the original BGI library should compile unmodified. For instance, @@ -78,7 +80,7 @@ You may want to use `initwindow(int width, int height)` instead. -`SDL_bgi.h` defines the `_SDL_BGI_H` constant. You may check for its +`SDL_bgi.h` defines the `_SDL_BGI_H` constant. You can check for its presence and write programs that employ `SDL_bgi` extensions; please have a look at the test program `fern.c`. @@ -94,7 +96,7 @@ `SDL_RenderPresent()`. You can choose whether to open the graphics system using -`initgraph()`, which toggles BGI compatibility and forces a screen +`initgraph()`, which toggles BGI compatibility on and forces a screen refresh after every graphics command, or using `initwindow()` that leaves you in charge of refreshing the screen when needed, using the new function `refresh()`. The second method is *much* faster and is @@ -168,8 +170,6 @@ to other BGI fonts (e.g. `TRIPLEX_FONT`, and others) have no effect: consider using `SDL_ttf`! -- key presses may not be detected correctly during a `delay()`. - Additions --------- @@ -209,8 +209,8 @@ - `IS_BGI_COLOR(int c)` and `IS_RGB_COLOR(int c)` return 1 if the current colour is standard BGI or RGB, respectively. -- `RED_VALUE(int c)`, `GREEN_VALUE(int c)`, and `BLUE_VALUE(int c)` -return the R, G, B component of an RGB colour. +- `ALPHA_VALUE(int c)`, `RED_VALUE(int c)`, `GREEN_VALUE(int c)`, +and `BLUE_VALUE(int c)` return the A, R, G, B component of an RGB colour. - `setalpha(int col, Uint8 alpha)` sets the alpha component of colour 'col'. @@ -310,7 +310,8 @@ <https://archive.org/details/msdos_borland_turbo_c_2.01>. The `bgidemo.c` program demonstrates the capabilities of the BGI -library. You can download it and compile it using `SDL_bgi`. +library. You can download it and compile it using `SDL_bgi`; in +Windows, you will have to change its `main()` declaration. Bugs & Issues @@ -321,8 +322,8 @@ refreshing an `SDL_Rect` correctly, it only works on entire textures. It looks like it's an SDL2 bug. -In MSYS2 + Mingw64, the `getch()` function hangs; use `getevent()` -instead. In general, keyboard events may work strangely in Mingw. +Console routines such as `getch()` may hang in Mingw. As far as I can +tell, it's a bug in Mingw console handling. Colours don't have the same RGB values as the original BGI colours. But they look better (IMHO). Binary files old/SDL_bgi-2.2.0/doc/using.pdf and new/SDL_bgi-2.2.1/doc/using.pdf differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/sdl_bgi.spec new/SDL_bgi-2.2.1/sdl_bgi.spec --- old/SDL_bgi-2.2.0/sdl_bgi.spec 2018-07-13 18:08:39.000000000 +0200 +++ new/SDL_bgi-2.2.1/sdl_bgi.spec 2018-07-30 07:54:12.000000000 +0200 @@ -4,7 +4,7 @@ Summary: BGI-compatible 2D graphics C library Name: SDL_bgi -Version: 2.2.0 +Version: 2.2.1 Release: 1 License: ZLib Group: Libraries diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/src/SDL_bgi.c new/SDL_bgi-2.2.1/src/SDL_bgi.c --- old/SDL_bgi-2.2.0/src/SDL_bgi.c 2018-07-18 10:45:04.000000000 +0200 +++ new/SDL_bgi-2.2.1/src/SDL_bgi.c 2018-08-09 11:04:44.000000000 +0200 @@ -3,8 +3,9 @@ // A BGI (Borland Graphics Library) implementation based on SDL2. // Easy to use, pretty fast, and useful for porting old programs // and for teaching. +// // By Guido Gonzato, PhD -// July 18, 2018 +// August 9, 2018 /* @@ -75,11 +76,14 @@ // copied to bgi_renderer, and finally bgi_renderer is made present. // The palette contains the BGI colors, entries 0:MAXCOLORS; -// then three entries for temporary fg, bg, and fill RGB colors -// allocated with COLOR(); then user-defined RGB colors +// then three entries for temporary fg, bg, and fill ARGB colors +// allocated with COLOR(); then user-defined ARGB colors + +#define BGI_COLORS MAXCOLORS + 1 +#define TMP_COLORS 3 static Uint32 - palette[1 + MAXCOLORS + 3 + PALETTE_SIZE]; // all colors + palette[BGI_COLORS + TMP_COLORS + PALETTE_SIZE]; // all colors static Uint32 bgi_palette[1 + MAXCOLORS] = { // 0 - 15 @@ -126,7 +130,7 @@ bgi_font_width = 8, // default font width and height bgi_font_height = 8, bgi_fast_mode = 1, // needs screen update? - bgi_last_event = 0, // mouse click or keyboard event + bgi_last_event = 0, // mouse click, keyboard event, or QUIT bgi_cp_x = 0, // current position bgi_cp_y = 0, bgi_maxx, // screen size @@ -144,7 +148,9 @@ // booleans static int - window_is_hidden = NOPE; + window_is_hidden = NOPE, + key_pressed = NOPE, + xkey_pressed = NOPE; static float bgi_font_mag_x = 1.0, // font magnification @@ -371,10 +377,37 @@ // ----- +int ALPHA_VALUE (int color) +{ + // Returns the alpha (transparency) component of an ARGB color. + return ((palette[BGI_COLORS + TMP_COLORS + color] >> 24) & 0xFF); + +} // ALPHA_VALUE () + +// ----- + +int RED_VALUE (int color) +{ + // return the red component of 'color' in the extended palette + return ((palette[BGI_COLORS + TMP_COLORS + color] >> 16) & 0xFF); + +} // RED_VALUE () + +// ----- + +int GREEN_VALUE (int color) +{ + // return the green component of 'color' in the extended palette + return ((palette[BGI_COLORS + TMP_COLORS + color] >> 8) & 0xFF); + +} // GREEN_VALUE () + +// ----- + int BLUE_VALUE (int color) { - // Returns the blue component of an RGB color. - return (palette[color] & 0xFF); + // Returns the blue component of an ARGB color. + return (palette[BGI_COLORS + TMP_COLORS + color] & 0xFF); } // BLUE_VALUE () @@ -499,7 +532,7 @@ fprintf (stderr, "Window %d does not exist\n", id); return; } - + SDL_DestroyTexture (bgi_txt[id]); SDL_DestroyRenderer (bgi_rnd[id]); SDL_DestroyWindow (bgi_win[id]); @@ -513,7 +546,7 @@ int COLOR (int r, int g, int b) { // Can be used as an argument for setcolor() and setbkcolor() - // to set an RBG color. + // to set an ARGB color. // set up the temporary color bgi_tmp_color_argb = 0xff000000 | r << 16 | g << 8 | b; @@ -525,22 +558,24 @@ void delay (int msec) { - // Waits for msec milliseconds. Takes cares of key presses. + // Waits for msec milliseconds. Implemented as a loop, + // because apparently SDL_Delay() ignores pending events. Uint32 - start, stop; - SDL_Event - event; + stop; if (! bgi_fast_mode) refresh (); - - start = SDL_GetTicks (); - stop = start + msec; - + + stop = SDL_GetTicks () + msec; + do { - if (SDL_PollEvent (&event)) - SDL_PushEvent (&event); + + if (kbhit ()) // take care of keypresses + key_pressed = YEAH; + if (xkbhit ()) + xkey_pressed = YEAH; + } while (SDL_GetTicks () < stop); } // delay () @@ -638,9 +673,10 @@ SDL_Event event; if (SDL_PollEvent (&event)) { - if ( (event.type == SDL_KEYDOWN) || - (event.type == SDL_MOUSEBUTTONDOWN) || - (event.type == SDL_MOUSEWHEEL)) { + if ( (SDL_KEYDOWN == event.type) || + (SDL_MOUSEBUTTONDOWN == event.type) || + (SDL_MOUSEWHEEL == event.type) || + (SDL_QUIT == event.type) ) { SDL_PushEvent (&event); // don't disrupt the event bgi_last_event = event.type; return YEAH; @@ -1181,18 +1217,28 @@ // ----- -int getch (void) +// this function should be simply named "getch", but this name +// causes a bug in Mingw. +// "getch" is defined as a macro in SDL_bgi.h + +int bgi_getch (void) { - // Waits for a key and returns its ASCII value or code + // Waits for a key and returns its ASCII value or code, + // or QUIT if the user asked to close the window + + int + key, type; - int key, type; - if (window_is_hidden) return (getchar()); - + do { key = getevent (); type = eventtype (); + + if (QUIT == type) + return QUIT; + if (SDL_KEYDOWN == type && key != KEY_LEFT_CTRL && key != KEY_RIGHT_CTRL && @@ -1205,7 +1251,7 @@ // we should never get here... return 0; -} // getch () +} // bgi_getch () // ----- @@ -1513,7 +1559,7 @@ // Returns the size of the palette. // !!! BUG - don't ignore the parameter - return 1 + MAXCOLORS + 3 + PALETTE_SIZE; + return BGI_COLORS + TMP_COLORS + PALETTE_SIZE; } // getpalettesize () // ----- @@ -1854,31 +1900,19 @@ } } - /* // maximised window? */ - /* if (window_flags & SDL_WINDOW_MAXIMIZED) { */ - /* bgi_maxx = mode.w - 1; */ - /* bgi_maxy = mode.h - 1; */ - /* window_x = window_y = 0; */ - /* } */ - - bgi_win[current_window] = SDL_CreateWindow (bgi_win_title, - window_x, - window_y, - bgi_maxx + 1, - bgi_maxy + 1, - window_flags); + bgi_win[current_window] = + SDL_CreateWindow (bgi_win_title, + window_x, + window_y, + bgi_maxx + 1, + bgi_maxy + 1, + window_flags); // is the window OK? if (NULL == bgi_win[current_window]) { printf ("Could not create window: %s\n", SDL_GetError ()); return; } - /* // maximised window? */ - /* if (window_flags & SDL_WINDOW_MAXIMIZED) */ - /* SDL_SetWindowPosition (bgi_win[current_window], */ - /* SDL_WINDOWPOS_CENTERED, */ - /* SDL_WINDOWPOS_CENTERED); */ - // window ok; create renderer bgi_rnd[current_window] = SDL_CreateRenderer (bgi_win[current_window], -1, @@ -1930,8 +1964,8 @@ int IS_BGI_COLOR (int color) { - // Returns 1 if the current color is a standard BGI color (not RGB)- - // the color argument is redundant + // Returns 1 if the current color is a standard BGI color + // (not ARGB); the color argument is redundant return ! bgi_argb_mode; } // IS_BGI_COLOR () @@ -1948,8 +1982,13 @@ if (! bgi_fast_mode) refresh (); + if (YEAH == key_pressed) { // a key was pressed during delay() + key_pressed = NOPE; + return YEAH; + } + if (SDL_PollEvent (&event)) { - if (event.type == SDL_KEYDOWN) { + if (SDL_KEYDOWN == event.type) { key = event.key.keysym.sym; if (key != SDLK_LCTRL && key != SDLK_RCTRL && @@ -1967,9 +2006,9 @@ return YEAH; else return NOPE; - } // if (event.type == SDL_KEYDOWN) + } // if (SDL_KEYDOWN == event.type) else - if (event.type == SDL_WINDOWEVENT) { + if (SDL_WINDOWEVENT == event.type) { if (SDL_WINDOWEVENT_CLOSE == event.window.event) return QUIT; } @@ -1979,49 +2018,6 @@ return NOPE; } -// alternate implementation (defective): - -#if 0 -int kbhit (void) -{ - // Returns YEAH when a key is pressed. - - const Uint8 *keys; - int i, numkeys, pressed = NOPE; - - if (! bgi_fast_mode) - refresh (); - - SDL_PumpEvents (); - keys = SDL_GetKeyboardState (&numkeys); - - // check if any key is set to 1 - for (i = 0; i < numkeys; i++) - if (keys[i]) - pressed = YEAH; - - // is that a key that should be ignored? - - if (keys[SDL_SCANCODE_LCTRL] || - keys[SDL_SCANCODE_RCTRL] || - keys[SDL_SCANCODE_LSHIFT] || - keys[SDL_SCANCODE_RSHIFT] || - keys[SDL_SCANCODE_LGUI] || - keys[SDL_SCANCODE_RGUI] || - keys[SDL_SCANCODE_LALT] || - keys[SDL_SCANCODE_RALT] || - keys[SDL_SCANCODE_PAGEUP] || - keys[SDL_SCANCODE_PAGEDOWN] || - keys[SDL_SCANCODE_CAPSLOCK] || - keys[SDL_SCANCODE_MENU] || - keys[SDL_SCANCODE_APPLICATION]) - pressed = NOPE; - - return pressed; - -} // kbhit () -#endif - // ----- // Bresenham's line algorithm routines that implement logical @@ -2435,13 +2431,13 @@ if (SDL_PollEvent (&event)) { - if (event.type == SDL_MOUSEBUTTONDOWN) { + if (SDL_MOUSEBUTTONDOWN == event.type) { bgi_mouse_x = event.button.x; bgi_mouse_y = event.button.y; return (event.button.button); } else - if (event.type == SDL_MOUSEMOTION) { + if (SDL_MOUSEMOTION == event.type) { bgi_mouse_x = event.motion.x; bgi_mouse_y = event.motion.y; return (WM_MOUSEMOVE); @@ -2787,7 +2783,7 @@ void _putpixel (int x, int y) { - // line putpixel (), but not updated + // like putpixel (), but not updated // viewport range is taken care of by this function only, // since all others use it to draw. @@ -2935,7 +2931,8 @@ if (x < vp.left || x > vp.right || y < vp.top || y > vp.bottom) return; - if (-1 == color) { // COLOR () set up the WHITE + 1 color + // COLOR () set up the BGI_COLORS + 1 color + if (-1 == color) { bgi_argb_mode = YEAH; tmpcolor = WHITE + 1; palette[tmpcolor] = bgi_tmp_color_argb; @@ -3175,14 +3172,18 @@ Uint32 tmp; - if (-1 == col) { // COLOR () set up the WHITE + 1 color + // alpha is only allowed in argb mode + if (col <= BGI_COLORS) + return; + + // COLOR () set up the BGI_COLORS + 1 (temporary) color + if (-1 == col) { bgi_argb_mode = YEAH; - bgi_fg_color = WHITE + 1; - } - else { - bgi_argb_mode = NOPE; - bgi_fg_color = col; + bgi_fg_color = BGI_COLORS + 1; } + else + bgi_fg_color = BGI_COLORS + TMP_COLORS + col; + tmp = palette[bgi_fg_color] << 8; // get rid of alpha tmp = tmp >> 8; palette[bgi_fg_color] = ((Uint32)alpha << 24) | tmp; @@ -3205,9 +3206,10 @@ { // Sets the current background color using the default palette. - if (-1 == col) { // COLOR () set up the WHITE + 2 color + // COLOR () set up the BGI_COLORS + 2 color + if (-1 == col) { bgi_argb_mode = YEAH; - bgi_bg_color = WHITE + 2; + bgi_bg_color = BGI_COLORS + 2; palette[bgi_bg_color] = bgi_tmp_color_argb; } else { @@ -3221,9 +3223,9 @@ void setbkrgbcolor (int index) { // Sets the current background color using using the - // n-th color index in the RGB palette. + // n-th color index in the ARGB palette. - bgi_bg_color = 1 + MAXCOLORS + 2 + index; + bgi_bg_color = BGI_COLORS + TMP_COLORS + index; } // setbkrgbcolor () // ----- @@ -3232,7 +3234,8 @@ { // Sets the current drawing color using the default palette. - if (-1 == col) { // COLOR () set up the WHITE + 1 color + // COLOR () set up the BGI_COLORS + 1 color + if (-1 == col) { bgi_argb_mode = YEAH; bgi_fg_color = WHITE + 1; palette[bgi_fg_color] = bgi_tmp_color_argb; @@ -3278,9 +3281,10 @@ for (i = 0; i < 8; i++) fill_patterns[USER_FILL][i] = (Uint8) *upattern++; - if (-1 == color) { // COLOR () set up the WHITE + 3 color + // COLOR () set up the BGI_COLORS + 3 color + if (-1 == color) { bgi_argb_mode = YEAH; - bgi_fill_color = WHITE + 3; + bgi_fill_color = BGI_COLORS + 3; palette[bgi_fill_color] = bgi_tmp_color_argb; bgi_fill_style.color = bgi_fill_color; } @@ -3301,9 +3305,10 @@ bgi_fill_style.pattern = pattern; - if (-1 == color) { // COLOR () set up the WHITE + 3 color + // COLOR () set up the BGI_COLORS + 3 color + if (-1 == color) { bgi_argb_mode = YEAH; - bgi_fill_color = WHITE + 3; + bgi_fill_color = BGI_COLORS + 3; palette[bgi_fill_color] = bgi_tmp_color_argb; bgi_fill_style.color = bgi_fill_color; } @@ -3352,19 +3357,19 @@ void setrgbcolor (int index) { // Sets the current drawing color using the n-th color index - // in the RGB palette. + // in the ARGB palette. - bgi_fg_color = 1 + MAXCOLORS + 3 + index; + bgi_fg_color = BGI_COLORS + TMP_COLORS + index; } // setrgbcolor () // ----- void setrgbpalette (int colornum, int red, int green, int blue) { - // Sets the n-th entry in the RGB palette specifying the r, g, + // Sets the n-th entry in the ARGB palette specifying the r, g, // and b components. - palette[1 + MAXCOLORS + 3 + colornum] = + palette[BGI_COLORS + TMP_COLORS + colornum] = 0xff000000 | red << 16 | green << 8 | blue; } // setrgbpalette () @@ -3508,24 +3513,6 @@ // ----- -int RED_VALUE (int color) -{ - // return the red component of 'color' in the extended palette - return ((palette[color] >> 16) & 0xFF); - -} // RED_VALUE () - -// ----- - -int GREEN_VALUE (int color) -{ - // return the green component of 'color' in the extended palette - return ((palette[color] >> 8) & 0xFF); - -} // GREEN_VALUE () - -// ----- - void updaterect (int x1, int y1, int x2, int y2) { // updates a rectangle on the screen. Suffers from SDL2 bug. @@ -3623,11 +3610,16 @@ if (! bgi_fast_mode) refresh (); + if (YEAH == xkey_pressed) { // a key was pressed during delay() + xkey_pressed = NOPE; + return YEAH; + } + if (SDL_PollEvent (&event)) { - if (event.type == SDL_KEYDOWN) + if (SDL_KEYDOWN == event.type) return YEAH; else - if (event.type == SDL_WINDOWEVENT) { + if (SDL_WINDOWEVENT == event.type) { if (SDL_WINDOWEVENT_CLOSE == event.window.event) return QUIT; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/src/SDL_bgi.h new/SDL_bgi-2.2.1/src/SDL_bgi.h --- old/SDL_bgi-2.2.0/src/SDL_bgi.h 2018-07-18 10:35:08.000000000 +0200 +++ new/SDL_bgi-2.2.1/src/SDL_bgi.h 2018-08-10 08:33:48.000000000 +0200 @@ -3,7 +3,7 @@ // A BGI (Borland Graphics Library) implementation based on SDL2. // Easy to use, pretty fast, and useful for porting old programs. // Guido Gonzato, PhD -// July 18, 2018 +// August 8, 2018 /* This software is provided 'as-is', without any express or implied @@ -23,18 +23,24 @@ 3. This notice may not be removed or altered from any source distribution. */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +// SDL2 stuff #include <SDL2/SDL.h> #include <SDL2/SDL_keycode.h> +// for fprintf() +#include <stdio.h> +// for exit(), calloc() +#include <stdlib.h> +// for sin(), cos() +#include <math.h> +// for strlen(), memcpy() +#include <string.h> + #ifndef _SDL_BGI_H #define _SDL_BGI_H -#define SDL_BGI_VERSION 2.2.0 +#define SDL_BGI_VERSION 2.2.1 #define NOPE 0 #define YEAH 1 @@ -180,7 +186,6 @@ #define KEY_SCR_LOCK SDLK_SCROLLOCK #define KEY_ESC SDLK_ESCAPE -// SDL_QUIT #define QUIT SDL_QUIT // graphics modes @@ -308,7 +313,9 @@ void getarccoords (struct arccoordstype *); void getaspectratio (int *, int *); int getbkcolor (void); -int getch (void); +int bgi_getch (void); +// circumvents Mingw bug +#define getch bgi_getch int getcolor (void); struct palettetype *getdefaultpalette (void); char *getdrivername (void); @@ -379,6 +386,7 @@ // SDL_bgi extensions +int ALPHA_VALUE (int); int BLUE_VALUE (int); void closewindow (int); int COLOR (int, int, int); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/Makefile new/SDL_bgi-2.2.1/test/Makefile --- old/SDL_bgi-2.2.0/test/Makefile 2018-07-17 13:49:03.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/Makefile 2018-08-07 12:47:15.000000000 +0200 @@ -26,7 +26,7 @@ PROGRAMS = cellular dla fern floodfilltest hopalong life \ mandelbrot mousetest moveit multiwin plasma \ - sdlbgidemo simple turtledemo + psychedelia sdlbgidemo simple turtledemo all: $(PROGRAMS) @@ -66,6 +66,9 @@ plasma: plasma.c $(CC) $(CFLAGS) -o plasma plasma.c $(LIBS) -lm +psychedelia: psychedelia.c + $(CC) $(CFLAGS) -o psychedelia psychedelia.c $(LIBS) -lm + simple: simple.c $(CC) $(CFLAGS) -o simple simple.c $(LIBS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/README.md new/SDL_bgi-2.2.1/test/README.md --- old/SDL_bgi-2.2.0/test/README.md 2018-07-17 11:43:44.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/README.md 2018-08-07 13:04:54.000000000 +0200 @@ -44,9 +44,14 @@ - `plasma.c` writes the window contents to a .bmp file. +- `psychedelia.c` sets up an RGB palette and produces a plasma effect. +Algorithm described at <https://lodev.org/cgtutor/plasma.html>. + - `sdlbgidemo.c` shows how to use some of `SDL_bgi`'s features. - `simple.c` displays simple shapes to test `SDL_bgi`'s speed. +**Note**: this programs hangs in Mingw, because of a bug in its +console routines (apparently). - `turtledemo.c` uses a simple yet powerful turtle graphics implementation to draw fractals and simple shapes. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/cellular.c new/SDL_bgi-2.2.1/test/cellular.c --- old/SDL_bgi-2.2.0/test/cellular.c 2018-07-17 10:10:57.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/cellular.c 2018-08-08 12:20:16.000000000 +0200 @@ -75,7 +75,7 @@ // ----- -int main (int argc, char **argv) +int main (int argc, char *argv[]) { int diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/hopalong.c new/SDL_bgi-2.2.1/test/hopalong.c --- old/SDL_bgi-2.2.0/test/hopalong.c 2018-06-27 07:20:29.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/hopalong.c 2018-08-08 12:20:53.000000000 +0200 @@ -33,7 +33,7 @@ // ----- -int main (int argc, char **argv) +int main (int argc, char *argv[]) { int gd, gm, stop; unsigned int seed; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/life.c new/SDL_bgi-2.2.1/test/life.c --- old/SDL_bgi-2.2.0/test/life.c 2018-07-17 08:48:50.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/life.c 2018-08-08 12:20:36.000000000 +0200 @@ -70,7 +70,7 @@ closegraph (); -} // main(void) () +} // main() () // ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/mandelbrot.c new/SDL_bgi-2.2.1/test/mandelbrot.c --- old/SDL_bgi-2.2.0/test/mandelbrot.c 2018-06-27 07:20:29.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/mandelbrot.c 2018-08-08 12:25:10.000000000 +0200 @@ -152,7 +152,7 @@ settextstyle (GOTHIC_FONT, HORIZ_DIR, 2); settextjustify (CENTER_TEXT, CENTER_TEXT); - c = textheight ("H"); + c = 2*textheight ("H"); outtextxy (maxx / 2, maxy / 2 - 3*c, "Press '1', '2', or '3' to change the palette;"); outtextxy (maxx / 2, maxy / 2 - 2*c, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/plasma.c new/SDL_bgi-2.2.1/test/plasma.c --- old/SDL_bgi-2.2.0/test/plasma.c 2018-07-17 17:35:34.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/plasma.c 2018-08-09 09:26:02.000000000 +0200 @@ -66,13 +66,12 @@ b = b - 256; if (b < 0) b = 256 + c; - setcolor (COLOR(r, g, b)); - _putpixel(x, y); + putpixel(x, y, COLOR(r, g, b)); } } refresh (); + getch (); writeimagefile ("plasma.bmp", 0, 0, 599, 599); - getevent (); closegraph (); return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/psychedelia.c new/SDL_bgi-2.2.1/test/psychedelia.c --- old/SDL_bgi-2.2.0/test/psychedelia.c 1970-01-01 01:00:00.000000000 +0100 +++ new/SDL_bgi-2.2.1/test/psychedelia.c 2018-08-09 08:34:49.000000000 +0200 @@ -0,0 +1,115 @@ +/* psychedelia.c -*- C -*- + * + * To compile: + * gcc -o psychedelia psychedelia.c -lSDL_bgi -lSDL2 -lm + * + * Variation on 'plasma.c', as described here: + * https://lodev.org/cgtutor/plasma.html + * By Guido Gonzato, August 2018. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <math.h> +#include <graphics.h> + +// ----- + +int main (int argc, char **argv) +{ + + int + col, + r, g, b, // colour indices + d1, d2, d3; // used to change the plasma parameters + + float + k1, k2, k3; // plasma parameters + + // make a palette + for (int i = 0; i < 255; i++) + setrgbpalette (i, + (int) fabs((128. - 127.*sinf((float)i*M_PI/32.))), + (int) fabs((128. - 127.*sinf((float)i*M_PI/64.))), + (int) fabs((128. - 127.*sinf((float)i*M_PI/128.))) ); + + // parameters are allowed to range from 0 to 256 + + k1 = 128.; + k2 = 32.; + k3 = 64.; + d1 = -1; + d2 = 1; + d3 = 1; + + initwindow (800, 600); + int stop = 0; + + do { + + for (int y = 0; y < getmaxy (); y++) { + for (int x = 0; x < getmaxx (); x++) { + + col = (int) ( + sinf (x / 50.) * k1 + + sinf (y / 40.) * k2 + + sinf ((x + y) / 30.) * k3); + + while (col > 255) + col -= 256; + while (col < 0) + col += 256; + + r = RED_VALUE (col); + g = GREEN_VALUE (col); + b = BLUE_VALUE (col); + + // changing the palette on each plotted pixel + // is not a great idea. + // setrgbpalette (col, r, g, b); + // setrgbcolor (col); + // _putpixel (x, y); + + // simpler option + putpixel (x, y, COLOR(r, g, b)); + + } // for x + } // for y + + refresh (); + + // change the parameters + k1 += d1; + if (k1 < 2 || k1 > 255) + d1 *= -1; + k2 += d2; + if (k2 < 2 || k2 > 255) + d2 *= -1; + k3 += d3; + if (k3 < 2 || k3 > 255) + d3 *= -1; + + if (event()) + stop = 1; + + } while (!stop); + + closegraph (); + return 0; + +} + +// ----- end of file psychedelia.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/simple.c new/SDL_bgi-2.2.1/test/simple.c --- old/SDL_bgi-2.2.0/test/simple.c 2018-07-17 17:36:23.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/simple.c 2018-07-26 12:06:47.000000000 +0200 @@ -149,7 +149,7 @@ lines (); pixels (); - getevent (); + // getevent (); closegraph (); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.2.0/test/turtledemo.c new/SDL_bgi-2.2.1/test/turtledemo.c --- old/SDL_bgi-2.2.0/test/turtledemo.c 2018-07-18 09:26:17.000000000 +0200 +++ new/SDL_bgi-2.2.1/test/turtledemo.c 2018-08-08 12:40:48.000000000 +0200 @@ -74,13 +74,13 @@ home (); wrap (); setheading (angle); - turtlesize (50); + turtlesize (40); showturtle (); refresh (); do { - c = getevent (); + c = getch (); switch (c) { case KEY_UP: @@ -93,7 +93,7 @@ turnright (5); break; default: - forwd (len); + ; } refresh (); @@ -336,7 +336,7 @@ for (i = 0; i < 14; i++) { cleardevice (); setcolor (GREEN); - outtextxy (0, 0, "Tree:"); + outtextxy (0, 0, "Fractal tree:"); setposition (getmaxx ()*4/10, getmaxy ()); setheading (T_NORTH); tree (getmaxy () / 3, i); @@ -377,6 +377,7 @@ if (kbhit ()) break; } + hideturtle (); pause (); // Hilbert @@ -386,6 +387,7 @@ setcolor (GREEN); for (i = 1; i < 8; i++) { + cleardevice (); l = getmaxy () / powerof2 (i); x += l / 2; y = l / 2; @@ -396,9 +398,12 @@ sprintf (s, "Hilbert curve at level %d", i); outtextxy (0, 0, s); refresh (); - delay (1000); - cleardevice (); + delay (200); } + hideturtle (); + pause (); + + cleardevice (); outtextxy (0, 0, "PRESS A KEY TO EXIT:"); refresh (); ++++++ sdlbgi-automake.diff ++++++ --- /var/tmp/diff_new_pack.sETo86/_old 2018-08-18 00:03:02.782885989 +0200 +++ /var/tmp/diff_new_pack.sETo86/_new 2018-08-18 00:03:02.782885989 +0200 @@ -24,7 +24,7 @@ --- /dev/null +++ SDL_bgi-2.0.6/configure.ac @@ -0,0 +1,9 @@ -+AC_INIT([SDL_bgi], [2.0.6]) ++AC_INIT([SDL_bgi], [2.2.1]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_MACRO_DIR([m4]) +AC_PROG_CC @@ -43,7 +43,7 @@ +lib_LTLIBRARIES = libSDL_bgi.la +libSDL_bgi_la_SOURCES = SDL_bgi.c +libSDL_bgi_la_LIBADD = -lm ${sdl2_LIBS} -+libSDL_bgi_la_LDFLAGS = -no-undefined -version-info 1:0:0 ++libSDL_bgi_la_LDFLAGS = -no-undefined -version-info 2:0:0 +pkgincludedir = ${includedir}/SDL2 +pkginclude_HEADERS = SDL_bgi.h Index: SDL_bgi-2.0.6/test/Makefile.am
