Răsfoiți Sursa

* Updated libndsfpc and nds linkerscript to Ver. 1.5.8

git-svn-id: trunk@28299 -
Legolas 11 ani în urmă
părinte
comite
a52e51d0b7
39 a modificat fișierele cu 284 adăugiri și 138 ștergeri
  1. 61 73
      compiler/systems/t_nds.pas
  2. 1 0
      packages/Makefile.fpc.fpcmake
  3. 4 0
      packages/libndsfpc/examples/audio/maxmod/audio_modes/Makefile.fpc
  4. 3 0
      packages/libndsfpc/examples/audio/maxmod/reverb/Makefile.fpc
  5. 1 1
      packages/libndsfpc/examples/audio/maxmod/song_events_example/Makefile.fpc
  6. 3 0
      packages/libndsfpc/examples/audio/maxmod/song_events_example2/Makefile.fpc
  7. 3 0
      packages/libndsfpc/examples/audio/micrecord/Makefile.fpc
  8. 3 0
      packages/libndsfpc/examples/card/eeprom/Makefile.fpc
  9. 3 0
      packages/libndsfpc/examples/debugging/exceptionTest/Makefile.fpc
  10. 3 0
      packages/libndsfpc/examples/ds_motion/Makefile.fpc
  11. 3 0
      packages/libndsfpc/examples/dswifi/ap_search/Makefile.fpc
  12. 3 0
      packages/libndsfpc/examples/dswifi/autoconnect/Makefile.fpc
  13. 3 0
      packages/libndsfpc/examples/dswifi/httpget/Makefile.fpc
  14. 1 1
      packages/libndsfpc/examples/filesystem/embedded_gbfs/Makefile.fpc
  15. 1 2
      packages/libndsfpc/examples/filesystem/libfat/access_dir/Makefile.fpc
  16. 1 2
      packages/libndsfpc/examples/filesystem/libfat/access_file/Makefile.fpc
  17. 1 2
      packages/libndsfpc/examples/filesystem/libfat/libfatdir/Makefile.fpc
  18. 1 2
      packages/libndsfpc/examples/filesystem/nitrofs/nitrodir/Makefile.fpc
  19. 1 1
      packages/libndsfpc/examples/filesystem/nitrofs/nitrodir/nitrodir.pp
  20. 75 9
      packages/libndsfpc/examples/hello_world/Makefile.fpc
  21. 3 0
      packages/libndsfpc/examples/input/Touch_Pad/touch_area/Makefile.fpc
  22. 1 2
      packages/libndsfpc/examples/input/Touch_Pad/touch_look/Makefile.fpc
  23. 1 2
      packages/libndsfpc/examples/input/Touch_Pad/touch_test/Makefile.fpc
  24. 3 0
      packages/libndsfpc/examples/input/keyboard/keyboard_async/Makefile.fpc
  25. 3 0
      packages/libndsfpc/examples/input/keyboard/keyboard_stdin/Makefile.fpc
  26. 3 0
      packages/libndsfpc/examples/time/RealTimeClock/Makefile.fpc
  27. 3 0
      packages/libndsfpc/examples/time/stopwatch/Makefile.fpc
  28. 3 0
      packages/libndsfpc/examples/time/timercallback/Makefile.fpc
  29. 7 5
      packages/libndsfpc/src/dswifi/inc/dswifi9.inc
  30. 2 2
      packages/libndsfpc/src/dswifi/inc/dswifi_version.inc
  31. 2 0
      packages/libndsfpc/src/fat/fat.inc
  32. 1 1
      packages/libndsfpc/src/fat/filesystem.inc
  33. 16 0
      packages/libndsfpc/src/nds/arm9/background.inc
  34. 26 0
      packages/libndsfpc/src/nds/arm9/math.inc
  35. 5 26
      packages/libndsfpc/src/nds/arm9/videoGL.inc
  36. 2 2
      packages/libndsfpc/src/nds/libversion.inc
  37. 1 0
      packages/libndsfpc/src/nds/nds.inc
  38. 3 2
      rtl/nds/system.pp
  39. 24 3
      rtl/nds/sysutils.pp

+ 61 - 73
compiler/systems/t_nds.pas

@@ -243,20 +243,19 @@ begin
     begin
       if apptype=app_arm9 then //ARM9
       begin
-        add('OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")');
-        add('OUTPUT_ARCH(arm)');
-        add('ENTRY(_start)');
-        add('');
         add('MEMORY {');
