aboutsummaryrefslogtreecommitdiff
path: root/core/bgdrtm/src
diff options
context:
space:
mode:
authorneonloop2021-10-20 14:54:27 +0000
committerneonloop2021-10-20 14:54:27 +0000
commitea1947ffcc606d757357398b24e74a3f4ecefa07 (patch)
tree2031b8d4fc4c61063c710a7148378f57e662efbd /core/bgdrtm/src
downloadbennugd-ea1947ffcc606d757357398b24e74a3f4ecefa07.tar.gz
bennugd-ea1947ffcc606d757357398b24e74a3f4ecefa07.tar.bz2
bennugd-ea1947ffcc606d757357398b24e74a3f4ecefa07.zip
Initial commit from steward-fu releasemain
Diffstat (limited to 'core/bgdrtm/src')
-rw-r--r--core/bgdrtm/src/Makefile710
-rw-r--r--core/bgdrtm/src/Makefile.am15
-rw-r--r--core/bgdrtm/src/Makefile.in710
-rw-r--r--core/bgdrtm/src/copy.c226
-rw-r--r--core/bgdrtm/src/dcbr.c551
-rw-r--r--core/bgdrtm/src/dirs.c430
-rw-r--r--core/bgdrtm/src/fmath.c149
-rw-r--r--core/bgdrtm/src/instance.c763
-rw-r--r--core/bgdrtm/src/interpreter.c2192
-rw-r--r--core/bgdrtm/src/misc.c317
-rw-r--r--core/bgdrtm/src/strings.c1037
-rw-r--r--core/bgdrtm/src/sysprocs.c577
-rw-r--r--core/bgdrtm/src/varspace_file.c357
13 files changed, 8034 insertions, 0 deletions
diff --git a/core/bgdrtm/src/Makefile b/core/bgdrtm/src/Makefile
new file mode 100644
index 0000000..031c34c
--- /dev/null
+++ b/core/bgdrtm/src/Makefile
@@ -0,0 +1,710 @@
+# Makefile.in generated by automake 1.12.1 from Makefile.am.
+# bgdrtm/src/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 = bgdrtm/src
+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 =
+libbgdrtm_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libbgdrtm_la_OBJECTS = libbgdrtm_la-fmath.lo libbgdrtm_la-dcbr.lo \
+ libbgdrtm_la-sysprocs.lo libbgdrtm_la-strings.lo \
+ libbgdrtm_la-dirs.lo libbgdrtm_la-copy.lo libbgdrtm_la-misc.lo \
+ libbgdrtm_la-instance.lo libbgdrtm_la-interpreter.lo \
+ libbgdrtm_la-varspace_file.lo libbgdrtm_la-debug.lo \
+ libbgdrtm_la-b_crypt.lo libbgdrtm_la-files.lo \
+ libbgdrtm_la-xctype.lo
+libbgdrtm_la_OBJECTS = $(am_libbgdrtm_la_OBJECTS)
+libbgdrtm_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libbgdrtm_la_CFLAGS) \
+ $(CFLAGS) $(libbgdrtm_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 = $(libbgdrtm_la_SOURCES)
+DIST_SOURCES = $(libbgdrtm_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/core/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/core/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/steward/Github/miyoo_src/bennugd/core/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/steward/Github/miyoo_src/bennugd/core/missing --run automake-1.12
+AWK = mawk
+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 -finline-functions -fno-strict-aliasing
+COMMON_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 -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/core/../3rdparty/des-4.04b
+COMMON_LDFLAGS = -D_REENTRANT -lc -ldl -D_REENTRANT -L/home/steward/Github/miyoo_src/bennugd/core/../3rdparty/des-4.04b -ldes
+CPP = /opt/miyoo/usr/bin/arm-linux-gcc -E
+CPPFLAGS =
+CRYPT_LDFLAGS =
+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\"
+DEPDIR = .deps
+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 =
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LIPO =
+LN_S = ln -s
+LTLIBOBJS =
+MAINT = #
+MAKEINFO = ${SHELL} /home/steward/Github/miyoo_src/bennugd/core/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
+RANLIB = /opt/miyoo/usr/bin/arm-linux-ranlib
+SED = /bin/sed
+SET_MAKE =
+SHELL = /bin/bash
+STRIP = /opt/miyoo/usr/bin/arm-linux-strip
+VERSION = 1.0.0
+WINDRES =
+ZLIB_CFLAGS =
+ZLIB_LIBS = -lz
+abs_builddir = /home/steward/Github/miyoo_src/bennugd/core/bgdrtm/src
+abs_srcdir = /home/steward/Github/miyoo_src/bennugd/core/bgdrtm/src
+abs_top_builddir = /home/steward/Github/miyoo_src/bennugd/core
+abs_top_srcdir = /home/steward/Github/miyoo_src/bennugd/core
+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/core/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 = libbgdrtm.la
+libbgdrtm_la_SOURCES = fmath.c dcbr.c sysprocs.c strings.c dirs.c copy.c misc.c instance.c interpreter.c varspace_file.c ../../common/debug.c ../../common/b_crypt.c ../../common/files.c ../../common/xctype.c
+libbgdrtm_la_CFLAGS = $(COMMON_CFLAGS) $(ZLIB_CFLAGS) -I../../include -I../include -D__BGDRTM__ -DDEBUG
+libbgdrtm_la_LDFLAGS = -s -module -no-undefined -avoid-version -export-all-symbols
+libbgdrtm_la_LIBADD = $(COMMON_LDFLAGS) $(ZLIB_LIBS) $(CRYPT_LDFLAGS) -lm
+CLEANFILES = libbgdrtm.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 bgdrtm/src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu bgdrtm/src/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}; \
+ }
+libbgdrtm.la: $(libbgdrtm_la_OBJECTS) $(libbgdrtm_la_DEPENDENCIES) $(EXTRA_libbgdrtm_la_DEPENDENCIES)
+ $(libbgdrtm_la_LINK) -rpath $(libdir) $(libbgdrtm_la_OBJECTS) $(libbgdrtm_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/libbgdrtm_la-b_crypt.Plo
+include ./$(DEPDIR)/libbgdrtm_la-copy.Plo
+include ./$(DEPDIR)/libbgdrtm_la-dcbr.Plo
+include ./$(DEPDIR)/libbgdrtm_la-debug.Plo
+include ./$(DEPDIR)/libbgdrtm_la-dirs.Plo
+include ./$(DEPDIR)/libbgdrtm_la-files.Plo
+include ./$(DEPDIR)/libbgdrtm_la-fmath.Plo
+include ./$(DEPDIR)/libbgdrtm_la-instance.Plo
+include ./$(DEPDIR)/libbgdrtm_la-interpreter.Plo
+include ./$(DEPDIR)/libbgdrtm_la-misc.Plo
+include ./$(DEPDIR)/libbgdrtm_la-strings.Plo
+include ./$(DEPDIR)/libbgdrtm_la-sysprocs.Plo
+include ./$(DEPDIR)/libbgdrtm_la-varspace_file.Plo
+include ./$(DEPDIR)/libbgdrtm_la-xctype.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 $@ $<
+
+libbgdrtm_la-fmath.lo: fmath.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-fmath.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-fmath.Tpo -c -o libbgdrtm_la-fmath.lo `test -f 'fmath.c' || echo '$(srcdir)/'`fmath.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-fmath.Tpo $(DEPDIR)/libbgdrtm_la-fmath.Plo
+# source='fmath.c' object='libbgdrtm_la-fmath.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-fmath.lo `test -f 'fmath.c' || echo '$(srcdir)/'`fmath.c
+
+libbgdrtm_la-dcbr.lo: dcbr.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-dcbr.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-dcbr.Tpo -c -o libbgdrtm_la-dcbr.lo `test -f 'dcbr.c' || echo '$(srcdir)/'`dcbr.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-dcbr.Tpo $(DEPDIR)/libbgdrtm_la-dcbr.Plo
+# source='dcbr.c' object='libbgdrtm_la-dcbr.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-dcbr.lo `test -f 'dcbr.c' || echo '$(srcdir)/'`dcbr.c
+
+libbgdrtm_la-sysprocs.lo: sysprocs.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-sysprocs.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-sysprocs.Tpo -c -o libbgdrtm_la-sysprocs.lo `test -f 'sysprocs.c' || echo '$(srcdir)/'`sysprocs.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-sysprocs.Tpo $(DEPDIR)/libbgdrtm_la-sysprocs.Plo
+# source='sysprocs.c' object='libbgdrtm_la-sysprocs.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-sysprocs.lo `test -f 'sysprocs.c' || echo '$(srcdir)/'`sysprocs.c
+
+libbgdrtm_la-strings.lo: strings.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-strings.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-strings.Tpo -c -o libbgdrtm_la-strings.lo `test -f 'strings.c' || echo '$(srcdir)/'`strings.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-strings.Tpo $(DEPDIR)/libbgdrtm_la-strings.Plo
+# source='strings.c' object='libbgdrtm_la-strings.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-strings.lo `test -f 'strings.c' || echo '$(srcdir)/'`strings.c
+
+libbgdrtm_la-dirs.lo: dirs.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-dirs.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-dirs.Tpo -c -o libbgdrtm_la-dirs.lo `test -f 'dirs.c' || echo '$(srcdir)/'`dirs.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-dirs.Tpo $(DEPDIR)/libbgdrtm_la-dirs.Plo
+# source='dirs.c' object='libbgdrtm_la-dirs.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-dirs.lo `test -f 'dirs.c' || echo '$(srcdir)/'`dirs.c
+
+libbgdrtm_la-copy.lo: copy.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-copy.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-copy.Tpo -c -o libbgdrtm_la-copy.lo `test -f 'copy.c' || echo '$(srcdir)/'`copy.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-copy.Tpo $(DEPDIR)/libbgdrtm_la-copy.Plo
+# source='copy.c' object='libbgdrtm_la-copy.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-copy.lo `test -f 'copy.c' || echo '$(srcdir)/'`copy.c
+
+libbgdrtm_la-misc.lo: misc.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-misc.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-misc.Tpo -c -o libbgdrtm_la-misc.lo `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-misc.Tpo $(DEPDIR)/libbgdrtm_la-misc.Plo
+# source='misc.c' object='libbgdrtm_la-misc.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-misc.lo `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
+
+libbgdrtm_la-instance.lo: instance.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-instance.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-instance.Tpo -c -o libbgdrtm_la-instance.lo `test -f 'instance.c' || echo '$(srcdir)/'`instance.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-instance.Tpo $(DEPDIR)/libbgdrtm_la-instance.Plo
+# source='instance.c' object='libbgdrtm_la-instance.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-instance.lo `test -f 'instance.c' || echo '$(srcdir)/'`instance.c
+
+libbgdrtm_la-interpreter.lo: interpreter.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-interpreter.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-interpreter.Tpo -c -o libbgdrtm_la-interpreter.lo `test -f 'interpreter.c' || echo '$(srcdir)/'`interpreter.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-interpreter.Tpo $(DEPDIR)/libbgdrtm_la-interpreter.Plo
+# source='interpreter.c' object='libbgdrtm_la-interpreter.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-interpreter.lo `test -f 'interpreter.c' || echo '$(srcdir)/'`interpreter.c
+
+libbgdrtm_la-varspace_file.lo: varspace_file.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-varspace_file.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-varspace_file.Tpo -c -o libbgdrtm_la-varspace_file.lo `test -f 'varspace_file.c' || echo '$(srcdir)/'`varspace_file.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-varspace_file.Tpo $(DEPDIR)/libbgdrtm_la-varspace_file.Plo
+# source='varspace_file.c' object='libbgdrtm_la-varspace_file.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-varspace_file.lo `test -f 'varspace_file.c' || echo '$(srcdir)/'`varspace_file.c
+
+libbgdrtm_la-debug.lo: ../../common/debug.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-debug.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-debug.Tpo -c -o libbgdrtm_la-debug.lo `test -f '../../common/debug.c' || echo '$(srcdir)/'`../../common/debug.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-debug.Tpo $(DEPDIR)/libbgdrtm_la-debug.Plo
+# source='../../common/debug.c' object='libbgdrtm_la-debug.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-debug.lo `test -f '../../common/debug.c' || echo '$(srcdir)/'`../../common/debug.c
+
+libbgdrtm_la-b_crypt.lo: ../../common/b_crypt.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-b_crypt.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-b_crypt.Tpo -c -o libbgdrtm_la-b_crypt.lo `test -f '../../common/b_crypt.c' || echo '$(srcdir)/'`../../common/b_crypt.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-b_crypt.Tpo $(DEPDIR)/libbgdrtm_la-b_crypt.Plo
+# source='../../common/b_crypt.c' object='libbgdrtm_la-b_crypt.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-b_crypt.lo `test -f '../../common/b_crypt.c' || echo '$(srcdir)/'`../../common/b_crypt.c
+
+libbgdrtm_la-files.lo: ../../common/files.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-files.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-files.Tpo -c -o libbgdrtm_la-files.lo `test -f '../../common/files.c' || echo '$(srcdir)/'`../../common/files.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-files.Tpo $(DEPDIR)/libbgdrtm_la-files.Plo
+# source='../../common/files.c' object='libbgdrtm_la-files.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-files.lo `test -f '../../common/files.c' || echo '$(srcdir)/'`../../common/files.c
+
+libbgdrtm_la-xctype.lo: ../../common/xctype.c
+ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-xctype.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-xctype.Tpo -c -o libbgdrtm_la-xctype.lo `test -f '../../common/xctype.c' || echo '$(srcdir)/'`../../common/xctype.c
+ $(am__mv) $(DEPDIR)/libbgdrtm_la-xctype.Tpo $(DEPDIR)/libbgdrtm_la-xctype.Plo
+# source='../../common/xctype.c' object='libbgdrtm_la-xctype.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-xctype.lo `test -f '../../common/xctype.c' || echo '$(srcdir)/'`../../common/xctype.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/core/bgdrtm/src/Makefile.am b/core/bgdrtm/src/Makefile.am
new file mode 100644
index 0000000..642c4a4
--- /dev/null
+++ b/core/bgdrtm/src/Makefile.am
@@ -0,0 +1,15 @@
+## Process this file with automake to produce Makefile.in
+
+#AUTOMAKE_OPTIONS = no-dependencies foreign
+
+lib_LTLIBRARIES = libbgdrtm.la
+
+libbgdrtm_la_SOURCES = fmath.c dcbr.c sysprocs.c strings.c dirs.c copy.c misc.c instance.c interpreter.c varspace_file.c ../../common/debug.c ../../common/b_crypt.c ../../common/files.c ../../common/xctype.c
+libbgdrtm_la_CFLAGS = $(COMMON_CFLAGS) $(ZLIB_CFLAGS) -I../../include -I../include -D__BGDRTM__ -DDEBUG
+libbgdrtm_la_LDFLAGS = -s -module -no-undefined -avoid-version -export-all-symbols
+libbgdrtm_la_LIBADD = $(COMMON_LDFLAGS) $(ZLIB_LIBS) $(CRYPT_LDFLAGS) -lm
+
+## Make sure these will be cleaned even when they're not built by
+## default.
+CLEANFILES = libbgdrtm.la
+
diff --git a/core/bgdrtm/src/Makefile.in b/core/bgdrtm/src/Makefile.in
new file mode 100644
index 0000000..34750f1
--- /dev/null
+++ b/core/bgdrtm/src/Makefile.in
@@ -0,0 +1,710 @@
+# 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 = bgdrtm/src
+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 =
+libbgdrtm_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libbgdrtm_la_OBJECTS = libbgdrtm_la-fmath.lo libbgdrtm_la-dcbr.lo \
+ libbgdrtm_la-sysprocs.lo libbgdrtm_la-strings.lo \
+ libbgdrtm_la-dirs.lo libbgdrtm_la-copy.lo libbgdrtm_la-misc.lo \
+ libbgdrtm_la-instance.lo libbgdrtm_la-interpreter.lo \
+ libbgdrtm_la-varspace_file.lo libbgdrtm_la-debug.lo \
+ libbgdrtm_la-b_crypt.lo libbgdrtm_la-files.lo \
+ libbgdrtm_la-xctype.lo
+libbgdrtm_la_OBJECTS = $(am_libbgdrtm_la_OBJECTS)
+libbgdrtm_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libbgdrtm_la_CFLAGS) \
+ $(CFLAGS) $(libbgdrtm_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 = $(libbgdrtm_la_SOURCES)
+DIST_SOURCES = $(libbgdrtm_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@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMMON_CFLAGS = @COMMON_CFLAGS@
+COMMON_LDFLAGS = @COMMON_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CRYPT_LDFLAGS = @CRYPT_LDFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+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@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+WINDRES = @WINDRES@
+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 = libbgdrtm.la
+libbgdrtm_la_SOURCES = fmath.c dcbr.c sysprocs.c strings.c dirs.c copy.c misc.c instance.c interpreter.c varspace_file.c ../../common/debug.c ../../common/b_crypt.c ../../common/files.c ../../common/xctype.c
+libbgdrtm_la_CFLAGS = $(COMMON_CFLAGS) $(ZLIB_CFLAGS) -I../../include -I../include -D__BGDRTM__ -DDEBUG
+libbgdrtm_la_LDFLAGS = -s -module -no-undefined -avoid-version -export-all-symbols
+libbgdrtm_la_LIBADD = $(COMMON_LDFLAGS) $(ZLIB_LIBS) $(CRYPT_LDFLAGS) -lm
+CLEANFILES = libbgdrtm.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 bgdrtm/src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu bgdrtm/src/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}; \
+ }
+libbgdrtm.la: $(libbgdrtm_la_OBJECTS) $(libbgdrtm_la_DEPENDENCIES) $(EXTRA_libbgdrtm_la_DEPENDENCIES)
+ $(libbgdrtm_la_LINK) -rpath $(libdir) $(libbgdrtm_la_OBJECTS) $(libbgdrtm_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-b_crypt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-copy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-dcbr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-debug.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-dirs.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-files.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-fmath.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-instance.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-interpreter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-misc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-strings.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-sysprocs.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-varspace_file.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbgdrtm_la-xctype.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 $@ $<
+
+libbgdrtm_la-fmath.lo: fmath.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-fmath.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-fmath.Tpo -c -o libbgdrtm_la-fmath.lo `test -f 'fmath.c' || echo '$(srcdir)/'`fmath.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-fmath.Tpo $(DEPDIR)/libbgdrtm_la-fmath.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fmath.c' object='libbgdrtm_la-fmath.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-fmath.lo `test -f 'fmath.c' || echo '$(srcdir)/'`fmath.c
+
+libbgdrtm_la-dcbr.lo: dcbr.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-dcbr.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-dcbr.Tpo -c -o libbgdrtm_la-dcbr.lo `test -f 'dcbr.c' || echo '$(srcdir)/'`dcbr.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-dcbr.Tpo $(DEPDIR)/libbgdrtm_la-dcbr.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dcbr.c' object='libbgdrtm_la-dcbr.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-dcbr.lo `test -f 'dcbr.c' || echo '$(srcdir)/'`dcbr.c
+
+libbgdrtm_la-sysprocs.lo: sysprocs.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-sysprocs.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-sysprocs.Tpo -c -o libbgdrtm_la-sysprocs.lo `test -f 'sysprocs.c' || echo '$(srcdir)/'`sysprocs.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-sysprocs.Tpo $(DEPDIR)/libbgdrtm_la-sysprocs.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sysprocs.c' object='libbgdrtm_la-sysprocs.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-sysprocs.lo `test -f 'sysprocs.c' || echo '$(srcdir)/'`sysprocs.c
+
+libbgdrtm_la-strings.lo: strings.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-strings.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-strings.Tpo -c -o libbgdrtm_la-strings.lo `test -f 'strings.c' || echo '$(srcdir)/'`strings.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-strings.Tpo $(DEPDIR)/libbgdrtm_la-strings.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strings.c' object='libbgdrtm_la-strings.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-strings.lo `test -f 'strings.c' || echo '$(srcdir)/'`strings.c
+
+libbgdrtm_la-dirs.lo: dirs.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-dirs.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-dirs.Tpo -c -o libbgdrtm_la-dirs.lo `test -f 'dirs.c' || echo '$(srcdir)/'`dirs.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-dirs.Tpo $(DEPDIR)/libbgdrtm_la-dirs.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dirs.c' object='libbgdrtm_la-dirs.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-dirs.lo `test -f 'dirs.c' || echo '$(srcdir)/'`dirs.c
+
+libbgdrtm_la-copy.lo: copy.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-copy.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-copy.Tpo -c -o libbgdrtm_la-copy.lo `test -f 'copy.c' || echo '$(srcdir)/'`copy.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-copy.Tpo $(DEPDIR)/libbgdrtm_la-copy.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='copy.c' object='libbgdrtm_la-copy.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-copy.lo `test -f 'copy.c' || echo '$(srcdir)/'`copy.c
+
+libbgdrtm_la-misc.lo: misc.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-misc.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-misc.Tpo -c -o libbgdrtm_la-misc.lo `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-misc.Tpo $(DEPDIR)/libbgdrtm_la-misc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libbgdrtm_la-misc.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-misc.lo `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
+
+libbgdrtm_la-instance.lo: instance.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-instance.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-instance.Tpo -c -o libbgdrtm_la-instance.lo `test -f 'instance.c' || echo '$(srcdir)/'`instance.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-instance.Tpo $(DEPDIR)/libbgdrtm_la-instance.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='instance.c' object='libbgdrtm_la-instance.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-instance.lo `test -f 'instance.c' || echo '$(srcdir)/'`instance.c
+
+libbgdrtm_la-interpreter.lo: interpreter.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-interpreter.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-interpreter.Tpo -c -o libbgdrtm_la-interpreter.lo `test -f 'interpreter.c' || echo '$(srcdir)/'`interpreter.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-interpreter.Tpo $(DEPDIR)/libbgdrtm_la-interpreter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='interpreter.c' object='libbgdrtm_la-interpreter.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-interpreter.lo `test -f 'interpreter.c' || echo '$(srcdir)/'`interpreter.c
+
+libbgdrtm_la-varspace_file.lo: varspace_file.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-varspace_file.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-varspace_file.Tpo -c -o libbgdrtm_la-varspace_file.lo `test -f 'varspace_file.c' || echo '$(srcdir)/'`varspace_file.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-varspace_file.Tpo $(DEPDIR)/libbgdrtm_la-varspace_file.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='varspace_file.c' object='libbgdrtm_la-varspace_file.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-varspace_file.lo `test -f 'varspace_file.c' || echo '$(srcdir)/'`varspace_file.c
+
+libbgdrtm_la-debug.lo: ../../common/debug.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-debug.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-debug.Tpo -c -o libbgdrtm_la-debug.lo `test -f '../../common/debug.c' || echo '$(srcdir)/'`../../common/debug.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-debug.Tpo $(DEPDIR)/libbgdrtm_la-debug.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../common/debug.c' object='libbgdrtm_la-debug.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-debug.lo `test -f '../../common/debug.c' || echo '$(srcdir)/'`../../common/debug.c
+
+libbgdrtm_la-b_crypt.lo: ../../common/b_crypt.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-b_crypt.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-b_crypt.Tpo -c -o libbgdrtm_la-b_crypt.lo `test -f '../../common/b_crypt.c' || echo '$(srcdir)/'`../../common/b_crypt.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-b_crypt.Tpo $(DEPDIR)/libbgdrtm_la-b_crypt.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../common/b_crypt.c' object='libbgdrtm_la-b_crypt.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-b_crypt.lo `test -f '../../common/b_crypt.c' || echo '$(srcdir)/'`../../common/b_crypt.c
+
+libbgdrtm_la-files.lo: ../../common/files.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-files.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-files.Tpo -c -o libbgdrtm_la-files.lo `test -f '../../common/files.c' || echo '$(srcdir)/'`../../common/files.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-files.Tpo $(DEPDIR)/libbgdrtm_la-files.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../common/files.c' object='libbgdrtm_la-files.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-files.lo `test -f '../../common/files.c' || echo '$(srcdir)/'`../../common/files.c
+
+libbgdrtm_la-xctype.lo: ../../common/xctype.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -MT libbgdrtm_la-xctype.lo -MD -MP -MF $(DEPDIR)/libbgdrtm_la-xctype.Tpo -c -o libbgdrtm_la-xctype.lo `test -f '../../common/xctype.c' || echo '$(srcdir)/'`../../common/xctype.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libbgdrtm_la-xctype.Tpo $(DEPDIR)/libbgdrtm_la-xctype.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../common/xctype.c' object='libbgdrtm_la-xctype.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) $(libbgdrtm_la_CFLAGS) $(CFLAGS) -c -o libbgdrtm_la-xctype.lo `test -f '../../common/xctype.c' || echo '$(srcdir)/'`../../common/xctype.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/core/bgdrtm/src/copy.c b/core/bgdrtm/src/copy.c
new file mode 100644
index 0000000..ca2c587
--- /dev/null
+++ b/core/bgdrtm/src/copy.c
@@ -0,0 +1,226 @@
+/*
+ * 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.
+ *
+ */
+
+/*
+ * FILE : i_copy.c
+ * DESCRIPTION : Struct copy functions based on varspace type info
+ *
+ * HISTORY: 0.85 - First version
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <math.h>
+#include <time.h>
+
+#include "xstrings.h"
+#include "bgdrtm.h"
+
+static int copytype( void * dst, void * src, DCB_TYPEDEF * var );
+
+/*
+ * FUNCTION : copyvars
+ *
+ * Copy data using a varspace's type information. It updates the
+ * destination pointer while walking the variables.
+ *
+ * PARAMS :
+ * dst Pointer to the destination memory
+ * src Pointer to the data
+ * var Pointer to the type array
+ * nvars Number of variables (length of var array)
+ *
+ * RETURN VALUE :
+ * Number of bytes actually copied
+ *
+ */
+
+int copyvars( void * dst, void * src, DCB_VAR * var, int nvars )
+{
+ int result = 0;
+ int partial;
+
+ for ( ; nvars > 0; nvars--, var++ )
+ {
+ partial = copytype( dst, src, &var->Type );
+ src = (( uint8_t* )src ) + partial;
+ dst = (( uint8_t* )dst ) + partial;
+ result += partial;
+ }
+ return result;
+}
+
+
+/*
+ * FUNCTION : copytypes
+ *
+ * Copy data from memory using type information stored in memory
+ *
+ * PARAMS :
+ * dst Pointer to the destination memory
+ * src Pointer to the source
+ * var Pointer to the type array
+ * nvars Number of variables (length of var array)
+ *
+ * RETURN VALUE :
+ * Number of bytes actually coppied
+ *
+ */
+
+int copytypes( void * dst, void * src, DCB_TYPEDEF * var, int nvars, int reps )
+{
+ int result = 0;
+ int partial;
+ DCB_TYPEDEF * _var = var;
+ int _nvars = nvars ;
+
+ for ( ; reps > 0; reps-- )
+ {
+ var = _var;
+ nvars = _nvars;
+ for ( ; nvars > 0; nvars--, var++ )
+ {
+ partial = copytype( dst, src, var );
+ result += partial;
+ src = (( uint8_t* )src ) + partial;
+ dst = (( uint8_t* )dst ) + partial;
+ }
+ }
+ return result;
+}
+
+/*
+ * FUNCTION : copytype
+ *
+ * Copy one variable using the given type information.
+ *
+ * PARAMS :
+ * dst Pointer to the file object
+ * src Pointer to the data
+ * var Pointer to the variable type
+ *
+ * RETURN VALUE :
+ * Number of bytes actually written
+ *
+ */
+
+static int copytype( void * dst, void * src, DCB_TYPEDEF * var )
+{
+ int count = 1;
+ int result = 0;
+ int n = 0;
+
+ for ( ;; )
+ {
+ switch ( var->BaseType[n] )
+ {
+ case TYPE_FLOAT:
+ case TYPE_INT:
+ case TYPE_DWORD:
+ case TYPE_POINTER:
+ memcpy( dst, src, 4 * count );
+ return 4 * count;
+
+ case TYPE_WORD:
+ case TYPE_SHORT:
+ memcpy( dst, src, 2 * count );
+ return 2 * count;
+
+ case TYPE_BYTE:
+ case TYPE_SBYTE:
+ case TYPE_CHAR:
+ memcpy( dst, src, count );
+ return count;
+
+ case TYPE_STRING:
+ while ( count-- )
+ {
+ string_discard( *( int * )dst );
+ string_use( *( int * )src );
+ *(( int * )dst ) = *(( int * )src );
+ dst = (( int * )dst ) + 1;
+ src = (( int * )src ) + 1;
+ result += 4;
+ }
+ return result;
+
+ case TYPE_ARRAY:
+ count *= var->Count[n];
+ n++;
+ continue;
+
+ case TYPE_STRUCT:
+ for ( ; count ; count-- )
+ {
+ int partial = copyvars( dst, src, dcb.varspace_vars[var->Members], dcb.varspace[var->Members].NVars );
+ src = (( uint8_t* )src ) + partial;
+ dst = (( uint8_t* )dst ) + partial;
+ result += partial;
+ }
+ break;
+
+ default:
+ fprintf( stderr, "ERROR: Runtime error - Could not copy datatype\n" ) ;
+ exit( 1 );
+ break;
+ }
+ break;
+ }
+ return result;
+}
+
+/**
+ * POINTER #COPY# (POINTER DEST, POINTER SRC, POINTER VARSPACE, INT VARS)
+ *
+ * Copy struct data from src to dst, using the information varspace given
+ **/
+
+int bgd_copy_struct( INSTANCE * my, int * params )
+{
+ return ( int ) copytypes(( void * )params[0], ( void * )params[1], ( DCB_TYPEDEF * )params[2], params[3], params[4] );
+}
+
+int bgd_internal_memcopy( INSTANCE * my, int * params )
+{
+ memmove(( void * )params[0], ( void * )params[1], params[2] ) ;
+ return 1 ;
+}
+
+int bgd_internal_copy_string_array( INSTANCE * my, int * params )
+{
+ int n = params[ 2 ];
+ while( n-- )
+ {
+ ((int *)( params[ 0 ] )) [ n ] = ((int *)( params[ 1 ] )) [ n ];
+ string_use( ((int *)( params[ 0 ] )) [ n ] );
+ }
+
+ return 1 ;
+}
diff --git a/core/bgdrtm/src/dcbr.c b/core/bgdrtm/src/dcbr.c
new file mode 100644
index 0000000..4f4bd24
--- /dev/null
+++ b/core/bgdrtm/src/dcbr.c
@@ -0,0 +1,551 @@
+/*
+ * 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>
+#ifndef WIN32
+#include <unistd.h>
+#else
+#include <direct.h>
+#endif
+#include "bgdrtm.h"
+#include "dcb.h"
+#include "dirs.h"
+#include "files.h"
+#include "xstrings.h"
+
+#define SYSPROCS_ONLY_DECLARE
+#include "sysprocs.h"
+
+/* --------------------------------------------------------------------------- */
+
+void * globaldata = 0 ;
+void * localdata = 0 ;
+int local_size = 0 ;
+int * localstr = 0 ;
+int local_strings = 0 ;
+
+PROCDEF * procs = NULL ;
+PROCDEF * mainproc = NULL ;
+int procdef_count = 0 ;
+
+/* ---------------------------------------------------------------------- */
+
+DCB_SYSPROC_CODE2 * sysproc_code_ref = NULL ;
+
+/* ---------------------------------------------------------------------- */
+
+void sysprocs_fixup( void )
+{
+ SYSPROC * proc = sysprocs ;
+ DCB_SYSPROC_CODE2 * s = NULL ;
+ int n;
+
+ while ( proc->func )
+ {
+ proc->code = -1;
+
+ s = sysproc_code_ref ;
+ for ( n = 0; n < dcb.data.NSysProcsCodes; n++, s++ )
+ {
+ if (
+ proc->type == s->Type && proc->params == s->Params &&
+ s->Id == getid( proc->name ) && !strcmp( (const char *)s->ParamTypes, proc->paramtypes ) )
+ {
+ proc->code = s->Code ;
+ break ;
+ }
+ }
+ proc++ ;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+PROCDEF * procdef_get( int n )
+{
+ if ( n >= 0 && n < procdef_count )
+ return &procs[n] ;
+
+ return NULL ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+PROCDEF * procdef_get_by_name( char * name )
+{
+ int n;
+ for ( n = 0 ; n < procdef_count; n++ )
+ if ( strcmp( procs[n].name, name ) == 0 )
+ return &procs[n];
+
+ return NULL ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+DCB_HEADER dcb ;
+
+/* ---------------------------------------------------------------------- */
+
+static char * trim( char * ptr )
+{
+ char * ostr = ptr;
+ char * bptr = ptr;
+
+ while ( *ptr == ' ' || *ptr == '\n' || *ptr == '\r' || *ptr == '\t' ) ptr++;
+
+ while ( *ptr ) *bptr++ = *ptr++;
+
+ while ( bptr > ostr && ( bptr[-1] == ' ' || bptr[-1] == '\n' || bptr[-1] == '\r' || bptr[-1] == '\t' ) ) bptr--;
+
+ *bptr = 0;
+
+ return ( ostr );
+}
+
+/* ---------------------------------------------------------------------- */
+
+static int load_file( const char * filename, int n )
+{
+ char line[2048] ;
+ int allocated = 16 ;
+ int count = 0 ;
+ char ** lines ;
+ file * fp ;
+
+ fp = file_open( filename, "r0" ) ;
+ if ( !fp )
+ {
+ dcb.sourcefiles[n] = 0 ;
+ dcb.sourcelines[n] = 0 ;
+ dcb.sourcecount[n] = 0 ;
+ return 0 ;
+ }
+
+ lines = ( char ** ) calloc( 16, sizeof( char* ) ) ;
+
+ while ( !file_eof( fp ) )
+ {
+ file_qgets( fp, line, 2048 ) ;
+ trim( line );
+ if ( allocated == count )
+ {
+ allocated += 16 ;
+ lines = realloc( lines, sizeof( char* ) * allocated ) ;
+ }
+ lines[count++] = strdup( line ) ;
+ }
+ file_close( fp ) ;
+
+ dcb.sourcefiles[n] = ( uint8_t * ) strdup( filename );
+ dcb.sourcelines[n] = ( uint8_t ** ) lines ;
+ dcb.sourcecount[n] = count ;
+ return 1 ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+int dcb_load( const char * filename )
+{
+ file * fp ;
+
+ /* check for existence of the DCB FILE */
+ if ( !file_exists( filename ) ) return 0 ;
+
+ fp = file_open( filename, "rb0" ) ;
+ if ( !fp )
+ {
+ fprintf( stderr, "ERROR: Runtime error - Could not open file (%s)\n", filename ) ;
+ exit( 1 );
+ }
+
+ return dcb_load_from( fp, filename, 0 );
+}
+
+/* ---------------------------------------------------------------------- */
+
+DCB_VAR * read_and_arrange_varspace( file * fp, int count )
+{
+ int n, n1;
+ DCB_VAR * vars = ( DCB_VAR * ) calloc( count, sizeof( DCB_VAR ) ) ;
+
+ for ( n = 0; n < count; n++ )
+ {
+ file_read( fp, &vars[n], sizeof( DCB_VAR ) ) ;
+ ARRANGE_DWORD( &vars[n].ID );
+ ARRANGE_DWORD( &vars[n].Offset );
+ for ( n1 = 0; n1 < MAX_TYPECHUNKS; n1++ ) ARRANGE_DWORD( &vars[n].Type.Count[n1] );
+ ARRANGE_DWORD( &vars[n].Type.Members );
+ }
+
+ return vars;
+}
+
+/* ---------------------------------------------------------------------- */
+
+int dcb_load_from( file * fp, char * filename, int offset )
+{
+ unsigned int n ;
+ uint32_t size;
+
+ /* Lee el contenido del fichero */
+
+ file_seek( fp, offset, SEEK_SET );
+ file_read( fp, &dcb, sizeof( DCB_HEADER_DATA ) ) ;
+
+ ARRANGE_DWORD( &dcb.data.Version );
+ ARRANGE_DWORD( &dcb.data.NProcs );
+ ARRANGE_DWORD( &dcb.data.NFiles );
+ ARRANGE_DWORD( &dcb.data.NID );
+ ARRANGE_DWORD( &dcb.data.NStrings );
+ ARRANGE_DWORD( &dcb.data.NLocVars );
+ ARRANGE_DWORD( &dcb.data.NLocStrings );
+ ARRANGE_DWORD( &dcb.data.NGloVars );
+
+ ARRANGE_DWORD( &dcb.data.SGlobal );
+ ARRANGE_DWORD( &dcb.data.SLocal );
+ ARRANGE_DWORD( &dcb.data.SText );
+
+ ARRANGE_DWORD( &dcb.data.NImports );
+
+ ARRANGE_DWORD( &dcb.data.NSourceFiles );
+
+ ARRANGE_DWORD( &dcb.data.NSysProcsCodes );
+
+ ARRANGE_DWORD( &dcb.data.OProcsTab );
+ ARRANGE_DWORD( &dcb.data.OID );
+ ARRANGE_DWORD( &dcb.data.OStrings );
+ ARRANGE_DWORD( &dcb.data.OText );
+ ARRANGE_DWORD( &dcb.data.OGlobal );
+ ARRANGE_DWORD( &dcb.data.OGloVars );
+ ARRANGE_DWORD( &dcb.data.OLocal );
+ ARRANGE_DWORD( &dcb.data.OLocVars );
+ ARRANGE_DWORD( &dcb.data.OLocStrings );
+ ARRANGE_DWORD( &dcb.data.OVarSpaces );
+ ARRANGE_DWORD( &dcb.data.OFilesTab );
+ ARRANGE_DWORD( &dcb.data.OImports );
+
+ ARRANGE_DWORD( &dcb.data.OSourceFiles );
+ ARRANGE_DWORD( &dcb.data.OSysProcsCodes );
+
+ if ( memcmp( dcb.data.Header, DCB_MAGIC, sizeof( DCB_MAGIC ) - 1 ) != 0 || dcb.data.Version < 0x0700 ) return 0 ;
+
+ globaldata = calloc( dcb.data.SGlobal + 4, 1 ) ;
+ localdata = calloc( dcb.data.SLocal + 4, 1 ) ;
+ localstr = ( int * ) calloc( dcb.data.NLocStrings + 4, sizeof( int ) ) ;
+ dcb.proc = ( DCB_PROC * ) calloc(( 1 + dcb.data.NProcs ), sizeof( DCB_PROC ) ) ;
+ procs = ( PROCDEF * ) calloc(( 1 + dcb.data.NProcs ), sizeof( PROCDEF ) ) ;
+
+ procdef_count = dcb.data.NProcs ;
+ local_size = dcb.data.SLocal ;
+ local_strings = dcb.data.NLocStrings ;
+
+ /* Recupera las zonas de datos globales */
+
+ file_seek( fp, offset + dcb.data.OGlobal, SEEK_SET ) ;
+ file_read( fp, globaldata, dcb.data.SGlobal ) ; /* **** */
+
+ file_seek( fp, offset + dcb.data.OLocal, SEEK_SET ) ;
+ file_read( fp, localdata, dcb.data.SLocal ) ; /* **** */
+
+ if ( dcb.data.NLocStrings )
+ {
+ file_seek( fp, offset + dcb.data.OLocStrings, SEEK_SET ) ;
+ file_readUint32A( fp, (uint32_t *)localstr, dcb.data.NLocStrings ) ;
+ }
+
+ file_seek( fp, offset + dcb.data.OProcsTab, SEEK_SET ) ;
+ for ( n = 0 ; n < dcb.data.NProcs ; n++ )
+ {
+ file_read( fp, &dcb.proc[n], sizeof( DCB_PROC_DATA ) ) ;
+
+ ARRANGE_DWORD( &dcb.proc[n].data.ID );
+ ARRANGE_DWORD( &dcb.proc[n].data.Flags );
+ ARRANGE_DWORD( &dcb.proc[n].data.NParams );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.NPriVars );
+ ARRANGE_DWORD( &dcb.proc[n].data.NPriStrings );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.NPubVars );
+ ARRANGE_DWORD( &dcb.proc[n].data.NPubStrings );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.NSentences );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.SPrivate );
+ ARRANGE_DWORD( &dcb.proc[n].data.SPublic );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.SCode );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.OExitCode );
+ ARRANGE_DWORD( &dcb.proc[n].data.OErrorCode );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.OSentences );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.OPriVars );
+ ARRANGE_DWORD( &dcb.proc[n].data.OPriStrings );
+ ARRANGE_DWORD( &dcb.proc[n].data.OPrivate );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.OPubVars );
+ ARRANGE_DWORD( &dcb.proc[n].data.OPubStrings );
+ ARRANGE_DWORD( &dcb.proc[n].data.OPublic );
+
+ ARRANGE_DWORD( &dcb.proc[n].data.OCode );
+ }
+
+ /* Recupera las cadenas */
+
+ dcb.data.OStrings += offset;
+ dcb.data.OText += offset;
+
+ string_load( fp, dcb.data.OStrings, dcb.data.OText, dcb.data.NStrings, dcb.data.SText );
+
+ /* Recupera los ficheros incluídos */
+
+ if ( dcb.data.NFiles )
+ {
+ DCB_FILE dcbfile;
+ char fname[__MAX_PATH];
+
+ xfile_init( dcb.data.NFiles );
+ file_seek( fp, offset + dcb.data.OFilesTab, SEEK_SET ) ;
+ for ( n = 0 ; n < dcb.data.NFiles; n++ )
+ {
+ file_read( fp, &dcbfile, sizeof( DCB_FILE ) ) ;
+
+ ARRANGE_DWORD( &dcbfile.SName );
+ ARRANGE_DWORD( &dcbfile.SFile );
+ ARRANGE_DWORD( &dcbfile.OFile );
+
+ file_read( fp, &fname, dcbfile.SName ) ;
+ file_add_xfile( fp, filename, offset + dcbfile.OFile, fname, dcbfile.SFile ) ;
+ }
+ }
+
+ /* Recupera los imports */
+
+ if ( dcb.data.NImports )
+ {
+ dcb.imports = ( uint32_t * )calloc( dcb.data.NImports, sizeof( uint32_t ) ) ;
+ file_seek( fp, offset + dcb.data.OImports, SEEK_SET ) ;
+ file_readUint32A( fp, dcb.imports, dcb.data.NImports ) ;
+ }
+
+ /* Recupera los datos de depurado */
+
+ if ( dcb.data.NID )
+ {
+ dcb.id = ( DCB_ID * ) calloc( dcb.data.NID, sizeof( DCB_ID ) ) ;
+ file_seek( fp, offset + dcb.data.OID, SEEK_SET ) ;
+
+ for ( n = 0; n < dcb.data.NID; n++ )
+ {
+ file_read( fp, &dcb.id[n], sizeof( DCB_ID ) ) ;
+ ARRANGE_DWORD( &dcb.id[n].Code );
+ }
+ }
+
+ if ( dcb.data.NGloVars )
+ {
+ file_seek( fp, offset + dcb.data.OGloVars, SEEK_SET ) ;
+ dcb.glovar = read_and_arrange_varspace( fp, dcb.data.NGloVars );
+ }
+
+ if ( dcb.data.NLocVars )
+ {
+ file_seek( fp, offset + dcb.data.OLocVars, SEEK_SET ) ;
+ dcb.locvar = read_and_arrange_varspace( fp, dcb.data.NLocVars );
+ }
+
+ if ( dcb.data.NVarSpaces )
+ {
+ dcb.varspace = ( DCB_VARSPACE * ) calloc( dcb.data.NVarSpaces, sizeof( DCB_VARSPACE ) ) ;
+ dcb.varspace_vars = ( DCB_VAR ** ) calloc( dcb.data.NVarSpaces, sizeof( DCB_VAR * ) ) ;
+ file_seek( fp, offset + dcb.data.OVarSpaces, SEEK_SET ) ;
+
+ for ( n = 0; n < dcb.data.NVarSpaces; n++ )
+ {
+ file_read( fp, &dcb.varspace[n], sizeof( DCB_VARSPACE ) ) ;
+ ARRANGE_DWORD( &dcb.varspace[n].NVars );
+ ARRANGE_DWORD( &dcb.varspace[n].OVars );
+ }
+
+ for ( n = 0; n < dcb.data.NVarSpaces; n++ )
+ {
+ dcb.varspace_vars[n] = 0 ;
+ if ( !dcb.varspace[n].NVars ) continue ;
+ file_seek( fp, offset + dcb.varspace[n].OVars, SEEK_SET ) ;
+ dcb.varspace_vars[n] = read_and_arrange_varspace( fp, dcb.varspace[n].NVars );
+ }
+ }
+
+ if ( dcb.data.NSourceFiles )
+ {
+ char fname[__MAX_PATH] ;
+
+ dcb.sourcecount = ( uint32_t * ) calloc( dcb.data.NSourceFiles, sizeof( uint32_t ) ) ;
+ dcb.sourcelines = ( uint8_t *** ) calloc( dcb.data.NSourceFiles, sizeof( char ** ) ) ;
+ dcb.sourcefiles = ( uint8_t ** ) calloc( dcb.data.NSourceFiles, sizeof( char * ) ) ;
+ file_seek( fp, offset + dcb.data.OSourceFiles, SEEK_SET ) ;
+ for ( n = 0; n < dcb.data.NSourceFiles; n++ )
+ {
+ file_readUint32( fp, &size ) ;
+ file_read( fp, fname, size ) ;
+ if ( !load_file( fname, n ) ) fprintf( stdout, "WARNING: Runtime warning - file not found (%s)\n", fname ) ;
+ }
+ }
+
+ /* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */
+
+ /* Recupera los procesos */
+
+ for ( n = 0 ; n < dcb.data.NProcs ; n++ )
+ {
+ procs[n].params = dcb.proc[n].data.NParams ;
+ procs[n].string_count = dcb.proc[n].data.NPriStrings ;
+ procs[n].pubstring_count = dcb.proc[n].data.NPubStrings ;
+ procs[n].private_size = dcb.proc[n].data.SPrivate ;
+ procs[n].public_size = dcb.proc[n].data.SPublic ;
+ procs[n].code_size = dcb.proc[n].data.SCode ;
+ procs[n].id = dcb.proc[n].data.ID ;
+ procs[n].flags = dcb.proc[n].data.Flags ;
+ procs[n].type = n ;
+ procs[n].name = getid_name( procs[n].id ) ;
+ procs[n].breakpoint = 0;
+
+ if ( dcb.proc[n].data.SPrivate )
+ {
+ procs[n].pridata = ( int * )calloc( dcb.proc[n].data.SPrivate, sizeof( char ) ) ; /* El size ya esta calculado en bytes */
+ file_seek( fp, offset + dcb.proc[n].data.OPrivate, SEEK_SET ) ;
+ file_read( fp, procs[n].pridata, dcb.proc[n].data.SPrivate ) ; /* *** */
+ }
+
+ if ( dcb.proc[n].data.SPublic )
+ {
+ procs[n].pubdata = ( int * )calloc( dcb.proc[n].data.SPublic, sizeof( char ) ) ; /* El size ya esta calculado en bytes */
+ file_seek( fp, offset + dcb.proc[n].data.OPublic, SEEK_SET ) ;
+ file_read( fp, procs[n].pubdata, dcb.proc[n].data.SPublic ) ; /* *** */
+ }
+
+ if ( dcb.proc[n].data.SCode )
+ {
+ procs[n].code = ( int * ) calloc( dcb.proc[n].data.SCode, sizeof( char ) ) ; /* El size ya esta calculado en bytes */
+ file_seek( fp, offset + dcb.proc[n].data.OCode, SEEK_SET ) ;
+ file_readUint32A( fp, (uint32_t *)procs[n].code, dcb.proc[n].data.SCode / sizeof(uint32_t) ) ;
+
+ if ( dcb.proc[n].data.OExitCode )
+ procs[n].exitcode = dcb.proc[n].data.OExitCode ;
+ else
+ procs[n].exitcode = 0 ;
+
+ if ( dcb.proc[n].data.OErrorCode )
+ procs[n].errorcode = dcb.proc[n].data.OErrorCode ;
+ else
+ procs[n].errorcode = 0 ;
+ }
+
+ if ( dcb.proc[n].data.NPriStrings )
+ {
+ procs[n].strings = ( int * )calloc( dcb.proc[n].data.NPriStrings, sizeof( int ) ) ;
+ file_seek( fp, offset + dcb.proc[n].data.OPriStrings, SEEK_SET ) ;
+ file_readUint32A( fp, (uint32_t *)procs[n].strings, dcb.proc[n].data.NPriStrings ) ;
+ }
+
+ if ( dcb.proc[n].data.NPubStrings )
+ {
+ procs[n].pubstrings = ( int * )calloc( dcb.proc[n].data.NPubStrings, sizeof( int ) ) ;
+ file_seek( fp, offset + dcb.proc[n].data.OPubStrings, SEEK_SET ) ;
+ file_readUint32A( fp, (uint32_t *)procs[n].pubstrings, dcb.proc[n].data.NPubStrings ) ;
+ }
+
+ if ( dcb.proc[n].data.NPriVars )
+ {
+ file_seek( fp, offset + dcb.proc[n].data.OPriVars, SEEK_SET ) ;
+ dcb.proc[n].privar = read_and_arrange_varspace( fp, dcb.proc[n].data.NPriVars );
+ }
+
+ if ( dcb.proc[n].data.NPubVars )
+ {
+ file_seek( fp, offset + dcb.proc[n].data.OPubVars, SEEK_SET ) ;
+ dcb.proc[n].pubvar = read_and_arrange_varspace( fp, dcb.proc[n].data.NPubVars );
+ }
+ }
+
+ /* Recupero tabla de fixup de sysprocs */
+
+ sysproc_code_ref = calloc( dcb.data.NSysProcsCodes, sizeof( DCB_SYSPROC_CODE2 ) ) ;
+ file_seek( fp, offset + dcb.data.OSysProcsCodes, SEEK_SET ) ;
+ for ( n = 0; n < dcb.data.NSysProcsCodes; n++ )
+ {
+ DCB_SYSPROC_CODE sdcb;
+ file_read( fp, &sdcb, sizeof( DCB_SYSPROC_CODE ) ) ;
+
+ ARRANGE_DWORD( &sdcb.Id );
+ ARRANGE_DWORD( &sdcb.Type );
+ ARRANGE_DWORD( &sdcb.Params );
+ ARRANGE_DWORD( &sdcb.Code );
+
+ sysproc_code_ref[n].Id = sdcb.Id ;
+ sysproc_code_ref[n].Type = sdcb.Type ;
+ sysproc_code_ref[n].Params = sdcb.Params ;
+ sysproc_code_ref[n].Code = sdcb.Code ;
+ sysproc_code_ref[n].ParamTypes = ( uint8_t * ) calloc( sdcb.Params + 1, sizeof( char ) );
+ if ( sdcb.Params ) file_read( fp, sysproc_code_ref[n].ParamTypes, sdcb.Params ) ;
+ }
+
+ sysprocs_fixup();
+
+ mainproc = procdef_get_by_name( "MAIN" );
+
+ return 1 ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+char * getid_name( unsigned int code )
+{
+ unsigned int n ;
+ for ( n = 0 ; n < dcb.data.NID ; n++ )
+ if ( dcb.id[n].Code == code )
+ return (char *)dcb.id[n].Name ;
+ return "(?)" ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+int getid( char * name )
+{
+ unsigned int n ;
+ for ( n = 0 ; n < dcb.data.NID ; n++ )
+ if ( strcmp( (const char *)dcb.id[n].Name, name ) == 0 )
+ return dcb.id[n].Code ;
+ return -1 ;
+}
+
+/* ---------------------------------------------------------------------- */
diff --git a/core/bgdrtm/src/dirs.c b/core/bgdrtm/src/dirs.c
new file mode 100644
index 0000000..bb306c8
--- /dev/null
+++ b/core/bgdrtm/src/dirs.c
@@ -0,0 +1,430 @@
+/*
+ * 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.
+ *
+ */
+
+/*
+ * FILE : dirs.c
+ * DESCRIPTION : directory functions
+ *
+ * HISTORY:
+ *
+ */
+
+#include "bgdrtm.h"
+#include "dirs.h"
+#include "xstrings.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* ------------------------------------------------------------------------------------ */
+/*
+ * FUNCTION : dir_path_convert
+ *
+ * Convert a path to the valid OS format
+ *
+ * PARAMS :
+ * char * path: path to convert
+ *
+ * RETURN VALUE :
+ * char *: converted path
+ *
+ */
+
+char * dir_path_convert( const char * dir )
+{
+ char *c, *p ;
+
+ p = strdup( dir ) ;
+ if ( !p ) return NULL;
+
+ c = p ;
+ /* Convert characters */
+ while ( *p )
+ {
+ if ( *p == PATH_CHAR_ISEP ) *p = PATH_CHAR_SEP ;
+ p++ ;
+ }
+ return c;
+}
+
+
+/* ------------------------------------------------------------------------------------ */
+/*
+ * FUNCTION : dir_current
+ *
+ * Retrieve current directory
+ *
+ * PARAMS :
+ *
+ * RETURN VALUE :
+ * STRING ID pointing to a system string with the current dir
+ *
+ */
+
+char * dir_current( void )
+{
+ return ( getcwd( NULL, 0 ) ) ;
+}
+
+/* ------------------------------------------------------------------------------------ */
+/*
+ * FUNCTION : dir_change
+ *
+ * Retrieve current directory
+ *
+ * PARAMS :
+ * char * dir: the new current directory
+ *
+ * RETURN VALUE :
+ * 0 - FAILURE
+ * NON_ZERO - SUCCESS
+ *
+ */
+
+int dir_change( const char * dir )
+{
+ char *c = dir_path_convert( dir ) ;
+ if ( !c ) return 0;
+ int r = chdir( c ) ;
+ free( c ) ;
+ return r ;
+}
+
+/* ------------------------------------------------------------------------------------ */
+/*
+ * FUNCTION : dir_create
+ *
+ * Retrieve current directory
+ *
+ * PARAMS :
+ * char * dir: the directory to create
+ *
+ * RETURN VALUE :
+ * 0 - FAILURE
+ * NON_ZERO - SUCCESS
+ *
+ */
+
+int dir_create( const char * dir )
+{
+ char *c = dir_path_convert( dir ) ;
+ if ( !c ) return 0;
+#ifdef WIN32
+ int r = mkdir( c ) ;
+#else
+ int r = mkdir( c, 0777 ) ;
+#endif
+ free( c ) ;
+ return r ;
+}
+
+/* ------------------------------------------------------------------------------------ */
+/*
+ * FUNCTION : dir_delete
+ *
+ * Retrieve current directory
+ *
+ * PARAMS :
+ * char * dir: the directory to delete
+ *
+ * RETURN VALUE :
+ * 0 - FAILURE
+ * NON_ZERO - SUCCESS
+ *
+ */
+
+int dir_delete( const char * dir )
+{
+ char *c = dir_path_convert( dir ) ;
+ if ( !c ) return 0;
+ int r = rmdir( c ) ;
+ free( c ) ;
+ return r ;
+}
+
+/* ------------------------------------------------------------------------------------ */
+/*
+ * FUNCTION : dir_deletefile
+ *
+ * Remove a given file
+ *
+ * PARAMS :
+ * char * filename: the file to delete
+ *
+ * RETURN VALUE :
+ * 0 - FAILURE
+ * NON_ZERO - SUCCESS
+ *
+ */
+
+int dir_deletefile( const char * filename )
+{
+ char *c = dir_path_convert( filename ) ;
+ if ( !c ) return 0;
+ int r = unlink( c ) ;
+ free( c ) ;
+ return ( r == -1 ) ? 0 : 1 ;
+}
+
+/* ------------------------------------------------------------------------------------ */
+
+__DIR_ST * dir_open( const char * path )
+{
+ __DIR_ST * hDir = malloc( sizeof( __DIR_ST ) );
+ if ( !hDir ) return NULL;
+
+ hDir->path = strdup( path );
+ if ( !hDir->path )
+ {
+ free ( hDir );
+ return NULL;
+ }
+
+#ifdef _WIN32
+ hDir->handle = FindFirstFile( hDir->path, &hDir->data );
+ hDir->eod = ( hDir->handle == INVALID_HANDLE_VALUE );
+
+ if ( !hDir->handle )
+ {
+ free( hDir->path );
+ free( hDir );
+ return NULL;
+ }
+#else
+ const char * ptr = hDir->path;
+ char * fptr;
+ int r;
+
+ hDir->pattern = malloc( strlen( path ) * 4 );
+ if ( !hDir->pattern )
+ {
+ free ( hDir->path );
+ free ( hDir );
+ return NULL;
+ }
+
+ /* Clean the path creating a case-insensitive match pattern */
+
+ fptr = hDir->pattern;
+ while ( *ptr )
+ {
+ if ( *ptr == '\\' )
+ {
+ *fptr++ = '/';
+ }
+ else if ( *ptr >= 'a' && *ptr <= 'z' )
+ {
+ *fptr++ = '[';
+ *fptr++ = *ptr;
+ *fptr++ = toupper( *ptr );
+ *fptr++ = ']';
+ }
+ else if ( *ptr >= 'A' && *ptr <= 'Z' )
+ {
+ *fptr++ = '[';
+ *fptr++ = tolower( *ptr );
+ *fptr++ = *ptr;
+ *fptr++ = ']';
+ }
+ else
+ *fptr++ = *ptr;
+ ptr++;
+ }
+ *fptr = 0;
+
+ /* Convert '*.*' to '*' */
+ if ( fptr > hDir->pattern + 2 && fptr[ -1 ] == '*' && fptr[ -2 ] == '.' && fptr[ -3 ] == '*' ) fptr[ -2 ] = 0;
+
+#if defined(TARGET_MAC) || defined(TARGET_BEOS)
+ r = glob( hDir->pattern, GLOB_ERR | GLOB_NOSORT, NULL, &hDir->globd );
+#else
+ r = glob( hDir->pattern, GLOB_ERR | GLOB_PERIOD | GLOB_NOSORT, NULL, &hDir->globd );
+#endif
+
+ if ( r )
+ {
+ free( hDir->pattern );
+ free( hDir->path );
+ free( hDir );
+ return NULL;
+ }
+
+ hDir->currFile = 0;
+#endif
+
+ return hDir;
+}
+
+/* ------------------------------------------------------------------------------------ */
+
+void dir_close ( __DIR_ST * hDir )
+{
+ free ( hDir->path );
+
+#ifdef _WIN32
+ FindClose( hDir->handle );
+#else
+ globfree( &hDir->globd );
+ free( hDir->pattern );
+#endif
+
+ free ( hDir );
+}
+
+/* ------------------------------------------------------------------------------------ */
+
+__DIR_FILEINFO_ST * dir_read( __DIR_ST * hDir )
+{
+ char realpath[__MAX_PATH];
+ char * ptr ;
+
+#ifdef _WIN32
+ SYSTEMTIME time;
+
+ if ( hDir->eod ) return NULL;
+
+ /* Fill the FILEINFO struct */
+ strcpy( realpath, hDir->path );
+ ptr = realpath + strlen( realpath );
+ while ( ptr >= realpath )
+ {
+ if ( *ptr == '\\' || *ptr == '/' )
+ {
+ ptr[ 1 ] = 0;
+ break;
+ }
+ ptr--;
+ }
+
+ memset( &hDir->info, '\0', sizeof( hDir->info ) );
+
+ strcat( realpath, hDir->data.cFileName );
+ GetFullPathName( realpath, __MAX_PATH, hDir->info.fullpath, &ptr );
+ if ( ptr ) * ptr = '\0';
+
+ strcpy ( hDir->info.filename, hDir->data.cFileName );
+
+ hDir->info.attributes = (( hDir->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ? DIR_FI_ATTR_DIRECTORY : 0 ) |
+ (( hDir->data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN ) ? DIR_FI_ATTR_HIDDEN : 0 ) |
+ (( hDir->data.dwFileAttributes & FILE_ATTRIBUTE_READONLY ) ? DIR_FI_ATTR_READONLY : 0 );
+
+ hDir->info.size = hDir->data.nFileSizeLow;
+
+ /* Format and store the creation time */
+ FileTimeToSystemTime( &hDir->data.ftCreationTime, &time );
+
+ hDir->info.crtime.tm_sec = time.wSecond;
+ hDir->info.crtime.tm_min = time.wMinute;
+ hDir->info.crtime.tm_hour = time.wHour;
+ hDir->info.crtime.tm_mday = time.wDay;
+ hDir->info.crtime.tm_mon = time.wMonth - 1;
+ hDir->info.crtime.tm_year = time.wYear - 1900;
+ hDir->info.crtime.tm_wday = time.wDayOfWeek;
+ hDir->info.crtime.tm_yday = time.wMonth;
+ hDir->info.crtime.tm_isdst = -1;
+
+ /* Format and store the last write time */
+ FileTimeToSystemTime( &hDir->data.ftLastWriteTime, &time );
+
+ hDir->info.mtime.tm_sec = time.wSecond;
+ hDir->info.mtime.tm_min = time.wMinute;
+ hDir->info.mtime.tm_hour = time.wHour;
+ hDir->info.mtime.tm_mday = time.wDay;
+ hDir->info.mtime.tm_mon = time.wMonth - 1;
+ hDir->info.mtime.tm_year = time.wYear - 1900;
+ hDir->info.mtime.tm_wday = time.wDayOfWeek;
+ hDir->info.mtime.tm_yday = time.wMonth;
+ hDir->info.mtime.tm_isdst = -1;
+
+ /* Format and store the last access time */
+ FileTimeToSystemTime( &hDir->data.ftLastAccessTime, &time );
+
+ hDir->info.atime.tm_sec = time.wSecond;
+ hDir->info.atime.tm_min = time.wMinute;
+ hDir->info.atime.tm_hour = time.wHour;
+ hDir->info.atime.tm_mday = time.wDay;
+ hDir->info.atime.tm_mon = time.wMonth - 1;
+ hDir->info.atime.tm_year = time.wYear - 1900;
+ hDir->info.atime.tm_wday = time.wDayOfWeek;
+ hDir->info.atime.tm_yday = time.wMonth;
+ hDir->info.atime.tm_isdst = -1;
+
+ /* Continue last search */
+ if (!FindNextFile( hDir->handle, &hDir->data )) hDir->eod = 1;
+#else
+ struct stat s;
+
+ if ( hDir->currFile == hDir->globd.gl_pathc ) return NULL;
+
+ memset( &hDir->info, '\0', sizeof( hDir->info ) );
+
+ stat( hDir->globd.gl_pathv[ hDir->currFile ], &s );
+
+ ptr = strrchr( hDir->globd.gl_pathv[ hDir->currFile ], '/' );
+ if ( !ptr )
+ {
+ strcpy ( hDir->info.filename, hDir->globd.gl_pathv[ hDir->currFile ] );
+ strcpy ( hDir->info.fullpath, getcwd( realpath, sizeof( realpath ) ) );
+ }
+ else
+ {
+ strcpy ( hDir->info.filename, ptr + 1 );
+ if ( hDir->globd.gl_pathv[ hDir->currFile ][0] == '/' )
+ {
+ strcpy ( hDir->info.fullpath, hDir->globd.gl_pathv[ hDir->currFile ] );
+ hDir->info.fullpath[ ptr - hDir->globd.gl_pathv[ hDir->currFile ] + 1 ] = '\0';
+ }
+ else
+ {
+ strcpy ( hDir->info.fullpath, getcwd( realpath, sizeof( realpath ) ) );
+ strcat ( hDir->info.fullpath, "/" );
+ strcat ( hDir->info.fullpath, hDir->globd.gl_pathv[ hDir->currFile ] );
+ ptr = strrchr( hDir->info.fullpath, '/' );
+ *(ptr + 1) = '\0';
+ }
+ }
+
+ hDir->info.attributes = (( S_ISDIR( s.st_mode ) ) ? DIR_FI_ATTR_DIRECTORY : 0 ) |
+ (( hDir->info.filename[0] == '.' ) ? DIR_FI_ATTR_HIDDEN : 0 ) |
+ (( !( s.st_mode & 0444 ) ) ? DIR_FI_ATTR_READONLY : 0 );
+
+ hDir->info.size = s.st_size;
+
+ hDir->info.mtime = *localtime( &s.st_mtime ) ;
+ hDir->info.atime = *localtime( &s.st_atime ) ;
+ hDir->info.ctime = *localtime( &s.st_ctime ) ;
+
+ hDir->currFile++;
+
+#endif
+
+ return ( &hDir->info );
+}
+
+/* ------------------------------------------------------------------------------------ */
diff --git a/core/bgdrtm/src/fmath.c b/core/bgdrtm/src/fmath.c
new file mode 100644
index 0000000..cdf3e1a
--- /dev/null
+++ b/core/bgdrtm/src/fmath.c
@@ -0,0 +1,149 @@
+/*
+ * 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 "fmath.h"
+
+#include "bgdcore.h"
+
+/* --------------------------------------------------------------------------- */
+/* Fixed-point math routines, based on Allegro */
+
+//#define FIXED_PREC 12
+
+#define FIXED_PREC 10000
+
+//#define FIXED_PREC_MED 5000
+//#define FIXED_PREC_DEC 1000
+
+/* --------------------------------------------------------------------------- */
+
+static fixed * cos_table = NULL ;
+
+/* --------------------------------------------------------------------------- */
+
+fixed ftofix( float x )
+{
+ return ( long )( x * FIXED_PREC );
+}
+
+/* --------------------------------------------------------------------------- */
+
+float fixtof( fixed x )
+{
+ return ( ( float ) x ) / FIXED_PREC ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+fixed itofix( int x )
+{
+ return x * FIXED_PREC ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+int fixtoi( fixed x )
+{
+ return x / FIXED_PREC ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+int fixceil( fixed x )
+{
+ int xd;
+
+ if ( x < 0 )
+ {
+ xd = x % FIXED_PREC ;
+ x -= ( FIXED_PREC + xd ) ;
+ }
+ else if ( x > 0 )
+ {
+ xd = x % FIXED_PREC ;
+ x += ( FIXED_PREC - xd ) ;
+ }
+
+ return x ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+fixed fcos( int x )
+{
+ if ( x < 0 ) x = -x ;
+ if ( x > 360000 ) x %= 360000 ;
+ if ( x > 270000 ) return cos_table[360000 - x] ;
+ if ( x > 180000 ) return -cos_table[x - 180000] ;
+ if ( x > 90000 ) return -cos_table[180000 - x] ;
+ return cos_table[x] ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+fixed fsin( int x )
+{
+ if ( x < 0 ) return -fsin( -x ) ;
+ if ( x > 360000 ) x %= 360000 ;
+ if ( x > 270000 ) return -cos_table[x - 270000] ;
+ if ( x > 180000 ) return -cos_table[270000 - x] ;
+ if ( x > 90000 ) return cos_table[x - 90000] ;
+ return cos_table[90000 - x] ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+fixed fmul( int x, int y )
+{
+ return ftofix( fixtof( x ) * fixtof( y ) ) ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+fixed fdiv( int x, int y )
+{
+ return ftofix( fixtof( x ) / fixtof( y ) ) ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+void init_cos_tables()
+{
+ int i ;
+
+ if ( !cos_table ) cos_table = ( fixed * ) malloc( 90001 * sizeof( fixed ) );
+
+ for ( i = 0 ; i <= 90000 ; i++ )
+ {
+ cos_table[i] = ftofix( cos( i * M_PI / 180000.0 ) ) ;
+ }
+}
+
+/* --------------------------------------------------------------------------- */
diff --git a/core/bgdrtm/src/instance.c b/core/bgdrtm/src/instance.c
new file mode 100644
index 0000000..a91633c
--- /dev/null
+++ b/core/bgdrtm/src/instance.c
@@ -0,0 +1,763 @@
+/*
+ * 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>
+
+#ifdef TARGET_BEOS
+#include <posix/assert.h>
+#else
+#include <assert.h>
+#endif
+
+#include "offsets.h"
+#include "bgdrtm.h"
+#include "sysprocs_p.h"
+#include "instance.h"
+#include "xstrings.h"
+
+#undef STACK_SIZE
+#define STACK_SIZE 4096
+
+/* ---------------------------------------------------------------------- */
+
+#define INSTANCE_MIN_PRIORITY -32768
+#define INSTANCE_MAX_PRIORITY 32767
+#define INSTANCE_NORMALIZE_PRIORITY 32768
+
+/* ---------------------------------------------------------------------- */
+/* Módulo de gestión de instancias, con las funciones de incialización y */
+/* destrucción, duplicado, etc. */
+/* ---------------------------------------------------------------------- */
+
+#define HASH(id) (unsigned int)((id)&0x0000ffff)
+#define HASH_PRIORITY(id) (unsigned int)(((id) + INSTANCE_NORMALIZE_PRIORITY) & 0x0000ffff)
+#define HASH_INSTANCE(id) (unsigned int)(((( uint32_t )(id)) >> 2 ) & 0x0000ffff)
+#define HASH_SIZE 65536
+
+INSTANCE ** hashed_by_id = NULL;
+INSTANCE ** hashed_by_instance = NULL;
+INSTANCE ** hashed_by_type = NULL;
+INSTANCE ** hashed_by_priority = NULL;
+
+INSTANCE * first_instance = NULL ;
+
+/* Priority lists */
+
+static INSTANCE * iterator_by_priority = NULL ;
+static int iterator_pos = HASH_SIZE;
+
+static int instance_maxid = FIRST_INSTANCE_ID ;
+
+static int instance_min_actual_prio = INSTANCE_MAX_PRIORITY ;
+static int instance_max_actual_prio = INSTANCE_MIN_PRIORITY ;
+
+/* ---------------------------------------------------------------------- */
+/* By id */
+/* ---------------------------------------------------------------------- */
+
+void instance_add_to_list_by_id( INSTANCE * r, uint32_t id )
+{
+ if ( !hashed_by_id ) hashed_by_id = calloc( HASH_SIZE, sizeof( INSTANCE * ) );
+ hashed_by_id[HASH( id )] = r;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void instance_remove_from_list_by_id( INSTANCE * r, uint32_t id )
+{
+ hashed_by_id[HASH( id )] = NULL;
+}
+
+/* ---------------------------------------------------------------------- */
+/* By instance */
+/* ---------------------------------------------------------------------- */
+
+void instance_add_to_list_by_instance( INSTANCE * r )
+{
+ unsigned int hash = HASH_INSTANCE( r );
+
+ if ( !hashed_by_instance ) hashed_by_instance = calloc( HASH_SIZE, sizeof( INSTANCE * ) );
+
+ r->prev_by_instance = NULL ;
+ r->next_by_instance = hashed_by_instance[hash];
+ if ( r->next_by_instance ) r->next_by_instance->prev_by_instance = r ;
+ hashed_by_instance[hash] = r;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void instance_remove_from_list_by_instance( INSTANCE * r )
+{
+ unsigned int hash = HASH_INSTANCE( r );
+
+ if ( r->prev_by_instance ) r->prev_by_instance->next_by_instance = r->next_by_instance ;
+ if ( r->next_by_instance ) r->next_by_instance->prev_by_instance = r->prev_by_instance ;
+
+ if ( hashed_by_instance[hash] == r ) hashed_by_instance[hash] = r->next_by_instance ;
+}
+
+/* ---------------------------------------------------------------------- */
+/* By type */
+/* ---------------------------------------------------------------------- */
+
+void instance_add_to_list_by_type( INSTANCE * r, uint32_t type )
+{
+ unsigned int hash = HASH( type );
+
+ if ( !hashed_by_type ) hashed_by_type = calloc( HASH_SIZE, sizeof( INSTANCE * ) );
+
+ r->prev_by_type = NULL ;
+ r->next_by_type = hashed_by_type[hash];
+ if ( r->next_by_type ) r->next_by_type->prev_by_type = r ;
+ hashed_by_type[hash] = r;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void instance_remove_from_list_by_type( INSTANCE * r, uint32_t type )
+{
+ unsigned int hash = HASH( type );
+
+ if ( r->prev_by_type ) r->prev_by_type->next_by_type = r->next_by_type ;
+ if ( r->next_by_type ) r->next_by_type->prev_by_type = r->prev_by_type ;
+
+ if ( hashed_by_type[hash] == r ) hashed_by_type[hash] = r->next_by_type ;
+}
+
+/* ---------------------------------------------------------------------- */
+/* By priority */
+/* ---------------------------------------------------------------------- */
+
+void instance_add_to_list_by_priority( INSTANCE * r, int32_t priority )
+{
+ unsigned int hash ;
+
+ if ( priority < INSTANCE_MIN_PRIORITY ) priority = LOCINT32( r, PRIORITY ) = INSTANCE_MIN_PRIORITY;
+ if ( priority > INSTANCE_MAX_PRIORITY ) priority = LOCINT32( r, PRIORITY ) = INSTANCE_MAX_PRIORITY;
+
+ hash = HASH_PRIORITY( priority );
+
+ if ( !hashed_by_priority ) hashed_by_priority = calloc( HASH_SIZE, sizeof( INSTANCE * ) );
+
+ r->prev_by_priority = NULL ;
+ r->next_by_priority = hashed_by_priority[hash];
+ if ( r->next_by_priority ) r->next_by_priority->prev_by_priority = r ;
+ hashed_by_priority[hash] = r;
+ r->last_priority = priority ;
+
+ if ( priority < instance_min_actual_prio ) instance_min_actual_prio = priority ;
+ if ( priority > instance_max_actual_prio ) instance_max_actual_prio = priority ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void instance_remove_from_list_by_priority( INSTANCE * r )
+{
+ unsigned int hash = HASH_PRIORITY( r->last_priority );
+
+ /* Update iterator_by_priority if necessary */
+
+ if ( iterator_by_priority == r ) instance_next_by_priority() ;
+
+ if ( r->prev_by_priority ) r->prev_by_priority->next_by_priority = r->next_by_priority ;
+ if ( r->next_by_priority ) r->next_by_priority->prev_by_priority = r->prev_by_priority ;
+
+ if ( hashed_by_priority[hash] == r ) hashed_by_priority[hash] = r->next_by_priority ;
+
+ if ( !hashed_by_priority[hash] )
+ {
+ if ( r->last_priority == instance_min_actual_prio )
+ {
+ while ( instance_min_actual_prio < instance_max_actual_prio && !hashed_by_priority[ instance_min_actual_prio + INSTANCE_NORMALIZE_PRIORITY ] )
+ instance_min_actual_prio++;
+ }
+
+ if ( r->last_priority == instance_max_actual_prio )
+ {
+ while ( instance_max_actual_prio > instance_min_actual_prio && !hashed_by_priority[ instance_max_actual_prio + INSTANCE_NORMALIZE_PRIORITY ] )
+ instance_max_actual_prio--;
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_dirty
+ *
+ * Adds an instance to the dirty instances list. This is a list of all
+ * instances which priority changed since the last execution.
+ *
+ * PARAMS :
+ * i Pointer to the instance
+ *
+ * RETURN VALUE :
+ * None
+ */
+
+void instance_dirty( INSTANCE * i )
+{
+ instance_remove_from_list_by_priority( i );
+ instance_add_to_list_by_priority( i, LOCINT32( i, PRIORITY ) );
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_get
+ *
+ * Returns a instance, given its ID.
+ *
+ * PARAMS :
+ * id Integer ID of the instance
+ *
+ * RETURN VALUE :
+ * Pointer to the found instance or NULL if not found
+ */
+
+INSTANCE * instance_get( int id )
+{
+ if ( !hashed_by_id || !id ) return NULL;
+ return ( hashed_by_id[HASH( id )] );
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_getid
+ *
+ * Allocate and return a free instance identifier code.
+ *
+ * PARAMS :
+ * None
+ *
+ * RETURN VALUE :
+ * A new, unused instance identifier
+ * -1 if error
+ */
+
+int instance_getid()
+{
+ int id = instance_maxid++ ;
+
+ if ( !hashed_by_id ) hashed_by_id = calloc( HASH_SIZE, sizeof( INSTANCE * ) );
+
+ if ( id <= LAST_INSTANCE_ID && !hashed_by_id[ HASH( id ) ] ) return id;
+
+ if ( instance_maxid > LAST_INSTANCE_ID )
+ {
+ for ( instance_maxid = FIRST_INSTANCE_ID; instance_maxid <= LAST_INSTANCE_ID; instance_maxid++ )
+ {
+ if ( !hashed_by_id[HASH( instance_maxid )] ) return instance_maxid++;
+ }
+ }
+ else
+ {
+ for ( ; instance_maxid <= LAST_INSTANCE_ID; instance_maxid++ )
+ {
+ if ( !hashed_by_id[HASH( instance_maxid )] ) return instance_maxid++;
+ }
+ for ( instance_maxid = FIRST_INSTANCE_ID; instance_maxid < id; instance_maxid++ )
+ {
+ if ( !hashed_by_id[HASH( instance_maxid )] ) return instance_maxid++;
+ }
+ }
+ return -1;
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_duplicate
+ *
+ * Create a copy of an instance, using the same local/private data
+ * - Updates the instance list, adding the new instance
+ * - Marks all local and private strings
+ * - Updates all parents local family variables
+ *
+ * The new instance uses the same code pointer as the father
+ * (it begins execution at the same line, instead of the first one)
+ *
+ * PARAMS :
+ * father Pointer to the original instance
+ *
+ * RETURN VALUE :
+ * Pointer to the new instance
+ */
+
+INSTANCE * instance_duplicate( INSTANCE * father )
+{
+ INSTANCE * r, * brother ;
+ int n, pid ;
+ uint32_t type ;
+
+ if ( ( pid = instance_getid() ) == -1 ) return NULL;
+
+ r = ( INSTANCE * ) calloc( 1, sizeof( INSTANCE ) ) ;
+ assert( r ) ;
+
+ r->pridata = ( int * ) malloc( father->private_size + 4 ) ;
+ r->pubdata = ( int * ) malloc( father->public_size + 4 ) ;
+ r->locdata = ( int * ) malloc( local_size + 4 ) ;
+ r->code = father->code ;
+ r->codeptr = father->codeptr ;
+ r->exitcode = father->exitcode ;
+ r->errorcode = father->errorcode ;
+ r->proc = father->proc ;
+ r->call_level = father->call_level ;
+
+ r->switchval = 0;
+ r->switchval_string = 0;
+ r->cased = 0;
+
+ r->breakpoint = 0 ;
+
+ r->private_size = father->private_size ;
+ r->public_size = father->public_size ;
+ r->first_run = 1 ;
+
+ if ( father->private_size > 0 ) memcpy( r->pridata, father->pridata, r->private_size ) ;
+ if ( father->public_size > 0 ) memcpy( r->pubdata, father->pubdata, r->public_size ) ;
+ if ( local_size > 0 ) memcpy( r->locdata, father->locdata, local_size ) ;
+
+ /* Inicializa datos de jerarquia */
+
+ /* Crea el proceso clónico como si lo hubiera llamado el padre */
+
+ type = LOCDWORD( father, PROCESS_TYPE ) ;
+ LOCDWORD( r, PROCESS_ID ) = pid ;
+ LOCDWORD( r, SON ) = 0 ;
+ LOCDWORD( r, SMALLBRO ) = 0 ;
+
+ LOCDWORD( r, FATHER ) = LOCDWORD( father, PROCESS_ID ) ;
+ brother = instance_get( LOCDWORD( father, SON ) ) ;
+ if ( brother )
+ {
+ LOCDWORD( r, BIGBRO ) = LOCDWORD( brother, PROCESS_ID ) ;
+ LOCDWORD( brother, SMALLBRO ) = pid ;
+ }
+ else
+ {
+ LOCDWORD( r, BIGBRO ) = 0 ;
+ }
+ LOCDWORD( father, SON ) = pid ;
+
+ /* Actualiza las cuentas de uso de las cadenas */
+
+ for ( n = 0; n < r->proc->string_count; n++ ) string_use( PRIDWORD( r, r->proc->strings[n] ) ) ; /* Strings privadas */
+ for ( n = 0; n < r->proc->pubstring_count; n++ ) string_use( PUBDWORD( r, r->proc->pubstrings[n] ) ) ; /* Strings publicas */
+ for ( n = 0; n < local_strings; n++ ) string_use( LOCDWORD( r, localstr[n] ) ) ; /* Strings locales */
+
+ r->prev = NULL ;
+ r->next = first_instance ;
+ if ( first_instance ) first_instance->prev = r;
+ first_instance = r ;
+
+ instance_add_to_list_by_id( r, pid );
+ instance_add_to_list_by_instance( r );
+ instance_add_to_list_by_type( r, type );
+ instance_add_to_list_by_priority( r, LOCINT32( r, PRIORITY ) );
+
+ /* The called_by pointer should be set only when the caller
+ * is waiting for this process to return */
+
+ r->called_by = NULL;
+
+ r->stack = malloc( father->stack[0] );
+ memmove(r->stack, father->stack, (int)father->stack_ptr - (int)father->stack);
+ r->stack_ptr = &r->stack[1];
+
+ /* Initialize list pointers */
+
+ LOCDWORD( r, STATUS ) = STATUS_RUNNING;
+
+ if ( instance_create_hook_count )
+ for ( n = 0; n < instance_create_hook_count; n++ )
+ instance_create_hook_list[n]( r );
+
+ return r ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_new
+ *
+ * Create a new instance, using the default local/private data
+ * - Updates the instance list, adding the new instance
+ * - Marks all local and private strings
+ * - Updates all parents local family variables
+ *
+ * PARAMS :
+ * proc Pointer to the procedure definition
+ * father Pointer to the father instance (may be NULL)
+ *
+ * RETURN VALUE :
+ * Pointer to the new instance
+ */
+
+INSTANCE * instance_new( PROCDEF * proc, INSTANCE * father )
+{
+ INSTANCE * r, * brother;
+ int n, pid;
+
+ if ( ( pid = instance_getid() ) == -1 ) return NULL;
+
+ r = ( INSTANCE * ) calloc( 1, sizeof( INSTANCE ) ) ;
+ assert( r ) ;
+
+ r->pridata = ( int * ) malloc( proc->private_size + 4 ) ;
+ r->pubdata = ( int * ) malloc( proc->public_size + 4 ) ;
+ r->locdata = ( int * ) malloc( local_size + 4 ) ;
+ r->code = proc->code ;
+ r->codeptr = proc->code ;
+ r->exitcode = proc->exitcode ;
+ r->errorcode = proc->errorcode ;
+ r->proc = proc ;
+ r->call_level = 0 ;
+
+ r->switchval = 0;
+ r->switchval_string = 0;
+ r->cased = 0;
+
+ r->breakpoint = 0 ;
+
+ r->private_size = proc->private_size ;
+ r->public_size = proc->public_size ;
+ r->first_run = 1 ;
+
+ if ( proc->private_size > 0 ) memcpy( r->pridata, proc->pridata, proc->private_size ) ;
+ if ( proc->public_size > 0 ) memcpy( r->pubdata, proc->pubdata, proc->public_size ) ;
+ if ( local_size > 0 ) memcpy( r->locdata, localdata, local_size ) ;
+
+ /* Inicializa datos de jerarquia */
+
+ LOCDWORD( r, PROCESS_TYPE ) = proc->type ;
+ LOCDWORD( r, PROCESS_ID ) = pid ;
+ LOCDWORD( r, SON ) = 0 ;
+ LOCDWORD( r, SMALLBRO ) = 0 ;
+
+ if ( father )
+ {
+ LOCDWORD( r, FATHER ) = LOCDWORD( father, PROCESS_ID ) ;
+ brother = instance_get( LOCDWORD( father, SON ) ) ;
+ if ( brother )
+ {
+ LOCDWORD( r, BIGBRO ) = LOCDWORD( brother, PROCESS_ID ) ;
+ LOCDWORD( brother, SMALLBRO ) = pid ;
+ }
+ else
+ {
+ LOCDWORD( r, BIGBRO ) = 0 ;
+ }
+ LOCDWORD( father, SON ) = pid ;
+ }
+ else
+ {
+ LOCDWORD( r, FATHER ) = 0 ;
+ LOCDWORD( r, BIGBRO ) = 0 ;
+ }
+
+ /* Cuenta los usos de las variables tipo cadena */
+
+ for ( n = 0; n < proc->string_count; n++ ) string_use( PRIDWORD( r, proc->strings[n] ) ) ; /* Strings privadas */
+ for ( n = 0; n < proc->pubstring_count; n++ ) string_use( PUBDWORD( r, proc->pubstrings[n] ) ) ; /* Strings publicas */
+ for ( n = 0; n < local_strings; n++ ) string_use( LOCDWORD( r, localstr[n] ) ) ; /* Strings locales */
+
+ r->prev = NULL ;
+ r->next = first_instance ;
+ if ( first_instance ) first_instance->prev = r;
+ first_instance = r ;
+
+ instance_add_to_list_by_id( r, pid );
+ instance_add_to_list_by_instance( r );
+ instance_add_to_list_by_type( r, proc->type );
+ instance_add_to_list_by_priority( r, 0 );
+
+ /* The called_by pointer should be set only when the caller
+ * is waiting for this process to return */
+
+ r->called_by = NULL;
+
+ r->stack = malloc( STACK_SIZE );
+ r->stack_ptr = &r->stack[1];
+ r->stack[0] = STACK_SIZE;
+
+ /* Initialize list pointers */
+
+ LOCDWORD( r, STATUS ) = STATUS_RUNNING;
+
+ if ( instance_create_hook_count )
+ for ( n = 0; n < instance_create_hook_count; n++ )
+ instance_create_hook_list[n]( r );
+
+ return r ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+INSTANCE * instance_getfather( INSTANCE * i )
+{
+ return instance_get( LOCDWORD( i, FATHER ) ) ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+INSTANCE * instance_getson( INSTANCE * i )
+{
+ return instance_get( LOCDWORD( i, SON ) ) ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+INSTANCE * instance_getbigbro( INSTANCE * i )
+{
+ return instance_get( LOCDWORD( i, BIGBRO ) ) ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+INSTANCE * instance_getsmallbro( INSTANCE * i )
+{
+ return instance_get( LOCDWORD( i, SMALLBRO ) ) ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_destroy_all
+ *
+ * Destroy all instances. Simply calls instance_destroy
+ * for any and every instance in existence.
+ *
+ * PARAMS :
+ * except Don't destroy this instance (used for LET_ME_ALONE)
+ *
+ * RETURN VALUE :
+ * None
+ */
+
+void instance_destroy_all( INSTANCE * except )
+{
+ INSTANCE * i, * next ;
+
+ i = first_instance ;
+ while ( i )
+ {
+ next = i->next ;
+ if ( i != except ) instance_destroy( i ) ;
+ i = next ;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_destroy
+ *
+ * Destroy an instance, effectively
+ * - Updates any instance list, removing the given instance
+ * - Discards all local and private strings
+ * - Updates all parents local family variables
+ * - Frees any memory involved
+ *
+ * PARAMS :
+ * r Pointer to the instance
+ *
+ * RETURN VALUE :
+ * None
+ */
+
+void instance_destroy( INSTANCE * r )
+{
+ INSTANCE * father, * bigbro, * smallbro;
+ int n ;
+
+ LOCDWORD( r, STATUS ) = STATUS_RUNNING;
+
+ if ( instance_destroy_hook_count )
+ for ( n = 0; n < instance_destroy_hook_count; n++ )
+ instance_destroy_hook_list[n]( r );
+
+ /* Actualiza la cuenta de referencia de las variables tipo string */
+
+ for ( n = 0 ; n < r->proc->string_count ; n++ ) string_discard( PRIDWORD( r, r->proc->strings[n] ) ) ; /* Strings privadas */
+ for ( n = 0 ; n < r->proc->pubstring_count ; n++ ) string_discard( PUBDWORD( r, r->proc->pubstrings[n] ) ) ; /* Strings publicas */
+ for ( n = 0 ; n < local_strings ; n++ ) string_discard( LOCDWORD( r, localstr[n] ) ) ; /* Strings locales */
+
+ /* Actualiza árbol de jerarquias */
+
+ bigbro = instance_get( LOCDWORD( r, BIGBRO ) ) ; /* Tengo hermano mayor? */
+ if ( bigbro ) LOCDWORD( bigbro, SMALLBRO ) = LOCDWORD( r, SMALLBRO ) ; /* El hermano menor de mi hermano mayor es mi hermano menor */
+
+ smallbro = instance_get( LOCDWORD( r, SMALLBRO ) ) ; /* Tengo hermano menor? */
+ if ( smallbro ) LOCDWORD( smallbro, BIGBRO ) = LOCDWORD( r, BIGBRO ) ; /* El hermano mayor de mi hermano menor es mi hermano mayor */
+
+ father = instance_get( LOCDWORD( r, FATHER ) ) ; /* Tengo padre? */
+ if ( father && instance_get( LOCDWORD( father, SON ) ) == r ) LOCDWORD( father, SON ) = LOCDWORD( r, BIGBRO ); /* Si tengo padre y soy el hijo menor, mi hermano mayor pasa a ser el menor hijo de mi padre */
+
+ /* Quita la instancia de la lista */
+
+ if ( r->prev ) r->prev->next = r->next ;
+ if ( r->next ) r->next->prev = r->prev ;
+
+ if ( first_instance == r ) first_instance = r->next ;
+
+ /* Remove the instance from all hash lists */
+
+ instance_remove_from_list_by_id( r, LOCDWORD( r, PROCESS_ID ) );
+ instance_remove_from_list_by_instance( r );
+ instance_remove_from_list_by_type( r, LOCDWORD( r, PROCESS_TYPE ) );
+ instance_remove_from_list_by_priority( r );
+
+ if ( r->stack ) free( r->stack ) ;
+
+ if ( r->locdata ) free( r->locdata ) ;
+ if ( r->pubdata ) free( r->pubdata ) ;
+ if ( r->pridata ) free( r->pridata ) ;
+ free( r ) ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_exists
+ *
+ * Given an instance pointer, returns TRUE if it is still valid.
+ *
+ * PARAMS :
+ * i Pointer to the instance
+ *
+ * RETURN VALUE :
+ * 1 if the instance pointer is in the global instance list, 0 otherwise
+ */
+
+int instance_exists( INSTANCE * r )
+{
+ INSTANCE * i ;
+
+ if ( !hashed_by_instance || !r ) return 0;
+
+ i = hashed_by_instance[HASH_INSTANCE( r )];
+ while ( i )
+ {
+ if ( r == i ) return 1 ;
+ i = i->next_by_instance ;
+ }
+
+ return 0 ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_next_by_priority
+ *
+ * Gets the next instance pointer until no more instances are
+ * returned. Instances are returned sorted by priority.
+ *
+ * PARAMS :
+ * None
+ *
+ * RETURN VALUE :
+ * Pointer to the next priority on the list or NULL
+ * if there is no more instances. The next call in this
+ * case will return a pointer to the first instance
+ * (the one with the lower priority)
+ */
+
+INSTANCE * instance_next_by_priority()
+{
+ INSTANCE * r = iterator_by_priority ;
+
+ if ( iterator_by_priority ) iterator_by_priority = iterator_by_priority->next_by_priority;
+
+ if ( !iterator_by_priority )
+ {
+ if ( !hashed_by_priority ) return NULL;
+
+ if ( iterator_pos < ( instance_min_actual_prio + INSTANCE_NORMALIZE_PRIORITY ) ||
+ iterator_pos > ( instance_max_actual_prio + INSTANCE_NORMALIZE_PRIORITY )
+ )
+ iterator_pos = instance_max_actual_prio + INSTANCE_NORMALIZE_PRIORITY + 1;
+
+ while ( --iterator_pos >= ( instance_min_actual_prio + INSTANCE_NORMALIZE_PRIORITY ) && !( iterator_by_priority = hashed_by_priority[iterator_pos] ) );
+ }
+
+ return ( r ) ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+ * FUNCTION : instance_get_by_type
+ *
+ * Returns a instance, given its type.
+ *
+ * PARAMS :
+ * type Integer type of the first instance
+ * context Pointer to an INSTANCE * use as context (internal use)
+ *
+ * RETURN VALUE :
+ * Pointer to the found instance or NULL if not found
+ */
+
+/*
+context = NULL = start scan
+context = pointer = continue scan
+context = -1 = end scan
+*/
+
+INSTANCE * instance_get_by_type( uint32_t type, INSTANCE ** context )
+{
+ INSTANCE * i;
+
+ if ( !context || !hashed_by_type || !type /* || type >= FIRST_INSTANCE_ID */ ) return NULL;
+
+ if ( !*context ) /* start scan */
+ i = hashed_by_type[HASH( type )];
+ else if ( ( i = *context ) == ( INSTANCE * ) -1 ) /* End scan */
+ return ( *context = NULL );
+
+ if ( i ) /* Valid instance, continue scan */
+ {
+ if ( i->next_by_type )
+ *context = i->next_by_type ;
+ else
+ *context = ( INSTANCE * ) -1 ; /* Next call will be "end scan" */
+
+ return i;
+ }
+
+ /* Here only if hashed_by_type[HASH( type )] is NULL */
+ return ( *context = NULL ) ; /* return is null, then end scan */
+}
+
+/* ---------------------------------------------------------------------- */
diff --git a/core/bgdrtm/src/interpreter.c b/core/bgdrtm/src/interpreter.c
new file mode 100644
index 0000000..4904987
--- /dev/null
+++ b/core/bgdrtm/src/interpreter.c
@@ -0,0 +1,2192 @@
+/*
+ * 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 "bgdrtm.h"
+#include "dcb.h"
+
+#include "sysprocs_p.h"
+#include "pslang.h"
+#include "instance.h"
+#include "offsets.h"
+#include "xstrings.h"
+
+#include <assert.h>
+
+/* ---------------------------------------------------------------------- */
+/* Interpreter's main module */
+/* ---------------------------------------------------------------------- */
+
+int debug_mode = 0 ;
+
+int exit_value = 0 ;
+int must_exit = 0 ;
+
+int force_debug = 0 ;
+int debug_next = 0 ;
+
+int trace_sentence = -1;
+INSTANCE * trace_instance = NULL;
+
+/* ---------------------------------------------------------------------- */
+
+static INSTANCE * last_instance_run = NULL;
+
+/* ---------------------------------------------------------------------- */
+
+static int stack_dump( INSTANCE * r )
+{
+ register int * ptr = &r->stack[1] ;
+ register int i = 0;
+
+ while ( ptr < r->stack_ptr )
+ {
+ if ( i == 5 )
+ {
+ i = 0;
+ printf( "\n" );
+ }
+ printf( "%08X ", *ptr++ ) ;
+ i++;
+ }
+
+ return i;
+}
+
+/* ---------------------------------------------------------------------- */
+
+int instance_go_all()
+{
+ INSTANCE * i = NULL;
+ int i_count = 0 ;
+ int n;
+ int status;
+
+ must_exit = 0 ;
+
+ while ( first_instance )
+ {
+ if ( debug_mode )
+ {
+ /* Hook */
+ if ( handler_hook_count )
+ for ( n = 0; n < handler_hook_count; n++ )
+ handler_hook_list[n].hook();
+ /* Hook */
+ if ( must_exit ) break ;
+
+ }
+ else
+ {
+ if ( last_instance_run )
+ {
+ if ( instance_exists( last_instance_run ) )
+ {
+ i = last_instance_run;
+ }
+ else
+ {
+ last_instance_run = NULL;
+ i = instance_next_by_priority();
+ }
+ }
+ else
+ {
+ i = instance_next_by_priority();
+ i_count = 0 ;
+ }
+
+ while ( i )
+ {
+ status = LOCDWORD( i, STATUS );
+ /* If instance is KILLED or DEAD or return from some debug command, then execute it again.
+ No exec_hook is executed.
+ */
+ if ( status == STATUS_KILLED || status == STATUS_DEAD || last_instance_run )
+ {
+ /* Run instance */
+ }
+ else if ( status == STATUS_RUNNING && LOCINT32( i, FRAME_PERCENT ) < 100 )
+ {
+ /* Run instance */
+ /* Hook */
+ if ( process_exec_hook_count )
+ for ( n = 0; n < process_exec_hook_count; n++ )
+ process_exec_hook_list[n]( i );
+ /* Hook */
+ }
+ else
+ {
+ i = instance_next_by_priority();
+ last_instance_run = NULL;
+ continue;
+ }
+
+ i_count++;
+
+ last_instance_run = NULL;
+
+ instance_go( i );
+
+ if ( force_debug )
+ {
+ debug_mode = 1;
+ last_instance_run = trace_instance;
+ break;
+ }
+
+ if ( must_exit ) break;
+
+ i = instance_next_by_priority();
+ }
+
+ if ( must_exit ) break ;
+
+ /* If frame is complete, then update internal vars and execute main hooks. */
+
+ if ( !i_count && !force_debug )
+ {
+ /* Honors the signal-changed status of the process and
+ * saves so it is used in this loop the next frame
+ */
+
+ i = first_instance ;
+ while ( i )
+ {
+ status = LOCDWORD( i, STATUS );
+ if ( status == STATUS_RUNNING ) LOCINT32( i, FRAME_PERCENT ) -= 100 ;
+ LOCDWORD( i, SAVED_STATUS ) = status ;
+
+ if ( LOCINT32( i, SAVED_PRIORITY ) != LOCINT32( i, PRIORITY ) )
+ {
+ LOCINT32( i, SAVED_PRIORITY ) = LOCINT32( i, PRIORITY );
+ instance_dirty( i );
+ }
+
+ i = i->next ;
+ }
+
+ if ( !first_instance ) break ;
+
+ /* Hook */
+ if ( handler_hook_count )
+ for ( n = 0; n < handler_hook_count; n++ )
+ handler_hook_list[n].hook();
+ /* Hook */
+
+ continue ;
+ }
+ }
+ }
+
+ return exit_value;
+
+}
+
+/* ---------------------------------------------------------------------- */
+
+int instance_go( INSTANCE * r )
+{
+ if ( !r ) return 0 ;
+
+ register int * ptr = r->codeptr ;
+
+ int n, return_value = LOCDWORD( r, PROCESS_ID ) ;
+ SYSPROC * p = NULL ;
+ INSTANCE * i = NULL ;
+ static char buffer[16];
+ char * str = NULL ;
+ int status ;
+
+ /* Pointer to the current process's code (it may be a called one) */
+
+ int child_is_alive = 0;
+
+ /* ------------------------------------------------------------------------------- */
+ /* Restore if exit by debug */
+
+ if ( debug > 0 )
+ {
+ printf( "\n>>> Instance:%s ProcID:%d StackUsed:%d/%d\n", r->proc->name,
+ LOCDWORD( r, PROCESS_ID ),
+ ( r->stack_ptr - r->stack ) / sizeof( r->stack[0] ),
+ ( r->stack[0] & ~STACK_RETURN_VALUE )
+ ) ;
+ }
+
+ /* Hook */
+ if ( instance_pre_execute_hook_count )
+ for ( n = 0; n < instance_pre_execute_hook_count; n++ )
+ instance_pre_execute_hook_list[n]( r );
+ /* Hook */
+
+ if (( r->proc->breakpoint || r->breakpoint ) && trace_instance != r ) debug_next = 1;
+
+ trace_sentence = -1;
+
+ while ( !must_exit )
+ {
+ /* If I was killed or I'm waiting status, then exit */
+ status = LOCDWORD( r, STATUS );
+ if (( status & ~STATUS_WAITING_MASK ) == STATUS_KILLED || ( status & STATUS_WAITING_MASK ) )
+ {
+ r->codeptr = ptr;
+ return_value = LOCDWORD( r, PROCESS_ID );
+ goto break_all ;
+ }
+
+ if ( debug_next && trace_sentence != -1 )
+ {
+ force_debug = 1;
+ debug_next = 0;
+ r->codeptr = ptr ;
+ return_value = LOCDWORD( r, PROCESS_ID );
+ break;
+ }
+
+ /* debug output */
+ if ( debug > 0 )
+ {
+ if ( debug > 2 )
+ {
+ int c = 45 - stack_dump( r ) * 9;
+ if ( debug > 1 ) printf( "%*.*s[%4u] ", c, c, "", ( ptr - r->code ) ) ;
+ }
+ else if ( debug > 1 ) printf( "[%4u] ", ( ptr - r->code ) ) ;
+ mnemonic_dump( *ptr, ptr[1] ) ;
+ fflush(stdout);
+ }
+
+ switch ( *ptr )
+ {
+ /* Stack manipulation */
+
+ case MN_DUP:
+ *r->stack_ptr = r->stack_ptr[-1] ;
+ r->stack_ptr++;
+ ptr++ ;
+ break ;
+
+ case MN_PUSH:
+ *r->stack_ptr++ = ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_POP:
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_INDEX:
+ case MN_INDEX | MN_UNSIGNED:
+ case MN_INDEX | MN_STRING:
+ case MN_INDEX | MN_WORD:
+ case MN_INDEX | MN_WORD | MN_UNSIGNED:
+ case MN_INDEX | MN_BYTE:
+ case MN_INDEX | MN_BYTE | MN_UNSIGNED:
+ case MN_INDEX | MN_FLOAT: /* Add float, I don't know why it was missing (SplinterGU) */
+ r->stack_ptr[-1] += ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_ARRAY:
+ r->stack_ptr[-2] += ( ptr[1] * r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr += 2 ;
+ break ;
+
+ /* Process calls */
+
+ case MN_CLONE:
+ i = instance_duplicate( r ) ;
+ i->codeptr = ptr + 2 ;
+ ptr = r->code + ptr[1] ;
+ continue ;
+
+ case MN_CALL:
+ case MN_PROC:
+ {
+ PROCDEF * proc = procdef_get( ptr[1] ) ;
+
+ if ( !proc )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Unknown process\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+
+ /* Process uses FRAME or locals, must create an instance */
+ i = instance_new( proc, r ) ;
+
+ assert ( i ) ;
+
+ for ( n = 0; n < proc->params; n++ )
+ PRIDWORD( i, 4 * n ) = r->stack_ptr[-proc->params+n] ;
+
+ r->stack_ptr -= proc->params ;
+
+ /* I go to waiting status (by default) */
+ LOCDWORD( r, STATUS ) |= STATUS_WAITING_MASK;
+ i->called_by = r;
+
+ /* Run the process/function */
+ if ( *ptr == MN_CALL )
+ {
+ r->stack[0] |= STACK_RETURN_VALUE;
+ r->stack_ptr++;
+ *r->stack_ptr = instance_go( i );
+ }
+ else
+ {
+ r->stack[0] &= ~STACK_RETURN_VALUE;
+ instance_go( i );
+ }
+
+ child_is_alive = instance_exists( i );
+
+ ptr += 2 ;
+
+ /* If the process is a function in a frame, save the stack and leave */
+ /* If the process/function still running, then it is in a FRAME.
+ If the process/function is running code, then it his status is RUNNING */
+ if ( child_is_alive &&
+ (
+ (( status = LOCDWORD( r, STATUS ) ) & STATUS_WAITING_MASK ) ||
+ ( status & ~STATUS_WAITING_MASK ) == STATUS_FROZEN ||
+ ( status & ~STATUS_WAITING_MASK ) == STATUS_SLEEPING
+ )
+ )
+ {
+ /* I go to sleep and return from this process/function */
+ i->called_by = r;
+
+ /* Save the instruction pointer */
+ /* This instance don't run other code until the child return */
+ r->codeptr = ptr ;
+
+ /* If it don't was a CALL, then I set a flag in "len" for no return value */
+ if ( ptr[-2] == MN_CALL )
+ r->stack[0] |= STACK_RETURN_VALUE;
+ else
+ r->stack[0] &= ~STACK_RETURN_VALUE;
+
+ if ( debug_next && trace_sentence != -1 )
+ {
+ force_debug = 1;
+ debug_next = 0;
+ }
+ return 0;
+ }
+
+ /* Wake up! */
+ LOCDWORD( r, STATUS ) &= ~STATUS_WAITING_MASK;
+ if ( child_is_alive ) i->called_by = NULL;
+
+ break ;
+ }
+
+ case MN_SYSCALL:
+ p = sysproc_get( ptr[1] ) ;
+ if ( !p )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Unknown system function\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+
+ r->stack_ptr -= p->params ;
+ *r->stack_ptr = ( *p->func )( r, r->stack_ptr ) ;
+ r->stack_ptr++ ;
+ ptr += 2 ;
+ break ;
+
+ case MN_SYSPROC:
+ p = sysproc_get( ptr[1] ) ;
+ if ( !p )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Unknown system process\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ r->stack_ptr -= p->params ;
+ ( *p->func )( r, r->stack_ptr ) ;
+ ptr += 2 ;
+ break ;
+
+ /* Access to variables address */
+
+ case MN_PRIVATE:
+ case MN_PRIVATE | MN_UNSIGNED:
+ case MN_PRIVATE | MN_WORD:
+ case MN_PRIVATE | MN_BYTE:
+ case MN_PRIVATE | MN_WORD | MN_UNSIGNED:
+ case MN_PRIVATE | MN_BYTE | MN_UNSIGNED:
+ case MN_PRIVATE | MN_STRING:
+ case MN_PRIVATE | MN_FLOAT:
+ *r->stack_ptr++ = ( uint32_t ) & PRIDWORD( r, ptr[1] );
+ ptr += 2 ;
+ break ;
+
+ case MN_PUBLIC:
+ case MN_PUBLIC | MN_UNSIGNED:
+ case MN_PUBLIC | MN_WORD:
+ case MN_PUBLIC | MN_BYTE:
+ case MN_PUBLIC | MN_WORD | MN_UNSIGNED:
+ case MN_PUBLIC | MN_BYTE | MN_UNSIGNED:
+ case MN_PUBLIC | MN_STRING:
+ case MN_PUBLIC | MN_FLOAT:
+ *r->stack_ptr++ = ( uint32_t ) & PUBDWORD( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_LOCAL:
+ case MN_LOCAL | MN_UNSIGNED:
+ case MN_LOCAL | MN_WORD:
+ case MN_LOCAL | MN_BYTE:
+ case MN_LOCAL | MN_WORD | MN_UNSIGNED:
+ case MN_LOCAL | MN_BYTE | MN_UNSIGNED:
+ case MN_LOCAL | MN_STRING:
+ case MN_LOCAL | MN_FLOAT:
+ *r->stack_ptr++ = ( uint32_t ) & LOCDWORD( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_GLOBAL:
+ case MN_GLOBAL | MN_UNSIGNED:
+ case MN_GLOBAL | MN_WORD:
+ case MN_GLOBAL | MN_BYTE:
+ case MN_GLOBAL | MN_WORD | MN_UNSIGNED:
+ case MN_GLOBAL | MN_BYTE | MN_UNSIGNED:
+ case MN_GLOBAL | MN_STRING:
+ case MN_GLOBAL | MN_FLOAT:
+ *r->stack_ptr++ = ( uint32_t ) & GLODWORD( ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_REMOTE:
+ case MN_REMOTE | MN_UNSIGNED:
+ case MN_REMOTE | MN_WORD:
+ case MN_REMOTE | MN_BYTE:
+ case MN_REMOTE | MN_WORD | MN_UNSIGNED:
+ case MN_REMOTE | MN_BYTE | MN_UNSIGNED:
+ case MN_REMOTE | MN_STRING:
+ case MN_REMOTE | MN_FLOAT:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = ( uint32_t ) & LOCDWORD( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_REMOTE_PUBLIC:
+ case MN_REMOTE_PUBLIC | MN_UNSIGNED:
+ case MN_REMOTE_PUBLIC | MN_WORD:
+ case MN_REMOTE_PUBLIC | MN_BYTE:
+ case MN_REMOTE_PUBLIC | MN_WORD | MN_UNSIGNED:
+ case MN_REMOTE_PUBLIC | MN_BYTE | MN_UNSIGNED:
+ case MN_REMOTE_PUBLIC | MN_STRING:
+ case MN_REMOTE_PUBLIC | MN_FLOAT:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = ( uint32_t ) & PUBDWORD( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ /* Access to variables DWORD type */
+
+ case MN_GET_PRIV:
+ case MN_GET_PRIV | MN_FLOAT:
+ case MN_GET_PRIV | MN_UNSIGNED:
+ *r->stack_ptr++ = PRIDWORD( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_PUBLIC:
+ case MN_GET_PUBLIC | MN_FLOAT:
+ case MN_GET_PUBLIC | MN_UNSIGNED:
+ *r->stack_ptr++ = PUBDWORD( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_LOCAL:
+ case MN_GET_LOCAL | MN_FLOAT:
+ case MN_GET_LOCAL | MN_UNSIGNED:
+ *r->stack_ptr++ = LOCDWORD( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_GLOBAL:
+ case MN_GET_GLOBAL | MN_FLOAT:
+ case MN_GET_GLOBAL | MN_UNSIGNED:
+ *r->stack_ptr++ = GLODWORD( ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_REMOTE:
+ case MN_GET_REMOTE | MN_FLOAT:
+ case MN_GET_REMOTE | MN_UNSIGNED:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = LOCDWORD( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_REMOTE_PUBLIC:
+ case MN_GET_REMOTE_PUBLIC | MN_FLOAT:
+ case MN_GET_REMOTE_PUBLIC | MN_UNSIGNED:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = PUBDWORD( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_PTR:
+ case MN_PTR | MN_UNSIGNED:
+ case MN_PTR | MN_FLOAT:
+ r->stack_ptr[-1] = *( int32_t * )r->stack_ptr[-1] ;
+ ptr++ ;
+ break ;
+
+ /* Access to variables STRING type */
+
+ case MN_PUSH | MN_STRING:
+ *r->stack_ptr++ = ptr[1];
+ string_use( r->stack_ptr[-1] );
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_PRIV | MN_STRING:
+ *r->stack_ptr++ = PRIDWORD( r, ptr[1] ) ;
+ string_use( r->stack_ptr[-1] );
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_PUBLIC | MN_STRING:
+ *r->stack_ptr++ = PUBDWORD( r, ptr[1] ) ;
+ string_use( r->stack_ptr[-1] );
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_LOCAL | MN_STRING:
+ *r->stack_ptr++ = LOCDWORD( r, ptr[1] ) ;
+ string_use( r->stack_ptr[-1] );
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_GLOBAL | MN_STRING:
+ *r->stack_ptr++ = GLODWORD( ptr[1] ) ;
+ string_use( r->stack_ptr[-1] );
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_REMOTE | MN_STRING:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = LOCDWORD( i, ptr[1] ) ;
+ string_use( r->stack_ptr[-1] );
+ ptr += 2 ;
+ break ;
+
+ case MN_GET_REMOTE_PUBLIC | MN_STRING:
+ i = instance_get( r->stack_ptr[-1] );
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = PUBDWORD( i, ptr[1] ) ;
+ string_use( r->stack_ptr[-1] );
+ ptr += 2 ;
+ break ;
+
+ case MN_STRING | MN_PTR:
+ r->stack_ptr[-1] = *( int32_t * )r->stack_ptr[-1] ;
+ string_use( r->stack_ptr[-1] );
+ ptr++ ;
+ break ;
+
+ case MN_STRING | MN_POP:
+ string_discard( r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* Access to variables WORD type */
+
+ case MN_WORD | MN_GET_PRIV:
+ *r->stack_ptr++ = PRIINT16( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_PRIV | MN_UNSIGNED:
+ *r->stack_ptr++ = PRIWORD( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_PUBLIC:
+ *r->stack_ptr++ = PUBINT16( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_PUBLIC | MN_UNSIGNED:
+ *r->stack_ptr++ = PUBWORD( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_LOCAL:
+ *r->stack_ptr++ = LOCINT16( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_LOCAL | MN_UNSIGNED:
+ *r->stack_ptr++ = LOCWORD( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_GLOBAL:
+ *r->stack_ptr++ = GLOINT16( ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_GLOBAL | MN_UNSIGNED:
+ *r->stack_ptr++ = GLOWORD( ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_REMOTE:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = LOCINT16( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_REMOTE | MN_UNSIGNED:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = LOCWORD( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_REMOTE_PUBLIC:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = PUBINT16( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_GET_REMOTE_PUBLIC | MN_UNSIGNED:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = PUBWORD( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_PTR:
+ r->stack_ptr[-1] = *( int16_t * )r->stack_ptr[-1] ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_PTR | MN_UNSIGNED:
+ r->stack_ptr[-1] = *( uint16_t * )r->stack_ptr[-1] ;
+ ptr++ ;
+ break ;
+
+ /* Access to variables BYTE type */
+
+ case MN_BYTE | MN_GET_PRIV:
+ *r->stack_ptr++ = PRIINT8( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_PRIV | MN_UNSIGNED:
+ *r->stack_ptr++ = PRIBYTE( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_PUBLIC:
+ *r->stack_ptr++ = PUBINT8( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_PUBLIC | MN_UNSIGNED:
+ *r->stack_ptr++ = PUBBYTE( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_LOCAL:
+ *r->stack_ptr++ = LOCINT8( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_LOCAL | MN_UNSIGNED:
+ *r->stack_ptr++ = LOCBYTE( r, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_GLOBAL:
+ *r->stack_ptr++ = GLOINT8( ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_GLOBAL | MN_UNSIGNED:
+ *r->stack_ptr++ = GLOBYTE( ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_REMOTE:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = LOCINT8( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_REMOTE | MN_UNSIGNED:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = LOCBYTE( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_REMOTE_PUBLIC:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = PUBINT8( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_GET_REMOTE_PUBLIC | MN_UNSIGNED:
+ i = instance_get( r->stack_ptr[-1] ) ;
+ if ( !i )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Process %d not active\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), r->stack_ptr[-1] ) ;
+ exit( 0 );
+ }
+ else
+ r->stack_ptr[-1] = PUBBYTE( i, ptr[1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_PTR:
+ r->stack_ptr[-1] = *(( int8_t * )r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_PTR | MN_UNSIGNED:
+ r->stack_ptr[-1] = *(( uint8_t * )r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ /* Floating point math */
+
+ case MN_FLOAT | MN_NEG:
+ *( float * )&r->stack_ptr[-1] = -*(( float * ) & r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_NOT:
+ *( float * )&r->stack_ptr[-1] = ( float ) !*(( float * ) & r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_ADD:
+ *( float * )&r->stack_ptr[-2] += *(( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_SUB:
+ *( float * )&r->stack_ptr[-2] -= *(( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_MUL:
+ *( float * )&r->stack_ptr[-2] *= *(( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_DIV:
+ *( float * )&r->stack_ptr[-2] /= *(( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT2INT:
+ *( int32_t * )&( r->stack_ptr[-ptr[1] - 1] ) = ( int32_t ) * ( float * ) & ( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2FLOAT:
+ case MN_INT2FLOAT | MN_UNSIGNED:
+ *( float * )&( r->stack_ptr[-ptr[1] - 1] ) = ( float ) * ( int32_t * ) & ( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2FLOAT | MN_UNSIGNED | MN_WORD:
+ *( float * )&( r->stack_ptr[-ptr[1] - 1] ) = ( float ) * ( uint16_t * ) & ( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2FLOAT | MN_UNSIGNED | MN_BYTE:
+ *( float * )&( r->stack_ptr[-ptr[1] - 1] ) = ( float ) * ( uint8_t * ) & ( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2WORD:
+ case MN_INT2WORD | MN_UNSIGNED:
+ *( uint32_t * )&( r->stack_ptr[-ptr[1] - 1] ) = ( int32_t )( uint16_t ) * ( int32_t * ) & ( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2;
+ break;
+
+ case MN_INT2BYTE:
+ case MN_INT2BYTE | MN_UNSIGNED:
+ *( uint32_t * )&( r->stack_ptr[-ptr[1] - 1] ) = ( int32_t )( uint8_t ) * ( int32_t * ) & ( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2;
+ break;
+
+ /* Mathematical operations */
+
+ case MN_NEG:
+ case MN_NEG | MN_UNSIGNED:
+ r->stack_ptr[-1] = -r->stack_ptr[-1] ;
+ ptr++ ;
+ break ;
+
+ case MN_NOT:
+ case MN_NOT | MN_UNSIGNED:
+ r->stack_ptr[-1] = !( r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ case MN_ADD:
+ r->stack_ptr[-2] += r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_SUB:
+ r->stack_ptr[-2] -= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_MUL | MN_WORD:
+ case MN_MUL | MN_BYTE:
+ case MN_MUL:
+ r->stack_ptr[-2] *= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_MUL | MN_WORD | MN_UNSIGNED:
+ case MN_MUL | MN_BYTE | MN_UNSIGNED:
+ case MN_MUL | MN_UNSIGNED:
+ r->stack_ptr[-2] = ( uint32_t )r->stack_ptr[-2] * ( uint32_t )r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_DIV | MN_WORD:
+ case MN_DIV | MN_BYTE:
+ case MN_DIV:
+ if ( r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ r->stack_ptr[-2] /= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_DIV | MN_WORD | MN_UNSIGNED:
+ case MN_DIV | MN_BYTE | MN_UNSIGNED:
+ case MN_DIV | MN_UNSIGNED:
+ if ( r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ r->stack_ptr[-2] = ( uint32_t )r->stack_ptr[-2] / ( uint32_t )r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_MOD | MN_WORD:
+ case MN_MOD | MN_BYTE:
+ case MN_MOD:
+ if ( r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ r->stack_ptr[-2] %= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_MOD | MN_WORD | MN_UNSIGNED:
+ case MN_MOD | MN_BYTE | MN_UNSIGNED:
+ case MN_MOD | MN_UNSIGNED:
+ if ( r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ r->stack_ptr[-2] = ( uint32_t )r->stack_ptr[-2] % ( uint32_t )r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* Bitwise operations */
+
+ case MN_ROR:
+ ( r->stack_ptr[-2] ) = (( int32_t )r->stack_ptr[-2] ) >> r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_ROR | MN_UNSIGNED:
+ r->stack_ptr[-2] = (( uint32_t ) r->stack_ptr[-2] ) >> r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_ROR:
+ r->stack_ptr[-2] = (( int16_t ) r->stack_ptr[-2] ) >> r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_ROR | MN_UNSIGNED:
+ r->stack_ptr[-2] = (( uint16_t ) r->stack_ptr[-2] ) >> r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_ROR:
+ r->stack_ptr[-2] = (( int8_t ) r->stack_ptr[-2] >> r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_ROR | MN_UNSIGNED:
+ r->stack_ptr[-2] = (( uint8_t ) r->stack_ptr[-2] ) >> r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_ROL:
+ ( r->stack_ptr[-2] ) = (( int32_t )r->stack_ptr[-2] ) << r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* All the next ROL operations, don't could be necessaries, but well... */
+
+ case MN_ROL | MN_UNSIGNED:
+ ( r->stack_ptr[-2] ) = ( uint32_t )( r->stack_ptr[-2] << r->stack_ptr[-1] );
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_ROL:
+ ( r->stack_ptr[-2] ) = (( int16_t )r->stack_ptr[-2] ) << r->stack_ptr[-1];
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_ROL | MN_UNSIGNED:
+ ( r->stack_ptr[-2] ) = ( uint16_t )( r->stack_ptr[-2] << r->stack_ptr[-1] );
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_ROL:
+ ( r->stack_ptr[-2] ) = (( int8_t )r->stack_ptr[-2] ) << r->stack_ptr[-1];
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_ROL | MN_UNSIGNED:
+ ( r->stack_ptr[-2] ) = ( uint8_t )( r->stack_ptr[-2] << r->stack_ptr[-1] );
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BAND:
+ case MN_BAND | MN_UNSIGNED:
+ r->stack_ptr[-2] &= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BOR:
+ case MN_BOR | MN_UNSIGNED:
+ r->stack_ptr[-2] |= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BXOR:
+ case MN_BXOR | MN_UNSIGNED:
+ r->stack_ptr[-2] ^= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BNOT:
+ case MN_BNOT | MN_UNSIGNED:
+ r->stack_ptr[-1] = ~( r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_BNOT:
+ r->stack_ptr[-1] = ( int8_t ) ~( r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_BNOT | MN_UNSIGNED:
+ r->stack_ptr[-1] = ( uint8_t ) ~( r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_BNOT:
+ r->stack_ptr[-1] = ( int16_t ) ~( r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_BNOT | MN_UNSIGNED:
+ r->stack_ptr[-1] = ( uint16_t ) ~( r->stack_ptr[-1] ) ;
+ ptr++ ;
+ break ;
+
+ /* Logical operations */
+
+ case MN_AND:
+ r->stack_ptr[-2] = r->stack_ptr[-2] && r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_OR:
+ r->stack_ptr[-2] = r->stack_ptr[-2] || r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_XOR:
+ r->stack_ptr[-2] = ( r->stack_ptr[-2] != 0 ) ^( r->stack_ptr[-1] != 0 ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* Comparisons */
+
+ case MN_EQ:
+ r->stack_ptr[-2] = ( r->stack_ptr[-2] == r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_NE:
+ r->stack_ptr[-2] = ( r->stack_ptr[-2] != r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_GTE:
+ r->stack_ptr[-2] = ( r->stack_ptr[-2] >= r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_GTE | MN_UNSIGNED:
+ r->stack_ptr[-2] = (( uint32_t )r->stack_ptr[-2] >= ( uint32_t )r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LTE:
+ r->stack_ptr[-2] = ( r->stack_ptr[-2] <= r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LTE | MN_UNSIGNED:
+ r->stack_ptr[-2] = (( uint32_t )r->stack_ptr[-2] <= ( uint32_t )r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LT:
+ r->stack_ptr[-2] = ( r->stack_ptr[-2] < r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LT | MN_UNSIGNED:
+ r->stack_ptr[-2] = (( uint32_t )r->stack_ptr[-2] < ( uint32_t )r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_GT:
+ r->stack_ptr[-2] = ( r->stack_ptr[-2] > r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_GT | MN_UNSIGNED:
+ r->stack_ptr[-2] = (( uint32_t )r->stack_ptr[-2] > ( uint32_t )r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* Floating point comparisons */
+
+ case MN_EQ | MN_FLOAT:
+ r->stack_ptr[-2] = ( *( float * ) & r->stack_ptr[-2] == *( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_NE | MN_FLOAT:
+ r->stack_ptr[-2] = ( *( float * ) & r->stack_ptr[-2] != *( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_GTE | MN_FLOAT:
+ r->stack_ptr[-2] = ( *( float * ) & r->stack_ptr[-2] >= *( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LTE | MN_FLOAT:
+ r->stack_ptr[-2] = ( *( float * ) & r->stack_ptr[-2] <= *( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LT | MN_FLOAT:
+ r->stack_ptr[-2] = ( *( float * ) & r->stack_ptr[-2] < *( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_GT | MN_FLOAT:
+ r->stack_ptr[-2] = ( *( float * ) & r->stack_ptr[-2] > *( float * ) & r->stack_ptr[-1] ) ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* String comparisons */
+
+ case MN_EQ | MN_STRING :
+ n = string_comp( r->stack_ptr[-2], r->stack_ptr[-1] ) == 0 ;
+ string_discard( r->stack_ptr[-2] );
+ string_discard( r->stack_ptr[-1] );
+ r->stack_ptr[-2] = n;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_NE | MN_STRING :
+ n = string_comp( r->stack_ptr[-2], r->stack_ptr[-1] ) != 0 ;
+ string_discard( r->stack_ptr[-2] );
+ string_discard( r->stack_ptr[-1] );
+ r->stack_ptr[-2] = n;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_GTE | MN_STRING :
+ n = string_comp( r->stack_ptr[-2], r->stack_ptr[-1] ) >= 0 ;
+ string_discard( r->stack_ptr[-2] );
+ string_discard( r->stack_ptr[-1] );
+ r->stack_ptr[-2] = n;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LTE | MN_STRING :
+ n = string_comp( r->stack_ptr[-2], r->stack_ptr[-1] ) <= 0 ;
+ string_discard( r->stack_ptr[-2] );
+ string_discard( r->stack_ptr[-1] );
+ r->stack_ptr[-2] = n;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LT | MN_STRING :
+ n = string_comp( r->stack_ptr[-2], r->stack_ptr[-1] ) < 0 ;
+ string_discard( r->stack_ptr[-2] );
+ string_discard( r->stack_ptr[-1] );
+ r->stack_ptr[-2] = n;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_GT | MN_STRING :
+ n = string_comp( r->stack_ptr[-2], r->stack_ptr[-1] ) > 0 ;
+ string_discard( r->stack_ptr[-2] );
+ string_discard( r->stack_ptr[-1] );
+ r->stack_ptr[-2] = n;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* String operations */
+
+ case MN_VARADD | MN_STRING:
+ n = *( int32_t * )( r->stack_ptr[-2] ) ;
+ *( int32_t * )( r->stack_ptr[-2] ) = string_add( n, r->stack_ptr[-1] ) ;
+ string_use( *( int32_t * )( r->stack_ptr[-2] ) );
+ string_discard( n );
+ string_discard( r->stack_ptr[-1] );
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_LETNP | MN_STRING:
+ string_discard( *( int32_t * )( r->stack_ptr[-2] ) );
+ ( *( int32_t * )( r->stack_ptr[-2] ) ) = r->stack_ptr[-1];
+ r->stack_ptr -= 2 ;
+ ptr++ ;
+ break ;
+
+ case MN_LET | MN_STRING:
+ string_discard( *( int32_t * )( r->stack_ptr[-2] ) );
+ ( *( int32_t * )( r->stack_ptr[-2] ) ) = r->stack_ptr[-1];
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_ADD | MN_STRING:
+ n = string_add( r->stack_ptr[-2], r->stack_ptr[-1] );
+ string_use( n ) ;
+ string_discard( r->stack_ptr[-2] );
+ string_discard( r->stack_ptr[-1] );
+ r->stack_ptr-- ;
+ r->stack_ptr[-1] = n ;
+ ptr++ ;
+ break ;
+
+ case MN_INT2STR:
+ r->stack_ptr[-ptr[1] - 1] = string_itoa( r->stack_ptr[-ptr[1] - 1] ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2STR | MN_UNSIGNED:
+ r->stack_ptr[-ptr[1] - 1] = string_uitoa( r->stack_ptr[-ptr[1] - 1] ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2STR | MN_WORD:
+ r->stack_ptr[-ptr[1] - 1] = string_itoa( r->stack_ptr[-ptr[1] - 1] ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2STR | MN_UNSIGNED | MN_WORD:
+ r->stack_ptr[-ptr[1] - 1] = string_uitoa( r->stack_ptr[-ptr[1] - 1] ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2STR | MN_BYTE:
+ r->stack_ptr[-ptr[1] - 1] = string_itoa( r->stack_ptr[-ptr[1] - 1] ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_INT2STR | MN_UNSIGNED | MN_BYTE:
+ r->stack_ptr[-ptr[1] - 1] = string_uitoa( r->stack_ptr[-ptr[1] - 1] ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_FLOAT2STR:
+ r->stack_ptr[-ptr[1] - 1] = string_ftoa( *( float * ) & r->stack_ptr[-ptr[1] - 1] ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_CHR2STR:
+ buffer[0] = ( uint8_t )r->stack_ptr[-ptr[1] - 1] ;
+ buffer[1] = 0 ;
+ r->stack_ptr[-ptr[1] - 1] = string_new( buffer ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_STRI2CHR:
+ n = string_char( r->stack_ptr[-2], r->stack_ptr[-1] ) ;
+ string_discard( r->stack_ptr[-2] );
+ r->stack_ptr-- ;
+ r->stack_ptr[-1] = n ;
+ ptr++ ;
+ break ;
+
+ case MN_STR2CHR:
+ n = r->stack_ptr[-ptr[1] - 1] ;
+ r->stack_ptr[-1] = *string_get( n ) ;
+ string_discard( n );
+ ptr += 2 ;
+ break ;
+
+ case MN_POINTER2STR:
+ r->stack_ptr[-ptr[1] - 1] = string_ptoa( *( void ** ) & r->stack_ptr[-ptr[1] - 1] ) ;
+ string_use( r->stack_ptr[-ptr[1] - 1] ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_STR2FLOAT:
+ n = r->stack_ptr[-ptr[1] - 1] ;
+ str = ( char * )string_get( n ) ;
+ *( float * )( &r->stack_ptr[-ptr[1] - 1] ) = str ? ( float )atof( str ) : 0.0f ;
+ string_discard( n ) ;
+ ptr += 2 ;
+ break ;
+
+ case MN_STR2INT:
+ n = r->stack_ptr[-ptr[1] - 1] ;
+ str = ( char * )string_get( n ) ;
+ r->stack_ptr[-ptr[1] - 1] = str ? atoi( str ) : 0 ;
+ string_discard( n ) ;
+ ptr += 2 ;
+ break ;
+
+ /* Fixed-length strings operations*/
+
+ case MN_A2STR:
+ str = *( char ** )( &r->stack_ptr[-ptr[1] - 1] ) ;
+ n = string_new( str );
+ string_use( n );
+ r->stack_ptr[-ptr[1] - 1] = n ;
+ ptr += 2 ;
+ break ;
+
+ case MN_STR2A:
+ n = r->stack_ptr[-1];
+ strncpy( *( char ** )( &r->stack_ptr[-2] ), string_get( n ), ptr[1] ) ;
+ (( char * )( r->stack_ptr[-2] ) )[ptr[1]] = 0;
+ r->stack_ptr[-2] = r->stack_ptr[-1];
+ r->stack_ptr--;
+ ptr += 2 ;
+ break ;
+
+ case MN_STRACAT:
+ n = r->stack_ptr[-1];
+ strncat( *( char ** )( &r->stack_ptr[-2] ), string_get( n ), (ptr[1]-1) - strlen( *( char ** )( &r->stack_ptr[-2] ) ) ) ;
+ (( char * )( r->stack_ptr[-2] ) )[ptr[1]-1] = 0;
+ r->stack_ptr[-2] = r->stack_ptr[-1];
+ r->stack_ptr--;
+ ptr += 2 ;
+ break ;
+
+ /* Direct operations with variables DWORD type */
+
+ case MN_LETNP:
+ case MN_LETNP | MN_UNSIGNED:
+ ( *( int32_t * )( r->stack_ptr[-2] ) ) = r->stack_ptr[-1] ;
+ r->stack_ptr -= 2 ;
+ ptr++ ;
+ break ;
+
+ case MN_LET:
+ case MN_LET | MN_UNSIGNED:
+ ( *( int32_t * )( r->stack_ptr[-2] ) ) = r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_INC:
+ case MN_INC | MN_UNSIGNED:
+ ( *( int32_t * )( r->stack_ptr[-1] ) ) += ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_DEC:
+ case MN_DEC | MN_UNSIGNED:
+ ( *( int32_t * )( r->stack_ptr[-1] ) ) -= ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_POSTDEC:
+ case MN_POSTDEC | MN_UNSIGNED:
+ ( *( int32_t * )( r->stack_ptr[-1] ) ) -= ptr[1] ;
+ r->stack_ptr[-1] = *( int32_t * )( r->stack_ptr[-1] ) + ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_POSTINC:
+ case MN_POSTINC | MN_UNSIGNED:
+ *(( int32_t * )( r->stack_ptr[-1] ) ) += ptr[1] ;
+ r->stack_ptr[-1] = *( int32_t * )( r->stack_ptr[-1] ) - ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_VARADD:
+ case MN_VARADD | MN_UNSIGNED:
+ *( int32_t * )( r->stack_ptr[-2] ) += r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARSUB:
+ case MN_VARSUB | MN_UNSIGNED:
+ *( int32_t * )( r->stack_ptr[-2] ) -= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARMUL:
+ case MN_VARMUL | MN_UNSIGNED:
+ *( int32_t * )( r->stack_ptr[-2] ) *= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARDIV:
+ case MN_VARDIV | MN_UNSIGNED:
+ if ( r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ *( int32_t * )( r->stack_ptr[-2] ) /= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARMOD:
+ case MN_VARMOD | MN_UNSIGNED:
+ if ( r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ *( int32_t * )( r->stack_ptr[-2] ) %= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VAROR:
+ case MN_VAROR | MN_UNSIGNED:
+ *( int32_t * )( r->stack_ptr[-2] ) |= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARXOR:
+ case MN_VARXOR | MN_UNSIGNED:
+ *( int32_t * )( r->stack_ptr[-2] ) ^= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARAND:
+ case MN_VARAND | MN_UNSIGNED:
+ *( int32_t * )( r->stack_ptr[-2] ) &= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARROR:
+ *( int32_t * )( r->stack_ptr[-2] ) >>= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARROR | MN_UNSIGNED:
+ *( uint32_t * )( r->stack_ptr[-2] ) >>= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARROL:
+ *( int32_t * )( r->stack_ptr[-2] ) <<= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_VARROL | MN_UNSIGNED:
+ *( uint32_t * )( r->stack_ptr[-2] ) <<= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* Direct operations with variables WORD type */
+
+ case MN_WORD | MN_LETNP:
+ case MN_WORD | MN_LETNP | MN_UNSIGNED:
+ ( *( int16_t * )( r->stack_ptr[-2] ) ) = r->stack_ptr[-1] ;
+ r->stack_ptr -= 2 ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_LET:
+ case MN_WORD | MN_LET | MN_UNSIGNED:
+ ( *( int16_t * )( r->stack_ptr[-2] ) ) = r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_INC:
+ case MN_WORD | MN_INC | MN_UNSIGNED:
+ ( *( int16_t * )( r->stack_ptr[-1] ) ) += ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_DEC:
+ case MN_WORD | MN_DEC | MN_UNSIGNED:
+ ( *( int16_t * )( r->stack_ptr[-1] ) ) -= ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_POSTDEC:
+ case MN_WORD | MN_POSTDEC | MN_UNSIGNED:
+ ( *( int16_t * )( r->stack_ptr[-1] ) ) -= ptr[1] ;
+ r->stack_ptr[-1] = *( int16_t * )( r->stack_ptr[-1] ) + ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_POSTINC:
+ case MN_WORD | MN_POSTINC | MN_UNSIGNED:
+ *(( int16_t * )( r->stack_ptr[-1] ) ) += ptr[1] ;
+ r->stack_ptr[-1] = *( int16_t * )( r->stack_ptr[-1] ) - ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_WORD | MN_VARADD:
+ case MN_WORD | MN_VARADD | MN_UNSIGNED:
+ *( int16_t * )( r->stack_ptr[-2] ) += r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARSUB:
+ case MN_WORD | MN_VARSUB | MN_UNSIGNED:
+ *( int16_t * )( r->stack_ptr[-2] ) -= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARMUL:
+ case MN_WORD | MN_VARMUL | MN_UNSIGNED:
+ *( int16_t * )( r->stack_ptr[-2] ) *= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARDIV:
+ case MN_WORD | MN_VARDIV | MN_UNSIGNED:
+ if (( int16_t )r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ *( int16_t * )( r->stack_ptr[-2] ) /= ( int16_t )r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARMOD:
+ case MN_WORD | MN_VARMOD | MN_UNSIGNED:
+ if (( int16_t )r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ *( int16_t * )( r->stack_ptr[-2] ) %= ( int16_t )r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VAROR:
+ case MN_WORD | MN_VAROR | MN_UNSIGNED:
+ *( int16_t * )( r->stack_ptr[-2] ) |= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARXOR:
+ case MN_WORD | MN_VARXOR | MN_UNSIGNED:
+ *( int16_t * )( r->stack_ptr[-2] ) ^= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARAND:
+ case MN_WORD | MN_VARAND | MN_UNSIGNED:
+ *( int16_t * )( r->stack_ptr[-2] ) &= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARROR:
+ *( int16_t * )( r->stack_ptr[-2] ) >>= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARROR | MN_UNSIGNED:
+ *( uint16_t * )( r->stack_ptr[-2] ) >>= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARROL:
+ *( int16_t * )( r->stack_ptr[-2] ) <<= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_WORD | MN_VARROL | MN_UNSIGNED:
+ *( uint16_t * )( r->stack_ptr[-2] ) <<= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* Direct operations with variables BYTE type */
+
+ case MN_BYTE | MN_LETNP:
+ case MN_BYTE | MN_LETNP | MN_UNSIGNED:
+ ( *( uint8_t * )( r->stack_ptr[-2] ) ) = r->stack_ptr[-1] ;
+ r->stack_ptr -= 2 ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_LET:
+ case MN_BYTE | MN_LET | MN_UNSIGNED:
+ ( *( uint8_t * )( r->stack_ptr[-2] ) ) = r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_INC:
+ case MN_BYTE | MN_INC | MN_UNSIGNED:
+ ( *( uint8_t * )( r->stack_ptr[-1] ) ) += ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_DEC:
+ case MN_BYTE | MN_DEC | MN_UNSIGNED:
+ ( *( uint8_t * )( r->stack_ptr[-1] ) ) -= ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_POSTDEC:
+ case MN_BYTE | MN_POSTDEC | MN_UNSIGNED:
+ ( *( uint8_t * )( r->stack_ptr[-1] ) ) -= ptr[1] ;
+ r->stack_ptr[-1] = *( uint8_t * )( r->stack_ptr[-1] ) + ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_POSTINC:
+ case MN_BYTE | MN_POSTINC | MN_UNSIGNED:
+ *(( uint8_t * )( r->stack_ptr[-1] ) ) += ptr[1] ;
+ r->stack_ptr[-1] = *( uint8_t * )( r->stack_ptr[-1] ) - ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_BYTE | MN_VARADD:
+ case MN_BYTE | MN_VARADD | MN_UNSIGNED:
+ *( uint8_t * )( r->stack_ptr[-2] ) += r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARSUB:
+ case MN_BYTE | MN_VARSUB | MN_UNSIGNED:
+ *( uint8_t * )( r->stack_ptr[-2] ) -= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARMUL:
+ case MN_BYTE | MN_VARMUL | MN_UNSIGNED:
+ *( uint8_t * )( r->stack_ptr[-2] ) *= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARDIV:
+ case MN_BYTE | MN_VARDIV | MN_UNSIGNED:
+ if (( uint8_t )r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ *( uint8_t * )( r->stack_ptr[-2] ) /= ( uint8_t )r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARMOD:
+ case MN_BYTE | MN_VARMOD | MN_UNSIGNED:
+ if (( uint8_t )r->stack_ptr[-1] == 0 )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Division by zero\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ *( uint8_t * )( r->stack_ptr[-2] ) %= ( uint8_t )r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VAROR:
+ case MN_BYTE | MN_VAROR | MN_UNSIGNED:
+ *( uint8_t * )( r->stack_ptr[-2] ) |= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARXOR:
+ case MN_BYTE | MN_VARXOR | MN_UNSIGNED:
+ *( uint8_t * )( r->stack_ptr[-2] ) ^= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARAND:
+ case MN_BYTE | MN_VARAND | MN_UNSIGNED:
+ *( uint8_t * )( r->stack_ptr[-2] ) &= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARROR:
+ *( int8_t * )( r->stack_ptr[-2] ) >>= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARROR | MN_UNSIGNED:
+ *( uint8_t * )( r->stack_ptr[-2] ) >>= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARROL:
+ *( int8_t * )( r->stack_ptr[-2] ) <<= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_BYTE | MN_VARROL | MN_UNSIGNED:
+ *( uint8_t * )( r->stack_ptr[-2] ) <<= r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* Direct operations with variables FLOAT type */
+
+ case MN_FLOAT | MN_LETNP:
+ ( *( float * )( r->stack_ptr[-2] ) ) = *( float * ) & r->stack_ptr[-1] ;
+ r->stack_ptr -= 2 ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_LET :
+ ( *( float * )( r->stack_ptr[-2] ) ) = *( float * ) & r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_INC:
+ ( *( float * )( r->stack_ptr[-1] ) ) += ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_FLOAT | MN_DEC:
+ ( *( float * )( r->stack_ptr[-1] ) ) -= ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_FLOAT | MN_POSTDEC:
+ ( *( float * )( r->stack_ptr[-1] ) ) -= ptr[1] ;
+ r->stack_ptr[-1] = *( uint32_t * )( r->stack_ptr[-1] ) + ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_FLOAT | MN_POSTINC:
+ *(( float * )( r->stack_ptr[-1] ) ) += ptr[1] ;
+ r->stack_ptr[-1] = *( uint32_t * )( r->stack_ptr[-1] ) - ptr[1] ;
+ ptr += 2 ;
+ break ;
+
+ case MN_FLOAT | MN_VARADD:
+ *( float * )( r->stack_ptr[-2] ) += *( float * ) & r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_VARSUB:
+ *( float * )( r->stack_ptr[-2] ) -= *( float * ) & r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_VARMUL:
+ *( float * )( r->stack_ptr[-2] ) *= *( float * ) & r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ case MN_FLOAT | MN_VARDIV:
+ *( float * )( r->stack_ptr[-2] ) /= *( float * ) & r->stack_ptr[-1] ;
+ r->stack_ptr-- ;
+ ptr++ ;
+ break ;
+
+ /* Jumps */
+
+ case MN_JUMP:
+ ptr = r->code + ptr[1] ;
+ continue ;
+
+ case MN_JTRUE:
+ r->stack_ptr-- ;
+ if ( *r->stack_ptr )
+ {
+ ptr = r->code + ptr[1] ;
+ continue ;
+ }
+ ptr += 2 ;
+ break ;
+
+ case MN_JFALSE:
+ r->stack_ptr-- ;
+ if ( !*r->stack_ptr )
+ {
+ ptr = r->code + ptr[1] ;
+ continue ;
+ }
+ ptr += 2 ;
+ break ;
+
+ case MN_JTTRUE:
+ if ( r->stack_ptr[-1] )
+ {
+ ptr = r->code + ptr[1] ;
+ continue ;
+ }
+ ptr += 2 ;
+ break ;
+
+ case MN_JTFALSE:
+ if ( !r->stack_ptr[-1] )
+ {
+ ptr = r->code + ptr[1] ;
+ continue ;
+ }
+ ptr += 2 ;
+ break ;
+
+ case MN_NCALL:
+ *r->stack_ptr++ = ptr - r->code + 2 ; /* Push next address */
+ ptr = r->code + ptr[1] ; /* Call function */
+ r->call_level++;
+ break ;
+
+ /* Switch */
+
+ case MN_SWITCH:
+ r->switchval = *--r->stack_ptr ;
+ r->cased = 0 ;
+ ptr++ ;
+ break ;
+
+ case MN_SWITCH | MN_STRING:
+ if ( r->switchval_string != 0 ) string_discard( r->switchval_string );
+ r->switchval_string = *--r->stack_ptr;
+ r->cased = 0;
+ ptr++;
+ break;
+
+ case MN_CASE:
+ if ( r->switchval == *--r->stack_ptr ) r->cased = 2 ;
+ ptr++ ;
+ break ;
+
+ case MN_CASE | MN_STRING:
+ if ( string_comp( r->switchval_string, *--r->stack_ptr ) == 0 ) r->cased = 2 ;
+ string_discard( *r->stack_ptr );
+ string_discard( r->stack_ptr[-1] );
+ ptr++;
+ break;
+
+ case MN_CASE_R:
+ r->stack_ptr -= 2 ;
+ if ( r->switchval >= r->stack_ptr[0] && r->switchval <= r->stack_ptr[1] ) r->cased = 1 ;
+ ptr++ ;
+ break ;
+
+ case MN_CASE_R | MN_STRING:
+ r->stack_ptr -= 2;
+ if ( string_comp( r->switchval_string, r->stack_ptr[0] ) >= 0 &&
+ string_comp( r->switchval_string, r->stack_ptr[1] ) <= 0 )
+ r->cased = 1;
+ string_discard( r->stack_ptr[0] );
+ string_discard( r->stack_ptr[1] );
+ ptr++;
+ break;
+
+ case MN_JNOCASE:
+ if ( r->cased < 1 )
+ {
+ ptr = r->code + ptr[1] ;
+ continue ;
+ }
+ ptr += 2 ;
+ break ;
+
+ /* Process control */
+
+ case MN_TYPE:
+ {
+ PROCDEF * proct = procdef_get( ptr[1] ) ;
+ if ( !proct )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Invalid type\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ exit( 0 );
+ }
+ *r->stack_ptr++ = proct->type ;
+ ptr += 2 ;
+ break ;
+ }
+
+ case MN_FRAME:
+ LOCINT32( r, FRAME_PERCENT ) += r->stack_ptr[-1];
+ r->stack_ptr-- ;
+ r->codeptr = ptr + 1 ;
+ return_value = LOCDWORD( r, PROCESS_ID );
+
+ if ( !( r->proc->flags & PROC_FUNCTION ) &&
+ r->called_by && instance_exists( r->called_by ) && ( LOCDWORD( r->called_by, STATUS ) & STATUS_WAITING_MASK ) )
+ {
+ /* We're returning and the parent is waiting: wake it up */
+ if ( r->called_by->stack && ( r->called_by->stack[0] & STACK_RETURN_VALUE ) )
+ r->called_by->stack_ptr[-1] = return_value;
+
+ LOCDWORD( r->called_by, STATUS ) &= ~STATUS_WAITING_MASK;
+ r->called_by = NULL;
+ }
+ goto break_all ;
+
+ case MN_END:
+ if ( r->call_level > 0 )
+ {
+ ptr = r->code + *--r->stack_ptr ;
+ r->call_level--;
+ continue;
+ }
+
+ if ( LOCDWORD( r, STATUS ) != STATUS_DEAD ) LOCDWORD( r, STATUS ) = STATUS_KILLED ;
+ goto break_all ;
+
+ case MN_RETURN:
+ if ( r->call_level > 0 )
+ {
+ ptr = r->code + *--r->stack_ptr ;
+ r->call_level--;
+ continue;
+ }
+
+ if ( LOCDWORD( r, STATUS ) != STATUS_DEAD ) LOCDWORD( r, STATUS ) = STATUS_KILLED ;
+ r->stack_ptr-- ;
+ return_value = *r->stack_ptr ;
+ goto break_all ;
+
+ /* Handlers */
+
+ case MN_EXITHNDLR:
+ r->exitcode = ptr[1] ;
+ ptr += 2 ;
+ break;
+
+ case MN_ERRHNDLR:
+ r->errorcode = ptr[1] ;
+ ptr += 2 ;
+ break;
+
+ /* Others */
+
+ case MN_DEBUG:
+ if ( dcb.data.NSourceFiles )
+ {
+ if ( debug > 0 ) printf( "\n::: DEBUG from %s(%d)\n", r->proc->name, LOCDWORD( r, PROCESS_ID ) ) ;
+ debug_next = 1;
+ }
+ ptr++;
+ break ;
+
+ case MN_SENTENCE:
+ trace_sentence = ptr[1];
+ trace_instance = r;
+ ptr += 2 ;
+ break ;
+
+ default:
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Mnemonic 0x%02X not implemented\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), *ptr ) ;
+ exit( 0 );
+ }
+
+ if ( r->stack_ptr < r->stack )
+ {
+ fprintf( stderr, "ERROR: Runtime error in %s(%d) - Critical Stack Problem StackBase=%p StackPTR=%p\n", r->proc->name, LOCDWORD( r, PROCESS_ID ), (void *)r->stack, (void *)r->stack_ptr ) ;
+ exit( 0 );
+ }
+
+#ifdef EXIT_ON_EMPTY_STACK
+ if ( r->stack_ptr == r->stack )
+ {
+ r->codeptr = ptr ;
+ if ( LOCDWORD( r, STATUS ) != STATUS_RUNNING && LOCDWORD( r, STATUS ) != STATUS_DEAD ) break ;
+ }
+#endif
+
+ }
+
+ /* *** GENERAL EXIT *** */
+break_all:
+
+ if ( !*ptr || *ptr == MN_RETURN || *ptr == MN_END || LOCDWORD( r, STATUS ) == STATUS_KILLED )
+ {
+ /* Check for waiting parent */
+ if ( r->called_by && instance_exists( r->called_by ) && ( LOCDWORD( r->called_by, STATUS ) & STATUS_WAITING_MASK ) )
+ {
+ /* We're returning and the parent is waiting: wake it up */
+ if ( r->called_by->stack && ( r->called_by->stack[0] & STACK_RETURN_VALUE ) )
+ r->called_by->stack_ptr[-1] = return_value;
+
+ LOCDWORD( r->called_by, STATUS ) &= ~STATUS_WAITING_MASK;
+ }
+ r->called_by = NULL;
+
+ /* The process should be destroyed immediately, it is a function-type one */
+ /* Run ONEXIT */
+ if (( LOCDWORD( r, STATUS ) & ~STATUS_WAITING_MASK ) != STATUS_DEAD && r->exitcode )
+ {
+ LOCDWORD( r, STATUS ) = STATUS_DEAD;
+ r->codeptr = r->code + r->exitcode;
+ instance_go( r );
+ if ( !instance_exists( r ) ) r = NULL;
+ }
+ else
+ {
+ instance_destroy( r );
+ r = NULL ;
+ }
+ }
+
+ /* Hook */
+ if ( r && instance_pos_execute_hook_count )
+ {
+ for ( n = 0; n < instance_pos_execute_hook_count; n++ )
+ instance_pos_execute_hook_list[n]( r );
+ }
+ /* Hook */
+ if ( r && LOCDWORD( r, STATUS ) != STATUS_KILLED && r->first_run ) r->first_run = 0;
+
+ if ( debug_next && trace_sentence != -1 )
+ {
+ force_debug = 1;
+ debug_next = 0;
+ }
+
+ return return_value;
+}
+
+/* ---------------------------------------------------------------------- */
diff --git a/core/bgdrtm/src/misc.c b/core/bgdrtm/src/misc.c
new file mode 100644
index 0000000..aeaf1f1
--- /dev/null
+++ b/core/bgdrtm/src/misc.c
@@ -0,0 +1,317 @@
+/*
+ * Copyright © 2006-2016 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.
+ *
+ */
+
+/* --------------------------------------------------------------------------- */
+/*
+ * INCLUDES
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+
+#include "bgdrtm.h"
+#include "offsets.h"
+#include "dcb.h"
+#include "sysprocs_p.h"
+#include "xstrings.h"
+
+#include "fmath.h"
+
+#if defined(TARGET_GP2X_WIZ) || defined(TARGET_CAANOO)
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+
+ #include <sys/mman.h>
+#endif
+
+/* --------------------------------------------------------------------------- */
+
+char * appname = NULL;
+char * appexename = NULL;
+char * appexepath = NULL;
+char * appexefullpath = NULL;
+
+/* --------------------------------------------------------------------------- */
+
+int debug = 0; /* 1 if running in debug mode */
+
+/* --------------------------------------------------------------------------- */
+
+/* os versions */
+#ifdef _WIN32
+#define _OS_ID OS_WIN32
+#endif
+
+#ifdef TARGET_LINUX
+#define _OS_ID OS_LINUX
+#endif
+
+#ifdef TARGET_BEOS
+#define _OS_ID OS_BEOS
+#endif
+
+#ifdef TARGET_MAC
+#define _OS_ID OS_MACOS
+#endif
+
+#ifdef TARGET_GP32
+#define _OS_ID OS_GP32
+#endif
+
+#ifdef TARGET_DC
+#define _OS_ID OS_DC
+#endif
+
+#ifdef TARGET_BSD
+#define _OS_ID OS_BSD
+#endif
+
+#ifdef TARGET_GP2X
+#ifdef _OS_ID
+#undef _OS_ID
+#endif
+#define _OS_ID OS_GP2X
+#endif
+
+#ifdef TARGET_GP2X_WIZ
+#ifdef _OS_ID
+#undef _OS_ID
+#endif
+#define _OS_ID OS_GP2X_WIZ
+#endif
+
+#ifdef TARGET_CAANOO
+#ifdef _OS_ID
+#undef _OS_ID
+#endif
+#define _OS_ID OS_CAANOO
+#endif
+
+#ifdef TARGET_DINGUX_A320
+#ifdef _OS_ID
+#undef _OS_ID
+#endif
+#define _OS_ID OS_DINGUX_A320
+#endif
+
+#ifdef TARGET_WII
+#ifdef _OS_ID
+#undef _OS_ID
+#endif
+#define _OS_ID OS_WII
+#endif
+
+#ifdef TARGET_ANDROID
+#ifdef _OS_ID
+#undef _OS_ID
+#endif
+#define _OS_ID OS_ANDROID
+#endif
+
+#ifdef TARGET_IOS
+#ifdef _OS_ID
+#undef _OS_ID
+#endif
+#define _OS_ID OS_IOS
+#endif
+
+/* --------------------------------------------------------------------------- */
+
+#if defined(TARGET_GP2X_WIZ) || defined(TARGET_CAANOO)
+
+#define TIMER_BASE3 0x1980
+#define TIMER_REG(x) __bgdrtm_memregl[(TIMER_BASE3 + x) >> 2]
+
+volatile unsigned long *__bgdrtm_memregl = NULL;
+int __bgdrtm_memdev = -1;
+
+#ifdef TARGET_CAANOO
+static unsigned long caanoo_firmware_version = 0;
+#endif
+
+void bgdrtm_ptimer_init(void)
+{
+#if defined(TARGET_GP2X_WIZ)
+ TIMER_REG(0x44) = 0x922;
+#else
+ if ( caanoo_firmware_version < 1000006 ) /* firmware version < 1.0.6 */
+ {
+ TIMER_REG(0x44) = 0x922;
+ }
+ else
+ {
+ TIMER_REG(0x44) = 0x0FF2;
+ }
+#endif
+ TIMER_REG(0x40) = 0x0c;
+ TIMER_REG(0x08) = 0x6b;
+}
+
+unsigned long bgdrtm_ptimer_get_ticks_us(void)
+{
+ TIMER_REG(0x08) = 0x4b; /* run timer, latch value */
+ return TIMER_REG(0);
+}
+
+void bgdrtm_ptimer_cleanup(void)
+{
+ TIMER_REG(0x40) = 0x0c;
+ TIMER_REG(0x08) = 0x23;
+ TIMER_REG(0x00) = 0;
+ TIMER_REG(0x40) = 0;
+ TIMER_REG(0x44) = 0;
+}
+
+#endif
+
+/* --------------------------------------------------------------------------- */
+/*
+ * FUNCTION : strncmpi
+ *
+ * Compare two strings (case-insensitive version)
+ *
+ * PARAMS:
+ * str1 first string
+ * str2 second string
+ *
+ * RETURN VALUE:
+ * Result of the comparison
+ */
+
+int strncmpi( char * str1, char * str2, int sz )
+{
+ while (( *str1 || *str2 ) && sz )
+ {
+#ifdef _WIN32
+ if ( toupper( *str1 ) != toupper( *str2 ) ) return toupper( *str1 ) - toupper( *str2 );
+#else
+ if ( *str1 != *str2 ) return *str1 - *str2;
+#endif
+ str1++; str2++; sz--;
+ }
+
+ return 0 ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+void bgdrtm_entry( int argc, char * argv[] )
+{
+ int i;
+ int * args = (int *)&GLODWORD( ARGV_TABLE );
+ char * os_id;
+
+ GLODWORD( ARGC ) = argc ;
+
+ for ( i = 0 ; i < argc && i < 32; i++ )
+ {
+ args[i] = string_new( argv[i] ) ;
+ string_use( args[i] ) ;
+ }
+
+ if ( ( os_id = getenv( "OS_ID" ) ) )
+ GLODWORD( OS_ID ) = atol( os_id ) ;
+ else
+ GLODWORD( OS_ID ) = _OS_ID ;
+
+#if defined(TARGET_GP2X_WIZ) || defined(TARGET_CAANOO)
+
+#ifdef TARGET_CAANOO
+ {
+ FILE * fp = fopen( "/usr/gp2x/version", "r" );
+ if ( fp )
+ {
+ char *p1, *p2;
+ char b[32] = "";
+
+ fgets( b, sizeof(b), fp );
+ fclose( fp );
+
+ if ( ( p2 = strchr( b, '.' ) ) )
+ {
+ *p2++ = '\0';
+ caanoo_firmware_version = atol( b ) * 1000000L;
+ if ( ( p1 = strchr( p2, '.' ) ) )
+ {
+ *p1++ = '\0';
+ caanoo_firmware_version += atol( p2 ) * 1000L;
+ caanoo_firmware_version += atol( p1 );
+ }
+ else
+ {
+ caanoo_firmware_version += atol( p2 ) * 1000L;
+ }
+ }
+ }
+ }
+#endif
+
+ __bgdrtm_memdev = open( "/dev/mem", O_RDWR );
+ __bgdrtm_memregl = mmap( 0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, __bgdrtm_memdev, 0xc0000000 );
+
+ bgdrtm_ptimer_init();
+#endif
+
+ init_cos_tables();
+}
+
+/* --------------------------------------------------------------------------- */
+/*
+ * FUNCTION : bgdrtm_exit
+ *
+ * Exits from the program cleanly ending operations
+ *
+ * PARAMS:
+ * INT n: ERROR LEVEL to return to OS
+ *
+ * RETURN VALUE:
+ * No value
+ *
+ */
+
+void bgdrtm_exit( int exit_value )
+{
+ int n;
+ /* Finalize all modules */
+ if ( module_finalize_count )
+ for ( n = 0; n < module_finalize_count; n++ )
+ module_finalize_list[n]();
+
+#if defined(TARGET_GP2X_WIZ) || defined(TARGET_CAANOO)
+ bgdrtm_ptimer_cleanup();
+
+ __bgdrtm_memregl = munmap( 0, 0x20000 ); __bgdrtm_memregl = NULL;
+ close( __bgdrtm_memdev ); __bgdrtm_memdev = -1;
+#endif
+
+ exit( exit_value ) ;
+}
+
+/* --------------------------------------------------------------------------- */
diff --git a/core/bgdrtm/src/strings.c b/core/bgdrtm/src/strings.c
new file mode 100644
index 0000000..f7d3641
--- /dev/null
+++ b/core/bgdrtm/src/strings.c
@@ -0,0 +1,1037 @@
+/*
+ * 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.
+ *
+ */
+
+/****************************************************************************/
+/* FILE : strings.c */
+/* DESCRIPTION : Strings management. Includes any function related to */
+/* variable-length strings. Those strings are allocated */
+/* in dynamic memory with reference counting. */
+/****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#ifdef TARGET_BEOS
+#include <posix/assert.h>
+#else
+#include <assert.h>
+#endif
+
+#include "files.h"
+#include "xctype.h"
+
+/****************************************************************************/
+
+#define BLOCK_INCR 1024
+
+#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)))
+
+/****************************************************************************/
+/* STATIC VARIABLES : */
+/****************************************************************************/
+
+/* Fixed string memory. The DCB fixed strings are stored here */
+static char * string_mem = NULL ;
+
+static int string_reserved = 0; /* Last fixed string */
+
+static char ** string_ptr = NULL ; /* Pointers to each string's text. Every string is allocated using strdup() or malloc().
+ A pointer of a unused slot is 0.
+ Exception: "fixed" strings are stored in a separate memory block and should not be freed */
+static uint32_t * string_uct = NULL ; /* Usage count for each string. An unused slot has a count of 0 */
+
+static uint32_t * string_bmp = NULL ; /* Bitmap for speed up string creation, and reused freed slots */
+
+static int string_allocated = 0 ; /* How many string slots are available in the ptr, uct and dontfree arrays */
+
+static int string_bmp_start = 0 ; /* Offset of assignable string for reused (32bits each one) */
+
+static int string_last_id = 1 ; /* How many strings slots are used. This is only the bigger id in use + 1.
+ There may be unused slots in this many positions */
+
+/* --------------------------------------------------------------------------- */
+
+void _string_ptoa( char *t, void * ptr )
+{
+ unsigned char c ;
+ int p = ( int ) ptr;
+
+ c = ((( p ) & 0xf0000000 ) >> 28 );
+ *t++ = ( c > 9 ? '7' : '0' ) + c; /* '7' + 10 = 'A' */
+
+ c = ((( p ) & 0x0f000000 ) >> 24 );
+ *t++ = ( c > 9 ? '7' : '0' ) + c; /* '7' + 10 = 'A' */
+
+ c = ((( p ) & 0x00f00000 ) >> 20 );
+ *t++ = ( c > 9 ? '7' : '0' ) + c; /* '7' + 10 = 'A' */
+
+ c = ((( p ) & 0x000f0000 ) >> 16 );
+ *t++ = ( c > 9 ? '7' : '0' ) + c; /* '7' + 10 = 'A' */
+
+ c = ((( p ) & 0x0000f000 ) >> 12 );
+ *t++ = ( c > 9 ? '7' : '0' ) + c; /* '7' + 10 = 'A' */
+
+ c = ((( p ) & 0x00000f00 ) >> 8 );
+ *t++ = ( c > 9 ? '7' : '0' ) + c; /* '7' + 10 = 'A' */
+
+ c = ((( p ) & 0x000000f0 ) >> 4 );
+ *t++ = ( c > 9 ? '7' : '0' ) + c; /* '7' + 10 = 'A' */
+
+ c = ( p ) & 0x0000000f;
+ *t++ = ( c > 9 ? '7' : '0' ) + c; /* '7' + 10 = 'A' */
+
+ *t = '\0';
+}
+
+/* --------------------------------------------------------------------------- */
+
+void _string_ntoa( char *p, unsigned long n )
+{
+ char * i = p ;
+
+ p += 10;
+ if (( long ) n < 0 )
+ {
+ * i++ = '-';
+ p++ ;
+ n = ( unsigned long )( -( long )n ) ;
+ }
+
+ * p = '\0';
+ do
+ {
+ * --p = '0' + ( n % 10 );
+ }
+ while ( n /= 10 ) ;
+
+ if ( p > i ) while (( *i++ = *p++ ) ) ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+void _string_utoa( char *p, unsigned long n )
+{
+ char * i = p ;
+
+ p += 10;
+
+ * p = '\0';
+ do
+ {
+ * --p = '0' + ( n % 10 );
+ }
+ while ( n /= 10 ) ;
+
+ if ( p > i ) while (( *i++ = *p++ ) ) ;
+}
+
+/* --------------------------------------------------------------------------- */
+
+/****************************************************************************/
+/* FUNCTION : string_alloc */
+/****************************************************************************/
+/* int bytes: how many new strings we could need */
+/****************************************************************************/
+/* Increase the size of the internal string arrays. This limits how many */
+/* strings you can have in memory at the same time, and this should be */
+/* called when every identifier slot available is already used. */
+/****************************************************************************/
+
+static void string_alloc( int count )
+{
+ int lim = ( string_allocated >> 5 ) ;
+
+ count = (( count >> 5 ) + 1 ) << 5 ;
+
+ string_allocated += count ;
+
+ string_ptr = ( char ** ) realloc( string_ptr, string_allocated * sizeof( char * ) ) ;
+ string_uct = ( uint32_t * ) realloc( string_uct, string_allocated * sizeof( uint32_t ) ) ;
+ string_bmp = ( uint32_t * ) realloc( string_bmp, ( string_allocated >> 5 ) * sizeof( uint32_t ) );
+
+ if ( !string_ptr || !string_uct || !string_bmp )
+ {
+ fprintf( stderr, "ERROR: Runtime error - string_alloc: out of memory\n" ) ;
+ exit( 0 );
+ }
+
+ memset( &string_bmp[ lim ], '\0', ( count >> 5 ) * sizeof ( uint32_t ) );
+}
+
+/****************************************************************************/
+/* FUNCTION : string_init */
+/****************************************************************************/
+/* Allocate memory for the dynamic arrays. You should call this function */
+/* before anything else in this file. There is enough space for about */
+/* BLOCK_INCR short strings, that should be enough for simple programs. */
+/* More space is allocated as needed. */
+/****************************************************************************/
+
+void string_init()
+{
+ string_alloc( BLOCK_INCR );
+
+ /* Create an empty string with ID 0 */
+
+ string_last_id = 0;
+ string_reserved = 0;
+ string_bmp_start = 0;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_dump */
+/****************************************************************************/
+/* Shows all the strings in memory in the console, including the reference */
+/* count (usage count) of each string. */
+/****************************************************************************/
+
+void string_dump( void ( *wlog )( const char *fmt, ... ) )
+{
+ int i ;
+ int used = 0;
+
+ if ( wlog )
+ wlog( "[STRING] ---- Dumping MaxID=%d strings ----\n", string_allocated ) ;
+ else
+ printf( "[STRING] ---- Dumping MaxID=%d strings ----\n", string_allocated ) ;
+
+ for ( i = 0; i < string_allocated; i++ )
+ {
+ if ( string_ptr[i] )
+ {
+ if ( !string_uct[i] )
+ {
+ if ( i >= string_reserved )
+ {
+ free( string_ptr[i] ) ;
+ string_ptr[i] = NULL ;
+ bit_clr( string_bmp, i );
+ }
+ continue ;
+ }
+ used++;
+ if ( wlog )
+ wlog( "[STRING] %4d [%4d]%s: {%s}\n", i, string_uct[i], ( i >= string_reserved ) ? "" : " STATIC", string_ptr[i] ) ;
+ else
+ printf( "[STRING] %4d [%4d]%s: {%s}\n", i, string_uct[i], ( i >= string_reserved ) ? "" : " STATIC", string_ptr[i] ) ;
+ }
+ else
+ {
+ continue ;
+ }
+ }
+ if ( wlog )
+ wlog( "[STRING] ---- Dumping Used=%d End ----\n", used ) ;
+ else
+ printf( "[STRING] ---- Dumping Used=%d End ----\n", used ) ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_get */
+/****************************************************************************/
+/* int code: identifier of the string you want */
+/****************************************************************************/
+/* Returns the contens of an string. Beware: this pointer with only be */
+/* valid while no other string function is called. */
+/****************************************************************************/
+
+const char * string_get( int code )
+{
+ assert( code < string_allocated && code >= 0 ) ;
+ return string_ptr[code] ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_load */
+/****************************************************************************/
+/* file * fp: the DCB file (must be opened) */
+/* */
+/* This function uses the global "dcb" struct. It should be already filled. */
+/****************************************************************************/
+/* Loads the string portion of a DCB file. This includes an area with all */
+/* the text (that will be stored in the string_mem pointer) and an array of */
+/* the offsets of every string. This function fills the internal arrayswith */
+/* all this data and allocates memory if needed. */
+/****************************************************************************/
+
+void string_load( void * fp, int ostroffs, int ostrdata, int nstrings, int totalsize )
+{
+ uint32_t * string_offset;
+ int n;
+
+ string_mem = malloc( totalsize );
+ assert( string_mem );
+
+ string_offset = ( uint32_t * ) malloc( sizeof( uint32_t ) * nstrings ) ;
+ assert( string_offset );
+
+ file_seek(( file * )fp, ostroffs, SEEK_SET ) ;
+ file_readUint32A(( file * )fp, string_offset, nstrings ) ;
+
+ if ( string_last_id + nstrings > string_allocated )
+ string_alloc((( string_last_id + nstrings - string_allocated ) / BLOCK_INCR + 1 ) * BLOCK_INCR ) ;
+
+ file_seek(( file * )fp, ostrdata, SEEK_SET ) ;
+ file_read(( file * )fp, string_mem, totalsize ) ;
+
+ for ( n = 0 ; n < nstrings ; n++ )
+ {
+ string_ptr[string_last_id + n] = string_mem + string_offset[n] ;
+ string_uct[string_last_id + n] = 0 ;
+ bit_set( string_bmp, string_last_id + n );
+ }
+
+ string_last_id += nstrings ;
+
+ string_last_id = ( string_last_id + 32 ) & ~0x1F;
+
+ string_reserved = string_last_id ;
+ string_bmp_start = string_last_id >> 5;
+
+ free( string_offset ) ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_use */
+/****************************************************************************/
+/* int code: identifier of the string you are using */
+/****************************************************************************/
+/* Increase the usage counter of an string. Use this when you store the */
+/* identifier of the string somewhere. */
+/****************************************************************************/
+
+void string_use( int code )
+{
+ string_uct[code]++ ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_discard */
+/****************************************************************************/
+/* int code: identifier of the string you don't need anymore */
+/****************************************************************************/
+/* Decrease the usage counter of an string. Use this when you retrieve the */
+/* identifier of the string and discard it, or some memory (like private */
+/* variables) containing the string identifier is destroyed. If the usage */
+/* count is decreased to zero, the string will be discarted, and the */
+/* identifier may be used in the future by other string. */
+/****************************************************************************/
+
+void string_discard( int code )
+{
+ if ( code < 0 || code > string_allocated || !string_ptr[code] ) return;
+
+ if ( !string_uct[code] ) return ;
+
+ string_uct[code]-- ;
+
+ if ( !string_uct[code] )
+ {
+ if ( code >= string_reserved )
+ {
+ free( string_ptr[code] ) ;
+ string_ptr[code] = NULL ;
+ bit_clr( string_bmp, code );
+ }
+ }
+}
+
+/****************************************************************************/
+/* FUNCTION : string_getid */
+/****************************************************************************/
+/* Searchs for an available ID and returns it. If none available, more space*/
+/* is allocated for the new string. This is used for new strings only. */
+/****************************************************************************/
+
+static int string_getid()
+{
+ int n, nb, lim, ini ;
+
+ /* Si tengo suficientes alocados, retorno el siguiente segun string_last_id */
+ if ( string_last_id < string_allocated )
+ {
+ if ( !bit_tst( string_bmp, string_last_id ) )
+ {
+ bit_set( string_bmp, string_last_id );
+ return string_last_id++ ;
+ }
+ }
+
+ /* Ya no tengo mas espacio, entonces busco alguno libre entre ~+32 desde el ultimo fijo y ~-32 del ultimo asignado */
+
+ ini = ( string_last_id < string_allocated ) ? ( string_last_id >> 5 ) : string_reserved ;
+ lim = ( string_allocated >> 5 ) ;
+
+ while ( 1 )
+ {
+ for ( n = ini; n < lim ; n++ )
+ {
+ if ( string_bmp[n] != ( uint32_t ) 0xFFFFFFFF ) /* Aca hay 1 libre, busco cual es */
+ {
+ for ( nb = 0; nb < 32; nb++ )
+ {
+ if ( !bit_tst( string_bmp + n, nb ) )
+ {
+ string_last_id = ( n << 5 ) + nb ;
+ bit_set( string_bmp, string_last_id );
+ return string_last_id++ ;
+ }
+ }
+ }
+ }
+ if ( ini == string_reserved ) break;
+ lim = ini;
+ ini = string_reserved;
+ }
+
+ string_last_id = string_allocated ;
+
+ /* Incremento espacio, no habia libres */
+ string_alloc( BLOCK_INCR ) ;
+
+ assert( !bit_tst( string_bmp, string_last_id ) );
+
+ /* Devuelvo string_last_id e incremento en 1, ya que ahora tengo BLOCK_INCR mas que antes */
+ bit_set( string_bmp, string_last_id );
+ return string_last_id++ ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_new */
+/****************************************************************************/
+/* Create a new string. It returns its ID. Note that it uses strdup() */
+/* TODO: do something if no memory available */
+/****************************************************************************/
+
+int string_new( const char * ptr )
+{
+ char * str = strdup( ptr ) ;
+ int id ;
+
+ assert( str ) ;
+
+ id = string_getid() ;
+
+ string_ptr[id] = str ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/*
+ * FUNCTION : string_newa
+ *
+ * Create a new string from a text buffer section
+ *
+ * PARAMS:
+ * ptr Pointer to the text buffer at start position
+ * count Number of characters
+ *
+ * RETURN VALUE:
+ * ID of the new string
+ */
+
+int string_newa( const char * ptr, unsigned count )
+{
+ char * str = malloc( count + 1 );
+ int id ;
+
+ assert( str ) ;
+ id = string_getid() ;
+
+ strncpy( str, ptr, count );
+ str[count] = '\0';
+ string_ptr[id] = str ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_concat */
+/****************************************************************************/
+/* Add some text to an string and return the resulting string. This does not*/
+/* modify the original string, but creates a new one. */
+/****************************************************************************/
+
+int string_concat( int code1, char * str2 )
+{
+ char * str1 ;
+ int len1, len2;
+
+ assert( code1 < string_allocated && code1 >= 0 ) ;
+
+ str1 = string_ptr[code1] ;
+ assert( str1 ) ;
+
+ len1 = strlen( str1 ) ;
+ len2 = strlen( str2 ) + 1 ;
+
+ str1 = ( char * ) realloc( str1, len1 + len2 ) ;
+ assert( str1 ) ;
+
+ memmove( str1 + len1, str2, len2 ) ;
+
+ string_ptr[code1] = str1 ;
+
+ return code1 ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_add */
+/****************************************************************************/
+/* Add an string to another one and return the resulting string. This does */
+/* not modify the original string, but creates a new one. */
+/****************************************************************************/
+
+int string_add( int code1, int code2 )
+{
+ const char * str1 = string_get( code1 ) ;
+ const char * str2 = string_get( code2 ) ;
+ char * str3 ;
+ int id ;
+ int len1, len2;
+
+ assert( str1 ) ;
+ assert( str2 ) ;
+
+ len1 = strlen( str1 ) ;
+ len2 = strlen( str2 ) + 1;
+
+ str3 = ( char * ) malloc( len1 + len2 ) ;
+ assert( str3 ) ;
+
+ memmove( str3, str1, len1 ) ;
+ memmove( str3 + len1, str2, len2 ) ;
+
+ id = string_getid() ;
+
+ string_ptr[id] = str3 ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_ptoa */
+/****************************************************************************/
+/* Convert a pointer to a new created string and return its ID. */
+/****************************************************************************/
+
+int string_ptoa( void * n )
+{
+ char * str ;
+ int id ;
+
+ str = ( char * ) malloc( 10 ) ;
+ assert( str ) ;
+
+ _string_ptoa( str, n ) ;
+
+ id = string_getid() ;
+ string_ptr[id] = str ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_ftoa */
+/****************************************************************************/
+/* Convert a float to a new created string and return its ID. */
+/****************************************************************************/
+
+int string_ftoa( float n )
+{
+ char * str = ( char * ) malloc( 32 ), * ptr = str;
+ int id ;
+
+ assert( str ) ;
+
+ ptr += sprintf( str, "%f", n ) - 1;
+
+ while ( ptr >= str )
+ {
+ if ( *ptr != '0' ) break ;
+ *ptr-- = 0 ;
+ }
+ if ( ptr >= str && *ptr == '.' ) *ptr = 0 ;
+ if ( *str == 0 )
+ {
+ *str = '0';
+ *( str + 1 ) = '\0';
+ }
+
+ id = string_getid() ;
+ string_ptr[id] = str ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_itoa */
+/****************************************************************************/
+/* Convert an integer to a new created string and return its ID. */
+/****************************************************************************/
+
+int string_itoa( int n )
+{
+ char * str ;
+ int id ;
+
+ str = ( char * ) malloc( 16 ) ;
+ assert( str ) ;
+
+ _string_ntoa( str, n ) ;
+
+ id = string_getid() ;
+ string_ptr[id] = str ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_uitoa */
+/****************************************************************************/
+/* Convert an unsigned integer to a new created string and return its ID. */
+/****************************************************************************/
+
+int string_uitoa( unsigned int n )
+{
+ char * str ;
+ int id ;
+
+ str = ( char * ) malloc( 16 ) ;
+ assert( str ) ;
+
+ _string_utoa( str, n ) ;
+
+ id = string_getid() ;
+ string_ptr[id] = str ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_comp */
+/****************************************************************************/
+/* Compare two strings using strcmp and return the result */
+/****************************************************************************/
+
+int string_comp( int code1, int code2 )
+{
+ const char * str1 = string_get( code1 ) ;
+ const char * str2 = string_get( code2 ) ;
+
+ return strcmp( str1, str2 ) ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_char */
+/****************************************************************************/
+/* Extract a character from a string. The parameter nchar can be: */
+/* - 0 or positive: return this character from the left (0 = leftmost) */
+/* - negative: return this character from the right (-1 = rightmost) */
+/* The result is not the ASCII value, but the identifier of a new string */
+/* that is create in the process and contains only the extracted character */
+/****************************************************************************/
+
+int string_char( int n, int nchar )
+{
+ const char * str = string_get( n ) ;
+
+ assert( str ) ;
+
+ if ( nchar < 0 )
+ {
+ nchar = strlen( str ) + nchar ;
+ if ( nchar < 0 ) return 0 ;
+ }
+
+ return str[nchar] ;
+}
+
+/****************************************************************************/
+/* FUNCTION : string_substr */
+/****************************************************************************/
+/* Extract a substring from a string. The parameters can be: */
+/* - 0 or positive: count this character from the left (0 = leftmost) */
+/* - negative: count this character from the right (-1 = rightmost) */
+/* */
+/* NO MORE: If first > last, the two values are swapped before returning the result */
+/****************************************************************************/
+
+int string_substr( int code, int first, int len )
+{
+ const char * str = string_get( code ) ;
+ char * ptr ;
+ int rlen, n ;
+
+ assert( str ) ;
+ rlen = strlen( str ) ;
+
+ if ( first < 0 )
+ {
+ first = rlen + first ;
+ if ( first < 0 ) return string_new( "" ) ;
+ }
+ else
+ if ( first > ( rlen - 1 ) ) return string_new( "" ) ;
+
+ if ( len < 0 )
+ {
+ len = rlen + ( len + 2 ) - first - 1 ;
+ if ( len < 1 ) return string_new( "" ) ;
+ }
+
+ if (( first + len ) > rlen ) len = ( rlen - first ) ;
+
+ ptr = ( char * )malloc( len + 1 ) ;
+ memcpy( ptr, str + first, len ) ;
+ ptr[len] = '\0' ;
+
+ n = string_getid() ;
+ string_ptr[n] = ptr ;
+ string_uct[n] = 0 ;
+
+ return n ;
+}
+
+/*
+ * FUNCTION : string_find
+ *
+ * Find a substring. Returns the position of the leftmost character (0
+ * for the leftmost position) or -1 if the string was not found.
+ *
+ * PARAMS:
+ * code1 Code of the string
+ * code2 Code of the substring
+ * first Character to start the search
+ * (negative to search backwards)
+ *
+ * RETURN VALUE:
+ * Result of the comparison
+ */
+
+int string_find( int code1, int code2, int first )
+{
+ char * str1 = ( char * ) string_get( code1 ) ;
+ char * str2 = ( char * ) string_get( code2 ) ;
+ char * p = str1, * p1, * p2 ;
+
+ assert( str1 && str2 ) ;
+
+ if ( first < 0 )
+ {
+ first += strlen( str1 ) ;
+ if ( first < 0 ) return -1;
+ str1 += first;
+ }
+ else
+ {
+ /* Avoid use strlen */
+ while ( first-- && *str1 ) str1++;
+ if ( !*str1 ) return -1;
+ }
+
+ while ( *str1 )
+ {
+ if ( *str1 == *str2 )
+ {
+ p1 = str1 + 1;
+ p2 = str2 + 1;
+
+ while ( *p1 && *p2 && *p1 == *p2 )
+ {
+ p1++;
+ p2++;
+ }
+ if ( !*p2 ) return str1 - p;
+ }
+ str1++;
+ }
+
+ return -1 ;
+}
+
+/*
+ * FUNCTION : string_ucase
+ *
+ * Convert an string to upper case. It does not alter the given string, but
+ * creates a new string in the correct case and returns its id.
+ *
+ * PARAMS:
+ * code Internal code of original string
+ *
+ * RETURN VALUE:
+ * Code of the resulting string
+ */
+
+int string_ucase( int code )
+{
+ const char * str = string_get( code ) ;
+ char * base, * ptr ;
+ int id ;
+
+ assert( str ) ;
+
+ base = ( char * )malloc( strlen( str ) + 1 ) ;
+ assert( base ) ;
+
+ for ( ptr = base; *str ; ptr++, str++ ) *ptr = TOUPPER( *str ) ;
+ ptr[0] = '\0' ;
+
+ id = string_getid() ;
+ string_ptr[id] = base ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/*
+ * FUNCTION : string_lcase
+ *
+ * Convert an string to lower case. It does not alter the given string, but
+ * creates a new string in the correct case and returns its id.
+ *
+ * PARAMS:
+ * code Internal code of original string
+ *
+ * RETURN VALUE:
+ * Code of the resulting string
+ */
+
+int string_lcase( int code )
+{
+ const char * str = string_get( code ) ;
+ char * base, * ptr ;
+ int id ;
+
+ assert( str ) ;
+
+ base = ( char * )malloc( strlen( str ) + 1 ) ;
+ assert( base ) ;
+
+ for ( ptr = base; *str ; ptr++, str++ ) *ptr = TOLOWER( *str ) ;
+ ptr[0] = '\0' ;
+
+ id = string_getid() ;
+ string_ptr[id] = base ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
+
+/*
+ * FUNCTION : string_strip
+ *
+ * Create a copy of a string, without any leading or ending blanks
+ *
+ * PARAMS:
+ * code Internal code of original string
+ *
+ * RETURN VALUE:
+ * Code of the resulting string
+ */
+
+int string_strip( int code )
+{
+ const char * str = string_get( code ) ;
+ char * base, * ptr;
+ int id = string_new( str );
+
+ ptr = base = ( char * )string_get( id ) ;
+
+ assert( ptr );
+
+ while ( *str == ' ' || *str == '\n' || *str == '\r' || *str == '\t' ) str++;
+ while ( *str ) *ptr++ = *str++;
+ while ( ptr > base && ( ptr[-1] == ' ' || ptr[-1] == '\n' || ptr[-1] == '\r' || ptr[-1] == '\t' ) ) ptr--;
+ *ptr = '\0';
+
+ return id ;
+}
+
+/*
+ * FUNCTION : string_format
+ *
+ * Format a number using the given characters
+ *
+ * PARAMS:
+ * number Number to format
+ * spec Format specification
+ *
+ * RETURN VALUE:
+ * Code of the resulting string
+ */
+
+int string_format( double number, int dec, char point, char thousands )
+{
+ char * str = malloc( 128 );
+ char * s = str, * t, * p = NULL;
+ int c, id, neg ;
+
+ assert( str );
+
+ if ( dec == -1 )
+ s += sprintf( str, "%f", number );
+ else
+ s += sprintf( str, "%.*f", dec, number );
+
+ neg = (*str == '-') ? 1 : 0;
+
+ if ( dec )
+ {
+ p = str;
+ while ( *p && *p != '.' ) p++;
+ if ( *p ) *p = point;
+ }
+ else
+ {
+ p = s;
+ }
+
+ /* p = where decimal point is */
+ /* s = where '\0' is */
+
+ if ( thousands )
+ t = s + (p - (str + neg) - 1 ) / 3;
+ else
+ t = s;
+
+ c = 0;
+ while ( s >= str )
+ {
+ if ( isdigit( *s ) && s < p )
+ {
+ if ( c == 3 )
+ {
+ *t-- = thousands ;
+ c = 0;
+ continue;
+ }
+ else
+ c++;
+ }
+ *t-- = *s-- ;
+ }
+
+ id = string_getid() ;
+
+ string_ptr[id] = str ;
+ string_uct[id] = 0 ;
+
+ return id;
+}
+
+/*
+ * FUNCTION : string_casecmp
+ *
+ * Compare two strings (case-insensitive version)
+ *
+ * PARAMS:
+ * code1 Code of the first string
+ * code2 Code of the second string
+ *
+ * RETURN VALUE:
+ * Result of the comparison
+ */
+
+int string_casecmp( int code1, int code2 )
+{
+ unsigned char * str1 = ( unsigned char * ) string_get( code1 ) ;
+ unsigned char * str2 = ( unsigned char * ) string_get( code2 ) ;
+
+ while ( *str1 || *str2 )
+ {
+ if ( TOUPPER( *str1 ) != TOUPPER( *str2 ) ) return TOUPPER( *str1 ) - TOUPPER( *str2 );
+
+ str1++;
+ str2++;
+ }
+
+ return 0 ;
+}
+
+/*
+ * FUNCTION : string_pad
+ *
+ * Add spaces to the left or right of a string
+ *
+ * PARAMS:
+ * code Code of the string
+ * total Total length of the final string
+ * align 0 = align to the right; 1 = align to the left
+ *
+ * RETURN VALUE:
+ * Result of the comparison
+ */
+
+int string_pad( int code, int total, int align )
+{
+ const char * ptr = string_get( code );
+
+ int len;
+ int spaces = 0;
+ int id;
+ char * str;
+
+ assert( ptr );
+ len = strlen( ptr );
+ if ( len < total ) spaces = total - len;
+
+ if ( !spaces ) return string_new( ptr ) ;
+
+ str = malloc( total + 1 );
+ assert( str );
+
+ if ( !align )
+ {
+ memset( str, ' ', spaces );
+ strcpy( str + spaces, ptr ) ;
+ }
+ else
+ {
+ strcpy( str, ptr ) ;
+ memset( str + len, ' ', spaces ) ;
+ str[total] = '\0';
+ }
+
+ id = string_getid() ;
+ string_ptr[id] = str ;
+ string_uct[id] = 0 ;
+
+ return id ;
+}
diff --git a/core/bgdrtm/src/sysprocs.c b/core/bgdrtm/src/sysprocs.c
new file mode 100644
index 0000000..97ebfbe
--- /dev/null
+++ b/core/bgdrtm/src/sysprocs.c
@@ -0,0 +1,577 @@
+/*
+ * 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 <loadlib.h> /* Must be fist include */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "bgdrtm.h"
+#include "dcb.h"
+#include "xstrings.h"
+
+#include <bgddl.h>
+
+/* ---------------------------------------------------------------------- */
+
+/* Debe existir un header bgdrtm.h */
+extern int bgd_copy_struct( INSTANCE * my, int * params ) ;
+extern int bgd_internal_memcopy( INSTANCE * my, int * params ) ;
+extern int bgd_internal_copy_string_array( INSTANCE * my, int * params ) ;
+
+#include "sysprocs.h"
+#include "sysprocs_p.h"
+
+/* ---------------------------------------------------------------------- */
+
+HOOK * handler_hook_list = NULL ;
+int handler_hook_allocated = 0 ;
+int handler_hook_count = 0 ;
+
+INSTANCE_HOOK * instance_create_hook_list = NULL ;
+int instance_create_hook_allocated = 0 ;
+int instance_create_hook_count = 0 ;
+
+INSTANCE_HOOK * instance_destroy_hook_list = NULL ;
+int instance_destroy_hook_allocated = 0 ;
+int instance_destroy_hook_count = 0 ;
+
+INSTANCE_HOOK * instance_pre_execute_hook_list = NULL ;
+int instance_pre_execute_hook_allocated = 0 ;
+int instance_pre_execute_hook_count = 0 ;
+
+INSTANCE_HOOK * instance_pos_execute_hook_list = NULL ;
+int instance_pos_execute_hook_allocated = 0 ;
+int instance_pos_execute_hook_count = 0 ;
+
+INSTANCE_HOOK * process_exec_hook_list = NULL ;
+int process_exec_hook_allocated = 0 ;
+int process_exec_hook_count = 0 ;
+
+FN_HOOK * module_initialize_list = NULL ;
+int module_initialize_allocated = 0 ;
+int module_initialize_count = 0 ;
+
+FN_HOOK * module_finalize_list = NULL ;
+int module_finalize_allocated = 0 ;
+int module_finalize_count = 0 ;
+
+/* ---------------------------------------------------------------------- */
+
+#define hook_add(new_hook, hook_list, hook_allocated, hook_count) \
+ { \
+ if ((hook_count) >= (hook_allocated)) { \
+ (hook_allocated) = (hook_count) + 5; \
+ (hook_list) = realloc (hook_list, (hook_allocated) * sizeof((hook_list)[0])); \
+ } \
+ \
+ if (!(hook_list)) { \
+ fprintf (stderr, "No memory for alloc hook\n"); \
+ exit(-1); \
+ } \
+ (hook_list)[hook_count] = (new_hook); \
+ (hook_count)++; \
+ }
+
+/* ---------------------------------------------------------------------- */
+
+static SYSPROC ** sysproc_tab = NULL ;
+
+/* ---------------------------------------------------------------------- */
+
+static int tsize( DCB_TYPEDEF orig );
+static DCB_TYPEDEF treduce( DCB_TYPEDEF orig );
+
+/* ---------------------------------------------------------------------- */
+
+/* Tipos de token */
+static struct
+{
+ enum { NOTOKEN, IDENTIFIER, NUMBER } type ;
+ char name[128] ;
+ int code ;
+} token ;
+
+static const char * token_ptr = NULL;
+
+/* ---------------------------------------------------------------------- */
+
+/* Very simple tokenizer */
+
+static void get_token()
+{
+ char * ptr ;
+ unsigned int n ;
+
+ while ( isspace( *token_ptr ) ) token_ptr++ ;
+
+ if ( !*token_ptr )
+ {
+ token.type = NOTOKEN ;
+ return ;
+ }
+
+ /* Numbers */
+
+ if ( ISNUM( *token_ptr ) )
+ {
+ int num = 0 ;
+
+ /* Calculate the number value */
+
+ while ( ISNUM( *token_ptr ) ) num = num * 10 + ( *token_ptr++ - '0' ) ;
+ token.type = NUMBER ;
+ token.code = num ;
+ snprintf( token.name, sizeof( token.name ), "%d", token.code ) ;
+ return ;
+ }
+
+ ptr = token.name ;
+ *ptr++ = TOUPPER( *token_ptr ) ;
+ if ( ISWORDCHAR( *token_ptr++ ) )
+ while ( ISWORDCHAR( *token_ptr ) ) *ptr++ = TOUPPER( *token_ptr++ ) ;
+ *ptr = 0 ;
+
+ for ( n = 0; n < dcb.data.NID; n++ )
+ {
+ if ( strcmp( (const char *)dcb.id[n].Name, token.name ) == 0 )
+ {
+ token.type = IDENTIFIER ;
+ token.code = dcb.id[n].Code ;
+ strcpy( token.name, (char *)dcb.id[n].Name ) ;
+ return ;
+ }
+ }
+
+ token.type = NOTOKEN ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+static DCB_TYPEDEF treduce( DCB_TYPEDEF orig )
+{
+ int n ;
+ for ( n = 0; n < MAX_TYPECHUNKS - 1; n++ )
+ {
+ orig.BaseType[n] = orig.BaseType[n+1] ;
+ orig.Count[n] = orig.Count[n+1] ;
+ }
+ return orig ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+static int tsize( DCB_TYPEDEF orig )
+{
+ unsigned int n, total ;
+
+ switch ( orig.BaseType[0] )
+ {
+ case TYPE_ARRAY:
+ return orig.Count[0] * tsize( treduce( orig ) ) ;
+
+ case TYPE_POINTER:
+ case TYPE_STRING:
+ case TYPE_DWORD:
+ case TYPE_FLOAT:
+ case TYPE_INT:
+ return 4 ;
+
+ case TYPE_WORD:
+ case TYPE_SHORT:
+ return 2 ;
+
+ case TYPE_BYTE:
+ case TYPE_SBYTE:
+ case TYPE_CHAR:
+ return 1 ;
+
+ case TYPE_STRUCT:
+ total = 0 ;
+ for ( n = 0; n < dcb.varspace[orig.Members].NVars; n++ )
+ total += tsize( dcb.varspace_vars[orig.Members][n].Type ) ;
+ return total ;
+
+ default:
+ return 0 ;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+static void get_var_info( DLVARFIXUP * varfixup, DCB_VAR * basevar, int nvars, char * basedata )
+{
+ unsigned int n ;
+ DCB_VAR rvar ;
+ void * rdata = NULL ;
+
+ token_ptr = varfixup->var ;
+
+ /* for Error */
+ varfixup->data_offset = NULL;
+ varfixup->size = -1;
+ varfixup->elements = -1;
+
+ get_token() ;
+ if ( token.type != IDENTIFIER ) return ; /* Not a valid expression */
+
+ /* Busca variable */
+ for ( n = 0; n < nvars; n++ )
+ {
+ if ( basevar[n].ID == token.code )
+ {
+ rvar = basevar[n] ;
+ rdata = ( uint8_t* )basedata + basevar[n].Offset ;
+
+ get_token() ;
+ break;
+ }
+ }
+
+ if ( n == nvars ) return ; /* Error, no es variable */
+
+ for ( ;; )
+ {
+ if ( token.name[0] == '.' )
+ {
+ DCB_VARSPACE * v ;
+ DCB_VAR * var ;
+
+ if ( rvar.Type.BaseType[0] != TYPE_STRUCT ) return ; /* not an struct */
+
+ get_token() ;
+ if ( token.type != IDENTIFIER ) return ; /* not a member */
+
+ v = &dcb.varspace[rvar.Type.Members] ;
+ var = dcb.varspace_vars[rvar.Type.Members] ;
+ for ( n = 0; n < v->NVars; n++ ) if ( var[n].ID == token.code ) break ;
+
+ if ( n == v->NVars ) return ; /* not a member */
+
+ rvar = var[n] ;
+ rdata = ((uint8_t *)rdata) + var[n].Offset ;
+
+ get_token() ;
+ continue ;
+ }
+
+ if ( token.name[0] == '[' )
+ {
+ int index;
+
+ if ( rvar.Type.BaseType[0] != TYPE_ARRAY ) return ; /* not an array */
+
+ get_token() ;
+ if ( token.type != NUMBER ) return ; /* not an integer */
+ index = token.code;
+
+ if ( index < 0 ) return ; /* Index less than zero */
+ if ( index >= rvar.Type.Count[0] ) return ; /* Index out of bounds */
+
+ rvar.Type = treduce( rvar.Type ) ;
+ rdata = ((uint8_t *) rdata ) + index * tsize( rvar.Type ) ;
+
+ get_token() ;
+ if ( token.name[0] == ']' ) get_token() ; /* Skip ] */
+
+ continue ;
+ }
+
+ varfixup->data_offset = ( void * ) rdata;
+ varfixup->elements = rvar.Type.BaseType[0] == TYPE_ARRAY ? rvar.Type.Count[0] : 1;
+ varfixup->size = tsize( rvar.Type ) / varfixup->elements;
+/*
+ printf ("varfixup: %p var: %s offset: %p elements: %d size: %d\n", varfixup, varfixup->var, varfixup->data_offset, varfixup->elements, varfixup->size);
+*/
+ break ;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+int compare_priority( const HOOK * a1, const HOOK * a2 )
+{
+ return ( a2->prio - a1->prio ) ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+int sysproc_add( char * name, char * paramtypes, int type, void * func )
+{
+ static SYSPROC * sysproc_new = 0 ;
+ static int sysproc_count = 0 ;
+
+ if ( !sysproc_new )
+ {
+ sysproc_new = sysprocs ;
+ while ( sysproc_new->name )
+ {
+ sysproc_new++ ;
+ sysproc_count++ ;
+ }
+ }
+
+ if ( sysproc_count >= MAX_SYSPROCS )
+ {
+ fprintf( stderr, "ERROR: Runtime error - too many system functions\n" ) ;
+ return -1;
+ }
+
+ sysproc_new->code = -1 ; /* Se llena en el fixup */
+ sysproc_new->name = name ;
+ sysproc_new->paramtypes = paramtypes ;
+ sysproc_new->params = strlen( paramtypes ) ;
+ sysproc_new->type = type ;
+ sysproc_new->func = ( SYSFUNC * ) func ;
+ sysproc_new->id = getid( name ) ;
+
+ sysproc_new++ ;
+ sysproc_count++ ;
+
+ sysproc_new->func = NULL ;
+
+ return 0 /*sysproc_new->code*/ ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+SYSPROC * sysproc_get( int code )
+{
+ return sysproc_tab[code] ;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void sysproc_add_tab( DLSYSFUNCS * functions_exports )
+{
+ if ( functions_exports )
+ {
+ while ( functions_exports->name )
+ {
+ sysproc_add( functions_exports->name, functions_exports->paramtypes, functions_exports->type, functions_exports->func );
+ functions_exports++;
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+static char * dlsearchpath[] =
+{
+ "modules",
+ "mod",
+ "mods",
+ "extensions",
+ "plugins",
+ "data",
+ NULL
+};
+
+/* ---------------------------------------------------------------------- */
+
+void sysproc_init()
+{
+ SYSPROC * proc = sysprocs ;
+ void * library = NULL ;
+ const char * filename ;
+ unsigned int n ;
+
+ DLVARFIXUP * globals_fixup = NULL ;
+ DLVARFIXUP * locals_fixup = NULL ;
+ DLSYSFUNCS * functions_exports = NULL ;
+ FN_HOOK module_initialize ;
+ FN_HOOK module_finalize ;
+ INSTANCE_HOOK instance_create_hook ;
+ INSTANCE_HOOK instance_destroy_hook ;
+ INSTANCE_HOOK instance_pre_execute_hook ;
+ INSTANCE_HOOK instance_pos_execute_hook ;
+ INSTANCE_HOOK process_exec_hook ;
+ HOOK * handler_hooks = NULL ;
+
+ int maxcode = 0 ;
+
+ char soname[ __MAX_PATH ], fullsoname[ __MAX_PATH ], **spath ;
+
+#if defined( WIN32 )
+#define DLLEXT ".dll"
+#elif defined(TARGET_MAC)
+#define DLLEXT ".dylib"
+#else
+#define DLLEXT ".so"
+#endif
+
+ for ( n = 0; n < dcb.data.NImports; n++ )
+ {
+ filename = string_get( dcb.imports[n] ) ;
+
+ snprintf( soname, __MAX_PATH, "%s" DLLEXT, filename );
+
+ filename = soname ;
+
+ /* Load library */
+
+ if ( debug ) printf ("Loading... %s\n", filename );
+
+ fullsoname[0] = '\0';
+
+ library = NULL;
+
+ spath = dlsearchpath;
+ while( !library && spath && *spath )
+ {
+ sprintf( fullsoname, "%s%s/%s", appexepath, *spath, filename );
+ library = dlibopen( fullsoname ) ;
+ spath++;
+ }
+
+ if ( !library ) library = dlibopen( filename ) ;
+
+ if ( !library )
+ {
+ printf( dliberror() ) ;
+ exit( 0 );
+ }
+
+ globals_fixup = ( DLVARFIXUP * ) _dlibaddr( library, "globals_fixup" ) ;
+ locals_fixup = ( DLVARFIXUP * ) _dlibaddr( library, "locals_fixup" ) ;
+ functions_exports = ( DLSYSFUNCS * ) _dlibaddr( library, "functions_exports" ) ;
+
+ module_initialize = ( FN_HOOK ) _dlibaddr( library, "module_initialize" ) ;
+ module_finalize = ( FN_HOOK ) _dlibaddr( library, "module_finalize" ) ;
+
+ instance_create_hook = ( INSTANCE_HOOK ) _dlibaddr( library, "instance_create_hook" ) ;
+ instance_destroy_hook = ( INSTANCE_HOOK ) _dlibaddr( library, "instance_destroy_hook" ) ;
+ instance_pre_execute_hook = ( INSTANCE_HOOK ) _dlibaddr( library, "instance_pre_execute_hook" ) ;
+ instance_pos_execute_hook = ( INSTANCE_HOOK ) _dlibaddr( library, "instance_pos_execute_hook" ) ;
+ process_exec_hook = ( INSTANCE_HOOK ) _dlibaddr( library, "process_exec_hook" ) ;
+
+ handler_hooks = ( HOOK * ) _dlibaddr( library, "handler_hooks" ) ;
+
+ /* Fixups */
+
+ if ( globals_fixup )
+ {
+ while ( globals_fixup->var )
+ {
+ get_var_info( globals_fixup, dcb.glovar, dcb.data.NGloVars, globaldata );
+ globals_fixup++;
+ }
+ }
+
+ if ( locals_fixup )
+ {
+ while ( locals_fixup->var )
+ {
+ get_var_info( locals_fixup, dcb.locvar, dcb.data.NLocVars, NULL );
+ locals_fixup++;
+ }
+ }
+
+ sysproc_add_tab( functions_exports ) ;
+
+ if ( module_initialize )
+ hook_add( module_initialize, module_initialize_list, module_initialize_allocated, module_initialize_count ) ;
+
+ if ( module_finalize )
+ hook_add( module_finalize, module_finalize_list, module_finalize_allocated, module_finalize_count ) ;
+
+ if ( instance_create_hook )
+ hook_add( instance_create_hook, instance_create_hook_list, instance_create_hook_allocated, instance_create_hook_count ) ;
+
+ if ( instance_destroy_hook )
+ hook_add( instance_destroy_hook, instance_destroy_hook_list, instance_destroy_hook_allocated, instance_destroy_hook_count ) ;
+
+ if ( instance_pre_execute_hook )
+ hook_add( instance_pre_execute_hook, instance_pre_execute_hook_list, instance_pre_execute_hook_allocated, instance_pre_execute_hook_count ) ;
+
+ if ( instance_pos_execute_hook )
+ hook_add( instance_pos_execute_hook, instance_pos_execute_hook_list, instance_pos_execute_hook_allocated, instance_pos_execute_hook_count ) ;
+
+ if ( process_exec_hook )
+ hook_add( process_exec_hook, process_exec_hook_list, process_exec_hook_allocated, process_exec_hook_count ) ;
+
+ while ( handler_hooks && handler_hooks->hook )
+ {
+ hook_add( *handler_hooks, handler_hook_list, handler_hook_allocated, handler_hook_count ) ;
+ handler_hooks++;
+ }
+ }
+
+ if ( debug ) printf ("\n");
+
+ /* System Procs FixUp */
+
+ sysprocs_fixup();
+
+ proc = sysprocs ;
+ while ( proc->func )
+ {
+ if ( maxcode < proc->code ) maxcode = proc->code ;
+ proc++ ;
+ }
+
+ sysproc_tab = calloc( maxcode + 1 , sizeof( SYSPROC * ) );
+
+ proc = sysprocs ;
+ while ( proc->func )
+ {
+ if ( proc->code > -1 ) sysproc_tab[proc->code] = proc ;
+ proc++ ;
+ }
+
+ /* Sort handler_hooks */
+ if ( handler_hook_list )
+ qsort( handler_hook_list, handler_hook_count, sizeof( handler_hook_list[0] ), ( int ( * )( const void *, const void * ) ) compare_priority ) ;
+
+ /* Initialize all modules */
+ if ( module_initialize_count )
+ for ( n = 0; n < module_initialize_count; n++ )
+ module_initialize_list[n]();
+}
+
+/* ---------------------------------------------------------------------- */
+
+extern DCB_SYSPROC_CODE2 * sysproc_code_ref ;
+
+/* ---------------------------------------------------------------------- */
+
+char * sysproc_name( int code )
+{
+ DCB_SYSPROC_CODE2 * s = NULL ;
+ int n;
+
+ s = sysproc_code_ref ;
+ for ( n = 0; n < dcb.data.NSysProcsCodes; n++, s++ )
+ if ( s->Code == code ) return getid_name( s->Id ) ;
+
+ return NULL ;
+}
+
+/* ---------------------------------------------------------------------- */
diff --git a/core/bgdrtm/src/varspace_file.c b/core/bgdrtm/src/varspace_file.c
new file mode 100644
index 0000000..97f2e4c
--- /dev/null
+++ b/core/bgdrtm/src/varspace_file.c
@@ -0,0 +1,357 @@
+/*
+ * 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 <stdint.h>
+
+#include "files.h"
+#include "varspace_file.h"
+#include "xstrings.h"
+
+/* ----------------------------------------------------------------- */
+/*
+ * FUNCTION : loadvars
+ *
+ * Load data from memory to a given file at the current file offset,
+ * using a varspace's type information
+ *
+ * PARAMS :
+ * fp Pointer to the file object
+ * data Pointer to the data
+ * var Pointer to the type array
+ * nvars Number of variables (length of var array)
+ *
+ * RETURN VALUE :
+ * Number of bytes actually read
+ *
+ */
+
+int loadvars( file * fp, void * data, DCB_VAR * var, int nvars, int dcbformat )
+{
+ int result = 0;
+ int partial;
+
+ for ( ; nvars > 0; nvars--, var++ )
+ {
+ partial = loadtype( fp, data, &var->Type, dcbformat );
+ data = ( uint8_t* )data + partial;
+ result += partial;
+ }
+ return result;
+}
+
+
+/*
+ * FUNCTION : loadtypes
+ *
+ * Load data from memory to a given file at the current file offset,
+ * using type information stored in memory
+ *
+ * PARAMS :
+ * fp Pointer to the file object
+ * data Pointer to the data
+ * var Pointer to the type array
+ * nvars Number of variables (length of var array)
+ *
+ * RETURN VALUE :
+ * Number of bytes actually read
+ *
+ */
+
+int loadtypes( file * fp, void * data, DCB_TYPEDEF * var, int nvars, int dcbformat )
+{
+ int result = 0;
+ int partial;
+
+ for ( ; nvars > 0; nvars--, var++ )
+ {
+ partial = loadtype( fp, data, var, dcbformat );
+ data = (( uint8_t* )data ) + partial;
+ result += partial;
+ }
+ return result;
+}
+
+/*
+ * FUNCTION : savevars
+ *
+ * Save data from memory to a given file at the current file offset,
+ * using a varspace's type information
+ *
+ * PARAMS :
+ * fp Pointer to the file object
+ * data Pointer to the data
+ * var Pointer to the type array
+ * nvars Number of variables (length of var array)
+ *
+ * RETURN VALUE :
+ * Number of bytes actually written
+ *
+ */
+
+int savevars( file * fp, void * data, DCB_VAR * var, int nvars, int dcbformat )
+{
+ int result = 0;
+ int partial;
+
+ for ( ; nvars > 0; nvars--, var++ )
+ {
+ partial = savetype( fp, data, &var->Type, dcbformat );
+ data = (( uint8_t* ) data ) + partial;
+ result += partial;
+ }
+ return result;
+}
+
+
+/*
+ * FUNCTION : savetypes
+ *
+ * Save data from memory to a given file at the current file offset,
+ * using type information stored in memory
+ *
+ * PARAMS :
+ * fp Pointer to the file object
+ * data Pointer to the data
+ * var Pointer to the type array
+ * nvars Number of variables (length of var array)
+ *
+ * RETURN VALUE :
+ * Number of bytes actually written
+ *
+ */
+
+int savetypes( file * fp, void * data, DCB_TYPEDEF * var, int nvars, int dcbformat )
+{
+ int result = 0;
+ int partial;
+
+ for ( ; nvars > 0; nvars--, var++ )
+ {
+ partial = savetype( fp, data, var, dcbformat );
+ result += partial;
+ data = (( uint8_t* )data ) + partial;
+ }
+ return result;
+}
+
+/*
+ * FUNCTION : savetype
+ *
+ * Save one variable from memory to a given file at the current file offset,
+ * using the given type information. This is a convenience function
+ * used by both savevars and savetypes.
+ *
+ * PARAMS :
+ * fp Pointer to the file object
+ * data Pointer to the data
+ * var Pointer to the variable type
+ *
+ * RETURN VALUE :
+ * Number of bytes actually written
+ *
+ */
+
+int savetype( file * fp, void * data, DCB_TYPEDEF * var, int dcbformat )
+{
+ int n = 0;
+ int count = 1;
+ int result = 0;
+ const char * str;
+ int32_t len;
+ int partial;
+
+ for ( ;; )
+ {
+ switch ( var->BaseType[n] )
+ {
+ case TYPE_FLOAT:
+ case TYPE_INT:
+ case TYPE_DWORD:
+ case TYPE_POINTER:
+ result += file_writeUint32A( fp, data, count ) * sizeof( uint32_t );
+ break;
+
+ case TYPE_SHORT:
+ case TYPE_WORD:
+ result += file_writeUint16A( fp, data, count ) * sizeof( uint16_t );
+ break;
+
+ case TYPE_BYTE:
+ case TYPE_SBYTE:
+ case TYPE_CHAR:
+ result += file_write( fp, data, count );
+ break;
+
+ case TYPE_STRING:
+ if ( dcbformat )
+ {
+ result += file_writeUint32A( fp, data, count ) * sizeof( uint32_t );
+ }
+ else
+ {
+ for ( ; count ; count-- )
+ {
+ str = string_get( *( uint32_t * )data );
+ len = strlen( str );
+ file_writeUint32( fp, (uint32_t *)&len );
+ file_write( fp, ( void* )str, len );
+ data = ( uint8_t* )data + sizeof( uint32_t );
+ result += sizeof( uint32_t );
+ }
+ }
+ break;
+
+ case TYPE_ARRAY:
+ count *= var->Count[n];
+ n++;
+ continue;
+
+ case TYPE_STRUCT:
+ for ( ; count ; count-- )
+ {
+ partial = savevars( fp, data, dcb.varspace_vars[var->Members], dcb.varspace[var->Members].NVars, dcbformat );
+ data = (( uint8_t* )data ) + partial;
+ result += partial;
+ }
+ break;
+
+ default:
+ /* Can't be possible save this struct */
+ return -1;
+ break;
+ }
+ break;
+ }
+ return result;
+}
+
+/*
+ * FUNCTION : loadtype
+ *
+ * Load one variable from a given file at the current file offset,
+ * using the given type information. This is a convenience function
+ * used by both loadvars and loadtypes.
+ *
+ * PARAMS :
+ * fp Pointer to the file object
+ * data Pointer to the data
+ * var Pointer to the variable type
+ *
+ * RETURN VALUE :
+ * Number of bytes actually written
+ *
+ */
+
+int loadtype( file * fp, void * data, DCB_TYPEDEF * var, int dcbformat )
+{
+ int n = 0;
+ int count = 1;
+ int result = 0;
+ char * str;
+ int len;
+ int partial;
+
+ for ( ;; )
+ {
+ switch ( var->BaseType[n] )
+ {
+ /* Not sure about float types */
+ case TYPE_FLOAT:
+ case TYPE_INT:
+ case TYPE_DWORD:
+ case TYPE_POINTER:
+ result += file_readUint32A( fp, data, count ) * sizeof( uint32_t );
+ break;
+
+ case TYPE_SHORT:
+ case TYPE_WORD:
+ result += file_readUint16A( fp, data, count ) * sizeof( uint16_t );
+ break;
+
+ case TYPE_SBYTE:
+ case TYPE_BYTE:
+ case TYPE_CHAR:
+ result += file_read( fp, data, count );
+ break;
+
+ case TYPE_STRING:
+ if ( dcbformat )
+ {
+ result += file_readUint32A( fp, data, count ) * sizeof( uint32_t );
+ }
+ else
+ {
+ for ( ; count ; count-- )
+ {
+ string_discard( *( uint32_t* )data );
+ file_readUint32( fp, (uint32_t *)&len );
+ str = malloc( len + 1 );
+ if ( !str )
+ {
+ fprintf( stderr, "loadtype: out of memory\n" ) ;
+ return -1;
+ }
+
+ if ( len > 0 ) file_read( fp, str, len );
+ str[len] = 0;
+ *( uint32_t* )data = string_new( str );
+ string_use( *( uint32_t* )data );
+ free( str );
+ data = ( uint8_t* )data + sizeof( uint32_t );
+ result += sizeof( uint32_t );
+ }
+ }
+ break;
+
+ case TYPE_ARRAY:
+ count *= var->Count[n];
+ n++;
+ continue;
+
+ case TYPE_STRUCT:
+ for ( ; count ; count-- )
+ {
+ partial = loadvars( fp, data, dcb.varspace_vars[var->Members], dcb.varspace[var->Members].NVars, dcbformat );
+ result += partial;
+ data = ( uint8_t* )data + partial;
+ }
+ break;
+
+ default:
+ /* Can't be possible load this struct */
+ return -1;
+ break;
+ }
+ break;
+ }
+ return result;
+}