Browse Source

* gbaunits moved

git-svn-id: trunk@10034 -
marco 17 years ago
parent
commit
89108ccf3c

+ 24 - 25
.gitattributes

@@ -1091,31 +1091,6 @@ packages/extra/amunits/utilunits/tagsarray.pas svneol=native#text/plain
 packages/extra/amunits/utilunits/timerutils.pas svneol=native#text/plain
 packages/extra/amunits/utilunits/vartags.pas svneol=native#text/plain
 packages/extra/amunits/utilunits/wbargs.pas 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/gnome1/Makefile svneol=native#text/plain
 packages/extra/gnome1/Makefile.fpc svneol=native#text/plain
 packages/extra/gnome1/fpmake.pp svneol=native#text/plain
@@ -2724,6 +2699,30 @@ packages/fv/src/unixsmsg.inc svneol=native#text/plain
 packages/fv/src/validate.pas svneol=native#text/plain
 packages/fv/src/views.pas svneol=native#text/plain
 packages/fv/src/w32smsg.inc svneol=native#text/plain
+packages/gbaunits/Makefile svneol=native#text/plain
+packages/gbaunits/Makefile.fpc svneol=native#text/plain
+packages/gbaunits/fpmake.pp svneol=native#text/plain
+packages/gbaunits/lgpl.txt svneol=native#text/plain
+packages/gbaunits/libGBA4fpc.txt svneol=native#text/plain
+packages/gbaunits/src/bios_asm.as svneol=native#text/plain
+packages/gbaunits/src/core_asm.as svneol=native#text/plain
+packages/gbaunits/src/def.inc svneol=native#text/plain
+packages/gbaunits/src/gba_bg.pas svneol=native#text/plain
+packages/gbaunits/src/gba_bios.pas svneol=native#text/plain
+packages/gbaunits/src/gba_blend.pas svneol=native#text/plain
+packages/gbaunits/src/gba_core.pas svneol=native#text/plain
+packages/gbaunits/src/gba_dma.pas svneol=native#text/plain
+packages/gbaunits/src/gba_fade.pas svneol=native#text/plain
+packages/gbaunits/src/gba_input.pas svneol=native#text/plain
+packages/gbaunits/src/gba_irq.pas svneol=native#text/plain
+packages/gbaunits/src/gba_mosaic.pas svneol=native#text/plain
+packages/gbaunits/src/gba_regs.pas svneol=native#text/plain
+packages/gbaunits/src/gba_sio.pas svneol=native#text/plain
+packages/gbaunits/src/gba_sprites.pas svneol=native#text/plain
+packages/gbaunits/src/gba_timer.pas svneol=native#text/plain
+packages/gbaunits/src/gba_types.pas svneol=native#text/plain
+packages/gbaunits/src/gba_video.pas svneol=native#text/plain
+packages/gbaunits/src/gba_window.pas svneol=native#text/plain
 packages/gdbint/Makefile svneol=native#text/plain
 packages/gdbint/Makefile.fpc svneol=native#text/plain
 packages/gdbint/fpmake.pp svneol=native#text/plain

+ 0 - 1
.gitignore

