Hello community, here is the log from the commit of package SDL_bgi for openSUSE:Factory checked in at 2015-05-30 12:33:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/SDL_bgi (Old) and /work/SRC/openSUSE:Factory/.SDL_bgi.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "SDL_bgi" Changes: -------- --- /work/SRC/openSUSE:Factory/SDL_bgi/SDL_bgi.changes 2015-05-29 10:37:35.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.SDL_bgi.new/SDL_bgi.changes 2015-05-30 12:33:58.000000000 +0200 @@ -1,0 +2,7 @@ +Tue May 12 10:56:49 UTC 2015 - jengelh@inai.de + +- Update to new upstream release 2.0.1 +* Support line patterns +* Improvements to flood fills + +------------------------------------------------------------------- Old: ---- SDL_bgi-2.0.0.tar.gz New: ---- SDL_bgi-2.0.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ SDL_bgi.spec ++++++ --- /var/tmp/diff_new_pack.zGCdfh/_old 2015-05-30 12:33:59.000000000 +0200 +++ /var/tmp/diff_new_pack.zGCdfh/_new 2015-05-30 12:33:59.000000000 +0200 @@ -18,7 +18,7 @@ Name: SDL_bgi %define lname libSDL_bgi0 -Version: 2.0.0 +Version: 2.0.1 Release: 0 Summary: BGI-compatible 2D graphics C library with SDL backend License: Zlib and GPL-2.0+ ++++++ SDL_bgi-2.0.0.tar.gz -> SDL_bgi-2.0.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/00_README new/SDL_bgi-2.0.1/00_README --- old/SDL_bgi-2.0.0/00_README 2015-05-06 18:59:55.000000000 +0200 +++ new/SDL_bgi-2.0.1/00_README 2015-05-12 08:13:25.000000000 +0200 @@ -4,19 +4,19 @@ This is SDL_bgi, a graphics library based on SDL2. SDL_bgi provides graphics primitives, and is much easier to use than SDL2. -SDL_bgi is (say) 99% compatible with BGI, the Borland Graphics +SDL_bgi is nearly fully compatible with BGI, the Borland Graphics Interface that was the de facto standard in PC graphics back in DOS -days. It's pretty fast and very easy to use, and it also provides -extensions for RGB colours and mouse support. It should run on any +days. (It compiles and runs the original 'bgidemo.c' almost +perfectly.) It's pretty fast, very easy to use, and it also provides +extensions for ARGB colours and mouse support. It should run on any platform supported by SDL2; it was only tested in Linux, though. -Unlike other BGI-compatible libraries, the purpose of SDL_bgi is not -100% compatibility with BGI; rather, it is meant to be an easy -introduction to graphics. Some functions are still not implemented; -for instance, line and fill patterns. Obviously, native SDL2 functions -can be used in SDL_BGI programs. +I wrote SDL_bgi because I wanted a simple but fast graphics library +for my experiments with fractals and cellular automata, using the BGI +syntax I'm used to. Obviously, native SDL2 functions can be used in +SDL_bgi programs. -Examples are provided in the src/test/ directory. +A few examples are provided in the src/test/ directory. If you don't need BGI compatibility, I suggest that you check out SDL_gfx, a graphics library more complete and more powerful than @@ -24,11 +24,20 @@ Links: -0. WinBGIm: http://www.cs.colorado.edu/~main/cs1300/doc/bgi/ -1. SDL: https://www.libsdl.org/ -2. SDL_gfx: http://cms.ferzkopp.net/index.php/software/13-sdl-gfx -3. BGI: https://en.wikipedia.org/wiki/Borland_Graphics_Interface -4. Xbgi: http://libxbgi.sourceforge.net/ +0. WinBGIm, a BGI Windows port: + http://www.cs.colorado.edu/~main/cs1300/doc/bgi/ + +1. The SDL library: + https://www.libsdl.org/ + +2. SDL_gfx, graphics drawing primitives: + http://cms.ferzkopp.net/index.php/software/13-sdl-gfx + +3. BGI on Wikipedia: + https://en.wikipedia.org/wiki/Borland_Graphics_Interface + +4. Xbgi, a BGI XLib port: + http://libxbgi.sourceforge.net/ This library is licensed under the Zlib license; please see the file LICENSE. The 8x8 font comes from A. Schiffler's SDL_gfx. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/Changelog new/SDL_bgi-2.0.1/Changelog --- old/SDL_bgi-2.0.0/Changelog 2015-05-02 09:50:56.000000000 +0200 +++ new/SDL_bgi-2.0.1/Changelog 2015-05-11 10:51:19.000000000 +0200 @@ -2,9 +2,14 @@ --------- +v 2.0.1, 2015-05-11 +- line patterns. +- floodfill improvements. +- documentation updates. + v. 2.0.0, 2015-04-30 -- rewritten to use SDL2 only. -- added readimagefile (), logical plotting (XOR, etc.). +- major release: rewritten to use SDL2 only. +- added readimagefile () and logical plotting (XOR, etc.). v. 1.0.1, 2014-12-09 - Fixed minor bugs in putpixel() (reported by Angelo Graziosi) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/INSTALL new/SDL_bgi-2.0.1/INSTALL --- old/SDL_bgi-2.0.0/INSTALL 2015-05-01 10:22:55.000000000 +0200 +++ new/SDL_bgi-2.0.1/INSTALL 2015-05-11 21:45:13.000000000 +0200 @@ -2,10 +2,10 @@ ------------------ Please make sure you have SDL2 development packages. On Debian, Ubuntu -and similar distributions, please install libsdl2-dev and its +and similar distributions, please install 'libsdl2-dev' and its dependencies. -To compile and install the SDL_bgi library: +To compile and install the SDL_bgi library (using gcc or clang): $ cd src $ make diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/TODO new/SDL_bgi-2.0.1/TODO --- old/SDL_bgi-2.0.0/TODO 2015-05-06 18:57:05.000000000 +0200 +++ new/SDL_bgi-2.0.1/TODO 2015-05-12 08:18:58.000000000 +0200 @@ -1,10 +1,12 @@ TODO ---- -- a few BGI functions are missing, as explained in Using.txt. +- floodfill () fill patterns. -- other functions are not optimally implemented: filled curves and -polygons ought to use Bresenham-based algorithms. +- fillpoly () generic polygon, and fill patterns. -Got little time and lots of things to do. Please feel free to +- other functions are not optimally implemented: filled curves ought +to use Bresenham-based algorithms. + +I've got little time and lots of things to do. Please feel free to contribute! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/VERSION new/SDL_bgi-2.0.1/VERSION --- old/SDL_bgi-2.0.0/VERSION 2015-04-24 08:04:14.000000000 +0200 +++ new/SDL_bgi-2.0.1/VERSION 2015-05-08 09:15:35.000000000 +0200 @@ -1 +1 @@ -2.0.0 +2.0.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/doc/functions.txt new/SDL_bgi-2.0.1/doc/functions.txt --- old/SDL_bgi-2.0.0/doc/functions.txt 2015-05-06 12:52:20.000000000 +0200 +++ new/SDL_bgi-2.0.1/doc/functions.txt 2015-05-08 11:00:40.000000000 +0200 @@ -12,9 +12,9 @@ int BLUE_VALUE (int color); -// void bgifast (void); +void sdlbgifast (void); -// void bgislow (void); +void sdlbgislow (void); void circle (int x, int y, int radius); Files old/SDL_bgi-2.0.0/doc/sdl_bgi-quickref.pdf and new/SDL_bgi-2.0.1/doc/sdl_bgi-quickref.pdf differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/doc/sdl_bgi-quickref.tex new/SDL_bgi-2.0.1/doc/sdl_bgi-quickref.tex --- old/SDL_bgi-2.0.0/doc/sdl_bgi-quickref.tex 2015-05-07 10:50:43.000000000 +0200 +++ new/SDL_bgi-2.0.1/doc/sdl_bgi-quickref.tex 2015-05-11 11:53:31.000000000 +0200 @@ -1,6 +1,6 @@ -% xbgi-quickref.tex +% sdl_bgi-quickref.tex % -% Guido Gonzato, May 6, 2015 +% Guido Gonzato, May 11, 2015 \documentclass[a4paper,11pt]{article} \usepackage{graphicx} @@ -72,8 +72,8 @@ the like. Teachers may find \SDLbgi{} a useful tool for introductory computer graphics courses. -For example, this is a minimal program that opens a graphics window -and draws 1000 random lines: +For example, this is a minimal program that opens a window and draws +1000 random lines: \begin{small} \begin{verbatim} @@ -100,12 +100,12 @@ The program includes the header file \F{SDL\_bgi.h}, which contains all necessary definitions. The call to \func{initgraph()} opens a -graphics window; from now on, graphics functions may be called. +window; from now on, graphics functions may be called. \func{closegraph()} closes the window. -Within the graphics window, pixel coordinates range from (0, 0), the -upper left corner, to (\func{getmaxx()}, \func{getmaxy()}), the lower -right corner. +Within the window, pixel coordinates range from (0, 0), the upper left +corner, to (\func{getmaxx()}, \func{getmaxy()}), the lower right +corner. Some graphic functions set the coordinates of the last drawing position, defined as CP (Current Position). At any given moment, a @@ -173,6 +173,12 @@ #define NORM_WIDTH 1 #define THICK_WIDTH 3 +#define SOLID_LINE 0 +#define DOTTED_LINE 1 +#define CENTER_LINE 2 +#define DASHED_LINE 3 +#define USERBIT_LINE 4 + #define COPY_PUT 0 #define XOR_PUT 1 #define OR_PUT 2 @@ -978,9 +984,14 @@ \end{bgi} Sets the line width and style for all lines drawn by \func{line()}, -\func{lineto()}, \func{rectangle()}, \func{drawpoly()}, etc. As of the -current release, the line style can only be \T{SOLID\_LINE}. The line -thickness can be set with \T{NORM\_WIDTH} or \T{THICK\-\_WIDTH}. +\func{lineto()}, \func{rectangle()}, \func{drawpoly()}, etc. The line +style can be \T{SOLID\_LINE}, \T{DOTTED\_LINE}, \T{CENTER\_LINE}, +\T{DASHED\_LINE}, or \T{USERBIT\_LINE}; in the latter case, the user +provides a 16-bit number (\A{upattern}) whose bits set to 1 will be +plotted as pixels. + +The line thickness can be set with \T{NORM\_WIDTH} or +\T{THICK\-\_WIDTH}. Arcs, circles, ellipses, and pieslices are not affected by \A{linestyle}, but are affected by \A{thickness}. @@ -1335,3 +1346,5 @@ % ----- \end{document} + +% ----- end of file sdl_bgi-quickref.tex diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/doc/using.txt new/SDL_bgi-2.0.1/doc/using.txt --- old/SDL_bgi-2.0.0/doc/using.txt 2015-05-07 10:42:45.000000000 +0200 +++ new/SDL_bgi-2.0.1/doc/using.txt 2015-05-11 13:49:17.000000000 +0200 @@ -2,10 +2,9 @@ ============= -First of all: unlike other BGI-compatible libraries, the main purpose -of SDL_bgi is not to provide a drop-in replacement for old Borland -BGI. While compatibility with old BGI is important, a few minor -differences were introduced to take advantage of modern SDL graphics. +Although SDL_bgi is highly compatible with the original BGI library, a +few minor differences were introduced to take advantage of modern SDL +graphics. You don't want a slow library! Compiling programs @@ -22,10 +21,12 @@ but you could also do: - sudo ln -s /usr/include/SDL2/SDL_bgi.h /usr/include/graphics.h + $ sudo ln -s /usr/include/SDL2/SDL_bgi.h /usr/include/graphics.h which lets you leave old programs untouched - unless they also include -dos.h and conio.h, which you'll have to remove or replace. +dos.h and conio.h, which you'll have to remove or replace. The link +graphics.h must be created manually, since other software packages +provide it (e.g. Allegro, wx, and others). Then, to compile a program: @@ -37,7 +38,7 @@ int gd = DETECT, gm; initgraph (&gd, &gm, ""); -will open an 800x600 window (mimicking SVGA graphics). To specify the +will open an 800x600 window, mimicking SVGA graphics. To specify the window size, you can use the new SDL driver: gd = SDL; @@ -45,13 +46,13 @@ where <mode> can be one of the following: - X11_640x480 640x480 - X11_800x600 800x600 - X11_1024x768 1024x768 - X11_1152x900 1152x900 - X11_1280x1024 1280x1024 - X11_1366x768 1366x768 - X11_FULLSCREEN full screen + SDL_640x480 640x480 + SDL_800x600 800x600 + SDL_1024x768 1024x768 + SDL_1152x900 1152x900 + SDL_1280x1024 1280x1024 + SDL_1366x768 1366x768 + SDL_FULLSCREEN full screen You may want to use initwindow (int width, int height) instead. @@ -84,20 +85,18 @@ - The following functions are present but not implemented (i.e. they may be called but do nothing): - _graphfreemem - unneeded; not used by floodfill() - _graphgetmem - unneeded; not used by floodfill() + _graphfreemem - unneeded + _graphgetmem - unneeded getfillpattern installuserdriver - it makes no sense in SDL installuserfont registerbgidriver - it makes no sense in SDL registerbgifont - it makes no sense in SDL - restorecrtmode - it just clears the window setfillpattern setgraphbufsize - unneeded; not used by floodfill() - setgraphmode - it just returns to the previous window - setlinestyle - only sets thickness -- floodfill () only uses SOLID_FILL. +- floodfill () only uses SOLID_FILL. Fill patterns will be soon +implemented. - setpalette() only affects future drawing. That is, you can't get a "rotating palette animation" as in Turbo C. @@ -108,6 +107,11 @@ - fillpoly () only works correctly when the polygon is convex. +- kbhit () (provided by conio.h in Turbo C/Borland C++) returns 1 when +any key is pressed, including Shift, Ctrl, etc. + +- Key presses may not be detected during a delay (). + Additions --------- @@ -118,7 +122,7 @@ - void initwindow (int width, int height) lets you open a window specifying its size. -- void detectgraph(int *gd, int *gm) detects X11, X11_FULLSCREEN. +- void detectgraph(int *gd, int *gm) returns SDL, SDL_FULLSCREEN. - void setrgbpalette (int color, int r, int g, int b) sets an additional palette containing RGB colours (up to MAXRGBCOLORS + 1). @@ -149,9 +153,6 @@ - random (range) is defined as macro: rand()%range -- int kbhit (), provided by conio.h in Turbo C/Borland C++, returns 1 -when any key is pressed, including Shift, Alt, and so on. - - int getch () waits for a key and returns its ASCII code. Special keys are also reported; please see SDL_bgi.h. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/sdl_bgi.spec new/SDL_bgi-2.0.1/sdl_bgi.spec --- old/SDL_bgi-2.0.0/sdl_bgi.spec 2015-05-07 11:00:57.000000000 +0200 +++ new/SDL_bgi-2.0.1/sdl_bgi.spec 2015-05-12 08:17:51.000000000 +0200 @@ -1,6 +1,6 @@ Summary: BGI-compatible 2D graphics C library Name: SDL_bgi -Version: 2.0.0 +Version: 2.0.1 Release: 1 License: ZLib Group: Libraries @@ -14,7 +14,7 @@ This package contains a Borland Graphics Interface (BGI) emulation library based on SDL2. This library strictly emulates most BGI functions, making it possible to compile SDL versions of programs -written for Turbo/Borland C. RGB extensions and basic mouse support +written for Turbo/Borland C. ARGB extensions and basic mouse support are also implemented. %prep @@ -45,7 +45,9 @@ fi %%postun -echo "Warning - /usr/include/graphics.h not deleted." +if [ -r /usr/include/graphics.h ]; then + echo "Warning - /usr/include/graphics.h not deleted." +fi %files %defattr(644,root,root,755) @@ -55,6 +57,9 @@ %attr(644,root,root) %{_includedir}/SDL2/* %changelog +* Tue May 12 2015 Guido Gonzato <guido.gonzato at gmail.com> +Version 2.0.1. + * Thu Apr 30 2015 Guido Gonzato <guido.gonzato at gmail.com> Version 2.0. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/SDL_bgi.c new/SDL_bgi-2.0.1/src/SDL_bgi.c --- old/SDL_bgi-2.0.0/src/SDL_bgi.c 2015-05-07 10:28:36.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/SDL_bgi.c 2015-05-12 08:21:10.000000000 +0200 @@ -2,15 +2,14 @@ // A BGI (Borland Graphics Library) implementation based on SDL2. // Easy to use, and useful for porting old programs. -// Guido Gonzato, May 2015. +// Guido Gonzato PhD, May 2015. #include <math.h> #include "SDL_bgi.h" #include "SDL_bgi_font.h" -#define VERSION 2.0.0 - -// stuff gets drawn here +// stuff gets drawn here; these variables +// are available to the programmer. SDL_Window *bgi_window; SDL_Renderer *bgi_renderer; @@ -46,6 +45,14 @@ 0xffffffff // WHITE }; +static Uint16 + line_patterns[1 + USERBIT_LINE] = + {0xffff, // SOLID_LINE = 1111111111111111 + 0xcccc, // DOTTED_LINE = 1100110011001100 + 0xf1f8, // CENTER_LINE = 1111000111111000 + 0xf8f8, // DASHED_LINE = 1111100011111000 + 0xffff}; // USERBIT_LINE + static Uint32 bgi_tmp_color_argb; // temporary color set up by COLOR() @@ -60,7 +67,7 @@ bgi_fast_mode = 1, // needs screen update? bgi_cp_x = 0, // current position bgi_cp_y = 0, - bgi_maxx, // screen dimensions + bgi_maxx, // screen size bgi_maxy, bgi_gm, // graphics mode bgi_argb_mode = 0, // BGI or ARGB colors @@ -73,7 +80,7 @@ bgi_font_mag_x = 1.0, // font magnification bgi_font_mag_y = 1.0; -// pointer to font array. Add fonts? +// pointer to font array. Should I add more (ugly) bitmap fonts? static const Uint8 *fontptr = gfxPrimitivesFontdata; static struct arccoordstype last_arc; @@ -102,23 +109,34 @@ static void line_fast (int, int, int, int); static void updaterect (int, int, int, int); +static void unimplemented (char *); +static int is_in_range (int, int, int); static void swap_if_greater (int *, int *); +static void circle_bresenham (int, int, int); static int octant (int, int); // ----- -void unimplemented (char *msg) +static void unimplemented (char *msg) { fprintf (stderr, "%s() is not yet implemented.\n", msg); } // ----- +static int is_in_range (x, x1, x2) +{ + return (x >= x1 && x <= x2); +} + +// ----- + #define PI_CONV (3.1415926 / 180.0) void arc (int x, int y, int stangle, int endangle, int radius) { // quick and dirty for now, Bresenham-based later (maybe) + int angle; if (0 == radius) @@ -218,12 +236,46 @@ // ----- +static void circle_bresenham (int x, int y, int radius) +{ + // adapted from: + // http://members.chello.at/easyfilter/bresenham.html + + int + xx = -radius, + yy = 0, + err = 2 - 2*radius; + + do { + _putpixel (x - xx, y + yy); // I quadrant + _putpixel (x - yy, y - xx); // II quadrant + _putpixel (x + xx, y - yy); // III quadrant + _putpixel (x + yy, y + xx); // IV quadrant + radius = err; + + if (radius <= yy) + err += ++yy*2 + 1; + + if (radius > xx || err > yy) + err += ++xx*2 + 1; + + } while (xx < 0); + + if (! bgi_fast_mode) + refresh (); + +} // circle_bresenham (); + +// ----- + void circle (int x, int y, int radius) { - // a Bresenham approach would be better, but let's use the basic - // algorithm for BGI compatibility (line thickness) + // the Bresenham algorithm draws a better-looking circle - arc (x, y, 0, 360, radius); + if (NORM_WIDTH == line_style.thickness) + circle_bresenham (x, y, radius); + else + arc (x, y, 0, 360, radius); } // circle (); @@ -267,8 +319,12 @@ { int page; + // free memory for (page = 0; page < bgi_np; page++) free (bgi_vpage[page]); + + SDL_DestroyTexture (bgi_texture); + SDL_DestroyRenderer (bgi_renderer); SDL_DestroyWindow (bgi_window); SDL_Quit (); @@ -319,7 +375,7 @@ // ----- -void swap_if_greater (int *x1, int *x2) +static void swap_if_greater (int *x1, int *x2) { int tmp; @@ -333,16 +389,6 @@ // ----- -#if 0 -int is_in_range (x, x1, x2) -{ - swap_if_greater (&x1, &x2); - return ( x >= x1 && x <= x2); -} -#endif - -// ----- - void ellipse (int x, int y, int stangle, int endangle, int xradius, int yradius) { @@ -499,32 +545,54 @@ // ----- +// Next to come, fill patterns. +// These are setfillpattern-compatible arrays for the tiling patterns. +// Taken from TurboC, http://www.sandroid.org/TurboC/ + +static const Uint8 fill_styles[1 + USER_FILL][8] = { + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // EMPTY_FILL + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // SOLID_FILL + {0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00}, // LINE_FILL + {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, // LTSLASH_FILL + {0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x81}, // SLASH_FILL + {0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x81}, // BKSLASH_FILL + {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}, // LTBKSLASH_FILL + {0x22, 0x22, 0xff, 0x22, 0x22, 0x22, 0xff, 0x22}, // HATCH_FILL + {0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81}, // XHATCH_FILL + {0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44}, // INTERLEAVE_FILL + {0x10, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x00}, // WIDE_DOT_FILL + {0x11, 0x00, 0x44, 0x00, 0x11, 0x00, 0x44, 0x00}, // CLOSE_DOT_FILL + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} // USER_FILL +}; + // the following code is adapted from "A Seed Fill Algorithm" // by Paul Heckbert, "Graphics Gems", Academic Press, 1990 +// Filled horizontal segment of scanline y for xl<=x<=xr. +// Parent segment was on line y-dy. dy=1 or -1 + typedef struct { int y, xl, xr, dy; } Segment; -/* - * Filled horizontal segment of scanline y for xl<=x<=xr. - * Parent segment was on line y-dy. dy=1 or -1 - */ - -#define STACKSIZE 2000 /* max depth of stack */ - -#define PUSH(Y, XL, XR, DY) /* push new segment on stack */ \ - if (sp < stack+STACKSIZE && Y+(DY) >= 0 && Y+(DY) <= bgi_maxy ) \ - {sp->y = Y; sp->xl = XL; sp->xr = XR; sp->dy = DY; sp++;} - -#define POP(Y, XL, XR, DY) /* pop segment off stack */ \ - {sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;} - -/* - * fill: set the pixel at (x,y) and all of its 4-connected neighbors - * with the same pixel value to the new pixel value nv. - * A 4-connected neighbor is a pixel above, below, left, or right of a pixel. - */ +// max depth of stack - was 10000 + +#define STACKSIZE 2000 + +// push new segment on stack + +#define PUSH(Y, XL, XR, DY) \ + if (sp < stack+STACKSIZE && Y+(DY) >= 0 && Y+(DY) <= vp.bottom - vp.top ) \ + { sp->y = Y; sp->xl = XL; sp->xr = XR; sp->dy = DY; sp++; } + +// pop segment off stack + +#define POP(Y, XL, XR, DY) \ + { sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;} + +// fill: set the pixel at (x,y) and all of its 4-connected neighbors +// with the same pixel value to the new pixel value nv. +// A 4-connected neighbor is a pixel above, below, left, or right of a pixel. void floodfill (int x, int y, int border) { @@ -532,44 +600,48 @@ unsigned long oc, nc, b; // border pixel value Segment stack[STACKSIZE], *sp = stack; // stack of filled segments - x += vp.left; - y += vp.top; - oc = getpixel (x, y); - b = border; // vga_palette[border].pixel_value; - nc = getcolor (); // vga_palette[getcolor()].pixel_value; - if (oc == b || oc == nc) + b = border; + nc = bgi_fg_color; + if (oc == b || oc == nc || + x < 0 || x > vp.right - vp.left || // out of viewport/window? + y < 0 || y > vp.bottom - vp.top) return; - PUSH(y, x, x, 1); /* needed in some cases */ - PUSH(y + 1, x, x, -1); /* seed segment (popped 1st) */ + PUSH(y, x, x, 1); // needed in some cases + PUSH(y + 1, x, x, -1); // seed segment (popped 1st) while (sp > stack) { - /* pop segment off stack and fill a neighboring scan line */ + + // pop segment off stack and fill a neighboring scan line + POP(y, x1, x2, dy); - /* segment of scan line y-dy for x1<=x<=x2 was previously filled, - now explore adjacent pixels in scan line y - */ + + // segment of scan line y-dy for x1<=x<=x2 was previously filled, + // now explore adjacent pixels in scan line y + for (x = x1; x >= 0 && getpixel(x, y) == oc; x--) _putpixel(x, y); + if (x >= x1) { for (x++; x <= x2 && getpixel(x, y) == b; x++) ; start = x; if (x > x2) continue; - } else { + } + else { start = x + 1; if (start < x1) - PUSH(y, start, x1 - 1, -dy); /* leak on left? */ - x = x1 + 1; + PUSH(y, start, x1 - 1, -dy); // leak on left? + x = x1 + 1; } do { - for (x1 = x; x <= bgi_maxx && getpixel(x, y) != b; x++) + for (x1 = x; x <= vp.right && getpixel(x, y) != b; x++) _putpixel(x, y); PUSH(y, start, x - 1, dy); if (x > x2 + 1) - PUSH(y, x2 + 1, x - 1, -dy); /* leak on right? */ + PUSH(y, x2 + 1, x - 1, -dy); // leak on right? for (x++; x <= x2 && getpixel(x, y) == b; x++) ; start = x; @@ -689,8 +761,9 @@ void getfillsettings (struct fillsettingstype *fillinfo) { + // for now fillinfo->pattern = SOLID_FILL; - fillinfo->color = WHITE; + fillinfo->color = bgi_fill_color; } // getfillsettings () // ----- @@ -726,9 +799,9 @@ void getlinesettings (struct linesettingstype *lineinfo) { - lineinfo->linestyle = SOLID_LINE; // !!! for now - lineinfo->upattern = 1; - lineinfo->thickness = 1; + lineinfo->linestyle = line_style.linestyle; + lineinfo->upattern = line_style.upattern; + lineinfo->thickness = line_style.thickness; } // getlinesettings (); // ----- @@ -848,7 +921,7 @@ // ----- -Uint32 getpixel_raw (int x, int y) +static Uint32 getpixel_raw (int x, int y) { return bgi_activepage [y * (bgi_maxx + 1) + x]; } // getpixel_raw () @@ -863,13 +936,22 @@ x += vp.left; y += vp.top; + // out of screen? + if (! is_in_range (x, 0, bgi_maxx) && + ! is_in_range (y, 0, bgi_maxy)) + return bgi_bg_color; + tmp = getpixel_raw (x, y); + // now find the colour + for (col = BLACK; col < WHITE + 1; col++) if (tmp == palette[col]) return col; + // if it's not a BGI color, just return the 0xAARRGGBB value return tmp; + } // getpixel () // ----- @@ -1180,12 +1262,28 @@ void line_copy (int x1, int y1, int x2, int y2) { - int dx = abs (x2 - x1), sx = x1 < x2 ? 1 : -1; - int dy = abs (y2 - y1), sy = y1 < y2 ? 1 : -1; - int err = (dx > dy ? dx : -dy) / 2, e2; + int + counter = 0, // # of pixel plotted + dx = abs (x2 - x1), + sx = x1 < x2 ? 1 : -1, + dy = abs (y2 - y1), + sy = y1 < y2 ? 1 : -1, + err = (dx > dy ? dx : -dy) / 2, + e2; for (;;) { - putpixel_copy (x1, y1, palette[bgi_fg_color]); + + // plot the pixel only if the corresponding bit + // in the current pattern is set to 1 + + if (SOLID_LINE == line_style.linestyle) + putpixel_copy (x1, y1, palette[bgi_fg_color]); + else + if ((line_patterns[line_style.linestyle] >> counter % 16) & 1) + putpixel_copy (x1, y1, palette[bgi_fg_color]); + + counter++; + if (x1 == x2 && y1 == y2) break; e2 = err; @@ -1205,12 +1303,25 @@ void line_xor (int x1, int y1, int x2, int y2) { - int dx = abs (x2 - x1), sx = x1 < x2 ? 1 : -1; - int dy = abs (y2 - y1), sy = y1 < y2 ? 1 : -1; - int err = (dx > dy ? dx : -dy) / 2, e2; + int + counter = 0, // # of pixel plotted + dx = abs (x2 - x1), + sx = x1 < x2 ? 1 : -1, + dy = abs (y2 - y1), + sy = y1 < y2 ? 1 : -1, + err = (dx > dy ? dx : -dy) / 2, + e2; for (;;) { - putpixel_xor (x1, y1, palette[bgi_fg_color]); + + if (SOLID_LINE == line_style.linestyle) + putpixel_xor (x1, y1, palette[bgi_fg_color]); + else + if ((line_patterns[line_style.linestyle] >> counter % 16) & 1) + putpixel_xor (x1, y1, palette[bgi_fg_color]); + + counter++; + if (x1 == x2 && y1 == y2) break; e2 = err; @@ -1230,12 +1341,25 @@ void line_and (int x1, int y1, int x2, int y2) { - int dx = abs (x2 - x1), sx = x1 < x2 ? 1 : -1; - int dy = abs (y2 - y1), sy = y1 < y2 ? 1 : -1; - int err = (dx > dy ? dx : -dy) / 2, e2; + int + counter = 0, // # of pixel plotted + dx = abs (x2 - x1), + sx = x1 < x2 ? 1 : -1, + dy = abs (y2 - y1), + sy = y1 < y2 ? 1 : -1, + err = (dx > dy ? dx : -dy) / 2, + e2; for (;;) { - putpixel_and (x1, y1, palette[bgi_fg_color]); + + if (SOLID_LINE == line_style.linestyle) + putpixel_and (x1, y1, palette[bgi_fg_color]); + else + if ((line_patterns[line_style.linestyle] >> counter % 16) & 1) + putpixel_and (x1, y1, palette[bgi_fg_color]); + + counter++; + if (x1 == x2 && y1 == y2) break; e2 = err; @@ -1255,12 +1379,25 @@ void line_or (int x1, int y1, int x2, int y2) { - int dx = abs (x2 - x1), sx = x1 < x2 ? 1 : -1; - int dy = abs (y2 - y1), sy = y1 < y2 ? 1 : -1; - int err = (dx > dy ? dx : -dy) / 2, e2; + int + counter = 0, // # of pixel plotted + dx = abs (x2 - x1), + sx = x1 < x2 ? 1 : -1, + dy = abs (y2 - y1), + sy = y1 < y2 ? 1 : -1, + err = (dx > dy ? dx : -dy) / 2, + e2; for (;;) { - putpixel_or (x1, y1, palette[bgi_fg_color]); + + if (SOLID_LINE == line_style.linestyle) + putpixel_or (x1, y1, palette[bgi_fg_color]); + else + if ((line_patterns[line_style.linestyle] >> counter % 16) & 1) + putpixel_or (x1, y1, palette[bgi_fg_color]); + + counter++; + if (x1 == x2 && y1 == y2) break; e2 = err; @@ -1280,12 +1417,25 @@ void line_not (int x1, int y1, int x2, int y2) { - int dx = abs (x2 - x1), sx = x1 < x2 ? 1 : -1; - int dy = abs (y2 - y1), sy = y1 < y2 ? 1 : -1; - int err = (dx > dy ? dx : -dy) / 2, e2; + int + counter = 0, // # of pixel plotted + dx = abs (x2 - x1), + sx = x1 < x2 ? 1 : -1, + dy = abs (y2 - y1), + sy = y1 < y2 ? 1 : -1, + err = (dx > dy ? dx : -dy) / 2, + e2; for (;;) { - putpixel_not (x1, y1, palette[bgi_fg_color]); + + if (SOLID_LINE == line_style.linestyle) + putpixel_not (x1, y1, palette[bgi_fg_color]); + else + if ((line_patterns[line_style.linestyle] >> counter % 16) & 1) + putpixel_not (x1, y1, palette[bgi_fg_color]); + + counter++; + if (x1 == x2 && y1 == y2) break; e2 = err; @@ -1534,14 +1684,14 @@ int mousex (void) { - return bgi_mouse_x; + return bgi_mouse_x - vp.left; } // mousex () // ----- int mousey (void) { - return bgi_mouse_y; + return bgi_mouse_y - vp.top; } // mousey () // ----- @@ -1837,12 +1987,42 @@ { // plain putpixel - no logical operations + // out of range? if (x < 0 || x > bgi_maxx || y < 0 || y > bgi_maxy) return; + /* + // out of range? Plot it anyway (for floodfill()) + if (x < 0) + x = 0; + if (x > bgi_maxx) + x = bgi_maxx; + if (y < 0) + y = 0; + if (y > bgi_maxy) + y = bgi_maxy; + */ + + // the following will make floodfill () very angry: + if (1 == vp.clip) if (x < vp.left || x > vp.right || y < vp.top || y > vp.bottom) return; + + // same hack for floodfill () + + /* + if (1 == vp.clip) { + if (x < vp.left) + x = vp.left; + if (x > vp.right) + x = vp.right; + if (y < vp.top) + y = vp.top; + if (y > vp.bottom) + y = vp.bottom; + } + */ bgi_activepage [y * (bgi_maxx + 1) + x] = pixel; @@ -1854,9 +2034,10 @@ { // XOR'ed putpixel + // out of range? if (x < 0 || x > bgi_maxx || y < 0 || y > bgi_maxy) return; - + if (1 == vp.clip) if (x < vp.left || x > vp.right || y < vp.top || y > vp.bottom) return; @@ -1870,10 +2051,11 @@ void putpixel_and (int x, int y, Uint32 pixel) { // AND-ed putpixel - + + // out of range? if (x < 0 || x > bgi_maxx || y < 0 || y > bgi_maxy) return; - + if (1 == vp.clip) if (x < vp.left || x > vp.right || y < vp.top || y > vp.bottom) return; @@ -1888,6 +2070,7 @@ { // OR-ed putpixel + // out of range? if (x < 0 || x > bgi_maxx || y < 0 || y > bgi_maxy) return; @@ -1905,6 +2088,7 @@ { // NOT-ed putpixel + // out of range? if (x < 0 || x > bgi_maxx || y < 0 || y > bgi_maxy) return; @@ -1915,6 +2099,7 @@ // !!!BUG??? bgi_activepage [y * (bgi_maxx + 1) + x] = ~ bgi_activepage [y * (bgi_maxx + 1) + x]; + } // putpixel_not () // ----- @@ -2072,7 +2257,7 @@ // ----- -void bgislow (void) +void sdlbgislow (void) { bgi_fast_mode = 0; } // sdlbgislow () @@ -2254,10 +2439,9 @@ void setlinestyle (int linestyle, unsigned upattern, int thickness) { - // other settings are not implemented - // line_style.linestyle = linestyle; - // line_style.upattern = upattern; - + + line_style.linestyle = linestyle; + line_patterns[USERBIT_LINE] = line_style.upattern = upattern; line_style.thickness = thickness; } // setlinestyle () @@ -2319,15 +2503,15 @@ { if (left < 0 || right > bgi_maxx || top < 0 || bottom > bgi_maxy) return; - + vp.left = left; vp.top = top; vp.right = right; vp.bottom = bottom; vp.clip = clip; - bgi_cp_x = 0; bgi_cp_y = 0; + } // setviewport () // ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/SDL_bgi.h new/SDL_bgi-2.0.1/src/SDL_bgi.h --- old/SDL_bgi-2.0.0/src/SDL_bgi.h 2015-05-07 09:50:45.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/SDL_bgi.h 2015-05-12 08:07:27.000000000 +0200 @@ -2,10 +2,12 @@ // A BGI-like graphics library based on SDL2. // Easy to use and useful for porting old programs. -// Guido Gonzato, April 2015. +// Guido Gonzato PhD, May 2015. #include <SDL2/SDL.h> +#define SDL_BGI_VERSION 2.0.1 + // everything gets drawn here extern SDL_Window *bgi_window; @@ -172,6 +174,29 @@ #define SDL_USER 11 #define SDL_FULLSCREEN 12 +// libXbgi compatibility + +#define X11_CGALO SDL_CGALO +#define X11_CGAHI SDL_CGAHI +#define X11_EGA SDL_EGA +#define X11 SDL +#define X11_VGA SDL_VGA +#define X11_640x480 SDL_640x480 +#define X11_HERC SDL_HERC +#define X11_PC3270 SDL_PC3270 +#define X11_SVGALO SDL_SVGALO +#define X11_800x600 SDL_800x600 +#define X11_SVGAMED1 SDL_SVGAMED1 +#define X11_1024x768 SDL_1024x768 +#define X11_SVGAMED2 SDL_SVGAMED2 +#define X11_1152x900 SDL_1152x900 +#define X11_SVGAHI SDL_SVGAHI +#define X11_1280x1024 SDL_1280x1024 +#define X11_WXGA SDL_WXGA +#define X11_1366x768 SDL_1366x768 +#define X11_USER SDL_USER +#define X11_FULLSCREEN SDL_FULLSCREEN + // structs struct arccoordstype { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/test/README new/SDL_bgi-2.0.1/src/test/README --- old/SDL_bgi-2.0.0/src/test/README 2015-05-07 10:31:58.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/test/README 2015-05-11 22:04:41.000000000 +0200 @@ -4,40 +4,39 @@ By Guido Gonzato, PhD -1. 'cellular.c' is a cellular automaton program. For more information, +- 'cellular.c' is a cellular automaton program. For more information, please see http://mathworld.wolfram.com/CellularAutomaton.html -2. 'dla.c' is a diffusion limited aggregation program; please see +- 'dla.c' is a diffusion limited aggregation program; please see http://en.wikipedia.org/wiki/Diffusion-limited_aggregation -3. 'fern' is a famous IFS system; please see +- 'fern' is a famous IFS system; please see http://en.wikipedia.org/wiki/Iterated_function_system -4. 'floodfilltest.c' demonstrates the speed of the new floodfill() -routine. +- 'floodfilltest.c' shows the speed of the new floodfill() routine. -5. 'hopalong' is an implementation of Barry Martin's algorithm, +- 'hopalong' is an implementation of Barry Martin's algorithm, presented in the September 1986 issue of Scientific American. Run it as ./hopalong <seed>, where <seed> is an integer number. -6. 'life.c' is an implementation of Conway's Game of Life. Run it as +- 'life.c' is an implementation of Conway's Game of Life. Run it as ./life [number], where [number] is the percentage of living cells. -7. 'mandelbrot.c' is a simple, non-optimised program to display the +- 'mandelbrot.c' is a simple, non-optimised program to display the Mandelbrot set. It shows how to setup and use RGB colour mode. Press '1', '2', '3' to change the palette; left click to zoom in on a point; right click to zoom out; middle click to restore the initial boundary. -8. 'mousetest.c' shows how to detect and use mouse clicks. Click +- 'mousetest.c' shows how to detect and use mouse clicks. Click around using all buttons and mouse wheel. -9. 'moveit.c' shows how to use movement keys. +- 'moveit.c' shows how to use movement keys. -10. 'sdlbgidemo' shows how to use some of SDL_bgi's features. +- 'sdlbgidemo' shows how to use some of SDL_bgi's features. -11. 'simple.c' displays simple shapes to test SDL_bgi's speed. +- 'simple.c' displays simple shapes to test SDL_bgi's speed. -12. 'turtledemo.c' uses a simple yet powerful turtle graphics +- 'turtledemo.c' uses a simple yet powerful turtle graphics implementation to draw fractals and simple shapes. Besides, 'f90_test' shows how to use SDL_bgi in Fortran programs. @@ -57,23 +56,23 @@ Commands available are: -void back (int); move the turtle backwards by <int> pixels -void forwd (int); move the turtle forwards by <int> pixels -int heading (void); get the turtle heading (0-359) -void hideturtle (void); hide the turtle -void home (void); move the turtle to the screen centre - and set the heading to 0 -void pendown (void); activate drawing (put the pen down) -void penup (void); suspend drawing (lift the pen) -void setheading (int); set the turtle heading to <int> (0-359) -void setposition (int, int); move the turtle to <x>, <y> -void showturtle (void); show the turtle -void turnleft (int); turn the turtle left by <int> degrees -void turnright (int); turn the turns right by <int> degrees -void wrap (void); wrap around the window -void nowrap (void); don't wrap around the window -int xcor (void); get the turtle's X coordinate -int ycor (void); get the turtle's Y coordinate +void back (int); moves the turtle backwards by <int> pixels +void forwd (int); moves the turtle forwards by <int> pixels +int heading (void); gets the turtle heading (0-359) +void hideturtle (void); hides the turtle +void home (void); moves the turtle to the screen centre + and sest the heading to 0 +void pendown (void); activates drawing (put the pen down) +void penup (void); suspends drawing (lift the pen) +void setheading (int); sets the turtle heading to <int> (0-359) +void setposition (int, int); moves the turtle to <x>, <y> +void showturtle (void); shows the turtle +void turnleft (int); turns the turtle left by <int> degrees +void turnright (int); turns the turns right by <int> degrees +void wrap (void); wraps around the window +void nowrap (void); stops wrapping around the window +int xcor (void); gets the turtle's X coordinate +int ycor (void); gets the turtle's Y coordinate By default, the turtle is not visible, the pen is down, and the heading is 0. @@ -88,4 +87,3 @@ T_WEST 270 Please read turtle.h for more details. - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/test/mandelbrot.c new/SDL_bgi-2.0.1/src/test/mandelbrot.c --- old/SDL_bgi-2.0.0/src/test/mandelbrot.c 2015-05-06 18:02:40.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/test/mandelbrot.c 2015-05-11 19:27:53.000000000 +0200 @@ -224,6 +224,7 @@ sprintf (s, "%d", max_iter); outtextxy (0, 0, s); flag = 0; + refresh (); } redraw = 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/test/mousetest.c new/SDL_bgi-2.0.1/src/test/mousetest.c --- old/SDL_bgi-2.0.0/src/test/mousetest.c 2015-05-06 17:51:51.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/test/mousetest.c 2015-05-07 13:45:46.000000000 +0200 @@ -39,14 +39,18 @@ initgraph (&gd, &gm, ""); setbkcolor (BLACK); setcolor (RED); - cleardevice (); + setviewport (10, 10, getmaxx() - 10, getmaxy() - 10, 1); + + clearviewport (); settextjustify (CENTER_TEXT, CENTER_TEXT); outtextxy (getmaxx() / 2, getmaxy () / 2, "Click the RIGHT button to begin"); + while (!ismouseclick (WM_RBUTTONDOWN)) ; getmouseclick(WM_RBUTTONDOWN, &x, &y); - cleardevice (); + clearviewport (); + rectangle (0, 0, getmaxx () - 20, getmaxy () - 20); len = strlen(s) * 8; // assumes an 8x8 font rectangle (0, 0, len, 16); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/test/sdl_bgi.mod new/SDL_bgi-2.0.1/src/test/sdl_bgi.mod --- old/SDL_bgi-2.0.0/src/test/sdl_bgi.mod 2015-05-07 08:12:10.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/test/sdl_bgi.mod 1970-01-01 01:00:00.000000000 +0100 @@ -1,64 +0,0 @@ -GFORTRAN module version '10' created from f90_test.f90 -MD5:575d173bc8bb9cfdee11c04ee6ebcbf8 -- If you edit this, you'll get what you deserve. - -(() () () () () () () () () () () () () () () () () () () () () () () () -() () ()) - -() - -() - -() - -() - -() - -(2 'close_graph' 'sdl_bgi' 'closegraph' 1 ((PROCEDURE UNKNOWN-INTENT -MODULE-PROC BODY UNKNOWN 0 0 EXTERNAL SUBROUTINE IS_BIND_C IS_C_INTEROP) -(UNKNOWN 0 0 1 0 UNKNOWN ()) 3 0 () () 0 () () () 0 0) -4 'get_ch' 'sdl_bgi' 'getch' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC -BODY UNKNOWN 0 0 EXTERNAL FUNCTION IS_BIND_C IS_C_INTEROP) (INTEGER 4 0 -1 0 INTEGER ()) 5 0 () () 4 () () () 0 0) -6 'get_pixel' 'sdl_bgi' 'getpixel' 1 ((PROCEDURE UNKNOWN-INTENT -MODULE-PROC BODY UNKNOWN 0 0 EXTERNAL FUNCTION IS_BIND_C IS_C_INTEROP) ( -INTEGER 4 0 1 0 INTEGER ()) 7 0 (8 9) () 6 () () () 0 0) -10 'init_graph' 'sdl_bgi' 'initgraph' 1 ((PROCEDURE UNKNOWN-INTENT -MODULE-PROC BODY UNKNOWN 0 0 EXTERNAL SUBROUTINE IS_BIND_C IS_C_INTEROP) -(UNKNOWN 0 0 1 0 UNKNOWN ()) 11 0 (12 13 14) () 0 () () () 0 0) -15 'out_text_xy' 'sdl_bgi' 'outtextxy' 1 ((PROCEDURE UNKNOWN-INTENT -MODULE-PROC BODY UNKNOWN 0 0 EXTERNAL SUBROUTINE IS_BIND_C IS_C_INTEROP) -(UNKNOWN 0 0 1 0 UNKNOWN ()) 16 0 (17 18 19) () 0 () () () 0 0) -20 'put_pixel' 'sdl_bgi' 'putpixel' 1 ((PROCEDURE UNKNOWN-INTENT -MODULE-PROC BODY UNKNOWN 0 0 EXTERNAL SUBROUTINE IS_BIND_C IS_C_INTEROP) -(UNKNOWN 0 0 1 0 UNKNOWN ()) 21 0 (22 23 24) () 0 () () () 0 0) -8 'x' '' '' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VALUE DUMMY) -(INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -9 'y' '' '' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VALUE DUMMY) -(INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -12 'gd' '' '' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) -(INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -13 'gm' '' '' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) -(INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -14 'pd' '' '' 11 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 -DIMENSION DUMMY) (CHARACTER 1 0 1 0 CHARACTER ((CONSTANT (INTEGER 4 0 1 -1 CHARACTER ()) 0 '1'))) 0 0 () (1 0 ASSUMED_SIZE (CONSTANT (INTEGER 4 0 -0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0) -17 'x' '' '' 16 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VALUE -DUMMY) (INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -18 'y' '' '' 16 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VALUE -DUMMY) (INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -19 'textstring' '' '' 16 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 -DIMENSION DUMMY) (CHARACTER 1 0 1 0 CHARACTER ((CONSTANT (INTEGER 4 0 1 -1 CHARACTER ()) 0 '1'))) 0 0 () (1 0 ASSUMED_SIZE (CONSTANT (INTEGER 4 0 -0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0) -22 'x' '' '' 21 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VALUE -DUMMY) (INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -23 'y' '' '' 21 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VALUE -DUMMY) (INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -24 'c' '' '' 21 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VALUE -DUMMY) (INTEGER 4 0 1 0 INTEGER ()) 0 0 () () 0 () () () 0 0) -) - -('close_graph' 0 2 'get_ch' 0 4 'get_pixel' 0 6 'init_graph' 0 10 -'out_text_xy' 0 15 'put_pixel' 0 20) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/test/sdlbgidemo.c new/SDL_bgi-2.0.1/src/test/sdlbgidemo.c --- old/SDL_bgi-2.0.0/src/test/sdlbgidemo.c 2015-05-06 17:55:09.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/test/sdlbgidemo.c 2015-05-11 22:01:00.000000000 +0200 @@ -25,7 +25,9 @@ #define PI_CONV (3.1415926 / 180.0) -int maxx, maxy; +int + maxx, maxy, + width, height; int gd, gm; @@ -91,7 +93,7 @@ { detectgraph (&gd, &gm); initgraph (&gd, &gm, ""); - bgifast (); + sdlbgifast (); maxx = getmaxx (); maxy = getmaxy (); } // initgraph () @@ -124,6 +126,8 @@ setbkcolor (COLOR (0, 0, 20)); clearviewport (); refresh (); + width = viewport.right - viewport.left + 1; + height = viewport.bottom - viewport.top + 1; } // ----- @@ -584,6 +588,57 @@ // ----- +static int is_in_range (int x, int x1, int x2) +{ + return ( x >= x1 && x <= x2); +} + +// ----- + +void floodfilldemo (void) +{ + int + i, j, + p, stop = 0; + + message ("floodfill() Demonstration (click around!)"); + mainwindow (); + + setcolor (RED); + // draw something to fill + for (j = 25; j < maxy; j += 20) + for (i = 0; i < maxx; i += 50) { + line (i, j, i + 25, j - 25); + line (i + 25, j - 25, i + 50, j); + } + refresh (); + + while (! stop) { + + if ((p = mouseclick ())) { + + if ( (WM_LBUTTONDOWN == p) && + (is_in_range (mousex (), 0, width)) && + (is_in_range (mousey (), 0, height)) ) { + setcolor (COLOR (random (255), random (255), random (255))); + floodfill (mousex (), mousey (), RED); + refresh (); + } + else + if (WM_RBUTTONDOWN == p) + stop = 1; + } + + } // while + + refresh (); + if (! stop) + get_click (); + +} // ellipsedemo () + +// ----- + void alphademo (void) { int @@ -858,7 +913,7 @@ while (! stop) { for (col = 0; col < 256; col += 5) { - setcolor (COLOR (col, 0, 0)); + setcolor (COLOR (0, col, 0)); outtextxy (xm, ym, "That's all, folks!"); refresh (); if (ismouseclick (WM_RBUTTONDOWN)) { @@ -927,7 +982,7 @@ pause (); -} // theend () +} // pagedemo () // ----- @@ -943,6 +998,7 @@ boxdemo (); circledemo (); ellipsedemo (); + floodfilldemo (); alphademo (); loadimagedemo (); putimagedemo (); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/test/simple.c new/SDL_bgi-2.0.1/src/test/simple.c --- old/SDL_bgi-2.0.0/src/test/simple.c 2015-05-06 17:56:42.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/test/simple.c 2015-05-08 08:51:23.000000000 +0200 @@ -136,14 +136,14 @@ cleardevice (); message ("Drawing in SLOW mode:"); - bgislow (); + sdlbgislow (); circles (); lines (); pixels (); message ("Drawing in FAST mode:"); - bgifast (); + sdlbgifast (); circles (); lines (); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SDL_bgi-2.0.0/src/test/test.c new/SDL_bgi-2.0.1/src/test/test.c --- old/SDL_bgi-2.0.0/src/test/test.c 2015-05-07 10:28:53.000000000 +0200 +++ new/SDL_bgi-2.0.1/src/test/test.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,27 +0,0 @@ -// do your test using this template - -#include <SDL2/SDL_bgi.h> - -int main (void) -{ - - initgraph (NULL, NULL, ""); - - setcolor (RED); - setlinestyle (0, 0, THICK_WIDTH); - circle (400, 300, 200); - getch (); - - restorecrtmode (); - puts ("Aspetta 2 secondi per tornare alla grafica: "); - delay (2000); - - setgraphmode (0); - refresh (); - - getch (); - closegraph (); - -} - -// ----- end of test.c ++++++ sdlbgi-automake.diff ++++++ --- /var/tmp/diff_new_pack.zGCdfh/_old 2015-05-30 12:33:59.000000000 +0200 +++ /var/tmp/diff_new_pack.zGCdfh/_new 2015-05-30 12:33:59.000000000 +0200 @@ -48,45 +48,6 @@ +libSDL_bgi_la_LIBADD = -lm ${sdl2_LIBS} +pkgincludedir = ${includedir}/SDL2 +pkginclude_HEADERS = SDL_bgi.h -Index: SDL_bgi-2.0.0/src/SDL_bgi.c -=================================================================== ---- SDL_bgi-2.0.0.orig/src/SDL_bgi.c -+++ SDL_bgi-2.0.0/src/SDL_bgi.c -@@ -2069,6 +2069,10 @@ void sdlbgifast (void) - { - bgi_fast_mode = 1; - } // sdlbgifast () -+void bgifast (void) -+{ -+ bgi_fast_mode = 1; -+} // sdlbgifast () - - // ----- - -@@ -2076,6 +2080,10 @@ void bgislow (void) - { - bgi_fast_mode = 0; - } // sdlbgislow () -+void sdlbgislow (void) -+{ -+ bgi_fast_mode = 0; -+} // sdlbgislow () - - // ----- - -Index: SDL_bgi-2.0.0/src/SDL_bgi.h -=================================================================== ---- SDL_bgi-2.0.0.orig/src/SDL_bgi.h -+++ SDL_bgi-2.0.0/src/SDL_bgi.h -@@ -307,6 +307,8 @@ int registerbgifont (void *); - void restorecrtmode (void); - void sdlbgifast (void); - void sdlbgislow (void); -+void bgifast (void); -+void bgislow (void); - void sector (int, int, int, int, int, int); - void setactivepage (int); - void setallpalette (struct palettetype *); Index: SDL_bgi-2.0.0/src/test/Makefile.am =================================================================== --- /dev/null