Browse Source

initial import

git-svn-id: trunk@4127 -
Legolas 19 years ago
parent
commit
e3a85257be

+ 25 - 0
.gitattributes

@@ -2105,6 +2105,31 @@ packages/extra/fpgtk/pgtk/pgtk.pp svneol=native#text/plain
 packages/extra/fpgtk/pgtk/pgtk.ppr -text
 packages/extra/fpmake.inc svneol=native#text/plain
 packages/extra/fpmake.pp svneol=native#text/plain
+packages/extra/gbaunits/Makefile -text
+packages/extra/gbaunits/Makefile.fpc -text
+packages/extra/gbaunits/bios_asm.as -text
+packages/extra/gbaunits/core_asm.as -text
+packages/extra/gbaunits/def.inc -text
+packages/extra/gbaunits/fpmake.inc -text
+packages/extra/gbaunits/fpmake.pp -text
+packages/extra/gbaunits/gba_bg.pas -text
+packages/extra/gbaunits/gba_bios.pas -text
+packages/extra/gbaunits/gba_blend.pas -text
+packages/extra/gbaunits/gba_core.pas -text
+packages/extra/gbaunits/gba_dma.pas -text
+packages/extra/gbaunits/gba_fade.pas -text
+packages/extra/gbaunits/gba_input.pas -text
+packages/extra/gbaunits/gba_irq.pas -text
+packages/extra/gbaunits/gba_mosaic.pas -text
+packages/extra/gbaunits/gba_regs.pas -text
+packages/extra/gbaunits/gba_sio.pas -text
+packages/extra/gbaunits/gba_sprites.pas -text
+packages/extra/gbaunits/gba_timer.pas -text
+packages/extra/gbaunits/gba_types.pas -text
+packages/extra/gbaunits/gba_video.pas -text
+packages/extra/gbaunits/gba_window.pas -text
+packages/extra/gbaunits/lgpl.txt -text
+packages/extra/gbaunits/libGBA4fpc.txt -text
 packages/extra/gdbm/Makefile svneol=native#text/plain
 packages/extra/gdbm/Makefile.fpc svneol=native#text/plain
 packages/extra/gdbm/README -text

+ 1 - 0
.gitignore

