summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorLegolas <Legolas@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-10-31 15:22:49 +0000
committerLegolas <Legolas@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-10-31 15:22:49 +0000
commitd2cdfa754f87dbafb1bfb6a5033b612b4a35fc22 (patch)
tree0706ae217f24b105dd7cf0d6ea6ce75491d82660 /packages
parent11b50c19bc01b65ca29fb2faec8ad7891584078d (diff)
downloadfpc-d2cdfa754f87dbafb1bfb6a5033b612b4a35fc22.tar.gz
* Updated nds to devkitARM r32 and libnds 1.4.8
* Fixed nds rtl for ARGV and Exit to menu protocol git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@16273 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages')
-rw-r--r--packages/libndsfpc/Makefile42
-rw-r--r--packages/libndsfpc/src/nds/arm7/serial.inc3
-rw-r--r--packages/libndsfpc/src/nds/arm7/touch.inc2
-rw-r--r--packages/libndsfpc/src/nds/arm9/background.inc31
-rw-r--r--packages/libndsfpc/src/nds/arm9/decompress.inc6
-rw-r--r--packages/libndsfpc/src/nds/arm9/dynamicArray.inc (renamed from packages/libndsfpc/src/nds/dynamicArray.inc)56
-rw-r--r--packages/libndsfpc/src/nds/arm9/keyboard.inc18
-rw-r--r--packages/libndsfpc/src/nds/arm9/linkedlist.inc (renamed from packages/libndsfpc/src/nds/linkedlist.inc)47
-rw-r--r--packages/libndsfpc/src/nds/arm9/pcx.inc2
-rw-r--r--packages/libndsfpc/src/nds/arm9/sprite.inc25
-rw-r--r--packages/libndsfpc/src/nds/arm9/video.inc21
-rw-r--r--packages/libndsfpc/src/nds/arm9/videoGL.inc77
-rw-r--r--packages/libndsfpc/src/nds/bios.inc16
-rw-r--r--packages/libndsfpc/src/nds/card.inc30
-rw-r--r--packages/libndsfpc/src/nds/debug.inc1
-rw-r--r--packages/libndsfpc/src/nds/fifocommon.inc3
-rw-r--r--packages/libndsfpc/src/nds/fifomessages.inc3
-rw-r--r--packages/libndsfpc/src/nds/memory.inc8
-rw-r--r--packages/libndsfpc/src/nds/nds.inc23
-rw-r--r--packages/libndsfpc/src/nds/ndsinclude.inc8
-rw-r--r--packages/libndsfpc/src/nds/registers_alt.inc8
-rw-r--r--packages/libndsfpc/src/nds/system.inc60
-rw-r--r--packages/libndsfpc/src/nds/timers.inc123
-rw-r--r--packages/libndsfpc/src/nds7.pp2
-rw-r--r--packages/libndsfpc/src/nds9.pp2
25 files changed, 331 insertions, 286 deletions
diff --git a/packages/libndsfpc/Makefile b/packages/libndsfpc/Makefile
index 02c56195fe..a24b883450 100644
--- a/packages/libndsfpc/Makefile
+++ b/packages/libndsfpc/Makefile
@@ -1,8 +1,8 @@
#
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/29]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/26]
#
default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku 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 i386-nativent i386-iphonesim 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-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku 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-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
BSDs = freebsd netbsd openbsd darwin
UNIXs = linux $(BSDs) solaris qnx haiku
LIMIT83fs = go32v2 os2 emx watcom
@@ -247,7 +247,7 @@ endif
ifndef CROSSBINDIR
CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
endif
-ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
+ifeq ($(OS_TARGET),darwin)
ifeq ($(OS_SOURCE),darwin)
DARWIN2DARWIN=1
endif
@@ -329,12 +329,6 @@ endif
ifeq ($(FULL_TARGET),i386-symbian)
override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs filesystem maxmod9 maxmod7
endif
-ifeq ($(FULL_TARGET),i386-nativent)
-override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs filesystem maxmod9 maxmod7
-endif
-ifeq ($(FULL_TARGET),i386-iphonesim)
-override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs filesystem maxmod9 maxmod7
-endif
ifeq ($(FULL_TARGET),m68k-linux)
override TARGET_UNITS+=nds9 nds7 dswifi9 dswifi7 fat gbfs filesystem maxmod9 maxmod7
endif
@@ -515,12 +509,6 @@ endif
ifeq ($(FULL_TARGET),i386-symbian)
override TARGET_EXAMPLEDIRS+=examples
endif
-ifeq ($(FULL_TARGET),i386-nativent)
-override TARGET_EXAMPLEDIRS+=examples
-endif
-ifeq ($(FULL_TARGET),i386-iphonesim)
-override TARGET_EXAMPLEDIRS+=examples
-endif
ifeq ($(FULL_TARGET),m68k-linux)
override TARGET_EXAMPLEDIRS+=examples
endif
@@ -702,12 +690,6 @@ endif
ifeq ($(FULL_TARGET),i386-symbian)
override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/maxmod
endif
-ifeq ($(FULL_TARGET),i386-nativent)
-override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/maxmod
-endif
-ifeq ($(FULL_TARGET),i386-iphonesim)
-override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/maxmod
-endif
ifeq ($(FULL_TARGET),m68k-linux)
override COMPILER_INCLUDEDIR+=src src/dswifi src/fat src/maxmod
endif
@@ -888,12 +870,6 @@ endif
ifeq ($(FULL_TARGET),i386-symbian)
override COMPILER_SOURCEDIR+=src tests
endif
-ifeq ($(FULL_TARGET),i386-nativent)
-override COMPILER_SOURCEDIR+=src tests
-endif
-ifeq ($(FULL_TARGET),i386-iphonesim)
-override COMPILER_SOURCEDIR+=src tests
-endif
ifeq ($(FULL_TARGET),m68k-linux)
override COMPILER_SOURCEDIR+=src tests
endif
@@ -1343,7 +1319,7 @@ DEBUGSYMEXT=.xcoff
SHORTSUFFIX=mac
IMPORTLIBPREFIX=imp
endif
-ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
+ifeq ($(OS_TARGET),darwin)
BATCHEXT=.sh
EXEEXT=
HASSHAREDLIB=1
@@ -1358,10 +1334,6 @@ ifeq ($(OS_TARGET),symbian)
SHAREDLIBEXT=.dll
SHORTSUFFIX=symbian
endif
-ifeq ($(OS_TARGET),NativeNT)
-SHAREDLIBEXT=.dll
-SHORTSUFFIX=nativent
-endif
else
ifeq ($(OS_TARGET),go32v1)
PPUEXT=.pp1
@@ -2439,12 +2411,6 @@ endif
ifeq ($(FULL_TARGET),i386-symbian)
TARGET_EXAMPLEDIRS_EXAMPLES=1
endif
-ifeq ($(FULL_TARGET),i386-nativent)
-TARGET_EXAMPLEDIRS_EXAMPLES=1
-endif
-ifeq ($(FULL_TARGET),i386-iphonesim)
-TARGET_EXAMPLEDIRS_EXAMPLES=1
-endif
ifeq ($(FULL_TARGET),m68k-linux)
TARGET_EXAMPLEDIRS_EXAMPLES=1
endif
diff --git a/packages/libndsfpc/src/nds/arm7/serial.inc b/packages/libndsfpc/src/nds/arm7/serial.inc
index 5650318553..fbbc36907f 100644
--- a/packages/libndsfpc/src/nds/arm7/serial.inc
+++ b/packages/libndsfpc/src/nds/arm7/serial.inc
@@ -117,7 +117,6 @@ procedure readFirmware(address: cuint32; destination: pointer; size: cuint32); c
{$ifdef NDS_IMPLEMENTATION}
procedure SerialWaitBusy(); inline;
begin
- while (REG_SPICNT^ and SPI_BUSY) <> 0 do
- swiDelay(1);
+ while (REG_SPICNT^ and SPI_BUSY) <> 0 do;
end;
{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/nds/arm7/touch.inc b/packages/libndsfpc/src/nds/arm7/touch.inc
index fe11a89d9b..150314dc50 100644
--- a/packages/libndsfpc/src/nds/arm7/touch.inc
+++ b/packages/libndsfpc/src/nds/arm7/touch.inc
@@ -62,4 +62,6 @@ procedure touchReadXY(var touchPos: touchPosition); cdecl; external;
function touchRead(command: cuint32): cuint16; cdecl; external;
function touchReadTemperature(t1: pcint; t2: pcint): cuint32; cdecl; external;
+
+function touchPenDown(): cbool; cdecl; external;
{$endif NDS_INTERFACE}
diff --git a/packages/libndsfpc/src/nds/arm9/background.inc b/packages/libndsfpc/src/nds/arm9/background.inc
index 563e3867b7..865a6672b6 100644
--- a/packages/libndsfpc/src/nds/arm9/background.inc
+++ b/packages/libndsfpc/src/nds/arm9/background.inc
@@ -48,10 +48,10 @@ type
Pbg_scroll = ^bg_scroll;
bg_transform = record
- xdx: cint16;
- xdy: cint16;
- ydx: cint16;
- ydy: cint16;
+ hdx: cint16;
+ vdx: cint16;
+ hdy: cint16;
+ vdy: cint16;
dx: cint32;
dy: cint32;
end;
@@ -184,7 +184,7 @@ const
REG_BG1CNT_SUB : pcuint16 = pointer($400100A);
REG_BG2CNT_SUB : pcuint16 = pointer($400100C);
REG_BG3CNT_SUB : pcuint16 = pointer($400100E);
-
+
REG_BGOFFSETS_SUB : pcuint16 = pointer($4001010);
REG_BG0HOFS_SUB : pcuint16 = pointer($4001010);
REG_BG0VOFS_SUB : pcuint16 = pointer($4001012);
@@ -304,6 +304,7 @@ procedure bgShow(id: cint); inline;
procedure bgHide(id: cint); inline;
procedure bgSetCenterf(id: cint; x, y: cint32); inline;
procedure bgSetCenter(id, x, y: cint); inline;
+procedure bgSetAffineMatrixScroll(id, hdx, vdx, hdy, vdy, scrollx, scrolly: cint); inline;
{$endif NDS_INTERFACE}
@@ -450,6 +451,7 @@ end;
function bgSetControlBits(id: cint; bits: cuint16): pcuint16; inline;
begin
+ sassert( (id >= 0) and (id <= 7), 'bgSetControlBits(), id must be the number returned from bgInit or bgInitSub');
bgControl[id]^ := bgControl[id]^ or bits;
result := bgControl[id];
end;
@@ -541,7 +543,7 @@ end;
function bgGetTileBase(id: cint): cint; inline;
begin
- result := (bgControl[id]^ shr TILE_BASE_SHIFT) and 31;
+ result := (bgControl[id]^ shr TILE_BASE_SHIFT) and 15;
end;
function bgGetMapPtr(id: cint): pcuint16; inline;
@@ -608,4 +610,21 @@ begin
bgSetCenterf(id, x shl 8, y shl 8);
end;
+procedure bgSetAffineMatrixScroll(id, hdx, vdx, hdy, vdy, scrollx, scrolly: cint); inline;
+begin
+ sassert(not bgIsText(id), 'Text Backgrounds have no affine matrix and scroll registers.');
+
+ bgTransform[id]^.hdx := hdx;
+ bgTransform[id]^.vdx := vdx;
+ bgTransform[id]^.hdy := hdy;
+ bgTransform[id]^.vdy := vdy;
+
+ bgTransform[id]^.dx := scrollx;
+ bgTransform[id]^.dy := scrolly;
+
+ bgState[id].dirty := false;
+end;
+
+
+
{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/nds/arm9/decompress.inc b/packages/libndsfpc/src/nds/arm9/decompress.inc
index ce901c18b3..7193208458 100644
--- a/packages/libndsfpc/src/nds/arm9/decompress.inc
+++ b/packages/libndsfpc/src/nds/arm9/decompress.inc
@@ -40,9 +40,9 @@
{$ifdef NDS_INTERFACE}
-type
- getByteCallback = function(source: pcuint8): pcuint8;
- getHeaderCallback = function(source: pcuint8; dest: pcuint16; arg: cuint32): pcint;
+//type
+// getByteCallback = function(source: pcuint8): pcuint8;
+// getHeaderCallback = function(source: pcuint8; dest: pcuint16; arg: cuint32): pcint;
type
DecompressType = integer;
diff --git a/packages/libndsfpc/src/nds/dynamicArray.inc b/packages/libndsfpc/src/nds/arm9/dynamicArray.inc
index a8340d19f9..d3a923b2f4 100644
--- a/packages/libndsfpc/src/nds/dynamicArray.inc
+++ b/packages/libndsfpc/src/nds/arm9/dynamicArray.inc
@@ -1,5 +1,5 @@
(*
- $Id$
+ $Id: dynamicArray.inc 13585 2009-08-23 13:57:45Z Legolas $
------------------------------------------------------------------------------
Copyright (C) 2005
Jason Rogers (dovoto)
@@ -42,59 +42,15 @@
type
DynamicArray = record
data: ppointer; // pointer to array of void pointers
- cur_size: integer; // currently allocated size of the array
+ cur_size: cuint; // currently allocated size of the array
end;
TDynamicArray = DynamicArray;
PDynamicArray = ^TDynamicArray;
-function DynamicArrayInit(v: PDynamicArray; initialSize: integer): pointer; inline;
-procedure DynamicArrayDelete(v: PDynamicArray); inline;
-function DynamicArrayGet(v: PDynamicArray; index: integer): pointer; inline;
-procedure DynamicArraySet(v: PDynamicArray; index: integer; item: pointer); inline;
+function DynamicArrayInit(v: PDynamicArray; initialSize: cuint): pointer; cdecl; external;
+procedure DynamicArrayDelete(v: PDynamicArray); cdecl; external;
+function DynamicArrayGet(v: PDynamicArray; index: cuint): pointer; cdecl; external;
+function DynamicArraySet(v: PDynamicArray; index: cuint; item: pointer): cbool; cdecl; external;
{$endif NDS_INTERFACE}
-
-{$ifdef NDS_IMPLEMENTATION}
-function DynamicArrayInit(v: PDynamicArray; initialSize: integer): pointer; inline;
-begin
- v^.cur_size := initialSize;
-// v^.data := malloc(sizeof(pointer) * initialSize);
- GetMem(v^.data, sizeof(pointer) * initialSize);
- result := v^.data;
-end;
-
-procedure DynamicArrayDelete(v: PDynamicArray); inline;
-begin
- if (v^.data) <> nil then
- free(v^.data);
-end;
-
-function DynamicArrayGet(v: PDynamicArray; index: integer): pointer; inline;
-begin
- if (index >= v^.cur_size) then
- begin
- result := nil;
- exit;
- end;
- result := v^.data + index;
-end;
-
-procedure DynamicArraySet(v: PDynamicArray; index: integer; item: pointer); inline;
-var
- i: integer;
-begin
- if (index >= v^.cur_size) then
- begin
- v^.data := ReAllocMem(v^.data, sizeof(pointer) * v^.cur_size * 2);
- FillChar(pointer(integer(v^.data^^) + v^.cur_size)^, sizeof(pointer) * v^.cur_size, 0);
- v^.cur_size := v^.cur_size * 2;
- end;
- {
- i := integer(v^.data);
- i := i + index;
- pointer(i) := item;
- }
- v^.data[index] := item;
-end;
-{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/nds/arm9/keyboard.inc b/packages/libndsfpc/src/nds/arm9/keyboard.inc
index b8660dd7c6..405bddf13d 100644
--- a/packages/libndsfpc/src/nds/arm9/keyboard.inc
+++ b/packages/libndsfpc/src/nds/arm9/keyboard.inc
@@ -89,6 +89,24 @@ type
TKeyboard = Keyboard;
PKeyboard = ^Keyboard;
+type
+ TKeys = cint;
+const
+ NOKEY : TKeys = -1;
+ DVK_FOLD : TKeys = -23;
+ DVK_TAB : TKeys = 9;
+ DVK_BACKSPACE : TKeys = 8;
+ DVK_CAPS : TKeys = -15;
+ DVK_SHIFT : TKeys = -14;
+ DVK_SPACE : TKeys = 32;
+ DVK_MENU : TKeys = -5;
+ DVK_ENTER : TKeys = 10;
+ DVK_CTRL : TKeys = -16;
+ DVK_UP : TKeys = -17;
+ DVK_RIGHT : TKeys = -18;
+ DVK_DOWN : TKeys = -19;
+ DVK_LEFT : TKeys = -20;
+ DVK_ALT : TKeys = -26;
function keyboardGetDefault(): PKeyboard; cdecl; external;
diff --git a/packages/libndsfpc/src/nds/linkedlist.inc b/packages/libndsfpc/src/nds/arm9/linkedlist.inc
index 3835628612..658fe3c2a4 100644
--- a/packages/libndsfpc/src/nds/linkedlist.inc
+++ b/packages/libndsfpc/src/nds/arm9/linkedlist.inc
@@ -37,51 +37,8 @@ type
end;
TLinkedList = LinkedList;
-function linkedlistAdd(front: PLinkedList; data: pointer): PLinkedList; inline;
-procedure linkedlistRemove(node: PLinkedList); inline;
+function linkedlistAdd(front: PLinkedList; data: pointer): PLinkedList; cdecl; external;
+procedure linkedlistRemove(node: PLinkedList); cdecl; external;
{$endif NDS_INTERFACE}
-
-{$ifdef NDS_IMPLEMENTATION}
-function linkedlistAdd(front: PLinkedList; data: pointer): PLinkedList; inline;
-var
- node: PLinkedList;
-begin
- GetMem(node, sizeof(LinkedList));
-
- node^.prev := nil;
-
- if (front = nil) then
- begin
- node^.next := nil;
-
- node^.data := data;
-
- front := node;
-
- result := node;
- end;
-
- node^.next := front;
-
- front^.prev := node;
-
- result := node;
-end;
-
-
-procedure linkedlistRemove(node: PLinkedList); inline;
-begin
- if (node = nil) then exit;
-
- if (node^.prev <> nil) then
- node^.prev^.next := node^.next;
-
- if (node^.next <> nil) then
- node^.next^.prev := node^.prev;
-
- FreeMem(node);
-end;
-
-{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/nds/arm9/pcx.inc b/packages/libndsfpc/src/nds/arm9/pcx.inc
index 6bbf176ee2..6647f6f18a 100644
--- a/packages/libndsfpc/src/nds/arm9/pcx.inc
+++ b/packages/libndsfpc/src/nds/arm9/pcx.inc
@@ -61,5 +61,5 @@ type
PPCXHeader = ^PCXHeader;
-function loadPCX(pcx: pcuchar; image: PsImage): cint; cdecl; external;
+function loadPCX(const pcx: pcuchar; image: PsImage): cint; cdecl; external;
{$endif NDS_INTERFACE}
diff --git a/packages/libndsfpc/src/nds/arm9/sprite.inc b/packages/libndsfpc/src/nds/arm9/sprite.inc
index 41d28eb6a4..3ea494e112 100644
--- a/packages/libndsfpc/src/nds/arm9/sprite.inc
+++ b/packages/libndsfpc/src/nds/arm9/sprite.inc
@@ -86,7 +86,7 @@ function ATTR2_ALPHA(n: cint): cint; inline;
type
ObjBlendMode = (
- BJMODE_NORMAL = 0,
+ OBJMODE_NORMAL = 0,
OBJMODE_BLENDED = 1,
OBJMODE_WINDOWED = 2,
OBJMODE_BITMAP = 3
@@ -193,9 +193,9 @@ type
filler1: array [0..2] of cuint16;
hdx: cint16;
filler2: array [0..2] of cuint16;
- hdy: cint16;
- filler3: array [0..2] of cuint16;
vdx: cint16;
+ filler3: array [0..2] of cuint16;
+ hdy: cint16;
filler4: array [0..2] of cuint16;
vdy: cint16;
end;
@@ -310,6 +310,7 @@ procedure oamSet( var oam: OamState;
affineIndex: cint;
sizeDouble, hide, hflip, vflip, mosaic: cbool); cdecl; external;
procedure oamClear(var oam: OamState; start, count: cint); cdecl; external;
+procedure oamClearSprite(var oam: OamState; index: cint); inline;
procedure oamUpdate(var oam: OamState); cdecl; external;
procedure oamRotateScale(var oam: OamState; rotId, angle, sx, sy: cint); cdecl; external;
procedure oamAffineTransformation(var oam: OamState; rotId, hdx, hdy, vdx, vdy: cint); inline;
@@ -367,25 +368,31 @@ end;
procedure oamSetMosaic(dx, dy: cuint); inline;
begin
- sassert((dx < 16) and (dy < 16), 'Mosaic range is 0 to 15');
+ sassert((dx < 16) and (dy < 16), 'Mosaic range must be 0 to 15');
mosaicShadow := ( mosaicShadow and $00ff) or (dx shl 8) or (dy shl 12);
REG_MOSAIC^ := mosaicShadow;
end;
procedure oamSetMosaicSub(dx, dy: cuint); inline;
begin
- sassert((dx < 16) and (dy < 16), 'Mosaic range is 0 to 15');
+ sassert((dx < 16) and (dy < 16), 'Mosaic range must be 0 to 15');
mosaicShadowSub := (mosaicShadowSub and $00ff) or (dx shl 8) or (dy shl 12);
REG_MOSAIC_SUB^ := mosaicShadowSub;
end;
+procedure oamClearSprite(var oam: OamState; index: cint); inline;
+begin
+ sassert( (index >= 0) and (index < SPRITE_COUNT), 'oamClearSprite() index is out of bounds, must be 0-127');
+ oam.oamMemory[index].attribute[0] := ATTR0_DISABLED;
+end;
+
procedure oamAffineTransformation(var oam: OamState; rotId, hdx, hdy, vdx, vdy: cint); inline;
begin
sassert((rotId >= 0) and (rotId < 32), 'oamAffineTransformation() rotId is out of bounds, must be 0-31');
- oam.oamRotationMemory[rotId].hdx := hdx shr 12;
- oam.oamRotationMemory[rotId].hdy := hdy shr 12;
- oam.oamRotationMemory[rotId].vdx := vdx shr 12;
- oam.oamRotationMemory[rotId].vdy := vdy shr 12;
+ oam.oamRotationMemory[rotId].hdx := hdx;
+ oam.oamRotationMemory[rotId].vdx := vdx;
+ oam.oamRotationMemory[rotId].hdy := hdy;
+ oam.oamRotationMemory[rotId].vdy := vdy;
end;
diff --git a/packages/libndsfpc/src/nds/arm9/video.inc b/packages/libndsfpc/src/nds/arm9/video.inc
index 8850c7cacd..545ff72746 100644
--- a/packages/libndsfpc/src/nds/arm9/video.inc
+++ b/packages/libndsfpc/src/nds/arm9/video.inc
@@ -201,6 +201,10 @@ const
VRAM_F_MAIN_SPRITE_0x06410000 : VRAM_F_TYPE = 2 or (2 shl 3);
VRAM_F_MAIN_SPRITE_0x06414000 : VRAM_F_TYPE = 2 or (3 shl 3);
VRAM_F_TEX_PALETTE : VRAM_F_TYPE = 3;
+ VRAM_F_TEX_PALETTE_SLOT0 : VRAM_F_TYPE = 3;
+ VRAM_F_TEX_PALETTE_SLOT1 : VRAM_F_TYPE = 3 or (1 shl 3);
+ VRAM_F_TEX_PALETTE_SLOT4 : VRAM_F_TYPE = 3 or (2 shl 3);
+ VRAM_F_TEX_PALETTE_SLOT5 : VRAM_F_TYPE = 3 or (3 shl 3);
VRAM_F_BG_EXT_PALETTE : VRAM_F_TYPE = 4;
VRAM_F_BG_EXT_PALETTE_SLOT01 : VRAM_F_TYPE = 4 or (0 shl 3);
VRAM_F_BG_EXT_PALETTE_SLOT23 : VRAM_F_TYPE = 4 or (1 shl 3);
@@ -221,6 +225,10 @@ const
VRAM_G_MAIN_SPRITE_0x06410000 : VRAM_G_TYPE = 2 or (2 shl 3);
VRAM_G_MAIN_SPRITE_0x06414000 : VRAM_G_TYPE = 2 or (3 shl 3);
VRAM_G_TEX_PALETTE : VRAM_G_TYPE = 3;
+ VRAM_G_TEX_PALETTE_SLOT0 : VRAM_G_TYPE = 3;
+ VRAM_G_TEX_PALETTE_SLOT1 : VRAM_G_TYPE = 3 or (1 shl 3);
+ VRAM_G_TEX_PALETTE_SLOT4 : VRAM_G_TYPE = 3 or (2 shl 3);
+ VRAM_G_TEX_PALETTE_SLOT5 : VRAM_G_TYPE = 3 or (3 shl 3);
VRAM_G_BG_EXT_PALETTE : VRAM_G_TYPE = 4;
VRAM_G_BG_EXT_PALETTE_SLOT01 : VRAM_G_TYPE = 4 or (0 shl 3);
VRAM_G_BG_EXT_PALETTE_SLOT23 : VRAM_G_TYPE = 4 or (1 shl 3);
@@ -254,6 +262,7 @@ var
VRAM_H_EXT_PALETTE : P_ext_palette absolute VRAM_H;
function vramSetMainBanks(a: VRAM_A_TYPE; b: VRAM_B_TYPE; c: VRAM_C_TYPE; d: VRAM_D_TYPE): cuint32; cdecl; external;
+function vramDefault(): cuint32; cdecl; external;
procedure vramRestoreMainBanks(vramTemp: cuint32); cdecl; external;
procedure vramSetBankA(a: VRAM_A_TYPE); inline;
@@ -344,6 +353,8 @@ procedure videoBgEnableSub(number: cint); inline;
procedure videoBgDisable(number: cint); inline;
procedure videoBgDisableSub(number: cint); inline;
procedure setBrightness(screen, level: cint); cdecl; external;
+procedure setBackdropColor(const color: cuint16); inline;
+procedure setBackdropColorSub(const color: cuint16); inline;
const
REG_MASTER_BRIGHT : pcuint16 = pointer($0400006C);
@@ -673,4 +684,14 @@ begin
VRAM_I_CR^ := VRAM_ENABLE or i;
end;
+procedure setBackdropColor(const color: cuint16); inline;
+begin
+ BG_PALETTE[0] := color;
+end;
+
+procedure setBackdropColorSub(const color: cuint16); inline;
+begin
+ BG_PALETTE_SUB[0] := color;
+end;
+
{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/nds/arm9/videoGL.inc b/packages/libndsfpc/src/nds/arm9/videoGL.inc
index 669680b6bf..16286ae31a 100644
--- a/packages/libndsfpc/src/nds/arm9/videoGL.inc
+++ b/packages/libndsfpc/src/nds/arm9/videoGL.inc
@@ -299,6 +299,10 @@ function FIFO_NOP(): cuint8; inline;
function FIFO_STATUS(): cuint8; inline;
function FIFO_COLOR(): cuint8; inline;
function FIFO_VERTEX16(): cuint8; inline;
+function FIFO_VERTEX10(): cuint8; inline;
+function FIFO_VERTEX_XY(): cuint8; inline;
+function FIFO_VERTEX_XZ(): cuint8; inline;
+function FIFO_VERTEX_YZ(): cuint8; inline;
function FIFO_TEX_COORD(): cuint8; inline;
function FIFO_TEX_FORMAT(): cuint8; inline;
function FIFO_PAL_FORMAT(): cuint8; inline;
@@ -317,7 +321,7 @@ function FIFO_FLUSH(): cuint8; inline;
function FIFO_VIEWPORT(): cuint8; inline;
procedure glRotatef32i(angle: cint; x, y, z: cint32); cdecl; external;
-function glTexImage2D(target, empty1: cint; _type: GL_TEXTURE_TYPE_ENUM; sizeX, sizeY, empty2, param: cint; texture: pcuint8): cint; cdecl; external;
+function glTexImage2D(target, empty1: cint; _type: GL_TEXTURE_TYPE_ENUM; sizeX, sizeY, empty2, param: cint; texture: pointer): cint; cdecl; external;
procedure glTexLoadPal(const pal: pcuint16; count: cuint16; addr: cuint32); cdecl; external;
function gluTexLoadPal(const pal: pcuint16; count: cuint16; format: cuint8): cint; cdecl; external;
procedure glTexParameter(sizeX, sizeY: cuint8; const addr: pcuint32; mode: GL_TEXTURE_TYPE_ENUM; param: GL_TEXTURE_PARAM_ENUM); cdecl; external;
@@ -348,7 +352,8 @@ procedure glStoreMatrix(index: cint32); inline;
procedure glScalev(const v: PGLvector); inline;
procedure glTranslatev(const v: PGLvector) ; inline;
procedure glTranslate3f32(x, y, z: cint32); inline;
-procedure glScalef32(factor: cint32); inline;
+procedure glTranslatef32(x, y, z: cint32); inline;
+procedure glScalef32(x, y, z: cint32); inline;
procedure glLight(id: cint; color: rgb; x, y, z: v10); inline;
procedure glNormal(normal: cuint32); inline;
procedure glLoadIdentity(); inline;
@@ -360,6 +365,10 @@ procedure glCallList(list: pcuint32); inline;
procedure glPolyFmt(params: cuint32); inline;
procedure glEnable(bits: cint); inline;
procedure glDisable(bits: cint); inline;
+procedure glFogShift(shift: cint); inline;
+procedure glFogOffset(offset: cint); inline;
+procedure glFogColor(red, green, blue, alpha: cuint8); inline;
+procedure glFogDensity(index, density: cint); inline;
procedure glLoadMatrix4x4(const m: pm4x4); inline;
procedure glLoadMatrix4x3(const m: pm4x3); inline;
procedure glMultMatrix4x4(const m: pm4x4); inline;
@@ -547,6 +556,26 @@ begin
FIFO_VERTEX16 := REG2ID(GFX_VERTEX16);
end;
+function FIFO_VERTEX10(): cuint8; inline;
+begin
+ FIFO_VERTEX10 := REG2ID(GFX_VERTEX10);
+end;
+
+function FIFO_VERTEX_XY(): cuint8; inline;
+begin
+ FIFO_VERTEX_XY := REG2ID(GFX_VERTEX_XY);
+end;
+
+function FIFO_VERTEX_XZ(): cuint8; inline;
+begin
+ FIFO_VERTEX_XZ := REG2ID(GFX_VERTEX_XZ);
+end;
+
+function FIFO_VERTEX_YZ(): cuint8; inline;
+begin
+ FIFO_VERTEX_YZ := REG2ID(GFX_VERTEX_YZ);
+end;
+
function FIFO_TEX_COORD(): cuint8; inline;
begin
FIFO_TEX_COORD := REG2ID(GFX_TEX_COORD);
@@ -757,16 +786,21 @@ end;
procedure glTranslate3f32(x, y, z: cint32); inline;
begin
+ glTranslatef32(x, y, z);
+end;
+
+procedure glTranslatef32(x, y, z: cint32); inline;
+begin
MATRIX_TRANSLATE^ := x;
MATRIX_TRANSLATE^ := y;
MATRIX_TRANSLATE^ := z;
end;
-procedure glScalef32(factor: cint32); inline;
+procedure glScalef32(x, y, z: cint); inline;
begin
- MATRIX_SCALE^ := factor;
- MATRIX_SCALE^ := factor;
- MATRIX_SCALE^ := factor;
+ MATRIX_SCALE^ := x;
+ MATRIX_SCALE^ := y;
+ MATRIX_SCALE^ := z;
end;
procedure glLight(id: cint; color: rgb; x, y, z: v10); inline;
@@ -824,7 +858,9 @@ procedure glCallList(list: pcuint32); inline;
var
count: cuint32;
begin
+ sassert(list <> nil, 'glCallList received a null display list pointer');
count := list^;
+ sassert(count <> 0, 'glCallList received a display list of size 0');
inc(list);
DC_FlushRange(list, count*4);
while ( ((DMA_CR(0)^ and DMA_BUSY) <> 0) or
@@ -854,6 +890,35 @@ begin
GFX_CONTROL^ := GFX_CONTROL^ and not bits;
end;
+
+procedure glFogShift(shift: cint); inline;
+begin
+ sassert((shift >= 0) and (shift < 16), 'glFogShift is out of range');
+ GFX_CONTROL^ := (GFX_CONTROL^ and $F0FF) or (shift shl 8);
+end;
+
+procedure glFogOffset(offset: cint); inline;
+begin
+ sassert((offset >= 0) and (offset < $8000), 'glFogOffset is out of range');
+ GFX_FOG_OFFSET^ := offset;
+end;
+
+procedure glFogColor(red, green, blue, alpha: cuint8); inline;
+begin
+ sassert(red < 32, 'glFogColor red is out of range');
+ sassert(green < 32, 'glFogColor green is out of range');
+ sassert(blue < 32, 'glFogColor blue is out of range');
+ sassert(alpha < 32, 'glFogColor alpha is out of range');
+ GFX_FOG_COLOR^ := RGB15(red, green, blue) or (alpha shl 16);
+end;
+
+procedure glFogDensity(index, density: cint); inline;
+begin
+ sassert((index >= 0) and (index < 32), 'glFogDensity index is out of range');
+ sassert((index >= 0) and (density < 128), 'glFogDensity density is out of range');
+ GFX_FOG_TABLE[index] := density;
+end;
+
procedure glLoadMatrix4x4(const m: pm4x4); inline;
begin
MATRIX_LOAD4x4^ := m^.m[0];
diff --git a/packages/libndsfpc/src/nds/bios.inc b/packages/libndsfpc/src/nds/bios.inc
index f44d3721f1..e2a7651e72 100644
--- a/packages/libndsfpc/src/nds/bios.inc
+++ b/packages/libndsfpc/src/nds/bios.inc
@@ -41,16 +41,18 @@
{$ifdef NDS_INTERFACE}
type
- TGetSize = function(source: pcuint8; dest: pcuint16; r2: cuint32): pcint;
- TGetResult = function(source: pcuint8): pcint;
- TReadByte = function(source: pcuint8): pcuint8;
-
+ TGetHeaderCallback = function(source: pcuint8; dest: pcuint16; r2: cuint32): pcint;
+ getHeaderCallback = TGetHeaderCallback;
+ TGetResultCallback = function(source: pcuint8): pcint;
+ getResultCallback = TGetResultCallback;
+ TGetByteCallback = function(source: pcuint8): pcuint8;
+ getByteCallback = TGetByteCallback;
type
DecompressionStream = packed record
- getSize: TGetSize;
- getResult: TGetResult;
- readByte: TReadByte;
+ getSize: TGetHeaderCallback;
+ getResult: TGetResultCallback;
+ readByte: TGetByteCallback;
end;
TDecompressionStream = DecompressionStream;
PDecompressionStream = ^TDecompressionStream;
diff --git a/packages/libndsfpc/src/nds/card.inc b/packages/libndsfpc/src/nds/card.inc
index 3d659b638e..fcb74f9675 100644
--- a/packages/libndsfpc/src/nds/card.inc
+++ b/packages/libndsfpc/src/nds/card.inc
@@ -1,5 +1,4 @@
(*
- $Id: card.inc 25 2007-12-10 21:06:46Z p4p3r0 $
------------------------------------------------------------------------------
Copyright (C) 2005
Jason Rogers (dovoto)
@@ -25,29 +24,21 @@
distribution.
------------------------------------------------------------------------------
-
Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
(http://www.freepascal.org)
- Copyright (C) 2006 Francesco Lombardi
- Check http://sourceforge.net/projects/libndsfpc for updates
-
------------------------------------------------------------------------------
-
- $Log$
-
*)
{$ifdef NDS_INTERFACE}
const
// Card bus
- CARD_CR1 : pcuint16 = pointer($040001A0);
- CARD_CR1H : pcuint8 = pointer($040001A1);
- CARD_EEPDATA : pcuint8 = pointer($040001A2);
- CARD_CR2 : pcuint32 = pointer($040001A4);
CARD_COMMAND : pcuint8 = pointer($040001A8);
-
+ REG_ROMCTRL : pcuint32 = pointer($040001A4);
+ REG_AUXSPICNT : pcuint16 = pointer($040001A0);
+ REG_AUXSPICNTH : pcuint8 = pointer($040001A1);
+ REG_AUXSPIDATA : pcuint8 = pointer($040001A2);
CARD_DATA_RD : pcuint32 = pointer($04100010);
CARD_1B0 : pcuint32 = pointer($040001B0);
@@ -55,12 +46,17 @@ const
CARD_1B8 : pcuint16 = pointer($040001B8);
CARD_1BA : pcuint16 = pointer($040001BA);
-
CARD_CR1_ENABLE = $80; // in byte 1, i.e. 0x8000
CARD_CR1_IRQ = $40; // in byte 1, i.e. 0x4000
+ // SPI EEPROM COMMANDS
+ EEPROM_WRSR = $01;
+ EEPROM_WRDI = $04;
+ EEPROM_RDSR = $05;
+ EEPROM_WREN = $06;
+ EEPROM_RDID = $9f;
-// CARD_CR2 register:
+// ROMCTRL register:
CARD_ACTIVATE = (1 shl 31); // when writing, get the ball rolling
CARD_WR = (1 shl 30);
CARD_nRESET = (1 shl 29); // value on the /reset pin (1 = high out, not a reset state, 0 = low out = in reset)
@@ -115,9 +111,9 @@ function cardReadID(flags: cuint32): cuint32; cdecl; external;
procedure cardReadEeprom(address: cuint32; data: pcuint8; length: cuint32; addrtype: cuint32); cdecl; external;
procedure cardWriteEeprom(address: cuint32; data: pcuint8; length: cuint32; addrtype: cuint32); cdecl; external;
-function cardEepromReadID(i: cuint8): cuint8; cdecl; external;
+function cardEepromReadID(): cuint32; cdecl; external;
-function cardEepromCommand(command: cuint8; address: cuint32): cuint8; cdecl; external;
+function cardEepromCommand(command: cuint8): cuint8; cdecl; external;
function cardEepromGetType({void}): cint; cdecl; external;
function cardEepromGetSize(): cuint32; cdecl; external;
diff --git a/packages/libndsfpc/src/nds/debug.inc b/packages/libndsfpc/src/nds/debug.inc
index ad0e992d0c..64d1592794 100644
--- a/packages/libndsfpc/src/nds/debug.inc
+++ b/packages/libndsfpc/src/nds/debug.inc
@@ -40,6 +40,7 @@
{$ifdef NDS_INTERFACE}
+procedure nocashWrite(const aMessage: pchar; len: cint); cdecl; external;
procedure nocashMessage(const aMessage: pchar); cdecl; external;
{$endif NDS_INTERFACE}
diff --git a/packages/libndsfpc/src/nds/fifocommon.inc b/packages/libndsfpc/src/nds/fifocommon.inc
index 59c2ca1568..ace9facd49 100644
--- a/packages/libndsfpc/src/nds/fifocommon.inc
+++ b/packages/libndsfpc/src/nds/fifocommon.inc
@@ -83,6 +83,7 @@ const
SYS_REQ_TOUCH : FifoSystemCommands = 0;
SYS_REQ_KEYS : FifoSystemCommands = 1;
SYS_REQ_TIME : FifoSystemCommands = 2;
+ SYS_SET_TIME : FifoSystemCommands = 3;
type
FifoPMCommands = integer;
@@ -93,6 +94,8 @@ const
PM_REQ_SLEEP : FifoPMCommands = (4 shl 16);
PM_REQ_SLEEP_DISABLE : FifoPMCommands = (5 shl 16);
PM_REQ_SLEEP_ENABLE : FifoPMCommands = (6 shl 16);
+ PM_REQ_BATTERY : FifoPMCommands = (7 shl 16);
+ PM_DSI_HACK : FifoPMCommands = (8 shl 16);
type
FifoWifiCommands = integer;
diff --git a/packages/libndsfpc/src/nds/fifomessages.inc b/packages/libndsfpc/src/nds/fifomessages.inc
index ca54b212bc..ef172b0a98 100644
--- a/packages/libndsfpc/src/nds/fifomessages.inc
+++ b/packages/libndsfpc/src/nds/fifomessages.inc
@@ -48,8 +48,8 @@ type
SundPlay: record
_type: cuint16;
data: pointer;
- loopPoint: cuint16;
dataSize: cuint16;
+ loopPoint: cuint16;
freq: cuint16;
volume: cuint8;
pan: cuint8;
@@ -63,6 +63,7 @@ type
dutyCycle: cuint8;
volume: cuint8;
pan: cuint8;
+ channel: cuint8;
end;
);
2: (
diff --git a/packages/libndsfpc/src/nds/memory.inc b/packages/libndsfpc/src/nds/memory.inc
index ac5387452f..55e31786b1 100644
--- a/packages/libndsfpc/src/nds/memory.inc
+++ b/packages/libndsfpc/src/nds/memory.inc
@@ -108,19 +108,19 @@ type
romversion: cuint8;
flags: cuint8; // auto-boot flag
- arm9romSource: cuint32;
+ arm9romOffset: cuint32;
arm9executeAddress: cuint32;
arm9destination: cuint32;
arm9binarySize: cuint32;
- arm7romSource: cuint32;
+ arm7romOffset: cuint32;
arm7executeAddress: cuint32;
arm7destination: cuint32;
arm7binarySize: cuint32;
- filenameSource: cuint32;
+ filenameOffset: cuint32;
filenameSize: cuint32;
- fatSource: cuint32;
+ fatOffset: cuint32;
fatSize: cuint32;
arm9overlaySource: cuint32;
diff --git a/packages/libndsfpc/src/nds/nds.inc b/packages/libndsfpc/src/nds/nds.inc
index a336420c10..15b160fd51 100644
--- a/packages/libndsfpc/src/nds/nds.inc
+++ b/packages/libndsfpc/src/nds/nds.inc
@@ -75,46 +75,51 @@
{$include helper.inc}
-{$include jtypes.inc}
+{$include jtypes.inc} // testing...
+{$include ndstypes.inc} // testing...
{$include bios.inc}
{$include card.inc}
-{$include debug.inc} // testing...
+{$include debug.inc}
{$include dma.inc}
{$include interrupts.inc}
{$include ipc.inc}
{$include memory.inc}
{$include system.inc}
{$include timers.inc}
-{$include fifocommon.inc} // testing...
-{$include touch.inc} // testing...
-{$include input.inc} // testing...
+{$include fifocommon.inc}
+{$include touch.inc}
+{$include input.inc}
+
+{$include dynamicArray.inc} // testing...
+{$include linkedlist.inc} // testing...
{$ifdef ARM9}
{$include arm9/background.inc}
{$include arm9/boxtest.inc}
{$include arm9/cache.inc}
{$include arm9/console.inc}
- {$include arm9/keyboard.inc} // testing...
+ {$include arm9/decompress.inc}
{$include arm9/exceptions.inc}
{$include arm9/image.inc}
{$include arm9/input.inc}
+ {$include arm9/keyboard.inc}
{$include arm9/math.inc}
{$include arm9/pcx.inc}
{$include arm9/rumble.inc}
+ {$include arm9/sassert.inc}
{$include arm9/sound.inc}
+ {$include arm9/sprite.inc}
{$include arm9/trig_lut.inc}
{$include arm9/video.inc}
{$include arm9/videoGL.inc}
- {$include arm9/sprite.inc}
- {$include arm9/decompress.inc} // testing...
{$endif ARM9}
{$ifdef ARM7}
{$include arm7/audio.inc}
{$include arm7/clock.inc}
+ {$include arm7/input.inc}
{$include arm7/serial.inc}
{$include arm7/touch.inc}
- {$include arm7/input.inc} // testing...
{$endif ARM7}
{$ifdef ARM7}
diff --git a/packages/libndsfpc/src/nds/ndsinclude.inc b/packages/libndsfpc/src/nds/ndsinclude.inc
index 5ea21f476a..037ec596d3 100644
--- a/packages/libndsfpc/src/nds/ndsinclude.inc
+++ b/packages/libndsfpc/src/nds/ndsinclude.inc
@@ -1,4 +1,5 @@
+
{ $include helper.inc}
{$include ndstypes.inc}
{$include bios.inc}
@@ -15,11 +16,10 @@
{$include timers.inc}
{$include fifomessages.inc}
{$include input.inc} // testing...
-
-{$include linkedlist.inc}
-{$include dynamicArray.inc}
{$ifdef ARM9}
+ {$include arm9/dynamicArray.inc}
+ {$include arm9/linkedlist.inc}
{$include arm9/sassert.inc}
{$include arm9/background.inc}
{$include arm9/cache.inc}
@@ -35,8 +35,8 @@
{$include arm9/trig_lut.inc}
{$include arm9/video.inc}
{$include arm9/videoGL.inc}
- {$include arm9/postest.inc}
{$include arm9/boxtest.inc}
+ {$include arm9/postest.inc}
{$include arm9/sprite.inc}
{$include arm9/decompress.inc}
{$include arm9/ndsmotion.inc}
diff --git a/packages/libndsfpc/src/nds/registers_alt.inc b/packages/libndsfpc/src/nds/registers_alt.inc
index 01b258a348..5da3832ff2 100644
--- a/packages/libndsfpc/src/nds/registers_alt.inc
+++ b/packages/libndsfpc/src/nds/registers_alt.inc
@@ -305,10 +305,10 @@ const
// Card bus
- REG_CARD_CR1 : pcuint32 = pointer($040001A0);
- REG_CARD_CR1H : pcuint8 = pointer($040001A1);
- REG_CARD_CR2 : pcuint32 = pointer($040001A4);
- REG_CARD_COMMAND : pcuint8 = pointer($040001A8);
+ CARD_CR1 = REG_AUXSPICNT;
+ CARD_CR1H = REG_AUXSPICNTH;
+ CARD_CR2 = REG_ROMCTRL;
+ CARD_EEPDATA = REG_AUXSPIDATA;
REG_CARD_DATA : pcuint32 = pointer($04100000);
REG_CARD_DATA_RD : pcuint32 = pointer($04100010);
diff --git a/packages/libndsfpc/src/nds/system.inc b/packages/libndsfpc/src/nds/system.inc
index de60afff76..1617bc2493 100644
--- a/packages/libndsfpc/src/nds/system.inc
+++ b/packages/libndsfpc/src/nds/system.inc
@@ -55,6 +55,7 @@ const
REG_VCOUNT : pcuint16 = pointer($04000006);
HALT_CR : pcuint16 = pointer($04000300);
REG_POWERCNT : pcuint16 = pointer($04000304);
+ REG_DSIMODE : pcuint32 = pointer($04004000);
procedure SetYtrigger(Yvalue: cint); inline;
@@ -97,6 +98,8 @@ procedure lcdMainOnBottom(); inline;
procedure systemShutDown(); inline;
+function getBatteryLevel(): cuint32; cdecl; external;
+
procedure setVectorBase(highVector: cint); cdecl; external;
type
@@ -152,7 +155,13 @@ procedure systemShutDown(); cdecl; external;
{$endif ARM7}
-
+type
+ BACKLIGHT_LEVELS = cint;
+const
+ BACKLIGHT_LOW : BACKLIGHT_LEVELS = 0;
+ BACKLIGHT_MED : BACKLIGHT_LEVELS = 1;
+ BACKLIGHT_HIGH : BACKLIGHT_LEVELS = 2;
+ BACKLIGHT_MAX : BACKLIGHT_LEVELS = 3;
type
tPERSONAL_DATA = bitpacked record
@@ -191,9 +200,9 @@ type
gbaScreen: 0..1;
defaultBrightness: 0..2;
autoMode: 0..1;
- RESERVED1: 0..2;
+ RESERVED5: 0..2;
settingsLost: 0..1;
- RESERVED2: 0..6;
+ RESERVED6: 0..6;
end;
RESERVED3: cuint16;
rtcOffset: cuint32;
@@ -206,13 +215,19 @@ const
PersonalData : PPERSONAL_DATA = pointer($2FFFC80);
type
- BACKLIGHT_LEVELS = cint;
-const
- BACKLIGHT_LOW : BACKLIGHT_LEVELS = 0;
- BACKLIGHT_MED : BACKLIGHT_LEVELS = 1;
- BACKLIGHT_HIGH : BACKLIGHT_LEVELS = 2;
- BACKLIGHT_MAX : BACKLIGHT_LEVELS = 3;
+ RTCtime = packed record
+ year: cuint8; // add 2000 to get 4 digit year
+ month: cuint8; // 1 to 12
+ day: cuint8; // 1 to (days in month)
+ weekday: cuint8; // day of week
+ hours: cuint8; // 0 to 11 for AM, 52 to 63 for PM
+ minutes: cuint8; // 0 to 59
+ seconds: cuint8; // 0 to 59
+// padding: cuint8;
+ end;
+const
+ ARGV_MAGIC = $5f617267;
type
ppcchar = ^pcchar;
@@ -222,15 +237,19 @@ type
length: cint; // total length of command line
argc: integer;
argv: ppcchar;
+ dummy: cint; // internal use
+ host: cuint32; // internal use, host ip for dslink
end;
Targv = __argv;
Pargv = ^Targv;
const
__system_argv: Pargv = pointer($02FFFE70);
- ARGV_MAGIC = $5f617267;
+
+const
BOOTSIG = $62757473746F6F62; // ULL?
+
type
__bootstub = packed record // packed ?
bootsig: cuint64;
@@ -238,24 +257,13 @@ type
arm7reboot: VoidFn;
bootsize: cuint32;
end;
-
-
-type
- RTCtime = packed record
- year: cuint8; // add 2000 to get 4 digit year
- month: cuint8; // 1 to 12
- day: cuint8; // 1 to (days in month)
- weekday: cuint8; // day of week
- hours: cuint8; // 0 to 11 for AM, 52 to 63 for PM
- minutes: cuint8; // 0 to 59
- seconds: cuint8; // 0 to 59
- padding: cuint8;
- end;
{$ifdef ARM9}
-procedure memCached(address: pointer); cdecl; external;
-procedure memUncached(address: pointer); cdecl; external;
+//procedure memCached(address: pointer); cdecl; external;
+function memCached(address: pointer): pointer; cdecl; external;
+//procedure memUncached(address: pointer); cdecl; external;
+function memUncached(address: pointer): pointer; cdecl; external;
procedure resetARM7(address: cuint32); cdecl; external;
{$endif ARM9}
@@ -295,6 +303,7 @@ procedure systemShutDown(); inline;
begin
powerOn(PM_SYSTEM_PWR);
end;
+
{$endif ARM9}
@@ -320,6 +329,5 @@ begin
end;
{$endif ARM7}
-
{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/nds/timers.inc b/packages/libndsfpc/src/nds/timers.inc
index 7e11397e9b..474f3d165d 100644
--- a/packages/libndsfpc/src/nds/timers.inc
+++ b/packages/libndsfpc/src/nds/timers.inc
@@ -39,27 +39,13 @@
*)
{$ifdef NDS_INTERFACE}
-type
- ClockDivider = cint;
-const
- ClockDivider_1 : ClockDivider = 0;
- ClockDivider_64 : ClockDivider = 1;
- ClockDivider_256 : ClockDivider = 2;
- ClockDivider_1024: ClockDivider = 3;
-
-
-procedure timerStart(channel: cint; divider: ClockDivider; ticks: cuint16; callback: fp); cdecl; external;
-function timerElapsed(channel: cint): cuint16; cdecl; external;
-
-function timerFreqToTicks_1(freq: cint): cuint16; inline;
-function timerFreqToTicks_64(freq: cint): cuint16; inline;
-function timerFreqToTicks_256(freq: cint): cuint16; inline;
-function timerFreqToTicks_1024(freq: cint): cuint16; inline;
-function TIMER_FREQ(n: cint): cint; inline;
-function TIMER_FREQ_64(n: cint): cint; inline;
-function TIMER_FREQ_256(n: cint): cint; inline;
-function TIMER_FREQ_1024(n: cint): cint; inline;
+const
+ TIMER0_CR : pcuint16 = pointer($04000102);
+ TIMER1_CR : pcuint16 = pointer($04000106);
+ TIMER2_CR : pcuint16 = pointer($0400010A);
+ TIMER3_CR : pcuint16 = pointer($0400010E);
+function TIMER_CR(n: cint): pcuint16; inline;
const
TIMER0_DATA : pcuint16 = pointer($04000100);
@@ -68,70 +54,77 @@ const
TIMER3_DATA : pcuint16 = pointer($0400010C);
function TIMER_DATA(n: cuint): pcuint16; inline;
-
const
- TIMER0_CR : pcuint16 = pointer($04000102);
- TIMER1_CR : pcuint16 = pointer($04000106);
- TIMER2_CR : pcuint16 = pointer($0400010A);
- TIMER3_CR : pcuint16 = pointer($0400010E);
-function TIMER_CR(n: cint): pcuint16; inline;
+ BUS_CLOCK = 33513982;
const
TIMER_ENABLE = (1 shl 7);
TIMER_IRQ_REQ = (1 shl 6);
TIMER_CASCADE = (1 shl 2);
+
+
+type
+ ClockDivider = cint;
+const
+ ClockDivider_1 : ClockDivider = 0;
+ ClockDivider_64 : ClockDivider = 1;
+ ClockDivider_256 : ClockDivider = 2;
+ ClockDivider_1024: ClockDivider = 3;
+
+const
TIMER_DIV_1 = (0);
TIMER_DIV_64 = (1);
TIMER_DIV_256 = (2);
TIMER_DIV_1024 = (3);
-procedure timerStop(channel: cint); inline;
-procedure cpuStartTiming(timer: cuint32); cdecl; external;
-function cpuEndTiming(): cuint32; cdecl; external;
-{$endif NDS_INTERFACE}
+function TIMER_FREQ(n: cint): cint; inline;
+function TIMER_FREQ_64(n: cint): cint; inline;
+function TIMER_FREQ_256(n: cint): cint; inline;
+function TIMER_FREQ_1024(n: cint): cint; inline;
+procedure timerStart(channel: cint; divider: ClockDivider; ticks: cuint16; callback: fp); cdecl; external;
+function timerElapsed(channel: cint): cuint16; cdecl; external;
-{$ifdef NDS_IMPLEMENTATION}
+function timerTick(timer: cuint): cuint16; inline;
+function timerPause(timer: cuint): cuint16; cdecl; external;
+procedure timerUnpause(timer: cuint); inline;
-function timerFreqToTicks_1(freq: cint): cuint16; inline;
-begin
- result := -$2000000 div freq;
-end;
+function timerStop(channel: cint): cuint16; cdecl; external;
+procedure cpuStartTiming(timer: cuint32); cdecl; external;
+function cpuGetTiming(): cuint32; cdecl; external;
+function cpuEndTiming(): cuint32; cdecl; external;
-function timerFreqToTicks_64(freq: cint): cuint16; inline;
-begin
- result := (-$2000000 shr 6) div freq;
-end;
+function timerFreqToTicks_1(freq: cint): cuint16; inline;
+function timerFreqToTicks_64(freq: cint): cuint16; inline;
function timerFreqToTicks_256(freq: cint): cuint16; inline;
-begin
- result := (-$2000000 shr 8) div freq;
-end;
-
function timerFreqToTicks_1024(freq: cint): cuint16; inline;
-begin
- result := (-$2000000 shr 10) div freq;
-end;
+
+{$endif NDS_INTERFACE}
+
+
+
+{$ifdef NDS_IMPLEMENTATION}
function TIMER_FREQ(n: cint): cint; inline;
begin
- TIMER_FREQ := cint(-$2000000 div (n));
+ TIMER_FREQ := cint(-BUS_CLOCK div (n));
end;
function TIMER_FREQ_64(n: cint): cint; inline;
begin
- TIMER_FREQ_64 := cint(-($2000000 shr 6) div (n));
+ TIMER_FREQ_64 := cint(-(BUS_CLOCK shr 6) div (n));
end;
function TIMER_FREQ_256(n: cint): cint; inline;
begin
- TIMER_FREQ_256 := cint(-($2000000 shr 8) div (n));
+ TIMER_FREQ_256 := cint(-(BUS_CLOCK shr 8) div (n));
end;
function TIMER_FREQ_1024(n: cint): cint; inline;
begin
- TIMER_FREQ_1024 := cint(-($2000000 shr 10) div (n));
+ TIMER_FREQ_1024 := cint(-(BUS_CLOCK shr 10) div (n));
end;
function TIMER_DATA(n: cuint): pcuint16; inline;
@@ -144,8 +137,34 @@ begin
TIMER_CR := pcuint16($04000102 + (n shl 2));
end;
-procedure timerStop(channel: cint); inline;
+function timerTick(timer: cuint): cuint16; inline;
+begin
+ timerTick := TIMER_DATA(timer)^;
+end;
+
+procedure timerUnpause(timer: cuint); inline;
begin
- TIMER_CR(channel)^ := TIMER_CR(channel)^ and not TIMER_ENABLE;
+ TIMER_CR(timer)^ := TIMER_CR(timer)^ or TIMER_ENABLE;
end;
+
+function timerFreqToTicks_1(freq: cint): cuint16; inline;
+begin
+ result := -BUS_CLOCK div freq;
+end;
+
+function timerFreqToTicks_64(freq: cint): cuint16; inline;
+begin
+ result := (-BUS_CLOCK shr 6) div freq;
+end;
+
+function timerFreqToTicks_256(freq: cint): cuint16; inline;
+begin
+ result := (-BUS_CLOCK shr 8) div freq;
+end;
+
+function timerFreqToTicks_1024(freq: cint): cuint16; inline;
+begin
+ result := (-BUS_CLOCK shr 10) div freq;
+end;
+
{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/nds7.pp b/packages/libndsfpc/src/nds7.pp
index 1b547763f2..7570a37abf 100644
--- a/packages/libndsfpc/src/nds7.pp
+++ b/packages/libndsfpc/src/nds7.pp
@@ -16,8 +16,8 @@ uses
{$linklib nds7}
{$linklib c}
-{$linklib g}
{$linklib gcc}
+{$linklib g}
{$linklib sysbase}
{$define NDS_INTERFACE}
diff --git a/packages/libndsfpc/src/nds9.pp b/packages/libndsfpc/src/nds9.pp
index 8ef5a3bdce..c6f0f0dea6 100644
--- a/packages/libndsfpc/src/nds9.pp
+++ b/packages/libndsfpc/src/nds9.pp
@@ -16,8 +16,8 @@ uses
{$linklib nds9}
{$linklib c}
-{$linklib g}
{$linklib gcc}
+{$linklib g}
{$linklib sysbase}