-        add('');
         add('	rom	: ORIGIN = 0x08000000, LENGTH = 32M');
         add('	ewram	: ORIGIN = 0x02000000, LENGTH = 4M - 4k');
         add('	dtcm	: ORIGIN = 0x0b000000, LENGTH = 16K');
-        add('	vectors : ORIGIN = 0x01000000, LENGTH = 256');
-        add('	itcm    : ORIGIN = 0x01000100, LENGTH = 32K - 256');
+        add('	vectors	: ORIGIN = 0x01000000, LENGTH = 256');
+        add('	itcm	: ORIGIN = 0x01000100, LENGTH = 32K - 256');
         add('}');
         add('');
-        add('__vectors_start = ORIGIN(vectors);');
+        add('OUTPUT_ARCH(arm)');
+        add('OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")');
+        add('ENTRY(_start)');
+        add('');
+        add('__vectors_start	=	ORIGIN(vectors);');
         add('__itcm_start	=	ORIGIN(itcm);');
         add('__ewram_end	=	ORIGIN(ewram) + LENGTH(ewram);');
         add('__eheap_end	=	ORIGIN(ewram) + LENGTH(ewram);');
@@ -276,7 +275,7 @@ begin
         add('		__text_start = . ;');
         add('		KEEP (*(.init))');
         add('		. = ALIGN(4);  /* REQUIRED. LD is flaky without it. */');
-        add('		} >ewram = 0xff');
+        add('	} >ewram = 0xff');
         add('');
         add('	.plt : { *(.plt) } >ewram = 0xff');
         add('');
@@ -312,36 +311,40 @@ begin
         add('		. = ALIGN(4);   /* REQUIRED. LD is flaky without it. */');
         add('	} >ewram = 0xff');
         add('');
-        add('  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ewram');
-        add('   __exidx_start = .;');
-        add('  .ARM.exidx   : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ewram');
-        add('   __exidx_end = .;');
-        add('  /* Ensure the __preinit_array_start label is properly aligned.  We');
-        add('     could instead move the label definition inside the section, but');
-        add('     the linker would then create the section even if it turns out to');
-        add('     be empty, which isn''t pretty.  */');
-        add('  . = ALIGN(32 / 8);');
-        add('  PROVIDE (__preinit_array_start = .);');
-        add('  .preinit_array     : { KEEP (*(.preinit_array)) } >ewram = 0xff');
-        add('  PROVIDE (__preinit_array_end = .);');
-        add('  PROVIDE (__init_array_start = .);');
-        add('  .init_array     :');
-        add('  {');
-        add('       KEEP (*(SORT(.init_array.*)))');
-        add('       KEEP (*(.init_array))');
-        add('  } >ewram = 0xff');        
-        add('  PROVIDE (__init_array_end = .);');
-        add('  PROVIDE (__fini_array_start = .);');
-        add('  .fini_array     :');
-        add('  {');
-        add('       KEEP (*(.fini_array))');
-        add('       KEEP (*(SORT(.fini_array.*)))');
-        add('  } >ewram = 0xff');
-        add('  PROVIDE (__fini_array_end = .);');
+        add('	.ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ewram');
+        add(' 	__exidx_start = .;');
+        add('	ARM.exidx   : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ewram');
+        add(' 	__exidx_end = .;');
+        add('');
+        add('	/*	Ensure the __preinit_array_start label is properly aligned.  We');
+        add('		could instead move the label definition inside the section, but');
+        add('		the linker would then create the section even if it turns out to');
+        add('		be empty, which isn''t pretty.  */');
+        add('');
+        add('	. = ALIGN(32 / 8);');
+        add('');
+        add('	PROVIDE (__preinit_array_start = .);');
+        add('	.preinit_array     : { KEEP (*(.preinit_array)) } >ewram = 0xff');
+        add('	PROVIDE (__preinit_array_end = .);');
+        add('	PROVIDE (__init_array_start = .);');
+        add('	.init_array     :');
+        add('	{');
+        add('		KEEP (*(SORT(.init_array.*)))');
+        add('		KEEP (*(.init_array))');
+        add('	} >ewram = 0xff');
+        add('	PROVIDE (__init_array_end = .);');
+        add('	PROVIDE (__fini_array_start = .);');
+        add('	.fini_array     :');
+        add('	{');
+        add('		KEEP (*(.fini_array))');
+        add('		KEEP (*(SORT(.fini_array.*)))');
+        add('	} >ewram = 0xff');
+        add('');
+        add('	PROVIDE (__fini_array_end = .);');
         add('');
         add('	.ctors :');
         add('	{');
