Parcourir la source

Merged revisions 6754,6929,7182,7700,7715,7742,8295,8308,8312,8320,8345,8353,8373 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r6754 | jonas | 2007-03-09 13:35:11 +0100 (Fri, 09 Mar 2007) | 5 lines

+ big endian support for rendering .chr fonts
* explicitly use system unit versions of move and freemem, because
fpcmacosall also contains routines with these names (and that unit
is used in the upcoming Mac OS X implementation of the graph unit)

........
r6929 | daniel | 2007-03-18 23:07:37 +0100 (Sun, 18 Mar 2007) | 2 lines

+ Initial implementation of graph unit on ptc

........
r7182 | hajny | 2007-04-28 21:09:54 +0200 (Sat, 28 Apr 2007) | 1 line

* patch by Marco Borsari - saving of registers
........
r7700 | jonas | 2007-06-17 11:57:52 +0200 (Sun, 17 Jun 2007) | 19 lines

+ graph unit for Mac OS X. Note that you have to change one thing in graph
programs to use it: put the main program code in a function with signature
"function graphprog(p: pointer): longint;" and then start the program
by calling "StartGraphProgram(@graphprog);"
* compilation not yet enabled because graph needs to be moved to
packages/extra first (since this graph unit depends on packages/extra/
univint), and it's also not yet really polished (e.g. hardcoded to
640x480x256 colors)
* Something which will probably never work correctly:
* getpixel (and therefore also and/or/xorput), because you cannot
completely disable anti-aliasing in quartz. Further, the quartz api
requires floating point color component values when drawing, while
the bitmap from which we read the pixels back represents the colors
component values as bytes (which causes extra rounding errors).
Only solvable if we manually duplicate all drawing in a separate
buffer (although then you still won't erase the anti-aliasing pixels
in the real bitmap). An upside of the automatic anti-aliasing is that
all drawing looks nicer.

........
r7715 | jonas | 2007-06-17 19:15:03 +0200 (Sun, 17 Jun 2007) | 3 lines

* avoid extra locking/unlocking for updatescreen (must now always be
called while the graphdrawing lock is held)

........
r7742 | jonas | 2007-06-20 17:11:01 +0200 (Wed, 20 Jun 2007) | 2 lines

* fixed leaking of CGImage in every screen drawing operation

........
r8295 | jonas | 2007-08-21 22:04:37 +0200 (Tue, 21 Aug 2007) | 2 lines

* fixed m1024x768x32k initialisation (noted by Evgeniy Ivanov)

........
r8308 | jonas | 2007-08-25 20:49:30 +0200 (Sat, 25 Aug 2007) | 3 lines

* moved graph from packages/base to packages/extra so it can depend
on other packages such as sdl and univint

........
r8312 | jonas | 2007-08-26 13:50:53 +0200 (Sun, 26 Aug 2007) | 5 lines

+ added initial sdlgraph unit by Evgeniy Ivanov and related changes:
* also compile sdl/logger unit
+ restored sdlutils unit, since it's required for SDL_putpixel etc
* reordered graph unit in makefiles so it's compiled after sdl

........
r8320 | jonas | 2007-08-28 15:33:22 +0200 (Tue, 28 Aug 2007) | 2 lines

* fixed win32 compilation

........
r8345 | jonas | 2007-08-31 22:15:33 +0200 (Fri, 31 Aug 2007) | 4 lines

+ {$linkframework Carbon}
* managed to completely disable anti-aliasing, and mostly fixed getpixel
using least mean squares to find the closest palette entry

........
r8353 | jonas | 2007-09-02 16:57:01 +0200 (Sun, 02 Sep 2007) | 7 lines

* disabled color correction and fiddled some more with the translation
transformation, so getpixel works even better (hopefully 100% now)
* fixed usage of lineclipped when using native line drawing functions
* window was one pixel less tall than the intended resolution,
and clearviewport did not clear the entire offscreen buffer
- commented out some debugging code

........
r8373 | jonas | 2007-09-03 22:58:56 +0200 (Mon, 03 Sep 2007) | 7 lines