@@ -1072,6 +1072,7 @@ packages/extra/fpgtk/pgtk/*.s
 packages/extra/fpgtk/pgtk/fpcmade.*
 packages/extra/fpgtk/pgtk/units
 packages/extra/fpgtk/units
+packages/extra/gbaunits/*.bat
 packages/extra/gdbm/*.bak
 packages/extra/gdbm/*.exe
 packages/extra/gdbm/*.o

+ 1957 - 0
packages/extra/gbaunits/Makefile

@@ -0,0 +1,1957 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/06/02]
+#
+default: all
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-macos powerpc-darwin powerpc-morphos powerpc-gamecube sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux
+BSDs = freebsd netbsd openbsd darwin
+UNIXs = linux $(BSDs) solaris qnx
+LIMIT83fs = go32v2 os2 emx watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+endif
+override OS_TARGET_DEFAULT=gba
+override CPU_TARGET_DEFAULT=arm
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifneq ($(words $(FPC_COMPILERINFO)),5)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSO)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTO)
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=gbaunits
+override PACKAGE_VERSION=0.1.4
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),powerpc-gamecube)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_UNITS+=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+endif
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),powerpc-gamecube)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_LOADERS+=bios_asm core_asm
+endif
+override INSTALL_FPCPACKAGE=y
+ifeq ($(FULL_TARGET),i386-linux)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),powerpc-gamecube)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override COMPILER_OPTIONS+=-CX
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override COMPILER_OPTIONS+=-CX
+endif
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+ifeq ($(OS_TARGET),darwin)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+else
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.sl2
+STATICLIBPREFIX=
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppu
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_ECHO
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE= __missing_command_DATE
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL= __missing_command_GINSTALL
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),win32)
+ifeq ($(CROSSBINDIR),)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+endif
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(SRCBATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(CPU_TARGET)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX) -Xc
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O2
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef CREATESHARED
+override FPCOPT+=-Cg
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-Aas
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_loaders
+ifneq ($(TARGET_LOADERS),)
+override ALLTARGET+=fpc_loaders
+override CLEANTARGET+=fpc_loaders_clean
+override INSTALLTARGET+=fpc_loaders_install
+override LOADEROFILES:=$(addsuffix $(OEXT),$(TARGET_LOADERS))
+endif
+%$(OEXT): %$(LOADEREXT)
+ifdef COMPILER_UNITTARGETDIR
+	$(AS) -o $(COMPILER_UNITTARGETDIR)/$*$(OEXT) $<
+else
+	$(AS) -o $*$(OEXT) $<
+endif
+fpc_loaders: $(COMPILER_UNITTARGETDIR) $(LOADEROFILES)
+fpc_loaders_clean:
+ifdef COMPILER_UNITTARGETDIR
+	-$(DEL) $(addprefix $(COMPILER_UNITTARGETDIR)/,$(LOADEROFILES))
+else
+	-$(DEL) $(LOADEROFILES)
+endif
+fpc_loaders_install:
+	$(MKDIR) $(INSTALL_UNITDIR)
+ifdef COMPILER_UNITTARGETDIR
+	$(INSTALL) $(addprefix $(COMPILER_UNITTARGETDIR)/,$(LOADEROFILES)) $(INSTALL_UNITDIR)
+else
+	$(INSTALL) $(LOADEROFILES) $(INSTALL_UNITDIR)
+endif
+.PHONY: fpc_units
+ifneq ($(TARGET_UNITS),)
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared
+$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res
+$(COMPILER_UNITTARGETDIR):
+	$(MKDIRTREE) $(COMPILER_UNITTARGETDIR)
+$(COMPILER_TARGETDIR):
+	$(MKDIRTREE) $(COMPILER_TARGETDIR)
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.lpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.dpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_shared
+override INSTALLTARGET+=fpc_shared_install
+ifndef SHARED_LIBVERSION
+SHARED_LIBVERSION=$(FPC_VERSION)
+endif
+ifndef SHARED_LIBNAME
+SHARED_LIBNAME=$(PACKAGE_NAME)
+endif
+ifndef SHARED_FULLNAME
+SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT)
+endif
+ifndef SHARED_LIBUNITS
+SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS)
+override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS))
+endif
+fpc_shared:
+ifdef HASSHAREDLIB
+	$(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1
+ifneq ($(SHARED_BUILD),n)
+	$(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
+fpc_shared_install:
+ifneq ($(SHARED_BUILD),n)
+ifneq ($(SHARED_LIBUNITS),)
+ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),)
+	$(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR)
+endif
+endif
+endif
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+ifneq ($(UNITTARGETDIRPREFIX),)
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES)))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES))))
+endif
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+ifneq ($(TARGETDIRPREFIX),)
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES)))
+endif
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(PACKAGE_NAME)
+endif
+endif
+ifndef FULLZIPNAME
+FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX)
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(SRCBATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX)
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX)
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+fpc_distclean: cleanall
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+units: fpc_units
+examples:
+shared: fpc_shared
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif
+core_asm$(OEXT):core_asm.as
+	$(AS) -o $(UNITTARGETDIRPREFIX)core_asm$(OEXT) core_asm.as
+bios_asm$(OEXT):bios_asm.as
+	$(AS) -o $(UNITTARGETDIRPREFIX)bios_asm$(OEXT) bios_asm.as

+ 34 - 0
packages/extra/gbaunits/Makefile.fpc

@@ -0,0 +1,34 @@
+#
+#   Makefile.fpc for gba units
+#
+
+[package]
+name=gbaunits
+version=0.1.4
+
+[target]
+loaders=bios_asm core_asm
+units=gba_bg gba_blend gba_core gba_dma gba_irq gba_sio gba_mosaic gba_regs \
+gba_sprites gba_timer gba_types gba_video gba_window gba_bios gba_input gba_fade
+examples=
+
+[compiler]
+options=-CX
+
+[install]
+fpcpackage=y
+#prefix=d:/fpc4gba
+
+[default]
+cpu=arm
+target=gba
+fpcdir=../../..
+
+[require]
+nortl=y
+
+[rules]
+core_asm$(OEXT):core_asm.as
+        $(AS) -o $(UNITTARGETDIRPREFIX)core_asm$(OEXT) core_asm.as
+bios_asm$(OEXT):bios_asm.as
+        $(AS) -o $(UNITTARGETDIRPREFIX)bios_asm$(OEXT) bios_asm.as

+ 329 - 0
packages/extra/gbaunits/bios_asm.as

@@ -0,0 +1,329 @@
+@ 00h
+@ extern void SoftReset(void);
+@
+      .GLOBAL  SoftReset
+      .THUMB_FUNC
+SoftReset:
+  swi   1
+  swi   0
+ 
+@--------------------------------------------------
+@ 01h
+@ extern void RegisterRamReset(u32 flags);
+ 
+      .GLOBAL  RegisterRamReset
+      .THUMB_FUNC
+RegisterRamReset:
+  swi   1
+  bx    lr
+ 
+@--------------------------------------------------
+@ 02h
+@ extern void Halt(void);
+ 
+      .GLOBAL  Halt
+      .THUMB_FUNC
+Halt:       
+  swi   2
+  bx    lr
+ 
+@--------------------------------------------------
+@ 03h
+@ extern void Stop(void);
+ 
+      .GLOBAL  Stop
+      .THUMB_FUNC
+Stop:       swi      3
+            bx    lr
+ 
+@--------------------------------------------------
+@ 04h
+@ extern void IntrWait(u32 flagClear, u32 irq);
+ 
+      .GLOBAL  IntrWait
+      .THUMB_FUNC
+IntrWait:      swi      4
+            bx    lr
+ 
+@--------------------------------------------------
+@ 05h
+@ extern void VBlankIntrWait(void);
+ 
+      .GLOBAL  VBlankIntrWait
+      .THUMB_FUNC
+VBlankIntrWait:
+            swi      5
+            bx    lr
+ 
+@--------------------------------------------------
+@ 06h
+@ extern s32 Divi(s32 numerator, s32 denominator); 
+ 
+      .GLOBAL  Divi
+      .THUMB_FUNC
+Divi:       swi      6
+            bx    lr
+ 
+ 
+@--------------------------------------------------
+@ 07h
+@ extern s32 DiviArm(s32 denominator, s32 numerator);   
+ 
+      .GLOBAL  DiviArm
+      .THUMB_FUNC
+DiviArm:    swi      7
+            bx    lr
+ 
+@--------------------------------------------------
+@ 08h
+@ extern u32 Sqrt(u32 value);
+ 
+      .GLOBAL  Sqrt
+      .THUMB_FUNC
+Sqrt:       swi      8
+            bx    lr
+ 
+ 
+@--------------------------------------------------
+@ 09h
+@ extern s16 ArcTan(s16 ang);
+ 
+      .GLOBAL  ArcTan
+      .THUMB_FUNC
+ArcTan:        swi      9
+            bx    lr
+ 
+@--------------------------------------------------
+@ 0Ah
+@ extern u16 ArcTan2(s16 x, s16 y);
+ 
+      .GLOBAL  ArcTan2
+      .THUMB_FUNC
+ArcTan2:    swi      10
+            bx    lr
+ 
+@--------------------------------------------------
+@ 0Bh
+@ extern void CpuSet(void *source, void *dest, u32 mode);
+ 
+      .GLOBAL  CpuSet
+      .THUMB_FUNC
+CpuSet:        swi      11
+            bx    lr
+ 
+@--------------------------------------------------
+@ 0Ch
+@ extern void CpuFastSet(void *source, void *dest, u32 mode);
+ 
+      .GLOBAL  CpuFastSet
+      .THUMB_FUNC
+CpuFastSet:    swi      12
+            bx    lr
+ 
+@--------------------------------------------------
+@ 0Eh
+@ extern void BgAffineSet(BgAffineSrcData *source, BgAffineDestData *dest, s32 num);
+ 
+      .GLOBAL  BgAffineSet
+      .THUMB_FUNC
+BgAffineSet:   swi      14
+            bx    lr
+ 
+@--------------------------------------------------
+@ 0Fh
+@ extern void ObjAffineSet(ObjAffineSrcData *source, void *dest, s32 num, s32 offset);
+ 
+      .GLOBAL  ObjAffineSet
+      .THUMB_FUNC
+ObjAffineSet:  swi      15
+            bx    lr
+ 
+@--------------------------------------------------
+@ 10h
+@ extern void BitUnPack(void  *source, void *dest, BUP* bup);
+ 
+      .GLOBAL  BitUnPack
+      .THUMB_FUNC
+BitUnPack:     swi      16
+            bx    lr
+ 
+@--------------------------------------------------
+@ 11h
+@ extern void LZ77UnCompWram(void *source, void *dest);
+ 
+      .GLOBAL  LZ77UnCompWram
+      .THUMB_FUNC
+LZ77UnCompWram:
+            swi      17
+            bx    lr
+ 
+@--------------------------------------------------
+@ 12h
+@ extern void LZ77UnCompVram(void *source, void *dest);
+ 
+      .GLOBAL  LZ77UnCompVram
+      .THUMB_FUNC
+LZ77UnCompVram:
+            swi      18
+            bx    lr
+ 
+@--------------------------------------------------
+@ 13h
+@ extern void HuffUnComp(void *source, void *dest);
+ 
+      .GLOBAL  HuffUnComp
+      .THUMB_FUNC
+HuffUnComp:    swi      19
+            bx    lr
+ 
+@--------------------------------------------------
+@ 14h
+@ extern void RLUnCompWram(void *source, void *dest);
+ 
+      .GLOBAL  RLUnCompWram
+      .THUMB_FUNC
+RLUnCompWram:  swi      20
+            bx    lr
+ 
+@--------------------------------------------------
+@ 15h
+@ extern void RLUnCompVram(void *source, void *dest);
+ 
+      .GLOBAL  RLUnCompVram
+      .THUMB_FUNC
+RLUnCompVram:  swi      21
+            bx    lr
+ 
+@--------------------------------------------------
+@ 16h
+@ extern void Diff8bitUnFilterWram(void *source, void *dest);
+ 
+      .GLOBAL  Diff8bitUnFilterWram
+      .THUMB_FUNC
+Diff8bitUnFilterWram:
+            swi      22
+            bx    lr
+ 
+@--------------------------------------------------
+@ 17h
+@ extern void Diff8bitUnFilterVram(void *source, void *dest);
+ 
+      .GLOBAL  Diff8bitUnFilterVram
+      .THUMB_FUNC
+Diff8bitUnFilterVram:
+            swi      23
+            bx    lr
+ 
+@--------------------------------------------------
+@ 18h
+@ extern void Diff16bitUnFilter(void *source, void *dest);
+ 
+      .GLOBAL  Diff16bitUnFilter
+      .THUMB_FUNC
+Diff16bitUnFilter:
+            swi      24
+            bx    lr
+ 
+ 
+@--------------------------------------------------
+@ 19h
+@ extern void SoundBias(void);
+ 
+      .GLOBAL  SoundBias
+      .THUMB_FUNC
+SoundBiasSet:
+            swi      25
+            bx    lr
+ 
+@--------------------------------------------------
+@ 1Ah
+@ extern void SoundDriverInit(void);
+ 
+      .GLOBAL  SoundDriverInit
+      .THUMB_FUNC
+SoundDriverInit:
+            swi      26
+            bx    lr
+ 
+ 
+@--------------------------------------------------
+@ 1Bh
+@ extern void SoundDriverMode(u32 mode);
+ 
+      .GLOBAL  SoundDriverMode
+      .THUMB_FUNC
+SoundDriverMode:
+            swi      27
+            bx    lr
+ 
+@--------------------------------------------------
+@ 1Ch
+@ extern void SoundDriverMain(void);
+ 
+      .GLOBAL  SoundDriverMain
+      .THUMB_FUNC
+SoundDriverMain:
+            swi      28
+            bx    lr
+ 
+@--------------------------------------------------
+@ 1Dh
+@ extern void SoundDriverVSync(void);
+ 
+      .GLOBAL  SoundDriverVSync
+      .THUMB_FUNC
+SoundDriverVSync:
+            swi      29
+            bx    lr
+ 
+@--------------------------------------------------
+@ 1Eh
+@ extern void SoundChannelClear(void);
+ 
+      .GLOBAL  SoundChannelClear
+      .THUMB_FUNC
+SoundChannelClear:
+            swi      30
+            bx    lr
+ 
+ 
+@--------------------------------------------------
+@ 1Fh
+@ extern void  MidiKey2Freq(void);
+ 
+      .GLOBAL  MidiKey2Freq
+      .THUMB_FUNC
+MidiKey2Freq:
+            swi      31
+            bx    lr
+ 
+@--------------------------------------------------
+@ 25h
+@ extern int MultiBoot(void)
+ 
+      .GLOBAL  MultiBoot
+      .THUMB_FUNC
+MultiBoot:
+            swi      37
+            bx    lr
+ 
+@--------------------------------------------------
+@ 28h
+@ extern void SoundDriverVSyncOff(void);
+ 
+      .GLOBAL  SoundDriverVSyncOff
+      .THUMB_FUNC
+SoundDriverVSyncOff:
+            swi      40
+            bx    lr
+ 
+@--------------------------------------------------
+@ 29h
+@ extern void SoundDriverVSyncOn(void);
+ 
+      .GLOBAL  SoundDriverVSyncOn
+      .THUMB_FUNC
+SoundDriverVSyncOn:
+            swi      41
+            bx    lr
+  .END

+ 237 - 0
packages/extra/gbaunits/core_asm.as

@@ -0,0 +1,237 @@
+@   file core_asm.s
+@   core asm routines
+@   author cearn
+@   Modified by Legolas for fpc4gba use
+@
+@ === NOTES ===
+@ * 20050924: Lower overhead for all; reduced i-count for u16 loops.
+@ * These are 16/32bit memset and memcpy. The 32bit versions are in 
+@   iwram for maximum effect and pretty much do what CpuFastSet does, 
+@   except that it'll work for non multiples of 8 words too. Speed 
+@   is as good as CpuFastSet, but with a little less overhead.
+@ * The 16bit versions call the 32bit ones if possible and/or desirable. 
+@   They are thumb/ROM functions but did them in asm anyway because 
+@   GCC goes haywire with the use of registers resulting in a much
+@   higher overhead (i.e., detrimental for low counts)
+@ * Crossover with inline while(nn--) loops (not for(ii++), which are
+@   much slower):
+@		memcpy32: ~4
+@		memset32: ~5
+@		memcpy16: ~8
+@		memset16: ~8
+
+	.file "core_asm.s"
+
+@ === procedure memcpy32(dest: pointer; const src: pointer; wcount: u32); ======
+@     Fast-copy by words.
+@	  param dest Destination address.
+@	  param src Source address.
+@	  param wcount Number of words.
+@	  note: src and dst must be word aligned.
+@	  note: r0 and r1 return as dst + wdn and src + wdn.
+
+@ Reglist:
+@   r0, r1: dst, src
+@   r2: wcount, then wcount>>3
+@   r3-r10: data buffer
+@   r12: wcount&7
+
+	.text @ ?!?!?
+@	.section .iwram,"ax", %progbits
+	.align	2
+	.code	32
+	.global	memcpy32
+memcpy32:
+	and		r12, r2, #7
+	movs	r2, r2, lsr #3
+	beq		.Lres_cpy32
+	stmfd	sp!, {r4-r10}
+	@ copy 32byte chunks with 8fold xxmia
+.Lmain_cpy32:
+		ldmia	r1!, {r3-r10}	
+		stmia	r0!, {r3-r10}
+		subs	r2, r2, #1
+		bhi		.Lmain_cpy32
+	ldmfd	sp!, {r4-r10}
+	@ and the residual 0-7 words
+.Lres_cpy32:
+		subs	r12, r12, #1
+		ldmcsia	r1!, {r3}
+		stmcsia	r0!, {r3}
+		bcs		.Lres_cpy32
+	bx	lr
+
+@ === procedure memset32(dest: pointer; wd: u32; wcount: u32); =================
+@     Fast-fill by words.
+@   param dest Destination address.
+@   param src Fill word (not address).
+@   param wcount Number of words to fill.
+@   note: dst must be word aligned.
+@   note: r0 returns as dst + wcount.
+
+@ Reglist:
+@   r0, r1: dst, src
+@   r2: wcount, then wcount>>3
+@   r3-r10: data buffer
+@   r12: wcount&7
+
+  .text @?!?!?
+@	.section .iwram,"ax", %progbits
+	.align	2
+	.code	32
+	.global	memset32
+memset32:
+	and		r12, r2, #7
+	movs	r2, r2, lsr #3
+	beq		.Lres_set32
+	stmfd	sp!, {r4-r10}
+	@ set 32byte chunks with 8fold xxmia
+	mov		r3, r1
+	mov		r4, r1
+	mov		r5, r1
+	mov		r6, r1
+	mov		r7, r1
+	mov		r8, r1
+	mov		r9, r1
+	mov		r10, r1
+.Lmain_set32:
+		stmia	r0!, {r3-r10}
+		subs	r2, r2, #1
+		bhi		.Lmain_set32
+	ldmfd	sp!, {r4-r10}
+	@ residual 0-7 words
+.Lres_set32:
+		subs	r12, r12, #1
+		stmcsia	r0!, {r1}
+		bcs		.Lres_set32
+	bx	lr
+
+@ === procedure memcpy16(dest: pointer; const src: pointer; hwcount: u32); =====
+@     Copy for halfwords.
+@   	Uses memcpy32() if hwcount>6 and src and dst are aligned equally.
+@   param dest Destination address.
+@   param src Source address.
+@   param hwcount Number of halfwords to fill.
+@   note: dst and src must be halfword aligned.
+@   note: r0 and r1 return as dst + hwcount and src + hwcount.
+
+@ Reglist:
+@   r0, r1: dst, src
+@   r2, r4: hwcount
+@   r3: tmp; and data buffer
+
+	.text
+	.align	2
+	.code	16
+	.global memcpy16
+	.thumb_func
+memcpy16:
+	push	{r4, lr}
+	@ under 5 hwords -> std cpy
+	cmp		r2, #5
+	bls		.Ltail_cpy16
+	@ unreconcilable alignment -> std cpy
+	@ if (dst^src)&2 -> alignment impossible
+	mov		r3, r0
+	eor		r3, r1
+	lsl		r3, r3, #31		@ (dst^src), bit 1 into carry
+	bcs		.Ltail_cpy16	@ (dst^src)&2 : must copy by halfword
+	@ src and dst have same alignment -> word align
+	lsl		r3, r0, #31
+	bcc		.Lmain_cpy16	@ ~src&2 : already word aligned
+	@ aligning is necessary: copy 1 hword and align
+		ldrh	r3, [r1]
+		strh	r3, [r0]
+		add		r0, #2
+		add		r1, #2
+		sub		r2, r2, #1
+	@ right, and for the REAL work, we're gonna use memcpy32
+.Lmain_cpy16:
+	lsl		r4, r2, #31
+	lsr		r2, r2, #1
+	ldr		r3, .Lpool_cpy16
+  bx    r3
+  nop
+
+	@ NOTE: r0,r1 are altered by memcpy32, but in exactly the right 
+	@ way, so we can use them as is.
+	lsr		r2, r4, #31
+	beq		.Lend_cpy16
+.Ltail_cpy16:
+	sub		r2, #1
+	bcc		.Lend_cpy16		@ r2 was 0, bug out
+	lsl		r2, r2, #1
+.Lres_cpy16:
+		ldrh	r3, [r1, r2]
+		strh	r3, [r0, r2]
+		sub		r2, r2, #2
+		bcs		.Lres_cpy16
+.Lend_cpy16:
+	pop		{r4}
+	pop		{r3}
+	bx	r3
+	.align 2
+.Lpool_cpy16:
+	.word memcpy32
+
+
+@ === procedure memset16(dest: pointer; hw: u16; hwcount: u32); ================
+@     Fill for halfwords.
+@   	Uses memset32() if hwcount>5
+@   param dest Destination address.
+@   param hw Source halfword (not address).
+@   param hwcount Number of halfwords to fill.
+@   note: dest must be halfword aligned.
+@   note: r0 returns as dest + hwcount.
+
+@ Reglist:
+@   r0, r1: dst, hw
+@   r2, r4: hwcount
+@   r3: tmp; and data buffer
+
+	.text
+	.align	2
+	.code 16
+	.global memset16
+	.thumb_func
+memset16:
+	push	{r4, lr}
+	@ under 6 hwords -> std set
+	cmp		r2, #5
+	bls		.Ltail_set16
+	@ dst not word aligned: copy 1 hword and align
+	lsl		r3, r0, #31
+	bcc		.Lmain_set16
+		strh	r1, [r0]
+		add		r0, #2
+		sub		r2, r2, #1
+	@ Again, memset32 does the real work
+.Lmain_set16:
+	lsl		r4, r1, #16
+	orr		r1, r4
+	lsl		r4, r2, #31
+	lsr		r2, r2, #1
+	ldr		r3, .Lpool_set16
+  bx    r3
+  nop
+
+	@ NOTE: r0 is altered by memset32, but in exactly the right 
+	@ way, so we can use is as is. r1 is now doubled though.
+	lsr		r2, r4, #31
+	beq		.Lend_set16
+	lsr		r1, #16
+.Ltail_set16:
+	sub		r2, #1
+	bcc		.Lend_set16		@ r2 was 0, bug out
+	lsl		r2, r2, #1
+.Lres_set16:
+		strh	r1, [r0, r2]
+		sub		r2, r2, #2
+		bcs		.Lres_set16
+.Lend_set16:
+	pop		{r4}
+	pop		{r3}
+	bx	r3
+	.align 2
+.Lpool_set16:
+	.word memset32

+ 37 - 0
packages/extra/gbaunits/def.inc

@@ -0,0 +1,37 @@
+(*
+  def.inc
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+
+{$MODE OBJFPC}
+{$J+}
+{$INLINE ON}
+{$MACRO ON}

+ 26 - 0
packages/extra/gbaunits/fpmake.inc

@@ -0,0 +1,26 @@
+    StartPackage('gbaunits');
+    {$IF defined(ALLPACKAGES)}
+    Directory:='extra/gbaunits';
+    {$ELSEIF defined(EXTRAPACKAGES)}
+    Directory:='gbaunits';
+    {$ENDIF}
+    OS:=[gba];
+    T:=Targets.AddUnit('gba');
+    T:=Targets.AddUnit('gba_bg');
+    T:=Targets.AddUnit('gba_bios');
+    T:=Targets.AddUnit('gba_blend');
+    T:=Targets.AddUnit('gba_core');
+    T:=Targets.AddUnit('gba_dma');
+    T:=Targets.AddUnit('gba_fade');
+    T:=Targets.AddUnit('gba_input');
+    T:=Targets.AddUnit('gba_irq');
+    T:=Targets.AddUnit('gba_mosaic');
+    T:=Targets.AddUnit('gba_regs');
+    T:=Targets.AddUnit('gba_sio');
+    T:=Targets.AddUnit('gba_sprites');
+    T:=Targets.AddUnit('gba_timer');
+    T:=Targets.AddUnit('gba_types');
+    T:=Targets.AddUnit('gba_video');
+    T:=Targets.AddUnit('gba_window');
+    T.OS:=[gba];
+    EndPackage;

+ 17 - 0
packages/extra/gbaunits/fpmake.pp

@@ -0,0 +1,17 @@
+{$mode objfpc}{$H+}
+program fpmake;
+
+uses fpmkunit;
+
+Var
+  T : TTarget;
+
+begin
+  With Installer do 
+    begin
+    { Base packages }
+    {$i fpmake.inc}
+    Run;
+    end;
+end.
+

+ 159 - 0
packages/extra/gbaunits/gba_bg.pas

@@ -0,0 +1,159 @@
+(*
+  gba_bg.pas  18/06/2006 4.07.57
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+
+unit gba_bg;
+{$i def.inc}
+
+interface
+
+uses
+  gba_types;
+
+
+const 
+  DISP_HBLANK_PROCESS_ON = (0 shl 5);
+  DISP_HBLANK_PROCESS_OFF = (1 shl 5);
+
+  DISP_SPRITE_TYPE_1D = (1 shl 6);
+  DISP_SPRITE_TYPE_2D = (0 shl 6);
+
+  DISP_FORCE_BLANK  = (1 shl 7);
+
+  DISP_BG0  = (1 shl 8);
+  DISP_BG1  = (1 shl 9);
+  DISP_BG2  = (1 shl 10);
+  DISP_BG3  = (1 shl 11);
+  DISP_OBJ  = (1 shl 12);
+
+  DISP_WND0 = (1 shl 13);
+  DISP_WND1 = (1 shl 14);
+  DISP_OBJWND = (1 shl 15);
+
+  DSTAT_BIT_VBLANK  = (1);
+  DSTAT_BIT_HBLANK  = (1 shl 1);
+  DSTAT_BIT_VCOUNT  = (1 shl 2);
+
+  DSTAT_USE_VBLANK  = (1 shl 3);
+  DSTAT_USE_HBLANK  = (1 shl 4);
+  DSTAT_USE_VCOUNT  = (1 shl 5);
+
+  BG_SIZEA_256_256  = 0;
+  BG_SIZEA_512_256  = (1 shl 14);
+  BG_SIZEA_256_512  = (2 shl 14);
+  BG_SIZEA_512_512  = (3 shl 14);
+
+  BG_SIZEB_128_128  = 0;
+  BG_SIZEB_256_256  = (1 shl 14);
+  BG_SIZEB_512_512  = (2 shl 14);
+  BG_SIZEB_1024_1024= (2 shl 14);
+
+  BG_OVERLAP  = (1 shl 13);
+
+  BG_COLOR_16   = 0;
+  BG_COLOR_256  = (1 shl 7);
+
+  BG_MOZAIC_ON  = (1 shl 6);
+
+  BG_MAP_YFLIP  = (1 shl 11);
+  BG_MAP_XFLIP  = (1 shl 10);
+
+  MEM_BG_PAL  : ^word = pointer($5000000);
+
+function DispBgMode(x: dword): dword;
+function DispSelectBuffer(x: dword): dword;
+function BgMapTile(x: word): word;
+function MemBgChar(x: word): pointer;
+function MemBgMap(x: word): pointer;
+function BgCharBase(x: dword): dword;
+function BgPriority(x: dword): dword;
+function BgMapPal(x: dword): dword;
+function BgMapBase(x: dword): dword;
+function DStatVCountLine(x: dword): dword;
+
+
+implementation
+
+function DispBgMode(x: dword): dword;
+begin
+  DispBgMode := x;
+end;
+
+function DispSelectBuffer(x: dword): dword;
+begin
+  DispSelectBuffer := (x shl 4);
+end;
+
+function BgMapTile(x: word): word;
+begin
+  BgMapTile := (x);
+end;
+
+function MemBgChar(x: word): pointer;
+begin
+  MemBgChar := pointer($6000000 + (x)*$4000);
+end;
+
+function MemBgMap(x: word): pointer;
+begin
+  MemBgMap :=  pointer($6000000 + (x)* $800);
+end;
+
+function BgCharBase(x: dword): dword;
+begin
+  BgCharBase := ((x) shl 2);
+end;
+
+function BgPriority(x: dword): dword;
+begin
+  BgPriority := x;
+end;
+
+
+function BgMapPal(x: dword): dword;
+begin
+  BgMapPal := ((x) shl 12);
+end;
+
+function BgMapBase(x: dword): dword;
+begin
+  BgMapBase := ((x) shl 8);
+end;
+
+function DStatVCountLine(x: dword): dword;
+begin
+  DStatVCountLine := ((x) shl 8);
+end;
+
+
+end.
+

+ 80 - 0
packages/extra/gbaunits/gba_bios.pas

@@ -0,0 +1,80 @@
+(*
+  gba_bios.pas  18/06/2006 4.17.48
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_bios;
+{$i def.inc}
+
+interface
+
+uses
+  gba_types;
+   
+procedure SoftReset();cdecl; external;
+procedure RegisterRamReset(flags: dword); cdecl; external;
+procedure Halt(); cdecl; external;
+procedure Stop(); cdecl; external;
+procedure IntrWait(flagClear, irq: dword); cdecl; external;
+procedure VBlankIntrWait(); cdecl; external;
+function Divi(numerator, denominator: longint): longint;  cdecl; external;     
+function DiviArm(denominator, numerator: longint): longint; cdecl; external;
+function Sqrt(value: dword): dword; cdecl; external;
+function ArcTan(ang: smallint): smallint; cdecl; external;
+function ArcTan2(x, y: smallint): word; cdecl; external;
+procedure CpuSet(source, dest: pointer; mode: dword); cdecl; external;
+procedure CpuFastSet(source, dest: pointer; mode: dword); cdecl; external;
+procedure ObjAffineSet(source: PObjAffineSource; dest: pointer; num: longint; offset: longint); cdecl; external;
+procedure BgAffineSet(source: PBGAffineSource; dest: PBGAffineDest; num: longint); cdecl; external;
+procedure BitUnPack(source: pointer; dest: pointer; _bup: PBUP); cdecl; external;
+procedure LZ77UnCompWram(source, dest: pointer); cdecl; external;
+procedure LZ77UnCompVram(source, dest: pointer); cdecl; external;
+procedure HuffUnComp(source, dest: pointer); cdecl; external;
+procedure RLUnCompWram(source, dest: pointer); cdecl; external;
+procedure RLUnCompVram(source, dest: pointer); cdecl; external;
+procedure Diff8bitUnFilterWram(source, dest: pointer); cdecl; external;
+procedure Diff8bitUnFilterVram(source, dest: pointer); cdecl; external;
+procedure Diff16bitUnFilter(source, dest: pointer); cdecl; external;
+function MultiBoot(mb: PMultiBootParam; mode: dword): integer; cdecl; external;
+procedure SoundBias(); cdecl; external;
+procedure SoundDriverInit(); cdecl; external;
+procedure SoundDriverMode(mode: dword); cdecl; external;
+procedure SoundDriverMain(); cdecl; external;
+procedure SoundDriverVSync(); cdecl; external;
+procedure SoundChannelClear(); cdecl; external;
+procedure MidiKey2Freq(); cdecl; external;
+procedure SoundDriverVSyncOff(); cdecl; external;
+procedure SoundDriverVSyncOn(); cdecl; external;
+ 
+implementation
+
+{$l bios_asm.o}
+
+end.

+ 92 - 0
packages/extra/gbaunits/gba_blend.pas

@@ -0,0 +1,92 @@
+(*
+  gba_blend.pas 18/06/2006 4.17.40
+  ------------------------------------------------------------------------------
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_blend;
+{$i def.inc}
+
+interface
+
+uses
+  gba_types;
+
+const
+  BLEND_TOP_BG0 = (1 shl 0); 
+  BLEND_TOP_BG1 = (1 shl 1);
+  BLEND_TOP_BG2 = (1 shl 2);
+  BLEND_TOP_BG3 = (1 shl 3);
+  BLEND_TOP_OBJ = (1 shl 4);
+  BLEND_TOP_BD  = (1 shl 5);
+  
+  BLEND_LOW_BG0 = (1 shl 8); 
+  BLEND_LOW_BG1 = (1 shl 9);
+  BLEND_LOW_BG2 = (1 shl 10);
+  BLEND_LOW_BG3 = (1 shl 11);
+  BLEND_LOW_OBJ = (1 shl 12);
+  BLEND_LOW_BD  = (1 shl 13);
+
+  BLEND_MODE_OFF    = (0 shl 6);
+  BLEND_MODE_ALPHA  = (1 shl 6);
+  BLEND_MODE_LIGHT  = (2 shl 6);
+  BLEND_MODE_DARK   = (3 shl 6);
+
+function BlendLow(n: dword): dword; inline;
+function BlendHigh(n: dword): dword; inline;
+function BlendLevel(n: dword): dword; inline;
+function BlendBalance(n: dword): dword; inline;
+function BlendDepth(n: dword): dword; inline;
+
+implementation
+
+function BlendLow(n: dword): dword; inline;
+begin
+  BlendLow := (n shl 0);
+end;
+
+function BlendHigh(n: dword): dword; inline;
+begin
+  BlendHigh := (n shl 8);
+end;
+
+function BlendLevel(n: dword): dword; inline;
+begin
+  BlendLevel := (BlendLow(n) or BlendHigh(n));
+end;
+
+function BlendBalance(n: dword): dword; inline;
+begin
+  BlendBalance := (BlendLow(n) or BlendHigh(16-n));
+end;
+
+function BlendDepth(n: dword): dword; inline;
+begin
+  BlendDepth := (n shl 0);
+end;
+
+
+end.

+ 95 - 0
packages/extra/gbaunits/gba_core.pas

@@ -0,0 +1,95 @@
+(*
+  gba_core.pas  18/06/2006 4.17.35
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of tonclib library for gba (you can find it at
+  http://user.chem.tue.nl/jakvijn/index.htm).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_core;
+{$i def.inc}
+
+interface
+
+uses 
+  gba_types;
+
+
+// random numbers  -- courtesy of Cearn (TONClib)
+const
+  QRAN_SHIFT  = 15;
+  QRAN_MASK   = ((1 shl QRAN_SHIFT) - 1);
+  QRAN_MAX    = QRAN_MASK;
+  QRAN_A      = 1664525;
+  QRAN_C      = 1013904223;
+
+var
+  gbaRandSeed: dword = 42;
+
+function gbaRandomize(seed: dword): dword;
+function gbaRand(): dword;
+
+procedure memset16(dest: pointer; hw: word; hwcount: dword); cdecl; external;
+procedure memcpy16(dest: pointer; const src: pointer; hwcount: dword); cdecl; external;
+
+procedure memset32(dest: pointer; wd: dword; wcount: dword); cdecl; external;
+procedure memcpy32(dest: pointer; const src: pointer; wcount: dword); cdecl; external;
+
+procedure DebugPrint(s: string); assembler; inline;
+
+implementation
+
+function gbaRandomize(seed: dword): dword;
+var
+  old: dword;
+begin	
+	old := gbaRandSeed;
+	gbaRandSeed := seed; 
+	gbaRandomize := old;	
+end;
+
+function gbaRand(): dword;
+begin	
+	gbaRandSeed := QRAN_A * gbaRandSeed + QRAN_C;
+	gbaRand := (gbaRandSeed shr 16) and QRAN_MAX;
+end;
+
+// memory handling routines
+// these are in ASM and optimized; use when possible
+{$l core_asm.o}
+
+
+{$OPTIMIZATION OFF}
+procedure DebugPrint(s: string); assembler; inline;
+asm
+  mov r0,s
+  swi #0xff0000
+end['r0'];
+{$OPTIMIZATION ON}                  
+
+
+end.

+ 150 - 0
packages/extra/gbaunits/gba_dma.pas

@@ -0,0 +1,150 @@
+(*
+  gba_dma.pas 18/06/2006 4.18.32
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+
+unit gba_dma;
+{$i def.inc}
+
+interface
+
+uses
+  gba_types, gba_regs;
+
+const
+  DMA_SHIFT       = 16;
+
+  // destination control
+  _DMA_DST_INC    = ($0000 shl DMA_SHIFT);
+  DMA_DST_DEC     = ($0020 shl DMA_SHIFT);
+  DMA_DST_FIX     = ($0040 shl DMA_SHIFT);
+  DMA_DST_RESET   = ($0060 shl DMA_SHIFT);
+  
+  // source control
+  _DMA_SRC_INC    = ($0000 shl DMA_SHIFT);
+  DMA_SRC_DEC     = ($0080 shl DMA_SHIFT);
+  DMA_SRC_FIX     = ($0100 shl DMA_SHIFT);
+  DMA_SRC_RESET   = ($0180 shl DMA_SHIFT);
+
+  DMA_REPEAT      = ($0200 shl DMA_SHIFT);
+  
+  // chunks
+  _DMA_16         = ($0000 shl DMA_SHIFT);
+  DMA_32          = ($0400 shl DMA_SHIFT);
+
+  // timing
+  _DMA_AT_NOW     = ($0000 shl DMA_SHIFT);
+  DMA_AT_VBLANK   = ($1000 shl DMA_SHIFT);
+  DMA_AT_HBLANK   = ($2000 shl DMA_SHIFT);
+  DMA_AT_FIFO     = ($3000 shl DMA_SHIFT);		// for sound ( DMA 1 & 2)
+  DMA_AT_REFRESH  = ($3000 shl DMA_SHIFT);		// for video ( DMA 3)
+
+  DMA_IRQ         = ($4000 shl DMA_SHIFT);
+  DMA_ON          = ($8000 shl DMA_SHIFT);
+
+  // I want it NOW!
+  DMA_NOW         = DMA_ON or _DMA_AT_NOW;
+  DMA_16NOW       = DMA_NOW or _DMA_16;
+  DMA_32NOW       = DMA_NOW or DMA_32;
+  
+  // copies
+  DMA_CPY16       = DMA_NOW or _DMA_16;
+  DMA_CPY32       = DMA_NOW or DMA_32;
+  
+  // fills
+  DMA_FILL16      = DMA_NOW or DMA_SRC_FIX or _DMA_16;
+  DMA_FILL32      = DMA_NOW or DMA_SRC_FIX or DMA_32;
+
+  DMA_TRANSFER_ON	    = (1 shl 15);
+  DMA_TRANSFER_OFF    = (0 shl 15);
+
+  DMA_INTR_ON         = (1 shl 14);
+  DMA_INTR_OFF        = (0 shl 14);
+
+  DMA_TIMING_NOW      = (0 shl 12);
+  DMA_TIMING_VBLANK   = (1 shl 12);
+  DMA_TIMING_HBLANK   = (2 shl 12);
+  DMA_TIMING_FIFO     = (3 shl 12);
+  DMA_TIMING_DRAWLINE = (3 shl 12);
+  
+  DMA_ROM_REQUEST     = (1 shl 11);
+
+  DMA_SIZE_16         = (0 shl 10);
+  DMA_SIZE_32         = (1 shl 10);
+  
+  DMA_REPEAT_ON       = (1 shl 9);
+  DMA_REPEAT_OFF      = (0 shl 9);
+
+  DMA_SAD_INC         = (0 shl 7);
+  DMA_SAD_DEC         = (1 shl 7);
+  DMA_SAD_FIX         = (2 shl 7);
+
+  DMA_DAD_INC         = (0 shl 5);
+  DMA_DAD_DEC         = (1 shl 5);
+  DMA_DAD_FIX         = (2 shl 5);
+  DMA_DAD_RESET       = (3 shl 5);
+
+procedure DMA0Copy(sad: pword; dad: pword; size: dword; mode: dword); inline;
+procedure DMA1Copy(sad: pword; dad: pword; size: dword; mode: dword); inline;
+procedure DMA2Copy(sad: pword; dad: pword; size: dword; mode: dword); inline;
+procedure DMA3Copy(sad: pword; dad: pword; size: dword; mode: dword); inline;
+
+implementation
+
+procedure DMA0Copy(sad: pword; dad: pword; size: dword; mode: dword); inline;
+begin
+  REG_DM0SAD^ := dword(sad);
+  REG_DM0DAD^ := dword(dad);
+  REG_DM0CNT^ := size or mode;
+end; 
+
+procedure DMA1Copy(sad: pword; dad: pword; size: dword; mode: dword); inline;
+begin
+  REG_DM1SAD^ := dword(sad);
+  REG_DM1DAD^ := dword(dad);
+  REG_DM1CNT^ := size or mode;
+end; 
+
+procedure DMA2Copy(sad: pword; dad: pword; size: dword; mode: dword); inline;
+begin
+  REG_DM2SAD^ := dword(sad);
+  REG_DM2DAD^ := dword(dad);
+  REG_DM2CNT^ := size or mode;
+end; 
+
+procedure DMA3Copy(sad: pword; dad: pword; size: dword; mode: dword); inline;
+begin
+  REG_DM3SAD^ := dword(sad);
+  REG_DM3DAD^ := dword(dad);
+  REG_DM3CNT^ := size or mode;
+end; 
+
+end.

+ 203 - 0
packages/extra/gbaunits/gba_fade.pas

@@ -0,0 +1,203 @@
+(*
+  gba_fade.pas  18/06/2006 4.19.14
+  ------------------------------------------------------------------------------
+  Part of this file is a raw porting of libgba library for gba (you can find it 
+  at http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+ 
+unit gba_fade;
+{$i def.inc}
+interface
+
+uses 
+  gba_types, gba_regs, gba_video, gba_core;
+
+var
+  CurrentPalette: array [0..511] of word;
+  FadeTable: array [0..(512*3*2)-1] of smallint;
+  
+procedure GetCurrentPalette();
+procedure SetPalette(Palette: pword);
+procedure DoFade(FadeCount: dword);
+procedure FadeToGrayScale(FrameCount: dword);
+procedure FadeToPalette(const NewPalette: pword; FrameCount: dword);
+procedure FadeToGray(gray: word; FrameCount: dword);
+
+implementation
+
+procedure GetCurrentPalette();
+var
+  i: dword;
+  Src: ^word;
+  Dest: ^word;
+begin
+  Src := BG_COLORS;
+  Dest := CurrentPalette;
+	for i := 0 to 511 do
+	  Dest[i] := dword(Src[i]);
+end;
+
+
+procedure SetPalette(Palette: pword);
+var
+  i: dword;
+  Src, Dest: ^word;
+begin	
+	Src := Palette;
+	Dest := BG_COLORS;
+	for i := 0 to 511 do
+		Dest[i] := dword(Src[i]);
+end;
+
+procedure DoFade(FadeCount: dword);
+var
+  r, g, b: word;
+	i, count, color: dword;
+	src: ^smallint;
+  dest: ^word;
+begin
+  for count := 0 to FadeCount - 1 do
+  begin
+    src := FadeTable;
+    dest := CurrentPalette;
+
+    i := 0;
+    while i < 512 do
+    begin
+      r := Src[(i*6)+1];
+      r := r + Src[(i*6)];
+      Src[(i*6)+1] := r;
+      
+      g := Src[(i*6)+3];
+      g := g + Src[(i*6)+2];
+      Src[(i*6)+3] := g;
+      
+      b := Src[(i*6)+5];
+      b := b + Src[(i*6)+4];
+      Src[(i*6)+5] := b;
+      
+      color := (r shr 8) or ((g shr 8) shl 5) or ((b shr 8) shl 10);
+      Dest[i] := color;
+      inc(i);
+    end;
+    WaitForVBlank();
+    SetPalette(CurrentPalette);
+	end;
+end;
+
+procedure FadeToGray(gray: word; FrameCount: dword);
+var
+	index, r, g, b, color: dword;
+ 	src: ^word;
+	table: ^smallint; 
+begin
+  GetCurrentPalette();
+  src := CurrentPalette;
+  
+  for index :=0  to 511 do 
+  begin
+    color := src[index];
+    r := (color and $1f) shl 8;
+    g := ((color shr 5) and $1f) shl 8;
+    b := ((color shr 10) and $1f) shl 8;
+    
+    FadeTable[(index*6)] := ((gray shl 8)-r) div FrameCount;
+    FadeTable[(index*6)+1] := r;
+    
+    FadeTable[(index*6)+2] := ((gray shl 8)-g) div FrameCount;
+    FadeTable[(index*6)+3] := g;
+    
+    FadeTable[(index*6)+4] := ((gray shl 8)-b) div FrameCount;
+    FadeTable[(index*6)+5] := b;
+  end;
+  DoFade( FrameCount);
+end;
+
+procedure FadeToPalette(const NewPalette: pword; FrameCount: dword);
+var
+  index: dword;
+  color: word;
+  r1, r2, g1, g2, b1, b2: smallint;
+  Src: ^word;
+  Dest: ^word;
+  Table: ^smallint;
+begin
+  GetCurrentPalette();
+  Src := CurrentPalette;
+  Dest := NewPalette;
+  Table := FadeTable;
+  
+  for index := 0 to 511 do
+  begin
+    color := Src[index];
+    r1 := (color and $1f) shl 8;
+    g1 := ((color shr 5) and $1f) shl 8;
+    b1 := ((color shr 10) and $1f) shl 8;
+    
+    color := Dest[index];
+    r2 := (color and $1f) shl 8;
+    g2 := ((color shr 5) and $1f) shl 8;
+    b2 := ((color shr 10) and $1f) shl 8;
+    
+    Table[(index*6)] := (r2 - r1) div FrameCount;
+    Table[(index*6)+1] := r1;
+    Table[(index*6)+2] := (g2 - g1) div FrameCount;
+    Table[(index*6)+3] := g1;
+    Table[(index*6)+4] := (b2 - b1) div FrameCount;
+    Table[(index*6)+5] := b1;
+  end;
+  DoFade(FrameCount);
+end;
+
+procedure FadeToGrayScale(FrameCount: dword);
+var
+  index: dword;
+  gray: word;
+  r,g,b: smallint;
+  Src: ^word;
+  Dest: ^word;
+  Table: ^smallint;
+  GrayScalePalette: array [0..511] of word; 
+begin
+  GetCurrentPalette();
+  Src := CurrentPalette;
+  Table := FadeTable;
+
+  for index := 0 to 511 do
+  begin
+    r := (Src[index] and $1f);
+    g := ((Src[index] shr 5) and $1f);
+    b := ((Src[index] shr 10) and $1f);
+    Gray := (r shr 2) + (r shr 4) + (g shr 1) + (g shr 4) + (b shr 3); 
+    GrayScalePalette[index] := RGB(gray, gray, gray);
+  end;
+  FadeToPalette(GrayScalePalette, FrameCount);
+end;
+
+end.

+ 152 - 0
packages/extra/gbaunits/gba_input.pas

@@ -0,0 +1,152 @@
+(*
+  gba_input.pas 18/06/2006 4.20.21
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_input;
+{$i def.inc}
+interface
+
+uses 
+  gba_types, gba_regs;
+
+
+type
+  KeyInput = packed record
+    Up: word;
+    Down: word;
+    Held: word;
+    Last: word;
+    DownRepeat: word;
+  end;
+  TKeyInput = KeyInput;
+//---------------------------------------------------------------------------------
+// Global variables
+//---------------------------------------------------------------------------------
+
+var
+  Keys: TKeyInput;
+  delay: byte = 60;
+  rept: byte = 30; 
+  count: byte = 60;
+
+procedure ScanKeys();
+function KeysDown(): word;
+function KeysDownRepeat(): word;
+function KeysUp(): word;
+function KeysHeld(): word;
+procedure SetRepeat(SetDelay, SetRepeat: integer);
+
+
+
+
+implementation
+
+procedure SetRepeat(SetDelay, SetRepeat: integer);
+begin
+  delay := SetDelay;
+  rept := SetRepeat;
+end;
+
+//---------------------------------------------------------------------------------
+procedure ScanKeys();
+var
+  pressed, released: word;
+begin
+  Keys.Last := Keys.Held;
+  Keys.Held := (REG_KEYINPUT^ and $03ff) xor $03ff; // upper 6 bits clear on hw not emulated
+
+
+	pressed := Keys.Held and ( Keys.Last xor $03ff);
+
+	Keys.DownRepeat	:= Keys.DownRepeat or pressed;
+	Keys.Down := Keys.Down or pressed;
+
+
+	released := ((Keys.Held xor $03ff) and Keys.Last);
+
+	Keys.Up	:= Keys.Up or released;
+
+	Keys.Down := Keys.Down and not released;
+	Keys.DownRepeat := Keys.DownRepeat and not released;
+
+	Keys.Up := Keys.Up and not pressed;
+
+	if ( Keys.Last <> Keys.Held) then 
+    count := delay;
+
+
+	if ( delay <> 0) then
+	begin
+		dec(count);
+		if (count = 0) then
+		begin
+			count := rept;
+			Keys.DownRepeat := Keys.DownRepeat or Keys.Held;
+		end;
+	end;
+end;
+
+function KeysDownRepeat(): word;
+var
+	tmp: word; 
+begin
+  tmp := Keys.DownRepeat;
+	Keys.DownRepeat := 0;
+
+	KeysDownRepeat := tmp;
+end;
+
+function KeysDown(): word;
+var
+  tmp: word;
+begin
+  tmp := Keys.Down;
+  Keys.Down := 0;
+
+	KeysDown := tmp;
+end;
+
+function KeysUp(): word;
+var
+  tmp: word;
+begin
+  tmp := Keys.Up;
+	Keys.Up := 0;
+
+	KeysUp := tmp;
+end;
+
+function KeysHeld(): word;
+begin
+  KeysHeld := Keys.Held;
+end;
+
+end.

+ 70 - 0
packages/extra/gbaunits/gba_irq.pas

@@ -0,0 +1,70 @@
+(*
+  gba_irq.pas 18/06/2006 4.20.45
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_irq;
+{$i def.inc}
+
+interface
+
+uses
+  gba_types, gba_regs;
+
+const
+  IRQ_MASTER_ON  = 1;
+  IRQ_MASTER_OFF = 0;
+  IRQ_BIT_VBLANK  = (1 shl 0);
+  IRQ_BIT_HBLANK  = (1 shl 1);
+  IRQ_BIT_VCOUNT  = (1 shl 2);
+  IRQ_BIT_TIMER0  = (1 shl 3);
+  IRQ_BIT_TIMER1  = (1 shl 4);
+  IRQ_BIT_TIMER2  = (1 shl 5);
+  IRQ_BIT_TIMER3  = (1 shl 6);
+  IRQ_BIT_SERIAL  = (1 shl 7);
+  IRQ_BIT_DMA0    = (1 shl 8);
+  IRQ_BIT_DMA1    = (1 shl 9);
+  IRQ_BIT_DMA2    = (1 shl 10);
+  IRQ_BIT_DMA3    = (1 shl 11);
+  IRQ_BIT_KEYS    = (1 shl 12);
+  IRQ_BIT_CART    = (1 shl 13);
+
+procedure SetIRQ(x: dword);
+
+implementation
+
+procedure SetIRQ(x: dword);
+begin
+  REG_INTERRUPT^ := x;
+end;
+
+
+end.
+

+ 68 - 0
packages/extra/gbaunits/gba_mosaic.pas

@@ -0,0 +1,68 @@
+(*
+  gba_mosaic.pas  18/06/2006 4.22.03
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+
+unit gba_mosaic;
+{$i def.inc}
+interface
+
+uses
+  gba_types;
+
+function MosaicBgH(x: dword): dword;
+function MosaicBgV(x: dword): dword;
+function MosaicObjH(x: dword): dword;
+function MosaicObjV(x: dword): dword;
+
+implementation 
+
+function MosaicBgH(x: dword): dword;
+begin
+  MosaicBgH := (x shl 0);
+end;
+
+function MosaicBgV(x: dword): dword;
+begin
+  MosaicBgV := (x shl 4);
+end;
+  
+function MosaicObjH(x: dword): dword;
+begin
+  MosaicObjH := (x shl 8);
+end;
+
+function MosaicObjV(x: dword): dword;
+begin
+  MosaicObjV := (x shl 12);
+end;
+
+end.

+ 269 - 0
packages/extra/gbaunits/gba_regs.pas

@@ -0,0 +1,269 @@
+(*
+  gba_regs.pas  18/06/2006 4.22.49
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+
+unit gba_regs;
+{$i def.inc}
+interface
+
+uses
+  gba_types;
+
+const
+  OAMMem          : ^word = pointer($7000000); // Sprites(128), coordinates, size..(total 1Kb)
+  VideoBuffer     : ^word = pointer($6000000); // Front Display Memory (the screen in mode 3-5)
+  SecondBuffer    : ^word = pointer($600A000); // Back Display Memory
+  
+  OAMData         : ^word = pointer($6010000); // Sprite data (bitmapped)
+  OAMdataTile     : ^word = pointer($6010000);
+  OAMdataBmp      : ^word = pointer($6014000);
+
+  BG_COLORS       : ^word = pointer($5000000); // Background Palette(256/16 colors)
+  OBJ_COLORS      : ^word = pointer($5000200); // Sprite Palette(256/16 colors)
+
+  REG_INTERRUPT   : ^dword = pointer($3007FFC);
+  REG_DISPCNT     : ^dword = pointer($4000000);  // Display control mode
+  REG_DISPCNT_L   : ^word = pointer($4000000);
+  REG_DISPCNT_H   : ^word = pointer($4000002);
+  REG_DISPSTAT    : ^word = pointer($4000004);
+{$OPTIMIZATION OFF}
+  REG_VCOUNT      : ^word = pointer($4000006);  // Vertical control sync
+{$OPTIMIZATION ON}
+  BGCTRL          : ^word = pointer($4000008);
+  REG_BG0CNT      : ^word = pointer($4000008);
+  REG_BG1CNT      : ^word = pointer($400000A);
+  REG_BG2CNT      : ^word = pointer($400000C);
+  REG_BG3CNT      : ^word = pointer($400000E);
+  
+  BG_OFFSET       : PBgScroll = pointer($4000010);
+  
+  REG_BG0HOFS     : ^word = pointer($4000010);
+  REG_BG0VOFS     : ^word = pointer($4000012);
+  REG_BG1HOFS     : ^word = pointer($4000014);
+  REG_BG1VOFS     : ^word = pointer($4000016);
+  REG_BG2HOFS     : ^word = pointer($4000018);
+  REG_BG2VOFS     : ^word = pointer($400001A);
+  REG_BG3HOFS     : ^word = pointer($400001C);
+  REG_BG3VOFS     : ^word = pointer($400001E);
+
+  REG_BG2PA       : ^word = pointer($4000020);
+  REG_BG2PB       : ^word = pointer($4000022);
+  REG_BG2PC       : ^word = pointer($4000024);
+  REG_BG2PD       : ^word = pointer($4000026);
+  REG_BG2X        : ^dword = pointer($4000028);
+  REG_BG2X_L      : ^word = pointer($4000028);
+  REG_BG2X_H      : ^word = pointer($400002A);
+  REG_BG2Y        : ^dword = pointer($400002C);
+  REG_BG2Y_L      : ^word = pointer($400002C);
+  REG_BG2Y_H      : ^word = pointer($400002E);
+  REG_BG3PA       : ^word = pointer($4000030);
+  REG_BG3PB       : ^word = pointer($4000032);
+  REG_BG3PC       : ^word = pointer($4000034);
+  REG_BG3PD       : ^word = pointer($4000036);
+  REG_BG3X        : ^dword = pointer($4000038);
+  REG_BG3X_L      : ^word = pointer($4000038);
+  REG_BG3X_H      : ^word = pointer($400003A);
+  REG_BG3Y        : ^dword = pointer($400003C);
+  REG_BG3Y_L      : ^word = pointer($400003C);
+  REG_BG3Y_H      : ^word = pointer($400003E);
+  REG_WIN0H       : ^word = pointer($4000040);
+  REG_WIN1H       : ^word = pointer($4000042);
+  REG_WIN0V       : ^word = pointer($4000044);
+  REG_WIN1V       : ^word = pointer($4000046);
+  REG_WININ       : ^word = pointer($4000048);
+  REG_WINOUT      : ^word = pointer($400004A);
+  
+  REG_MOSAIC      : ^dword = pointer($400004C);
+  REG_MOSAIC_L    : ^dword = pointer($400004C);
+  REG_MOSAIC_H    : ^dword = pointer($400004E);
+
+  REG_BLDMOD      : ^word = pointer($4000050);
+  REG_BLDCNT      : ^word = pointer($4000050);
+  REG_COLEV       : ^word = pointer($4000052);
+  REG_BLDALPHA    : ^word = pointer($4000052);
+  REG_COLEY       : ^word = pointer($4000054);
+  REG_BLDY        : ^word = pointer($4000054);
+  
+{$OPTIMIZATION OFF}
+  REG_SG10        : ^dword = pointer($4000060);
+  REG_SG10_L      : ^word = pointer($4000060);
+  REG_SG10_H      : ^word = pointer($4000062);
+  REG_SG11        : ^word = pointer($4000064);
+  REG_SG20        : ^word = pointer($4000068);
+  REG_SG21        : ^word = pointer($400006C);
+  REG_SG30        : ^dword = pointer($4000070);
+  REG_SG30_L      : ^word = pointer($4000070);
+  REG_SG30_H      : ^word = pointer($4000072);
+  REG_SG31        : ^word = pointer($4000074);
+  REG_SG40        : ^word = pointer($4000078);
+  REG_SG41        : ^word = pointer($400007C);
+  REG_SGCNT0      : ^dword = pointer($4000080);
+  REG_SGCNT0_L    : ^word = pointer($4000080);
+  REG_SGCNT0_H    : ^word = pointer($4000082);
+  REG_SGCNT1      : ^word = pointer($4000084);
+  REG_SGBIAS      : ^word = pointer($4000088);
+  REG_SGWR0       : ^dword = pointer($4000090);
+  REG_SGWR0_L     : ^word = pointer($4000090);
+  REG_SGWR0_H     : ^word = pointer($4000092);
+  REG_SGWR1       : ^dword = pointer($4000094);
+  REG_SGWR1_L     : ^word = pointer($4000094);
+  REG_SGWR1_H     : ^word = pointer($4000096);
+{$OPTIMIZATION ON}
+  REG_SGWR2       : ^dword = pointer($4000098);
+{$OPTIMIZATION OFF}
+  REG_SGWR2_L     : ^word = pointer($4000098);
+  REG_SGWR2_H     : ^word = pointer($400009A);
+  REG_SGWR3       : ^dword = pointer($400009C);
+  REG_SGWR3_L     : ^word = pointer($400009C);
+  REG_SGWR3_H     : ^word = pointer($400009E);
+  REG_SGFIF0A     : ^dword = pointer($40000A0);
+  REG_SGFIFOA_L   : ^word = pointer($40000A0);
+  REG_SGFIFOA_H   : ^word = pointer($40000A2);
+  REG_SGFIFOB     : ^dword = pointer($40000A4);
+  REG_SGFIFOB_L   : ^word = pointer($40000A4);
+  REG_SGFIFOB_H   : ^word = pointer($40000A6);
+{$OPTIMIZATION ON}
+
+  REG_DM0SAD      : ^dword = pointer($40000B0);
+  REG_DM0SAD_L    : ^word = pointer($40000B0);
+  REG_DM0SAD_H    : ^word = pointer($40000B2);
+  REG_DM0DAD      : ^dword = pointer($40000B4);
+  REG_DM0DAD_L    : ^word = pointer($40000B4);
+  REG_DM0DAD_H    : ^word = pointer($40000B6);
+  REG_DM0CNT      : ^dword = pointer($40000B8);
+  REG_DM0CNT_L    : ^word = pointer($40000B8);
+  REG_DM0CNT_H    : ^word = pointer($40000BA);
+  REG_DM1SAD      : ^dword = pointer($40000BC);
+  REG_DM1SAD_L    : ^word = pointer($40000BC);
+  REG_DM1SAD_H    : ^word = pointer($40000BE);
+  REG_DM1DAD      : ^dword = pointer($40000C0);
+  REG_DM1DAD_L    : ^word = pointer($40000C0);
+  REG_DM1DAD_H    : ^word = pointer($40000C2);
+  REG_DM1CNT      : ^dword = pointer($40000C4);
+  REG_DM1CNT_L    : ^word = pointer($40000C4);
+  REG_DM1CNT_H    : ^word = pointer($40000C6);
+  REG_DM2SAD      : ^dword = pointer($40000C8);
+  REG_DM2SAD_L    : ^word = pointer($40000C8);
+  REG_DM2SAD_H    : ^word = pointer($40000CA);
+  REG_DM2DAD      : ^dword = pointer($40000CC);
+  REG_DM2DAD_L    : ^word = pointer($40000CC);
+  REG_DM2DAD_H    : ^word = pointer($40000CE);
+  REG_DM2CNT      : ^dword = pointer($40000D0);
+  REG_DM2CNT_L    : ^word = pointer($40000D0);
+  REG_DM2CNT_H    : ^word = pointer($40000D2);
+  REG_DM3SAD      : ^dword = pointer($40000D4);
+  REG_DM3SAD_L    : ^word = pointer($40000D4);
+  REG_DM3SAD_H    : ^word = pointer($40000D6);
+  REG_DM3DAD      : ^dword = pointer($40000D8);
+  REG_DM3DAD_L    : ^word = pointer($40000D8);
+  REG_DM3DAD_H    : ^word = pointer($40000DA);
+  REG_DM3CNT      : ^dword = pointer($40000DC);
+  REG_DM3CNT_L    : ^word = pointer($40000DC);
+  REG_DM3CNT_H    : ^word = pointer($40000DE);
+ 
+{$OPTIMIZATION OFF} 
+  REG_TM0CNT_L    : ^word = pointer($4000100);
+  REG_TM0CNT_H	  : ^word = pointer($4000102);
+  REG_TM1CNT_L	  : ^word = pointer($4000104);
+  REG_TM1CNT_H	  : ^word = pointer($4000106);
+  REG_TM2CNT_L	  : ^word = pointer($4000108);
+  REG_TM2CNT_H	  : ^word = pointer($400010A);
+  REG_TM3CNT_L	  : ^word = pointer($400010C);
+  REG_TM3CNT_H	  : ^word = pointer($400010E);
+{$OPTIMIZATION ON}
+
+{$OPTIMIZATION OFF}
+  REG_SCD0        : ^word = pointer($4000120);
+  REG_SCD1        : ^word = pointer($4000122);
+  REG_SCD2        : ^word = pointer($4000124);
+  REG_SCD3        : ^word = pointer($4000126);
+ 
+  REG_SCCNT       : ^dword = pointer($4000128);
+  REG_SCCNT_L     : ^word = pointer($4000128);
+  REG_SIOCNT      : ^word = pointer($4000128);
+  REG_SCCNT_H     : ^word = pointer($400012A);
+  REG_SIODATA8    : ^word = pointer($400012A);
+  REG_SIODATA32   : ^dword = pointer($4000120);
+  REG_SIOMLT_SEND : ^word = pointer($400012A);
+  REG_SIOMLT_RECV : ^word = pointer($4000120);
+  REG_SIOMULTI0   : ^word = pointer($4000120);
+  REG_SIOMULTI1   : ^word = pointer($4000122);
+  REG_SIOMULTI2   : ^word = pointer($4000124);
+  REG_SIOMULTI3   : ^word = pointer($4000126);
+
+  REG_RCNT        : ^word = pointer($4000134);
+
+  REG_P1          : ^word = pointer($4000130);
+  REG_KEYINPUT    : ^word = pointer($4000130);
+  REG_P1CNT       : ^word = pointer($4000132);
+  REG_KEYCNT      : ^word = pointer($4000132);
+  REG_R           : ^word = pointer($4000134);
+  
+{$OPTIMIZATION ON}
+
+
+  REG_HS_CTRL     : ^word = pointer($4000140);
+  REG_JOYRE       : ^dword = pointer($4000150);
+  REG_JOYRE_L     : ^word = pointer($4000150);
+  REG_JOYRE_H     : ^word = pointer($4000152);
+  REG_JOYTR       : ^dword = pointer($4000154);
+  REG_JOYTR_L     : ^word = pointer($4000154);
+  REG_JOYTR_H     : ^word = pointer($4000156);
+  REG_JSTAT       : ^dword = pointer($4000158);
+  REG_JSTAT_L     : ^word = pointer($4000158);
+  REG_JSTAT_H     : ^word = pointer($400015A);
+  REG_IE          : ^word = pointer($4000200);
+  REG_IF          : ^word = pointer($4000202);
+  REG_WSCNT       : ^word = pointer($4000204);
+  REG_IME         : ^word = pointer($4000208);
+  REG_PAUSE       : ^word = pointer($4000300);
+
+  BIT0  = 1;
+  BIT1  = 2;
+  BIT2  = 4;
+  BIT3  = 8;
+  BIT4  = 16;
+  BIT5  = 32;
+  BIT6  = 64;
+  BIT7  = 128;
+  BIT8  = 256;
+  BIT9  = 512;
+  BIT10 = 1024;
+  BIT11 = 2048;
+  BIT12 = 4096;
+  BIT13 = 8192;
+  BIT14 = 16384;
+  BIT15 = 32768;
+
+implementation
+
+end.

+ 95 - 0
packages/extra/gbaunits/gba_sio.pas

@@ -0,0 +1,95 @@
+(*
+  gba_sio.pas 18/06/2006 4.23.01
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_sio;
+{$i def.inc}
+interface
+
+uses
+  gba_types;
+
+const
+  SIO_8BIT  = $0000;	// Normal 8-bit communication mode
+  SIO_32BIT = $1000;	// Normal 32-bit communication mode
+  SIO_MULTI = $2000;	// Multi-play communication mode
+  SIO_UART  = $3000;	// UART communication mode
+  SIO_IRQ   = $4000;	// Enable serial irq
+
+
+//---------------------------------------------------------------------------------
+// baud rate settings
+//---------------------------------------------------------------------------------
+  SIO_9600   = $0000;
+  SIO_38400  = $0001;
+  SIO_57600  = $0002;
+  SIO_115200 = $0003;
+
+  SIO_CLK_INT  = (1 shl 0);	// Select internal clock
+  SIO_2MHZ_CLK = (1 shl 1);	// Select 2MHz clock
+  SIO_RDY      = (1 shl 2);	// Opponent SO state
+  SIO_SO_HIGH  = (1 shl 3);	// Our SO state
+  SIO_START    = (1 shl 7);
+
+
+//---------------------------------------------------------------------------------
+// SIO modes set with REG_RCNT
+//---------------------------------------------------------------------------------
+  R_NORMAL  = $0000;
+  R_MULTI   = $0000;
+  R_UART    = $0000;
+  R_GPIO    = $8000;
+  R_JOYBUS  = $C000;
+
+//---------------------------------------------------------------------------------
+// General purpose mode control bits used with REG_RCNT
+//---------------------------------------------------------------------------------
+  GPIO_SC  = $0001;	// Data
+  GPIO_SD	 = $0002;
+  GPIO_SI	 = $0004;
+  GPIO_SO	 = $0008;
+  GPIO_SC_IO  = $0010;	// Select I/O
+  GPIO_SD_IO  = $0020;
+  GPIO_SI_IO  = $0040;
+  GPIO_SO_IO  = $0080;
+  GPIO_SC_INPUT  = $0000;	// Input setting
+  GPIO_SD_INPUT  = $0000;
+  GPIO_SI_INPUT  = $0000;
+  GPIO_SO_INPUT  = $0000;
+  GPIO_SC_OUTPUT = $0010;	// Output setting
+  GPIO_SD_OUTPUT = $0020;
+  GPIO_SI_OUTPUT = $0040;
+  GPIO_SO_OUTPUT = $0080;
+
+
+implementation 
+
+end.

+ 149 - 0
packages/extra/gbaunits/gba_sprites.pas

@@ -0,0 +1,149 @@
+(*
+  gba_sprites.pas 18/06/2006 4.28.18
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+
+unit gba_sprites;
+{$i def.inc}
+interface
+
+uses
+  gba_types, gba_regs;
+
+
+const
+  OAM	: POBJATTR =	pointer($07000000);
+  OBJ_BASE_ADR	=	pointer($06010000);
+  BITMAP_OBJ_BASE_ADR	= pointer($06014000);
+
+  OBJ_ROT_SCALE_ON  = (1 shl 8);
+  OBJ_DISABLE = (1 shl 9);
+  OBJ_DOUBLE  = (1 shl 9);
+
+  OBJ_MOSAIC    = (1 shl 12);
+  OBJ_256_COLOR = (1 shl 13);
+  OBJ_16_COLOR  = (0 shl 13);
+
+  OBJ_HFLIP = (1 shl 12);
+  OBJ_VFLIP = (1 shl 13);
+
+
+
+type
+  SPRITE_SHAPES = (
+    SQUARE,
+    WIDE,
+    TALL
+  );
+  TSpriteShapes = SPRITE_SHAPES;
+  
+  SPRITE_SIZECODE = (
+    Sprite_8x8,
+    Sprite_16x16,
+    Sprite_32x32,
+    Sprite_64x64,
+    Sprite_16x8,
+    Sprite_32x8,
+    Sprite_32x16,
+    Sprite_64x32,
+    Sprite_8x16,
+    Sprite_8x32,
+    Sprite_16x32,
+    Sprite_32x64
+  );
+  TSpriteSizeCode = SPRITE_SIZECODE;
+
+function ObjY(m: integer): integer; inline;
+function ObjMode(m: integer): integer; inline;
+function ObjShape(m: integer): integer; inline;
+function ObjX(m: integer): integer; inline;
+function ObjRotScale(m: integer): integer; inline;
+function ObjSize(m: integer): integer; inline;
+function ObjChar(m: integer): integer; inline;
+function ObjPriority(m: integer): integer; inline;
+function ObjPalette(m: integer): integer; inline;
+
+{$define ObjTranslucent := ObjMode(1)}
+{$define ObjObjWindow := ObjMode(2)}
+{$define ObjSquare := ObjShape(0)}
+{$define ObjWide := ObjShape(1)}
+{$define ObjTall := ObjShape(2)}
+
+
+implementation
+
+function ObjY(m: integer): integer; inline;
+begin
+  ObjY := ((m) and $00ff);
+end;
+
+function ObjMode(m: integer): integer; inline;
+begin
+  ObjMode := ((m) shl 10);
+end;
+
+function ObjShape(m: integer): integer; inline;
+begin
+  ObjShape := ((m) shl 14);
+end;
+
+function ObjX(m: integer): integer; inline;
+begin
+  ObjX := ((m) and $01ff);
+end;
+
+function ObjRotScale(m: integer): integer; inline;
+begin
+  ObjRotScale := ((m) shl 9);
+end;
+
+function ObjSize(m: integer): integer; inline;
+begin
+  ObjSize := ((m) shl 14);
+end;
+
+function ObjChar(m: integer): integer; inline;
+begin
+  ObjChar := ((m) and $03ff);
+end;
+
+function ObjPriority(m: integer): integer; inline;
+begin
+  ObjPriority := ((m) shl 10);
+end;
+
+function ObjPalette(m: integer): integer; inline;
+begin
+  ObjPalette := ((m) shl 12);
+end;
+
+end.
+

+ 47 - 0
packages/extra/gbaunits/gba_timer.pas

@@ -0,0 +1,47 @@
+(*
+  gba_timer.pas 18/06/2006 4.29.04
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_timer;
+{$i def.inc}
+interface
+
+uses
+  gba_types, gba_regs;
+
+const
+  TIMER_COUNT = BIT2;
+  TIMER_IRQ	  = BIT6;
+  TIMER_START	= BIT7;
+
+implementation
+
+end.

+ 197 - 0
packages/extra/gbaunits/gba_types.pas

@@ -0,0 +1,197 @@
+(*
+  gba_types.pas 18/06/2006 4.38.46
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_types;
+{$i def.inc}
+interface
+
+type
+  (* Unsigned types *)
+  u8  = byte;
+  u16 = word;
+  u32 = dword;
+  pu8 = ^u8;
+  pu16 = ^u16;
+  pu32 = ^u32;
+  
+  (* Signed types *)
+  s8  = shortint;
+  s16 = smallint;
+  s32 = longint;
+  ps8 = ^s8;
+  ps16 = ^s16;
+  ps32 = ^s32;
+
+  BGAffineSource = record
+    x: longint;
+    y: longint;
+    tX: smallint;
+    tY: smallint;
+    sX: smallint;
+    sY: smallint;
+    theta: smallint;
+  end;
+  TBgAffineSource = BGAffineSource;
+  PBgAffineSource = ^TBgAffineSource;
+   
+  BGAffineDest = record
+    pa: smallint;
+    pb: smallint;
+    pc: smallint;
+    pd: smallint;
+    x: longint;
+    y: longint;
+  end;
+  TBgAffineDest = BGAffineDest;
+  PBgAffineDest = ^TBgAffineDest;
+
+  ObjAffineSource = record
+    sX: smallint;
+    sY: smallint;
+    theta: word;
+  end;
+  TObjAffineSource = ObjAffineSource;
+  PObjAffineSource = ^TObjAffineSource;
+
+  ObjAffineDest = record
+    pa: smallint;
+    pb: smallint;
+    pc: smallint;
+    pd: smallint;
+  end;
+  TObjAffineDest = ObjAffineDest;
+  PObjAffineDest = ^TObjAffineDest;
+
+  BUP = record
+    SrcNum: word;				  // Source Data Byte Size
+    SrcBitNum: byte;			  // 1 Source Data Bit Number
+    DestBitNum: byte;			  // 1 Destination Data Bit Number
+    DestOffset: dword;		  // Number added to Source Data
+    DestOffset0_On: dword;	// Flag to add/not add Offset to 0 Data
+  end;
+  TBUP = BUP;
+  PBUP = ^TBUP;
+
+  FIXED = longint;
+  TFixed = FIXED;
+  
+  COLOR = word;
+  TColor = COLOR;
+
+  
+  MultiBootParam = record 
+    reserved1: array [0..4] of dword;
+    handshake_data: byte;
+    padding: byte;
+    handshake_timeout: word;
+    probe_count: byte;
+    client_data: array [0..2] of byte;
+    palette_data: byte;
+    response_bit: byte;
+    client_bit: byte;
+    reserved2: byte;
+    boot_srcp: ^byte;
+    boot_endp: ^byte;
+    masterp: ^byte;
+    reserved3: array [0..2] of ^byte;
+    system_work2: array [0..3] of dword;
+    sendflag: byte;
+    probe_target_bit: byte;
+    check_wait: byte;
+    server_type: byte;
+  end;
+  TMultiBootParam = MultiBootParam;
+  PMultiBootParam = ^TMultiBootParam;
+  
+  MULTIBOOT_MODES = ( MODE32_NORMAL, MODE16_MULTI, MODE32_2MHZ);
+  TMultiBootModes = MULTIBOOT_MODES;
+  
+  DMA_MODES = (
+    FILL    = (1 shl 24),
+    COPY16  = (0 shl 26),
+    COPY32  = (1 shl 26)
+  );
+  TDMAModes = DMA_MODES;
+
+  KEYPAD_BITS = (
+    KEY_A       = (1 shl 0),
+    KEY_B       = (1 shl 1),
+    KEY_SELECT  = (1 shl 2),
+    KEY_START   = (1 shl 3),	
+    KEY_RIGHT   = (1 shl 4),
+    KEY_LEFT    = (1 shl 5),
+    KEY_UP      = (1 shl 6),
+    KEY_DOWN    = (1 shl 7),
+    KEY_R       = (1 shl 8),
+    KEY_L       = (1 shl 9),
+
+    KEYIRQ_ENABLE = (1 shl 14),
+    KEYIRQ_OR     = (0 shl 15),
+    KEYIRQ_AND    = (1 shl 15),
+    DPAD          = integer(KEY_UP) or integer(KEY_DOWN) or integer(KEY_LEFT) or integer(KEY_RIGHT)
+  );
+  TKeyPadBits = KEYPAD_BITS;
+  
+  OBJATTR = record
+    attr0: word;
+    attr1: word;
+    attr2: word;
+    dummy: word;
+  end;
+  TObjAttr = OBJATTR;
+  PObjAttr = ^TObjAttr;
+
+  OBJAFFINE = record
+    dummy0: array [0..2] of word;
+    pa: smallint;
+    dummy1: array [0..2] of word;
+    pb: smallint;
+    dummy2: array [0..2] of word;
+    pc: smallint;
+    dummy3: array [0..2] of word;
+    pd: smallint;
+  end;
+  TObjAffine = OBJAFFINE;
+  PObjAffine = ^TObjAffine;
+  
+  bg_scroll = record
+    x: word;
+    y: word;
+  end;
+  TBgScroll = bg_scroll;
+  PBgScroll = ^TBgScroll;  
+
+
+implementation
+
+
+end.

+ 284 - 0
packages/extra/gbaunits/gba_video.pas

@@ -0,0 +1,284 @@
+(*
+  gba_video.pas 18/06/2006 4.38.37
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+unit gba_video;
+{$i def.inc}
+
+interface
+
+uses 
+  gba_types, gba_regs;
+
+type
+  LCDC_IRQ = (
+    LCDC_VBL_FLAG   = (1 shl 0),
+    LCDC_HBL_FLAG   = (1 shl 1),
+    LCDC_VCNT_FLAG  = (1 shl 2),
+    LCDC_VBL        = (1 shl 3),
+    LCDC_HBL        = (1 shl 4),
+    LCDC_VCNT       = (1 shl 5)
+  );
+  TLCDCIRQ = LCDC_IRQ;
+  
+  BG_CTRL_BITS = (
+    BG_MOSAIC     = BIT6,
+    BG_16_COLOR		=	(0 shl 7),
+    BG_256_COLOR	=	BIT7,
+    BG_WRAP			=	BIT13,
+    BG_SIZE_0		=	(0 shl 14),
+    BG_SIZE_1		=	(1 shl 14),
+    BG_SIZE_2		=	(2 shl 14),
+    BG_SIZE_3		=	(3 shl 14)
+  );
+  TBgCTRLBits = BG_CTRL_BITS;
+  
+  NAMETABLE  = array [0..31, 0..31] of word;
+  TNameTable = NAMETABLE;
+  PNameTable = ^TNameTable;
+  
+  MODE3_LINE = array [0..239] of word;
+  TMODE3Line = MODE3_LINE;
+  
+  MODE5_LINE = array [0..159] of word;
+  TMODE5Line = MODE5_LINE;
+
+
+const
+  MODE_0	=	0;
+  MODE_1	=	1;
+  MODE_2	=	2;
+  MODE_3	=	3;
+  MODE_4	=	4;
+  MODE_5	=	5;
+  
+  BACKBUFFER	=	BIT4;
+  OBJ_1D_MAP	=	BIT6;
+  LCDC_OFF	=	BIT7;
+  BG0_ON		=	BIT8;
+  BG1_ON		=	BIT9;
+  BG2_ON		=	BIT10;
+  BG3_ON		=	BIT11;
+  OBJ_ON		=	BIT12;
+  WIN0_ON		=	BIT13;
+  WIN1_ON		=	BIT14;
+  OBJ_WIN_ON	=	BIT15;
+  
+  BG0_ENABLE		=	BG0_ON;
+  BG1_ENABLE		=	BG1_ON;
+  BG2_ENABLE		=	BG2_ON;
+  BG3_ENABLE		=	BG3_ON;
+  OBJ_ENABLE		=	OBJ_ON;
+  WIN0_ENABLE		=	WIN0_ON;
+  WIN1_ENABLE		=	WIN1_ON;
+  OBJ_WIN_ENABLE	=	BG0_ON;
+  
+  BG_ALL_ON		=	BG0_ON or BG1_ON or BG2_ON or BG3_ON;
+  BG_ALL_ENABLE	=	BG0_ON or BG1_ON or BG2_ON or BG3_ON;
+ 
+
+const
+  MAP : PNameTable = pointer($06000000);
+  BG_WID_32 = BG_SIZE_0;
+  BG_WID_64 = BG_SIZE_1;
+  BG_HT_32  = BG_SIZE_0;
+  BG_HT_64  = BG_SIZE_2;
+//---------------------------------------------------------------------------------
+// Symbolic names for the rot/scale map sizes
+//---------------------------------------------------------------------------------
+  ROTBG_SIZE_16  = BG_SIZE_0;
+  ROTBG_SIZE_32  = BG_SIZE_1;
+  ROTBG_SIZE_64  = BG_SIZE_2;
+  ROTBG_SIZE_128 = BG_SIZE_3;
+  MODE3_FB: ^TMODE3Line = pointer($06000000);
+  MODE5_FB: ^TMODE5Line = pointer($06000000);
+  MODE5_BB: ^TMODE5Line = pointer($0600A000);
+
+
+function VCount(m: integer): dword; inline;
+function BgSize(m: integer): integer; inline;
+function CharBase(m: integer): integer; inline;
+function CharBaseAdr(m: integer): integer; inline;
+function MapBaseAdr(m: integer): integer; inline;
+function ScreenBase(m: integer): integer; inline;
+function TileBase(m: integer): integer; inline;
+function TileBaseAdr(m: integer): integer; inline;
+function BgPriority(m: integer): integer; inline;
+function BgPalette(m: integer): integer; inline;
+function PatRAM4(x, tn: integer): dword; inline;
+function PatRAM8(x, tn: integer): dword; inline;
+function SprVRAM(tn: integer): dword; inline;
+
+
+procedure SetMode(mode: dword); inline;
+procedure Wait(count: dword);
+procedure WaitForVBlank(); inline;
+procedure WaitForVDraw(); inline;
+procedure VSync(); inline;
+function Flip(): pword;
+
+function RGB(r, g, b: integer): integer;
+function RGB5(r, g, b: integer): integer;
+function RGB8(r, g, b: integer): integer;
+
+implementation
+
+function VCount(m: integer): dword; inline;
+begin
+  VCount := m shl 8;
+end;
+
+function BgSize(m: integer): integer; inline;
+begin
+  BgSize := ((m shl 14));
+end;
+
+function CharBase(m: integer): integer; inline;
+begin
+  CharBase := ((m) shl 2);
+end;
+
+function CharBaseAdr(m: integer): integer; inline;
+begin
+  CharBaseAdr := ($6000000 + ((m) shl 14));
+end;
+
+function MapBaseAdr(m: integer): integer; inline;
+begin
+  MapBaseAdr := ($6000000 + ((m) shl 11));
+end;
+
+function ScreenBase(m: integer): integer; inline;
+begin
+  ScreenBase := ((m) shl 8);
+end;
+
+//alternate names for char and screen base
+function TileBase(m: integer): integer; inline;
+begin
+  TileBase := ((m) shl 2);
+end;
+
+function TileBaseAdr(m: integer): integer; inline;
+begin
+  TileBaseAdr := ($6000000 + ((m) shl 14));
+end;
+
+function BgPriority(m: integer): integer; inline;
+begin
+  BgPriority := (m);
+end;
+
+function BgPalette(m: integer): integer; inline;
+begin
+  BgPalette := ((m) shl 12);
+end;
+
+(*---------------------------------------------------------------------------------
+	CHAR_BASE_ADR() is the direct equivalent to old PATRAM(),
+	giving the base address of a chr bank.
+	These macros pinpoint the base address of a single tile.
+---------------------------------------------------------------------------------*)
+function PatRAM4(x, tn: integer): dword; inline;
+begin
+  PatRAM4 := (dword($6000000 or (((x) shl 14) + ((tn) shl 5)) ));
+end;
+
+function PatRAM8(x, tn: integer): dword; inline;
+begin
+  PatRAM8 := (dword($6000000 or (((x) shl 14) + ((tn) shl 6)) ));
+end;
+  
+function SprVRAM(tn: integer): dword; inline;
+begin
+  SprVRAM := (dword($6000000 or $10000 or ((tn) shl 5)));
+end;
+
+procedure SetMode(mode: dword); inline;
+begin
+  REG_DISPCNT^ := (mode);
+end;
+ 
+procedure Wait(count: dword);
+var
+  vline: word;
+begin
+	vline := REG_VCOUNT^;
+	dec(count);
+	while (count > 0) do
+	begin
+		while(vline = REG_VCOUNT^) do;
+		while(vline <> REG_VCOUNT^) do;
+		dec(count);
+	end;
+end;
+
+procedure WaitForVBlank(); inline;
+begin
+  while (REG_VCOUNT^ < 160) do
+end;
+
+procedure WaitForVDraw(); inline;
+begin
+ 	while (REG_VCOUNT^ >= 160) do
+end;
+
+// wait till the _next_ vblank
+// Note that for real work, using a VBlank interrupt is preferred
+procedure VSync(); inline;
+begin
+	WaitForVDraw();	
+  WaitForVBlank();
+end;
+
+function Flip(): pword;
+begin
+  VideoBuffer := pword(dword(VideoBuffer) or $0000A000);
+  REG_DISPCNT^ := REG_DISPCNT^ or $0010;
+  Flip := VideoBuffer;
+end;
+
+function RGB(r, g, b: integer): integer;
+begin
+  RGB := ((r) + (g shl 5) + (b shl 10)); 
+end;
+
+function RGB5(r, g, b: integer): integer;
+begin
+  RGB5 := ((r) or ((g) shl 5) or ((b) shl 10));
+end;
+
+function RGB8(r, g, b: integer): integer;
+begin
+  RGB8 := ( (((b) shr 3) shl 10) or (((g) shr 3) shl 5) or ((r) shr 3) );
+end;
+
+end.

+ 83 - 0
packages/extra/gbaunits/gba_window.pas

@@ -0,0 +1,83 @@
+(*
+  gba_window.pas  18/06/2006 4.40.07
+  ------------------------------------------------------------------------------
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+  ------------------------------------------------------------------------------
+*)
+
+unit gba_window;
+{$i def.inc}
+interface
+
+uses 
+  gba_types;
+
+const 
+  WIN_0_BG0 = (1 shl 0);
+  WIN_0_BG1 = (1 shl 1);
+  WIN_0_BG2 = (1 shl 2);
+  WIN_0_BG3 = (1 shl 3);
+  WIN_0_OBJ = (1 shl 4);
+  WIN_0_SPE = (1 shl 5);
+  WIN_1_BG0 = (1 shl 8);
+  WIN_1_BG1 = (1 shl 9);
+  WIN_1_BG2 = (1 shl 10);
+  WIN_1_BG3 = (1 shl 11);
+  WIN_1_OBJ = (1 shl 12);
+  WIN_1_SPE = (1 shl 13);
+
+function WinRight(x: dword): dword;
+function WinLeft(x: dword): dword;
+function WinDown(x: dword): dword;
+function WinTop(x: dword): dword;
+
+
+implementation
+
+function WinRight(x: dword): dword;
+begin
+  WinRight := (x shl 0);
+end;
+
+function WinLeft(x: dword): dword;
+begin
+  WinLeft := (x shl 8);
+end;
+
+function WinDown(x: dword): dword;
+begin
+  WinDown := (x shl 0);
+end;
+
+function WinTop(x: dword): dword;
+begin
+  WinTop := (x shl 8);
+end;
+
+end.

+ 504 - 0
packages/extra/gbaunits/lgpl.txt

@@ -0,0 +1,504 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+

+ 51 - 0
packages/extra/gbaunits/libGBA4fpc.txt

@@ -0,0 +1,51 @@
+libGba[4fpc] (ver. 0.1.5)
+------------
+
+  This lib is a raw porting of libgba library for gba (you can find it at
+  http://www.devkitpro.org).
+  
+  As this is a direct port from c, I'm pretty sure that something could not work
+  as you expect. I am even more sure that this code could be written better, so 
+  if you think that I have made some mistakes or you have some better 
+  implemented functions, let me know [francky74 (at) gmail (dot) com]
+  Enjoy!
+
+  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
+  (http://www.freepascal.org)
+  
+  Copyright (C) 2006  Francesco Lombardi
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+  
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+
+History
+-------
+ver. 0.1.5 - Removed useless optimization switches.
+
+ver. 0.1.4 - Changed var declaration to standard types, to be freepascal 
+             consistent.
+
+ver. 0.1.3 - Changed naming convention, to be more pascal standard.
+
+ver. 0.1.2 - Added fading routines; added lgpl license and header.
+
+ver. 0.1.1 - Added some inlning and macros.
+
+ver. 0.1.0 - Major rewritting (units based on libgba from devkitPro).
+
+ver. 0.0.2 - Added some other units (window, mosaic, timer, dma, blend); 
+             moved some functions in more sigificant places.
+
+ver. 0.0.1 - First raw port.