@@ -592,7 +592,6 @@ packages/extra/amunits/utilunits/*.s
 packages/extra/amunits/utilunits/fpcmade.*
 packages/extra/amunits/utilunits/units
 packages/extra/fpcmade.*
-packages/extra/gbaunits/*.bat
 packages/extra/gnome1/*.bak
 packages/extra/gnome1/*.exe
 packages/extra/gnome1/*.o

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

@@ -1,26 +0,0 @@
-    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;

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

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

+ 325 - 7
packages/extra/gbaunits/Makefile → packages/gbaunits/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/11/08]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/01/26]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
@@ -100,7 +100,7 @@ export ECHO
 endif
 override OS_TARGET_DEFAULT=gba
 override CPU_TARGET_DEFAULT=arm
-override DEFAULT_FPCDIR=../../..
+override DEFAULT_FPCDIR=../..
 ifndef FPC
 ifdef PP
 FPC=$(PP)
@@ -722,6 +722,324 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 override COMPILER_OPTIONS+=-CX
 endif
+ifeq ($(FULL_TARGET),i386-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
 ifdef REQUIRE_UNITSDIR
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 endif
@@ -1650,7 +1968,7 @@ else
 	$(INSTALL) $(LOADEROFILES) $(INSTALL_UNITDIR)
 endif
 .PHONY: fpc_units
-ifneq ($(TARGET_UNITS),)
+ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),)
 override ALLTARGET+=fpc_units
 override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
 override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
@@ -2090,7 +2408,7 @@ ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 endif
 .NOTPARALLEL:
-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
+core_asm$(OEXT):src/core_asm.as
+	$(AS) -o $(UNITTARGETDIRPREFIX)core_asm$(OEXT) src/core_asm.as
+bios_asm$(OEXT):src/bios_asm.as
+	$(AS) -o $(UNITTARGETDIRPREFIX)bios_asm$(OEXT) src/bios_asm.as

+ 36 - 34
packages/extra/gbaunits/Makefile.fpc → packages/gbaunits/Makefile.fpc

@@ -1,35 +1,37 @@
-#
-#   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
-
+#
+#   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
+includedir=src
+sourcedir=src tests
+
+[install]
+fpcpackage=y
+#prefix=d:/fpc4gba
+
+[default]
+cpu=arm
+target=gba
+fpcdir=../..
+
+[require]
+nortl=y
+
 [rules]
-.NOTPARALLEL:
-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
+.NOTPARALLEL:
+core_asm$(OEXT):src/core_asm.as
+        $(AS) -o $(UNITTARGETDIRPREFIX)core_asm$(OEXT) src/core_asm.as
+bios_asm$(OEXT):src/bios_asm.as
+        $(AS) -o $(UNITTARGETDIRPREFIX)bios_asm$(OEXT) src/bios_asm.as

+ 29 - 0
packages/gbaunits/fpmake.pp

@@ -0,0 +1,29 @@
+{$ifndef ALLPACKAGES}
+{$mode objfpc}{$H+}
+program fpmake;
+
+uses fpmkunit;
+
+Var
+  P : TPackage;
+  T : TTarget;
+begin
+  With Installer do
+    begin
+{$endif ALLPACKAGES}
+
+    P:=AddPackage('gbaunits');
+{$ifdef ALLPACKAGES}
+    P.Directory:='gbaunits';
+{$endif ALLPACKAGES}
+    P.Version:='2.0.0';
+    P.SourcePath.Add('src');
+//    P.Dependencies.Add('x11');
+
+    /// can't compile -> no deps.
+
+{$ifndef ALLPACKAGES}
+    Run;
+    end;
+end.
+{$endif ALLPACKAGES}

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

@@ -1,504 +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!
-
-
+		  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 - 51
packages/extra/gbaunits/libGBA4fpc.txt → packages/gbaunits/libGBA4fpc.txt

@@ -1,51 +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.
+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.

+ 329 - 329
packages/extra/gbaunits/bios_asm.as → packages/gbaunits/src/bios_asm.as

@@ -1,329 +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
+@ 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 - 237
packages/extra/gbaunits/core_asm.as → packages/gbaunits/src/core_asm.as

@@ -1,237 +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
+@   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 - 37
packages/extra/gbaunits/def.inc → packages/gbaunits/src/def.inc

@@ -1,37 +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}
+(*
+  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}

+ 159 - 159
packages/extra/gbaunits/gba_bg.pas → packages/gbaunits/src/gba_bg.pas

@@ -1,159 +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.
-
+(*
+  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 - 80
packages/extra/gbaunits/gba_bios.pas → packages/gbaunits/src/gba_bios.pas

@@ -1,80 +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.
+(*
+  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 - 92
packages/extra/gbaunits/gba_blend.pas → packages/gbaunits/src/gba_blend.pas

@@ -1,92 +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.
+(*
+  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.

+ 105 - 105
packages/extra/gbaunits/gba_core.pas → packages/gbaunits/src/gba_core.pas

@@ -1,105 +1,105 @@
-(*
-  gba_core.pas  01/09/2006 19.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;
-function gbaRand(value: integer): 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;
-
-function gbaRand(value: integer): dword;
-var
-  a: dword;
-begin	
-	gbaRandSeed := QRAN_A * gbaRandSeed + QRAN_C;
-	a := (gbaRandSeed shr 16) and QRAN_MAX;
-  gbaRand := (a * value) shr 15;
-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.
+(*
+  gba_core.pas  01/09/2006 19.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;
+function gbaRand(value: integer): 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;
+
+function gbaRand(value: integer): dword;
+var
+  a: dword;
+begin	
+	gbaRandSeed := QRAN_A * gbaRandSeed + QRAN_C;
+	a := (gbaRandSeed shr 16) and QRAN_MAX;
+  gbaRand := (a * value) shr 15;
+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 - 150
packages/extra/gbaunits/gba_dma.pas → packages/gbaunits/src/gba_dma.pas

@@ -1,150 +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.
+(*
+  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 - 203
packages/extra/gbaunits/gba_fade.pas → packages/gbaunits/src/gba_fade.pas

@@ -1,203 +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.
+(*
+  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.

+ 172 - 172
packages/extra/gbaunits/gba_input.pas → packages/gbaunits/src/gba_input.pas

@@ -1,172 +1,172 @@
-(*
-  gba_input.pas 01/09/2006 19.57.16
-  ------------------------------------------------------------------------------
-  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;
-
-
-
-const
-  KEY_A: TKeyPadBits       = (1 shl 0);
-  KEY_B: TKeyPadBits       = (1 shl 1);
-  KEY_SELECT: TKeyPadBits  = (1 shl 2);
-  KEY_START: TKeyPadBits   = (1 shl 3);	
-  KEY_RIGHT: TKeyPadBits   = (1 shl 4);
-  KEY_LEFT: TKeyPadBits    = (1 shl 5);
-  KEY_UP: TKeyPadBits      = (1 shl 6);
-  KEY_DOWN: TKeyPadBits    = (1 shl 7);
-  KEY_R: TKeyPadBits       = (1 shl 8);
-  KEY_L: TKeyPadBits       = (1 shl 9);
-
-  KEYIRQ_ENABLE: TKeyPadBits = (1 shl 14);
-  KEYIRQ_OR: TKeyPadBits     = (0 shl 15);
-  KEYIRQ_AND: TKeyPadBits    = (1 shl 15);
-  DPAD: TKeyPadBits          = (1 shl 6) or (1 shl 7) or (1 shl 5) or (1 shl 4);
-
-
-
-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.
+(*
+  gba_input.pas 01/09/2006 19.57.16
+  ------------------------------------------------------------------------------
+  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;
+
+
+
+const
+  KEY_A: TKeyPadBits       = (1 shl 0);
+  KEY_B: TKeyPadBits       = (1 shl 1);
+  KEY_SELECT: TKeyPadBits  = (1 shl 2);
+  KEY_START: TKeyPadBits   = (1 shl 3);	
+  KEY_RIGHT: TKeyPadBits   = (1 shl 4);
+  KEY_LEFT: TKeyPadBits    = (1 shl 5);
+  KEY_UP: TKeyPadBits      = (1 shl 6);
+  KEY_DOWN: TKeyPadBits    = (1 shl 7);
+  KEY_R: TKeyPadBits       = (1 shl 8);
+  KEY_L: TKeyPadBits       = (1 shl 9);
+
+  KEYIRQ_ENABLE: TKeyPadBits = (1 shl 14);
+  KEYIRQ_OR: TKeyPadBits     = (0 shl 15);
+  KEYIRQ_AND: TKeyPadBits    = (1 shl 15);
+  DPAD: TKeyPadBits          = (1 shl 6) or (1 shl 7) or (1 shl 5) or (1 shl 4);
+
+
+
+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 - 70
packages/extra/gbaunits/gba_irq.pas → packages/gbaunits/src/gba_irq.pas

@@ -1,70 +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.
-
+(*
+  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 - 68
packages/extra/gbaunits/gba_mosaic.pas → packages/gbaunits/src/gba_mosaic.pas

@@ -1,68 +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.
+(*
+  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 - 269
packages/extra/gbaunits/gba_regs.pas → packages/gbaunits/src/gba_regs.pas

@@ -1,269 +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.
+(*
+  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 - 95
packages/extra/gbaunits/gba_sio.pas → packages/gbaunits/src/gba_sio.pas

@@ -1,95 +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.
+(*
+  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 - 149
packages/extra/gbaunits/gba_sprites.pas → packages/gbaunits/src/gba_sprites.pas

@@ -1,149 +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.
-
+(*
+  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 - 47
packages/extra/gbaunits/gba_timer.pas → packages/gbaunits/src/gba_timer.pas

@@ -1,47 +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.
+(*
+  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.

+ 181 - 181
packages/extra/gbaunits/gba_types.pas → packages/gbaunits/src/gba_types.pas

@@ -1,181 +1,181 @@
-(*
-  gba_types.pas 01/09/2006 19.57.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 = integer;
-  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.
+(*
+  gba_types.pas 01/09/2006 19.57.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 = integer;
+  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 - 284
packages/extra/gbaunits/gba_video.pas → packages/gbaunits/src/gba_video.pas

@@ -1,284 +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(const r, g, b: word): word;inline;
-function RGB5(const r, g, b: word): word;inline;
-function RGB8(const r, g, b: word): word;inline;
-
-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(const r, g, b: word): word;inline;
-begin
-  RGB := ((r) + (g shl 5) + (b shl 10));
-end;
-
-function RGB5(const r, g, b: word): word;inline;
-begin
-  RGB5 := ((r) or ((g) shl 5) or ((b) shl 10));
-end;
-
-function RGB8(const r, g, b: word): word;inline;
-begin
-  RGB8 := ( (((b) shr 3) shl 10) or (((g) shr 3) shl 5) or ((r) shr 3) );
-end;
-
-end.
+(*
+  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(const r, g, b: word): word;inline;
+function RGB5(const r, g, b: word): word;inline;
+function RGB8(const r, g, b: word): word;inline;
+
+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(const r, g, b: word): word;inline;
+begin
+  RGB := ((r) + (g shl 5) + (b shl 10));
+end;
+
+function RGB5(const r, g, b: word): word;inline;
+begin
+  RGB5 := ((r) or ((g) shl 5) or ((b) shl 10));
+end;
+
+function RGB8(const r, g, b: word): word;inline;
+begin
+  RGB8 := ( (((b) shr 3) shl 10) or (((g) shr 3) shl 5) or ((r) shr 3) );
+end;
+
+end.

+ 83 - 83
packages/extra/gbaunits/gba_window.pas → packages/gbaunits/src/gba_window.pas

@@ -1,83 +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.
+(*
+  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.