-        add('	/* gcc uses crtbegin.o to find the start of the constructors, so');
+        add('	/*	gcc uses crtbegin.o to find the start of the constructors, so');
         add('		we make sure it is first.  Because this is a wildcard, it');
         add('		doesn''t matter if the user does not actually link against');
         add('		crtbegin.o; the linker won''t look for a file to match a');
@@ -392,7 +395,6 @@ begin
         add('		*(.data)');
         add('		*(.data.*)');
         add('		*(.gnu.linkonce.d*)');
-        add('		*(.fpc*)');
         add('		CONSTRUCTORS');
         add('		. = ALIGN(4);');
         add('		__data_end = ABSOLUTE(.) ;');
@@ -408,7 +410,7 @@ begin
         add('		*(.dtcm.*)');
         add('		. = ALIGN(4);');
         add('		__dtcm_end = ABSOLUTE(.);');
-        add('	} >dtcm = 0xff');
+        add('	} >dtcm  = 0xff');
         add('');
         add('');
         add('	__itcm_lma = __dtcm_lma + SIZEOF(.dtcm);');
@@ -420,29 +422,27 @@ begin
         add('		. = ALIGN(4);');
         add('		__itcm_end = ABSOLUTE(.);');
         add('	} >itcm = 0xff');
+        add('	');
+        add('	__vectors_lma = __itcm_lma + SIZEOF(.itcm);');
         add('');
-
-        add(' __vectors_lma = __itcm_lma + SIZEOF(.itcm);');
-        add(' .vectors __vectors_start : AT (__vectors_lma)');
-        add(' {');
-        add('   *(.vectors)');
-        add('   *vectors.*(.text)');
-        add('   . = ALIGN(4);');
-        add('   __vectors_end = ABSOLUTE(.);');
-        add(' } >vectors = 0xff');
-        add('');
-        add(' .sbss __dtcm_end (NOLOAD):');
+        add('	.vectors __vectors_start : AT (__vectors_lma)');
+        add('	{');
+        add('		*(.vectors)');
+        add('		*vectors.*(.text)');
+        add('		. = ALIGN(4);');
+        add('		__vectors_end = ABSOLUTE(.);');
+        add('	} >vectors = 0xff');
+        add('	');
+        add('	.sbss __dtcm_end (NOLOAD): ');
         add('	{');
         add('		__sbss_start = ABSOLUTE(.);');
         add('		__sbss_start__ = ABSOLUTE(.);');
         add('		*(.sbss)');
         add('		. = ALIGN(4);    /* REQUIRED. LD is flaky without it. */');
         add('		__sbss_end = ABSOLUTE(.);');
-        add('	} >dtcm');
-        add('');
-        add('');
+        add('	} >dtcm ');
         add('');
-        add('	.bss __bss_vma (NOLOAD):');
+        add('	.bss __bss_vma (NOLOAD): ');
         add('	{');
         add('		__bss_start = ABSOLUTE(.);');
         add('		__bss_start__ = ABSOLUTE(.);');
@@ -453,7 +453,8 @@ begin
         add('		. = ALIGN(4);    /* REQUIRED. LD is flaky without it. */');
         add('		__bss_end__ = ABSOLUTE(.) ;');
         add('		__end__ = ABSOLUTE(.) ;');
-        add('	} AT>ewram');
+        add('	} AT>ewram ');
+        add('');
         add('');
         add('');
         add('	/* Stabs debugging sections.  */');
@@ -492,6 +493,7 @@ begin
         add('	.stack 0x80000 : { _stack = .; *(.stack) }');
         add('	/* These must appear regardless of  .  */');
         add('}');
+        add('');
       end;
       if apptype=app_arm7 then
       begin
@@ -501,12 +503,13 @@ begin
         add('');
         add('MEMORY {');
         add('');
-        add('	rom	  : ORIGIN = 0x08000000, LENGTH = 32M');
-        add('	iwram : ORIGIN = 0x037f8000, LENGTH = 96K');
+        add('	rom	: ORIGIN = 0x08000000, LENGTH = 32M');
+        add('	iwram	: ORIGIN = 0x037f8000, LENGTH = 96K	');
         add('}');
         add('');
         add('__iwram_start	=	ORIGIN(iwram);');
         add('__iwram_top	=	ORIGIN(iwram)+ LENGTH(iwram);');
+        add('');
         add('__sp_irq	=	__iwram_top - 0x100;');
         add('__sp_svc	=	__sp_irq - 0x100;');
         add('__sp_usr	=	__sp_svc - 0x100;');