* set correct aspect ratios for standard vga resolutions (although they
are probably no longer correct when running in a window on a higher
resolutions, because everything's now 4:3 I guess) (mantis #5190)
* fixed aspect ratio logic for circle/ellipse (only circle gets adjusted)
(mantis #5190)
* clear window to black when initing graphics mode on Mac OS X

........

git-svn-id: branches/fixes_2_2@8450 -

peter il y a 18 ans
Parent
commit
9a4ab15fd5

+ 25 - 22
.gitattributes

@@ -777,28 +777,6 @@ packages/base/gdbint/gdbver.pp svneol=native#text/plain
 packages/base/gdbint/gdbver_nogdb.inc svneol=native#text/x-pascal
 packages/base/gdbint/symify.pp svneol=native#text/plain
 packages/base/gdbint/testgdb.pp svneol=native#text/plain
-packages/base/graph/Makefile -text
-packages/base/graph/Makefile.fpc svneol=native#text/plain
-packages/base/graph/amiga/graph.pp svneol=native#text/plain
-packages/base/graph/go32v2/graph.pp svneol=native#text/plain
-packages/base/graph/go32v2/vesa.inc svneol=native#text/plain
-packages/base/graph/go32v2/vesah.inc svneol=native#text/plain
-packages/base/graph/inc/clip.inc svneol=native#text/plain
-packages/base/graph/inc/fills.inc svneol=native#text/plain
-packages/base/graph/inc/fontdata.inc svneol=native#text/plain
-packages/base/graph/inc/graph.inc svneol=native#text/plain
-packages/base/graph/inc/graph.tex -text
-packages/base/graph/inc/graphh.inc svneol=native#text/plain
-packages/base/graph/inc/gtext.inc svneol=native#text/plain
-packages/base/graph/inc/makefile.inc svneol=native#text/plain
-packages/base/graph/inc/modes.inc svneol=native#text/plain
-packages/base/graph/inc/palette.inc svneol=native#text/plain
-packages/base/graph/unix/ggigraph.pp svneol=native#text/plain
-packages/base/graph/unix/graph.pp svneol=native#text/plain
-packages/base/graph/unix/graph16.inc svneol=native#text/plain
-packages/base/graph/win32/graph.pp svneol=native#text/plain
-packages/base/graph/win32/wincrt.pp svneol=native#text/plain
-packages/base/graph/win32/winmouse.pp svneol=native#text/plain
 packages/base/hash/Makefile svneol=native#text/plain
 packages/base/hash/Makefile.fpc svneol=native#text/plain
 packages/base/hash/crc.pas -text
@@ -2193,6 +2171,31 @@ packages/extra/gnome1/zvt/zvt/libzvt.pp svneol=native#text/plain
 packages/extra/gnome1/zvt/zvt/lists.inc svneol=native#text/plain
 packages/extra/gnome1/zvt/zvt/vt.inc svneol=native#text/plain
 packages/extra/gnome1/zvt/zvt/vtx.inc svneol=native#text/plain
+packages/extra/graph/Makefile -text
+packages/extra/graph/Makefile.fpc svneol=native#text/plain
+packages/extra/graph/amiga/graph.pp svneol=native#text/plain
+packages/extra/graph/go32v2/graph.pp svneol=native#text/plain
+packages/extra/graph/go32v2/vesa.inc svneol=native#text/plain
+packages/extra/graph/go32v2/vesah.inc svneol=native#text/plain
+packages/extra/graph/inc/clip.inc svneol=native#text/plain
+packages/extra/graph/inc/fills.inc svneol=native#text/plain
+packages/extra/graph/inc/fontdata.inc svneol=native#text/plain
+packages/extra/graph/inc/graph.inc svneol=native#text/plain
+packages/extra/graph/inc/graph.tex -text
+packages/extra/graph/inc/graphh.inc svneol=native#text/plain
+packages/extra/graph/inc/gtext.inc svneol=native#text/plain
+packages/extra/graph/inc/makefile.inc svneol=native#text/plain
+packages/extra/graph/inc/modes.inc svneol=native#text/plain
+packages/extra/graph/inc/palette.inc svneol=native#text/plain
+packages/extra/graph/macosx/graph.pp svneol=native#text/plain
+packages/extra/graph/ptcgraph.pp svneol=native#text/x-pascal
+packages/extra/graph/sdlgraph/sdlgraph.pp svneol=native#text/plain
+packages/extra/graph/unix/ggigraph.pp svneol=native#text/plain
+packages/extra/graph/unix/graph.pp svneol=native#text/plain
+packages/extra/graph/unix/graph16.inc svneol=native#text/plain
+packages/extra/graph/win32/graph.pp svneol=native#text/plain
+packages/extra/graph/win32/wincrt.pp svneol=native#text/plain
+packages/extra/graph/win32/winmouse.pp svneol=native#text/plain
 packages/extra/gtk/Makefile svneol=native#text/plain
 packages/extra/gtk/Makefile.fpc svneol=native#text/plain
 packages/extra/gtk/README -text

+ 15 - 15
.gitignore

@@ -214,21 +214,6 @@ packages/base/gdbint/*.ppu
 packages/base/gdbint/*.s
 packages/base/gdbint/fpcmade.*
 packages/base/gdbint/units
-packages/base/graph/*.bak
-packages/base/graph/*.exe
-packages/base/graph/*.o
-packages/base/graph/*.ppu
-packages/base/graph/*.s
-packages/base/graph/.gdbinit
-packages/base/graph/fpcmade.*
-packages/base/graph/inc/*.bak
-packages/base/graph/inc/*.exe
-packages/base/graph/inc/*.o
-packages/base/graph/inc/*.ppu
-packages/base/graph/inc/*.s
-packages/base/graph/inc/fpcmade.*
-packages/base/graph/inc/units
-packages/base/graph/units
 packages/base/hash/*.bak
 packages/base/hash/*.exe
 packages/base/hash/*.o
@@ -905,6 +890,21 @@ packages/extra/gnome1/zvt/zvt/*.ppu
 packages/extra/gnome1/zvt/zvt/*.s
 packages/extra/gnome1/zvt/zvt/fpcmade.*
 packages/extra/gnome1/zvt/zvt/units
+packages/extra/graph/*.bak
+packages/extra/graph/*.exe
+packages/extra/graph/*.o
+packages/extra/graph/*.ppu
+packages/extra/graph/*.s
+packages/extra/graph/.gdbinit
+packages/extra/graph/fpcmade.*
+packages/extra/graph/inc/*.bak
+packages/extra/graph/inc/*.exe
+packages/extra/graph/inc/*.o
+packages/extra/graph/inc/*.ppu
+packages/extra/graph/inc/*.s
+packages/extra/graph/inc/fpcmade.*
+packages/extra/graph/inc/units
+packages/extra/graph/units
 packages/extra/gtk/*.bak
 packages/extra/gtk/*.exe
 packages/extra/gtk/*.o

+ 44 - 72
packages/base/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/08/29]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/09/12]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-embedded
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
@@ -231,22 +231,22 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd libc
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite imagemagick dbus httpd libc
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint graph
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint mysql ibase odbc sqlite postgres oracle graph imagemagick httpd winunits
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint mysql ibase odbc sqlite postgres oracle imagemagick httpd winunits
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres odbc sqlite pthreads imagemagick
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
@@ -288,10 +288,10 @@ ifeq ($(FULL_TARGET),i386-symbian)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite imagemagick dbus httpd
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
@@ -312,7 +312,7 @@ ifeq ($(FULL_TARGET),m68k-embedded)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite imagemagick dbus httpd
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
@@ -333,7 +333,7 @@ ifeq ($(FULL_TARGET),powerpc-embedded)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite imagemagick dbus httpd
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
@@ -345,10 +345,10 @@ ifeq ($(FULL_TARGET),sparc-embedded)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd libc
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite imagemagick dbus httpd libc
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  mysql ibase odbc sqlite postgres oracle winunits
@@ -357,7 +357,7 @@ ifeq ($(FULL_TARGET),x86_64-embedded)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite imagemagick dbus httpd
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
@@ -378,7 +378,10 @@ ifeq ($(FULL_TARGET),arm-symbian)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite imagemagick dbus httpd
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
@@ -1473,7 +1476,6 @@ TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_SQLITE=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
 TARGET_DIRS_HTTPD=1
@@ -1486,7 +1488,6 @@ TARGET_DIRS_PASJPEG=1
 TARGET_DIRS_REGEXPR=1
 TARGET_DIRS_NETDB=1
 TARGET_DIRS_GDBINT=1
-TARGET_DIRS_GRAPH=1
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 TARGET_DIRS_HASH=1
@@ -1501,7 +1502,6 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_HTTPD=1
 TARGET_DIRS_WINUNITS=1
@@ -1521,7 +1521,6 @@ TARGET_DIRS_REGEXPR=1
 TARGET_DIRS_NETDB=1
 TARGET_DIRS_GDBINT=1
 TARGET_DIRS_LIBASYNC=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_MYSQL=1
 TARGET_DIRS_IBASE=1
 TARGET_DIRS_POSTGRES=1
@@ -1538,6 +1537,15 @@ TARGET_DIRS_PASZLIB=1
 TARGET_DIRS_PASJPEG=1
 TARGET_DIRS_REGEXPR=1
 TARGET_DIRS_NETDB=1
+TARGET_DIRS_GDBINT=1
+TARGET_DIRS_LIBASYNC=1
+TARGET_DIRS_MYSQL=1
+TARGET_DIRS_IBASE=1
+TARGET_DIRS_POSTGRES=1
+TARGET_DIRS_ODBC=1
+TARGET_DIRS_SQLITE=1
+TARGET_DIRS_PTHREADS=1
+TARGET_DIRS_IMAGEMAGICK=1
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 TARGET_DIRS_HASH=1
@@ -1686,7 +1694,6 @@ TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_SQLITE=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
 TARGET_DIRS_HTTPD=1
@@ -1699,7 +1706,6 @@ TARGET_DIRS_REGEXPR=1
 TARGET_DIRS_NETDB=1
 TARGET_DIRS_GDBINT=1
 TARGET_DIRS_LIBASYNC=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_MYSQL=1
 TARGET_DIRS_IBASE=1
 TARGET_DIRS_POSTGRES=1
@@ -1785,7 +1791,6 @@ TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_SQLITE=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
 TARGET_DIRS_HTTPD=1
@@ -1866,7 +1871,6 @@ TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_SQLITE=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
 TARGET_DIRS_HTTPD=1
@@ -1926,7 +1930,6 @@ TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_SQLITE=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
 TARGET_DIRS_HTTPD=1
@@ -1940,7 +1943,6 @@ TARGET_DIRS_REGEXPR=1
 TARGET_DIRS_NETDB=1
 TARGET_DIRS_GDBINT=1
 TARGET_DIRS_LIBASYNC=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_MYSQL=1
 TARGET_DIRS_IBASE=1
 TARGET_DIRS_POSTGRES=1
@@ -1987,7 +1989,6 @@ TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_SQLITE=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
 TARGET_DIRS_HTTPD=1
@@ -2052,11 +2053,27 @@ TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_SQLITE=1
-TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
 TARGET_DIRS_HTTPD=1
 endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+TARGET_DIRS_HASH=1
+TARGET_DIRS_PASZLIB=1
+TARGET_DIRS_PASJPEG=1
+TARGET_DIRS_REGEXPR=1
+TARGET_DIRS_NETDB=1
+TARGET_DIRS_LIBASYNC=1
+TARGET_DIRS_MYSQL=1
+TARGET_DIRS_IBASE=1
+TARGET_DIRS_POSTGRES=1
+TARGET_DIRS_ORACLE=1
+TARGET_DIRS_ODBC=1
+TARGET_DIRS_SQLITE=1
+TARGET_DIRS_PTHREADS=1
+TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
+endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 TARGET_DIRS_HASH=1
 TARGET_DIRS_PASZLIB=1
@@ -2694,51 +2711,6 @@ sqlite:
 	$(MAKE) -C sqlite all
 .PHONY: sqlite_all sqlite_debug sqlite_smart sqlite_release sqlite_units sqlite_examples sqlite_shared sqlite_install sqlite_sourceinstall sqlite_exampleinstall sqlite_distinstall sqlite_zipinstall sqlite_zipsourceinstall sqlite_zipexampleinstall sqlite_zipdistinstall sqlite_clean sqlite_distclean sqlite_cleanall sqlite_info sqlite_makefiles sqlite
 endif
-ifdef TARGET_DIRS_GRAPH
-graph_all:
-	$(MAKE) -C graph all
-graph_debug:
-	$(MAKE) -C graph debug
-graph_smart:
-	$(MAKE) -C graph smart
-graph_release:
-	$(MAKE) -C graph release
-graph_units:
-	$(MAKE) -C graph units
-graph_examples:
-	$(MAKE) -C graph examples
-graph_shared:
-	$(MAKE) -C graph shared
-graph_install:
-	$(MAKE) -C graph install
-graph_sourceinstall:
-	$(MAKE) -C graph sourceinstall
-graph_exampleinstall:
-	$(MAKE) -C graph exampleinstall
-graph_distinstall:
-	$(MAKE) -C graph distinstall
-graph_zipinstall:
-	$(MAKE) -C graph zipinstall
-graph_zipsourceinstall:
-	$(MAKE) -C graph zipsourceinstall
-graph_zipexampleinstall:
-	$(MAKE) -C graph zipexampleinstall
-graph_zipdistinstall:
-	$(MAKE) -C graph zipdistinstall
-graph_clean:
-	$(MAKE) -C graph clean
-graph_distclean:
-	$(MAKE) -C graph distclean
-graph_cleanall:
-	$(MAKE) -C graph cleanall
-graph_info:
-	$(MAKE) -C graph info
-graph_makefiles:
-	$(MAKE) -C graph makefiles
-graph:
-	$(MAKE) -C graph all
-.PHONY: graph_all graph_debug graph_smart graph_release graph_units graph_examples graph_shared graph_install graph_sourceinstall graph_exampleinstall graph_distinstall graph_zipinstall graph_zipsourceinstall graph_zipexampleinstall graph_zipdistinstall graph_clean graph_distclean graph_cleanall graph_info graph_makefiles graph
-endif
 ifdef TARGET_DIRS_IMAGEMAGICK
 imagemagick_all:
 	$(MAKE) -C imagemagick all

+ 6 - 4
packages/base/Makefile.fpc

@@ -7,16 +7,18 @@ dirs=hash paszlib pasjpeg regexpr netdb
 dirs_i386_linux=libc
 dirs_x86_64_linux=libc
 dirs_linux=gdbint libasync mysql ibase postgres oracle odbc \
-            pthreads sqlite graph imagemagick dbus httpd
-dirs_win32=gdbint mysql ibase odbc sqlite postgres oracle graph imagemagick httpd winunits
+            pthreads sqlite imagemagick dbus httpd
+dirs_win32=gdbint mysql ibase odbc sqlite postgres oracle imagemagick httpd winunits
 dirs_win64=mysql ibase odbc sqlite postgres oracle winunits
 dirs_wince=ibase sqlite postgres
-dirs_go32v2=gdbint graph
+dirs_go32v2=gdbint
 dirs_netbsd=gdbint libasync \
             mysql ibase postgres oracle odbc imagemagick httpd
 dirs_openbsd=gdbint libasync \
             mysql ibase postgres oracle odbc imagemagick httpd
-dirs_freebsd=gdbint libasync graph \
+dirs_beos=gdbint libasync \
+             mysql ibase postgres odbc sqlite pthreads imagemagick
+dirs_freebsd=gdbint libasync \
              mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 dirs_darwin=libasync \
              mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd

+ 152 - 15
packages/extra/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/08/29]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/09/12]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-embedded
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
@@ -231,19 +231,22 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil lua
+override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil lua sdl graph
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_DIRS+=unzip
+override TARGET_DIRS+=unzip graph
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_DIRS+=unzip opengl gtk gtk2 zlib tcl cdrom fpgtk fftw mad openal oggvorbis a52 libpng openssl pcap lua lua
+override TARGET_DIRS+=unzip opengl gtk gtk2 zlib tcl cdrom fpgtk fftw graph mad openal oggvorbis a52 libpng openssl pcap lua
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 override TARGET_DIRS+=os2units rexx unzip zlib x11 gtk libpng tcl imlib fpgtk
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
+override TARGET_DIRS+=unzip zlib fftw graph x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_DIRS+=graph
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 override TARGET_DIRS+=unzip zlib x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
@@ -270,10 +273,10 @@ ifeq ($(FULL_TARGET),i386-wince)
 override TARGET_DIRS+=unzip zlib tcl fftw
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil
+override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil graph
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
+override TARGET_DIRS+=unzip zlib fftw graph x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 override TARGET_DIRS+=unzip zlib x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
@@ -288,7 +291,7 @@ ifeq ($(FULL_TARGET),m68k-palmos)
 override TARGET_DIRS+=palmunits
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil
+override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil sdl graph
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 override TARGET_DIRS+=unzip zlib x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
@@ -300,7 +303,7 @@ ifeq ($(FULL_TARGET),powerpc-darwin)
 override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl libcurl cairo univint
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil
+override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil graph
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 override TARGET_DIRS+=unzip zlib x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
@@ -309,16 +312,16 @@ ifeq ($(FULL_TARGET),sparc-solaris)
 override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil
+override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil sdl graph
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
+override TARGET_DIRS+=unzip zlib fftw graph x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl pcap libcurl cairo
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 override TARGET_DIRS+=unzip opengl gtk gtk2 zlib tcl cdrom fpgtk fftw openssl
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil
+override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil graph
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 override TARGET_DIRS+=palmunits
@@ -327,7 +330,10 @@ ifeq ($(FULL_TARGET),arm-wince)
 override TARGET_DIRS+=unzip zlib tcl fftw
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil
+override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms svgalib ggi libpng libgd utmp bfd gdbm ncurses tcl cdrom imlib gnome1 fpgtk newt uuid ldap openal mad oggvorbis a52 modplug dts openssl pcap libcurl cairo unixutil graph
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override TARGET_DIRS+=unzip zlib fftw x11 opengl gtk gtk2 syslog forms libpng libgd utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 openssl libcurl cairo
 endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCSUBDIR=packages/extra
@@ -1442,9 +1448,12 @@ TARGET_DIRS_LIBCURL=1
 TARGET_DIRS_CAIRO=1
 TARGET_DIRS_UNIXUTIL=1
 TARGET_DIRS_LUA=1
+TARGET_DIRS_SDL=1
+TARGET_DIRS_GRAPH=1
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 TARGET_DIRS_UNZIP=1
+TARGET_DIRS_GRAPH=1
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 TARGET_DIRS_UNZIP=1
@@ -1456,6 +1465,7 @@ TARGET_DIRS_TCL=1
 TARGET_DIRS_CDROM=1
 TARGET_DIRS_FPGTK=1
 TARGET_DIRS_FFTW=1
+TARGET_DIRS_GRAPH=1
 TARGET_DIRS_MAD=1
 TARGET_DIRS_OPENAL=1
 TARGET_DIRS_OGGVORBIS=1
@@ -1464,7 +1474,6 @@ TARGET_DIRS_LIBPNG=1
 TARGET_DIRS_OPENSSL=1
 TARGET_DIRS_PCAP=1
 TARGET_DIRS_LUA=1
-TARGET_DIRS_LUA=1
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 TARGET_DIRS_OS2UNITS=1
@@ -1482,6 +1491,7 @@ ifeq ($(FULL_TARGET),i386-freebsd)
 TARGET_DIRS_UNZIP=1
 TARGET_DIRS_ZLIB=1
 TARGET_DIRS_FFTW=1
+TARGET_DIRS_GRAPH=1
 TARGET_DIRS_X11=1
 TARGET_DIRS_OPENGL=1
 TARGET_DIRS_GTK=1
@@ -1505,6 +1515,9 @@ TARGET_DIRS_PCAP=1
 TARGET_DIRS_LIBCURL=1
 TARGET_DIRS_CAIRO=1
 endif
+ifeq ($(FULL_TARGET),i386-beos)
+TARGET_DIRS_GRAPH=1
+endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 TARGET_DIRS_UNZIP=1
 TARGET_DIRS_ZLIB=1
@@ -1670,11 +1683,13 @@ TARGET_DIRS_PCAP=1
 TARGET_DIRS_LIBCURL=1
 TARGET_DIRS_CAIRO=1
 TARGET_DIRS_UNIXUTIL=1
+TARGET_DIRS_GRAPH=1
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 TARGET_DIRS_UNZIP=1
 TARGET_DIRS_ZLIB=1
 TARGET_DIRS_FFTW=1
+TARGET_DIRS_GRAPH=1
 TARGET_DIRS_X11=1
 TARGET_DIRS_OPENGL=1
 TARGET_DIRS_GTK=1
@@ -1791,6 +1806,8 @@ TARGET_DIRS_PCAP=1
 TARGET_DIRS_LIBCURL=1
 TARGET_DIRS_CAIRO=1
 TARGET_DIRS_UNIXUTIL=1
+TARGET_DIRS_SDL=1
+TARGET_DIRS_GRAPH=1
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 TARGET_DIRS_UNZIP=1
@@ -1882,6 +1899,7 @@ TARGET_DIRS_PCAP=1
 TARGET_DIRS_LIBCURL=1
 TARGET_DIRS_CAIRO=1
 TARGET_DIRS_UNIXUTIL=1
+TARGET_DIRS_GRAPH=1
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 TARGET_DIRS_UNZIP=1
@@ -1972,11 +1990,14 @@ TARGET_DIRS_PCAP=1
 TARGET_DIRS_LIBCURL=1
 TARGET_DIRS_CAIRO=1
 TARGET_DIRS_UNIXUTIL=1
+TARGET_DIRS_SDL=1
+TARGET_DIRS_GRAPH=1
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 TARGET_DIRS_UNZIP=1
 TARGET_DIRS_ZLIB=1
 TARGET_DIRS_FFTW=1
+TARGET_DIRS_GRAPH=1
 TARGET_DIRS_X11=1
 TARGET_DIRS_OPENGL=1
 TARGET_DIRS_GTK=1
@@ -2049,6 +2070,7 @@ TARGET_DIRS_PCAP=1
 TARGET_DIRS_LIBCURL=1
 TARGET_DIRS_CAIRO=1
 TARGET_DIRS_UNIXUTIL=1
+TARGET_DIRS_GRAPH=1
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 TARGET_DIRS_PALMUNITS=1
@@ -2096,6 +2118,31 @@ TARGET_DIRS_PCAP=1
 TARGET_DIRS_LIBCURL=1
 TARGET_DIRS_CAIRO=1
 TARGET_DIRS_UNIXUTIL=1
+TARGET_DIRS_GRAPH=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+TARGET_DIRS_UNZIP=1
+TARGET_DIRS_ZLIB=1
+TARGET_DIRS_FFTW=1
+TARGET_DIRS_X11=1
+TARGET_DIRS_OPENGL=1
+TARGET_DIRS_GTK=1
+TARGET_DIRS_GTK2=1
+TARGET_DIRS_SYSLOG=1
+TARGET_DIRS_FORMS=1
+TARGET_DIRS_LIBPNG=1
+TARGET_DIRS_LIBGD=1
+TARGET_DIRS_UTMP=1
+TARGET_DIRS_BFD=1
+TARGET_DIRS_GDBM=1
+TARGET_DIRS_NCURSES=1
+TARGET_DIRS_FPGTK=1
+TARGET_DIRS_TCL=1
+TARGET_DIRS_IMLIB=1
+TARGET_DIRS_GNOME1=1
+TARGET_DIRS_OPENSSL=1
+TARGET_DIRS_LIBCURL=1
+TARGET_DIRS_CAIRO=1
 endif
 ifdef TARGET_DIRS_UNZIP
 unzip_all:
@@ -3762,6 +3809,96 @@ lua:
 	$(MAKE) -C lua all
 .PHONY: lua_all lua_debug lua_smart lua_release lua_units lua_examples lua_shared lua_install lua_sourceinstall lua_exampleinstall lua_distinstall lua_zipinstall lua_zipsourceinstall lua_zipexampleinstall lua_zipdistinstall lua_clean lua_distclean lua_cleanall lua_info lua_makefiles lua
 endif
+ifdef TARGET_DIRS_SDL
+sdl_all:
+	$(MAKE) -C sdl all
+sdl_debug:
+	$(MAKE) -C sdl debug
+sdl_smart:
+	$(MAKE) -C sdl smart
+sdl_release:
+	$(MAKE) -C sdl release
+sdl_units:
+	$(MAKE) -C sdl units
+sdl_examples:
+	$(MAKE) -C sdl examples
+sdl_shared:
+	$(MAKE) -C sdl shared
+sdl_install:
+	$(MAKE) -C sdl install
+sdl_sourceinstall:
+	$(MAKE) -C sdl sourceinstall
+sdl_exampleinstall:
+	$(MAKE) -C sdl exampleinstall
+sdl_distinstall:
+	$(MAKE) -C sdl distinstall
+sdl_zipinstall:
+	$(MAKE) -C sdl zipinstall
+sdl_zipsourceinstall:
+	$(MAKE) -C sdl zipsourceinstall
+sdl_zipexampleinstall:
+	$(MAKE) -C sdl zipexampleinstall
+sdl_zipdistinstall:
+	$(MAKE) -C sdl zipdistinstall
+sdl_clean:
+	$(MAKE) -C sdl clean
+sdl_distclean:
+	$(MAKE) -C sdl distclean
+sdl_cleanall:
+	$(MAKE) -C sdl cleanall
+sdl_info:
+	$(MAKE) -C sdl info
+sdl_makefiles:
+	$(MAKE) -C sdl makefiles
+sdl:
+	$(MAKE) -C sdl all
+.PHONY: sdl_all sdl_debug sdl_smart sdl_release sdl_units sdl_examples sdl_shared sdl_install sdl_sourceinstall sdl_exampleinstall sdl_distinstall sdl_zipinstall sdl_zipsourceinstall sdl_zipexampleinstall sdl_zipdistinstall sdl_clean sdl_distclean sdl_cleanall sdl_info sdl_makefiles sdl
+endif
+ifdef TARGET_DIRS_GRAPH
+graph_all:
+	$(MAKE) -C graph all
+graph_debug:
+	$(MAKE) -C graph debug
+graph_smart:
+	$(MAKE) -C graph smart
+graph_release:
+	$(MAKE) -C graph release
+graph_units:
+	$(MAKE) -C graph units
+graph_examples:
+	$(MAKE) -C graph examples
+graph_shared:
+	$(MAKE) -C graph shared
+graph_install:
+	$(MAKE) -C graph install
+graph_sourceinstall:
+	$(MAKE) -C graph sourceinstall
+graph_exampleinstall:
+	$(MAKE) -C graph exampleinstall
+graph_distinstall:
+	$(MAKE) -C graph distinstall
+graph_zipinstall:
+	$(MAKE) -C graph zipinstall
+graph_zipsourceinstall:
+	$(MAKE) -C graph zipsourceinstall
+graph_zipexampleinstall:
+	$(MAKE) -C graph zipexampleinstall
+graph_zipdistinstall:
+	$(MAKE) -C graph zipdistinstall
+graph_clean:
+	$(MAKE) -C graph clean
+graph_distclean:
+	$(MAKE) -C graph distclean
+graph_cleanall:
+	$(MAKE) -C graph cleanall
+graph_info:
+	$(MAKE) -C graph info
+graph_makefiles:
+	$(MAKE) -C graph makefiles
+graph:
+	$(MAKE) -C graph all
+.PHONY: graph_all graph_debug graph_smart graph_release graph_units graph_examples graph_shared graph_install graph_sourceinstall graph_exampleinstall graph_distinstall graph_zipinstall graph_zipsourceinstall graph_zipexampleinstall graph_zipdistinstall graph_clean graph_distclean graph_cleanall graph_info graph_makefiles graph
+endif
 ifdef TARGET_DIRS_OS2UNITS
 os2units_all:
 	$(MAKE) -C os2units all

+ 11 - 5
packages/extra/Makefile.fpc

@@ -10,14 +10,19 @@ dirs_linux=unzip zlib fftw \
            ldap openal mad oggvorbis a52 \
            modplug dts openssl pcap libcurl cairo \
            unixutil
-dirs_i386_linux=lua
-dirs_i386_win32=lua
+dirs_i386_linux=lua sdl graph
+dirs_x86_64_linux=sdl graph
+dirs_powerpc_linux=sdl graph
+dirs_powerpc64_linux=graph
+dirs_sparc_linux=graph
+dirs_arm_linux=graph
+dirs_m68k_linux=graph
 dirs_netbsd=unzip zlib \
             x11 opengl gtk syslog \
             forms svgalib ggi libpng libgd \
             utmp bfd gdbm ncurses fpgtk \
             tcl imlib gnome1 openssl pcap libcurl cairo 
-dirs_freebsd=unzip zlib fftw \
+dirs_freebsd=unzip zlib fftw graph \
              x11 opengl gtk gtk2 syslog \
              forms svgalib ggi libpng libgd \
              utmp bfd gdbm ncurses fpgtk \
@@ -28,7 +33,7 @@ dirs_openbsd=unzip zlib \
              utmp bfd gdbm ncurses fpgtk \
              tcl imlib gnome1 openssl pcap libcurl cairo 
 # libcurl should work on Win32 too, but I haven't tested this. Skip it for now. MVC.
-dirs_win32=unzip opengl gtk gtk2 zlib tcl cdrom fpgtk fftw \
+dirs_win32=unzip opengl gtk gtk2 zlib tcl cdrom fpgtk fftw graph \
              mad openal oggvorbis a52 libpng openssl pcap lua
 dirs_win64=unzip opengl gtk gtk2 zlib tcl cdrom fpgtk fftw openssl 
 dirs_wince=unzip zlib tcl fftw
@@ -46,7 +51,7 @@ dirs_emx=os2units \
          libpng \
          tcl \
          imlib fpgtk
-dirs_go32v2=unzip
+dirs_go32v2=unzip graph
 dirs_amiga=amunits
 dirs_palmos=palmunits
 dirs_netware=unzip zlib
@@ -63,6 +68,7 @@ dirs_solaris= unzip zlib fftw \
              forms svgalib ggi libpng libgd \
              utmp bfd gdbm ncurses fpgtk tcl imlib gnome1 \
              openssl pcap libcurl cairo
+dirs_beos=graph
 
 [install]
 fpcpackage=y

+ 134 - 9
packages/base/graph/Makefile → packages/extra/graph/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/08/29]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/08/22]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-embedded
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
@@ -231,7 +231,7 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 override PACKAGE_NAME=graph
-override PACKAGE_VERSION=2.2.1
+override PACKAGE_VERSION=2.1
 GRAPHDIR=inc
 UNIXINC=unix
 ifndef USELIBGGI
@@ -255,32 +255,38 @@ GRAPHUNIT_DIR=unix
 UNIXINCDEPS=$(UNIXINC)/graph16.inc
 endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT)
+override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT) sdlgraph
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 override TARGET_UNITS+=graph
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=graph wincrt winmouse
+override TARGET_UNITS+=graph wincrt winmouse sdlgraph
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=graph $(GGIGRAPH_UNIT)
+override TARGET_UNITS+=graph $(GGIGRAPH_UNIT) sdlgraph
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_UNITS+=sdlgraph
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT)
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=graph $(GGIGRAPH_UNIT)
+override TARGET_UNITS+=graph $(GGIGRAPH_UNIT) sdlgraph
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 override TARGET_UNITS+=graph
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT)
+override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT) sdlgraph
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 override TARGET_UNITS+=graph
 endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_UNITS+=sdlgraph
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT)
 endif
@@ -288,7 +294,7 @@ ifeq ($(FULL_TARGET),x86_64-linux)
 override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT)
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=graph $(GGIGRAPH_UNIT)
+override TARGET_UNITS+=graph $(GGIGRAPH_UNIT) sdlgraph
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT)
@@ -446,6 +452,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 override CLEAN_UNITS+=$(GGIGRAPH_UNIT) $(GRAPH_UNIT)
 endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override CLEAN_UNITS+=$(GGIGRAPH_UNIT) $(GRAPH_UNIT)
+endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 override CLEAN_UNITS+=$(GGIGRAPH_UNIT) $(GRAPH_UNIT)
 endif
@@ -600,6 +609,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 override COMPILER_OPTIONS+=-S2
 endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_OPTIONS+=-S2
+endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 override COMPILER_OPTIONS+=-S2
 endif
@@ -753,6 +765,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 override COMPILER_INCLUDEDIR+=$(OS_TARGET) inc  unix
 endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_INCLUDEDIR+=$(OS_TARGET) inc  unix
+endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 override COMPILER_INCLUDEDIR+=$(OS_TARGET) inc
 endif
@@ -906,6 +921,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 override COMPILER_SOURCEDIR+=$(OS_TARGET) inc
 endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_SOURCEDIR+=$(OS_TARGET) inc
+endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 override COMPILER_SOURCEDIR+=$(OS_TARGET) inc
 endif
@@ -1692,18 +1710,27 @@ endif
 override REQUIRE_PACKAGES=rtl 
 ifeq ($(FULL_TARGET),i386-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PTHREADS=1
+REQUIRE_PACKAGES_X11=1
+REQUIRE_PACKAGES_SDL=1
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 REQUIRE_PACKAGES_RTL=1
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PTHREADS=1
+REQUIRE_PACKAGES_X11=1
+REQUIRE_PACKAGES_SDL=1
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 REQUIRE_PACKAGES_RTL=1
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PTHREADS=1
+REQUIRE_PACKAGES_X11=1
+REQUIRE_PACKAGES_SDL=1
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 REQUIRE_PACKAGES_RTL=1
@@ -1728,6 +1755,9 @@ REQUIRE_PACKAGES_RTL=1
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PTHREADS=1
+REQUIRE_PACKAGES_X11=1
+REQUIRE_PACKAGES_SDL=1
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 REQUIRE_PACKAGES_RTL=1
@@ -1752,6 +1782,9 @@ REQUIRE_PACKAGES_RTL=1
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PTHREADS=1
+REQUIRE_PACKAGES_X11=1
+REQUIRE_PACKAGES_SDL=1
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 REQUIRE_PACKAGES_RTL=1
@@ -1773,6 +1806,9 @@ REQUIRE_PACKAGES_RTL=1
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PTHREADS=1
+REQUIRE_PACKAGES_X11=1
+REQUIRE_PACKAGES_SDL=1
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 REQUIRE_PACKAGES_RTL=1
@@ -1785,6 +1821,9 @@ REQUIRE_PACKAGES_RTL=1
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PTHREADS=1
+REQUIRE_PACKAGES_X11=1
+REQUIRE_PACKAGES_SDL=1
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 REQUIRE_PACKAGES_RTL=1
@@ -1809,6 +1848,9 @@ REQUIRE_PACKAGES_RTL=1
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PTHREADS=1
+REQUIRE_PACKAGES_X11=1
+REQUIRE_PACKAGES_SDL=1
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 REQUIRE_PACKAGES_RTL=1
@@ -1840,6 +1882,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 REQUIRE_PACKAGES_RTL=1
 endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 REQUIRE_PACKAGES_RTL=1
 endif
@@ -1869,6 +1914,84 @@ ifdef UNITDIR_RTL
 override COMPILER_UNITDIR+=$(UNITDIR_RTL)
 endif
 endif
+ifdef REQUIRE_PACKAGES_PTHREADS
+PACKAGEDIR_PTHREADS:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /pthreads/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_PTHREADS),)
+ifneq ($(wildcard $(PACKAGEDIR_PTHREADS)/units/$(TARGETSUFFIX)),)
+UNITDIR_PTHREADS=$(PACKAGEDIR_PTHREADS)/units/$(TARGETSUFFIX)
+else
+UNITDIR_PTHREADS=$(PACKAGEDIR_PTHREADS)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_PTHREADS)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_PTHREADS) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_PTHREADS)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_PTHREADS=
+UNITDIR_PTHREADS:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /pthreads/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_PTHREADS),)
+UNITDIR_PTHREADS:=$(firstword $(UNITDIR_PTHREADS))
+else
+UNITDIR_PTHREADS=
+endif
+endif
+ifdef UNITDIR_PTHREADS
+override COMPILER_UNITDIR+=$(UNITDIR_PTHREADS)
+endif
+endif
+ifdef REQUIRE_PACKAGES_X11
+PACKAGEDIR_X11:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /x11/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_X11),)
+ifneq ($(wildcard $(PACKAGEDIR_X11)/units/$(TARGETSUFFIX)),)
+UNITDIR_X11=$(PACKAGEDIR_X11)/units/$(TARGETSUFFIX)
+else
+UNITDIR_X11=$(PACKAGEDIR_X11)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_X11)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_X11) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_X11)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_X11=
+UNITDIR_X11:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /x11/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_X11),)
+UNITDIR_X11:=$(firstword $(UNITDIR_X11))
+else
+UNITDIR_X11=
+endif
+endif
+ifdef UNITDIR_X11
+override COMPILER_UNITDIR+=$(UNITDIR_X11)
+endif
+endif
+ifdef REQUIRE_PACKAGES_SDL
+PACKAGEDIR_SDL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /sdl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_SDL),)
+ifneq ($(wildcard $(PACKAGEDIR_SDL)/units/$(TARGETSUFFIX)),)
+UNITDIR_SDL=$(PACKAGEDIR_SDL)/units/$(TARGETSUFFIX)
+else
+UNITDIR_SDL=$(PACKAGEDIR_SDL)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_SDL)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_SDL) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_SDL)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_SDL=
+UNITDIR_SDL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /sdl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_SDL),)
+UNITDIR_SDL:=$(firstword $(UNITDIR_SDL))
+else
+UNITDIR_SDL=
+endif
+endif
+ifdef UNITDIR_SDL
+override COMPILER_UNITDIR+=$(UNITDIR_SDL)
+endif
+endif
 ifndef NOCPUDEF
 override FPCOPTDEF=$(CPU_TARGET)
 endif
@@ -2470,4 +2593,6 @@ winmouse$(PPUEXT) : win32/winmouse.pp graph$(PPUEXT)
 	$(COMPILER) win32/winmouse.pp
 wincrt$(PPUEXT) : win32/wincrt.pp graph$(PPUEXT)
 	$(COMPILER) win32/wincrt.pp
+sdlgraph$(PPUEXT) : sdlgraph/sdlgraph.pp $(GRAPHINCDEPS)
+	$(COMPILER) -I$(GRAPHDIR) sdlgraph/sdlgraph.pp
 .NOTPARALLEL:

+ 18 - 2
packages/base/graph/Makefile.fpc → packages/extra/graph/Makefile.fpc

@@ -4,14 +4,20 @@
 
 [package]
 name=graph
-version=2.2.1
+version=2.1
 
 [require]
 libc=y
+packages_linux_i386=sdl
+packages_linux_powerpc=sdl
+packages_freebsd=sdl
+packages_win32=sdl
+packages_darwin_powerpc=sdl
+packages_darwin_i386=sdl
 
 # clean package units
 [clean]
-units=$(GGIGRAPH_UNIT) $(GRAPH_UNIT)
+units=$(GGIGRAPH_UNIT) $(GRAPH_UNIT) 
 
 [target]
 dirs=
@@ -21,6 +27,12 @@ units_freebsd=graph $(GGIGRAPH_UNIT)
 units_win32=graph wincrt winmouse
 units_go32v2=graph
 units_amiga=graph
+units_i386_linux=sdlgraph
+units_powerpc_linux=sdlgraph
+units_freebsd=sdlgraph
+units_win32=sdlgraph
+units_powerpc_darwin=sdlgraph
+units_i386_darwin=sdlgraph
 
 [compiler]
 options=-S2
@@ -87,4 +99,8 @@ winmouse$(PPUEXT) : win32/winmouse.pp graph$(PPUEXT)
 wincrt$(PPUEXT) : win32/wincrt.pp graph$(PPUEXT)
         $(COMPILER) win32/wincrt.pp
 
+sdlgraph$(PPUEXT) : sdlgraph/sdlgraph.pp $(GRAPHINCDEPS)
+        $(COMPILER) -I$(GRAPHDIR) sdlgraph/sdlgraph.pp
+
 .NOTPARALLEL:
+

+ 0 - 0
packages/base/graph/amiga/graph.pp → packages/extra/graph/amiga/graph.pp


+ 207 - 88
packages/base/graph/go32v2/graph.pp → packages/extra/graph/go32v2/graph.pp

@@ -145,30 +145,26 @@ const
      inWindows: boolean;
 
 {$ifndef tp}
-  procedure seg_bytemove(sseg : word;source : longint;dseg : word;dest : longint;count : longint);
-
-    begin
-       asm
-          push edi
-          push esi
-          push es
-          push ds
-          cld
-          mov ecx,count
-          mov esi,source
-          mov edi,dest
-          mov ax,dseg
-          mov es,ax
-          mov ax,sseg
-          mov ds,ax
-          rep movsb
-          pop ds
-          pop es
-          pop esi
-          pop edi
-       end ['ECX','EAX']
-    end;
-
+  Procedure seg_bytemove(sseg : word;source : longint;dseg : word;dest : longint;count : longint); assembler;
+    asm
+      push edi
+      push esi
+      push es
+      push ds
+      cld
+      mov ecx,count
+      mov esi,source
+      mov edi,dest
+      mov ax,dseg
+      mov es,ax
+      mov ax,sseg
+      mov ds,ax
+      rep movsb
+      pop ds
+      pop es
+      pop esi
+      pop edi
+    end ['ECX','EAX'];
 {$endif tp}
 
  Procedure CallInt10(val_ax : word); assembler;
@@ -189,7 +185,7 @@ const
       pop esi
       pop ebp
 {$endif fpc}
-   end;
+   end ['EAX'];
 
  {************************************************************************}
  {*                     4-bit planar VGA mode routines                   *}
@@ -254,11 +250,8 @@ const
      PortW[$3ce] := $0001;         { Index 01 : Disable ops on all four planes.         }
 {$else asmgraph}
       asm
-        push ebx
-        push edi
  {$ifndef fpc}
         mov  es, [SegA000]
- {$endif fpc}
         { enable the set / reset function and load the color }
         mov  dx, 3ceh
         mov  ax, 0f01h
@@ -277,7 +270,6 @@ const
         mov  al, 80h
         shr  al, cl
         out  dx, ax
- {$ifndef fpc}
         { get the x index and divide by 8 for 16-color }
         mov  ax,[X]
         shr  ax,3
@@ -303,6 +295,29 @@ const
         mov  ax,0001h
         out  dx,ax
  {$else fpc}
+        push eax
+        push ebx
+        push ecx
+        push edx
+        push edi
+        { enable the set / reset function and load the color }
+        mov  dx, 3ceh
+        mov  ax, 0f01h
+        out  dx, ax
+        { setup set/reset register }
+        mov  ax, [Pixel]
+        shl  ax, 8
+        out  dx, ax
+        { setup the bit mask register }
+        mov  al, 8
+        out  dx, al
+        inc  dx
+        { load the bitmask register }
+        mov  cx, [X]
+        and  cx, 0007h
+        mov  al, 80h
+        shr  al, cl
+        out  dx, ax
         { get the x index and divide by 8 for 16-color }
         movzx eax,[X]
         shr  eax,3
@@ -327,9 +342,12 @@ const
         { restore enable set/reset register }
         mov  ax,0001h
         out  dx,ax
- {$endif fpc}
         pop edi
+        pop edx
+        pop ecx
         pop ebx
+        pop eax
+ {$endif fpc}
       end;
 {$endif asmgraph}
    end;
@@ -424,9 +442,11 @@ const
       xor   ah,ah
       mov   @Result, ax
   {$else fpc}
-      push esi
-      push edi
+      push eax
       push ebx
+      push ecx
+      push edx
+      push esi
       movzx eax, [X]          { Get X address                    }
       push  eax
       shr   eax, 3
@@ -490,9 +510,11 @@ const
       mov   al,ah            { 16-bit pixel in AX   }
       xor   ah,ah
       mov   @Result, ax
-      pop ebx
-      pop edi
       pop esi
+      pop edx
+      pop ecx
+      pop ebx
+      pop eax
   {$endif fpc}
     end;
 {$endif asmgraph}
@@ -719,9 +741,11 @@ End;
       mov  ax,0001h
       out  dx,ax
   {$else fpc}
-      push esi
-      push edi
+      push eax
       push ebx
+      push ecx
+      push edx
+      push edi
       { enable the set / reset function and load the color }
       mov  dx, 3ceh
       mov  ax, 0f01h
@@ -764,9 +788,11 @@ End;
       { restore enable set/reset register }
       mov  ax,0001h
       out  dx,ax
-      pop ebx
       pop edi
-      pop esi
+      pop edx
+      pop ecx
+      pop ebx
+      pop eax
   {$endif fpc}
     end;
 {$endif asmgraph}
@@ -1029,7 +1055,7 @@ End;
       mov al,0dh
       out dx,al
       in  al,dx
-    end;
+    end ['EDX','EAX'];
   end;
 
  procedure SetActive200(page: word); {$ifndef fpc}far;{$endif fpc}
@@ -1064,7 +1090,7 @@ End;
       pop esi
       pop ebp
 {$endif fpc}
-    end;
+    end ['EAX'];
   end;
 
  procedure SetActive350(page: word); {$ifndef fpc}far;{$endif fpc}
@@ -1125,8 +1151,10 @@ End;
   {$else fpc}
   assembler;
   asm
-      push edi
+      push eax
       push ebx
+      push ecx
+      push edi
 {$IFDEF REGCALL}
       movsx  edi, ax
       movsx  ebx, dx
@@ -1158,8 +1186,10 @@ End;
       add    edi, ebx
       mov    fs:[edi+ebx*4+$a0000], al
 @putpix320done:
-      pop ebx
       pop edi
+      pop ecx
+      pop ebx
+      pop eax
 {$endif fpc}
  end;
 
@@ -1185,8 +1215,11 @@ End;
   {$else fpc}
   assembler;
   asm
-    push edi
+    push eax
     push ebx
+    push ecx
+    push edx
+    push edi
 {$IFDEF REGCALL}
     movsx  edi, ax
     movsx  ebx, dx
@@ -1202,8 +1235,11 @@ End;
     shl    ebx, 6
     add    edi, ebx
     movzx  ax, byte ptr fs:[edi+ebx*4+$a0000]
-    pop ebx
     pop edi
+    pop edx
+    pop ecx
+    pop ebx
+    pop eax
  {$endif fpc}
   end;
 
@@ -1245,8 +1281,9 @@ End;
     @MovMode:
       mov    es:[di], al
   {$else fpc}
-      push edi
+      push eax
       push ebx
+      push edi
 {$IFDEF REGCALL}
       movzx  edi, ax
       movzx  ebx, dx
@@ -1263,8 +1300,9 @@ End;
       xor    al, fs:[edi+ebx*4+$a0000]
      @MovMode:
       mov    fs:[edi+ebx*4+$a0000], al
-      pop ebx
       pop edi
+      pop ebx
+      pop eax
 {$endif fpc}
   end;
 {$endif asmgraph}
@@ -1308,10 +1346,16 @@ const CrtAddress: word = 0;
   @L2:
 {$ifdef fpc}
      push ebp
+     push esi
+     push edi
+     push ebx
 {$EndIf fpc}
      INT  10h
 {$ifdef fpc}
-    pop ebp
+     pop ebx
+     pop edi
+     pop esi
+     pop ebp
 {$EndIf fpc}
      MOV DX,03C4h   {select memory-mode-register at sequencer Port    }
      MOV AL,04
@@ -1336,8 +1380,10 @@ const CrtAddress: word = 0;
      CLD
      REP STOSW
 {$else fpc}
-      push edi
+     push eax
+     push ecx
      push es
+     push edi
      push fs
      mov edi, $a0000
      pop es
@@ -1345,8 +1391,10 @@ const CrtAddress: word = 0;
      mov ecx, 4000h
      cld
      rep stosd
-     pop es
      pop edi
+     pop es
+     pop ecx
+     pop eax
 {$EndIf fpc}
      MOV DX,CRTAddress  {address the underline-location-register at }
      MOV AL,14h         {the CRT-controller Port, read out the according      }
@@ -1362,7 +1410,7 @@ const CrtAddress: word = 0;
      IN  AL,DX
      OR  AL,40h     {bit 6 := 1: memory access scheme=linear bit array      }
      OUT DX,AL
-  end ['ESI','EDI','EBX','EAX'];
+  end ['EDX','EBX','EAX'];
  end;
 
 
@@ -1405,10 +1453,12 @@ const CrtAddress: word = 0;
     mov al, ES:[DI]
     xor ah, ah
     mov @Result, ax
-  end;
   {$else fpc}
-      push edi
-      push ebx
+     push eax  
+     push ebx
+     push ecx
+     push edx
+     push edi
      movzx edi,[Y]                   ; (* DI = Y coordinate                 *)
      (* Multiply by 80 start *)
      mov ebx, edi
@@ -1431,10 +1481,13 @@ const CrtAddress: word = 0;
    (* End selection of plane *)
     mov ax, fs:[edi+$a0000]
     mov @Result, ax
-    pop ebx
     pop edi
-   end ['ESI','EDI','EBX','EAX'];
+    pop edx
+    pop ecx
+    pop ebx
+    pop eax
   {$endif fpc}
+   end;
 {$endif asmgraph}
  end;
 
@@ -1445,6 +1498,9 @@ const CrtAddress: word = 0;
    (* Select where the left corner of the screen will be *)
    { By Matt Pritchard }
     asm
+     push ax
+     push cx
+     push dx
 {$IFDEF REGCALL}
      mov cx, ax
 {$ENDIF REGCALL}
@@ -1488,6 +1544,9 @@ const CrtAddress: word = 0;
      AND     AL, VERT_RETRACE    { Vertical Retrace Start?        }
      JZ      @DP_WAIT1           { If Not, wait for it            }
     { Now Set Display Starting Address                     }
+     pop dx
+     pop cx
+     pop ax
   end;
 
 {$ifdef fpc}
@@ -1539,6 +1598,12 @@ const CrtAddress: word = 0;
     Mem[SegA000:offset] := color;
 {$else asmgraph}
      asm
+      push ax
+      push bx
+      push cx
+      push dx
+      push es
+      push di
       mov di,[Y]                   ; (* DI = Y coordinate                 *)
       (* Multiply by 80 start *)
       mov bx, di
@@ -1567,6 +1632,12 @@ const CrtAddress: word = 0;
       xor al,ah             { xor it and return value into AL }
     @MovMode:
       mov es:[di], al
+      pop di
+      pop es
+      pop dx
+      pop cx
+      pop bx
+      pop ax
     end;
 {$endif asmgraph}
   end;
@@ -1605,6 +1676,12 @@ const CrtAddress: word = 0;
 { note: still needs or/and/notput support !!!!! (JM) }
  Assembler;
  asm
+   push ax
+   push bx
+   push cx
+   push dx
+   push es
+   push di
 {$IFDEF REGCALL}
    mov cl, al
    mov di, dx
@@ -1638,6 +1715,12 @@ const CrtAddress: word = 0;
    xor al,ah             { xor it and return value into AL }
  @MovMode:
    mov es:[di], al
+   pop di
+   pop es
+   pop dx
+   pop cx
+   pop bx
+   pop ax
  end;
 {$endif asmgraph}
 
@@ -1673,13 +1756,19 @@ const CrtAddress: word = 0;
       mov  ah,0fh
 {$ifdef fpc}
       push ebp
+      push esi
+      push edi
+      push ebx
 {$endif fpc}
       int  10h
 {$ifdef fpc}
+      pop ebx
+      pop edi
+      pop esi
       pop ebp
 {$endif fpc}
       mov  [VideoMode], al
-    end;
+    end ['EAX'];
     { saving/restoring video state screws up Windows (JM) }
     if inWindows then
       exit;
@@ -1688,18 +1777,26 @@ const CrtAddress: word = 0;
       mov  ax, 1C00h       { get buffer size to save state }
       mov  cx, 00000111b   { Save DAC / Data areas / Hardware states }
 {$ifdef fpc}
+      push ebx
       push ebp
+      push esi
+      push edi
 {$endif fpc}
       int  10h
 {$ifdef fpc}
+      pop edi
+      pop esi
       pop ebp
 {$endif fpc}
       mov  [StateSize], bx
+{$ifdef fpc}
+      pop ebx
+{$endif fpc}
       cmp  al,01ch
       jnz  @notok
       mov  [SaveSupPorted],TRUE
      @notok:
-    end;
+    end ['ECX','EAX'];
     if SaveSupPorted then
       begin
 
@@ -1748,12 +1845,18 @@ const CrtAddress: word = 0;
       mov  al,[VideoMode]
 {$ifdef fpc}
       push ebp
+      push esi
+      push edi
+      push ebx
 {$endif fpc}
       int  10h
 {$ifdef fpc}
+      pop ebx
+      pop edi
+      pop esi
       pop ebp
 {$endif fpc}
-     end;
+     end ['EAX'];
      { then restore all state information }
 {$ifndef fpc}
      if assigned(SavePtr) and (SaveSupPorted=TRUE) then
@@ -1907,6 +2010,8 @@ const CrtAddress: word = 0;
         { on some hardware - there is a snow like effect       }
         { when changing the palette register directly          }
         { so we wait for a vertical retrace start period.      }
+        push ax
+        push dx
         mov dx, $03da
       @1:
         in    al, dx          { Get input status register    }
@@ -1935,6 +2040,8 @@ const CrtAddress: word = 0;
         mov ax, [BlueValue] { Get RedValue                      }
         shr ax, 2
         out dx, al
+        pop dx
+        pop ax
       end
     End;
 
@@ -2033,30 +2140,28 @@ const CrtAddress: word = 0;
      { check if Hercules adapter supPorted ... }
      { check if EGA adapter supPorted...       }
      asm
-{$ifdef fpc}
-       push esi
-       push edi
-       push ebx
-{$endif fpc}
        mov ah,12h
        mov bx,0FF10h
 {$ifdef fpc}
+       push ebx
        push ebp
+       push esi
+       push edi
 {$endif fpc}
        int 10h              { get EGA information }
 {$ifdef fpc}
+       pop edi
+       pop esi
        pop ebp
 {$endif fpc}
        cmp bh,0ffh
-       jz  @noega
-       mov [EGADetected],TRUE
-     @noega:
 {$ifdef fpc}
        pop ebx
-       pop edi
-       pop esi
 {$endif fpc}
-     end;
+       jz  @noega
+       mov [EGADetected],TRUE
+     @noega:
+     end ['EBX','EAX'];
 {$ifdef logging}
      LogLn('EGA detected: '+strf(Longint(EGADetected)));
 {$endif logging}
@@ -2064,17 +2169,18 @@ const CrtAddress: word = 0;
      if EGADetected then
        begin
         asm
+         mov ax,1a00h
 {$ifdef fpc}
+         push ebp
          push esi
          push edi
          push ebx
-{$endif fpc}
-         mov ax,1a00h
-{$ifdef fpc}
-         push ebp
 {$endif fpc}
          int 10h            { get display combination code...}
 {$ifdef fpc}
+         pop ebx
+         pop edi
+         pop esi
          pop ebp
 {$endif fpc}
          cmp al,1ah         { check if supPorted...          }
@@ -2083,17 +2189,24 @@ const CrtAddress: word = 0;
          mov ax,1c00h       { get state size for save...     }
                             { ... all imPortant data         }
          mov cx,07h
+{$ifdef fpc}
+         push ebp
+         push esi
+         push edi
+         push ebx
+{$endif fpc}
          int 10h
+{$ifdef fpc}
+         pop ebx
+         pop edi
+         pop esi
+         pop ebp
+{$endif fpc}
          cmp al,1ch         { success?                       }
          jne @novga
          mov [VGADetected],TRUE
         @novga:
-{$ifdef fpc}
-       pop ebx
-       pop edi
-       pop esi
-{$endif fpc}
-        end;
+        end ['ECX','EAX'];
        end;
 {$ifdef logging}
        LogLn('VGA detected: '+strf(Longint(VGADetected)));
@@ -2129,7 +2242,7 @@ const CrtAddress: word = 0;
          mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisual320;
          mode.SetActivePage := {$ifdef fpc}@{$endif}SetActive320;
          mode.InitMode := {$ifdef fpc}@{$endif}Init320;
-         mode.XAspect := 10000;
+         mode.XAspect := 8333;
          mode.YAspect := 10000;
          AddMode(mode);
 
@@ -2153,7 +2266,7 @@ const CrtAddress: word = 0;
          mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualX;
          mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveX;
          mode.InitMode := {$ifdef fpc}@{$endif}InitModeX;
-         mode.XAspect := 10000;
+         mode.XAspect := 8333;
          mode.YAspect := 10000;
          AddMode(mode);
 
@@ -2179,7 +2292,7 @@ const CrtAddress: word = 0;
          mode.HLine := {$ifdef fpc}@{$endif}HLine16;
          mode.VLine := {$ifdef fpc}@{$endif}VLine16;
          mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
-         mode.XAspect := 10000;
+         mode.XAspect := 4500;
          mode.YAspect := 10000;
          AddMode(mode);
 
@@ -2205,7 +2318,7 @@ const CrtAddress: word = 0;
          mode.HLine := {$ifdef fpc}@{$endif}HLine16;
          mode.VLine := {$ifdef fpc}@{$endif}VLine16;
          mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLine16;
-         mode.XAspect := 10000;
+         mode.XAspect := 7750;
          mode.YAspect := 10000;
          AddMode(mode);
 
@@ -2283,7 +2396,7 @@ const CrtAddress: word = 0;
              mode.InitMode := {$ifdef fpc}@{$endif}Init320x200x32k;
              mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
              mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.XAspect := 10000;
+             mode.XAspect := 8333;
              mode.YAspect := 10000;
              AddMode(mode);
            end;
@@ -2309,7 +2422,7 @@ const CrtAddress: word = 0;
              mode.InitMode := {$ifdef fpc}@{$endif}Init320x200x64k;
              mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
              mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
-             mode.XAspect := 10000;
+             mode.XAspect := 8333;
              mode.YAspect := 10000;
              AddMode(mode);
            end;
@@ -2341,7 +2454,7 @@ const CrtAddress: word = 0;
              mode.hline := {$ifdef fpc}@{$endif}HLineVESA256;
              mode.vline := {$ifdef fpc}@{$endif}VLineVESA256;
              mode.GetScanLine := {$ifdef fpc}@{$endif}GetScanLineVESA256;
-             mode.XAspect := 10000;
+             mode.XAspect := 8333;
              mode.YAspect := 10000;
              AddMode(mode);
            end;
@@ -2624,7 +2737,7 @@ const CrtAddress: word = 0;
              mode.GetPixel:={$ifdef fpc}@{$endif}GetPixVESA32kOr64k;
              mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetVESARGBPalette;
              mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetVESARGBPalette;
-             mode.InitMode := {$ifdef fpc}@{$endif}Init640x480x32k;
+             mode.InitMode := {$ifdef fpc}@{$endif}Init1024x768x32k;
              mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualVESA;
              mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveVESA;
              mode.XAspect := 10000;
@@ -2810,14 +2923,20 @@ begin
     mov  ax,$160a
 {$ifdef fpc}
     push ebp
+    push esi
+    push edi
+    push ebx
 {$endif fpc}
     int  $2f
 {$ifdef fpc}
+    pop ebx
+    pop edi
+    pop esi
     pop ebp
 {$endif fpc}
     test ax,ax
     sete al
     mov  inWindows,al
-  end ['ESI','EDI','EBX','EAX'];
+  end ['EAX'];
   InitializeGraph;
 end.

+ 61 - 9
packages/base/graph/go32v2/vesa.inc → packages/extra/graph/go32v2/vesa.inc

@@ -353,12 +353,18 @@ end;
 {$ENDIF REGCALL}
 {$ifdef fpc}
      push ebp
+     push esi
+     push edi
+     push ebx
 {$endif fpc}
      int  10h
 {$ifdef fpc}
+     pop ebx
+     pop edi
+     pop esi
      pop ebp
 {$endif fpc}
-   end;
+   end ['EDX','EBX','EAX'];
 
   {********************************************************}
   { There are two routines for setting banks. This may in  }
@@ -2260,16 +2266,22 @@ Const
     mov bx,mode
 {$ifdef fpc}
     push ebp
+    push esi
+    push edi
+    push ebx
 {$endif fpc}
     int 10h
 {$ifdef fpc}
+    pop ebx
+    pop edi
+    pop esi
     pop ebp
 {$endif fpc}
     sub ax,004Fh
     cmp ax,1
     sbb al,al
     mov res,al
-   end;
+   end ['EBX','EAX'];
    if not res then
      _GraphResult := GrNotDetected
    else _GraphResult := grOk;
@@ -2281,10 +2293,15 @@ Const
    asm  {return -1 if error}
     mov ax,4F03h
 {$ifdef fpc}
+    push ebx
     push ebp
+    push esi
+    push edi
 {$endif fpc}
     int 10h
 {$ifdef fpc}
+    pop edi
+    pop esi
     pop ebp
 {$endif fpc}
     cmp ax,004Fh
@@ -2294,7 +2311,10 @@ Const
   @@OK:
     mov ax,bx
   @@X:
-   end;
+{$ifdef fpc}
+    pop ebx
+{$endif fpc}
+   end ['EAX'];
 *)
 
 
@@ -2373,9 +2393,9 @@ Const
     ScanLines := GetMaxScanLines;
   end;
 
- procedure Init640x480x32k; {$ifndef fpc}far;{$endif fpc}
+ procedure Init1024x768x32k; {$ifndef fpc}far;{$endif fpc}
   begin
-    SetVESAMode(m640x480x32k);
+    SetVESAMode(m1024x768x32k);
     { Get maximum number of scanlines for page flipping }
     ScanLines := GetMaxScanLines;
   end;
@@ -2429,6 +2449,12 @@ Const
     ScanLines := GetMaxScanLines;
   end;
 
+ procedure Init640x480x32k; {$ifndef fpc}far;{$endif fpc}
+  begin
+    SetVESAMode(m640x480x32k);
+    { Get maximum number of scanlines for page flipping }
+    ScanLines := GetMaxScanLines;
+  end;
 
  procedure Init640x480x256; {$ifndef fpc}far;{$endif fpc}
   begin
@@ -2476,13 +2502,19 @@ Const
       mov  ah,0fh
 {$ifdef fpc}
       push ebp
+      push esi
+      push edi
+      push ebx
 {$endif fpc}
       int  10h
 {$ifdef fpc}
+      pop ebx
+      pop edi
+      pop esi
       pop ebp
 {$endif fpc}
       mov  [VideoMode], al
-    end;
+    end ['EAX'];
     { saving/restoring video state screws up Windows (JM) }
     if inWindows then
       exit;
@@ -2495,18 +2527,26 @@ Const
       mov  dx, 00h
       mov  cx, 00001111b   { Save DAC / Data areas / Hardware states }
 {$ifdef fpc}
+      push ebx
       push ebp
+      push esi
+      push edi
 {$endif fpc}
       int  10h
 {$ifdef fpc}
+      pop edi
+      pop esi
       pop ebp
 {$endif fpc}
       mov  [StateSize], bx
+{$ifdef fpc}
+      pop ebx
+{$endif fpc}
       cmp  al,04fh
       jnz  @notok
       mov  [SaveSupported],TRUE
      @notok:
-    end;
+    end ['EDX','ECX','EAX'];
     regs.eax := $4f04;
     regs.edx := $0000;
     regs.ecx := $000F;
@@ -2567,12 +2607,18 @@ Const
       mov  al,[VideoMode]
 {$ifdef fpc}
       push ebp
+      push esi
+      push edi
+      push ebx
 {$endif fpc}
       int  10h
 {$ifdef fpc}
+      pop ebx
+      pop edi
+      pop esi
       pop ebp
 {$endif fpc}
-     end;
+     end ['EAX'];
      { then restore all state information }
 {$ifndef fpc}
      if assigned(SavePtr) and (SaveSupported=TRUE) then
@@ -2719,12 +2765,18 @@ Const
       mov dx, [NewStartVisible]  { new scanline }
 {$ifdef fpc}
       push    ebp
+      push    esi
+      push    edi
+      push    ebx
 {$endif}
       int     10h
 {$ifdef fpc}
+      pop     ebx
+      pop     edi
+      pop     esi
       pop     ebp
 {$endif}
-    end;
+    end ['EDX','ECX','EBX','EAX'];
   end;
 
  procedure SetActiveVESA(page: word); {$ifndef fpc}far;{$endif fpc}

+ 0 - 0
packages/base/graph/go32v2/vesah.inc → packages/extra/graph/go32v2/vesah.inc


+ 0 - 0
packages/base/graph/inc/clip.inc → packages/extra/graph/inc/clip.inc


+ 7 - 7
packages/base/graph/inc/fills.inc → packages/extra/graph/inc/fills.inc

@@ -135,7 +135,7 @@ begin
     while (i < nActive) do begin
       if (AET^[i]^.yMax = y) then begin
         dec(nActive);
-        move(AET^[i+1], AET^[i], (nActive-i)*sizeof(pedge));
+        System.move(AET^[i+1], AET^[i], (nActive-i)*sizeof(pedge));
       end else
         inc(i);
     end;
@@ -207,9 +207,9 @@ begin
     inc(y);
     if (y >= ViewHeight) then break;
   end;
-  freemem(et, sizeof(tedge) * numpoints);
-  freemem(get, sizeof(pedge) * numpoints);
-  freemem(aet, sizeof(pedge) * numpoints);
+  System.freemem(et, sizeof(tedge) * numpoints);
+  System.freemem(get, sizeof(pedge) * numpoints);
+  System.freemem(aet, sizeof(pedge) * numpoints);
 end;
 
 
@@ -474,9 +474,9 @@ var
        PatternLine (x1,x2,y);
      End; { end while }
 
-    FreeMem (s1,(ViewWidth+1)*2);
-    FreeMem (s2,(ViewWidth+1)*2);
-    FreeMem (s3,(ViewWidth+1)*2);
+    System.FreeMem (s1,(ViewWidth+1)*2);
+    System.FreeMem (s2,(ViewWidth+1)*2);
+    System.FreeMem (s3,(ViewWidth+1)*2);
     CleanUpDrawnList;
     CurrentColor := BackUpColor;
   End;

+ 0 - 0
packages/base/graph/inc/fontdata.inc → packages/extra/graph/inc/fontdata.inc


+ 7 - 9
packages/base/graph/inc/graph.inc → packages/extra/graph/inc/graph.inc

@@ -681,9 +681,6 @@ var
        { restore line thickness }
        LineInfo.Thickness := OldLineWidth;
      End;
-   { Adjust for screen aspect ratio }
-   XRadius:=(longint(XRadius)*10000) div XAspect;
-   YRadius:=(longint(YRadius)*10000) div YAspect;
    If xradius = 0 then inc(xradius);
    if yradius = 0 then inc(yradius);
    { check for an ellipse with negligable x and y radius }
@@ -1392,17 +1389,18 @@ end;
      { save state of arc information }
      { because it is not needed for  }
      { a circle call.                }
-     move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
+     System.move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
      if LineInfo.Thickness = Normwidth then
        begin
              OldWriteMode := CurrentWriteMode;
              CurrentWriteMode := CopyPut;
        end;
-     InternalEllipse(X,Y,Radius,Radius,0,360,{$ifdef fpc}@{$endif}DummyPatternLine);
+     { Adjust for screen aspect ratio }
+     InternalEllipse(X,Y,Radius,(longint(Radius)*XAspect) div YAspect,0,360,{$ifdef fpc}@{$endif}DummyPatternLine);
      if LineInfo.Thickness = Normwidth then
          CurrentWriteMode := OldWriteMode;
      { restore arc information }
-     move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
+     System.move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
  end;
 
  procedure SectorPL(x1,x2,y: smallint); {$ifndef fpc}far;{$endif fpc}
@@ -1818,7 +1816,7 @@ end;
      { normal write mode }
      CurrentWriteMode := CopyPut;
 
-     { Schriftart einstellen }
+     { set font style }
      CurrentTextInfo.font := DefaultFont;
      CurrentTextInfo.direction:=HorizDir;
      CurrentTextInfo.charsize:=1;
@@ -2114,7 +2112,7 @@ begin
  { This installs an exit procedure which cleans up the mode list...}
  ExitSave := ExitProc;
  ExitProc := @GraphExitProc;
-{$ifdef win32}
+{$if defined(win32) and not defined(sdlgraph)}
  charmessagehandler:=nil;
-{$endif win32}
+{$endif win32 and not sdlgraph}
 end;

+ 0 - 0
packages/base/graph/inc/graph.tex → packages/extra/graph/inc/graph.tex


+ 0 - 0
packages/base/graph/inc/graphh.inc → packages/extra/graph/inc/graphh.inc


+ 83 - 11
packages/base/graph/inc/gtext.inc → packages/extra/graph/inc/gtext.inc

@@ -89,6 +89,64 @@
 {                         Internal support routines                         }
 {***************************************************************************}
 
+{$ifdef FPC_BIG_ENDIAN}
+procedure swap_fheader(var h: tfheader);
+(*
+      TFHeader = packed record
+         header_size: word;    {* Version 2.0 Header Format        *}
+         font_name: array[1..4] of char;
+         font_size: word;      {* Size in byte of file        *}
+         font_major: byte;     {* Driver Version Information    *}
+         font_minor: byte;
+         min_major: byte;      {* BGI Revision Information         *}
+         min_minor: byte;
+      end;
+*)
+begin
+  with h do
+    begin
+      header_size := swap(header_size);
+      font_size := swap(font_size);
+    end;
+end;
+
+procedure swap_header(var h: theader);
+(*
+      THeader = packed record
+        Signature:  char;     { signature byte                        }
+        Nr_chars:   smallint;  { number of characters in file          }
+        Reserved:   byte;
+        First_char: byte;     { first character in file               }
+        cdefs :     smallint;  { offset to character definitions       }
+        scan_flag:  byte;     { TRUE if char is scanable              }
+        org_to_cap: shortint;     { Height from origin to top of capitol  }
+        org_to_base:shortint;     { Height from origin to baseline        }
+        org_to_dec: shortint;     { Height from origin to bot of decender }
+        _reserved: array[1..4] of char;
+        Unused: byte;
+      end;
+*)
+begin
+  with h do
+    begin
+      nr_chars := swap(nr_chars);
+      cdefs := swap(cdefs);
+    end;
+end;
+
+
+procedure swap_offsets(var t: toffsettable; start, len: longint);
+(*
+      TOffsetTable =array[0..MaxChars] of smallint;
+*)
+var
+  i: longint;
+begin
+  for i := start to start+len-1 do
+    t[i]:=Swap(t[i]);
+end;
+{$endif FPC_BIG_ENDIAN}
+
 
 function ConvertString(const OrigString: String): String;
 var
@@ -292,30 +350,37 @@ end;
               hp:=pchar(font);
               { Move to EOF in prefix header }
               while (hp[i] <> chr($1a)) do Inc(i);
-              move(hp[i+1],FHeader,sizeof(FHeader));
-              move(hp[Prefix_Size],header,sizeof(Header));
+              System.move(hp[i+1],FHeader,sizeof(FHeader));
+              System.move(hp[Prefix_Size],header,sizeof(Header));
+{$ifdef FPC_BIG_ENDIAN}
+              swap_fheader(fheader);
+              swap_header(header);
+{$endif FPC_BIG_ENDIAN}
               { check if the font name is already allocated? }
               i:=Prefix_Size+sizeof(Header);
               for b:=1 to installedfonts do
                 begin
                    if fonts[b].name=FHeader.Font_name then
                      begin
-                        move(FHeader,fonts[b].PHeader,sizeof(FHeader));
-                        move(Header,fonts[b].Header,sizeof(Header));
-                        move(hp[i],Fonts[b].Offsets[Fonts[b].Header.First_Char],Fonts[b].Header.Nr_chars*sizeof(smallint));
+                        System.move(FHeader,fonts[b].PHeader,sizeof(FHeader));
+                        System.move(Header,fonts[b].Header,sizeof(Header));
+                        System.move(hp[i],Fonts[b].Offsets[Fonts[b].Header.First_Char],Fonts[b].Header.Nr_chars*sizeof(smallint));
+{$ifdef FPC_BIG_ENDIAN}
+                        swap_offsets(Fonts[b].Offsets,Fonts[b].Header.First_Char,Fonts[b].Header.Nr_chars);
+{$endif FPC_BIG_ENDIAN}
                         Inc(i,Fonts[b].Header.Nr_chars*sizeof(smallint));
-                        move(hp[i],Fonts[b].Widths[Fonts[b].Header.First_Char],Fonts[b].Header.Nr_chars*sizeof(byte));
+                        System.move(hp[i],Fonts[b].Widths[Fonts[b].Header.First_Char],Fonts[b].Header.Nr_chars*sizeof(byte));
                         Inc(i,Fonts[b].Header.Nr_chars*sizeof(byte));
                         counter:=Fonts[b].PHeader.font_size+PREFIX_SIZE-i;
                         { allocate also space for null }
                         GetMem(FontData,Counter+1);
-                        move(hp[i],FontData^,Counter);
+                        System.move(hp[i],FontData^,Counter);
                         { Null terminate the string }
                         FontData[counter+1] := #0;
                         if fonts[b].header.Signature<> SIGNATURE then
                           begin
                             _graphResult:=grInvalidFont;
-                            Freemem(FontData, Counter+1);
+                            System.Freemem(FontData, Counter+1);
                             exit;
                           end;
                         fonts[b].instr:=FontData;
@@ -743,10 +808,17 @@ end;
               hp:=Prefix;
               i:=0;
               while (hp[i] <> chr($1a)) do Inc(i);
-              move(hp[i+1],fonts[font].PHeader,sizeof(TFHeader));
+              System.move(hp[i+1],fonts[font].PHeader,sizeof(TFHeader));
               (* Read in the Header file  *)
               BlockRead(F,fonts[font].Header,Sizeof(THeader));
+{$ifdef FPC_BIG_ENDIAN}
+              swap_fheader(fonts[font].PHeader);
+              swap_header(fonts[font].Header);
+{$endif FPC_BIG_ENDIAN}
               BlockRead(F,Fonts[font].Offsets[Fonts[font].Header.First_Char],Fonts[font].Header.Nr_chars*sizeof(smallint));
+{$ifdef FPC_BIG_ENDIAN}
+              swap_offsets(Fonts[font].Offsets,Fonts[font].Header.First_Char,Fonts[font].Header.Nr_chars);
+{$endif FPC_BIG_ENDIAN}
               {*        Load the character width table into memory.                     *}
               BlockRead(F,Fonts[font].Widths[Fonts[font].Header.First_Char],Fonts[font].Header.Nr_chars*sizeof(byte));
               {*        Determine the length of the stroke database.                    *}
@@ -765,7 +837,7 @@ end;
              begin
                 _graphResult:=grInvalidFont;
                 Currenttextinfo.font:=DefaultFont;
-                Freemem(FontData, Length+1);
+                System.Freemem(FontData, Length+1);
                 exit;
              end;
              fonts[font].instr:=FontData;
@@ -776,7 +848,7 @@ end;
                 begin
                    _graphresult:=grInvalidFont;
                    Currenttextinfo.font:=DefaultFont;
-                   Freemem(FontData, Length+1);
+                   System.Freemem(FontData, Length+1);
                 end;
               close(f);
            end;

+ 0 - 0
packages/base/graph/inc/makefile.inc → packages/extra/graph/inc/makefile.inc


+ 2 - 2
packages/base/graph/inc/modes.inc → packages/extra/graph/inc/modes.inc

@@ -155,7 +155,7 @@ end;
     if not assigned(ModeList) then
       begin
         new(ModeList);
-        move(mode, ModeList^, sizeof(Mode));
+        System.move(mode, ModeList^, sizeof(Mode));
       end
     else
       begin
@@ -165,7 +165,7 @@ end;
           list:=list^.next;
         new(NewLst);
         list^.next := NewLst;
-        move(mode, NewLst^, sizeof(Mode));
+        System.move(mode, NewLst^, sizeof(Mode));
       end;
   end;
 

+ 1 - 1
packages/base/graph/inc/palette.inc → packages/extra/graph/inc/palette.inc

@@ -373,7 +373,7 @@ CONST
 
     procedure GetDefaultPalette(var Palette: PaletteType);
       begin
-        move(DefaultColors, Palette.Colors, sizeof(DefaultColors));
+        System.move(DefaultColors, Palette.Colors, sizeof(DefaultColors));
         { The default palette always has 256 entries, but in reality }
         { it depends on the number of colors possible.               }
         Palette.Size := PaletteSize;

+ 1118 - 0
packages/extra/graph/macosx/graph.pp

@@ -0,0 +1,1118 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Florian Klaempfl
+
+    This file implements the linux GGI support for the graph unit
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    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.
+
+ **********************************************************************}
+unit Graph;
+interface
+
+uses
+  { in the interface so the graphh definitions of moveto etc override }
+  { the ones in the universal interfaces                              }
+  cthreads, FPCMacOSAll;
+
+{$linkframework Carbon}
+
+type
+  TGraphProgram = function(p: pointer): longint;
+
+  procedure StartGraphProgram(p: TGraphProgram);
+
+{$i graphh.inc}
+
+Const
+  { Supported modes }
+  {(sg) GTEXT deactivated because we need mode #0 as default mode}
+  {GTEXT             = 0;                 Compatible with VGAlib v1.2 }
+  G320x200x16       = 1;
+  G640x200x16       = 2;
+  G640x350x16       = 3;
+  G640x480x16       = 4;
+  G320x200x256      = 5;
+  G320x240x256      = 6;
+  G320x400x256      = 7;
+  G360x480x256      = 8;
+  G640x480x2        = 9;
+
+  G640x480x256      = 10;
+  G800x600x256      = 11;
+  G1024x768x256     = 12;
+
+  G1280x1024x256    = 13;   { Additional modes. }
+
+  G320x200x32K      = 14;
+  G320x200x64K      = 15;
+  G320x200x16M      = 16;
+  G640x480x32K      = 17;
+  G640x480x64K      = 18;
+  G640x480x16M      = 19;
+  G800x600x32K      = 20;
+  G800x600x64K      = 21;
+  G800x600x16M      = 22;
+  G1024x768x32K     = 23;
+  G1024x768x64K     = 24;
+  G1024x768x16M     = 25;
+  G1280x1024x32K    = 26;
+  G1280x1024x64K    = 27;
+  G1280x1024x16M    = 28;
+
+  G800x600x16       = 29;
+  G1024x768x16      = 30;
+  G1280x1024x16     = 31;
+
+  G720x348x2        = 32;               { Hercules emulation mode }
+
+  G320x200x16M32    = 33;       { 32-bit per pixel modes. }
+  G640x480x16M32    = 34;
+  G800x600x16M32    = 35;
+  G1024x768x16M32   = 36;
+  G1280x1024x16M32  = 37;
+
+  { additional resolutions }
+  G1152x864x16      = 38;
+  G1152x864x256     = 39;
+  G1152x864x32K     = 40;
+  G1152x864x64K     = 41;
+  G1152x864x16M     = 42;
+  G1152x864x16M32   = 43;
+
+  G1600x1200x16     = 44;
+  G1600x1200x256    = 45;
+  G1600x1200x32K    = 46;
+  G1600x1200x64K    = 47;
+  G1600x1200x16M    = 48;
+  G1600x1200x16M32  = 49;
+
+
+implementation
+
+uses
+  { for FOUR_CHAR_CODE }
+  macpas;
+
+const
+  InternalDriverName = 'Quartz';
+
+  kEventClassFPCGraph = $46504367; // 'FPCg'
+  kEventInitGraph     = $496E6974; // 'Init'
+  kEventFlush         = $466c7368; // 'Flsh'
+  kEventCloseGraph    = $446f6e65; // 'Done'
+  kEventQuit          = $51756974; // 'Quit'
+  
+  kEventGraphInited   = $49746564 ; // Ited;
+  kEventGraphClosed   = $436c6564 ; // Cled;
+
+//  initGraphSpec  : EventTypeSpec = (eventClass: kEventClassFPCGraph; eventKind: kEventInitGraph);
+//  flushGraphSpec : EventTypeSpec = (eventClass: kEventClassFPCGraph; eventKind: kEventFlush);
+//  closeGraphSpec  : EventTypeSpec = (eventClass: kEventClassFPCGraph; eventKind: kEventCloseGraph);
+  allGraphSpec: array[0..3] of EventTypeSpec = ((eventClass: kEventClassFPCGraph; eventKind: kEventInitGraph),
+                                                (eventClass: kEventClassFPCGraph; eventKind: kEventFlush),
+                                                (eventClass: kEventClassFPCGraph; eventKind: kEventCloseGraph),
+                                                (eventClass: kEventClassFPCGraph; eventKind: kEventQuit));
+
+  GraphInitedSpec: array[0..0] of EventTypeSpec = ((eventClass: kEventClassFPCGraph; eventKind: kEventGraphInited));
+  GraphClosedSpec: array[0..0] of EventTypeSpec = ((eventClass: kEventClassFPCGraph; eventKind: kEventGraphClosed));
+
+{$i graph.inc}
+
+  type
+    PByte = ^Byte;
+    PLongInt = ^LongInt;
+
+    PByteArray = ^TByteArray;
+    TByteArray = array [0..MAXINT - 1] of Byte;
+
+  var
+    graphdrawing: TRTLCriticalSection;
+
+{ ---------------------------------------------------------------------
+   SVGA bindings.
+
+  ---------------------------------------------------------------------}
+
+Const
+  { Text }
+
+  WRITEMODE_OVERWRITE = 0;
+  WRITEMODE_MASKED    = 1;
+  FONT_EXPANDED       = 0;
+  FONT_COMPRESSED     = 2;
+
+ { Types }
+ type
+  PGraphicsContext = ^TGraphicsContext;
+  TGraphicsContext = record
+                       ModeType: Byte;
+                       ModeFlags: Byte;
+                       Dummy: Byte;
+                       FlipPage: Byte;
+                       Width: LongInt;
+                       Height: LongInt;
+                       BytesPerPixel: LongInt;
+                       Colors: LongInt;
+                       BitsPerPixel: LongInt;
+                       ByteWidth: LongInt;
+                       VBuf: pointer;
+                       Clip: LongInt;
+                       ClipX1: LongInt;
+                       ClipY1: LongInt;
+                       ClipX2: LongInt;
+                       ClipY2: LongInt;
+                       ff: pointer;
+                     end;
+
+Const
+  GLASTMODE         = 49;
+  ModeNames : Array[0..GLastMode] of string [18] =
+   ('Text',
+    'G320x200x16',
+    'G640x200x16',
+    'G640x350x16',
+    'G640x480x16',
+    'G320x200x256',
+    'G320x240x256',
+    'G320x400x256',
+    'G360x480x256',
+    'G640x480x2',
+    'G640x480x256',
+    'G800x600x256',
+    'G1024x768x256',
+    'G1280x1024x256',
+    'G320x200x32K',
+    'G320x200x64K',
+    'G320x200x16M',
+    'G640x480x32K',
+    'G640x480x64K',
+    'G640x480x16M',
+    'G800x600x32K',
+    'G800x600x64K',
+    'G800x600x16M',
+    'G1024x768x32K',
+    'G1024x768x64K',
+    'G1024x768x16M',
+    'G1280x1024x32K',
+    'G1280x1024x64K',
+    'G1280x1024x16M',
+    'G800x600x16',
+    '1024x768x16',
+    '1280x1024x16',
+    'G720x348x2',
+    'G320x200x16M32',
+    'G640x480x16M32',
+    'G800x600x16M32',
+    'G1024x768x16M32',
+    'G1280x1024x16M32',
+    'G1152x864x16',
+    'G1152x864x256',
+    'G1152x864x32K',
+    'G1152x864x64K',
+    'G1152x864x16M',
+    'G1152x864x16M32',
+    'G1600x1200x16',
+    'G1600x1200x256',
+    'G1600x1200x32K',
+    'G1600x1200x64K',
+    'G1600x1200x16M',
+    'G1600x1200x16M32');
+
+
+{ ---------------------------------------------------------------------
+    Mac OS X - specific stuff
+  ---------------------------------------------------------------------}
+
+
+var
+  { where all the drawing occurs }
+  offscreen: CGContextRef;
+  { the drawing window's contents to which offscreen is flushed }
+  graphHIView: HIViewRef;
+  { the drawing window itself }
+  myMainWindow: WindowRef;
+  maineventqueue: EventQueueRef;
+  updatepending: boolean;
+
+  colorpalette: array[0..255,1..3] of single;
+
+
+{ create a new offscreen bitmap context in which we can draw (and from }
+{ which we can read again)                                             }
+function CreateBitmapContext (pixelsWide, pixelsHigh: SInt32) : CGContextRef;
+var
+    colorSpace        : CGColorSpaceRef;
+    bitmapData        : Pointer;
+    bitmapByteCount   : SInt32;
+    bitmapBytesPerRow : SInt32;
+begin
+  CreateBitmapContext := nil;
+
+  bitmapBytesPerRow   := (pixelsWide * 4);// always draw in 24 bit colour (+ 8 bit alpha)
+  bitmapByteCount     := (bitmapBytesPerRow * pixelsHigh);
+
+  colorSpace := CGColorSpaceCreateDeviceRGB;// 2
+  bitmapData := getmem ( bitmapByteCount );// 3
+  if (bitmapData = nil) then
+    exit;
+
+  CreateBitmapContext := CGBitmapContextCreate (bitmapData,
+                                  pixelsWide,
+                                  pixelsHigh,
+                                  8,      // bits per component
+                                  bitmapBytesPerRow,
+                                  colorSpace,
+                                  kCGImageAlphaPremultipliedLast);
+  if (CreateBitmapContext = nil) then
+    begin
+      system.freemem (bitmapData);
+      writeln (stderr, 'Could not create graphics context!');
+      exit;
+    end;
+    CGColorSpaceRelease( colorSpace );
+    { disable anti-aliasing }
+    CGContextTranslateCTM(CreateBitmapContext,0.5,0.5);
+end;
+
+
+{ dispose the offscreen bitmap context }
+procedure DisposeBitmapContext(var bmContext: CGContextRef);
+begin
+  system.freemem(CGBitmapContextGetData(bmContext));
+  CGContextRelease(bmContext);
+  bmContext:=nil;
+end;
+
+
+{ create a HIView to add to a window, in which we can then draw }
+function CreateHIView (inWindow: WindowRef; const inBounds: Rect; var outControl: HIObjectRef): OSStatus;
+  var
+    root  : ControlRef;
+    event : EventRef;
+    err   : OSStatus;
+  label
+    CantCreate, CantGetRootControl, CantSetParameter, CantCreateEvent{, CantRegister};
+  begin
+    // Make an initialization event
+    err := CreateEvent( nil, kEventClassHIObject, kEventHIObjectInitialize,
+                        GetCurrentEventTime(), 0, event );
+    if (err <> noErr) then
+      goto CantCreateEvent;
+ 
+    // If bounds were specified, push the them into the initialization event
+    // so that they can be used in the initialization handler.
+    err := SetEventParameter( event, FOUR_CHAR_CODE('boun'), typeQDRectangle,
+           sizeof( Rect ), @inBounds );
+    if (err <> noErr) then
+      goto CantSetParameter;
+
+    err := HIObjectCreate( { kHIViewClassID } CFSTR('com.apple.hiview'), event, outControl );
+    assert(err = noErr);
+ 
+    // If a parent window was specified, place the new view into the
+    // parent window.
+    err := GetRootControl( inWindow, root );
+    if (err <> noErr) then
+      goto CantGetRootControl;
+    err := HIViewAddSubview( root, outControl );
+    if (err <> noErr) then
+      goto CantGetRootControl;
+
+    err := HIViewSetVisible(outControl, true);
+ 
+CantCreate:
+CantGetRootControl:
+CantSetParameter:
+CantCreateEvent:
+    ReleaseEvent( event );
+ 
+    CreateHIView := err;
+  end;
+
+
+{ Event handler which does the actual drawing by copying the offscreen to }
+{ the HIView of the drawing window                                        }
+function MyDrawEventHandler (myHandler: EventHandlerCallRef; 
+                        event: EventRef; userData: pointer): OSStatus; mwpascal;
+  var
+    myContext: CGContextRef;
+    bounds: HIRect;
+    img: CGImageRef;
+  begin
+//      writeln('event');
+      MyDrawEventHandler := GetEventParameter (event, // 1
+                              kEventParamCGContextRef, 
+                              typeCGContextRef, 
+                              nil, 
+                              sizeof (CGContextRef),
+                              nil,
+                              @myContext);
+    if (MyDrawEventHandler <> noErr) then
+      exit;
+    MyDrawEventHandler := HIViewGetBounds (HIViewRef(userData), bounds);
+    if (MyDrawEventHandler <> noErr) then
+      exit;
+    EnterCriticalSection(graphdrawing);
+    img:=CGBitmapContextCreateImage(offscreen);
+    CGContextDrawImage(myContext,
+                       bounds,
+                       img);
+    updatepending:=false;
+    LeaveCriticalSection(graphdrawing);
+    CGImageRelease(img);
+end;
+
+
+{ force the draw event handler to fire }
+procedure UpdateScreen;
+var
+  event : EventRef;
+begin
+  if (updatepending) then
+    exit;
+
+  if (CreateEvent(nil, kEventClassFPCGraph, kEventFlush, GetCurrentEventTime(), 0, event) <> noErr) then
+    exit;
+
+  if (PostEventToQueue(MainEventQueue,event,kEventPriorityLow) <> noErr) then
+    begin
+      ReleaseEvent(event);
+      exit;
+    end;
+  updatepending:=true;
+end;
+
+
+{ ---------------------------------------------------------------------
+    Required procedures
+  ---------------------------------------------------------------------}
+var
+  LastColor: smallint;   {Cache the last set color to improve speed}
+
+procedure q_SetColor(color: smallint);
+begin
+  if color <> LastColor then
+    begin
+//      writeln('setting color to ',color);
+      EnterCriticalSection(graphdrawing);
+      case maxcolor of
+        16:
+          begin
+            CGContextSetRGBFillColor(offscreen,colorpalette[color,1],colorpalette[color,2],colorpalette[color,3],1);
+            CGContextSetRGBStrokeColor(offscreen,colorpalette[color,1],colorpalette[color,2],colorpalette[color,3],1);
+          end;
+        256:
+          begin
+            CGContextSetRGBFillColor(offscreen,colorpalette[color,1],colorpalette[color,2],colorpalette[color,3],1);
+            CGContextSetRGBStrokeColor(offscreen,colorpalette[color,1],colorpalette[color,2],colorpalette[color,3],1);
+          end;
+        32678:
+          begin
+            CGContextSetRGBFillColor(offscreen,((color and $7ffff) shr 10)/31.0,((color shr 5) and 31)/31.0,(color and 31)/31.0,1);
+            CGContextSetRGBStrokeColor(offscreen,((color and $7ffff) shr 10)/31.0,((color shr 5) and 31)/31.0,(color and 31)/31.0,1);
+          end;
+        65536:
+          begin
+            CGContextSetRGBFillColor(offscreen,(word(color) shr 11)/31.0,((word(color) shr 5) and 63)/63.0,(color and 31)/31.0,1);
+            CGContextSetRGBStrokeColor(offscreen,(word(color) shr 11)/31.0,((word(color) shr 5) and 63)/63.0,(color and 31)/31.0,1);
+          end;
+        else
+          runerror(218);
+      end;
+      LeaveCriticalSection(graphdrawing);
+      lastcolor:=color;
+    end
+end;
+
+
+procedure q_savevideostate;
+begin
+end;
+
+procedure q_restorevideostate;
+begin
+end;
+
+
+function CGRectMake(x,y, width, height: single): CGRect; inline;
+begin
+  CGRectMake.origin.x:=x;
+  CGRectMake.origin.y:=y;
+  CGRectMake.size.width:=width;
+  CGRectMake.size.height:=height;
+end;
+
+
+Function ClipCoords (Var X,Y : smallint) : Boolean;
+{ Adapt to viewport, return TRUE if still in viewport,
+  false if outside viewport}
+
+begin
+  X:= X + StartXViewPort;
+  Y:= Y + StartYViewPort;
+  ClipCoords:=Not ClipPixels;
+  if ClipPixels then
+    Begin
+    ClipCoords:=(X < StartXViewPort) or (X > (StartXViewPort + ViewWidth));
+    ClipCoords:=ClipCoords or
+               ((Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)));
+    ClipCoords:=Not ClipCoords;
+    end;
+end;
+
+
+procedure q_directpixelproc(X,Y: smallint);
+
+Var Color : Word;
+
+begin
+  case CurrentWriteMode of
+    XORPut:
+      begin
+        { getpixel wants local/relative coordinates }
+        Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+        Color := CurrentColor Xor Color;
+      end;
+    OrPut:
+      begin
+        { getpixel wants local/relative coordinates }
+        Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+        Color := CurrentColor Or Color;
+      end;
+    AndPut:
+      begin
+        { getpixel wants local/relative coordinates }
+        Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+        Color := CurrentColor And Color;
+      end;
+    NotPut:
+      begin
+        Color := Not CurrentColor;
+      end
+  else
+    Color:=CurrentColor;
+  end;
+  q_SetColor(Color);
+  EnterCriticalSection(graphdrawing);
+  CGContextBeginPath(offscreen);
+  CGContextMoveToPoint(offscreen,x,y);
+  CGContextAddLineToPoint(offscreen,x,y);
+  CGContextClosePath(offscreen);
+  CGContextStrokePath(offscreen);
+  UpdateScreen;
+  LeaveCriticalSection(graphdrawing);
+end;
+
+procedure q_putpixelproc(X,Y: smallint; Color: Word);
+begin
+  if Not ClipCoords(X,Y) Then
+    exit;
+  q_setcolor(Color);
+  EnterCriticalSection(graphdrawing);
+  CGContextBeginPath(offscreen);
+  CGContextMoveToPoint(offscreen,x,y);
+  CGContextAddLineToPoint(offscreen,x,y);
+  CGContextClosePath(offscreen);
+  CGContextStrokePath(offscreen);
+  UpdateScreen;
+  LeaveCriticalSection(graphdrawing);
+end;
+
+function q_getpixelproc (X,Y: smallint): word;
+type
+  pbyte = ^byte;
+var
+  p: pbyte;
+  rsingle, gsingle, bsingle, dist, closest: single;
+  count: longint;
+  red, green, blue: byte;
+begin
+ if not ClipCoords(X,Y) then
+   exit;
+ p := pbyte(CGBitmapContextGetData(offscreen));
+ y:=maxy-y;
+ inc(p,(y*(maxx+1)+x)*4);
+ red:=p^;
+ green:=(p+1)^;
+ blue:=(p+2)^;
+ case maxcolor of
+   16, 256:
+     begin
+       { find closest color using least squares }
+       rsingle:=red/255.0;
+       gsingle:=green/255.0;
+       bsingle:=blue/255.0;
+       closest:=255.0;
+       q_getpixelproc:=0;
+       for count := 0 to maxcolor-1 do
+         begin
+           dist:=sqr(colorpalette[count,1]-rsingle) +
+                sqr(colorpalette[count,2]-gsingle) +
+                sqr(colorpalette[count,3]-bsingle);
+           if (dist < closest) then
+             begin
+               closest:=dist;
+               q_getpixelproc:=count;
+             end;
+         end;
+       exit;
+     end;
+   32678:
+     q_getpixelproc:=((red div 8) shl 7) or ((green div 8) shl 2) or (blue div 8);
+   65536:
+     q_getpixelproc:=((red div 8) shl 8) or ((green div 4) shl 3) or (blue div 8);
+ end;
+end;
+
+procedure q_clrviewproc;
+
+begin
+  q_SetColor(CurrentBkColor);
+  EnterCriticalSection(graphdrawing);
+  CGContextFillRect(offscreen,CGRectMake(StartXViewPort,StartYViewPort,ViewWidth+1,ViewHeight+1));
+  UpdateScreen;
+  LeaveCriticalSection(graphdrawing);
+  { reset coordinates }
+  CurrentX := 0;
+  CurrentY := 0;
+end;
+
+procedure q_putimageproc (X,Y: smallint; var Bitmap; BitBlt: Word);
+begin
+{
+  With TBitMap(BitMap) do
+    gl_putbox(x, y, width, height, @Data);
+}
+end;
+
+procedure q_getimageproc (X1,Y1,X2,Y2: smallint; Var Bitmap);
+begin
+{  with TBitmap(Bitmap) do
+    begin
+    Width := x2 - x1 + 1;
+    Height := y2 - y1 + 1;
+    gl_getbox(x1,y1, x2 - x1 + 1, y2 - y1 + 1, @Data);
+    end;
+}
+end;
+
+{
+function  q_imagesizeproc (X1,Y1,X2,Y2: smallint): longint;
+begin
+ q_imagesizeproc := SizeOf(TBitmap) + (x2 - x1 + 1) * (y2 - y1 + 1) * PhysicalScreen^.BytesPerPixel;
+
+end;
+}
+
+procedure q_lineproc_intern (X1, Y1, X2, Y2 : smallint);
+begin
+  if (CurrentWriteMode in [OrPut,AndPut,XorPut]) then
+    begin
+      LineDefault(X1,Y1,X2,Y2);
+      exit
+    end
+  else
+    begin
+      { Convert to global coordinates. }
+      x1 := x1 + StartXViewPort;
+      x2 := x2 + StartXViewPort;
+      y1 := y1 + StartYViewPort;
+      y2 := y2 + StartYViewPort;
+      if ClipPixels then
+        if LineClipped(x1,y1,x2,y2,StartXViewPort,StartYViewPort,
+                       StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
+           exit;
+      if (CurrentWriteMode = NotPut) then
+        q_SetColor(not(currentcolor))
+      else
+        q_SetColor(currentcolor);
+    end;
+  EnterCriticalSection(graphdrawing);
+  CGContextBeginPath(offscreen);
+  CGContextMoveToPoint(offscreen,x1,y1);
+  CGContextAddLineToPoint(offscreen,x2,y2);
+  CGContextClosePath(offscreen);
+  CGContextStrokePath(offscreen);
+  UpdateScreen;
+  LeaveCriticalSection(graphdrawing);
+end;
+
+
+procedure q_lineproc (X1, Y1, X2, Y2 : smallint);
+begin
+  if (CurrentWriteMode in [OrPut,AndPut,XorPut]) or
+     (lineinfo.LineStyle <> SolidLn) or
+     (lineinfo.Thickness<>NormWidth) then
+    begin
+      LineDefault(X1,Y1,X2,Y2);
+      exit
+    end
+  else
+    begin
+      { Convert to global coordinates. }
+      x1 := x1 + StartXViewPort;
+      x2 := x2 + StartXViewPort;
+      y1 := y1 + StartYViewPort;
+      y2 := y2 + StartYViewPort;
+      if ClipPixels then
+        if LineClipped(x1,y1,x2,y2,StartXViewPort,StartYViewPort,
+                       StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
+           exit;
+      if (CurrentWriteMode = NotPut) then
+        q_SetColor(not(currentcolor))
+      else
+        q_SetColor(currentcolor);
+    end;
+  EnterCriticalSection(graphdrawing);
+  CGContextBeginPath(offscreen);
+  CGContextMoveToPoint(offscreen,x1,y1);
+  CGContextAddLineToPoint(offscreen,x2,y2);
+  CGContextClosePath(offscreen);
+  CGContextStrokePath(offscreen);
+  UpdateScreen;
+  LeaveCriticalSection(graphdrawing);
+end;
+
+
+procedure q_hlineproc (x, x2,y : smallint);
+begin
+  if (CurrentWriteMode in [OrPut,AndPut,XorPut]) then
+    HLineDefault(X,X2,Y)
+  else
+    q_lineproc_intern(x,y,x2,y);
+end;
+
+procedure q_vlineproc (x,y,y2: smallint);
+begin
+  if (CurrentWriteMode in [OrPut,AndPut,XorPut]) then
+    VLineDefault(x,y,y2)
+  else
+    q_lineproc_intern(x,y,x,y2);
+end;
+
+procedure q_patternlineproc (x1,x2,y: smallint);
+begin
+end;
+
+procedure q_ellipseproc  (X,Y: smallint;XRadius: word;
+  YRadius:word; stAngle,EndAngle: word; fp: PatternLineProc);
+begin
+end;
+
+procedure q_getscanlineproc (X1,X2,Y : smallint; var data);
+begin
+end;
+
+procedure q_setactivepageproc (page: word);
+begin
+end;
+
+procedure q_setvisualpageproc (page: word);
+begin
+end;
+
+
+procedure q_savestateproc;
+begin
+end;
+
+procedure q_restorestateproc;
+begin
+end;
+
+procedure q_setrgbpaletteproc(ColorNum, RedValue, GreenValue, BlueValue: smallint);
+begin
+  { vga is only 6 bits per channel, palette values go from 0 to 252 }
+  colorpalette[ColorNum,1]:=RedValue * (1.0/252.0);
+  colorpalette[ColorNum,2]:=GreenValue * (1.0/252.0);
+  colorpalette[ColorNum,3]:=BlueValue * (1.0/252.0);
+end;
+
+procedure q_getrgbpaletteproc (ColorNum: smallint; var RedValue, GreenValue, BlueValue: smallint);
+begin
+  RedValue:=trunc(colorpalette[ColorNum,1]*252.0);
+  GreenValue:=trunc(colorpalette[ColorNum,2]*252.0);
+  BlueValue:=trunc(colorpalette[ColorNum,3]*252.0);
+end;
+
+
+procedure InitColors(nrColors: longint);
+
+var
+  i: smallint;
+begin
+  for i:=0 to nrColors-1 do
+    q_setrgbpaletteproc(I,DefaultColors[i].red,
+      DefaultColors[i].green,DefaultColors[i].blue)
+end;
+
+procedure q_initmodeproc;
+const
+  myHIViewSpec  : EventTypeSpec = (eventClass: kEventClassControl; eventKind: kEventControlDraw);
+var
+ windowAttrs:   WindowAttributes;
+ contentRect:   Rect; 
+ titleKey:      CFStringRef;
+ windowTitle:   CFStringRef; 
+ err:           OSStatus;
+ hiviewbounds : HIRect;
+ b: boolean;
+begin
+  windowAttrs := kWindowStandardDocumentAttributes // 1
+                        or kWindowStandardHandlerAttribute 
+                        or kWindowInWindowMenuAttribute
+                        or kWindowCompositingAttribute
+                        or kWindowLiveResizeAttribute
+                        or kWindowInWindowMenuAttribute
+                        or kWindowNoUpdatesAttribute; 
+
+  SetRect (contentRect, 0,  0,
+                         MaxX+1, MaxY+1);
+  
+  CreateNewWindow (kDocumentWindowClass, windowAttrs,// 3
+                         contentRect, myMainWindow);
+  
+  SetRect (contentRect, 0,  50,
+                         MaxX+1, 51+MaxY);
+  
+  SetWindowBounds(myMainWindow,kWindowContentRgn,contentrect);
+  titleKey    := CFSTR('Graph Window'); // 4
+  windowTitle := CFCopyLocalizedString(titleKey, nil); // 5
+  err := SetWindowTitleWithCFString (myMainWindow, windowTitle); // 6
+  CFRelease (titleKey); // 7
+  CFRelease (windowTitle);
+
+  with contentRect do
+    begin
+      top:=0;
+      left:=0;
+      bottom:=MaxY+1;
+      right:=MaxX+1;
+    end;
+    
+  offscreen:=CreateBitmapContext(MaxX+1,MaxY+1);
+  if (offscreen = nil) then
+    begin
+      _GraphResult:=grNoLoadMem;
+      exit;
+    end;
+  CGContextSetShouldAntialias(offscreen,0);
+
+  if (CreateHIView(myMainWindow,contentRect,graphHIView) <> noErr) then
+    begin
+      DisposeBitmapContext(offscreen);
+      _GraphResult:=grError;
+      exit;
+    end;
+
+
+//   HIViewFindByID( HIViewGetRoot( myMainWindow ), kHIViewWindowContentID, graphHIView );
+
+  if InstallEventHandler (GetControlEventTarget (graphHIView),
+                          NewEventHandlerUPP (@MyDrawEventHandler), 
+                          { GetEventTypeCount (myHIViewSpec)} 1,
+                          @myHIViewSpec, 
+                          pointer(graphHIView),
+                          Nil) <> noErr then
+    begin
+      DisposeWindow(myMainWindow);
+      DisposeBitmapContext(offscreen);
+      _GraphResult:=grError;
+      exit;
+    end;
+
+  LastColor:=-1;
+  if (maxcolor=16) or (maxcolor=256) then
+    InitColors(maxcolor);
+
+  CGContextSetLineWidth(offscreen,1.0);
+
+  { start with a black background }
+  CGContextSetRGBStrokeColor(offscreen,0.0,0.0,0.0,1);
+  CGContextFillRect(offscreen,CGRectMake(0,0,MaxX+1,MaxY+1));
+  HIViewSetNeedsDisplay(graphHIView, true);
+
+  ShowWindow (myMainWindow);  
+
+{
+  write('view is active: ',HIViewIsActive(graphHIView,@b));
+  writeln(', latent: ',b);
+  writeln('compositing enabled: ',HIViewIsCompositingEnabled(graphHIView));
+  writeln('visible before: ',HIViewIsVisible(graphHIView));
+  write('drawing enabled: ',HIViewIsDrawingEnabled(graphHIView));
+  writeln(', latent: ',b);
+  write('view is enabled: ',HIViewIsEnabled(graphHIView,@b));
+  writeln(', latent: ',b);
+
+  err := HIViewGetBounds(graphHIView,hiviewbounds);
+  writeln('err, ',err,' (',hiviewbounds.origin.x:0:2,',',hiviewbounds.origin.y:0:2,'),(',hiviewbounds.size.width:0:2,',',hiviewbounds.size.height:0:2,')');
+}
+end;
+
+
+{************************************************************************}
+{*                       General routines                               *}
+{************************************************************************}
+
+procedure q_donegraph;
+begin
+  If not isgraphmode then
+    begin
+      _graphresult := grnoinitgraph;
+      exit
+    end;
+  RestoreVideoState;
+  DisposeWindow(myMainWindow);
+  DisposeBitmapContext(offscreen);
+  isgraphmode := false;
+end;
+
+
+procedure CloseGraph;
+var
+  event : EventRef;
+  myQueue: EventQueueRef;
+begin
+  if (CreateEvent(nil, kEventClassFPCGraph, kEventCloseGraph, GetCurrentEventTime(), 0, event) <> noErr) then
+    begin
+      _GraphResult:=grError;
+      exit;
+    end;
+
+  myQueue := GetCurrentEventQueue;
+  if (SetEventParameter(event, FOUR_CHAR_CODE('Src '), typeVoidPtr, sizeof(EventQueueRef), @myQueue) <> noErr) then
+    begin
+      ReleaseEvent(event);
+      _GraphResult:=grError;
+    end;
+
+  if (PostEventToQueue(MainEventQueue,event,kEventPriorityStandard) <> noErr) then
+    begin
+      ReleaseEvent(event);
+      _GraphResult:=grError;
+      exit;
+    end;
+    
+  if (ReceiveNextEvent(length(GraphClosedSpec),@GraphClosedSpec,kEventDurationForever,true,event) <> noErr) then
+    runerror(218);
+  ReleaseEvent(event);
+end;
+
+
+procedure SendInitGraph;
+var
+  event : EventRef;
+  myQueue: EventQueueRef;
+begin
+  if (CreateEvent(nil, kEventClassFPCGraph, kEventInitGraph, GetCurrentEventTime(), 0, event) <> noErr) then
+    begin
+      _GraphResult:=grError;
+      exit;
+    end;
+
+  myQueue := GetCurrentEventQueue;
+  if (SetEventParameter(event, FOUR_CHAR_CODE('Src '), typeVoidPtr, sizeof(EventQueueRef), @myQueue) <> noErr) then
+    begin
+      ReleaseEvent(event);
+      _GraphResult:=grError;
+      exit;
+    end;
+
+  if (PostEventToQueue(MainEventQueue,event,kEventPriorityStandard) <> noErr) then
+    begin
+      ReleaseEvent(event);
+      _GraphResult:=grError;
+      exit;
+    end;
+
+  if (ReceiveNextEvent(length(GraphInitedSpec),@GraphInitedSpec,kEventDurationForever,true,event) <> noErr) then
+    runerror(218);
+  ReleaseEvent(event);
+end;
+
+
+  function QueryAdapterInfo:PModeInfo;
+  { This routine returns the head pointer to the list }
+  { of supported graphics modes.                      }
+  { Returns nil if no graphics mode supported.        }
+  { This list is READ ONLY!                           }
+   var
+    mode: TModeInfo;
+    i : longint;
+
+   begin
+     QueryAdapterInfo := ModeList;
+     { If the mode listing already exists... }
+     { simply return it, without changing    }
+     { anything...                           }
+     if assigned(ModeList) then
+       exit;
+     SaveVideoState:=@q_savevideostate;
+     RestoreVideoState:=@q_restorevideostate;
+//     For I:=0 to GLastMode do
+     i := 10;
+       begin
+         begin
+         InitMode(Mode);
+         With Mode do
+           begin
+           ModeNumber:=I;
+           ModeName:=ModeNames[i];
+           // Pretend we are VGA always.
+           DriverNumber := VGA;
+           // MaxX is number of pixels in X direction - 1
+           MaxX:=640-1;
+           // same for MaxY
+           MaxY:=480-1;
+           YAspect:=10000;
+           if ((MaxX+1)*35=(MaxY+1)*64) then
+             XAspect:=7750
+           else if ((MaxX+1)*20=(MaxY+1)*64) then
+             XAspect:=4500
+           else if ((MaxX+1)*40=(MaxY+1)*64) then
+             XAspect:=8333
+           else { assume 4:3 }
+             XAspect:=10000;
+           MaxColor := 256;
+           PaletteSize := MaxColor;
+           HardwarePages := 0;
+           // necessary hooks ...
+           DirectPutPixel := @q_DirectPixelProc;
+           GetPixel       := @q_GetPixelProc;
+           PutPixel       := @q_PutPixelProc;
+           { May be implemented later: }
+           HLine          := @q_HLineProc;
+           VLine          := @q_VLineProc;
+{           GetScanLine    := @q_GetScanLineProc;}
+           ClearViewPort  := @q_ClrViewProc;
+           SetRGBPalette  := @q_SetRGBPaletteProc;
+           GetRGBPalette  := @q_GetRGBPaletteProc;
+           { These are not really implemented yet:
+           PutImage       := @q_PutImageProc;
+           GetImage       := @q_GetImageProc;}
+{          If you use the default getimage/putimage, you also need the default
+           imagesize! (JM)
+            ImageSize      := @q_ImageSizeProc; }
+           { Add later maybe ?
+           SetVisualPage  := SetVisualPageProc;
+           SetActivePage  := SetActivePageProc; }
+           Line           := @q_LineProc;
+{
+           InternalEllipse:= @q_EllipseProc;
+           PatternLine    := @q_PatternLineProc;
+           }
+           InitMode       := @SendInitGraph;
+           end;
+         AddMode(Mode);
+         end;
+       end;
+   end;
+
+
+{ ************************************************* }
+
+function GraphEventHandler (myHandler: EventHandlerCallRef; 
+                        event: EventRef; userData: pointer): OSStatus; mwpascal;
+var
+  source: EventQueueRef;
+  newEvent: EventRef;
+begin
+//  writeln('in GraphEventHandler, event: ',FourCharArray(GetEventKind(event)));
+  newEvent := nil;
+  case GetEventKind(event) of
+    kEventInitGraph:
+      begin
+        q_initmodeproc;
+        if (GetEventParameter(event,FOUR_CHAR_CODE('Src '), typeVoidPtr, nil, sizeof(EventQueueRef), nil, @source) <> noErr) then
+          runerror(218);
+        if (CreateEvent(nil, kEventClassFPCGraph, kEventGraphInited, GetCurrentEventTime(), 0, newEvent) <> noErr) then
+          runerror(218);
+      end;
+    kEventCloseGraph:
+      begin
+        q_donegraph;
+        if (GetEventParameter(event,FOUR_CHAR_CODE('Src '), typeVoidPtr, nil, sizeof(EventQueueRef), nil, @source) <> noErr) then
+          runerror(218);
+        if (CreateEvent(nil, kEventClassFPCGraph, kEventGraphClosed, GetCurrentEventTime(), 0, newEvent) <> noErr) then
+          runerror(218);
+      end;
+    kEventFlush:
+      begin
+        HIViewSetNeedsDisplay(graphHIView, true);
+      end;
+    kEventQuit:
+      begin
+        QuitApplicationEventLoop;
+      end;
+  end;
+  if assigned(newEvent) then
+    if PostEventToQueue(source,newEvent,kEventPriorityStandard) <> noErr then
+      runerror(218);
+  GraphEventHandler := noErr;
+  ReleaseEvent(event);
+end;
+
+
+var
+  proctorun: TGraphProgram;
+   
+function wrapper(p: pointer): longint;
+(*
+  var
+    event : EventRef;
+*)
+  begin 
+    wrapper:=proctorun(nil);
+    halt(wrapper);
+(*
+    if (CreateEvent(nil, kEventClassFPCGraph, kEventQuit, GetCurrentEventTime(), 0, event) <> noErr) then
+      exit;
+
+    if (PostEventToQueue(MainEventQueue,event,kEventPriorityLow) <> noErr) then
+      begin
+        ReleaseEvent(event);
+        halt(wrapper);
+      end;
+*)
+  end;
+
+
+procedure StartGraphProgram(p: TGraphProgram);
+  var
+    taskid: mptaskid;
+    eventRec: eventrecord;
+  begin
+    if InstallEventHandler (GetApplicationEventTarget,
+                            NewEventHandlerUPP (@GraphEventHandler), 
+                            length(allGraphSpec),
+                            @allGraphSpec, 
+                            nil,
+                            nil) <> noErr then
+      begin
+        _GraphResult:=grError;
+        exit;
+      end;
+  
+    proctorun:=p;
+     
+    { main program has to be the first one to access the event queue, see }
+    { http://lists.apple.com/archives/carbon-dev/2007/Jun/msg00612.html   }
+    eventavail(0,eventRec);
+    maineventqueue:=GetMainEventQueue;
+    BeginThread(@wrapper);
+    RunApplicationEventLoop;
+  end;
+
+
+initialization
+  initcriticalsection(graphdrawing);
+  InitializeGraph;
+finalization
+  donecriticalsection(graphdrawing);
+end.

+ 537 - 0
packages/extra/graph/ptcgraph.pp

@@ -0,0 +1,537 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2007 by Daniel Mantione
+      member of the Free Pascal development team
+
+    This file implements the PTC support for the graph unit
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    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.
+
+ **********************************************************************}
+unit ptcgraph;
+
+{$define logging}
+
+{******************************************************************************}
+                                    interface
+{******************************************************************************}
+
+{$i graphh.inc}
+
+{Driver number for PTC.}
+const	PTC=22;
+
+{******************************************************************************}
+                                 implementation
+{******************************************************************************}
+
+uses
+  termio,x86,ptc;
+
+const
+  InternalDriverName = 'PTCPas';
+
+{$i graph.inc}
+
+  type
+    PByte = ^Byte;
+    PLongInt = ^LongInt;
+
+    PByteArray = ^TByteArray;
+    TByteArray = array [0..MAXINT - 1] of Byte;
+
+
+
+{ ---------------------------------------------------------------------
+   SVGA bindings.
+
+  ---------------------------------------------------------------------}
+
+Const
+  { Text }
+
+  WRITEMODE_OVERWRITE = 0;
+  WRITEMODE_MASKED    = 1;
+  FONT_EXPANDED       = 0;
+  FONT_COMPRESSED     = 2;
+
+ { Types }
+ type
+   pvga_modeinfo = ^vga_modeinfo;
+   vga_modeinfo = record
+     width,
+     height,
+     bytesperpixel,
+     colors,
+     linewidth,          { scanline width in bytes }
+     maxlogicalwidth,    { maximum logical scanline width }
+     startaddressrange,  { changeable bits set }
+     maxpixels,          { video memory / bytesperpixel }
+     haveblit,           { mask of blit functions available }
+     flags: Longint;     { other flags }
+    { Extended fields: }
+     chiptype,           { Chiptype detected }
+     memory,             { videomemory in KB }
+     linewidth_unit: Longint;    { Use only a multiple of this as parameter for                                   set_displaystart }
+     linear_aperture: PChar;     { points to mmap secondary mem aperture of card }
+     aperture_size: Longint;     { size of aperture in KB if size>=videomemory.}
+
+     set_aperture_page: procedure (page: Longint);
+            { if aperture_size<videomemory select a memory page }
+     extensions: Pointer;        { points to copy of eeprom for mach32 }
+            { depends from actual driver/chiptype.. etc. }
+     end;
+
+  PGraphicsContext = ^TGraphicsContext;
+  TGraphicsContext = record
+                       ModeType: Byte;
+                       ModeFlags: Byte;
+                       Dummy: Byte;
+                       FlipPage: Byte;
+                       Width: LongInt;
+                       Height: LongInt;
+                       BytesPerPixel: LongInt;
+                       Colors: LongInt;
+                       BitsPerPixel: LongInt;
+                       ByteWidth: LongInt;
+                       VBuf: pointer;
+                       Clip: LongInt;
+                       ClipX1: LongInt;
+                       ClipY1: LongInt;
+                       ClipX2: LongInt;
+                       ClipY2: LongInt;
+                       ff: pointer;
+                     end;
+
+var
+  OldIO : TermIos;
+
+  ptcconsole:TPTCconsole;
+  ptcsurface:TPTCSurface;
+  ptcformat:TPTCFormat;
+
+Procedure SetRawMode(b:boolean);
+Var
+  Tio : Termios;
+Begin
+  if b then
+   begin
+     TCGetAttr(1,Tio);
+     OldIO:=Tio;
+     CFMakeRaw(Tio);
+   end
+  else
+   Tio:=OldIO;
+  TCSetAttr(1,TCSANOW,Tio);
+End;
+
+
+{ ---------------------------------------------------------------------
+    Required procedures
+  ---------------------------------------------------------------------}
+
+var
+  LastColor: smallint;   {Cache the last set color to improve speed}
+
+
+procedure ptc_savevideostate;
+begin
+end;
+
+procedure ptc_restorevideostate;
+begin
+{  vga_setmode(0);}
+end;
+
+{
+const
+  BgiColors: array[0..15] of LongInt
+    = ($000000, $000020, $002000, $002020,
+       $200000, $200020, $202000, $303030,
+       $202020, $00003F, $003F00, $003F3F,
+       $3F0000, $3F003F, $3F3F00, $3F3F3F);
+}
+
+procedure InitColors(nrColors: longint);
+
+var
+  i: smallint;
+begin
+{  for i:=0 to nrColors do
+    vga_setpalette(I,DefaultColors[i].red shr 2,
+      DefaultColors[i].green shr 2,DefaultColors[i].blue shr 2)}
+end;
+
+procedure ptc_initmodeproc;
+
+begin
+  writeln('Initializing mode');
+  { create format }
+  ptcformat:=TPTCFormat.Create(16,$f800,$07e0,$001f);
+  { open the console }
+  ptcconsole.open(paramstr(0),ptcformat);
+  { create surface matching console dimensions }
+  ptcsurface:=TPTCSurface.Create(ptcconsole.width,ptcconsole.height,ptcformat);
+end;
+
+Function ClipCoords (Var X,Y : smallint) : Boolean;
+{ Adapt to viewport, return TRUE if still in viewport,
+  false if outside viewport}
+
+begin
+  X:= X + StartXViewPort;
+  Y:= Y + StartYViewPort;
+  ClipCoords:=Not ClipPixels;
+  if ClipPixels then
+    Begin
+    ClipCoords:=(X < StartXViewPort) or (X > (StartXViewPort + ViewWidth));
+    ClipCoords:=ClipCoords or
+               ((Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)));
+    ClipCoords:=Not ClipCoords;
+    end;
+end;
+
+
+procedure ptc_directpixelproc_16bpp(X,Y: smallint);
+
+var color:word;
+    pixels:Pword;
+
+begin
+  case CurrentWriteMode of
+    XORPut:
+      begin
+      { getpixel wants local/relative coordinates }
+      Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+      Color := CurrentColor Xor Color;
+      end;
+    OrPut:
+      begin
+      { getpixel wants local/relative coordinates }
+      Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+      Color := CurrentColor Or Color;
+      end;
+    AndPut:
+      begin
+      { getpixel wants local/relative coordinates }
+      Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+      Color := CurrentColor And Color;
+      end;
+    NotPut:
+      begin
+      Color := Not Color;
+      end
+  else
+    Color:=CurrentColor;
+  end;
+  pixels:=ptcsurface.lock;
+  {Plot the pixel on the surface.}
+  pixels[x+y*ptcsurface.width]:=color;
+  ptcsurface.unlock;
+  { copy to console }
+  ptcsurface.copy(ptcconsole);
+  { update console }
+  ptcconsole.update;
+end;
+
+procedure ptc_putpixelproc_16bpp(X,Y:smallint;Color:Word);
+
+var pixels:Pword;
+
+begin
+  if clipcoords(X,Y) then
+    begin
+      pixels:=ptcsurface.lock;
+{      pixels:=ptcconsole.lock;}
+      {Plot the pixel on the surface.}
+      pixels[x+y*ptcsurface.width]:=color;
+      ptcsurface.unlock;
+      { copy to console }
+      ptcsurface.copy(ptcconsole);
+      { update console }
+      ptcconsole.update;
+    end;
+end;
+
+function ptc_getpixelproc_16bpp(X,Y: smallint):word;
+
+var pixels:Pword;
+
+begin
+  if clipcoords(X,Y) then
+    begin
+      pixels:=ptcsurface.lock;
+      {Get the pixel from the surface.}
+      ptc_getpixelproc_16bpp:=pixels[x+y*ptcsurface.width];
+      ptcsurface.unlock;
+    end;
+end;
+
+
+{ Bitmap utilities }
+{type
+  PBitmap = ^TBitmap;
+  TBitmap = record
+            Width, Height: smallint;
+            Data: record end;
+            end;
+}
+
+procedure ptc_putimageproc (X,Y: smallint; var Bitmap; BitBlt: Word);
+begin
+end;
+
+procedure ptc_getimageproc (X1,Y1,X2,Y2: smallint; Var Bitmap);
+begin
+end;
+
+function  ptc_imagesizeproc (X1,Y1,X2,Y2: smallint): longint;
+begin
+end;
+
+procedure ptc_hlineproc_16bpp(x, x2,y : smallint);
+
+var pixels:Pword;
+    i:word;
+
+begin
+  {Clip.}
+  if (y<0) or (y>viewheight) then
+    exit;
+  if x<0 then
+    x:=0;
+  if x>viewwidth then
+    x:=viewwidth;
+  if x2<0 then
+    x2:=0;
+  if x>viewwidth then
+    x2:=viewwidth;
+  pixels:=ptcsurface.lock;
+  inc(x,StartXViewPort);
+  inc(x2,StartXViewPort);
+  inc(y,StartXViewPort);
+  {Plot the pixel on the surface.}
+  for i:=x to x2 do
+    pixels[i+y*ptcsurface.width]:=$ffff;
+  ptcsurface.unlock;
+  { copy to console }
+  ptcsurface.copy(ptcconsole);
+  { update console }
+  ptcconsole.update;
+end;
+
+procedure ptc_vlineproc (x,y,y2: smallint);
+begin
+end;
+
+procedure ptc_clrviewproc_16bpp;
+
+Var I,Xmax : longint;
+
+begin
+  Xmax:=StartXViewPort+ViewWidth-1;
+  For i:=StartYViewPort to StartYViewPort+ViewHeight-1 do
+    ptc_hlineproc_16bpp(0,viewwidth,i);
+  { reset coordinates }
+  CurrentX := 0;
+  CurrentY := 0;
+end;
+
+procedure ptc_patternlineproc (x1,x2,y: smallint);
+begin
+end;
+
+procedure ptc_ellipseproc  (X,Y: smallint;XRadius: word;
+  YRadius:word; stAngle,EndAngle: word; fp: PatternLineProc);
+begin
+end;
+
+procedure ptc_lineproc (X1, Y1, X2, Y2 : smallint);
+begin
+end;
+
+procedure ptc_getscanlineproc (X1,X2,Y : smallint; var data);
+begin
+end;
+
+procedure ptc_setactivepageproc (page: word);
+begin
+end;
+
+procedure ptc_setvisualpageproc (page: word);
+begin
+end;
+
+
+procedure ptc_savestateproc;
+begin
+end;
+
+procedure ptc_restorestateproc;
+begin
+end;
+
+procedure ptc_setrgbpaletteproc(ColorNum, RedValue, GreenValue, BlueValue: smallint);
+begin
+{  vga_setpalette(ColorNum,RedValue shr 2,GreenValue shr 2,BlueValue shr 2);}
+end;
+
+procedure ptc_getrgbpaletteproc (ColorNum: smallint;
+                                    var RedValue, GreenValue, BlueValue: smallint);
+
+Var R,G,B : longint;
+
+begin
+{  vga_getpalette(ColorNum,R,G,B);}
+  RedValue:=R * 255 div 63;
+  GreenValue:=G * 255 div 63;
+  BlueValue:=B * 255 div 63;
+end;
+
+{************************************************************************}
+{*                       General routines                               *}
+{************************************************************************}
+
+ procedure CloseGraph;
+ Begin
+    If not isgraphmode then
+      begin
+        _graphresult := grnoinitgraph;
+        exit
+      end;
+    SetRawMode(False);
+    RestoreVideoState;
+    isgraphmode := false;
+ end;
+
+  function QueryAdapterInfo:PModeInfo;
+  { This routine returns the head pointer to the list }
+  { of supported graphics modes.                      }
+  { Returns nil if no graphics mode supported.        }
+  { This list is READ ONLY!                           }
+   var
+    graphmode:Tmodeinfo;
+    ptcmode: PPTCmode;
+    d,i : longint;
+    ws,hs:string[5];
+
+   const depths:array[0..3] of byte=(8,16,24,32);
+         colours:array[0..3] of longint=(256,65536,16777216,16777216);
+         depth_names:array[0..3] of string[5]=('256','64K','16M','16M32');
+
+   begin
+     QueryAdapterInfo := ModeList;
+     { If the mode listing already exists... }
+     { simply return it, without changing    }
+     { anything...                           }
+     if assigned(ModeList) then
+       exit;
+     SaveVideoState:=@ptc_savevideostate;
+     RestoreVideoState:=@ptc_restorevideostate;
+     ptcconsole:=TPTCconsole.create;
+     ptcmode:=ptcconsole.modes;
+     i:=0;
+     initmode(graphmode);
+     with graphmode do
+       begin
+         modenumber:=0;
+         drivernumber:=ptcgraph.ptc;
+         maxx:=639;
+         maxy:=479;
+         modename:='PTC_640x480x64K';
+         maxcolor:=65536;
+         palettesize:=65536;
+         hardwarepages:=0;
+         InitMode       := @ptc_InitModeProc;
+         DirectPutPixel := @ptc_DirectPixelProc_16bpp;
+         GetPixel       := @ptc_GetPixelProc_16bpp;
+         PutPixel       := @ptc_PutPixelProc_16bpp;
+         SetRGBPalette  := @ptc_SetRGBPaletteProc;
+         GetRGBPalette  := @ptc_GetRGBPaletteProc;
+       end;
+     addmode(graphmode);
+(*
+     writeln('processing modes');
+     while ptcmode^.valid do
+       begin
+         for d:=low(depths) to high(depths) do
+           begin
+             InitMode(graphmode);
+             with graphmode do
+               begin
+                 ModeNumber:=I;
+                 DriverNumber:=ptcgraph.PTC;
+                 { MaxX is number of pixels in X direction - 1}
+                 MaxX:=ptcmode^.width-1;
+                 { same for MaxY}
+                 MaxY:=ptcmode^.height-1;
+                 str(ptcmode^.width,ws);
+                 str(ptcmode^.height,hs);
+                 modename:='PTC_'+ws+'x'+hs+'x'+depth_names[d];
+                 MaxColor := 1 shl ptcmode^.format.r * 1 shl ptcmode^.format.g *1 shl ptcmode^.format.b;
+                 writeln('mode ',modename,' ',maxcolor,'kleuren');
+                 PaletteSize := MaxColor;
+                 HardwarePages := 0;
+*)
+                 { necessary hooks ...}
+(*
+                 if (MaxColor = 16) and
+                   (LongInt(ModeInfo.Width) * LongInt(ModeInfo.Height) < 65536*4*2) then
+                  begin
+                   {Use optimized graphics routines for 4 bit EGA/VGA modes.}
+                   ScrWidth := ModeInfo.Width div 8;
+                   DirectPutPixel := @DirectPutPixel16;
+                   PutPixel := @PutPixel16;
+                   GetPixel := @GetPixel16;
+                   HLine := @HLine16;
+                   VLine := @VLine16;
+                   GetScanLine := @GetScanLine16;
+                 end
+               else
+*)
+(*
+                 begin
+                   DirectPutPixel := @ptc_DirectPixelProc;
+                   GetPixel       := @ptc_GetPixelProc;
+                   PutPixel       := @ptc_PutPixelProc;
+                   { May be implemented later:
+                   HLine          := @libvga_HLineProc;
+                   VLine          := @libvga_VLineProc;
+                   GetScanLine    := @libvga_GetScanLineProc;}
+                   ClearViewPort  := @ptc_ClrViewProc;
+                 end;
+                 SetRGBPalette  := @ptc_SetRGBPaletteProc;
+                 GetRGBPalette  := @ptc_GetRGBPaletteProc;
+                 { These are not really implemented yet:
+                 PutImage       := @libvga_PutImageProc;
+                 GetImage       := @libvga_GetImageProc;}
+{                If you use the default getimage/putimage, you also need the default
+                 imagesize! (JM)
+                 ImageSize      := @libvga_ImageSizeProc; }
+                 { Add later maybe ?
+                 SetVisualPage  := SetVisualPageProc;
+                 SetActivePage  := SetActivePageProc;
+                 Line           := @libvga_LineProc;
+                 InternalEllipse:= @libvga_EllipseProc;
+                 PatternLine    := @libvga_PatternLineProc;
+                 }
+                 InitMode       := @ptc_InitModeProc;
+               end;
+           AddMode(graphmode);
+           inc(i);
+         end;
+     end;
+*)
+  end;
+
+initialization
+  ptcconsole:=TPTCconsole.create;
+  InitializeGraph;
+finalization
+  ptcconsole.destroy;
+end.

+ 954 - 0
packages/extra/graph/sdlgraph/sdlgraph.pp

@@ -0,0 +1,954 @@
+{**************************************************************************
+    Copyright            : (c) 2007 Evgeniy Ivanov
+    email                : [email protected]
+    http                 : Not yet
+****************************************************************************/
+
+    This file implements the sdl support for the graph unit
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    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.
+****************************************************************************}
+
+
+
+{Important TODO list
+
+TODO: color conversion. from pascal color constant to color (pixel) from SDL_putpixel. At this moment you may gent another colors than you're waiting for. The worsest thing is it may be black on the black
+
+TODO: check all mode.HardwarePages and find true value for each mode!
+
+TODO: check initgraph(0,0,' ') and work with modes to set up best SDL mode. 
+Maybe to hook internDetectGraph and detectGraph. I thing they are not needed for sdlgraph
+
+TODO: check VESA modes ModeNumber (if they needed)
+}
+
+
+
+
+{ Programming Notes
+TODO: (it's a linux note, I haven't yet tested it on other systems) When SDL window is activated from the terminal readln does'n work!!! And when from KDE it autocloses without waiting readln input. I think that there must be a hook for readln while sdlgraph is active
+
+TODO: setcaption for the programme. There is no such procedure in Graph unit so we should add it or use setcaption with default (prograamme's name)
+
+TODO: to not forget about rgb_from_color's RGB values. Now they are just for testing!!!
+
+TODO: configure refresh (flip) time. SDL_AddTimer(100...: time interval must be the same as monitor vertical refresh.
+
+}
+
+
+unit sdlgraph;
+
+{$ifdef darwin}
+{$linkframework Cocoa}
+{$linklib SDLmain}
+{$linklib gcc}
+{$endif}
+
+interface
+//procedure sdlgraph_bar3D(x1, y1, x2, y2 : smallint;depth : word;top : boolean);
+{$i graphh.inc}
+
+const
+
+{==================================================================================================================================================
+Graphics Drivers Constants. Needed to support turbo pascale code  TODO: is it needed???
+It's highly recommended to use Detect (0 constant) for grDriver and grmode: initGraph(0,0,' ') to allow SDL to configure app for the best perfomance
+====================================================================================================================================================
+}
+
+ //Detect      =0;     is in the graphh.inc
+ CGA           =1;
+ MCGA	       =2;
+ EGA           =3;
+ EGA64         =4;
+ EGAMono       =5;
+ IBM8514       =6;
+ //HercMono      =7;   is in the graphh.inc
+ ATT400        =8;
+ //VGA           =9;   is in graphh.inc
+ PC3270        =10;
+
+{Graphics Modes for Each Driver}
+ CGAC0         =0;
+ CGAC          =1;
+ CGAC2         =2;
+ CGAC3         =3;
+ CGAHi         =4;
+ 
+ MCGAC0        =0;
+ MCGAC         =1;
+ MCGAC2        =2;
+ MCGAC3        =3;
+ MCGAMed       =4;
+ MCGAHi        =5;
+ 
+ EGAMonoHi     =3;
+ //HercMonoHi    =0;      is in the graphh.inc
+ //VGALo         =0;      is in the graphh.inc
+ //VGAMed        =1;      is in the graphh.inc
+ //VGAHi         =2;      is in the graphh.inc
+ 
+ EGALo         =0;
+ EGAHi         =1;
+ EGA64Lo       =0;
+ EGA64Hi       =1;
+ 
+ ATT400C0      =0;
+ ATT400C1      =1;
+ ATT400C2      =2;
+ ATT400C3      =3;
+ ATT400CMed    =4;
+ ATT400Hi      =5;
+ 
+ IBM8514Lo     =0;
+ IBM8514Hi     =1;
+ 
+ PC3270Hi      =0;
+
+{ From *Go32* VESA Specific video modes. }
+  m320x200x32k      = $10D;
+  m320x200x64k      = $10E;
+
+  m640x400x256      = $100;
+
+  m640x480x256      = $101;
+  m640x480x32k      = $110;
+  m640x480x64k      = $111;
+
+  m800x600x16       = $102;
+  m800x600x256      = $103;
+  m800x600x32k      = $113;
+  m800x600x64k      = $114;
+
+  m1024x768x16      = $104;
+  m1024x768x256     = $105;
+  m1024x768x32k     = $116;
+  m1024x768x64k     = $117;
+
+  m1280x1024x16     = $106;
+  m1280x1024x256    = $107;
+  m1280x1024x32k    = $119;
+  m1280x1024x64k    = $11A;
+implementation
+
+uses {$ifdef unix}cthreads,{$endif}
+   sdl,sdlutils,
+          logger,
+          SysUtils;
+
+const
+  InternalDriverName = 'SDL';
+
+{$define sdlgraph}
+
+{$i graph.inc}
+
+var
+screen: PSDL_Surface; //Global becouse its value is needed by some functions
+
+
+
+procedure CloseGraph;
+begin
+ If not isgraphmode then
+ begin
+  _graphresult := grnoinitgraph;
+ exit;
+ end;
+   isgraphmode := false;
+   SDL_Quit();
+ //Halt(0);   TODO: check, if it close application wich calls sdlgraph
+end;
+
+
+procedure Slock;
+begin
+  if SDL_MUSTLOCK(screen) then
+    if SDL_LockSurface(screen) < 0 then
+          begin
+          Log.LogError( Format( 'Cant lock screen: : %s', [SDL_GetError]), 'Slock' );
+          CloseGraph;
+          end;
+end;
+
+
+function timer_flip(flip_interval:Uint32; flip_callback_param:Pointer):Uint32;
+begin
+SDL_Flip(screen);
+timer_flip:=flip_interval;
+exit;
+end;
+
+
+{
+procedure Slock;
+begin
+  if SDL_MUSTLOCK(screen) then
+    if SDL_LockSurface(screen) < 0 then
+          begin
+          Log.LogError( Format( 'Cant lock screen: : %s', [SDL_GetError]), 'Slock' );
+          CloseGraph;
+          end;
+end;
+
+
+procedure Sulock; //Unlock and flip the surface
+begin
+  if SDL_MUSTLOCK(screen) then 
+    SDL_UnlockSurface(screen);
+  SDL_Flip(screen);
+
+end;
+
+}
+
+
+
+{PutPixel and GetPixel use SDL_* functions from sdlutils unit.}
+
+procedure sdlgraph_PutPixel(X,Y:smallint; color: Word);
+begin
+ X:= X + StartXViewPort;
+ Y:= Y + StartYViewPort;
+
+{ convert to absolute coordinates and then verify clipping...}
+ if ClipPixels then
+   begin
+   if (X < StartXViewPort) or (X > (StartXViewPort + ViewWidth)) then
+          exit;
+   if (Y < StartYViewPort) or (Y > (StartYViewPort + ViewHeight)) then
+          exit;
+   end;
+ SDL_PutPixel(screen,x,y,255);
+ exit;
+
+end;
+
+
+
+function sdlgraph_GetPixel(X,Y:smallint):Word;
+var
+temp:word;
+begin
+ X:= X + StartXViewPort;
+ Y:= Y + StartYViewPort;
+ temp:=word(SDL_GetPixel(screen,x,y));
+ sdlgraph_GetPixel:=temp;
+ exit;
+end;
+
+
+procedure sdlgraph_DirectPutPixel(X,Y: smallint);
+var
+Color: word;
+begin
+
+    case CurrentWriteMode of
+      XORPut:
+        begin
+{ getpixel wants local/relative coordinates }
+          Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+          Color := CurrentColor Xor Color;
+        end;
+      OrPut:
+        begin
+{ getpixel wants local/relative coordinates }
+          Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+          Color := CurrentColor Or Color;
+        end;
+      AndPut:
+        begin
+{ getpixel wants local/relative coordinates }
+          Color := GetPixel(x-StartXViewPort,y-StartYViewPort);
+          Color := CurrentColor And Color;
+        end;
+      NotPut:
+        begin
+          Color := (Not CurrentColor) and 15;
+        end
+      else
+        Color := CurrentColor;
+   end;
+
+sdlgraph_PutPixel(X,Y,Color);
+
+exit;
+end;
+
+
+{
+procedure nonBuf_DirectPutPixel(X,Y: smallint);   // for HLine and other such hooks. It doesn't use buffering (SLock & Sulock routines).
+begin
+  CurrentColor:=255;
+  SDL_PutPixel(screen,x,y,CurrentColor);
+exit;
+end;
+
+
+procedure sdlgraph_HLine(x,x2,y: smallint);
+var
+temp:DefPixelProc;
+begin
+ HLineDefault(x,x2,y);
+ //SDL_DrawLine(screen,X,y,x2,y,255);
+end;
+
+procedure sdlgraph_VLine(x,y,y2:smallint);
+var
+temp:DefPixelProc;
+begin
+VLineDefault(x,y,y2);
+end;
+
+
+
+procedure sdlgraph_line(X1, Y1, X2, Y2: smallint);
+var
+temp:DefPixelProc;
+begin
+ LineDefault(X1, Y1, X2, Y2);
+ //SDL_DrawLine(screen,X1,y1,x2,y2,255);
+end;
+}
+
+{
+procedure nonBuf_HLine(x,x2,y: smallint);
+var
+temp:DefPixelProc;
+begin
+ temp:=DirectPutPixel;
+ DirectPutPixel:=@nonBuf_DirectPutPixel;
+ HLineDefault(x,x2,y);
+ DirectPutPixel:=temp;
+end;
+
+procedure nonBuf_VLine(x,y,y2:smallint);
+var
+temp:DefPixelProc;
+begin
+ temp:=DirectPutPixel;
+ DirectPutPixel:=@nonBuf_DirectPutPixel;
+ VLineDefault(x,y,y2);
+ DirectPutPixel:=temp;
+end;
+}
+
+
+{
+procedure nonBuf_line(X1, Y1, X2, Y2: smallint);
+var
+temp:DefPixelProc;
+begin
+ temp:=DirectPutPixel;
+ DirectPutPixel:=@nonBuf_DirectPutPixel;
+ LineDefault(X1, Y1, X2, Y2);
+ DirectPutPixel:=temp;
+end;
+}
+
+{
+procedure sdlgraph_InternalEllipse(X,Y: smallint;XRadius: word;
+    YRadius:word; stAngle,EndAngle: word; pl: PatternLineProc);
+var
+temp:PutPixelProc;
+begin
+ InternalEllipseDefault(X,Y,XRadius,YRadius,stAngle,EndAngle,pl);
+end;
+}
+
+
+procedure InitSDLgraph(Width,Height,BPP:Integer);
+var
+ videoflags : Uint32;
+ videoInfo : PSDL_VideoInfo;
+ 
+ flip_callback_param:Pointer;
+ flip_timer_id:PSDL_TimerID;
+begin
+  if ( SDL_Init( SDL_INIT_TIMER or SDL_INIT_VIDEO ) < 0 ) then
+  begin
+    Log.LogError( Format( 'Could not initialize SDL : %s', [SDL_GetError] ), 'InitSDLgraph' );
+    exit;
+  end;
+
+
+  // Fetch the video info 
+  videoInfo := SDL_GetVideoInfo;
+
+  if ( videoInfo = nil ) then
+  begin
+    Log.LogError( Format( 'Video query failed : %s', [SDL_GetError] ), 'InitSDLgraph' );
+    CloseGraph;
+    exit;
+  end;
+
+
+  // the flags to pass to SDL_SetVideoMode 
+  videoFlags := SDL_DOUBLEBUF; // Enable double buffering 
+  videoFlags := videoFlags or SDL_HWPALETTE; // Store the palette in hardware 
+
+  // This checks to see if surfaces can be stored in memory 
+ if  videoInfo^.hw_available <> 0  then
+    videoFlags := videoFlags or SDL_HWSURFACE
+  else
+    videoFlags := videoFlags or SDL_SWSURFACE;
+
+  // This checks if hardware blits can be done * /
+  if videoInfo^.blit_hw <> 0 then
+    videoFlags := videoFlags or SDL_HWACCEL;
+  videoflags := videoFlags or SDL_RESIZABLE;    // Enable window resizing    TODO: Do we want to have it in graph module?
+
+
+  if (SDL_VideoModeOK(Width,Height,BPP,videoFlags) = 0) then
+     begin
+     //TODO: create 1 string from parametres!
+     //Log.LogError('InitSDLgraph: ',Width,'x',Height,'x',BPP,' - no such mode (also you may check videoflags in the sdlgraph unit (procedure InitSDLgraph)');
+     exit;
+     end;
+
+  screen := SDL_SetVideoMode(Width, Height, BPP, SDL_SWSURFACE );   // TODO: use videoflags but not SDL_SWSURFACE!
+    
+//It doesn't work yet!
+{if ( surface = nil ) then
+  begin
+    Log.LogError( Format( 'Unable to SetVideMode : %s', [SDL_GetError]), 'InitSDLgraph' );
+    InitSDLgraph:=false;
+    exit;
+    CloseGraph;
+  end;}
+
+
+flip_timer_id := SDL_AddTimer(100,TSDL_NewTimerCallback( @timer_flip ), nil ); //TODO: time interval must be the same as monitor vertical refresh
+end;
+
+procedure sdlgraph_Init1280x1024x64k;
+begin
+ InitSDLgraph(1280,1024,16);
+end;
+
+
+procedure sdlgraph_Init1280x1024x32k;
+begin
+ InitSDLgraph(1280,1024,15);   //TODO: maybe to set 16 bit??? It's about all 15bpp modes.
+end;
+
+procedure sdlgraph_Init1280x1024x256;
+begin
+ InitSDLgraph(1280,1024,8);
+end;
+
+procedure sdlgraph_Init1280x1024x16;
+begin
+ InitSDLgraph(1280,1024,4);
+end;
+
+procedure sdlgraph_Init1024x768x64k;
+begin
+ InitSDLgraph(1024,768,16);
+end;
+
+procedure sdlgraph_Init640x480x32k;
+begin
+ InitSDLgraph(640,480,15);
+end;
+
+procedure sdlgraph_Init1024x768x256;
+begin
+ InitSDLgraph(1024,768,8);
+end;
+
+procedure sdlgraph_Init1024x768x16;
+begin
+ InitSDLgraph(1024,768,4);
+end;
+
+procedure sdlgraph_Init800x600x64k;
+begin
+ InitSDLgraph(800,600,16);
+end;
+
+procedure sdlgraph_Init800x600x32k;
+begin
+ InitSDLgraph(800,600,15);
+end;
+
+procedure sdlgraph_Init800x600x256;
+begin
+ InitSDLgraph(800,600,8);
+end;
+
+procedure sdlgraph_Init800x600x16;
+begin
+ InitSDLgraph(800,600,4);
+end;
+
+procedure sdlgraph_Init640x480x64k;
+begin
+ InitSDLgraph(640,480,16);
+end;
+
+procedure sdlgraph_Init1024x768x32k;
+begin
+ InitSDLgraph(1024,768,15);
+end;
+
+procedure sdlgraph_Init640x480x256;
+begin
+ InitSDLgraph(640,480,8);
+end;
+
+procedure sdlgraph_Init640x400x256;
+begin
+ InitSDLgraph(640,400,8);
+end;
+
+procedure sdlgraph_Init320x200x64k;
+begin
+ InitSDLgraph(320,200,16);
+end;
+
+procedure sdlgraph_Init320x200x32k;
+begin
+ InitSDLgraph(320,200,15);
+end;
+
+procedure sdlgraph_Init640x480x16;
+begin
+ InitSDLgraph(640,480,4);
+end;
+
+procedure sdlgraph_Init640x350x16;
+begin
+ InitSDLgraph(640,350,4);
+end;
+
+procedure sdlgraph_Init640x200x16;
+begin
+ InitSDLgraph(640,200,4);
+end;
+
+procedure sdlgraph_InitModeX;
+begin
+ InitSDLgraph(320,200,8);
+end;
+
+procedure sdlgraph_Init320;
+begin
+ InitSDLgraph(320,200,8);
+end;
+
+
+
+
+//TODO Check what does it do and if it is needed
+//BEGIN TODO
+procedure savestate;
+
+  begin
+  end;
+
+procedure restorestate;
+
+  begin
+  end;
+
+procedure sdlgraph_SetRGBpalette(ColorNum, RedValue, GreenValue, BlueValue: smallint);
+   begin
+   end;
+
+procedure sdlgraph_GetRGBpalette(ColorNum: smallint; var RedValue, GreenValue, BlueValue: smallint);
+   begin
+   end;
+
+
+//END TODO
+
+
+function QueryAdapterInfo:PModeInfo;
+var
+mode: TModeInfo;
+
+   procedure setupSDLgraphDefaults;
+    begin
+    mode.DirectPutPixel:={$ifdef fpc}@{$endif}sdlgraph_DirectPutPixel;
+    mode.PutPixel:={$ifdef fpc}@{$endif}sdlgraph_PutPixel;
+    mode.GetPixel:={$ifdef fpc}@{$endif}sdlgraph_GetPixel;
+    mode.SetRGBPalette := {$ifdef fpc}@{$endif}sdlgraph_SetRGBpalette;
+    mode.GetRGBPalette := {$ifdef fpc}@{$endif}sdlgraph_GetRGBpalette;
+    //mode.InternalEllipse := {$ifdef fpc}@{$endif}sdlgraph_InternalEllipse;
+    if ((mode.MaxX+1)*35=(mode.MaxY+1)*64) then
+      mode.XAspect:=7750
+    else if ((mode.MaxX+1)*20=(mode.MaxY+1)*64) then
+      mode.XAspect:=4500
+    else if ((mode.MaxX+1)*40=(mode.MaxY+1)*64) then
+      mode.XAspect:=8333
+    else { assume 4:3 }
+      mode.XAspect:=10000;
+    //mode.HLine:={$ifdef fpc}@{$endif}sdlgraph_HLine;
+    //mode.VLine:={$ifdef fpc}@{$endif}sdlgraph_VLine;
+    //mode.Line:={$ifdef fpc}@{$endif}sdlgraph_line;
+    end;
+
+begin
+     QueryAdapterInfo := ModeList;
+{ If the mode listing already exists... }
+{ simply return it, without changing    }
+{ anything...                           }
+     if assigned(ModeList) then
+       exit;
+
+         SaveVideoState:={$ifdef fpc}@{$endif}savestate;
+         RestoreVideoState:={$ifdef fpc}@{$endif}restorestate;
+
+
+
+
+
+
+
+//    =======================================================MODES  FROM *GO32*=====================================================================
+//    ==============================================================================================================================================
+
+            InitMode(mode);
+{ now add all standard VGA modes...       }
+            mode.DriverNumber:= LowRes;
+            mode.HardwarePages:= 0;
+            mode.ModeNumber:=0;
+            mode.ModeName:='320 x 200 VGA';
+            mode.MaxColor := 256;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := FALSE;
+            mode.MaxX := 319;
+            mode.MaxY := 199;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init320;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+{ now add all standard VGA modes...       }
+            InitMode(mode);
+            mode.DriverNumber:= LowRes;
+            mode.ModeNumber:=1;
+            mode.HardwarePages := 3; { 0..3 }
+            mode.ModeName:='320 x 200 ModeX';
+            mode.MaxColor := 256;
+            mode.DirectColor := FALSE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 319;
+            mode.MaxY := 199;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_InitModeX;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=VGALo;
+            mode.DriverNumber := VGA;
+            mode.ModeName:='640 x 200 VGA';
+            mode.MaxColor := 16;
+            mode.HardwarePages := 2;
+            mode.DirectColor := FALSE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 639;
+            mode.MaxY := 199;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init640x200x16;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=VGAMed;
+            mode.DriverNumber := VGA;
+            mode.ModeName:='640 x 350 VGA';
+            mode.HardwarePages := 1;
+            mode.MaxColor := 16;
+            mode.DirectColor := FALSE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 639;
+            mode.MaxY := 349;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init640x350x16;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=VGAHi;
+            mode.DriverNumber := VGA;
+            mode.HardwarePages := 0;
+            mode.ModeName:='640 x 480 VGA';
+            mode.MaxColor := 16;
+            mode.DirectColor := FALSE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 639;
+            mode.MaxY := 479;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init640x480x16;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m320x200x32k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='320 x 200 VESA';
+            mode.MaxColor := 32768;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := TRUE;
+            mode.MaxX := 319;
+            mode.MaxY := 199;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init320x200x32k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m320x200x64k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='320 x 200 VESA';
+            mode.MaxColor := 65536;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := TRUE;
+            mode.MaxX := 319;
+            mode.MaxY := 199;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init320x200x64k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m640x400x256;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='640 x 400 VESA';
+            mode.MaxColor := 256;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := FALSE;
+            mode.MaxX := 639;
+            mode.MaxY := 399;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init640x400x256;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m640x480x256;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='640 x 480 VESA';
+            mode.MaxColor := 256;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 639;
+            mode.MaxY := 479;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init640x480x256;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m640x480x32k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='640 x 480 VESA';
+            mode.MaxColor := 32768;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := TRUE;
+            mode.MaxX := 639;
+            mode.MaxY := 479;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init640x480x32k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m640x480x64k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='640 x 480 VESA';
+            mode.MaxColor := 65536;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := TRUE;
+            mode.MaxX := 639;
+            mode.MaxY := 479;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init640x480x64k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m800x600x16;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='800 x 600 VESA';
+            mode.MaxColor := 16;
+            mode.HardwarePages := 2;
+            mode.DirectColor := FALSE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 799;
+            mode.MaxY := 599;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init800x600x16;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m800x600x256;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='800 x 600 VESA';
+            mode.MaxColor := 256;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := FALSE;
+            mode.MaxX := 799;
+            mode.MaxY := 599;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init800x600x256;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m800x600x32k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='800 x 600 VESA';
+            mode.MaxColor := 32768;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := TRUE;
+            mode.MaxX := 799;
+            mode.MaxY := 599;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init800x600x32k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m800x600x64k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='800 x 600 VESA';
+            mode.MaxColor := 65536;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := TRUE;
+            mode.MaxX := 799;
+            mode.MaxY := 599;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init800x600x64k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+   
+            InitMode(mode);
+            mode.ModeNumber:=m1024x768x16;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='1024 x 768 VESA';
+            mode.MaxColor := 16;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := FALSE;
+            mode.MaxX := 1023;
+            mode.MaxY := 767;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init1024x768x16;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+            
+            InitMode(mode);
+            mode.ModeNumber:=m1024x768x256;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='1024 x 768 VESA';
+            mode.MaxColor := 256;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := FALSE;
+            mode.MaxX := 1023;
+            mode.MaxY := 767;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init1024x768x256;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+       
+            InitMode(mode);
+            mode.ModeNumber:=m1024x768x32k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='1024 x 768 VESA';
+            mode.MaxColor := 32768;
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.DirectColor := TRUE;
+            mode.MaxX := 1023;
+            mode.MaxY := 767;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init1024x768x32k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m1024x768x64k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='1024 x 768 VESA';
+            mode.MaxColor := 65536;
+            mode.DirectColor := TRUE;
+
+            mode.HardwarePages := 2;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 1023;
+            mode.MaxY := 767;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init1024x768x64k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m1280x1024x16;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='1280 x 1024 VESA';
+            mode.MaxColor := 16;
+            mode.HardwarePages := 2;
+            mode.DirectColor := FALSE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 1279;
+            mode.MaxY := 1023;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init1280x1024x16;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m1280x1024x256;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='1280 x 1024 VESA';
+            mode.MaxColor := 256;
+            mode.HardwarePages := 2;
+            mode.DirectColor := FALSE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 1279;
+            mode.MaxY := 1023;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init1280x1024x256;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m1280x1024x32k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='1280 x 1024 VESA';
+            mode.MaxColor := 32768;
+            mode.HardwarePages := 2;
+            mode.DirectColor := TRUE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 1279;
+            mode.MaxY := 1023;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init1280x1024x32k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+            InitMode(mode);
+            mode.ModeNumber:=m1280x1024x64k;
+            mode.DriverNumber := VESA;
+            mode.ModeName:='1280 x 1024 VESA';
+            mode.MaxColor := 65536;
+            mode.HardwarePages := 2;
+            mode.DirectColor := TRUE;
+            mode.PaletteSize := mode.MaxColor;
+            mode.MaxX := 1279;
+            mode.MaxY := 1023;
+            mode.InitMode := {$ifdef fpc}@{$endif}sdlgraph_Init1280x1024x64k;
+            setupSDLgraphDefaults;
+            AddMode(mode);
+
+end;
+
+
+
+
+
+
+begin
+
+
+InitializeGraph;
+
+end.

+ 0 - 0
packages/base/graph/unix/ggigraph.pp → packages/extra/graph/unix/ggigraph.pp


+ 9 - 0
packages/base/graph/unix/graph.pp → packages/extra/graph/unix/graph.pp

@@ -546,6 +546,15 @@ end;
            MaxX:=ModeInfo.Width-1;
            // same for MaxY
            MaxY:=ModeInfo.Height-1;
+           YAspect:=10000;
+           if ((MaxX+1)*35=(MaxY+1)*64) then
+             XAspect:=7750
+           else if ((MaxX+1)*20=(MaxY+1)*64) then
+             XAspect:=4500
+           else if ((MaxX+1)*40=(MaxY+1)*64) then
+             XAspect:=8333
+           else { assume 4:3 }
+             XAspect:=10000;
            MaxColor := ModeInfo.colors;
            PaletteSize := MaxColor;
            HardwarePages := 0;

+ 0 - 0
packages/base/graph/unix/graph16.inc → packages/extra/graph/unix/graph16.inc


+ 3 - 3
packages/base/graph/win32/graph.pp → packages/extra/graph/win32/graph.pp

@@ -2004,7 +2004,7 @@ function queryadapterinfo : pmodeinfo;
           mode.MaxX := 639;
           mode.MaxY := 199;
           SetupWin32GUIDefault;
-          mode.XAspect := 10000;
+          mode.XAspect := 4500;
           mode.YAspect := 10000;
           AddMode(mode);
        end;
@@ -2021,7 +2021,7 @@ function queryadapterinfo : pmodeinfo;
           mode.MaxX := 639;
           mode.MaxY := 349;
           SetupWin32GUIDefault;
-          mode.XAspect := 10000;
+          mode.XAspect := 7750;
           mode.YAspect := 10000;
           AddMode(mode);
        end;
@@ -2038,7 +2038,7 @@ function queryadapterinfo : pmodeinfo;
           mode.MaxX := 639;
           mode.MaxY := 399;
           SetupWin32GUIDefault;
-          mode.XAspect := 10000;
+          mode.XAspect := 8333;
           mode.YAspect := 10000;
           AddMode(mode);
        end;

+ 0 - 0
packages/base/graph/win32/wincrt.pp → packages/extra/graph/win32/wincrt.pp


+ 0 - 0
packages/base/graph/win32/winmouse.pp → packages/extra/graph/win32/winmouse.pp