diff options
Diffstat (limited to 'modules/libgrbase')
| -rw-r--r-- | modules/libgrbase/Makefile | 660 | ||||
| -rw-r--r-- | modules/libgrbase/Makefile.am | 14 | ||||
| -rw-r--r-- | modules/libgrbase/Makefile.in | 660 | ||||
| -rw-r--r-- | modules/libgrbase/bitwise_map.h | 34 | ||||
| -rw-r--r-- | modules/libgrbase/g_bitmap.c | 463 | ||||
| -rw-r--r-- | modules/libgrbase/g_bitmap.h | 131 | ||||
| -rw-r--r-- | modules/libgrbase/g_blendop.c | 448 | ||||
| -rw-r--r-- | modules/libgrbase/g_blendop.h | 46 | ||||
| -rw-r--r-- | modules/libgrbase/g_clear.c | 222 | ||||
| -rw-r--r-- | modules/libgrbase/g_clear.h | 39 | ||||
| -rw-r--r-- | modules/libgrbase/g_conversion.c | 481 | ||||
| -rw-r--r-- | modules/libgrbase/g_conversion.h | 40 | ||||
| -rw-r--r-- | modules/libgrbase/g_grlib.c | 353 | ||||
| -rw-r--r-- | modules/libgrbase/g_grlib.h | 52 | ||||
| -rw-r--r-- | modules/libgrbase/g_pal.c | 832 | ||||
| -rw-r--r-- | modules/libgrbase/g_pal.h | 133 | ||||
| -rw-r--r-- | modules/libgrbase/g_region.h | 43 | ||||
| -rw-r--r-- | modules/libgrbase/libgrbase.c | 65 | ||||
| -rw-r--r-- | modules/libgrbase/libgrbase.h | 60 | ||||
| -rw-r--r-- | modules/libgrbase/libgrbase_exports.h | 51 | ||||
| -rw-r--r-- | modules/libgrbase/resolution.h | 86 | 
21 files changed, 4913 insertions, 0 deletions
| diff --git a/modules/libgrbase/Makefile b/modules/libgrbase/Makefile new file mode 100644 index 0000000..15174f8 --- /dev/null +++ b/modules/libgrbase/Makefile @@ -0,0 +1,660 @@ +# Makefile.in generated by automake 1.12.1 from Makefile.am. +# libgrbase/Makefile.  Generated from Makefile.in by configure. + +# Copyright (C) 1994-2012 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +#AUTOMAKE_OPTIONS = no-dependencies foreign + + +am__make_dryrun = \ +  { \ +    am__dry=no; \ +    case $$MAKEFLAGS in \ +      *\\[\ \	]*) \ +        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \ +          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ +      *) \ +        for am__flg in $$MAKEFLAGS; do \ +          case $$am__flg in \ +            *=*|--*) ;; \ +            *n*) am__dry=yes; break;; \ +          esac; \ +        done;; \ +    esac; \ +    test $$am__dry = yes; \ +  } +pkgdatadir = $(datadir)/bennu +pkgincludedir = $(includedir)/bennu +pkglibdir = $(libdir)/bennu +pkglibexecdir = $(libexecdir)/bennu +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-pc-none +host_triplet = arm-unknown-linux-gnu +target_triplet = arm-unknown-linux-gnu +subdir = libgrbase +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ +	$(top_srcdir)/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ +	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ +	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ +	$(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ +	$(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ +    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ +    *) f=$$p;; \ +  esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ +  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ +  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ +  for p in $$list; do echo "$$p $$p"; done | \ +  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ +  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ +    if (++n[$$2] == $(am__install_max)) \ +      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ +    END { for (dir in files) print dir, files[dir] }' +am__base_list = \ +  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ +  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ +  test -z "$$files" \ +    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ +    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ +         $(am__cd) "$$dir" && rm -f $$files; }; \ +  } +am__installdirs = "$(DESTDIR)$(libdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am__DEPENDENCIES_1 = +libgrbase_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_libgrbase_la_OBJECTS = libgrbase_la-g_bitmap.lo \ +	libgrbase_la-g_clear.lo libgrbase_la-g_grlib.lo \ +	libgrbase_la-g_pal.lo libgrbase_la-g_blendop.lo \ +	libgrbase_la-g_conversion.lo libgrbase_la-libgrbase.lo +libgrbase_la_OBJECTS = $(am_libgrbase_la_OBJECTS) +libgrbase_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ +	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libgrbase_la_CFLAGS) \ +	$(CFLAGS) $(libgrbase_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ +	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ +	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ +	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ +	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ +	$(LDFLAGS) -o $@ +SOURCES = $(libgrbase_la_SOURCES) +DIST_SOURCES = $(libgrbase_la_SOURCES) +am__can_run_installinfo = \ +  case $$AM_UPDATE_INFO_DIR in \ +    n|no|NO) false;; \ +    *) (install-info --version) >/dev/null 2>&1;; \ +  esac +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /home/steward/Github/miyoo_src/bennugd/modules/missing --run aclocal-1.12 +AMTAR = $${TAR-tar} +AR = /opt/miyoo/usr/bin/arm-linux-ar +AS = as +AUTOCONF = ${SHELL} /home/steward/Github/miyoo_src/bennugd/modules/missing --run autoconf +AUTOHEADER = ${SHELL} /home/steward/Github/miyoo_src/bennugd/modules/missing --run autoheader +AUTOMAKE = ${SHELL} /home/steward/Github/miyoo_src/bennugd/modules/missing --run automake-1.12 +AWK = mawk +BGD_PATH = /home/steward/Github/miyoo_src/bennugd/modules/../core +CC = /opt/miyoo/usr/bin/arm-linux-gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -DTARGET_MIYOO -mcpu=arm926ej-s -mtune=arm926ej-s -O3 -DARM -D_ARM_ASSEM_ -I/opt/miyoo/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/include/SDL -O2 -finline-functions -fno-strict-aliasing -Wall -DTARGET_LINUX -DUSE_LIBDES -DTARGET_MIYOO -mcpu=arm926ej-s -mtune=arm926ej-s -O3 -DARM -D_ARM_ASSEM_ -I/opt/miyoo/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/include/SDL -I/home/steward/Github/miyoo_src/bennugd/modules/../3rdparty/des-4.04b +COMMON_CFLAGS = -Wall -DTARGET_LINUX -DUSE_LIBDES -DTARGET_MIYOO -mcpu=arm926ej-s -mtune=arm926ej-s -O3 -DARM -D_ARM_ASSEM_ -I/opt/miyoo/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/include/SDL -I/home/steward/Github/miyoo_src/bennugd/modules/../3rdparty/des-4.04b +COMMON_LDFLAGS =  -lc -ldl -D_REENTRANT -L/home/steward/Github/miyoo_src/bennugd/modules/../3rdparty/des-4.04b -ldes +CPP = /opt/miyoo/usr/bin/arm-linux-gcc -E +CPPFLAGS =  +CYGPATH_W = echo +DEFS = -DPACKAGE_NAME=\"bennu\" -DPACKAGE_TARNAME=\"bennu\" -DPACKAGE_VERSION=\"1.0.0\" -DPACKAGE_STRING=\"bennu\ 1.0.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE=\"bennu\" -DVERSION=\"1.0.0\" -DHAVE_LIBM=1 +DEPDIR = .deps +DESLIBS =  +DLLTOOL = false +DSYMUTIL =  +DUMPBIN =  +ECHO_C =  +ECHO_N = -n +ECHO_T =  +EGREP = /bin/grep -E +EXEEXT =  +FGREP = /bin/grep -F +GREP = /bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +LD = /opt/miyoo/usr/bin/arm-linux-ld +LDFLAGS = -D_REENTRANT +LIBOBJS =  +LIBS = -lm  +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LIPO =  +LN_S = ln -s +LTLIBOBJS =  +MAINT = # +MAKEINFO = ${SHELL} /home/steward/Github/miyoo_src/bennugd/modules/missing --run makeinfo +MANIFEST_TOOL = : +MKDIR_P = /bin/mkdir -p +NM = /opt/miyoo/bin//arm-linux-nm -B +NMEDIT =  +OBJDUMP = arm-linux-objdump +OBJEXT = o +OTOOL =  +OTOOL64 =  +PACKAGE = bennu +PACKAGE_BUGREPORT =  +PACKAGE_NAME = bennu +PACKAGE_STRING = bennu 1.0.0 +PACKAGE_TARNAME = bennu +PACKAGE_URL =  +PACKAGE_VERSION = 1.0.0 +PATH_SEPARATOR = : +PKG_CONFIG = /usr/bin/pkg-config +PKG_CONFIG_LIBDIR = /opt/miyoo/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/lib/pkgconfig +PKG_CONFIG_PATH = /opt/miyoo/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/lib/pkgconfig +PNGLIBS =  +PNG_CFLAGS = -I/usr/include/libpng16   +PNG_LIBS = -lpng16 -lz   +RANLIB = /opt/miyoo/usr/bin/arm-linux-ranlib +SDL_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT   +SDL_LIBS = -lSDL  -lpthread   +SDL_mixer_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT   +SDL_mixer_LIBS = -lSDL_mixer -lSDL  -lpthread   +SED = /bin/sed +SET_MAKE =  +SHELL = /bin/bash +STRIP = /opt/miyoo/usr/bin/arm-linux-strip +VERSION = 1.0.0 +WINDRES =  +X11LIBS = -lX11 +ZLIBS =  +ZLIB_CFLAGS =   +ZLIB_LIBS = -lz   +abs_builddir = /home/steward/Github/miyoo_src/bennugd/modules/libgrbase +abs_srcdir = /home/steward/Github/miyoo_src/bennugd/modules/libgrbase +abs_top_builddir = /home/steward/Github/miyoo_src/bennugd/modules +abs_top_srcdir = /home/steward/Github/miyoo_src/bennugd/modules +ac_ct_AR =  +ac_ct_CC =  +ac_ct_DUMPBIN =  +am__include = include +am__leading_dot = . +am__quote =  +am__tar = $${TAR-tar} chof - "$$tardir" +am__untar = $${TAR-tar} xf - +bindir = ${exec_prefix}/bin +build = x86_64-pc-none +build_alias = x86_64 +build_cpu = x86_64 +build_os = none +build_vendor = pc +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = arm-unknown-linux-gnu +host_alias = arm-linux +host_cpu = arm +host_os = linux-gnu +host_vendor = unknown +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = ${SHELL} /home/steward/Github/miyoo_src/bennugd/modules/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = /bin/mkdir -p +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /opt/miyoo/usr +program_transform_name = s&^&arm-linux-& +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target = arm-unknown-linux-gnu +target_alias = arm-linux +target_cpu = arm +target_os = linux-gnu +target_vendor = unknown +top_build_prefix = ../ +top_builddir = .. +top_srcdir = .. +lib_LTLIBRARIES = libgrbase.la +libgrbase_la_SOURCES = g_bitmap.c g_clear.c g_grlib.c g_pal.c g_blendop.c g_conversion.c libgrbase.c +libgrbase_la_CFLAGS = $(COMMON_CFLAGS) -I$(BGD_PATH)/include -I. +libgrbase_la_LDFLAGS = -s -module -no-undefined -avoid-version +libgrbase_la_LIBADD = $(COMMON_LDFLAGS) +CLEANFILES = libgrbase.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: # $(srcdir)/Makefile.am  $(am__configure_deps) +	@for dep in $?; do \ +	  case '$(am__configure_deps)' in \ +	    *$$dep*) \ +	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ +	        && { if test -f $@; then exit 0; else break; fi; }; \ +	      exit 1;; \ +	  esac; \ +	done; \ +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libgrbase/Makefile'; \ +	$(am__cd) $(top_srcdir) && \ +	  $(AUTOMAKE) --gnu libgrbase/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +	@case '$?' in \ +	  *config.status*) \ +	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ +	  *) \ +	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ +	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ +	esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: # $(am__configure_deps) +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): # $(am__aclocal_m4_deps) +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libLTLIBRARIES: $(lib_LTLIBRARIES) +	@$(NORMAL_INSTALL) +	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ +	list2=; for p in $$list; do \ +	  if test -f $$p; then \ +	    list2="$$list2 $$p"; \ +	  else :; fi; \ +	done; \ +	test -z "$$list2" || { \ +	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ +	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ +	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ +	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ +	} + +uninstall-libLTLIBRARIES: +	@$(NORMAL_UNINSTALL) +	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ +	for p in $$list; do \ +	  $(am__strip_dir) \ +	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ +	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ +	done + +clean-libLTLIBRARIES: +	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) +	@list='$(lib_LTLIBRARIES)'; \ +	locs=`for p in $$list; do echo $$p; done | \ +	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ +	      sort -u`; \ +	test -z "$$locs" || { \ +	  echo rm -f $${locs}; \ +	  rm -f $${locs}; \ +	} +libgrbase.la: $(libgrbase_la_OBJECTS) $(libgrbase_la_DEPENDENCIES) $(EXTRA_libgrbase_la_DEPENDENCIES)  +	$(libgrbase_la_LINK) -rpath $(libdir) $(libgrbase_la_OBJECTS) $(libgrbase_la_LIBADD) $(LIBS) + +mostlyclean-compile: +	-rm -f *.$(OBJEXT) + +distclean-compile: +	-rm -f *.tab.c + +include ./$(DEPDIR)/libgrbase_la-g_bitmap.Plo +include ./$(DEPDIR)/libgrbase_la-g_blendop.Plo +include ./$(DEPDIR)/libgrbase_la-g_clear.Plo +include ./$(DEPDIR)/libgrbase_la-g_conversion.Plo +include ./$(DEPDIR)/libgrbase_la-g_grlib.Plo +include ./$(DEPDIR)/libgrbase_la-g_pal.Plo +include ./$(DEPDIR)/libgrbase_la-libgrbase.Plo + +.c.o: +	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +#	source='$<' object='$@' libtool=no \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(COMPILE) -c $< + +.c.obj: +	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +#	source='$<' object='$@' libtool=no \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +#	source='$<' object='$@' libtool=yes \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(LTCOMPILE) -c -o $@ $< + +libgrbase_la-g_bitmap.lo: g_bitmap.c +	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_bitmap.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_bitmap.Tpo -c -o libgrbase_la-g_bitmap.lo `test -f 'g_bitmap.c' || echo '$(srcdir)/'`g_bitmap.c +	$(am__mv) $(DEPDIR)/libgrbase_la-g_bitmap.Tpo $(DEPDIR)/libgrbase_la-g_bitmap.Plo +#	source='g_bitmap.c' object='libgrbase_la-g_bitmap.lo' libtool=yes \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_bitmap.lo `test -f 'g_bitmap.c' || echo '$(srcdir)/'`g_bitmap.c + +libgrbase_la-g_clear.lo: g_clear.c +	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_clear.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_clear.Tpo -c -o libgrbase_la-g_clear.lo `test -f 'g_clear.c' || echo '$(srcdir)/'`g_clear.c +	$(am__mv) $(DEPDIR)/libgrbase_la-g_clear.Tpo $(DEPDIR)/libgrbase_la-g_clear.Plo +#	source='g_clear.c' object='libgrbase_la-g_clear.lo' libtool=yes \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_clear.lo `test -f 'g_clear.c' || echo '$(srcdir)/'`g_clear.c + +libgrbase_la-g_grlib.lo: g_grlib.c +	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_grlib.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_grlib.Tpo -c -o libgrbase_la-g_grlib.lo `test -f 'g_grlib.c' || echo '$(srcdir)/'`g_grlib.c +	$(am__mv) $(DEPDIR)/libgrbase_la-g_grlib.Tpo $(DEPDIR)/libgrbase_la-g_grlib.Plo +#	source='g_grlib.c' object='libgrbase_la-g_grlib.lo' libtool=yes \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_grlib.lo `test -f 'g_grlib.c' || echo '$(srcdir)/'`g_grlib.c + +libgrbase_la-g_pal.lo: g_pal.c +	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_pal.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_pal.Tpo -c -o libgrbase_la-g_pal.lo `test -f 'g_pal.c' || echo '$(srcdir)/'`g_pal.c +	$(am__mv) $(DEPDIR)/libgrbase_la-g_pal.Tpo $(DEPDIR)/libgrbase_la-g_pal.Plo +#	source='g_pal.c' object='libgrbase_la-g_pal.lo' libtool=yes \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_pal.lo `test -f 'g_pal.c' || echo '$(srcdir)/'`g_pal.c + +libgrbase_la-g_blendop.lo: g_blendop.c +	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_blendop.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_blendop.Tpo -c -o libgrbase_la-g_blendop.lo `test -f 'g_blendop.c' || echo '$(srcdir)/'`g_blendop.c +	$(am__mv) $(DEPDIR)/libgrbase_la-g_blendop.Tpo $(DEPDIR)/libgrbase_la-g_blendop.Plo +#	source='g_blendop.c' object='libgrbase_la-g_blendop.lo' libtool=yes \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_blendop.lo `test -f 'g_blendop.c' || echo '$(srcdir)/'`g_blendop.c + +libgrbase_la-g_conversion.lo: g_conversion.c +	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_conversion.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_conversion.Tpo -c -o libgrbase_la-g_conversion.lo `test -f 'g_conversion.c' || echo '$(srcdir)/'`g_conversion.c +	$(am__mv) $(DEPDIR)/libgrbase_la-g_conversion.Tpo $(DEPDIR)/libgrbase_la-g_conversion.Plo +#	source='g_conversion.c' object='libgrbase_la-g_conversion.lo' libtool=yes \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_conversion.lo `test -f 'g_conversion.c' || echo '$(srcdir)/'`g_conversion.c + +libgrbase_la-libgrbase.lo: libgrbase.c +	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-libgrbase.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-libgrbase.Tpo -c -o libgrbase_la-libgrbase.lo `test -f 'libgrbase.c' || echo '$(srcdir)/'`libgrbase.c +	$(am__mv) $(DEPDIR)/libgrbase_la-libgrbase.Tpo $(DEPDIR)/libgrbase_la-libgrbase.Plo +#	source='libgrbase.c' object='libgrbase_la-libgrbase.lo' libtool=yes \ +#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +#	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-libgrbase.lo `test -f 'libgrbase.c' || echo '$(srcdir)/'`libgrbase.c + +mostlyclean-libtool: +	-rm -f *.lo + +clean-libtool: +	-rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) +	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ +	unique=`for i in $$list; do \ +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ +	  done | \ +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ +	      END { if (nonempty) { for (i in files) print i; }; }'`; \ +	mkid -fID $$unique +tags: TAGS + +TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \ +		$(TAGS_FILES) $(LISP) +	set x; \ +	here=`pwd`; \ +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \ +	unique=`for i in $$list; do \ +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ +	  done | \ +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ +	      END { if (nonempty) { for (i in files) print i; }; }'`; \ +	shift; \ +	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ +	  test -n "$$unique" || unique=$$empty_fix; \ +	  if test $$# -gt 0; then \ +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ +	      "$$@" $$unique; \ +	  else \ +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ +	      $$unique; \ +	  fi; \ +	fi +ctags: CTAGS +CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \ +		$(TAGS_FILES) $(LISP) +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \ +	unique=`for i in $$list; do \ +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ +	  done | \ +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ +	      END { if (nonempty) { for (i in files) print i; }; }'`; \ +	test -z "$(CTAGS_ARGS)$$unique" \ +	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ +	     $$unique + +GTAGS: +	here=`$(am__cd) $(top_builddir) && pwd` \ +	  && $(am__cd) $(top_srcdir) \ +	  && gtags -i $(GTAGS_ARGS) "$$here" + +cscopelist:  $(HEADERS) $(SOURCES) $(LISP) +	list='$(SOURCES) $(HEADERS) $(LISP)'; \ +	case "$(srcdir)" in \ +	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ +	  *) sdir=$(subdir)/$(srcdir) ;; \ +	esac; \ +	for i in $$list; do \ +	  if test -f "$$i"; then \ +	    echo "$(subdir)/$$i"; \ +	  else \ +	    echo "$$sdir/$$i"; \ +	  fi; \ +	done >> $(top_builddir)/cscope.files + +distclean-tags: +	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) +	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ +	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ +	list='$(DISTFILES)'; \ +	  dist_files=`for file in $$list; do echo $$file; done | \ +	  sed -e "s|^$$srcdirstrip/||;t" \ +	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ +	case $$dist_files in \ +	  */*) $(MKDIR_P) `echo "$$dist_files" | \ +			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ +			   sort -u` ;; \ +	esac; \ +	for file in $$dist_files; do \ +	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ +	  if test -d $$d/$$file; then \ +	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ +	    if test -d "$(distdir)/$$file"; then \ +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ +	    fi; \ +	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ +	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ +	    fi; \ +	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ +	  else \ +	    test -f "$(distdir)/$$file" \ +	    || cp -p $$d/$$file "$(distdir)/$$file" \ +	    || exit 1; \ +	  fi; \ +	done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +	for dir in "$(DESTDIR)$(libdir)"; do \ +	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \ +	done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am +	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: +	if test -z '$(STRIP)'; then \ +	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ +	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ +	      install; \ +	else \ +	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ +	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ +	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ +	fi +mostlyclean-generic: + +clean-generic: +	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: +	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) +	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: +	@echo "This command is intended for maintainers to use" +	@echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ +	mostlyclean-am + +distclean: distclean-am +	-rm -rf ./$(DEPDIR) +	-rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ +	distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am +	-rm -rf ./$(DEPDIR) +	-rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ +	mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ +	clean-libLTLIBRARIES clean-libtool cscopelist ctags distclean \ +	distclean-compile distclean-generic distclean-libtool \ +	distclean-tags distdir dvi dvi-am html html-am info info-am \ +	install install-am install-data install-data-am install-dvi \ +	install-dvi-am install-exec install-exec-am install-html \ +	install-html-am install-info install-info-am \ +	install-libLTLIBRARIES install-man install-pdf install-pdf-am \ +	install-ps install-ps-am install-strip installcheck \ +	installcheck-am installdirs maintainer-clean \ +	maintainer-clean-generic mostlyclean mostlyclean-compile \ +	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ +	tags uninstall uninstall-am uninstall-libLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/modules/libgrbase/Makefile.am b/modules/libgrbase/Makefile.am new file mode 100644 index 0000000..f582d8a --- /dev/null +++ b/modules/libgrbase/Makefile.am @@ -0,0 +1,14 @@ +## Process this file with automake to produce Makefile.in + +#AUTOMAKE_OPTIONS = no-dependencies foreign + +lib_LTLIBRARIES = libgrbase.la + +libgrbase_la_SOURCES = g_bitmap.c g_clear.c g_grlib.c g_pal.c g_blendop.c g_conversion.c libgrbase.c +libgrbase_la_CFLAGS = $(COMMON_CFLAGS) -I$(BGD_PATH)/include -I. +libgrbase_la_LDFLAGS = -s -module -no-undefined -avoid-version +libgrbase_la_LIBADD = $(COMMON_LDFLAGS) + +## Make sure these will be cleaned even when they're not built by +## default. +CLEANFILES = libgrbase.la diff --git a/modules/libgrbase/Makefile.in b/modules/libgrbase/Makefile.in new file mode 100644 index 0000000..af64156 --- /dev/null +++ b/modules/libgrbase/Makefile.in @@ -0,0 +1,660 @@ +# Makefile.in generated by automake 1.12.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2012 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +#AUTOMAKE_OPTIONS = no-dependencies foreign + +VPATH = @srcdir@ +am__make_dryrun = \ +  { \ +    am__dry=no; \ +    case $$MAKEFLAGS in \ +      *\\[\ \	]*) \ +        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \ +          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ +      *) \ +        for am__flg in $$MAKEFLAGS; do \ +          case $$am__flg in \ +            *=*|--*) ;; \ +            *n*) am__dry=yes; break;; \ +          esac; \ +        done;; \ +    esac; \ +    test $$am__dry = yes; \ +  } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = libgrbase +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ +	$(top_srcdir)/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ +	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ +	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ +	$(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ +	$(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ +    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ +    *) f=$$p;; \ +  esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ +  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ +  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ +  for p in $$list; do echo "$$p $$p"; done | \ +  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ +  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ +    if (++n[$$2] == $(am__install_max)) \ +      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ +    END { for (dir in files) print dir, files[dir] }' +am__base_list = \ +  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ +  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ +  test -z "$$files" \ +    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ +    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ +         $(am__cd) "$$dir" && rm -f $$files; }; \ +  } +am__installdirs = "$(DESTDIR)$(libdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am__DEPENDENCIES_1 = +libgrbase_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_libgrbase_la_OBJECTS = libgrbase_la-g_bitmap.lo \ +	libgrbase_la-g_clear.lo libgrbase_la-g_grlib.lo \ +	libgrbase_la-g_pal.lo libgrbase_la-g_blendop.lo \ +	libgrbase_la-g_conversion.lo libgrbase_la-libgrbase.lo +libgrbase_la_OBJECTS = $(am_libgrbase_la_OBJECTS) +libgrbase_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ +	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libgrbase_la_CFLAGS) \ +	$(CFLAGS) $(libgrbase_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ +	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ +	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ +	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ +	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ +	$(LDFLAGS) -o $@ +SOURCES = $(libgrbase_la_SOURCES) +DIST_SOURCES = $(libgrbase_la_SOURCES) +am__can_run_installinfo = \ +  case $$AM_UPDATE_INFO_DIR in \ +    n|no|NO) false;; \ +    *) (install-info --version) >/dev/null 2>&1;; \ +  esac +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BGD_PATH = @BGD_PATH@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMMON_CFLAGS = @COMMON_CFLAGS@ +COMMON_LDFLAGS = @COMMON_LDFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DESLIBS = @DESLIBS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PNGLIBS = @PNGLIBS@ +PNG_CFLAGS = @PNG_CFLAGS@ +PNG_LIBS = @PNG_LIBS@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_LIBS = @SDL_LIBS@ +SDL_mixer_CFLAGS = @SDL_mixer_CFLAGS@ +SDL_mixer_LIBS = @SDL_mixer_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WINDRES = @WINDRES@ +X11LIBS = @X11LIBS@ +ZLIBS = @ZLIBS@ +ZLIB_CFLAGS = @ZLIB_CFLAGS@ +ZLIB_LIBS = @ZLIB_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +lib_LTLIBRARIES = libgrbase.la +libgrbase_la_SOURCES = g_bitmap.c g_clear.c g_grlib.c g_pal.c g_blendop.c g_conversion.c libgrbase.c +libgrbase_la_CFLAGS = $(COMMON_CFLAGS) -I$(BGD_PATH)/include -I. +libgrbase_la_LDFLAGS = -s -module -no-undefined -avoid-version +libgrbase_la_LIBADD = $(COMMON_LDFLAGS) +CLEANFILES = libgrbase.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps) +	@for dep in $?; do \ +	  case '$(am__configure_deps)' in \ +	    *$$dep*) \ +	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ +	        && { if test -f $@; then exit 0; else break; fi; }; \ +	      exit 1;; \ +	  esac; \ +	done; \ +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libgrbase/Makefile'; \ +	$(am__cd) $(top_srcdir) && \ +	  $(AUTOMAKE) --gnu libgrbase/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +	@case '$?' in \ +	  *config.status*) \ +	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ +	  *) \ +	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ +	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ +	esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libLTLIBRARIES: $(lib_LTLIBRARIES) +	@$(NORMAL_INSTALL) +	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ +	list2=; for p in $$list; do \ +	  if test -f $$p; then \ +	    list2="$$list2 $$p"; \ +	  else :; fi; \ +	done; \ +	test -z "$$list2" || { \ +	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ +	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ +	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ +	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ +	} + +uninstall-libLTLIBRARIES: +	@$(NORMAL_UNINSTALL) +	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ +	for p in $$list; do \ +	  $(am__strip_dir) \ +	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ +	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ +	done + +clean-libLTLIBRARIES: +	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) +	@list='$(lib_LTLIBRARIES)'; \ +	locs=`for p in $$list; do echo $$p; done | \ +	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ +	      sort -u`; \ +	test -z "$$locs" || { \ +	  echo rm -f $${locs}; \ +	  rm -f $${locs}; \ +	} +libgrbase.la: $(libgrbase_la_OBJECTS) $(libgrbase_la_DEPENDENCIES) $(EXTRA_libgrbase_la_DEPENDENCIES)  +	$(libgrbase_la_LINK) -rpath $(libdir) $(libgrbase_la_OBJECTS) $(libgrbase_la_LIBADD) $(LIBS) + +mostlyclean-compile: +	-rm -f *.$(OBJEXT) + +distclean-compile: +	-rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgrbase_la-g_bitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgrbase_la-g_blendop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgrbase_la-g_clear.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgrbase_la-g_conversion.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgrbase_la-g_grlib.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgrbase_la-g_pal.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgrbase_la-libgrbase.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $< + +libgrbase_la-g_bitmap.lo: g_bitmap.c +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_bitmap.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_bitmap.Tpo -c -o libgrbase_la-g_bitmap.lo `test -f 'g_bitmap.c' || echo '$(srcdir)/'`g_bitmap.c +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libgrbase_la-g_bitmap.Tpo $(DEPDIR)/libgrbase_la-g_bitmap.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='g_bitmap.c' object='libgrbase_la-g_bitmap.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_bitmap.lo `test -f 'g_bitmap.c' || echo '$(srcdir)/'`g_bitmap.c + +libgrbase_la-g_clear.lo: g_clear.c +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_clear.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_clear.Tpo -c -o libgrbase_la-g_clear.lo `test -f 'g_clear.c' || echo '$(srcdir)/'`g_clear.c +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libgrbase_la-g_clear.Tpo $(DEPDIR)/libgrbase_la-g_clear.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='g_clear.c' object='libgrbase_la-g_clear.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_clear.lo `test -f 'g_clear.c' || echo '$(srcdir)/'`g_clear.c + +libgrbase_la-g_grlib.lo: g_grlib.c +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_grlib.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_grlib.Tpo -c -o libgrbase_la-g_grlib.lo `test -f 'g_grlib.c' || echo '$(srcdir)/'`g_grlib.c +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libgrbase_la-g_grlib.Tpo $(DEPDIR)/libgrbase_la-g_grlib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='g_grlib.c' object='libgrbase_la-g_grlib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_grlib.lo `test -f 'g_grlib.c' || echo '$(srcdir)/'`g_grlib.c + +libgrbase_la-g_pal.lo: g_pal.c +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_pal.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_pal.Tpo -c -o libgrbase_la-g_pal.lo `test -f 'g_pal.c' || echo '$(srcdir)/'`g_pal.c +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libgrbase_la-g_pal.Tpo $(DEPDIR)/libgrbase_la-g_pal.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='g_pal.c' object='libgrbase_la-g_pal.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_pal.lo `test -f 'g_pal.c' || echo '$(srcdir)/'`g_pal.c + +libgrbase_la-g_blendop.lo: g_blendop.c +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_blendop.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_blendop.Tpo -c -o libgrbase_la-g_blendop.lo `test -f 'g_blendop.c' || echo '$(srcdir)/'`g_blendop.c +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libgrbase_la-g_blendop.Tpo $(DEPDIR)/libgrbase_la-g_blendop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='g_blendop.c' object='libgrbase_la-g_blendop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_blendop.lo `test -f 'g_blendop.c' || echo '$(srcdir)/'`g_blendop.c + +libgrbase_la-g_conversion.lo: g_conversion.c +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-g_conversion.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-g_conversion.Tpo -c -o libgrbase_la-g_conversion.lo `test -f 'g_conversion.c' || echo '$(srcdir)/'`g_conversion.c +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libgrbase_la-g_conversion.Tpo $(DEPDIR)/libgrbase_la-g_conversion.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='g_conversion.c' object='libgrbase_la-g_conversion.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-g_conversion.lo `test -f 'g_conversion.c' || echo '$(srcdir)/'`g_conversion.c + +libgrbase_la-libgrbase.lo: libgrbase.c +@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -MT libgrbase_la-libgrbase.lo -MD -MP -MF $(DEPDIR)/libgrbase_la-libgrbase.Tpo -c -o libgrbase_la-libgrbase.lo `test -f 'libgrbase.c' || echo '$(srcdir)/'`libgrbase.c +@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libgrbase_la-libgrbase.Tpo $(DEPDIR)/libgrbase_la-libgrbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='libgrbase.c' object='libgrbase_la-libgrbase.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgrbase_la_CFLAGS) $(CFLAGS) -c -o libgrbase_la-libgrbase.lo `test -f 'libgrbase.c' || echo '$(srcdir)/'`libgrbase.c + +mostlyclean-libtool: +	-rm -f *.lo + +clean-libtool: +	-rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) +	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ +	unique=`for i in $$list; do \ +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ +	  done | \ +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ +	      END { if (nonempty) { for (i in files) print i; }; }'`; \ +	mkid -fID $$unique +tags: TAGS + +TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \ +		$(TAGS_FILES) $(LISP) +	set x; \ +	here=`pwd`; \ +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \ +	unique=`for i in $$list; do \ +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ +	  done | \ +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ +	      END { if (nonempty) { for (i in files) print i; }; }'`; \ +	shift; \ +	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ +	  test -n "$$unique" || unique=$$empty_fix; \ +	  if test $$# -gt 0; then \ +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ +	      "$$@" $$unique; \ +	  else \ +	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ +	      $$unique; \ +	  fi; \ +	fi +ctags: CTAGS +CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \ +		$(TAGS_FILES) $(LISP) +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \ +	unique=`for i in $$list; do \ +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ +	  done | \ +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ +	      END { if (nonempty) { for (i in files) print i; }; }'`; \ +	test -z "$(CTAGS_ARGS)$$unique" \ +	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ +	     $$unique + +GTAGS: +	here=`$(am__cd) $(top_builddir) && pwd` \ +	  && $(am__cd) $(top_srcdir) \ +	  && gtags -i $(GTAGS_ARGS) "$$here" + +cscopelist:  $(HEADERS) $(SOURCES) $(LISP) +	list='$(SOURCES) $(HEADERS) $(LISP)'; \ +	case "$(srcdir)" in \ +	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ +	  *) sdir=$(subdir)/$(srcdir) ;; \ +	esac; \ +	for i in $$list; do \ +	  if test -f "$$i"; then \ +	    echo "$(subdir)/$$i"; \ +	  else \ +	    echo "$$sdir/$$i"; \ +	  fi; \ +	done >> $(top_builddir)/cscope.files + +distclean-tags: +	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) +	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ +	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ +	list='$(DISTFILES)'; \ +	  dist_files=`for file in $$list; do echo $$file; done | \ +	  sed -e "s|^$$srcdirstrip/||;t" \ +	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ +	case $$dist_files in \ +	  */*) $(MKDIR_P) `echo "$$dist_files" | \ +			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ +			   sort -u` ;; \ +	esac; \ +	for file in $$dist_files; do \ +	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ +	  if test -d $$d/$$file; then \ +	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ +	    if test -d "$(distdir)/$$file"; then \ +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ +	    fi; \ +	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ +	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ +	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ +	    fi; \ +	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ +	  else \ +	    test -f "$(distdir)/$$file" \ +	    || cp -p $$d/$$file "$(distdir)/$$file" \ +	    || exit 1; \ +	  fi; \ +	done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +	for dir in "$(DESTDIR)$(libdir)"; do \ +	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \ +	done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am +	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: +	if test -z '$(STRIP)'; then \ +	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ +	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ +	      install; \ +	else \ +	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ +	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ +	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ +	fi +mostlyclean-generic: + +clean-generic: +	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: +	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) +	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: +	@echo "This command is intended for maintainers to use" +	@echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ +	mostlyclean-am + +distclean: distclean-am +	-rm -rf ./$(DEPDIR) +	-rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ +	distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am +	-rm -rf ./$(DEPDIR) +	-rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ +	mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ +	clean-libLTLIBRARIES clean-libtool cscopelist ctags distclean \ +	distclean-compile distclean-generic distclean-libtool \ +	distclean-tags distdir dvi dvi-am html html-am info info-am \ +	install install-am install-data install-data-am install-dvi \ +	install-dvi-am install-exec install-exec-am install-html \ +	install-html-am install-info install-info-am \ +	install-libLTLIBRARIES install-man install-pdf install-pdf-am \ +	install-ps install-ps-am install-strip installcheck \ +	installcheck-am installdirs maintainer-clean \ +	maintainer-clean-generic mostlyclean mostlyclean-compile \ +	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ +	tags uninstall uninstall-am uninstall-libLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/modules/libgrbase/bitwise_map.h b/modules/libgrbase/bitwise_map.h new file mode 100644 index 0000000..fdcf990 --- /dev/null +++ b/modules/libgrbase/bitwise_map.h @@ -0,0 +1,34 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __BITWISE_MAP_H +#define __BITWISE_MAP_H + +#define bit_set(m,b)    (((uint32_t *)(m))[(b)>>5] |=   1<<((b)&0x1F)) +#define bit_clr(m,b)    (((uint32_t *)(m))[(b)>>5] &= ~(1<<((b)&0x1F))) +#define bit_tst(m,b)    (((uint32_t *)(m))[(b)>>5] &   (1<<((b)&0x1F))) + +#endif diff --git a/modules/libgrbase/g_bitmap.c b/modules/libgrbase/g_bitmap.c new file mode 100644 index 0000000..db88afb --- /dev/null +++ b/modules/libgrbase/g_bitmap.c @@ -0,0 +1,463 @@ +/* + *  Copyright © 2006-2016 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +/* --------------------------------------------------------------------------- */ + +#include <stdlib.h> +#include <string.h> + +#include "libgrbase.h" +#include "bitwise_map.h" + +/* --------------------------------------------------------------------------- */ + +uint32_t * map_code_bmp = NULL ; +int map_code_allocated = 0 ; +int map_code_last = 0; + +/* --------------------------------------------------------------------------- */ + +PIXEL_FORMAT * bitmap_create_format( int bpp ) +{ +    PIXEL_FORMAT *format; + +    /* Allocate an empty pixel format structure */ +    format = malloc( sizeof( *format ) ); +    if ( !format ) return( NULL ); + +    /* Set up the format */ + +    format->palette = NULL; +    format->depth = bpp; +    format->depthb = ( bpp + 7 ) / 8; + +    if ( bpp == 32 ) +    { +        format->Aloss = 0; +        format->Rloss = 0; +        format->Gloss = 0; +        format->Bloss = 0; + +        format->Ashift = 24; +        format->Rshift = 16; +        format->Gshift = 8; +        format->Bshift = 0; + +        format->Amask = 0xFF000000; +        format->Rmask = 0x00FF0000; +        format->Gmask = 0x0000FF00; +        format->Bmask = 0x000000FF; +    } +    else if ( bpp > 8 ) +    { +        /* R-G-B */ +        if ( bpp > 24 ) bpp = 24; + +        format->Rloss = 8 - ( bpp / 3 ); +        format->Gloss = 8 - ( bpp / 3 ) - ( bpp % 3 ); +        format->Bloss = 8 - ( bpp / 3 ); + +        format->Rshift = (( bpp / 3 ) + ( bpp % 3 ) ) + ( bpp / 3 ); +        format->Gshift = ( bpp / 3 ); +        format->Bshift = 0; + +        format->Rmask = (( 0xFF >> format->Rloss ) << format->Rshift ); +        format->Gmask = (( 0xFF >> format->Gloss ) << format->Gshift ); +        format->Bmask = (( 0xFF >> format->Bloss ) << format->Bshift ); +    } +    else +    { +        format->Rloss = 8; +        format->Gloss = 8; +        format->Bloss = 8; +        format->Aloss = 8; + +        format->Rshift = 0; +        format->Gshift = 0; +        format->Bshift = 0; +        format->Ashift = 0; + +        format->Rmask = 0; +        format->Gmask = 0; +        format->Bmask = 0; +        format->Amask = 0; +    } + +    return( format ); +} + +/* --------------------------------------------------------------------------- */ + +GRAPH * bitmap_new_ex( int code, int w, int h, int depth, void * data, int pitch ) +{ +    GRAPH * gr ; +    int wb ; + +    if ( w < 1 || h < 1 ) return NULL; + +    /* Create and fill the struct */ + +    gr = ( GRAPH * ) malloc( sizeof( GRAPH ) ) ; +    if ( !gr ) return NULL; // sin memoria + +    /* Calculate the row size (dword-aligned) */ + +    wb = w * depth / 8; +    if (( wb * 8 / depth ) < w ) wb++; + +    gr->data = data ; + +    gr->width = w ; +    gr->height = h ; + +    gr->format = bitmap_create_format( depth ) ; + +    gr->pitch = pitch ; +    gr->widthb = wb ; + +    gr->code = code ; +    gr->name[ 0 ] = '\0'; + +    gr->ncpoints = 0; +    gr->cpoints = NULL ; + +    gr->format->palette = NULL ; + +    gr->blend_table = NULL ; + +    gr->modified = 0; +    gr->info_flags = GI_EXTERNAL_DATA ; + +    return gr ; +} + +/* --------------------------------------------------------------------------- */ + +GRAPH * bitmap_new( int code, int w, int h, int depth ) +{ +    GRAPH * gr ; +    int bytesPerRow, wb ; + +    if ( w < 1 || h < 1 ) return NULL; + +    /* Create and fill the struct */ + +    gr = ( GRAPH * ) malloc( sizeof( GRAPH ) ) ; +    if ( !gr ) return NULL; // sin memoria + +    /* Calculate the row size (dword-aligned) */ + +    wb = w * depth / 8; +    if (( wb * 8 / depth ) < w ) wb++; + +    bytesPerRow = wb; +    if ( bytesPerRow & 0x03 ) bytesPerRow = ( bytesPerRow & ~3 ) + 4; + +    gr->data = ( char * ) malloc( h * bytesPerRow ) ; +    if ( !gr->data )   // Sin memoria +    { +        free( gr ); +        return NULL; +    } + +    gr->width = w ; +    gr->height = h ; + +    gr->format = bitmap_create_format( depth ) ; + +    gr->pitch = bytesPerRow ; +    gr->widthb = wb ; + +    gr->code = code ; +    gr->name[ 0 ] = '\0'; + +    gr->ncpoints = 0; +    gr->cpoints = NULL ; + +    gr->format->palette = NULL ; + +    gr->blend_table = NULL ; + +    gr->modified = 0; +    gr->info_flags = 0; + +    return gr ; +} + +/* --------------------------------------------------------------------------- */ + +GRAPH * bitmap_clone( GRAPH * map ) +{ +    GRAPH * gr ; +    uint32_t y; + +    gr = bitmap_new( 0, map->width, map->height, map->format->depth ) ; +    if ( gr == NULL ) return NULL; + +    for ( y = 0 ; y < map->height ; y++ ) +        memcpy(( uint8_t* ) gr->data + gr->pitch * y, ( uint8_t* ) map->data + gr->pitch * y, gr->widthb ); + +    if ( map->cpoints ) +    { +        gr->cpoints = malloc( sizeof( CPOINT ) * map->ncpoints ) ; +        memcpy( gr->cpoints, map->cpoints, sizeof( CPOINT ) * map->ncpoints ) ; +        gr->ncpoints = map->ncpoints ; +    } + +    gr->blend_table = map->blend_table; +    gr->info_flags = map->info_flags & ~GI_EXTERNAL_DATA ; +    gr->modified = map->modified ; +    gr->format->palette = map->format->palette ; +    pal_use( map->format->palette ); + +    memcpy( gr->name, map->name, sizeof( map->name ) ) ; + +    return gr ; +} + +/* --------------------------------------------------------------------------- */ + +void bitmap_add_cpoint( GRAPH * map, int x, int y ) +{ +    map->cpoints = ( CPOINT * ) realloc( map->cpoints, ( map->ncpoints + 1 ) * sizeof( CPOINT ) ) ; +    map->cpoints[ map->ncpoints ].x = x ; +    map->cpoints[ map->ncpoints ].y = y ; +    map->ncpoints++; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : bitmap_set_cpoint + * + *  Set a control point in a graphic + * + *  PARAMS : + *      map             Pointer to the bitmap + *      point           Control point index + *      x               New X coordinate or CPOINT_UNDEFINED to unset + *      y               New Y coordinate or CPOINT_UNDEFINED to unset + * + *  RETURN VALUE : + *      None + * + */ + +void bitmap_set_cpoint( GRAPH * map, uint32_t point, int x, int y ) +{ +    uint32_t n; + +    if ( point < 0 ) return ; + +    if ( point == 0 && !map->modified ) map->modified = 1; + +    if ( map->ncpoints <= point ) +    { +        map->cpoints = ( CPOINT * ) realloc( map->cpoints, ( point + 1 ) * sizeof( CPOINT ) ) ; +        for ( n = map->ncpoints; n < point; n++ ) +        { +            map->cpoints[ n ].x = CPOINT_UNDEFINED; +            map->cpoints[ n ].y = CPOINT_UNDEFINED; +        } +        map->ncpoints = point + 1 ; +    } +    map->cpoints[ point ].x = x; +    map->cpoints[ point ].y = y; +} + +/* --------------------------------------------------------------------------- */ + +void bitmap_destroy( GRAPH * map ) +{ +    if ( !map ) return ; + +    if ( map->cpoints ) free( map->cpoints ) ; + +    if ( map->code > 999 ) bit_clr( map_code_bmp, map->code - 1000 ); + +    if ( map->data && !( map->info_flags & GI_EXTERNAL_DATA ) ) free( map->data ) ; + +    if ( map->format ) +    { +        if ( map->format->palette ) pal_destroy( map->format->palette ) ; +        free ( map->format ); +    } + +    free( map ) ; +} + +/* --------------------------------------------------------------------------- */ +/* Análisis */ + +void bitmap_analize( GRAPH * bitmap ) +{ +    uint32_t x, y; +    int color_present = 0, tranparent_present = 0; + +    if ( bitmap->modified > 1 ) bitmap->modified = 1 ; + +    bitmap->info_flags &= ~( GI_CLEAN | GI_NOCOLORKEY ); + +    /* Search for transparent pixels (value 0). +     * If none found, set the flag GI_NOCOLORKEY */ + +    switch ( bitmap->format->depth ) +    { +        case    8: +        { +            uint8_t * ptr = ( uint8_t * ) bitmap->data ; +            int inc = bitmap->pitch - bitmap->widthb ; + +            for ( y = bitmap->height; y--; ptr = ((( uint8_t * ) ptr ) + inc ) ) +            { +                for ( x = bitmap->width; x--; ) { +                    if ( *ptr ) color_present = 1; +                    if ( !*ptr++ ) tranparent_present = 1; +                } +                if ( color_present && tranparent_present ) break; +            } +        } +        break; +        case    16: +        { +            int16_t * ptr = ( int16_t * ) bitmap->data ; +            int inc = bitmap->pitch - bitmap->widthb ; + +            for ( y = bitmap->height; y--; ptr = ( int16_t * )((( uint8_t * ) ptr ) + inc ) ) +            { +                for ( x = bitmap->width; x--; ) { +                    if ( *ptr ) color_present = 1; +                    if ( !*ptr++ ) tranparent_present = 1; +                } +                if ( color_present && tranparent_present ) break; +            } +        } +        break; +        case    32: +        { +            int32_t * ptr = ( int32_t * ) bitmap->data ; +            int inc = bitmap->pitch - bitmap->widthb ; + +            for ( y = bitmap->height; y--; ptr = ( int32_t * )((( uint8_t * ) ptr ) + inc ) ) +            { +                for ( x = bitmap->width; x--; ) { +                    if ( ( *ptr & 0xff000000 ) != 0x00000000 ) color_present = 1; +                    if ( !*ptr ) tranparent_present = 1; +                    ptr++; +                } +                if ( color_present && tranparent_present ) break; +            } +        } +    } + +    if ( color_present && !tranparent_present ) { +        bitmap->info_flags |= GI_NOCOLORKEY ; +    } else +    if ( !color_present && tranparent_present ) { +        bitmap->info_flags |= GI_CLEAN ; +    } +} + +/* --------------------------------------------------------------------------- */ +/* Returns the code of a new system library graph (1000+). Searchs +   for free slots if the program creates too many system maps */ + +int bitmap_next_code() +{ +    int n, nb, lim, ini ; + +    // Si tengo suficientes alocados, retorno el siguiente segun map_code_last +    if ( map_code_last < map_code_allocated ) +    { +        if ( !bit_tst( map_code_bmp, map_code_last ) ) +        { +            bit_set( map_code_bmp, map_code_last ); +            return 1000 + map_code_last++ ; +        } +    } + +    // Ya no tengo mas espacio, entonces busco alguno libre entre ~+32 desde el ultimo fijo y ~-32 del ultimo asignado + +    ini = ( map_code_last < map_code_allocated ) ? ( map_code_last >> 5 ) : 0 ; +    lim = ( map_code_allocated >> 5 ) ; + +    while ( 1 ) +    { +        for ( n = ini; n < lim ; n++ ) +        { +            if ( map_code_bmp[n] != ( uint32_t ) 0xFFFFFFFF ) // Aca hay 1 libre, busco cual es +            { +                for ( nb = 0; nb < 32; nb++ ) +                { +                    if ( !bit_tst( map_code_bmp + n, nb ) ) +                    { +                        map_code_last = ( n << 5 ) + nb ; +                        bit_set( map_code_bmp, map_code_last ); +                        return 1000 + map_code_last++ ; +                    } +                } +            } +        } +        if ( !ini ) break; +        lim = ini; +        ini = 0; +    } + +    map_code_last = map_code_allocated ; + +    // Increment space, no more slots availables +    // 256 new maps available for alloc + +    map_code_allocated += 256 ; +    map_code_bmp = ( uint32_t * ) realloc( map_code_bmp, sizeof( uint32_t ) * ( map_code_allocated >> 5 ) ); + +    memset( &map_code_bmp[( map_code_last >> 5 )], 0, 32 );  /* 256 >> 5 = 8 * sizeof ( uint32_t ) = 8 * 4 = 32 */ + +    // Devuelvo map_code_last e incremento en 1, ya que ahora tengo BLOCK_INCR mas que antes +    bit_set( map_code_bmp, map_code_last ); +    return 1000 + map_code_last++ ; + +} + +/* --------------------------------------------------------------------------- */ + +GRAPH * bitmap_new_syslib( int w, int h, int depth ) +{ +    GRAPH * gr ; + +    if ( !syslib ) return NULL; + +    gr = bitmap_new( 0, w, h, depth ) ; +    if ( !gr ) return NULL; + +    gr->code = bitmap_next_code() ; +    grlib_add_map( 0, gr ) ; + +    return gr ; +} + +/* --------------------------------------------------------------------------- */ diff --git a/modules/libgrbase/g_bitmap.h b/modules/libgrbase/g_bitmap.h new file mode 100644 index 0000000..d98bbe5 --- /dev/null +++ b/modules/libgrbase/g_bitmap.h @@ -0,0 +1,131 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __BITMAP_H +#define __BITMAP_H + +#include "g_pal.h" + +/* --------------------------------------------------------------------------- */ + +#define GI_NOCOLORKEY       0x00000001  /* info_flags bits */ +#define GI_CLEAN            0x40000000  /* the graphic is clean (no data) */ +#define GI_EXTERNAL_DATA    0x80000000  /* data area is external, it don't belong to bitmap */ + +#define GI_ANALIZE_MASK     GI_NOCOLORKEY + +#define CPOINT_UNDEFINED    32767       /* It's enough if X is set to this value */ + +/* --------------------------------------------------------------------------- */ + +typedef struct _cpoint +{ +    short int x; +    short int y; +} +CPOINT; + +typedef struct _pixel_format +{ +    PALETTE * palette;  /* Palette for 8 bits graphics */ + +    uint8_t  depth;       /* bits per pixel */ +    uint8_t  depthb;      /* bytes per pixel */ + +    uint8_t  Rloss; +    uint8_t  Gloss; +    uint8_t  Bloss; +    uint8_t  Aloss; + +    uint8_t  Rshift; +    uint8_t  Gshift; +    uint8_t  Bshift; +    uint8_t  Ashift; + +    uint32_t Rmask; +    uint32_t Gmask; +    uint32_t Bmask; +    uint32_t Amask; +} +PIXEL_FORMAT; + +typedef struct _bitmap +{ +    int code;               /* Identifier of the graphic (in the graphic library) */ +    char name[ 64 ];        /* Name of the graphic */ + +    uint32_t width;           /* Width of a bitmap frame in pixels */ +    uint32_t height;          /* Height of a bitmap frame in pixels */ + +    uint32_t pitch;           /* Bytes of distance between bitmap lines */ +    uint32_t widthb;          /* Width of a bitmap frame in bytes */ + +    PIXEL_FORMAT * format;  /* Pixel format */ + +    /* Runtime use */ +    int modified;           /* 0 - bitmap not modified +                               1 - bitmap is modified +                               2 - bitmap is modified and needs analysis +                             */ +    int info_flags;         /* Analysis result (see bitmap_analize) */ + +    void * data;            /* Pointer to the bitmap data at current frame */ + +    uint32_t ncpoints;        /* Number of control points */ +    CPOINT * cpoints;       /* Pointer to the control points ([0] = center) */ + +    /* Blend Ops */ +    int16_t * blend_table;   /* Pointer to 16 bits blend table if any */ + +    /* Linked list of all bitmaps in memory */ +/* +    struct _bitmap * next; +    struct _bitmap * prev; +*/ +} +GRAPH; + +/* --------------------------------------------------------------------------- */ + +extern GRAPH * bitmap_new( int code, int w, int h, int depth ); +extern GRAPH * bitmap_new_ex( int code, int w, int h, int depth, void * data, int pitch ); +extern GRAPH * bitmap_clone( GRAPH * t ); +extern GRAPH * bitmap_new_syslib( int w, int h, int depth ); +extern void bitmap_destroy( GRAPH * map ); +extern void bitmap_destroy_fake( GRAPH * map ); +extern void bitmap_add_cpoint( GRAPH *map, int x, int y ); +extern void bitmap_set_cpoint( GRAPH * map, uint32_t point, int x, int y ); +extern void bitmap_analize( GRAPH * bitmap ); + +extern PIXEL_FORMAT * bitmap_create_format( int bpp ); + +extern int bitmap_next_code(); + +/* --------------------------------------------------------------------------- */ + +#endif diff --git a/modules/libgrbase/g_blendop.c b/modules/libgrbase/g_blendop.c new file mode 100644 index 0000000..d05784b --- /dev/null +++ b/modules/libgrbase/g_blendop.c @@ -0,0 +1,448 @@ +/* + *  Copyright © 2006-2016 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +/* --------------------------------------------------------------------------- */ + +#include <stdlib.h> +#include "libgrbase.h" + +/* --------------------------------------------------------------------------- */ + +/* Fast macros for color component extraction from a 16 bits value */ + +#define GETR(color) (((color & sys_pixel_format->Rmask) >> sys_pixel_format->Rshift) << sys_pixel_format->Rloss) +#define GETG(color) (((color & sys_pixel_format->Gmask) >> sys_pixel_format->Gshift) << sys_pixel_format->Gloss) +#define GETB(color) (((color & sys_pixel_format->Bmask) >> sys_pixel_format->Bshift) << sys_pixel_format->Bloss) + +/* Fast macros for color composition */ + +#define MAKERGB_SATURATE(r,g,b)                                             \ +    (                                                                           \ +            ((int)(r) > 255 ? sys_pixel_format->Rmask : (((int)(r) >> sys_pixel_format->Rloss) << sys_pixel_format->Rshift)) |    \ +            ((int)(g) > 255 ? sys_pixel_format->Gmask : (((int)(g) >> sys_pixel_format->Gloss) << sys_pixel_format->Gshift)) |    \ +            ((int)(b) > 255 ? sys_pixel_format->Bmask : (((int)(b) >> sys_pixel_format->Bloss) << sys_pixel_format->Bshift))      \ +    ) + +#define MAKERGB(r,g,b)                                                  \ +    (                                                                       \ +            (((int)(r) >> sys_pixel_format->Rloss) << sys_pixel_format->Rshift) |   \ +            (((int)(g) >> sys_pixel_format->Gloss) << sys_pixel_format->Gshift) |   \ +            (((int)(b) >> sys_pixel_format->Bloss) << sys_pixel_format->Bshift)     \ +    ) + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_init + * + *  Initialize a blend table as a copy operation + * + *      Src_param   =   Src_color + *      Dst_param   =   0 + * + *  PARAMS : + *      blend           Pointer to the blend table + *      amount         Color component factor (1.0f leaves source unchanged) + * + *  RETURN VALUE : + *      None + */ + +void blend_init( int16_t * blend ) +{ +    int i; +    int16_t * blend2; + +    if ( !blend ) return ; + +    blend2 = blend + 65536; + +    for ( i = 0; i < 65536; i++ ) +    { +        *blend++ = i; +        *blend2++ = 0; +    } +} + +/* --------------------------------------------------------------------------- */ +/* ************************* */ +/* Blendops public functions */ +/* ************************* */ +/* + *  FUNCTION : blend_create + * + *  Create a new blendop table and initialize it with blend_init + *  A blendop table is a group of two tables that return intermediate + *  colors to a composite (+) operation that does no saturation: + * + *      Src_param   =   Src_color + *      Dst_param   =   Dst_color + *      Dst_color   =   Src_param + Dst_param       // No clamp! + * + *  The other blend_x funcions change the Src_param and Dst_param formulas. + *  The Dst_color formula is immutable and embedded in the blitter + * + *  PARAMS : + *      None + * + *  RETURN VALUE : + *      Pointer to the new blendop table or NULL if not enough memory + */ + +int16_t * blend_create( void ) +{ +    int16_t * blend = malloc( 65536 * 2 * sizeof( int16_t ) ); +    if ( !blend ) return NULL; + +    blend_init( blend ); + +    return blend; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_apply + * + *  Apply a blend operation to the pixels of a graphic, as if it was + *  rendered into a black (color 0) background + * + *  PARAMS : + *      graph           Pointer to the graphic + *      blend           Pointer to the blend table + * + *  RETURN VALUE : + *      0               Error + *      1               OK + */ + +void blend_apply( GRAPH * graph, int16_t * blend ) +{ +    uint16_t * ptr; +    uint32_t x, y; +    uint8_t * ptr8; +    int16_t * blend2; + +    if ( !graph || !blend || graph->format->depth != 16 ) return ; + +    blend2 = blend + 65536; + +    ptr = ( uint16_t * ) (ptr8 = ( uint8_t * ) graph->data); +    y = graph->height; +    while ( y-- ) +    { +        x = graph->width; +        while ( x-- ) +        { +            if ( *ptr ) * ptr = blend[ *ptr ] + blend2[ *ptr ]; +            ptr++; +        } +        ptr = ( uint16_t * ) (ptr8 += graph->pitch); +    } + +    graph->modified = 2; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_assign + * + *  Assign a blend operation to a graphic. The graphic will be + *  drawn using this blend operation thereafter. + * + *  PARAMS : + *      graph           Pointer to the graphic + *      blend           Pointer to the blend table + * + *  RETURN VALUE : + *      None + */ + +void blend_assign( GRAPH * graph, int16_t * blend ) +{ +    if ( !graph ) return ; +    graph->blend_table = blend; +    graph->modified = 1; /* Don't needs analysis */ +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_free + * + *  Free the memory used by a blendop table + * + *  PARAMS : + *      blend           Pointer to the blend table + * + *  RETURN VALUE : + *      None + */ + +void blend_free( int16_t * blend ) +{ +    if ( !blend ) return ; +    free( blend ); +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_grayscale + * + *  Initialize a blend table as a grayscale operation (changes the + *  color value of the source object to grayscale). Three methods + *  of operation are supported: + * + *      1.  Luminance:  result = 0.3R + 0.59G + 0.11B + *      2.  Desaturate: result = (MAX(R,G,B)+MIN(R,G,B))/2 + *      3.  Maximum:    result = MAX(R,G,B) + * + * + *      Src_param   =   Grayscale_operation(previous Src_param) + * + *  PARAMS : + *      blend           Pointer to the blend table + *      method          Method of operation + * + *  RETURN VALUE : + *      0               Error + *      1               Ok + */ + +void blend_grayscale( int16_t * blend, int method ) +{ +    int i, r, g, b, max, min; +    int16_t * blend2; + +    if ( !blend ) return ; + +    switch ( method ) +    { +        case 1: +            blend2 = blend + 65536; + +            for ( i = 0; i < 65536; i++ ) +            { +                r = ( int )( GETR( i ) * 0.3 ); +                g = ( int )( GETG( i ) * 0.59 ); +                b = ( int )( GETB( i ) * 0.11 ); +                r = r + g + b; +                *blend++ = MAKERGB( r, r, r ); +                *blend2++ = 0; +            } +            break; + +        case 2: +            blend2 = blend + 65536; + +            for ( i = 0; i < 65536; i++ ) +            { +                r = GETR( i ); +                g = GETG( i ); +                b = GETB( i ); + +            max = ( r > g ) ? ( r > b ) ? r : g : ( g > b ) ? g : b; +            min = ( r < g ) ? ( r < b ) ? r : g : ( g < b ) ? g : b; + +                r = ( max + min ) / 2; +                *blend++ = MAKERGB( r, r, r ); +                *blend2++ = 0; +            } +            break; + +        case 3: +            blend2 = blend + 65536; + +            for ( i = 0; i < 65536; i++ ) +            { +                r = GETR( i ); +                g = GETG( i ); +                b = GETB( i ); + +            max = ( r > g ) ? ( r > b ) ? r : g : ( g > b ) ? g : b; + +                *blend++ = MAKERGB( max, max, max ); +                *blend2++ = 0; +            } +            break; +    } +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_translucency + * + *  Modify a blend table as a translucency combination operation + * + *      Src_param   =   (previous Src_param) * amount + *      Dst_param   =   Dst_color * (1.0 - amount) + * + *  PARAMS : + *      blend           Pointer to the blend table + *      amount         Opacity factor (1.0f = opaque, 0.0f = transparent) + * + *  RETURN VALUE : + *      None + */ + +void blend_translucency( int16_t * blend, float amount ) +{ +    int i, r, g, b; +    float amount2; +    int16_t * blend2; + +    if ( !blend ) return ; + +    blend2 = blend + 65536; + +    if ( amount > 1.0f ) amount = 1.0f; +    if ( amount < 0.0f ) amount = 0.0f; + +    amount = 1.0f - amount; +    amount2 = 1.0f - amount; + +    for ( i = 0; i < 65536; i++ ) +    { +        r = ( int )( GETR( *blend ) * amount ); +        g = ( int )( GETG( *blend ) * amount ); +        b = ( int )( GETB( *blend ) * amount ); +        *blend++ = MAKERGB( r, g, b ); + +        r = ( int )( GETR( i ) * amount2 ); +        g = ( int )( GETG( i ) * amount2 ); +        b = ( int )( GETB( i ) * amount2 ); +        *blend2++ = MAKERGB( r, g, b ); +    } +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_intensity + * + *  Modify a blend table as an intensity operation (changes the + *  color value of the source object as the factor amount but + *  does no transparency or other operation with the background) + * + *      Src_param   =   (previous Src_param) * amount + * + *  PARAMS : + *      blend           Pointer to the blend table + *      amount         Color component factor (1.0f leaves source unchanged) + * + *  RETURN VALUE : + *      None + */ + +void blend_intensity( int16_t * blend, float amount ) +{ +    int i, r, g, b; + +    if ( !blend ) return ; + +    if ( amount < 0.0f ) amount = 0.0f; + +    for ( i = 65536; i--; ) +    { +        r = ( int )( GETR( *blend ) * amount ); +        g = ( int )( GETG( *blend ) * amount ); +        b = ( int )( GETB( *blend ) * amount ); +        *blend++ = MAKERGB_SATURATE( r, g, b ); +    } +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_swap + * + *  Swaps a blendop table. That is, change the blend operation so + *  the Dst_color and Src_color are exchanged in the formulas. + * + *  PARAMS : + *      blend           Pointer to the blend table + * + *  RETURN VALUE : + *      None + */ + +void blend_swap( int16_t * blend ) +{ +    int i, j; +    int16_t * blend2; + +    if ( !blend ) return ; + +    blend2 = blend + 65536; + +    for ( i = 65536; i--; ) +    { +        j = *blend; +        *blend++ = *blend2; +        *blend2++ = j; +    } +} + + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : blend_tint + * + *  Modify a blend table as a tint operation (changes the + *  color value of the source object as a combination of a given + *  color and the source color with the factor given) + * + *      Src_param = Const_color * amount + *                  + (previous Src_Param) * (1.0f-amount) + * + *  PARAMS : + *      blend           Pointer to the blend table + *      amount         Color component factor (1.0f = Full Const color) + *      cr              Constant color, red component (0-255) + *      cg              Constant color, green component (0-255) + *      cb              Constant color, blue component (0-255) + * + *  RETURN VALUE : + *      None + */ + +void blend_tint( int16_t * blend, float amount, uint8_t cr, uint8_t cg, uint8_t cb ) +{ +    int i, r, g, b; + +    if ( !blend ) return ; + +    if ( amount > 1.0f ) amount = 1.0f; +    if ( amount < 0.0f ) amount = 0.0f; + +    for ( i = 65536; i--; ) +    { +        r = ( int )( amount * cr + ( 1.0f - amount ) * GETR( *blend ) ); +        g = ( int )( amount * cg + ( 1.0f - amount ) * GETG( *blend ) ); +        b = ( int )( amount * cb + ( 1.0f - amount ) * GETB( *blend ) ); +        *blend = MAKERGB_SATURATE( r, g, b ); +        blend++; +    } +} + +/* --------------------------------------------------------------------------- */ diff --git a/modules/libgrbase/g_blendop.h b/modules/libgrbase/g_blendop.h new file mode 100644 index 0000000..1c97e17 --- /dev/null +++ b/modules/libgrbase/g_blendop.h @@ -0,0 +1,46 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __BLEND_H +#define __BLEND_H + +/* Blend ops */ +/* --------- */ + +extern void blend_apply( GRAPH * bitmap, int16_t * blend ) ; +extern void blend_assign( GRAPH * bitmap, int16_t * blend ) ; +extern int16_t * blend_create( void ) ; +extern void blend_free( int16_t * blend ); +extern void blend_grayscale( int16_t * blend, int method ) ; +extern void blend_init( int16_t * blend ) ; +extern void blend_intensity( int16_t * blend, float ammount ) ; +extern void blend_swap( int16_t * blend ) ; +extern void blend_tint( int16_t * blend, float ammount, uint8_t cr, uint8_t cg, uint8_t cb ) ; +extern void blend_translucency( int16_t * blend, float ammount ) ; + +#endif diff --git a/modules/libgrbase/g_clear.c b/modules/libgrbase/g_clear.c new file mode 100644 index 0000000..7bb0603 --- /dev/null +++ b/modules/libgrbase/g_clear.c @@ -0,0 +1,222 @@ +/* + *  Copyright � 2006-2016 SplinterGU (Fenix/Bennugd) + *  Copyright � 2002-2006 Fenix Team (Fenix) + *  Copyright � 1999-2002 Jos� Luis Cebri�n Pag�e (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +/* --------------------------------------------------------------------------- */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "libgrbase.h" + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : gr_clear + * + *  Clear a bitmap (paint all pixels as 0 [transparent]) + * + *  PARAMS : + *      dest            Bitmap to clear + * + *  RETURN VALUE : + *      None + * + */ + +void gr_clear( GRAPH * dest ) +{ +    memset( dest->data, 0, dest->pitch * dest->height ) ; + +    dest->modified = 1 ; /* Don't needs analysis */ +    dest->info_flags &= ~GI_NOCOLORKEY; +    dest->info_flags |= GI_CLEAN; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : gr_clear_as + * + *  Clear a bitmap (paint all pixels as the given color) + * + *  PARAMS : + *      dest            Bitmap to clear + *      color           8 or 16-bit color value + * + *  RETURN VALUE : + *      None + * + */ + +void gr_clear_as( GRAPH * dest, int color ) +{ +    uint32_t y; + +    if ( !color ) +    { +        gr_clear( dest ); +        return; +    } + +    switch ( dest->format->depth ) +    { +        case 8: +        { +            memset( dest->data, color, dest->pitch * dest->height ) ; +            break; +        } + +        case 16: +        { +            uint8_t * data = dest->data ; +            int16_t * ptr ; +            int n ; +            y = dest->height; +            while ( y-- ) +            { +                ptr = ( int16_t * ) data; +                n = dest->width; +                while ( n-- ) * ptr++ = color ; +                data += dest->pitch ; +            } +            break; +        } + +        case 32: +        { +            uint8_t * data = dest->data ; +            uint32_t * ptr ; +            int n ; +            y = dest->height; +            while ( y-- ) +            { +                ptr = ( uint32_t * ) data; +                n = dest->width; +                while ( n-- ) * ptr++ = color ; +                data += dest->pitch ; +            } +            break; +        } + +        case 1: +        { +            int c = color ? 0xFF : 0 ; +            memset( dest->data, c, dest->pitch * dest->height ) ; +            break; +        } +    } + +    dest->modified = 1 ; /* Don't needs analysis */ +    if ( dest->format->depth != 32 || ( color & 0xff000000 ) == 0xff000000 ) +        dest->info_flags |= GI_NOCOLORKEY; +    else +        dest->info_flags &= ~GI_NOCOLORKEY; +    dest->info_flags &= ~GI_CLEAN; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : gr_clear_region + * + *  Clear a region bitmap (paint all pixels as 0 [transparent]) + * + *  PARAMS : + *      dest            Bitmap to clear + *      region          Region to clear or NULL for the whole screen + * + *  RETURN VALUE : + *      None + * + */ + +void gr_clear_region( GRAPH * dest, REGION * region ) +{ +    REGION base_region ; +    int y, l ; + +    if ( !dest ) dest = scrbitmap ; + +    if ( !region ) +    { +        region = &base_region ; +        region->x = 0 ; +        region->y = 0 ; +        region->x2 = dest->width - 1 ; +        region->y2 = dest->height - 1 ; +    } +    else +    { +        base_region = *region ; +        region = &base_region ; + +        region->x = MAX( MIN( region->x, region->x2 ), 0 ) ; +        region->y = MAX( MIN( region->y, region->y2 ), 0 ) ; +        region->x2 = MIN( MAX( region->x, region->x2 ), dest->width - 1 ) ; +        region->y2 = MIN( MAX( region->y, region->y2 ), dest->height - 1 ) ; +    } + +    if ( region->x > dest->width || region->y > dest->height ) return; +    if ( region->x2 < 0 || region->y2 < 0 ) return; + +    switch ( dest->format->depth ) +    { +        case 8: +        case 16: +        case 32: +        { +            uint8_t * data = (( uint8_t * ) dest->data ) + dest->pitch * region->y + region->x * dest->format->depthb; +            l = ( region->x2 - region->x + 1 ) * dest->format->depthb; +            for ( y = region->y; y <= region->y2; y++ ) +            { +                memset( data, 0, l ); +                data += dest->pitch ; +            } +            break ; +        } + +        case 1: +        { +            uint8_t * data = (( uint8_t * ) dest->data ) + region->x / 8 ; +            l = ( region->x2 - region->x - 1 ) / 8 + 1 ; +            for ( y = region->y; y <= region->y2; y++ ) +            { +                /* Esta debe ser cambiada, por bits */ +                memset( data, 0, l ) ; +                data += dest->pitch ; +            } +            break ; +        } + +        default: +            return; +    } + +    dest->modified = 1 ; /* Don't needs analysis */ +    dest->info_flags &= ~GI_NOCOLORKEY; +} + +/* --------------------------------------------------------------------------- */ diff --git a/modules/libgrbase/g_clear.h b/modules/libgrbase/g_clear.h new file mode 100644 index 0000000..8b4684d --- /dev/null +++ b/modules/libgrbase/g_clear.h @@ -0,0 +1,39 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __CLEAR_H +#define __CLEAR_H + +#include "bgdcore.h" +#include "g_region.h" + +extern void gr_clear( GRAPH * dest ); +extern void gr_clear_as( GRAPH * dest, int color ); +extern void gr_clear_region( GRAPH * dest, REGION * region ); + +#endif diff --git a/modules/libgrbase/g_conversion.c b/modules/libgrbase/g_conversion.c new file mode 100644 index 0000000..1add7ec --- /dev/null +++ b/modules/libgrbase/g_conversion.c @@ -0,0 +1,481 @@ +/* + *  Copyright © 2006-2016 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +/* --------------------------------------------------------------------------- */ + +#include <stdlib.h> +#include "libgrbase.h" + +#include "bgddl.h" +#include "dlvaracc.h" + +/* --------------------------------------------------------------------------- */ + +/* Conversion tables - used by 16 bits conversions - 256K */ +static uint16_t * convert565ToScreen = NULL ; +static uint16_t * convertScreenTo565 = NULL ; +static int conversion_tables_ok = 0 ; + +/* Alpha multiplication tables - multiply a color by its alpha. + * There will be less than 256 levels + */ +static uint16_t * alpha16[ 256 ]; +static uint8_t * alpha8[ 256 ]; +static int alpha16_tables_ok = 0 ; +static int alpha8_tables_ok = 0 ; + +/* --------------------------------------------------------------------------- */ +/* used for variable access                                                    */ +/* --------------------------------------------------------------------------- */ + +enum { +    ALPHA_STEPS = 0 +}; + +/* --------------------------------------------------------------------------- */ +/* Son las variables que se desea acceder.                                     */ +/* El interprete completa esta estructura, si la variable existe.              */ +/* (usada en tiempo de ejecucion)                                              */ + +DLVARFIXUP __bgdexport( libgrbase, globals_fixup )[] = +{ +    /* Nombre de variable global, puntero al dato, tamaño del elemento, cantidad de elementos */ +    { "alpha_steps" , NULL, -1, -1 }, +    { NULL , NULL, -1, -1 } +}; + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : init_alpha16_tables + * + *  Init the 16 bit alpha tables (create as many tables as the parameter) + *  Each alpha table has a 128K memory footprint. Having many alpha tables + *  provides more transparency values. + * + *  PARAMS : + *  count   Number of tables + * + *  RETURN VALUE : + *      None + * + */ + +static void init_alpha16_tables( int count ) +{ +    int i, color, inc, next = 0, factor; +    uint16_t * table16 = NULL; + +    if ( count <= 0 ) count = 1; +    if ( count > 128 ) count = 128; + +    if ( alpha16_tables_ok == count ) return ; + +    inc = 256 / count; + +    /* Destroy existing tables */ + +    if ( alpha16_tables_ok ) +    { +        for ( table16 = NULL, i = 0 ; i < 256 ; i++ ) +        { +            if ( alpha16[ i ] != table16 ) +            { +                table16 = alpha16[ i ]; +                free( table16 ); +            } +            alpha16[ i ] = NULL; +        } +    } + +    /* Make new ones */ + +    for ( i = 0 ; i < 256 ; i++ ) +    { +        if ( i == next ) +        { +            table16 = malloc( 131072 ); +            factor = next + inc / 2; +            next += inc; +            if ( factor > 255 ) factor = 256; + +            for ( color = 0 ; color < 65536 ; color++ ) +            { +                int r = (( color & sys_pixel_format->Rmask ) >> sys_pixel_format->Rshift << sys_pixel_format->Rloss ) ; +                int g = (( color & sys_pixel_format->Gmask ) >> sys_pixel_format->Gshift << sys_pixel_format->Gloss ) ; +                int b = (( color & sys_pixel_format->Bmask ) >> sys_pixel_format->Bshift << sys_pixel_format->Bloss ) ; + +                table16[ color ] = +                    (((( r * factor ) >> 8 ) >> sys_pixel_format->Rloss ) << sys_pixel_format->Rshift ) | +                    (((( g * factor ) >> 8 ) >> sys_pixel_format->Gloss ) << sys_pixel_format->Gshift ) | +                    (((( b * factor ) >> 8 ) >> sys_pixel_format->Bloss ) << sys_pixel_format->Bshift ) ; +            } +        } +        alpha16[ i ] = table16; +    } + +    alpha16_tables_ok = count; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : init_alpha8_tables + * + *  Init the 8 bit alpha tables (create as many tables as the parameter) + *  Each alpha table has a 64K memory footprint. Having many alpha tables + *  provides more transparency values. Those tables should be updated + *  when the palette changes. + * + *  PARAMS : + *  count   Number of tables + * + *  RETURN VALUE : + *      None + * + */ + +static void init_alpha8_tables( int count ) +{ +    int i, color, color2, inc, next = 0, factor; +    uint8_t * table8 = NULL; +    rgb_component * rgb ; + +    if ( count <= 0 ) count = 1; +    if ( count > 128 ) count = 128; + +    if ( alpha16_tables_ok == count ) return ; + +    inc = 256 / count; + +    /* Destroy existing tables */ + +    if ( alpha8_tables_ok ) +    { +        for ( table8 = NULL, i = 0; i < 256; i++ ) +        { +            if ( alpha8[ i ] != table8 ) +            { +                table8 = alpha8[ i ]; +                free( table8 ); +            } +            alpha8[ i ] = NULL; +        } +    } + +    /* Make new ones */ + +    if ( !sys_pixel_format->palette ) +        rgb = ( rgb_component * ) default_palette; +    else +        rgb = sys_pixel_format->palette->rgb ; + +    for ( i = 0; i < 256; i++ ) +    { +        if ( i == next ) +        { +            table8 = malloc( 65536 ); +            factor = next + inc / 2; +            next += inc; +            if ( factor > 255 ) factor = 255; + +            for ( color = 0; color < 256; color++ ) +            { +                for ( color2 = 0; color2 < 256; color2++ ) +                { +                    int r = ( rgb[ color ].r * factor + rgb[ color2 ].r * ( 255 - factor ) ) >> 8 ; +                    int g = ( rgb[ color ].g * factor + rgb[ color2 ].g * ( 255 - factor ) ) >> 8 ; +                    int b = ( rgb[ color ].b * factor + rgb[ color2 ].b * ( 255 - factor ) ) >> 8 ; +                    table8[( color << 8 ) + color2 ] = gr_find_nearest_color( r, g, b ); +                } +                table8[ color ] = color; +            } +        } +        alpha8[ i ] = table8; +    } + +    alpha8_tables_ok = count; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : init_conversion_tables + * + *  Static routine used to initialize the 16 bits conversion + *  tables (this only needs to be done once) + * + *  PARAMS : + *  None + * + *  RETURN VALUE : + *      None + * + */ + +static void init_conversion_tables() +{ +    uint8_t r, g, b ; +    int n ; + +    /* Alloc space for the lookup tables */ + +    convert565ToScreen = ( uint16_t * ) malloc( sizeof( uint16_t ) * 65536 ); +    if ( !convert565ToScreen ) return ; + +    convertScreenTo565 = ( uint16_t * ) malloc( sizeof( uint16_t ) * 65536 ); +    if ( !convertScreenTo565 )  // No memory +    { +        free( convert565ToScreen ); +        return ; +    } + +    /* Special case if screen already in 565 format */ + +    if ( sys_pixel_format->Rmask == 0xF800 && +            sys_pixel_format->Gmask == 0x07E0 && +            sys_pixel_format->Bmask == 0x001F ) +    { +        for ( n = 0; n < 65536; n++ ) +        { +            convert565ToScreen[ n ] = n; +            convertScreenTo565[ n ] = n; +        } +        return ; +    } + +    /* Create a fast lookup array */ + +    for ( n = 0; n < 65536; n++ ) +    { +        /* Calculate conversion from 565 to screen format */ + +        r = (( n >> 8 ) & 0xF8 ) >> sys_pixel_format->Rloss ; +        g = (( n >> 3 ) & 0xFC ) >> sys_pixel_format->Gloss ; +        b = (( n << 3 ) & 0xF8 ) >> sys_pixel_format->Bloss ; + +        convert565ToScreen[ n ] = ( r << sys_pixel_format->Rshift ) | ( g << sys_pixel_format->Gshift ) | ( b << sys_pixel_format->Bshift ) ; + +        /* Calculate conversion from 565 to screen format */ + +        r = ((( n & sys_pixel_format->Rmask ) >> sys_pixel_format->Rshift ) << sys_pixel_format->Rloss ); +        g = ((( n & sys_pixel_format->Gmask ) >> sys_pixel_format->Gshift ) << sys_pixel_format->Gloss ); +        b = ((( n & sys_pixel_format->Bmask ) >> sys_pixel_format->Bshift ) << sys_pixel_format->Bloss ); + +        convertScreenTo565[ n ] = (( r & 0xF8 ) << 8 ) | (( g & 0xFC ) << 3 ) | (( b & 0xF8 ) >> 3 ) ; +    } +    conversion_tables_ok = 1; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : gr_convert16_565ToScreen + * + *  Convert a sequence of 16 bits pixels from 5:6:5 format to + *  the format used by the screen (usually 5:5:5 or 5:6:5) + * + *  PARAMS : + *  ptr    Pointer to the first pixel + *  len    Number of pixels (not bytes!) + * + *  RETURN VALUE : + *      None + * + */ + +void gr_convert16_565ToScreen( uint16_t * ptr, int len ) +{ +    if ( !conversion_tables_ok ) init_conversion_tables(); + +    while ( len-- ) +    { +        *ptr = convert565ToScreen[ *ptr ] ; +        ptr++; +    } +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : gr_convert16_ScreenTo565 + * + *  Convert a sequence of 16 bits pixels in screen format + *  (usually 5:5:5 or 5:6:5) to the 5:6:5 format used to + *  store 16 bits pixel values to files in disk + * + *  PARAMS : + *  ptr    Pointer to the first pixel + *  len    Number of pixels (not bytes!) + * + *  RETURN VALUE : + *      None + * + */ + +void gr_convert16_ScreenTo565( uint16_t * ptr, int len ) +{ +    if ( !conversion_tables_ok ) init_conversion_tables(); + +    while ( len-- ) +    { +        *ptr = convertScreenTo565[ *ptr ] ; +        ptr++; +    } +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : gr_fade16 + * + *  Fade a 16-bit graphic a given ammount. Fading values are given in percent + *  (0% = black, 100% = original color, 200% = full color value) + * + *  PARAMS : + *  graph   Pointer to the graphic object + *  r    Percent of Red component + *  g    Percent of Green component + *  b    Percent of Blue component + * + *  RETURN VALUE : + *      None + * + */ + +void gr_fade16( GRAPH * graph, int r, int g, int b ) +{ +    uint32_t Rtable[ 32 ]; +    uint32_t Gtable[ 32 ]; +    uint32_t Btable[ 32 ]; +    uint32_t x, y; +    uint32_t Rmask; +    uint32_t Rshift; +    uint32_t Gmask; +    uint32_t Gshift; +    uint32_t Bmask; +    uint32_t Bshift; + +    for ( x = 0 ; x < 32 ; x++ ) +    { +        int c = 8 * x + 7; + +        if ( r <= 100 ) +            Rtable[ x ] = ( c * r / 100 ) >> sys_pixel_format->Rloss << sys_pixel_format->Rshift; +        else +            Rtable[ x ] = ( c + ( 255 - c ) * ( r - 100 ) / 100 ) >> sys_pixel_format->Rloss << sys_pixel_format->Rshift; + +        if ( g <= 100 ) +            Gtable[ x ] = ( c * g / 100 ) >> sys_pixel_format->Gloss << sys_pixel_format->Gshift; +        else +            Gtable[ x ] = ( c + ( 255 - c ) * ( g - 100 ) / 100 ) >> sys_pixel_format->Gloss << sys_pixel_format->Gshift; + +        if ( b <= 100 ) +            Btable[ x ] = ( c * b / 100 ) >> sys_pixel_format->Bloss << sys_pixel_format->Bshift; +        else +            Btable[ x ] = ( c + ( 255 - c ) * ( b - 100 ) / 100 ) >> sys_pixel_format->Bloss << sys_pixel_format->Bshift; +    } + +    Rmask = sys_pixel_format->Rmask; +    Gmask = sys_pixel_format->Gmask; +    Bmask = sys_pixel_format->Bmask; + +    Rshift = sys_pixel_format->Rshift - sys_pixel_format->Rloss + 3; +    Gshift = sys_pixel_format->Gshift - sys_pixel_format->Gloss + 3; +    Bshift = sys_pixel_format->Bshift - sys_pixel_format->Bloss + 3; + +    if ( graph->format->depth == 16 ) +    { +        char * p = graph->data ; +        uint16_t * ptr ; + +        for ( y = 0 ; y < graph->height ; y++ ) +        { +            ptr = ( uint16_t * ) p ; + +            for ( x = 0 ; x < graph->width ; x++, ptr++ ) +            { +                *ptr = ( Rtable[(( *ptr & Rmask ) >> Rshift )] | Gtable[(( *ptr & Gmask ) >> Gshift )] | Btable[(( *ptr & Bmask ) >> Bshift )] ); +            } +            p += graph->pitch ; +        } +    } +    else if ( graph->format->depth == 32 ) +    { +        char * p = graph->data ; +        uint32_t * ptr ; + +        for ( y = 0 ; y < graph->height ; y++ ) +        { +            ptr = ( uint32_t * ) p ; +            for ( x = 0 ; x < graph->width ; x++, ptr++ ) +            { +                *ptr = ( Rtable[(( *ptr & Rmask ) >> Rshift )] | Gtable[(( *ptr & Gmask ) >> Gshift )] | Btable[(( *ptr & Bmask ) >> Bshift )] ); +            } +            p += graph->pitch ; +        } +    } +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : gr_alpha16 + * + *  Get an alpha multiplication table (a table that, given a 16 bit color, + *  returns the color multiplied by the alpha value) + * + *  PARAMS : + *  alpha   Alpha value for the requested table + * + *  RETURN VALUE : + *      None + * + */ + +uint16_t * gr_alpha16( int alpha ) +{ +    if ( !alpha16_tables_ok ) init_alpha16_tables( GLODWORD( libgrbase, ALPHA_STEPS ) ); +    return alpha16[ alpha ]; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : gr_alpha8 + * + *  Get an alpha translation table (a table that, given two 8 bit color, + *  returns the composite color given the alpha value) + * + *  PARAMS : + *  alpha   Alpha value for the requested table + * + *  RETURN VALUE : + *      None + * + */ + +uint8_t * gr_alpha8( int alpha ) +{ +    if ( !alpha8_tables_ok ) init_alpha8_tables( GLODWORD( libgrbase, ALPHA_STEPS ) ); +    return ( uint8_t * ) alpha8[ alpha ]; +} + +/* --------------------------------------------------------------------------- */ diff --git a/modules/libgrbase/g_conversion.h b/modules/libgrbase/g_conversion.h new file mode 100644 index 0000000..2b64e60 --- /dev/null +++ b/modules/libgrbase/g_conversion.h @@ -0,0 +1,40 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __CONVERSION_H +#define __CONVERSION_H + +/* Rutinas de conversión entre formatos */ + +extern void gr_convert16_ScreenTo565( uint16_t * ptr, int len ); +extern void gr_convert16_565ToScreen( uint16_t * ptr, int len ); +extern void gr_fade16( GRAPH * graph, int r, int g, int b ); +extern uint16_t * gr_alpha16( int alpha ); +extern uint8_t * gr_alpha8( int alpha ); + +#endif diff --git a/modules/libgrbase/g_grlib.c b/modules/libgrbase/g_grlib.c new file mode 100644 index 0000000..fdb4fe5 --- /dev/null +++ b/modules/libgrbase/g_grlib.c @@ -0,0 +1,353 @@ +/* + *  Copyright © 2006-2016 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +/* --------------------------------------------------------------------------- */ + +#include <stdlib.h> +#include <string.h> + +#include "libgrbase.h" +#include "bitwise_map.h" + +/* --------------------------------------------------------------------------- */ + +GRLIB * syslib = 0 ; + +static uint32_t * libs_bmp = NULL ; +static int libs_allocated = 0 ; +static int libs_last = 0; +static GRLIB ** libs = NULL; + +/* --------------------------------------------------------------------------- */ + +static GRLIB * grlib_create() ; + +/* --------------------------------------------------------------------------- */ + +int grlib_newid() +{ +    int n, nb, lim, ini ; + +    // Si tengo suficientes alocados, retorno el siguiente segun libs_last +    if ( libs_last < libs_allocated ) +    { +        if ( !bit_tst( libs_bmp, libs_last ) ) +        { +            bit_set( libs_bmp, libs_last ); +            return libs_last++ ; +        } +    } + +    // Ya no tengo mas espacio, entonces busco alguno libre entre ~+32 desde el ultimo fijo y ~-32 del ultimo asignado + +    ini = ( libs_last < libs_allocated ) ? ( libs_last >> 5 ) : 0 ; +    lim = ( libs_allocated >> 5 ) ; + +    while ( 1 ) +    { +        for ( n = ini; n < lim ; n++ ) +        { +            if ( libs_bmp[n] != ( uint32_t ) 0xFFFFFFFF ) // Aca hay 1 libre, busco cual es +            { +                for ( nb = 0; nb < 32; nb++ ) +                { +                    if ( !bit_tst( libs_bmp + n, nb ) ) +                    { +                        libs_last = ( n << 5 ) + nb ; +                        bit_set( libs_bmp, libs_last ); +                        return libs_last++ ; +                    } +                } +            } +        } +        if ( !ini ) break; +        lim = ini; +        ini = 0; +    } + +    libs_last = libs_allocated ; + +    /* Increment space, no more slots availables +       256 new maps available for alloc */ + +    libs_allocated += 256 ; +    libs_bmp = ( uint32_t * ) realloc( libs_bmp, sizeof( uint32_t ) * ( libs_allocated >> 5 ) ); +    memset( &libs_bmp[( libs_last >> 5 )], 0, 32 );  /* 256 >> 5 = 8 * sizeof ( uint32_t ) = 8 * 4 = 32 */ + +    libs = ( GRLIB ** ) realloc( libs, sizeof( GRLIB * ) * libs_allocated ); +    memset( &libs[ libs_last ], 0, sizeof( GRLIB * ) * 256 ); + +    /* Devuelvo libs_last e incremento en 1, ya que ahora tengo BLOCK_INCR mas que antes */ +    bit_set( libs_bmp, libs_last ); + +    return libs_last++ ; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : grlib_new + * + *  Create a new library + * + *  PARAMS : + *  None + * + *  RETURN VALUE : + *      ID of the new library or -1 if error + */ + +int grlib_new() +{ +    GRLIB * lib = grlib_create() ; +    int i ; + +    if ( !lib ) return -1; + +    i = grlib_newid(); +    libs[ i ] = lib; + +    return ( i ); +} + +/* --------------------------------------------------------------------------- */ +/* Static convenience function */ + +static GRLIB * grlib_create() +{ +    GRLIB * lib ; + +    lib = ( GRLIB * ) malloc( sizeof( GRLIB ) ) ; +    if ( !lib ) return 0 ; + +    lib->maps = ( GRAPH ** ) calloc( 32, sizeof( GRAPH * ) ) ; +    if ( !lib->maps ) +    { +        free( lib ); +        return 0 ; +    } + +    lib->name[ 0 ] = 0 ; +    lib->map_reserved = 32 ; + +    return lib ; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : grlib_get + * + *  Get a pointer to an library in memory given the internal ID + * + *  PARAMS : + *  libid   Library code + * + *  RETURN VALUE : + *      Pointer to the object required or NULL if it does not exist + */ + +GRLIB * grlib_get( int libid ) +{ +    if ( libid < 0 || libid >= libs_allocated ) return 0 ; +    return libs[ libid ] ; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : grlib_destroy + * + *  Remove a library and all its maps from memory + * + *  PARAMS : + *  libid   ID of the library + * + *  RETURN VALUE : + *      0 if there wasn't a map with this code, 1 otherwise + */ + +void grlib_destroy( int libid ) +{ +    int i ; +    GRLIB * lib = grlib_get( libid ) ; +    if ( !lib ) return ; + +    libs[ libid ] = 0 ; + +    for ( i = 0; i < lib->map_reserved; i++ ) bitmap_destroy( lib->maps[ i ] ) ; + +    free( lib->maps ) ; +    free( lib ) ; + +    bit_clr( libs_bmp, libid ); +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : grlib_unload_map + * + *  Remove a map from a library, if present + * + *  PARAMS : + *  libid   ID of the library + *  mapcode   ID of the map + * + *  RETURN VALUE : + *      0 if there wasn't a map with this code, 1 otherwise + */ + +int grlib_unload_map( int libid, int mapcode ) +{ +    GRLIB * lib ; + +    if ( mapcode < 1 || mapcode > 999 ) +        lib = syslib ; +    else +        lib = grlib_get( libid ) ; + +    if ( lib == NULL ) return 0 ; + +    if ( lib->map_reserved <= mapcode ) return 0 ; +    if ( !lib->maps[ mapcode ] ) return 0 ; + +    bitmap_destroy( lib->maps[ mapcode ] ) ; +    lib->maps[ mapcode ] = 0 ; +    return 1 ; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : grlib_add_map + * + *  Add a map to a graphic library. If any map with the same code + *  is in the library, it will be unload first + * + *  PARAMS : + *  lib    Pointer to the library + *  map    Pointer to the graphic + *         (fill map->code first!) + * + *  RETURN VALUE : + *      -1 if error, a number >= 0 otherwise + */ + +int grlib_add_map( int libid, GRAPH * map ) +{ +    GRLIB * lib ; + +    if ( map->code < 1 || map->code > 999 ) +        lib = syslib ; +    else +        lib = grlib_get( libid ) ; + +    if ( !lib ) return -1 ; +    if ( map->code < 0 ) return -1 ; + +    if ( map->code > 0 ) grlib_unload_map( libid, map->code ) ; + +    if ( lib->map_reserved <= map->code ) +    { +        GRAPH ** lmaps; +        int new_reserved = ( map->code & ~0x001F ) + 32 ; + +        lmaps = ( GRAPH ** ) realloc( lib->maps, sizeof( GRAPH* ) * new_reserved ) ; +        if ( !lmaps ) return -1; // No memory +        lib->maps = lmaps; + +        memset( lib->maps + lib->map_reserved, 0, ( new_reserved - lib->map_reserved ) * sizeof( GRAPH * ) ) ; +        lib->map_reserved = new_reserved ; +    } + +    lib->maps[ map->code ] = map ; + +    return map->code ; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : bitmap_get + * + *  Get a bitmap using the DIV syntax (libcode, mapcode) + * + *  PARAMS : + *  libid   Library code or 0 for system/global bitmap + *  mapcode   Code of the bitmap + * + *  RETURN VALUE : + *      Pointer to the graphic required or NULL if not found + * + *  (0, -1) gets the scrbitmap graphic (undocumented!) + *  (0,  0) gets the background + * + */ + +GRAPH * bitmap_get( int libid, int mapcode ) +{ +    GRLIB * lib = NULL ; + +    if ( !libid ) +    { +        /* Using (0, 0) we can get the background map */ +        if ( !mapcode ) return background ; + +        /* Using (0, -1) we can get the screen bitmap (undocumented bug/feature) */ +        if ( mapcode == -1 ) return scrbitmap ; +    } + +    /* Get the map from the system library +     * (the only one that can have more than 1000 maps) +     */ +    if ( mapcode > 999 ) lib = syslib ; + +    if ( !lib ) lib = grlib_get( libid ) ; + +    /* Get the map from a library */ + +    if ( lib && lib->map_reserved > mapcode && mapcode >= 0 ) return lib->maps[ mapcode ] ; + +    return 0 ; +} + +/* --------------------------------------------------------------------------- */ +/* + *  FUNCTION : grlib_init + * + *  Create the system library. This should be called at program startup. + * + *  PARAMS : + *  None + * + *  RETURN VALUE : + *      None + * + */ + +void grlib_init() +{ +    if ( !syslib ) syslib = grlib_create() ; +} + +/* --------------------------------------------------------------------------- */ diff --git a/modules/libgrbase/g_grlib.h b/modules/libgrbase/g_grlib.h new file mode 100644 index 0000000..09c6e32 --- /dev/null +++ b/modules/libgrbase/g_grlib.h @@ -0,0 +1,52 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __GRLIB_H +#define __GRLIB_H + +#define MAXLIBS 1024 + +typedef struct _grlib +{ +    GRAPH ** maps ; +    int map_reserved ; +    char name[ 64 ]; +} +GRLIB ; + +extern GRLIB * syslib ; + +extern GRAPH * bitmap_get( int libid, int mapcode ) ; +extern GRLIB * grlib_get( int libid ) ; +extern void grlib_init() ; +extern int grlib_new() ; +extern void grlib_destroy( int libid ) ; +extern int grlib_add_map( int libid, GRAPH * map ) ; +extern int grlib_unload_map( int libid, int mapcode ) ; + +#endif diff --git a/modules/libgrbase/g_pal.c b/modules/libgrbase/g_pal.c new file mode 100644 index 0000000..26e56a5 --- /dev/null +++ b/modules/libgrbase/g_pal.c @@ -0,0 +1,832 @@ +/* + *  Copyright © 2006-2016 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +/* --------------------------------------------------------------------------- */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "libgrbase.h" + +/* --------------------------------------------------------------------------- */ + +PALETTE * first_palette = NULL ; + +int palette_changed = 0 ; + +/* Tabla de transparencias */ + +uint8_t trans_table[ 256 ][ 256 ] ; +int trans_table_updated = 0 ; + +uint16_t colorghost[65536] ;           /* Deja un color a 50% de intensidad */ + +/* Paleta de colores por defecto */ + +uint8_t default_palette[] = +{ +    0, 0, 0,            /* Color   0 */ +    16, 16, 16,         /* Color   1 */ +    32, 32, 32,         /* Color   2 */ +    48, 48, 48,         /* Color   3 */ +    64, 64, 64,         /* Color   4 */ +    84, 84, 84,         /* Color   5 */ +    100, 100, 100,      /* Color   6 */ +    116, 116, 116,      /* Color   7 */ +    132, 132, 132,      /* Color   8 */ +    148, 148, 148,      /* Color   9 */ +    168, 168, 168,      /* Color  10 */ +    184, 184, 184,      /* Color  11 */ +    200, 200, 200,      /* Color  12 */ +    216, 216, 216,      /* Color  13 */ +    232, 232, 232,      /* Color  14 */ +    252, 252, 252,      /* Color  15 */ +    40, 0, 0,           /* Color  16 */ +    72, 0, 0,           /* Color  17 */ +    108, 0, 0,          /* Color  18 */ +    144, 0, 0,          /* Color  19 */ +    180, 0, 0,          /* Color  20 */ +    216, 0, 0,          /* Color  21 */ +    252, 0, 0,          /* Color  22 */ +    252, 32, 0,         /* Color  23 */ +    252, 64, 0,         /* Color  24 */ +    252, 96, 0,         /* Color  25 */ +    252, 128, 0,        /* Color  26 */ +    252, 160, 0,        /* Color  27 */ +    252, 180, 56,       /* Color  28 */ +    252, 200, 112,      /* Color  29 */ +    252, 220, 168,      /* Color  30 */ +    252, 240, 224,      /* Color  31 */ +    0, 40, 0,           /* Color  32 */ +    0, 60, 0,           /* Color  33 */ +    0, 84, 0,           /* Color  34 */ +    0, 108, 0,          /* Color  35 */ +    0, 132, 0,          /* Color  36 */ +    0, 156, 0,          /* Color  37 */ +    0, 180, 0,          /* Color  38 */ +    0, 204, 0,          /* Color  39 */ +    0, 228, 0,          /* Color  40 */ +    0, 252, 0,          /* Color  41 */ +    48, 252, 32,        /* Color  42 */ +    96, 252, 64,        /* Color  43 */ +    144, 252, 96,       /* Color  44 */ +    192, 252, 132,      /* Color  45 */ +    216, 252, 176,      /* Color  46 */ +    240, 252, 220,      /* Color  47 */ +    0, 0, 40,           /* Color  48 */ +    0, 0, 72,           /* Color  49 */ +    0, 0, 104,          /* Color  50 */ +    0, 0, 140,          /* Color  51 */ +    0, 0, 172,          /* Color  52 */ +    0, 0, 208,          /* Color  53 */ +    0, 0, 252,          /* Color  54 */ +    0, 48, 252,         /* Color  55 */ +    0, 100, 252,        /* Color  56 */ +    0, 148, 252,        /* Color  57 */ +    0, 200, 252,        /* Color  58 */ +    0, 252, 252,        /* Color  59 */ +    56, 252, 252,       /* Color  60 */ +    112, 252, 252,      /* Color  61 */ +    168, 252, 252,      /* Color  62 */ +    224, 252, 252,      /* Color  63 */ +    28, 28, 0,          /* Color  64 */ +    52, 52, 0,          /* Color  65 */ +    76, 76, 0,          /* Color  66 */ +    100, 100, 0,        /* Color  67 */ +    124, 124, 0,        /* Color  68 */ +    152, 152, 0,        /* Color  69 */ +    176, 176, 0,        /* Color  70 */ +    200, 200, 0,        /* Color  71 */ +    224, 224, 0,        /* Color  72 */ +    252, 252, 0,        /* Color  73 */ +    252, 252, 36,       /* Color  74 */ +    252, 252, 72,       /* Color  75 */ +    252, 252, 108,      /* Color  76 */ +    252, 252, 144,      /* Color  77 */ +    252, 252, 180,      /* Color  78 */ +    252, 252, 220,      /* Color  79 */ +    28, 0, 28,          /* Color  80 */ +    52, 0, 52,          /* Color  81 */ +    76, 0, 76,          /* Color  82 */ +    100, 0, 100,        /* Color  83 */ +    124, 0, 124,        /* Color  84 */ +    152, 0, 152,        /* Color  85 */ +    176, 0, 176,        /* Color  86 */ +    200, 0, 200,        /* Color  87 */ +    224, 0, 224,        /* Color  88 */ +    252, 0, 252,        /* Color  89 */ +    252, 36, 252,       /* Color  90 */ +    252, 72, 252,       /* Color  91 */ +    252, 112, 252,      /* Color  92 */ +    252, 148, 252,      /* Color  93 */ +    252, 184, 252,      /* Color  94 */ +    252, 224, 252,      /* Color  95 */ +    0, 20, 20,          /* Color  96 */ +    0, 40, 40,          /* Color  97 */ +    0, 60, 60,          /* Color  98 */ +    0, 80, 80,          /* Color  99 */ +    0, 104, 100,        /* Color 100 */ +    0, 124, 120,        /* Color 101 */ +    0, 144, 144,        /* Color 102 */ +    0, 164, 164,        /* Color 103 */ +    0, 188, 184,        /* Color 104 */ +    0, 208, 204,        /* Color 105 */ +    0, 228, 224,        /* Color 106 */ +    0, 252, 248,        /* Color 107 */ +    44, 252, 248,       /* Color 108 */ +    92, 252, 248,       /* Color 109 */ +    140, 252, 248,      /* Color 110 */ +    188, 252, 248,      /* Color 111 */ +    24, 12, 0,          /* Color 112 */ +    44, 24, 0,          /* Color 113 */ +    64, 36, 0,          /* Color 114 */ +    84, 48, 0,          /* Color 115 */ +    108, 60, 0,         /* Color 116 */ +    128, 72, 0,         /* Color 117 */ +    148, 84, 0,         /* Color 118 */ +    168, 96, 0,         /* Color 119 */ +    192, 112, 0,        /* Color 120 */ +    196, 128, 28,       /* Color 121 */ +    204, 144, 60,       /* Color 122 */ +    212, 160, 92,       /* Color 123 */ +    216, 180, 120,      /* Color 124 */ +    224, 196, 152,      /* Color 125 */ +    232, 212, 184,      /* Color 126 */ +    240, 232, 216,      /* Color 127 */ +    24, 12, 12,         /* Color 128 */ +    40, 20, 20,         /* Color 129 */ +    60, 32, 32,         /* Color 130 */ +    80, 44, 44,         /* Color 131 */ +    96, 52, 52,         /* Color 132 */ +    116, 64, 64,        /* Color 133 */ +    136, 76, 76,        /* Color 134 */ +    156, 88, 88,        /* Color 135 */ +    176, 104, 104,      /* Color 136 */ +    196, 120, 120,      /* Color 137 */ +    216, 136, 136,      /* Color 138 */ +    240, 152, 152,      /* Color 139 */ +    240, 168, 168,      /* Color 140 */ +    244, 188, 188,      /* Color 141 */ +    244, 204, 204,      /* Color 142 */ +    248, 224, 224,      /* Color 143 */ +    24, 20, 12,         /* Color 144 */ +    44, 36, 24,         /* Color 145 */ +    68, 52, 36,         /* Color 146 */ +    88, 72, 48,         /* Color 147 */ +    112, 88, 60,        /* Color 148 */ +    132, 104, 72,       /* Color 149 */ +    156, 124, 88,       /* Color 150 */ +    172, 140, 100,      /* Color 151 */ +    188, 156, 112,      /* Color 152 */ +    204, 176, 124,      /* Color 153 */ +    220, 192, 136,      /* Color 154 */ +    240, 212, 152,      /* Color 155 */ +    240, 216, 168,      /* Color 156 */ +    244, 224, 188,      /* Color 157 */ +    244, 232, 204,      /* Color 158 */ +    248, 240, 224,      /* Color 159 */ +    32, 8, 0,           /* Color 160 */ +    60, 16, 0,          /* Color 161 */ +    88, 28, 0,          /* Color 162 */ +    120, 36, 0,         /* Color 163 */ +    148, 48, 0,         /* Color 164 */ +    176, 56, 0,         /* Color 165 */ +    208, 68, 0,         /* Color 166 */ +    216, 88, 0,         /* Color 167 */ +    224, 112, 0,        /* Color 168 */ +    232, 136, 0,        /* Color 169 */ +    240, 160, 0,        /* Color 170 */ +    252, 184, 0,        /* Color 171 */ +    252, 200, 56,       /* Color 172 */ +    252, 216, 112,      /* Color 173 */ +    252, 232, 168,      /* Color 174 */ +    252, 252, 224,      /* Color 175 */ +    20, 12, 12,         /* Color 176 */ +    36, 24, 24,         /* Color 177 */ +    56, 36, 36,         /* Color 178 */ +    72, 48, 48,         /* Color 179 */ +    92, 64, 64,         /* Color 180 */ +    108, 76, 76,        /* Color 181 */ +    128, 88, 88,        /* Color 182 */ +    144, 100, 100,      /* Color 183 */ +    164, 116, 116,      /* Color 184 */ +    172, 132, 132,      /* Color 185 */ +    184, 148, 148,      /* Color 186 */ +    192, 164, 164,      /* Color 187 */ +    204, 180, 180,      /* Color 188 */ +    212, 196, 196,      /* Color 189 */ +    224, 212, 212,      /* Color 190 */ +    236, 232, 232,      /* Color 191 */ +    12, 20, 12,         /* Color 192 */ +    24, 36, 24,         /* Color 193 */ +    36, 56, 36,         /* Color 194 */ +    48, 72, 48,         /* Color 195 */ +    64, 92, 64,         /* Color 196 */ +    76, 108, 76,        /* Color 197 */ +    88, 128, 88,        /* Color 198 */ +    100, 144, 100,      /* Color 199 */ +    116, 164, 116,      /* Color 200 */ +    132, 172, 132,      /* Color 201 */ +    148, 184, 148,      /* Color 202 */ +    164, 192, 164,      /* Color 203 */ +    180, 204, 180,      /* Color 204 */ +    196, 212, 196,      /* Color 205 */ +    212, 224, 212,      /* Color 206 */ +    232, 236, 232,      /* Color 207 */ +    12, 12, 16,         /* Color 208 */ +    24, 24, 32,         /* Color 209 */ +    36, 36, 48,         /* Color 210 */ +    48, 48, 64,         /* Color 211 */ +    64, 64, 80,         /* Color 212 */ +    76, 76, 96,         /* Color 213 */ +    88, 88, 112,        /* Color 214 */ +    100, 100, 128,      /* Color 215 */ +    116, 116, 148,      /* Color 216 */ +    132, 132, 160,      /* Color 217 */ +    148, 148, 172,      /* Color 218 */ +    164, 164, 184,      /* Color 219 */ +    180, 180, 196,      /* Color 220 */ +    196, 196, 208,      /* Color 221 */ +    212, 212, 220,      /* Color 222 */ +    232, 232, 236,      /* Color 223 */ +    40, 0, 0,           /* Color 224 */ +    80, 0, 0,           /* Color 225 */ +    124, 0, 0,          /* Color 226 */ +    164, 0, 0,          /* Color 227 */ +    208, 0, 0,          /* Color 228 */ +    252, 0, 0,          /* Color 229 */ +    252, 40, 0,         /* Color 230 */ +    252, 84, 0,         /* Color 231 */ +    252, 124, 0,        /* Color 232 */ +    252, 168, 0,        /* Color 233 */ +    252, 208, 0,        /* Color 234 */ +    252, 252, 0,        /* Color 235 */ +    252, 252, 44,       /* Color 236 */ +    252, 252, 92,       /* Color 237 */ +    252, 252, 140,      /* Color 238 */ +    252, 252, 188,      /* Color 239 */ +    0, 0, 0,            /* Color 240 */ +    0, 0, 88,           /* Color 241 */ +    0, 0, 128,          /* Color 242 */ +    0, 0, 168,          /* Color 243 */ +    0, 0, 208,          /* Color 244 */ +    0, 0, 248,          /* Color 245 */ +    40, 0, 248,         /* Color 246 */ +    84, 0, 248,         /* Color 247 */ +    124, 0, 248,        /* Color 248 */ +    168, 0, 248,        /* Color 249 */ +    208, 0, 248,        /* Color 250 */ +    252, 0, 252,        /* Color 251 */ +    252, 52, 252,       /* Color 252 */ +    252, 108, 252,      /* Color 253 */ +    252, 164, 252,      /* Color 254 */ +    252, 220, 252       /* Color 255 */ +} ; + +uint32_t default_colorequiv[256]; + +/* --------------------------------------------------------------------------- */ +/* + * Match an RGB value to a particular palette index + */ +int find_nearest_color( PALETTE * pal, int first, int last, int r, int g, int b ) +{ +    /* Do colorspace distance matching */ +    unsigned int smallest = ~0; +    unsigned int distance; +    int rd, gd, bd; +    int i; +    int pixel = 0; +    rgb_component * palrgb ; + +    if ( !pal ) +        if ( !sys_pixel_format->palette ) +            palrgb = ( rgb_component * ) default_palette; +        else +            palrgb = sys_pixel_format->palette->rgb ; +    else +        palrgb = pal->rgb ; + +    for ( i = first; i <= last; ++i ) +    { +        rd = ( palrgb[i].r - ( r /*& ~0x02 */) ) ; +        gd = ( palrgb[i].g - ( g /*& ~0x02 */) ) ; +        bd = ( palrgb[i].b - ( b /*& ~0x02 */) ) ; + +        distance = ( rd * rd ) + ( gd * gd ) + ( bd * bd ) ; +        if ( distance < smallest ) +        { +            pixel = i; +            if ( !distance ) break;  /* Perfect match! */ +            smallest = distance; +        } +    } + +    return( pixel ); +} + +/* --------------------------------------------------------------------------- */ +/* Find the opaque pixel value corresponding to an RGB triple */ + +int _rgba( PIXEL_FORMAT * format, int r, int g, int b, int a ) +{ +    int color; + +    if ( format->depth < 16 ) return find_nearest_color( format->palette, 0, 255, r, g, b ); + +    color = (( r >> format->Rloss ) << format->Rshift ) | +            (( g >> format->Gloss ) << format->Gshift ) | +            (( b >> format->Bloss ) << format->Bshift ) ; + +    if ( format->depth == 32 ) color |= (( a >> format->Aloss ) << format->Ashift ); + +    return color; +} + +/* --------------------------------------------------------------------------- */ +/* Find the pixel value corresponding to an RGBA quadruple */ + +int _rgb( PIXEL_FORMAT * format, int r, int g, int b ) +{ +    return _rgba( format, r, g, b, 255 ); +} + +/* --------------------------------------------------------------------------- */ + +void _get_rgba( PIXEL_FORMAT * format, int color, int *r, int *g, int *b, int *a ) +{ +    /* 8 bits mode, work with system palette */ + +    if ( format->depth < 16 ) +    { +        rgb_component * rgb ; + +        if ( !format->palette ) rgb = ( rgb_component * ) default_palette; +        else                    rgb = format->palette->rgb ; + +        color &= 0xFF ; +        ( *r ) = rgb[ color ].r ; +        ( *g ) = rgb[ color ].g ; +        ( *b ) = rgb[ color ].b ; + +        return ; +    } + +    ( *r ) = (( color & format->Rmask ) >> format->Rshift ) << format->Rloss ; +    ( *g ) = (( color & format->Gmask ) >> format->Gshift ) << format->Gloss ; +    ( *b ) = (( color & format->Bmask ) >> format->Bshift ) << format->Bloss ; + +    if ( a && format->depth == 32 ) ( *a ) = (( color & format->Amask ) >> format->Ashift ) << format->Aloss ; +} + +/* --------------------------------------------------------------------------- */ + +void _get_rgb( PIXEL_FORMAT * format, int color, int *r, int *g, int *b ) +{ +    return _get_rgba( format, color, r, g, b, NULL ); +} + +/* --------------------------------------------------------------------------- */ + +void pal_refresh( PALETTE * pal ) +{ +    if ( sys_pixel_format->depth > 8 ) +    { +        int n; + +        if ( !pal ) +        { +            uint8_t * p = default_palette; +            for ( n = 0; n < 256; n++ ) +            { +                default_colorequiv[ n ] = _rgb( sys_pixel_format, *( p ), *( p + 1 ), *( p + 2 ) ); +                p += 3; +            } + +            pal = first_palette; +            while ( pal ) +            { +                for ( n = 256; n--; ) pal->colorequiv[ n ] = _rgb( sys_pixel_format, pal->rgb[ n ].r, pal->rgb[ n ].g, pal->rgb[ n ].b ); +                pal = pal->next; +            } +        } +        else +        { +            for ( n = 256; n--; ) pal->colorequiv[ n ] = _rgb( sys_pixel_format, pal->rgb[ n ].r, pal->rgb[ n ].g, pal->rgb[ n ].b ); +        } +    } +    else +        if ( !pal || pal == sys_pixel_format->palette ) palette_changed = 1 ; + +} + +/* --------------------------------------------------------------------------- */ + +void pal_use( PALETTE * pal ) +{ +    if ( pal ) pal->use++; +} + +/* --------------------------------------------------------------------------- */ + +int pal_discard( PALETTE * pal ) +{ +    if ( !pal ) return 0; +    if ( pal->use > 0 ) pal->use--; +    return pal->use; +} + +/* --------------------------------------------------------------------------- */ + +PALETTE * pal_new( PALETTE * basepal ) +{ +    PALETTE * pal = calloc( 1, sizeof( PALETTE ) ); +    if ( !pal ) return NULL ; + +    if ( basepal ) +    { +        memmove( pal->rgb, basepal->rgb, sizeof( pal->rgb ) ) ; +        memmove( pal->colorequiv, basepal->colorequiv, sizeof( pal->colorequiv ) ) ; +        pal_refresh( pal ); +    } +    else +    { +        /* Default */ +        if ( sys_pixel_format->palette ) +            memmove( pal->rgb, sys_pixel_format->palette->rgb, sizeof( pal->rgb ) ) ; +        else +            memmove( pal->rgb, default_palette, sizeof( pal->rgb ) ) ; + +        pal_refresh( pal ); +    } + +    pal->use = 1 ; +    pal->next = first_palette ; +    pal->prev = NULL ; +    if ( first_palette ) first_palette->prev = pal; +    first_palette = pal ; + +    return pal; +} + +/* --------------------------------------------------------------------------- */ + +PALETTE * pal_new_rgb( unsigned char * datapal ) +{ +    if ( !datapal ) return NULL ; + +    PALETTE * pal = malloc( sizeof( PALETTE ) ); +    if ( !pal ) return NULL ; + +    memmove( pal->rgb, datapal, sizeof( pal->rgb ) ); +    pal_refresh( pal ); + +    pal->use = 1 ; +    pal->next = first_palette ; +    pal->prev = NULL ; +    if ( first_palette ) first_palette->prev = pal; +    first_palette = pal ; + +    return pal; +} + +/* --------------------------------------------------------------------------- */ + +void pal_destroy( PALETTE * pal ) +{ +    if ( !pal ) return ; + +    if ( pal_discard( pal ) > 0 ) return ; + +    if ( pal->next ) pal->next->prev = pal->prev ; +    if ( pal->prev ) pal->prev->next = pal->next ; + +    if ( pal == first_palette ) first_palette = pal->next ; + +    free( pal ); +} + +/* --------------------------------------------------------------------------- */ + +int pal_get( PALETTE * spal, int color, int num, uint8_t * pal ) +{ +    if ( num < 1 || color < 0 || color > 255 ) return 0; +    if ( color + num > 256 ) num = 256 - color ; + +    if ( !spal ) +    { +        if ( !sys_pixel_format->palette ) sys_pixel_format->palette = pal_new( NULL ); +        spal = sys_pixel_format->palette ; +    } + +    while ( num-- ) +    { +        *pal++ = spal->rgb[ color ].r ; +        *pal++ = spal->rgb[ color ].g ; +        *pal++ = spal->rgb[ color++ ].b ; +    } +    return 1; +} + +/* --------------------------------------------------------------------------- */ + +int pal_set( PALETTE * spal, int color, int num, uint8_t * pal ) +{ +    if ( num < 1 || color < 0 || color > 255 ) return 0; +    if ( color + num > 256 ) num = 256 - color ; + +    if ( !spal ) +    { +        if ( !sys_pixel_format->palette ) sys_pixel_format->palette = pal_new( NULL ); +        spal = sys_pixel_format->palette ; +    } + +    while ( num-- ) +    { +        spal->rgb[ color ].r = *pal++ ; +        spal->rgb[ color ].g = *pal++ ; +        spal->rgb[ color++ ].b = *pal++ ; +    } +    return 1; +} + +/* --------------------------------------------------------------------------- */ + +int pal_map_assign( int libid, int mapcode, PALETTE * palid ) +{ +    GRAPH * bmp = bitmap_get( libid, mapcode ) ; +    PALETTE * oldpal ; + +    if ( !bmp /*|| !palid*/ || bmp->format->depth != 8 ) return 0 ; + +    oldpal = bmp->format->palette ; +    bmp->format->palette = palid ; + +    pal_use( bmp->format->palette ) ; + +    if ( oldpal ) pal_destroy( oldpal ) ; + +    bmp->modified = 1; + +    return 1 ; +} + +/* --------------------------------------------------------------------------- */ + +int pal_map_remove( int libid, int mapcode ) +{ +    GRAPH * bmp = bitmap_get( libid, mapcode ) ; + +    if ( !bmp || bmp->format->depth != 8 ) return 0 ; + +    if ( bmp->format->palette ) pal_destroy( bmp->format->palette ) ; + +    bmp->format->palette = NULL ; +    bmp->modified = 1; + +    return 1 ; +} + +/* --------------------------------------------------------------------------- */ + +void gr_roll_palette( int color0, int num, int inc ) +{ +    rgb_component backup[ 256 ] ; + +    if ( color0 < 0 || color0 > 255 ) return ; +    if ( num + color0 > 255 ) num = 256 - color0 ; + +    while ( inc >= num ) inc -= num ; +    while ( inc <= -num ) inc += num ; + +    if ( !inc ) return ; + +    memcpy( &backup[ color0 ], &sys_pixel_format->palette->rgb[ color0 ], sizeof( rgb_component ) * num ) ; + +    if ( inc < 0 )  /* Derecha */ +    { +        inc = -inc ; +        memmove( &sys_pixel_format->palette->rgb[ color0 + inc ], &sys_pixel_format->palette->rgb[ color0 ], sizeof( rgb_component ) * ( num - inc ) ) ; +        memcpy( &sys_pixel_format->palette->rgb[ color0 ], &backup[ color0 + num - inc ], sizeof( rgb_component ) * inc ) ; +    } +    else /* Izquierda */ +    { +        memmove( &sys_pixel_format->palette->rgb[ color0 ], &sys_pixel_format->palette->rgb[ color0 + inc ], sizeof( rgb_component ) * ( num - inc ) ) ; +        memcpy( &sys_pixel_format->palette->rgb[ color0 + num - inc ], &backup[ color0 ], sizeof( rgb_component ) * inc ) ; +    } + +    palette_changed = 1 ; +} + +/* --------------------------------------------------------------------------- */ + +int gr_rgb( int r, int g, int b ) +{ +    int color ; +    color = _rgb( sys_pixel_format, r, g, b ); +    if ( sys_pixel_format->depth == 16 && !color ) return 1; +    return color ; +} + +/* --------------------------------------------------------------------------- */ + +int gr_rgba( int r, int g, int b, int a ) +{ +    int color ; +    color = _rgba( sys_pixel_format, r, g, b, a ); +    if ( sys_pixel_format->depth == 16 && !color ) return 1; +    return color ; +} + +/* --------------------------------------------------------------------------- */ + +void gr_get_rgb( int color, int *r, int *g, int *b ) +{ +    return _get_rgb( sys_pixel_format, color, r, g, b ); +} + +/* --------------------------------------------------------------------------- */ + +void gr_get_rgba( int color, int *r, int *g, int *b, int *a ) +{ +    return _get_rgba( sys_pixel_format, color, r, g, b, a ); +} + +/* --------------------------------------------------------------------------- */ +/* This functions is used only for 16 and 32 bits                              */ + +int gr_rgb_depth( int depth, int r, int g, int b ) +{ +    int color ; +    PIXEL_FORMAT * pf = bitmap_create_format( depth ); +    color = _rgb( pf, r, g, b ); +    free( pf ); +    if ( !color && depth == 16 ) return 1 ; +    return color ; +} + +/* --------------------------------------------------------------------------- */ +/* This functions is used only for 16 and 32 bits                              */ + +int gr_rgba_depth( int depth, int r, int g, int b, int a ) +{ +    int color ; +    PIXEL_FORMAT * pf = bitmap_create_format( depth ); +    color = _rgba( pf, r, g, b, a ); +    free( pf ); +    if ( !color && depth == 16 ) return 1 ; +    return color ; +} + +/* --------------------------------------------------------------------------- */ + +void gr_get_rgb_depth( int depth, int color, int *r, int *g, int *b ) +{ +    PIXEL_FORMAT * pf = bitmap_create_format( depth ); +    _get_rgb( pf, color, r, g, b ); +    free( pf ); +} + +/* --------------------------------------------------------------------------- */ + +void gr_get_rgba_depth( int depth, int color, int *r, int *g, int *b, int *a ) +{ +    PIXEL_FORMAT * pf = bitmap_create_format( depth ); +    _get_rgba( pf, color, r, g, b, a ); +    free( pf ); +} + +/* --------------------------------------------------------------------------- */ + +int gr_find_nearest_color( int r, int g, int b ) +{ +    return find_nearest_color( sys_pixel_format->palette, 0, 255, r, g, b ) ; +} + +/* --------------------------------------------------------------------------- */ + +void gr_make_trans_table() +{ +    int a = 0, b = 0; +    int r1, g1, b1; +    rgb_component * rgb; + +    if ( trans_table_updated ) return ; + +    if ( sys_pixel_format->palette ) +        rgb = sys_pixel_format->palette->rgb; +    else +        rgb = ( rgb_component * ) default_palette; + +    for ( a = 0; a < 256; a++ ) +    { +        r1 = rgb[ a ].r / 2 ; +        g1 = rgb[ a ].g / 2 ; +        b1 = rgb[ a ].b / 2 ; + +        for ( b = 0; b < a; b++ ) +            trans_table[ a ][ b ] = +                trans_table[ b ][ a ] = +                    find_nearest_color( NULL, b, a, r1 + rgb[ b ].r / 2, g1 + rgb[ b ].g / 2, b1 + rgb[ b ].b / 2 ) ; + +        trans_table[ a ][ a ] = a ; +        trans_table[ 0 ][ a ] = a ; +    } + +    trans_table_updated = 1 ; +} + +/* --------------------------------------------------------------------------- */ + +void gr_set_rgb( int color, int r, int g, int b ) +{ +    if ( color < 0 || color > 255 ) return ; + +    if ( !sys_pixel_format->palette ) +    { +        sys_pixel_format->palette = pal_new( NULL ); +        memset ( sys_pixel_format->palette->rgb, '\0', sizeof( sys_pixel_format->palette->rgb ) ); +    } + +    sys_pixel_format->palette->rgb[ color ].r = r << 2; +    sys_pixel_format->palette->rgb[ color ].g = g << 2; +    sys_pixel_format->palette->rgb[ color ].b = b << 2; + +    palette_changed = 1 ; +} + +/* --------------------------------------------------------------------------- */ + +/* Rutinas para guardar y recibir trozos de paleta desde/hacia un buffer */ + +void gr_get_colors( int color, int num, uint8_t * pal ) +{ +    rgb_component * rgb; + +    if ( num < 1 || color < 0 || color > 255 ) return ; +    if ( color + num > 256 ) num = 256 - color ; + +    if ( !sys_pixel_format->palette ) +        rgb = ( rgb_component * ) default_palette; +    else +        rgb = ( rgb_component * ) sys_pixel_format->palette->rgb; + +    while ( num-- ) +    { +        *pal++ = rgb[ color ].r ; +        *pal++ = rgb[ color ].g ; +        *pal++ = rgb[ color++ ].b ; +    } +} + +/* --------------------------------------------------------------------------- */ + +void gr_set_colors( int color, int num, uint8_t * pal ) +{ +    if ( num < 1 || color < 0 || color > 255 ) return ; +    if ( color + num > 256 ) num = 256 - color ; + +    if ( !sys_pixel_format->palette ) +    { +        sys_pixel_format->palette = pal_new( NULL ); +        memset ( sys_pixel_format->palette->rgb, '\0', sizeof( sys_pixel_format->palette->rgb ) ); +    } + +    while ( num-- ) +    { +        sys_pixel_format->palette->rgb[ color ].r = *pal++ ; +        sys_pixel_format->palette->rgb[ color ].g = *pal++ ; +        sys_pixel_format->palette->rgb[ color++ ].b = *pal++ ; +    } + +    palette_changed = 1 ; +} + +/* --------------------------------------------------------------------------- */ + diff --git a/modules/libgrbase/g_pal.h b/modules/libgrbase/g_pal.h new file mode 100644 index 0000000..1895438 --- /dev/null +++ b/modules/libgrbase/g_pal.h @@ -0,0 +1,133 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __PAL_H +#define __PAL_H + +/* --------------------------------------------------------------------------- */ +#ifdef _MSC_VER +#pragma pack(push, 1) +#endif + +typedef struct _rgb_component +{ +    uint8_t     r ; +    uint8_t     g ; +    uint8_t     b ; +} +#ifdef __GNUC__ +__attribute__ ((packed)) +#endif +rgb_component ; + +typedef struct _palette +{ +    rgb_component       rgb[256] ; + +    uint32_t            colorequiv[256] ; + +    int                 use; + +    struct _palette     * next ; +    struct _palette     * prev ; +} +#ifdef __GNUC__ +__attribute__ ((packed)) +#endif +PALETTE ; + +#ifdef _MSC_VER +#pragma pack(pop) +#endif + +/* --------------------------------------------------------------------------- */ + +#include "g_bitmap.h" + +/* --------------------------------------------------------------------------- */ + +/* Paleta de colores */ +/* ----------------- */ + +extern PALETTE * first_palette ; + +extern int palette_changed ; + +/* Lista ordenada de colores */ + +extern int color_list[ 256 ] ; + +/* Tabla de transparencias */ + +extern uint8_t trans_table[ 256 ][ 256 ] ; +extern int trans_table_updated ; + +/* Deja un color a 50% de intensidad */ + +extern uint16_t colorghost[65536] ; + +/* Paleta de colores por defecto */ + +extern uint8_t default_palette[]; +extern uint32_t default_colorequiv[256]; + +/* --------------------------------------------------------------------------- */ + +extern int find_nearest_color( PALETTE * pal, int first, int last, int r, int g, int b ); +extern int _rgb( PIXEL_FORMAT * format, int r, int g, int b ); +extern int _rgba( PIXEL_FORMAT * format, int r, int g, int b, int a ); +void _get_rgb( PIXEL_FORMAT * format, int color, int *r, int *g, int *b ); +void _get_rgba( PIXEL_FORMAT * format, int color, int *r, int *g, int *b, int *a ); +extern void pal_refresh( PALETTE * pal ); +extern void pal_use( PALETTE * pal ); +extern int pal_discard( PALETTE * pal ); +extern PALETTE * pal_new( PALETTE * basepal ); +extern PALETTE * pal_new_rgb( unsigned char * datapal ); +extern void pal_destroy( PALETTE * pal ); +extern int pal_get( PALETTE * spal, int color, int num, uint8_t * pal ); +extern int pal_set( PALETTE * spal, int color, int num, uint8_t * pal ); +extern int pal_map_assign( int libid, int mapcode, PALETTE * palid ); +extern int pal_map_remove( int libid, int mapcode ); +extern void gr_roll_palette( int color0, int num, int inc ); +extern int gr_rgb( int r, int g, int b ); +extern int gr_rgba( int r, int g, int b, int a ); +extern void gr_get_rgb( int color, int *r, int *g, int *b ); +extern void gr_get_rgba( int color, int *r, int *g, int *b, int *a ); +extern int gr_rgb_depth( int depth, int r, int g, int b ); +extern int gr_rgba_depth( int depth, int r, int g, int b, int a ); +extern void gr_get_rgb_depth( int depth, int color, int *r, int *g, int *b ); +extern void gr_get_rgba_depth( int depth, int color, int *r, int *g, int *b, int *a ); +extern int gr_find_nearest_color( int r, int g, int b ); +extern void gr_make_trans_table(); +extern void gr_set_rgb( int color, int r, int g, int b ); +extern void gr_get_colors( int color, int num, uint8_t * pal ); +extern void gr_set_colors( int color, int num, uint8_t * pal ); + +/* --------------------------------------------------------------------------- */ + +#endif diff --git a/modules/libgrbase/g_region.h b/modules/libgrbase/g_region.h new file mode 100644 index 0000000..519d314 --- /dev/null +++ b/modules/libgrbase/g_region.h @@ -0,0 +1,43 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __REGION_H +#define __REGION_H + +/* --------------------------------------------------------------------------- */ + +typedef struct _clipregion +{ +    int x ; +    int y ; +    int x2 ;    /* Inclusive */ +    int y2 ; +} +REGION ; + +#endif diff --git a/modules/libgrbase/libgrbase.c b/modules/libgrbase/libgrbase.c new file mode 100644 index 0000000..49deb95 --- /dev/null +++ b/modules/libgrbase/libgrbase.c @@ -0,0 +1,65 @@ +/* + *  Copyright © 2006-2016 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +/* --------------------------------------------------------------------------- */ + +#include "bgddl.h" + +#include "libgrbase.h" + +/* --------------------------------------------------------------------------- */ + +PIXEL_FORMAT * std_pixel_format8  = NULL; +PIXEL_FORMAT * std_pixel_format16 = NULL; +PIXEL_FORMAT * std_pixel_format32 = NULL; + +PIXEL_FORMAT * sys_pixel_format = NULL; + +GRAPH * background = NULL ; +GRAPH * scrbitmap = NULL ; + + +/* --------------------------------------------------------------------------- */ +/* Module initialization                                                       */ + +void __bgdexport( libgrbase, module_initialize )() +{ +    std_pixel_format8  = bitmap_create_format( 8 ) ; +    std_pixel_format16 = bitmap_create_format( 16 ) ; +    std_pixel_format32 = bitmap_create_format( 32 ) ; + +    grlib_init() ; +} + +/* --------------------------------------------------------------------------- */ +/* exports                                                                     */ +/* --------------------------------------------------------------------------- */ + +#include "libgrbase_exports.h" + +/* --------------------------------------------------------------------------- */ diff --git a/modules/libgrbase/libgrbase.h b/modules/libgrbase/libgrbase.h new file mode 100644 index 0000000..44c46ca --- /dev/null +++ b/modules/libgrbase/libgrbase.h @@ -0,0 +1,60 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __LIBGRBASE_H +#define __LIBGRBASE_H + +/* --------------------------------------------------------------------------- */ + +#include <stdlib.h> +#include <stdint.h> + +/* --------------------------------------------------------------------------- */ + +#include "g_pal.h" +#include "g_bitmap.h" +#include "g_clear.h" +#include "g_grlib.h" +#include "g_region.h" +#include "g_blendop.h" +#include "g_conversion.h" + +/* --------------------------------------------------------------------------- */ + +extern PIXEL_FORMAT * std_pixel_format8 ; +extern PIXEL_FORMAT * std_pixel_format16 ; +extern PIXEL_FORMAT * std_pixel_format32 ; + +extern PIXEL_FORMAT * sys_pixel_format ; + +extern GRAPH * background ; +extern GRAPH * scrbitmap ; + +/* --------------------------------------------------------------------------- */ + +#endif diff --git a/modules/libgrbase/libgrbase_exports.h b/modules/libgrbase/libgrbase_exports.h new file mode 100644 index 0000000..2cecad7 --- /dev/null +++ b/modules/libgrbase/libgrbase_exports.h @@ -0,0 +1,51 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __LIBGRBASE_EXPORTS +#define __LIBGRBASE_EXPORTS + +/* --------------------------------------------------------------------------- */ + +#if defined(__BGDC__) || !defined(__STATIC__) + +/* --------------------------------------------------------------------------- */ + +#include "bgddl.h" + +/* --------------------------------------------------------------------------- */ +/* Definicion de variables globales (usada en tiempo de compilacion)           */ + +char * __bgdexport( libgrbase, globals_def ) = +    "alpha_steps = 16;\n" +    ; + +#endif + +/* --------------------------------------------------------------------------- */ + +#endif diff --git a/modules/libgrbase/resolution.h b/modules/libgrbase/resolution.h new file mode 100644 index 0000000..4033058 --- /dev/null +++ b/modules/libgrbase/resolution.h @@ -0,0 +1,86 @@ +/* + *  Copyright © 2006-2013 SplinterGU (Fenix/Bennugd) + *  Copyright © 2002-2006 Fenix Team (Fenix) + *  Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix) + * + *  This file is part of Bennu - Game Development + * + *  This software is provided 'as-is', without any express or implied + *  warranty. In no event will the authors be held liable for any damages + *  arising from the use of this software. + * + *  Permission is granted to anyone to use this software for any purpose, + *  including commercial applications, and to alter it and redistribute it + *  freely, subject to the following restrictions: + * + *     1. The origin of this software must not be misrepresented; you must not + *     claim that you wrote the original software. If you use this software + *     in a product, an acknowledgment in the product documentation would be + *     appreciated but is not required. + * + *     2. Altered source versions must be plainly marked as such, and must not be + *     misrepresented as being the original software. + * + *     3. This notice may not be removed or altered from any source + *     distribution. + * + */ + +#ifndef __RESOLUTION_H +#define __RESOLUTION_H + +/* -------------------------------------------------------------------- */ +/* Librería gráfica                                                     */ +/* -------------------------------------------------------------------- */ + +#define RESOLXY(m,r,x,y) \ +    {                                           \ +        int res = LOCINT32(m, r, RESOLUTION ) ; \ +        if ( res > 0 )                          \ +        {                                       \ +            if ( x < 0 )                        \ +                ( x ) = ( ( x ) - ( res - 1 )) / res ; \ +            else                                \ +                ( x ) /= res ;                  \ +                                                \ +            if ( y < 0 )                        \ +                ( y ) = ( ( y ) - ( res - 1 )) / res ; \ +            else                                \ +                ( y ) /= res ;                  \ +        }                                       \ +        else if ( res < 0 )                     \ +        {                                       \ +            ( x ) *= -res ;                     \ +            ( y ) *= -res ;                     \ +        }                                       \ +    } + +#define RESOLXYZ(m,r,x,y,z) \ +    {                                           \ +        int res = LOCINT32(m, r, RESOLUTION ) ; \ +        if ( res > 0 )                          \ +        {                                       \ +            if ( x < 0 )                        \ +                ( x ) = ( ( x ) - ( res - 1 )) / res ; \ +            else                                \ +                ( x ) /= res ;                  \ +                                                \ +            if ( y < 0 )                        \ +                ( y ) = ( ( y ) - ( res - 1 )) / res ; \ +            else                                \ +                ( y ) /= res ;                  \ +                                                \ +            if ( z < 0 )                        \ +                ( z ) = ( ( z ) - ( res - 1 )) / res ; \ +            else                                \ +                ( z ) /= res ;                  \ +        }                                       \ +        else if ( res < 0 )                     \ +        {                                       \ +            ( x ) *= -res ;                     \ +            ( y ) *= -res ;                     \ +            ( z ) *= -res ;                     \ +        }                                       \ +    } + +#endif | 