@@ -527,9 +530,8 @@ begin
         add('');
         add('	.text :   /* ALIGN (4): */');
         add('	{');
-        add('');
-        add('   *(.text .stub .text.* .gnu.linkonce.t.*)');
-        add('   KEEP (*(.text.*personality*))');        
+        add('		*(.text .stub .text.* .gnu.linkonce.t.*)');
+        add('		KEEP (*(.text.*personality*))');
         add('		/* .gnu.warning sections are handled specially by elf32.em.  */');
         add('		*(.gnu.warning)');
         add('		*(.glue_7t) *(.glue_7) *(.vfp11_veneer)');
@@ -612,30 +614,16 @@ begin
         add('	.jcr            : { KEEP (*(.jcr)) } >iwram = 0');
         add('	.got            : { *(.got.plt) *(.got) } >iwram = 0');
         add('');
-        add('');
-        add('	.iwram ALIGN(4) :');
-        add('	{');
-        add('		__iwram_start = ABSOLUTE(.) ;');
-        add('		*(.iwram)');
-        add('		*iwram.*(.text)');
-        add('		. = ALIGN(4);   /* REQUIRED. LD is flaky without it. */');
-        add('		__iwram_end = ABSOLUTE(.) ;');
-        add('	} >iwram = 0xff');
-        add('');
-        add('');
         add('	.data ALIGN(4) : 	{');
         add('		__data_start = ABSOLUTE(.);');
         add('		*(.data)');
         add('		*(.data.*)');
         add('		*(.gnu.linkonce.d*)');
-        add('		*(.fpc*)');
         add('		CONSTRUCTORS');
         add('		. = ALIGN(4);');
         add('		__data_end = ABSOLUTE(.) ;');
         add('	} >iwram = 0xff');
         add('');
-        add('');
-        add('');
         add('	.bss ALIGN(4) :');
         add('	{');
         add('		__bss_start = ABSOLUTE(.);');

+ 1 - 0
packages/Makefile.fpc.fpcmake

@@ -65,6 +65,7 @@ dirs_go32v2=rtl-console fv graph unzip gdbint
 dirs_amiga=amunits
 dirs_morphos=rtl-console fv opengl sdl
 dirs_wii=libogcfpc
+dirs_arm_nds=libndsfpc
 
 [install]
 fpcpackage=y

+ 4 - 0
packages/libndsfpc/examples/audio/maxmod/audio_modes/Makefile.fpc

@@ -14,6 +14,10 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/audio/maxmod/reverb/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 1 - 1
packages/libndsfpc/examples/audio/maxmod/song_events_example/Makefile.fpc

@@ -20,7 +20,7 @@ target=nds
 fpcdir=../../../../../..
 
 [compiler]
-options=-g -Xm
+options=-Xm
 #-d__THUMB__
 
 [clean]

+ 3 - 0
packages/libndsfpc/examples/audio/maxmod/song_events_example2/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/audio/micrecord/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/card/eeprom/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/debugging/exceptionTest/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/ds_motion/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/dswifi/ap_search/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/dswifi/autoconnect/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/dswifi/httpget/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 1 - 1
packages/libndsfpc/examples/filesystem/embedded_gbfs/Makefile.fpc

@@ -20,7 +20,7 @@ target=nds
 fpcdir=../../../../..
 
 [compiler]
-options=-g -Xm -O2
+options=-Xm
 #-d__THUMB__
 
 [clean]

+ 1 - 2
packages/libndsfpc/examples/filesystem/libfat/access_dir/Makefile.fpc

@@ -20,8 +20,7 @@ target=nds
 fpcdir=../../../../../..
 
 [compiler]
-options=-g -Xm -O2
-#-d__THUMB__
+options=-Xm 
 
 [clean]
 files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \

+ 1 - 2
packages/libndsfpc/examples/filesystem/libfat/access_file/Makefile.fpc

@@ -20,8 +20,7 @@ target=nds
 fpcdir=../../../../../..
 
 [compiler]
-options=-g -Xm -O2
-#-d__THUMB__
+options=-Xm 
 
 [clean]
 files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \

+ 1 - 2
packages/libndsfpc/examples/filesystem/libfat/libfatdir/Makefile.fpc

@@ -20,8 +20,7 @@ target=nds
 fpcdir=../../../../../..
 
 [compiler]
-options=-g -Xm -O2
-#-d__THUMB__
+options=-Xm 
 
 [clean]
 files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \

+ 1 - 2
packages/libndsfpc/examples/filesystem/nitrofs/nitrodir/Makefile.fpc

@@ -20,8 +20,7 @@ target=nds
 fpcdir=../../../../../..
 
 [compiler]
-options=-Xm -O2 
-#-d__THUMB__
+options=-Xm 
 
 [clean]
 files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \

+ 1 - 1
packages/libndsfpc/examples/filesystem/nitrofs/nitrodir/nitrodir.pp

@@ -63,7 +63,7 @@ begin
   // Initialise the console, required for printf
   consoleDemoInit();
    
-  if (nitroFSInit()) then
+  if nitroFSInit(nil) then
   begin
     dirlist('/');
     begin

+ 75 - 9
packages/libndsfpc/examples/hello_world/Makefile.fpc

@@ -8,39 +8,105 @@ programs=helloWorld
 
 [require]
 packages=libndsfpc
-tools=bin2s mmutil grit
+tools=bin2s mmutil grit rmdir ndstool
 nortl=y
 
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds
 fpcdir=../../../..
 
 [clean]
-files=*.elf *.o *.s *.nds *.nef *.h *.bin \
-       $(BUILD)/*
+files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \
+       $(BUILD)/* \
+       $(INC)/*
 units=*
 
 [prerules]
 BUILD = build
+INC = inc
 AUDIO_FILES = $(foreach dir,$(notdir $(wildcard audio/*.*)),$(CURDIR)/audio/$(dir))
 GFX_FILES = $(foreach dir,gfx,$(notdir $(wildcard $(dir)/*.png)))
+BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+NITRO_FILES = $(foreach dir,nitrofiles,$(notdir $(wildcard $(dir)/*)))
+
 
 [rules]
 .NOTPARALLEL:
-all: direc fpc_all 
-direc:
+clean: dir_delete fpc_clean fpc_cleanall
+all: dir_make $(BIN_FILES) $(GFX_FILES) fpc_all
+
+#
+# Delete temp directories
+#
+dir_delete:
+        @$(DELTREE) $(CURDIR)/$(BUILD) 
+        @$(DELTREE) $(CURDIR)/$(INC) 
+
+#
+# Create temp directories
+#
+dir_make:
 ifneq ($(BUILD), $(CURDIR))
-        $(MKDIR) $(BUILD)
+        @$(MKDIR) $(BUILD)
+endif
+ifneq ($(INC), $(CURDIR))
+        @$(MKDIR) $(INC)
 endif
+
+
+#
+# Audio files processing rule
+#
 soundbank.bin.o : $(AUDIO_FILES)
         @$(MMUTIL) $^ -d -o$(BUILD)/soundbank.bin -h$(BUILD)/soundbank.h
         $(BIN2S) $(BUILD)/soundbank.bin > $(BUILD)/soundbank.bin.s
         $(AS) -o $(BUILD)/soundbank.bin.o $(BUILD)/soundbank.bin.s
 
-$(GFX_FILES).o: 
-        $(GRIT) gfx/$(GFX_FILES) -fts -ff gfx/$(basename $(GFX_FILES)).grit -o$(BUILD)/$(GFX_FILES)
-        $(AS) -o $(BUILD)/$(basename $(GFX_FILES)).o $(BUILD)/$(basename $(GFX_FILES)).s
+#
+# Png files processing rule
+#
+$(GFX_FILES): $(wildcard %.bmp) $(wildcard %.png) 
+        @echo 'Converting $(@) file to asm...'
+        $(GRIT) gfx/$(@) -fts -ff gfx/$(basename $(@)).grit -o$(BUILD)/$(@)
+        @echo 'Assembling $(@).s file...'
+        $(AS) -o $(BUILD)/$(basename $(@)).o $(BUILD)/$(basename $(@)).s
+        @echo 'Done!'
+
+#
+# Binary files processing rule
+# 
+$(BIN_FILES): $(wildcard %.*)
+        @echo 'Converting $(@) file to asm...'
+        @$(BIN2S) data/$(@) > $(BUILD)/$(@).s
+        @echo 'Creating $(@).inc include file...'
+        @echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
+        @echo 'Assembling $(@).s file...'
+        @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
+        @echo 'Done!'
+
+#
+# GBFS files processing rule
+#
+data.gbfs.o:
+        @cd GBFS && gbfs ../$(BUILD)/data.gbfs $(GBFS_FILES)
+        $(BIN2S) $(BUILD)/data.gbfs > $(BUILD)/data.gbfs.s
+        $(AS) -o $(BUILD)/data.gbfs.o $(BUILD)/data.gbfs.s
+
+#
+# Binary files processing rule
+# 
+nitro: 
+	@ndstool -c $(TARGET_PROGRAMS).nds -9 $(TARGET_PROGRAMS).nef.bin -d $(CURDIR)/filesystem
+
+patch:
+	@dlditool r4tf.dldi $(TARGET_PROGRAMS).nds

+ 3 - 0
packages/libndsfpc/examples/input/Touch_Pad/touch_area/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 1 - 2
packages/libndsfpc/examples/input/Touch_Pad/touch_look/Makefile.fpc

@@ -20,8 +20,7 @@ target=nds
 fpcdir=../../../../../..
 
 [compiler]
-options=-g -Xm 
-#-d__THUMB__
+options=-Xm 
 
 [clean]
 files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \

+ 1 - 2
packages/libndsfpc/examples/input/Touch_Pad/touch_test/Makefile.fpc

@@ -15,8 +15,7 @@ nortl=y
 fpcpackage=y
 
 [compiler]
-options=-g -Xm -d__THUMB__
-
+options=-Xm 
 
 [default]
 cpu=arm

+ 3 - 0
packages/libndsfpc/examples/input/keyboard/keyboard_async/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/input/keyboard/keyboard_stdin/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/time/RealTimeClock/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/time/stopwatch/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 3 - 0
packages/libndsfpc/examples/time/timercallback/Makefile.fpc

@@ -14,6 +14,9 @@ nortl=y
 [install]
 fpcpackage=y
 
+[compiler]
+options=-Xm 
+
 [default]
 cpu=arm
 target=nds

+ 7 - 5
packages/libndsfpc/src/dswifi/inc/dswifi9.inc

@@ -97,13 +97,15 @@ type
     WSTAT_RXDATABYTES,
     WSTAT_TXPACKETS,
     WSTAT_TXBYTES,
-    WSTAT_TXDATABYTES,
+    WSTAT_TXDATABYTES,  
+    WSTAT_ARM7_UPDATES,
+    WSTAT_DEBUG,
 
-    WSTAT_HW_1B0,WSTAT_HW_1B1,WSTAT_HW_1B2,WSTAT_HW_1B3,WSTAT_HW_1B4,WSTAT_HW_1B5,WSTAT_HW_1B6,WSTAT_HW_1B7,	
-    WSTAT_HW_1B8,WSTAT_HW_1B9,WSTAT_HW_1BA,WSTAT_HW_1BB,WSTAT_HW_1BC,WSTAT_HW_1BD,WSTAT_HW_1BE,WSTAT_HW_1BF,	
+    WSTAT_HW_1B0,WSTAT_HW_1B1,WSTAT_HW_1B2,WSTAT_HW_1B3,WSTAT_HW_1B4,WSTAT_HW_1B5,WSTAT_HW_1B6,WSTAT_HW_1B7,
+    WSTAT_HW_1B8,WSTAT_HW_1B9,WSTAT_HW_1BA,WSTAT_HW_1BB,WSTAT_HW_1BC,WSTAT_HW_1BD,WSTAT_HW_1BE,WSTAT_HW_1BF,
     WSTAT_HW_1C0,WSTAT_HW_1C1,WSTAT_HW_1C4,WSTAT_HW_1C5,
-    WSTAT_HW_1D0,WSTAT_HW_1D1,WSTAT_HW_1D2,WSTAT_HW_1D3,WSTAT_HW_1D4,WSTAT_HW_1D5,WSTAT_HW_1D6,WSTAT_HW_1D7,	
-    WSTAT_HW_1D8,WSTAT_HW_1D9,WSTAT_HW_1DA,WSTAT_HW_1DB,WSTAT_HW_1DC,WSTAT_HW_1DD,WSTAT_HW_1DE,WSTAT_HW_1DF,	
+    WSTAT_HW_1D0,WSTAT_HW_1D1,WSTAT_HW_1D2,WSTAT_HW_1D3,WSTAT_HW_1D4,WSTAT_HW_1D5,WSTAT_HW_1D6,WSTAT_HW_1D7,
+    WSTAT_HW_1D8,WSTAT_HW_1D9,WSTAT_HW_1DA,WSTAT_HW_1DB,WSTAT_HW_1DC,WSTAT_HW_1DD,WSTAT_HW_1DE,WSTAT_HW_1DF,
     
     NUM_WIFI_STATS
   );

+ 2 - 2
packages/libndsfpc/src/dswifi/inc/dswifi_version.inc

@@ -2,6 +2,6 @@
 const
   DSWIFI_MAJOR    = 0;
   DSWIFI_MINOR    = 3;
-  DSWIFI_REVISION = 12;
-  DSWIFI_VERSION  = '0.3.12';
+  DSWIFI_REVISION = 16;
+  DSWIFI_VERSION  = '0.3.16';
 {$endif NDS_INTERFACE}

+ 2 - 0
packages/libndsfpc/src/fat/fat.inc

@@ -62,5 +62,7 @@ const
 function FAT_getAttr(const _file: pcchar): cint; cdecl; external;
 function FAT_setAttr(const _file: pcchar; attr: cint): cint; cdecl; external;
 
+{$define LIBFAT_FEOS_MULTICWD}
+
 {$endif NDS_INTERFACE}
 

+ 1 - 1
packages/libndsfpc/src/fat/filesystem.inc

@@ -1,6 +1,6 @@
 {$ifdef NDS_INTERFACE}
 
-function nitroFSInit(): cbool; cdecl; external;
+function nitroFSInit(basepath: ppchar): cbool; cdecl; external;
 
 {$endif NDS_INTERFACE}
 

+ 16 - 0
packages/libndsfpc/src/nds/arm9/background.inc

@@ -42,6 +42,22 @@ const
   TILE_FLIP_H = (1 shl 10);
   TILE_FLIP_V = (1 shl 11);
 
+
+type
+  TileMapEntry8 = record
+    index: cuint8;
+  end;
+  TTileMapEntry8 = TileMapEntry8;
+  PTileMapEntry8 = ^TileMapEntry8;
+
+  TileMapEntry16 = bitpacked record
+    index: 0..10;
+    hflip: 0..1;
+    vflip: 0..1;
+    palette: 0..4;
+  end;
+
+
 type
   BackgroundControl = cint;
 const

+ 26 - 0
packages/libndsfpc/src/nds/arm9/math.inc

@@ -30,6 +30,11 @@ const
   SQRT_64			= 1;
   SQRT_32			= 0;
   SQRT_BUSY		= (1 shl 15);
+
+function inttof32(n: cint): cint32; inline;
+function f32toint(n: cint32): cint; inline;
+function floattof32(n: cfloat): cint32; inline;  //inlining it makes impossible to pass it to another function :/
+function f32tofloat(n: cint32): cfloat; inline;
   
 function divf32(num: cint32; den: cint32): cint32; inline;
 function mulf32(a, b: cint32): cint32; inline;
@@ -46,6 +51,27 @@ procedure normalizef32(a: pcint32); inline;
 {$endif NDS_INTERFACE}
 
 {$ifdef NDS_IMPLEMENTATION}
+function inttof32(n: cint): cint32; inline;
+begin
+  inttof32 := ((n) shl 12);
+end;
+
+function f32toint(n: cint32): cint; inline;
+begin
+  f32toint := ((n) shr 12);
+end;
+
+function floattof32(n: cfloat): cint32; inline;
+begin
+  floattof32 := trunc((n) * (1 shl 12));
+end;
+
+// check it!
+function f32tofloat(n: cint32): cfloat; inline;
+begin
+  f32tofloat := cfloat(n * 1.0) / cfloat((1 shl 12) * 1.0);
+end;
+
 function divf32(num: cint32; den: cint32): cint32; inline;
 begin
   REG_DIVCNT^ := DIV_64_32;

+ 5 - 26
packages/libndsfpc/src/nds/arm9/videoGL.inc

@@ -32,11 +32,6 @@ function floatto12d3(n: cfloat): fixed12d3; inline;
 const
   GL_MAX_DEPTH     = $7FFF;
 
-function inttof32(n: cint): cint32; inline;
-function f32toint(n: cint32): cint; inline;
-function floattof32(n: cfloat): cint32; inline;  //inlining it makes impossible to pass it to another function :/
-function f32tofloat(n: cint32): cfloat; inline;
-
 type
   t16 = cshort;//cint16?       // text coordinate 12.4 fixed point (or cint?)
 
@@ -296,6 +291,7 @@ type
     matrixMode: GL_MATRIX_MODE_ENUM; // holds the current Matrix Mode
 
     vramBlocks: array [0..1] of ps_vramBlock;		// Two classe instances, one for textures, and one for palettes
+    vramLock: array [0..1] of cint;				// Holds the current lock state of the VRAM banks
     
     // texture globals
     texturePtrs: DynamicArray;		// Pointers to each individual texture
@@ -372,6 +368,10 @@ procedure glBindTexture(target, name: cint); cdecl; external;
 function glGenTextures(n: cint; names: pcint): cint; cdecl; external;
 function glDeleteTextures(n: cint; names: pcint): cint; cdecl; external;
 procedure glResetTextures(); cdecl; external;
+
+function glLockVRAMBank(addr: pcuint16): cint; cdecl; external;
+function glUnlockVRAMBank(addr: pcuint16): cint; cdecl; external;
+
 procedure glTexCoord2f32(u, v: cint32); cdecl; external;
 procedure glMaterialf(mode: GL_MATERIALS_ENUM; color: rgb); cdecl; external;
 procedure glInit_C(); cdecl; external;
@@ -464,27 +464,6 @@ begin
   floatto12d3 := fixed12d3(trunc( n  * (1 shl 3)));
 end;
 
-function inttof32(n: cint): cint32; inline;
-begin
-  inttof32 := ((n) shl 12);
-end;
-
-function f32toint(n: cint32): cint; inline;
-begin
-  f32toint := ((n) shr 12);
-end;
-
-function floattof32(n: cfloat): cint32; inline;
-begin
-  floattof32 := trunc((n) * (1 shl 12));
-end;
-
-// check it!
-function f32tofloat(n: cint32): cfloat; inline;
-begin
-  f32tofloat := cfloat(n * 1.0) / cfloat((1 shl 12) * 1.0);
-end;
-
 function f32tot16(n: cint32): t16; inline;
 begin
   f32tot16 := t16(n shr 8);

+ 2 - 2
packages/libndsfpc/src/nds/libversion.inc

@@ -2,9 +2,9 @@
 const
   _LIBNDS_MAJOR_ = 1;
   _LIBNDS_MINOR_ = 5;
-  _LIBNDS_PATCH_ = 7;
+  _LIBNDS_PATCH_ = 8;
 
-  _LIBNDS_STRING = 'libNDS Release 1.5.7';
+  _LIBNDS_STRING = 'libNDS Release 1.5.8';
 {$endif NDS_INTERFACE}
 
 {$ifdef NDS_IMPLEMENTATION}

+ 1 - 0
packages/libndsfpc/src/nds/nds.inc

@@ -105,6 +105,7 @@
   {$include arm9/sassert.inc}
   {$include arm9/sound.inc}
   {$include arm9/sprite.inc}
+  {$include arm9/window.inc}
   {$include arm9/trig_lut.inc}
   {$include arm9/video.inc}
   {$include arm9/videoGL.inc}

+ 3 - 2
rtl/nds/system.pp

@@ -18,13 +18,14 @@ unit System;
 interface
 
 {$define FPC_IS_SYSTEM}
-{$define HAS_CMDLINE}
-{$define FPC_HAS_FEATURE_THREADING}
+{$define HAS_CMDLINE}  
 {$define FPC_HAS_FEATURE_CONSOLEIO}
 {$define FPC_HAS_FEATURE_COMMANDARGS}
 {$define FPC_HAS_FEATURE_TEXTIO}
 {$define FPC_HAS_FEATURE_FILEIO}
+{$define FPC_HAS_FEATURE_THREADING}
 
+                       
 {$i systemh.inc}
 {$i ndsbiosh.inc}
 {$i ndsh.inc}

+ 24 - 3
rtl/nds/sysutils.pp

@@ -28,7 +28,8 @@ interface
 {$MODESWITCH OUT}
 { force ansistrings }
 {$H+}
-
+{$DEFINE HAS_OSERROR}
+{$DEFINE HAS_SLEEP}
 { used OS file system APIs use ansistring }
 {$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
 { OS has an ansistring/single byte environment variable API }
@@ -259,7 +260,24 @@ Procedure SysBeep;
 begin
 end;
 
-
+Procedure Sleep(Milliseconds : Cardinal);
+var
+  i,j : Cardinal;
+  calib : Cardinal;
+begin
+{ $warning no idea if this calibration value is correct (FK) }
+{ I estimated it roughly on the CPU clock of 16 MHz and 1+3 clock cycles for the loop }
+{ 
+  calib:=4000000;
+  for i:=1 to Milliseconds do
+    asm
+      ldr r0,calib
+    .L1:
+      sub r0,r0,#1
+      bne .L1
+    end;
+    }
+end;
 {****************************************************************************
                               Locale Functions
 ****************************************************************************}
@@ -305,7 +323,10 @@ begin
   result := -1;
 end;
 
-
+function GetLastOSError: Integer;
+begin
+  Result := -1;
+end;
 {****************************************************************************
                               Initialization code
 ****************************************************************************}