2008-08-19 Joel Sherrill <joel.sherrill@OARcorp.com>

* dswifi/arm7/makefile, dswifi/include/netinet/in.h,
	libnds/basicARM7/source/defaultARM7.c, libnds/include/gbfs.h,
	libnds/include/nds/bios.h, libnds/include/nds/card.h,
	libnds/include/nds/dma.h, libnds/include/nds/interrupts.h,
	libnds/include/nds/ipc.h, libnds/include/nds/jtypes.h,
	libnds/include/nds/registers_alt.h, libnds/include/nds/system.h,
	libnds/include/nds/timers.h, libnds/include/nds/arm7/audio.h,
	libnds/include/nds/arm7/clock.h, libnds/include/nds/arm7/serial.h,
	libnds/include/nds/arm7/touch.h, libnds/include/nds/arm9/boxtest.h,
	libnds/include/nds/arm9/cache.h, libnds/include/nds/arm9/console.h,
	libnds/include/nds/arm9/ndsmotion.h, libnds/include/nds/arm9/video.h,
	libnds/include/nds/arm9/videoGL.h, libnds/source/arm7/audio.c,
	libnds/source/arm7/clock.c, libnds/source/arm7/microphone.c,
	libnds/source/arm7/touch.c, libnds/source/arm7/userSettings.c,
	libnds/source/arm9/boxtest.c, libnds/source/arm9/gurumeditation.c,
	libnds/source/arm9/ndsmotion.c, libnds/source/arm9/videoGL.c,
	libnds/source/common/card.c,
	libnds/source/common/interruptDispatcher.S, touchscreen/reco.c: Fix
	various warnings by fixing prototypes. Remove unused .bin files.
	Convert all files to UNIX CF/LF.
	* libnds/source/arm9/COS.bin, libnds/source/arm9/SIN.bin,
	libnds/source/arm9/TAN.bin, libnds/source/arm9/default_font.bin: Removed.
This commit is contained in:
Joel Sherrill
2008-08-19 15:47:14 +00:00
parent e1730f64f8
commit 49a4016507
40 changed files with 8065 additions and 8022 deletions
+25
View File
@@ -1,3 +1,28 @@
2008-08-19 Joel Sherrill <joel.sherrill@OARcorp.com>
* dswifi/arm7/makefile, dswifi/include/netinet/in.h,
libnds/basicARM7/source/defaultARM7.c, libnds/include/gbfs.h,
libnds/include/nds/bios.h, libnds/include/nds/card.h,
libnds/include/nds/dma.h, libnds/include/nds/interrupts.h,
libnds/include/nds/ipc.h, libnds/include/nds/jtypes.h,
libnds/include/nds/registers_alt.h, libnds/include/nds/system.h,
libnds/include/nds/timers.h, libnds/include/nds/arm7/audio.h,
libnds/include/nds/arm7/clock.h, libnds/include/nds/arm7/serial.h,
libnds/include/nds/arm7/touch.h, libnds/include/nds/arm9/boxtest.h,
libnds/include/nds/arm9/cache.h, libnds/include/nds/arm9/console.h,
libnds/include/nds/arm9/ndsmotion.h, libnds/include/nds/arm9/video.h,
libnds/include/nds/arm9/videoGL.h, libnds/source/arm7/audio.c,
libnds/source/arm7/clock.c, libnds/source/arm7/microphone.c,
libnds/source/arm7/touch.c, libnds/source/arm7/userSettings.c,
libnds/source/arm9/boxtest.c, libnds/source/arm9/gurumeditation.c,
libnds/source/arm9/ndsmotion.c, libnds/source/arm9/videoGL.c,
libnds/source/common/card.c,
libnds/source/common/interruptDispatcher.S, touchscreen/reco.c: Fix
various warnings by fixing prototypes. Remove unused .bin files.
Convert all files to UNIX CF/LF.
* libnds/source/arm9/COS.bin, libnds/source/arm9/SIN.bin,
libnds/source/arm9/TAN.bin, libnds/source/arm9/default_font.bin: Removed.
2008-07-29 Chris Johns <chrisj@rtems.org>
* block/block.c: Update to the libblock changes.
+145 -145
View File
@@ -1,145 +1,145 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
endif
include $(DEVKITARM)/ds_rules
TOPDIR ?= $(CURDIR)/..
#---------------------------------------------------------------------------------
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files
# all directories are relative to this makefile
#---------------------------------------------------------------------------------
BUILD ?= release
SOURCES := source ../common/source
INCLUDES := include build ../common/source ../include
DATA :=
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb-interwork
CFLAGS := -g -Wall -O2\
-mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\
-ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM7
CXXFLAGS := $(CFLAGS)
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*).map
ifneq ($(BUILD),debug)
export ARM7BIN := $(TOPDIR)/lib/libdswifi7.a
else
export ARM7BIN := $(TOPDIR)/lib/libdswifi7d.a
CFLAGS += -DSGIP_DEBUG
endif
LIBS :=
#-lnds7
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export DEPSDIR := $(CURDIR)/$(BUILD)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr debug release
@rm -f $(TOPDIR)/lib/libdswifi7*
all: $(ARM7BIN)
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(ARM7BIN) : $(OFILES)
@rm -f "$(ARM7BIN)"
@$(AR) rcs "$(ARM7BIN)" $(OFILES)
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
endif
include $(DEVKITARM)/ds_rules
TOPDIR ?= $(CURDIR)/..
#---------------------------------------------------------------------------------
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files
# all directories are relative to this makefile
#---------------------------------------------------------------------------------
BUILD ?= release
SOURCES := source ../common/source
INCLUDES := include build ../common/source ../include
DATA :=
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb-interwork
CFLAGS := -g -Wall -O2\
-mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\
-ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM7
CXXFLAGS := $(CFLAGS)
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*).map
ifneq ($(BUILD),debug)
export ARM7BIN := $(TOPDIR)/lib/libdswifi7.a
else
export ARM7BIN := $(TOPDIR)/lib/libdswifi7d.a
CFLAGS += -DSGIP_DEBUG
endif
LIBS :=
#-lnds7
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export DEPSDIR := $(CURDIR)/$(BUILD)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr debug release
@rm -f $(TOPDIR)/lib/libdswifi7*
all: $(ARM7BIN)
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(ARM7BIN) : $(OFILES)
@rm -f "$(ARM7BIN)"
@$(AR) rcs "$(ARM7BIN)" $(OFILES)
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
@@ -51,7 +51,7 @@ extern "C" {
// actually from arpa/inet.h - but is included through netinet/in.h
unsigned long inet_addr(const char *cp);
int inet_aton(const char *cp, struct in_addr *inp);
char *inet_ntoa(struct in_addr in);
char *inet_ntoa(struct in_addr in);
#ifdef __cplusplus
};
@@ -1,50 +1,50 @@
/*---------------------------------------------------------------------------------
default ARM7 core
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------
default ARM7 core
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include <nds.h>
//---------------------------------------------------------------------------------
void startSound(int sampleRate, const void* data, u32 bytes, u8 channel, u8 vol, u8 pan, u8 format) {
//---------------------------------------------------------------------------------
SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate);
SCHANNEL_SOURCE(channel) = (u32)data;
SCHANNEL_LENGTH(channel) = bytes >> 2 ;
SCHANNEL_CR(channel) = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT);
}
//---------------------------------------------------------------------------------
s32 getFreeSoundChannel() {
//---------------------------------------------------------------------------------
int i;
for (i=0; i<16; i++) {
if ( (SCHANNEL_CR(i) & SCHANNEL_ENABLE) == 0 ) return i;
}
return -1;
}
//---------------------------------------------------------------------------------
void startSound(int sampleRate, const void* data, u32 bytes, u8 channel, u8 vol, u8 pan, u8 format) {
//---------------------------------------------------------------------------------
SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate);
SCHANNEL_SOURCE(channel) = (u32)data;
SCHANNEL_LENGTH(channel) = bytes >> 2 ;
SCHANNEL_CR(channel) = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT);
}
//---------------------------------------------------------------------------------
s32 getFreeSoundChannel() {
//---------------------------------------------------------------------------------
int i;
for (i=0; i<16; i++) {
if ( (SCHANNEL_CR(i) & SCHANNEL_ENABLE) == 0 ) return i;
}
return -1;
}
touchPosition first,tempPos;
@@ -89,27 +89,27 @@ void VcountHandler() {
}
//---------------------------------------------------------------------------------
void VblankHandler(void) {
//---------------------------------------------------------------------------------
u32 i;
//sound code :)
TransferSound *snd = IPC->soundData;
IPC->soundData = 0;
if (0 != snd) {
for (i=0; i<snd->count; i++) {
s32 chan = getFreeSoundChannel();
if (chan >= 0) {
startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format);
}
}
}
}
//---------------------------------------------------------------------------------
void VblankHandler(void) {
//---------------------------------------------------------------------------------
u32 i;
//sound code :)
TransferSound *snd = IPC->soundData;
IPC->soundData = 0;
if (0 != snd) {
for (i=0; i<snd->count; i++) {
s32 chan = getFreeSoundChannel();
if (chan >= 0) {
startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format);
}
}
}
}
//---------------------------------------------------------------------------------
@@ -131,7 +131,7 @@ int main(int argc, char ** argv) {
SetYtrigger(80);
irqSet(IRQ_VCOUNT, VcountHandler);
irqSet(IRQ_VBLANK, VblankHandler);
irqSet(IRQ_VBLANK, VblankHandler);
irqEnable( IRQ_VBLANK | IRQ_VCOUNT);
+100 -100
View File
@@ -1,100 +1,100 @@
/*---------------------------------------------------------------------------------
$Id$
access object in a GBFS file
Copyright 2002-2004 Damian Yerrick
Additional code Dave Murphy
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
---------------------------------------------------------------------------------*/
/* Dependency on prior include files
Before you #include "gbfs.h", you should define the following types:
typedef (unsigned 16-bit integer) u16;
typedef (unsigned 32-bit integer) u32;
Your system header should do this for you.
*/
#ifndef _INCLUDE_GBFS_H_
#define _INCLUDE_GBFS_H_
#ifdef __cplusplus
extern "C" {
#endif
/* to make a 300 KB space called samples do GBFS_SPACE(samples, 300) */
#define GBFS_SPACE(filename, kbytes) \
const char filename[(kbytes)*1024] __attribute__ ((aligned (16))) = \
"PinEightGBFSSpace-" #filename "-" #kbytes ;
typedef struct GBFS_FILE {
char magic[16]; /* "PinEightGBFS\r\n\032\n" */
u32 total_len; /* total length of archive */
u16 dir_off; /* offset in bytes to directory */
u16 dir_nmemb; /* number of files */
char reserved[8]; /* for future use */
} GBFS_FILE;
typedef struct GBFS_ENTRY {
char name[24]; /* filename, nul-padded */
u32 len; /* length of object in bytes */
u32 data_offset; /* in bytes from beginning of file */
} GBFS_ENTRY;
/*---------------------------------------------------------------------------------
Set the search limits and stride for searching
---------------------------------------------------------------------------------*/
void gbfs_search_range( u32 gbfs_1st_limit,
u32 gbfs_2nd_start, u32 gbfs_2nd_limit,
u32 gbfs_stride );
const GBFS_FILE * find_first_gbfs_file(const void *start);
const void *skip_gbfs_file(const GBFS_FILE * file);
const void *gbfs_get_obj(const GBFS_FILE *file,
const char *name,
u32 *len);
const void *gbfs_get_nth_obj(GBFS_FILE const * file,
size_t n,
char *name,
u32 *len);
void *gbfs_copy_obj(void *dst,
const GBFS_FILE *file,
const char *name);
size_t gbfs_count_objs(const GBFS_FILE *file);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_GBFS_H_
/*---------------------------------------------------------------------------------
$Id$
access object in a GBFS file
Copyright 2002-2004 Damian Yerrick
Additional code Dave Murphy
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
---------------------------------------------------------------------------------*/
/* Dependency on prior include files
Before you #include "gbfs.h", you should define the following types:
typedef (unsigned 16-bit integer) u16;
typedef (unsigned 32-bit integer) u32;
Your system header should do this for you.
*/
#ifndef _INCLUDE_GBFS_H_
#define _INCLUDE_GBFS_H_
#ifdef __cplusplus
extern "C" {
#endif
/* to make a 300 KB space called samples do GBFS_SPACE(samples, 300) */
#define GBFS_SPACE(filename, kbytes) \
const char filename[(kbytes)*1024] __attribute__ ((aligned (16))) = \
"PinEightGBFSSpace-" #filename "-" #kbytes ;
typedef struct GBFS_FILE {
char magic[16]; /* "PinEightGBFS\r\n\032\n" */
u32 total_len; /* total length of archive */
u16 dir_off; /* offset in bytes to directory */
u16 dir_nmemb; /* number of files */
char reserved[8]; /* for future use */
} GBFS_FILE;
typedef struct GBFS_ENTRY {
char name[24]; /* filename, nul-padded */
u32 len; /* length of object in bytes */
u32 data_offset; /* in bytes from beginning of file */
} GBFS_ENTRY;
/*---------------------------------------------------------------------------------
Set the search limits and stride for searching
---------------------------------------------------------------------------------*/
void gbfs_search_range( u32 gbfs_1st_limit,
u32 gbfs_2nd_start, u32 gbfs_2nd_limit,
u32 gbfs_stride );
const GBFS_FILE * find_first_gbfs_file(const void *start);
const void *skip_gbfs_file(const GBFS_FILE * file);
const void *gbfs_get_obj(const GBFS_FILE *file,
const char *name,
u32 *len);
const void *gbfs_get_nth_obj(GBFS_FILE const * file,
size_t n,
char *name,
u32 *len);
void *gbfs_copy_obj(void *dst,
const GBFS_FILE *file,
const char *name);
size_t gbfs_count_objs(const GBFS_FILE *file);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_GBFS_H_
@@ -1,141 +1,141 @@
/*---------------------------------------------------------------------------------
$Id$
ARM7 audio control
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef AUDIO_ARM7_INCLUDE
#define AUDIO_ARM7_INCLUDE
//---------------------------------------------------------------------------------
// Sound (ARM7 only)
//---------------------------------------------------------------------------------
#ifndef ARM7
#error Audio is only available on the ARM7
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <nds/arm7/serial.h>
#define SOUND_VOL(n) (n)
#define SOUND_FREQ(n) ((-0x1000000 / (n)))
#define SOUND_ENABLE BIT(15)
#define SOUND_REPEAT BIT(27)
#define SOUND_ONE_SHOT BIT(28)
#define SOUND_FORMAT_16BIT (1<<29)
#define SOUND_FORMAT_8BIT (0<<29)
#define SOUND_FORMAT_PSG (3<<29)
#define SOUND_FORMAT_ADPCM (2<<29)
#define SOUND_16BIT (1<<29)
#define SOUND_8BIT (0)
#define SOUND_PAN(n) ((n) << 16)
#define SCHANNEL_ENABLE BIT(31)
//---------------------------------------------------------------------------------
// registers
//---------------------------------------------------------------------------------
#define SCHANNEL_CR(n) (*(vuint32*)(0x04000400 + ((n)<<4)))
#define SCHANNEL_VOL(n) (*(vuint8*)(0x04000400 + ((n)<<4)))
#define SCHANNEL_PAN(n) (*(vuint8*)(0x04000402 + ((n)<<4)))
#define SCHANNEL_SOURCE(n) (*(vuint32*)(0x04000404 + ((n)<<4)))
#define SCHANNEL_TIMER(n) (*(vint16*)(0x04000408 + ((n)<<4)))
#define SCHANNEL_REPEAT_POINT(n) (*(vuint16*)(0x0400040A + ((n)<<4)))
#define SCHANNEL_LENGTH(n) (*(vuint32*)(0x0400040C + ((n)<<4)))
#define SOUND_CR (*(vuint16*)0x04000500)
#define SOUND_MASTER_VOL (*(vuint8*)0x04000500)
//---------------------------------------------------------------------------------
// not sure on the following
//---------------------------------------------------------------------------------
#define SOUND_BIAS (*(vuint16*)0x04000504)
#define SOUND508 (*(vuint16*)0x04000508)
#define SOUND510 (*(vuint16*)0x04000510)
#define SOUND514 (*(vuint16*)0x04000514)
#define SOUND518 (*(vuint16*)0x04000518)
#define SOUND51C (*(vuint16*)0x0400051C)
/*---------------------------------------------------------------------------------
microphone code based on neimod's microphone example.
See: http://neimod.com/dstek/
Chris Double (chris.double@double.co.nz)
http://www.double.co.nz/nintendo_ds
---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------
Read a byte from the microphone
---------------------------------------------------------------------------------*/
u8 MIC_ReadData();
/*---------------------------------------------------------------------------------
Fill the buffer with data from the microphone. The buffer will be
signed sound data at 16kHz. Once the length of the buffer is
reached, no more data will be stored. Uses ARM7 timer 0.
---------------------------------------------------------------------------------*/
void StartRecording(u8* buffer, int length);
/*---------------------------------------------------------------------------------
Stop recording data, and return the length of data recorded.
---------------------------------------------------------------------------------*/
int StopRecording();
/* This must be called during IRQ_TIMER0 */
void ProcessMicrophoneTimerIRQ();
void PM_SetAmp(u8 control);
//---------------------------------------------------------------------------------
// Turn the microphone on
//---------------------------------------------------------------------------------
static inline void MIC_On() {
//---------------------------------------------------------------------------------
PM_SetAmp(PM_AMP_ON);
}
//---------------------------------------------------------------------------------
// Turn the microphone off
//---------------------------------------------------------------------------------
static inline void MIC_Off() {
//---------------------------------------------------------------------------------
PM_SetAmp(PM_AMP_OFF);
}
#ifdef __cplusplus
}
#endif
#endif
/*---------------------------------------------------------------------------------
$Id$
ARM7 audio control
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef AUDIO_ARM7_INCLUDE
#define AUDIO_ARM7_INCLUDE
//---------------------------------------------------------------------------------
// Sound (ARM7 only)
//---------------------------------------------------------------------------------
#ifndef ARM7
#error Audio is only available on the ARM7
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <nds/arm7/serial.h>
#define SOUND_VOL(n) (n)
#define SOUND_FREQ(n) ((-0x1000000 / (n)))
#define SOUND_ENABLE BIT(15)
#define SOUND_REPEAT BIT(27)
#define SOUND_ONE_SHOT BIT(28)
#define SOUND_FORMAT_16BIT (1<<29)
#define SOUND_FORMAT_8BIT (0<<29)
#define SOUND_FORMAT_PSG (3<<29)
#define SOUND_FORMAT_ADPCM (2<<29)
#define SOUND_16BIT (1<<29)
#define SOUND_8BIT (0)
#define SOUND_PAN(n) ((n) << 16)
#define SCHANNEL_ENABLE BIT(31)
//---------------------------------------------------------------------------------
// registers
//---------------------------------------------------------------------------------
#define SCHANNEL_CR(n) (*(vuint32*)(0x04000400 + ((n)<<4)))
#define SCHANNEL_VOL(n) (*(vuint8*)(0x04000400 + ((n)<<4)))
#define SCHANNEL_PAN(n) (*(vuint8*)(0x04000402 + ((n)<<4)))
#define SCHANNEL_SOURCE(n) (*(vuint32*)(0x04000404 + ((n)<<4)))
#define SCHANNEL_TIMER(n) (*(vint16*)(0x04000408 + ((n)<<4)))
#define SCHANNEL_REPEAT_POINT(n) (*(vuint16*)(0x0400040A + ((n)<<4)))
#define SCHANNEL_LENGTH(n) (*(vuint32*)(0x0400040C + ((n)<<4)))
#define SOUND_CR (*(vuint16*)0x04000500)
#define SOUND_MASTER_VOL (*(vuint8*)0x04000500)
//---------------------------------------------------------------------------------
// not sure on the following
//---------------------------------------------------------------------------------
#define SOUND_BIAS (*(vuint16*)0x04000504)
#define SOUND508 (*(vuint16*)0x04000508)
#define SOUND510 (*(vuint16*)0x04000510)
#define SOUND514 (*(vuint16*)0x04000514)
#define SOUND518 (*(vuint16*)0x04000518)
#define SOUND51C (*(vuint16*)0x0400051C)
/*---------------------------------------------------------------------------------
microphone code based on neimod's microphone example.
See: http://neimod.com/dstek/
Chris Double (chris.double@double.co.nz)
http://www.double.co.nz/nintendo_ds
---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------
Read a byte from the microphone
---------------------------------------------------------------------------------*/
u8 MIC_ReadData();
/*---------------------------------------------------------------------------------
Fill the buffer with data from the microphone. The buffer will be
signed sound data at 16kHz. Once the length of the buffer is
reached, no more data will be stored. Uses ARM7 timer 0.
---------------------------------------------------------------------------------*/
void StartRecording(u8* buffer, int length);
/*---------------------------------------------------------------------------------
Stop recording data, and return the length of data recorded.
---------------------------------------------------------------------------------*/
int StopRecording();
/* This must be called during IRQ_TIMER0 */
void ProcessMicrophoneTimerIRQ();
void PM_SetAmp(u8 control);
//---------------------------------------------------------------------------------
// Turn the microphone on
//---------------------------------------------------------------------------------
static inline void MIC_On() {
//---------------------------------------------------------------------------------
PM_SetAmp(PM_AMP_ON);
}
//---------------------------------------------------------------------------------
// Turn the microphone off
//---------------------------------------------------------------------------------
static inline void MIC_Off() {
//---------------------------------------------------------------------------------
PM_SetAmp(PM_AMP_OFF);
}
#ifdef __cplusplus
}
#endif
#endif
@@ -1,140 +1,140 @@
/*---------------------------------------------------------------------------------
ARM7 realtime clock
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef ARM7_CLOCK_INCLUDE
#define ARM7_CLOCK_INCLUDE
#ifndef ARM7
#error The clock is only available on the ARM7
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <nds/arm7/serial.h>
// RTC registers
#define WRITE_STATUS_REG1 0x60
#define READ_STATUS_REG1 0x61
/*
Status Register 1
0 W Reset (0=Normal, 1=Reset)
1 R/W 12/24 hour mode (0=12 hour, 1=24 hour)
2-3 R/W General purpose bits
4 R Interrupt 1 Flag (1=Yes) ;auto-cleared on read
5 R Interrupt 2 Flag (1=Yes) ;auto-cleared on read
6 R Power Low Flag (0=Normal, 1=Power is/was low) ;auto-cleared on read
7 R Power Off Flag (0=Normal, 1=Power was off) ;auto-cleared on read
Power off indicates that the battery was removed or fully discharged,
all registers are reset to 00h (or 01h), and must be re-initialized.
*/
#define STATUS_POC (1<<7) // read-only, cleared by reading (1 if just powered on)
#define STATUS_BLD (1<<6) // read-only, cleared by reading (1 if power dropped below the safety threshold)
#define STATUS_INT2 (1<<5) // read-only, INT2 has occured
#define STATUS_INT1 (1<<4) // read-only, INT1 has occured
#define STATUS_SC1 (1<<3) // R/W scratch bit
#define STATUS_SC0 (1<<2) // R/W scratch bit
#define STATUS_24HRS (1<<1) // 24 hour mode when 1, 12 hour mode when 0
#define STATUS_RESET (1<<0) // write-only, reset when 1 written
#define WRITE_STATUS_REG2 0x62
#define READ_STATUS_REG2 0x63
/*
Status Register 2
0-3 R/W INT1 Mode/Enable
0000b Disable
0x01b Selected Frequency steady interrupt
0x10b Per-minute edge interrupt
0011b Per-minute steady interrupt 1 (duty 30.0 secomds)
0100b Alarm 1 interrupt
0111b Per-minute steady interrupt 2 (duty 0.0079 secomds)
1xxxb 32kHz output
4-5 R/W General purpose bits
6 R/W INT2 Enable
0b Disable
1b Alarm 2 interrupt
7 R/W Test Mode (0=Normal, 1=Test, don't use) (cleared on Reset)
*/
#define STATUS_TEST (1<<7) //
#define STATUS_INT2AE (1<<6) //
#define STATUS_SC3 (1<<5) // R/W scratch bit
#define STATUS_SC2 (1<<4) // R/W scratch bit
#define STATUS_32kE (1<<3) // Interrupt mode bits
#define STATUS_INT1AE (1<<2) //
#define STATUS_INT1ME (1<<1) //
#define STATUS_INT1FE (1<<0) //
// full 7 bytes for time and date
#define WRITE_TIME_AND_DATE 0x64
#define READ_TIME_AND_DATE 0x65
// last 3 bytes of current time
#define WRITE_TIME 0x66
#define READ_TIME 0x67
#define WRITE_INT_REG1 0x68
#define READ_INT_REG1 0x69
#define READ_INT_REG2 0x6A
#define WRITE_INT_REG2 0x6B
#define READ_CLOCK_ADJUST_REG 0x6C
#define WRITE_CLOCK_ADJUST_REG 0x6D
// clock-adjustment register
#define READ_FREE_REG 0x6E
#define WRITE_FREE_REG 0x6F
void rtcReset(void);
void rtcTransaction(uint8 * command, uint32 commandLength, uint8 * result, uint32 resultLength);
void rtcGetTime(uint8 * time);
void rtcSetTime(uint8 * time);
void rtcGetTimeAndDate(uint8 * time);
void rtcSetTimeAndDate(uint8 * time);
void rtcGetData(uint8 * data, uint32 size);
void BCDToInteger(uint8 * data, uint32 length);
void integerToBCD(uint8 * data, uint32 length);
void initClockIRQ();
#ifdef __cplusplus
}
#endif
#endif
/*---------------------------------------------------------------------------------
ARM7 realtime clock
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef ARM7_CLOCK_INCLUDE
#define ARM7_CLOCK_INCLUDE
#ifndef ARM7
#error The clock is only available on the ARM7
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <nds/arm7/serial.h>
// RTC registers
#define WRITE_STATUS_REG1 0x60
#define READ_STATUS_REG1 0x61
/*
Status Register 1
0 W Reset (0=Normal, 1=Reset)
1 R/W 12/24 hour mode (0=12 hour, 1=24 hour)
2-3 R/W General purpose bits
4 R Interrupt 1 Flag (1=Yes) ;auto-cleared on read
5 R Interrupt 2 Flag (1=Yes) ;auto-cleared on read
6 R Power Low Flag (0=Normal, 1=Power is/was low) ;auto-cleared on read
7 R Power Off Flag (0=Normal, 1=Power was off) ;auto-cleared on read
Power off indicates that the battery was removed or fully discharged,
all registers are reset to 00h (or 01h), and must be re-initialized.
*/
#define STATUS_POC (1<<7) // read-only, cleared by reading (1 if just powered on)
#define STATUS_BLD (1<<6) // read-only, cleared by reading (1 if power dropped below the safety threshold)
#define STATUS_INT2 (1<<5) // read-only, INT2 has occured
#define STATUS_INT1 (1<<4) // read-only, INT1 has occured
#define STATUS_SC1 (1<<3) // R/W scratch bit
#define STATUS_SC0 (1<<2) // R/W scratch bit
#define STATUS_24HRS (1<<1) // 24 hour mode when 1, 12 hour mode when 0
#define STATUS_RESET (1<<0) // write-only, reset when 1 written
#define WRITE_STATUS_REG2 0x62
#define READ_STATUS_REG2 0x63
/*
Status Register 2
0-3 R/W INT1 Mode/Enable
0000b Disable
0x01b Selected Frequency steady interrupt
0x10b Per-minute edge interrupt
0011b Per-minute steady interrupt 1 (duty 30.0 secomds)
0100b Alarm 1 interrupt
0111b Per-minute steady interrupt 2 (duty 0.0079 secomds)
1xxxb 32kHz output
4-5 R/W General purpose bits
6 R/W INT2 Enable
0b Disable
1b Alarm 2 interrupt
7 R/W Test Mode (0=Normal, 1=Test, don't use) (cleared on Reset)
*/
#define STATUS_TEST (1<<7) //
#define STATUS_INT2AE (1<<6) //
#define STATUS_SC3 (1<<5) // R/W scratch bit
#define STATUS_SC2 (1<<4) // R/W scratch bit
#define STATUS_32kE (1<<3) // Interrupt mode bits
#define STATUS_INT1AE (1<<2) //
#define STATUS_INT1ME (1<<1) //
#define STATUS_INT1FE (1<<0) //
// full 7 bytes for time and date
#define WRITE_TIME_AND_DATE 0x64
#define READ_TIME_AND_DATE 0x65
// last 3 bytes of current time
#define WRITE_TIME 0x66
#define READ_TIME 0x67
#define WRITE_INT_REG1 0x68
#define READ_INT_REG1 0x69
#define READ_INT_REG2 0x6A
#define WRITE_INT_REG2 0x6B
#define READ_CLOCK_ADJUST_REG 0x6C
#define WRITE_CLOCK_ADJUST_REG 0x6D
// clock-adjustment register
#define READ_FREE_REG 0x6E
#define WRITE_FREE_REG 0x6F
void rtcReset(void);
void rtcTransaction(uint8 * command, uint32 commandLength, uint8 * result, uint32 resultLength);
void rtcGetTime(uint8 * time);
void rtcSetTime(uint8 * time);
void rtcGetTimeAndDate(uint8 * time);
void rtcSetTimeAndDate(uint8 * time);
void rtcGetData(uint8 * data, uint32 size);
void BCDToInteger(uint8 * data, uint32 length);
void integerToBCD(uint8 * data, uint32 length);
void initClockIRQ();
#ifdef __cplusplus
}
#endif
#endif
@@ -1,167 +1,167 @@
/*---------------------------------------------------------------------------------
$Id$
ARM7 serial control
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef SERIAL_ARM7_INCLUDE
#define SERIAL_ARM7_INCLUDE
#ifndef ARM7
#error Serial header is for ARM7 only
#endif
#include <nds/bios.h>
// 'Networking'
#define REG_RCNT (*(vuint16*)0x04000134)
#define REG_KEYXY (*(vuint16*)0x04000136)
#define RTC_CR (*(vuint16*)0x04000138)
#define RTC_CR8 (*( vuint8*)0x04000138)
#define REG_SIOCNT (*(vuint16*)0x04000128)
#define SIO_DATA8 (*(vuint8*)0x0400012A)
#define SIO_DATA32 (*(vuint32*)0x04000120)
// Fixme: Does the hardware still support 16 bit comms mode?
// BIOS makes use of 32 bit mode, so some regs still exist
#define SIO_MULTI_0 (*(vuint16*)0x04000120)
#define SIO_MULTI_1 (*(vuint16*)0x04000122)
#define SIO_MULTI_2 (*(vuint16*)0x04000124)
#define SIO_MULTI_3 (*(vuint16*)0x04000126)
#define SIO_MULTI_SEND (*(vuint16*)0x0400012A)
// SPI chain registers
#define REG_SPICNT (*(vuint16*)0x040001C0)
#define REG_SPIDATA (*(vuint16*)0x040001C2)
#define SPI_ENABLE BIT(15)
#define SPI_IRQ BIT(14)
#define SPI_BUSY BIT(7)
// Pick the SPI clock speed
#define SPI_BAUD_4MHZ 0
#define SPI_BAUD_2MHZ 1
#define SPI_BAUD_1MHZ 2
#define SPI_BAUD_512KHZ 3
// meh
#define SPI_BAUD_4MHz 0
#define SPI_BAUD_2MHz 1
#define SPI_BAUD_1MHz 2
#define SPI_BAUD_512KHz 3
// Pick the SPI transfer length
#define SPI_BYTE_MODE (0<<10)
#define SPI_HWORD_MODE (1<<10)
// Pick the SPI device
#define SPI_DEVICE_POWER (0 << 8)
#define SPI_DEVICE_FIRMWARE (1 << 8)
#define SPI_DEVICE_NVRAM (1 << 8)
#define SPI_DEVICE_TOUCH (2 << 8)
#define SPI_DEVICE_MICROPHONE (2 << 8)
// When used, the /CS line will stay low after the transfer ends
// i.e. when we're part of a continuous transfer
#define SPI_CONTINUOUS BIT(11)
// Fixme: does this stuff really belong in serial.h?
// Power management registers
#define PM_CONTROL_REG 0
#define PM_BATTERY_REG 1
#define PM_AMPLIFIER_REG 2
#define PM_READ_REGISTER (1<<7)
// PM control register bits - power control
#define PM_SOUND_AMP BIT(0) // Power the sound hardware (needed to hear stuff in GBA mode too)
#define PM_SOUND_MUTE BIT(1) // Mute the main speakers, headphone output will still work.
#define PM_BACKLIGHT_BOTTOM BIT(2) // Enable the top backlight if set
#define PM_BACKLIGHT_TOP BIT(3) // Enable the bottom backlight if set
#define PM_SYSTEM_PWR BIT(6) // Turn the power *off* if set
#define PM_POWER_DOWN BIT(6) // Same thing, I like this name better tho
// PM control register bits - LED control
#define PM_LED_CONTROL(m) ((m)<<4) // ?
#define PM_LED_ON (0<<4) // Steady on
#define PM_LED_SLEEP (1<<4) // Blinking, mostly off
#define PM_LED_BLINK (3<<4) // Blinking, mostly on
#define PM_AMP_OFFSET 2
#define PM_AMP_ON 1
#define PM_AMP_OFF 0
// Fixme: does this stuff really belong in serial.h?
// Firmware commands
#define FIRMWARE_WREN 0x06
#define FIRMWARE_WRDI 0x04
#define FIRMWARE_RDID 0x9F
#define FIRMWARE_RDSR 0x05
#define FIRMWARE_READ 0x03
#define FIRMWARE_PW 0x0A
#define FIRMWARE_PP 0x02
#define FIRMWARE_FAST 0x0B
#define FIRMWARE_PE 0xDB
#define FIRMWARE_SE 0xD8
#define FIRMWARE_DP 0xB9
#define FIRMWARE_RDP 0xAB
static inline
void SerialWaitBusy() {
while (REG_SPICNT & SPI_BUSY)
swiDelay(1);
}
// Warning: These functions use the SPI chain, and are thus 'critical'
// sections, make sure to disable interrupts during the call if you've
// got a VBlank IRQ polling the touch screen, etc...
// Read/write a power management register
int writePowerManagement(int reg, int command);
static inline
int readPowerManagement(int reg) {
return writePowerManagement((reg)|PM_READ_REGISTER, 0);
}
// Read the firmware
void readFirmware(uint32 address, void * destination, uint32 size);
#endif
/*---------------------------------------------------------------------------------
$Id$
ARM7 serial control
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef SERIAL_ARM7_INCLUDE
#define SERIAL_ARM7_INCLUDE
#ifndef ARM7
#error Serial header is for ARM7 only
#endif
#include <nds/bios.h>
// 'Networking'
#define REG_RCNT (*(vuint16*)0x04000134)
#define REG_KEYXY (*(vuint16*)0x04000136)
#define RTC_CR (*(vuint16*)0x04000138)
#define RTC_CR8 (*( vuint8*)0x04000138)
#define REG_SIOCNT (*(vuint16*)0x04000128)
#define SIO_DATA8 (*(vuint8*)0x0400012A)
#define SIO_DATA32 (*(vuint32*)0x04000120)
// Fixme: Does the hardware still support 16 bit comms mode?
// BIOS makes use of 32 bit mode, so some regs still exist
#define SIO_MULTI_0 (*(vuint16*)0x04000120)
#define SIO_MULTI_1 (*(vuint16*)0x04000122)
#define SIO_MULTI_2 (*(vuint16*)0x04000124)
#define SIO_MULTI_3 (*(vuint16*)0x04000126)
#define SIO_MULTI_SEND (*(vuint16*)0x0400012A)
// SPI chain registers
#define REG_SPICNT (*(vuint16*)0x040001C0)
#define REG_SPIDATA (*(vuint16*)0x040001C2)
#define SPI_ENABLE BIT(15)
#define SPI_IRQ BIT(14)
#define SPI_BUSY BIT(7)
// Pick the SPI clock speed
#define SPI_BAUD_4MHZ 0
#define SPI_BAUD_2MHZ 1
#define SPI_BAUD_1MHZ 2
#define SPI_BAUD_512KHZ 3
// meh
#define SPI_BAUD_4MHz 0
#define SPI_BAUD_2MHz 1
#define SPI_BAUD_1MHz 2
#define SPI_BAUD_512KHz 3
// Pick the SPI transfer length
#define SPI_BYTE_MODE (0<<10)
#define SPI_HWORD_MODE (1<<10)
// Pick the SPI device
#define SPI_DEVICE_POWER (0 << 8)
#define SPI_DEVICE_FIRMWARE (1 << 8)
#define SPI_DEVICE_NVRAM (1 << 8)
#define SPI_DEVICE_TOUCH (2 << 8)
#define SPI_DEVICE_MICROPHONE (2 << 8)
// When used, the /CS line will stay low after the transfer ends
// i.e. when we're part of a continuous transfer
#define SPI_CONTINUOUS BIT(11)
// Fixme: does this stuff really belong in serial.h?
// Power management registers
#define PM_CONTROL_REG 0
#define PM_BATTERY_REG 1
#define PM_AMPLIFIER_REG 2
#define PM_READ_REGISTER (1<<7)
// PM control register bits - power control
#define PM_SOUND_AMP BIT(0) // Power the sound hardware (needed to hear stuff in GBA mode too)
#define PM_SOUND_MUTE BIT(1) // Mute the main speakers, headphone output will still work.
#define PM_BACKLIGHT_BOTTOM BIT(2) // Enable the top backlight if set
#define PM_BACKLIGHT_TOP BIT(3) // Enable the bottom backlight if set
#define PM_SYSTEM_PWR BIT(6) // Turn the power *off* if set
#define PM_POWER_DOWN BIT(6) // Same thing, I like this name better tho
// PM control register bits - LED control
#define PM_LED_CONTROL(m) ((m)<<4) // ?
#define PM_LED_ON (0<<4) // Steady on
#define PM_LED_SLEEP (1<<4) // Blinking, mostly off
#define PM_LED_BLINK (3<<4) // Blinking, mostly on
#define PM_AMP_OFFSET 2
#define PM_AMP_ON 1
#define PM_AMP_OFF 0
// Fixme: does this stuff really belong in serial.h?
// Firmware commands
#define FIRMWARE_WREN 0x06
#define FIRMWARE_WRDI 0x04
#define FIRMWARE_RDID 0x9F
#define FIRMWARE_RDSR 0x05
#define FIRMWARE_READ 0x03
#define FIRMWARE_PW 0x0A
#define FIRMWARE_PP 0x02
#define FIRMWARE_FAST 0x0B
#define FIRMWARE_PE 0xDB
#define FIRMWARE_SE 0xD8
#define FIRMWARE_DP 0xB9
#define FIRMWARE_RDP 0xAB
static inline
void SerialWaitBusy() {
while (REG_SPICNT & SPI_BUSY)
swiDelay(1);
}
// Warning: These functions use the SPI chain, and are thus 'critical'
// sections, make sure to disable interrupts during the call if you've
// got a VBlank IRQ polling the touch screen, etc...
// Read/write a power management register
int writePowerManagement(int reg, int command);
static inline
int readPowerManagement(int reg) {
return writePowerManagement((reg)|PM_READ_REGISTER, 0);
}
// Read the firmware
void readFirmware(uint32 address, void * destination, uint32 size);
#endif
@@ -1,73 +1,73 @@
/*---------------------------------------------------------------------------------
$Id$
Microphone control for the ARM7
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef ARM7_TOUCH_INCLUDE
#define ARM7_TOUCH_INCLUDE
//---------------------------------------------------------------------------------
#ifndef ARM7
#error Touch screen is only available on the ARM7
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <nds/arm7/serial.h>
#define SCREEN_WIDTH 256
#define SCREEN_HEIGHT 192
#define TSC_MEASURE_TEMP1 0x84
#define TSC_MEASURE_Y 0x90
#define TSC_MEASURE_BATTERY 0xA4
#define TSC_MEASURE_Z1 0xB4
#define TSC_MEASURE_Z2 0xC4
#define TSC_MEASURE_X 0xD0
#define TSC_MEASURE_AUX 0xE4
#define TSC_MEASURE_TEMP2 0xF4
touchPosition touchReadXY();
uint16 touchRead(uint32 command);
uint32 touchReadTemperature(int * t1, int * t2);
#ifdef __cplusplus
}
#endif
//---------------------------------------------------------------------------------
#endif // ARM7_TOUCH_INCLUDE
//---------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------
$Id$
Microphone control for the ARM7
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef ARM7_TOUCH_INCLUDE
#define ARM7_TOUCH_INCLUDE
//---------------------------------------------------------------------------------
#ifndef ARM7
#error Touch screen is only available on the ARM7
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <nds/arm7/serial.h>
#define SCREEN_WIDTH 256
#define SCREEN_HEIGHT 192
#define TSC_MEASURE_TEMP1 0x84
#define TSC_MEASURE_Y 0x90
#define TSC_MEASURE_BATTERY 0xA4
#define TSC_MEASURE_Z1 0xB4
#define TSC_MEASURE_Z2 0xC4
#define TSC_MEASURE_X 0xD0
#define TSC_MEASURE_AUX 0xE4
#define TSC_MEASURE_TEMP2 0xF4
touchPosition touchReadXY();
uint16 touchRead(uint32 command);
uint32 touchReadTemperature(int * t1, int * t2);
#ifdef __cplusplus
}
#endif
//---------------------------------------------------------------------------------
#endif // ARM7_TOUCH_INCLUDE
//---------------------------------------------------------------------------------
@@ -1,110 +1,110 @@
/*---------------------------------------------------------------------------------
$Id$
BoxTest.h -- Code for performing hardware box test against viewing frustrum
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef BOX_TEST_INCLUDE
#define BOX_TEST_INCLUDE
#include <nds/arm9/video.h>
#include <nds/arm9/videoGL.h>
/*! \file boxtest.h
\brief Box Test Functions.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*! \fn int BoxTest(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth)
\brief Performs a test to determine if the provided box is in the view frustrum.
\param x (x, y, z) point of a vertex on the box
\param y (x, y, z) point of a vertex on the box
\param z (x, y, z) point of a vertex on the box
\param height (height, width, depth) describe the size of the box referenced from (x, y, z)
\param width (height, width, depth) describe the size of the box referenced from (x, y, z)
\param depth (height, width, depth) describe the size of the box referenced from (x, y, z)
\return non zero if any or all of the box is in the view frustum
*/
int BoxTest(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth);
/*! \fn int BoxTestf(float x, float y, float z, float width, float height, float depth)
\brief Performs a test to determine if the provided box is in the view frustum.
\param x (x, y, z) point of a vertex on the box
\param y (x, y, z) point of a vertex on the box
\param z (x, y, z) point of a vertex on the box
\param width (width, height, depth) describe the size of the box referenced from (x, y, z)
\param height (width, height, depth) describe the size of the box referenced from (x, y, z)
\param depth (width, height, depth) describe the size of the box referenced from (x, y, z)
\return non zero if any or all of the box is in the view frustum
*/
int BoxTestf(float x, float y, float z, float width, float height, float depth);
/*! \fn void BoxTest_Asynch(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth)
\brief Performs a test to determine if the provided box is in the view frustum.
\param x (x, y, z) point of a vertex on the box
\param y (x, y, z) point of a vertex on the box
\param z (x, y, z) point of a vertex on the box
\param width (width, height, depth) describe the size of the box referenced from (x, y, z)
\param height (width, height, depth) describe the size of the box referenced from (x, y, z)
\param depth (width, height, depth) describe the size of the box referenced from (x, y, z)
Performs a test to determine if the provided box is in the view frustum. BoxTestResult must be called to get the result of this
operation.
*/
void BoxTest_Asynch(v16 x, v16 y, v16 z, v16 height, v16 width, v16 depth);
/*! \fn void BoxTestf_Asynch(float x, float y, float z, float width, float height, float depth)
\brief Performs a test to determine if the provided box is in the view frustum.
\param x (x, y, z) point of a vertex on the box
\param y (x, y, z) point of a vertex on the box
\param z (x, y, z) point of a vertex on the box
\param width (width, height, depth) describe the size of the box referenced from (x, y, z)
\param height (width, height, depth) describe the size of the box referenced from (x, y, z)
\param depth (width, height, depth) describe the size of the box referenced from (x, y, z)
Performs a test to determine if the provided box is in the view frustum. BoxTestResult must be called to get the result of this
operation.
*/
void BoxTestf_Asynch(float x, float y, float z, float width, float height, float depth);
/*! \fn void BoxTestResult(void)
\brief Gets the result of the last box test. Needed for asynch box test calls.
\return non zero if any or all of the box is in the view frustum
*/
int BoxTestResult(void);
#ifdef __cplusplus
}
#endif
#endif
/*---------------------------------------------------------------------------------
$Id$
BoxTest.h -- Code for performing hardware box test against viewing frustrum
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef BOX_TEST_INCLUDE
#define BOX_TEST_INCLUDE
#include <nds/arm9/video.h>
#include <nds/arm9/videoGL.h>
/*! \file boxtest.h
\brief Box Test Functions.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*! \fn int BoxTest(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth)
\brief Performs a test to determine if the provided box is in the view frustrum.
\param x (x, y, z) point of a vertex on the box
\param y (x, y, z) point of a vertex on the box
\param z (x, y, z) point of a vertex on the box
\param height (height, width, depth) describe the size of the box referenced from (x, y, z)
\param width (height, width, depth) describe the size of the box referenced from (x, y, z)
\param depth (height, width, depth) describe the size of the box referenced from (x, y, z)
\return non zero if any or all of the box is in the view frustum
*/
int BoxTest(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth);
/*! \fn int BoxTestf(float x, float y, float z, float width, float height, float depth)
\brief Performs a test to determine if the provided box is in the view frustum.
\param x (x, y, z) point of a vertex on the box
\param y (x, y, z) point of a vertex on the box
\param z (x, y, z) point of a vertex on the box
\param width (width, height, depth) describe the size of the box referenced from (x, y, z)
\param height (width, height, depth) describe the size of the box referenced from (x, y, z)
\param depth (width, height, depth) describe the size of the box referenced from (x, y, z)
\return non zero if any or all of the box is in the view frustum
*/
int BoxTestf(float x, float y, float z, float width, float height, float depth);
/*! \fn void BoxTest_Asynch(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth)
\brief Performs a test to determine if the provided box is in the view frustum.
\param x (x, y, z) point of a vertex on the box
\param y (x, y, z) point of a vertex on the box
\param z (x, y, z) point of a vertex on the box
\param width (width, height, depth) describe the size of the box referenced from (x, y, z)
\param height (width, height, depth) describe the size of the box referenced from (x, y, z)
\param depth (width, height, depth) describe the size of the box referenced from (x, y, z)
Performs a test to determine if the provided box is in the view frustum. BoxTestResult must be called to get the result of this
operation.
*/
void BoxTest_Asynch(v16 x, v16 y, v16 z, v16 height, v16 width, v16 depth);
/*! \fn void BoxTestf_Asynch(float x, float y, float z, float width, float height, float depth)
\brief Performs a test to determine if the provided box is in the view frustum.
\param x (x, y, z) point of a vertex on the box
\param y (x, y, z) point of a vertex on the box
\param z (x, y, z) point of a vertex on the box
\param width (width, height, depth) describe the size of the box referenced from (x, y, z)
\param height (width, height, depth) describe the size of the box referenced from (x, y, z)
\param depth (width, height, depth) describe the size of the box referenced from (x, y, z)
Performs a test to determine if the provided box is in the view frustum. BoxTestResult must be called to get the result of this
operation.
*/
void BoxTestf_Asynch(float x, float y, float z, float width, float height, float depth);
/*! \fn void BoxTestResult(void)
\brief Gets the result of the last box test. Needed for asynch box test calls.
\return non zero if any or all of the box is in the view frustum
*/
int BoxTestResult(void);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,88 +1,88 @@
/*---------------------------------------------------------------------------------
$Id$
key input code -- provides slightly higher level input forming
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file cache.h
\brief ARM9 cache control functions.
*/
#ifndef _cache_h_
#define _cache_h_
#ifdef __cplusplus
extern "C" {
#endif
#include "nds/jtypes.h"
/*! \fn IC_InvalidateAll()
\brief invalidate entire instruction cache.
*/
void IC_InvalidateAll();
/*! \fn IC_InvalidateRange(const void *base, u32 size)
\brief invalidate the instruction cache for a range of addresses.
\param base base address of the region to invalidate
\param size size of the region to invalidate.
*/
void IC_InvalidateRange(const void *base, u32 size);
/*! \fn DC_FlushAll()
\brief flush the entire data cache to memory.
*/
void DC_FlushAll();
/*! \fn DC_FlushRange(const void *base, u32 size)
\brief flush the data cache for a range of addresses to memory.
\param base base address of the region to flush.
\param size size of the region to flush.
*/
void DC_FlushRange(const void *base, u32 size);
/*! \fn DC_InvalidateAll()
\brief invalidate the entire data cache.
*/
void DC_InvalidateAll();
/*! \fn DC_InvalidateRange(const void *base, u32 size)
\brief invalidate the data cache for a range of addresses.
\param base base address of the region to invalidate
\param size size of the region to invalidate.
*/
void DC_InvalidateRange(const void *base, u32 size);
#ifdef __cplusplus
}
#endif
#endif
/*---------------------------------------------------------------------------------
$Id$
key input code -- provides slightly higher level input forming
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file cache.h
\brief ARM9 cache control functions.
*/
#ifndef _cache_h_
#define _cache_h_
#ifdef __cplusplus
extern "C" {
#endif
#include "nds/jtypes.h"
/*! \fn IC_InvalidateAll(void)
\brief invalidate entire instruction cache.
*/
void IC_InvalidateAll(void);
/*! \fn IC_InvalidateRange(const void *base, u32 size)
\brief invalidate the instruction cache for a range of addresses.
\param base base address of the region to invalidate
\param size size of the region to invalidate.
*/
void IC_InvalidateRange(const void *base, u32 size);
/*! \fn DC_FlushAll(void)
\brief flush the entire data cache to memory.
*/
void DC_FlushAll(void);
/*! \fn DC_FlushRange(const void *base, u32 size)
\brief flush the data cache for a range of addresses to memory.
\param base base address of the region to flush.
\param size size of the region to flush.
*/
void DC_FlushRange(const void *base, u32 size);
/*! \fn DC_InvalidateAll(void)
\brief invalidate the entire data cache.
*/
void DC_InvalidateAll(void);
/*! \fn DC_InvalidateRange(const void *base, u32 size)
\brief invalidate the data cache for a range of addresses.
\param base base address of the region to invalidate
\param size size of the region to invalidate.
*/
void DC_InvalidateRange(const void *base, u32 size);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,87 +1,87 @@
/*---------------------------------------------------------------------------------
$Id$
console functions
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file console.h
\brief nds stdio support.
*/
#ifndef CONSOLE_H
#define CONSOLE_H
#define CONSOLE_USE_COLOR255 16
#include <nds/jtypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/*! \fn void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth)
\brief Initialise the console.
\param font base address of the 16 color font to use
\param charBase VRAM address to load the font
\param numCharacters number of characters in the font
\param charStart ascii code of the first character in the font
\param map base address of the map to use for printing
\param pal 16 color palette index to use
\param bitDepth 256/16 color tile flag.
Initializes the console with the given parameters. When pal is greater than 15 and
bitDepth is 16 then all non zero entries in the font are set to index 255. When bitDepth
is not 16 then the font tiles are created as 8bit (256 color).
*/
void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth);
/*! \fn void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth)
\brief Initialize the console with some default parameters.
\param charBase VRAM address to load the font
\param map base address of the map to use for printing
\param bitDepth 256/16 color tile flag
This function calls consoleInit() with the default built in font and character ranges, the parameters given
are as for that function.
*/
void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth);
/*! \fn void consoleDemoInit(void)
\brief Initialize the console to a default state for prototyping.
This function sets the console to use sub display, VRAM_C, and BG0 and enables MODE_0_2D on the
sub display. It is intended for use in prototyping applications which need print ability and not actual
game use. Print functionality can be utilized with just this call.
*/
void consoleDemoInit(void);
/*! \fn void consoleClear(void)
\brief Clears the screan by iprintf("\x1b[2J");
*/
void consoleClear(void);
#ifdef __cplusplus
}
#endif
#endif
/*---------------------------------------------------------------------------------
$Id$
console functions
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file console.h
\brief nds stdio support.
*/
#ifndef CONSOLE_H
#define CONSOLE_H
#define CONSOLE_USE_COLOR255 16
#include <nds/jtypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/*! \fn void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth)
\brief Initialise the console.
\param font base address of the 16 color font to use
\param charBase VRAM address to load the font
\param numCharacters number of characters in the font
\param charStart ascii code of the first character in the font
\param map base address of the map to use for printing
\param pal 16 color palette index to use
\param bitDepth 256/16 color tile flag.
Initializes the console with the given parameters. When pal is greater than 15 and
bitDepth is 16 then all non zero entries in the font are set to index 255. When bitDepth
is not 16 then the font tiles are created as 8bit (256 color).
*/
void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth);
/*! \fn void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth)
\brief Initialize the console with some default parameters.
\param charBase VRAM address to load the font
\param map base address of the map to use for printing
\param bitDepth 256/16 color tile flag
This function calls consoleInit() with the default built in font and character ranges, the parameters given
are as for that function.
*/
void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth);
/*! \fn void consoleDemoInit(void)
\brief Initialize the console to a default state for prototyping.
This function sets the console to use sub display, VRAM_C, and BG0 and enables MODE_0_2D on the
sub display. It is intended for use in prototyping applications which need print ability and not actual
game use. Print functionality can be utilized with just this call.
*/
void consoleDemoInit(void);
/*! \fn void consoleClear(void)
\brief Clears the screan by iprintf("\x1b[2J");
*/
void consoleClear(void);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,192 +1,192 @@
/*---------------------------------------------------------------------------------
$Id$
DS Motion Card/DS Motion Pak functionality
Copyright (C) 2007
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
Keith Epstein (KeithE)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file ndsmotion.h
\brief interface code for the ds motion card, ds motion pak, MK6
*/
#ifndef NDS_MOTION_INCLUDE
#define NDS_MOTION_INCLUDE
//---------------------------------------------------------------------------------
typedef struct
{
short xoff, yoff, zoff, goff;
short xsens, ysens, zsens, gsens;
}MotionCalibration;
#ifdef __cplusplus
extern "C" {
#endif
/*! \fn int motion_init()
\brief Initializes the DS Motion Sensor.
Run this before using any of the DS Motion Sensor functions
save the return value and pass it to the other motion_ functions
*/
int motion_init();
/*! \fn int motion_deinit()
\brief Deinitializes the DS Motion Sensor
*/
void motion_deinit();
/*! \fn signed int motion_read_x()
\brief read the X acceleration
*/
signed int motion_read_x();
/*! \fn signed int motion_read_y()
\brief read the Y acceleration
*/
signed int motion_read_y();
/*! \fn signed int motion_read_z()
\brief read the Z acceleration
*/
signed int motion_read_z();
/*! \fn signed int motion_read_gyro()
\brief read the Z rotational speed
*/
signed int motion_read_gyro();
/*! \fn int motion_acceleration_x()
\brief gets acceleration value to mili G (where g is 9.8 m/s*s)
*/
int motion_acceleration_x();
/*! \fn int motion_acceleration_y()
\brief gets acceleration value to mili G (where g is 9.8 m/s*s)
*/
int motion_acceleration_y();
/*! \fn int motion_acceleration_z()
\brief gets acceleration value to mili G (where g is 9.8 m/s*s)
*/
int motion_acceleration_z();
/*! \fn void motion_set_sens_x(int sens)
\brief this should be passed the raw reading at 1g for accurate
acceleration calculations. Default is 819
*/
void motion_set_sens_x(int sens);
/*! \fn void motion_set_sens_y(int sens)
\brief this should be passed the raw reading at 1g for accurate
acceleration calculations. Default is 819
*/
void motion_set_sens_y(int sens);
/*! \fn void motion_set_sens_z(int sens)
\brief this should be passed the raw reading at 1g for accurate
acceleration calculations. Default is 819
*/
void motion_set_sens_z(int sens);
/*! \fn void motion_set_sens_x(int sens)
\brief this should be passed the raw reading at 1g for accurate
acceleration calculations. Default is 825
*/
void motion_set_sens_gyro(int sens);
/*! \fn void motion_set_offs_x()
\brief this should be called when the axis is under no acceleration
default is 2048
*/
void motion_set_offs_x();
/*! \fn void motion_set_offs_y()
\brief this should be called when the axis is under no acceleration
default is 2048
*/
void motion_set_offs_y();
/*! \fn void motion_set_offs_z()
\brief this should be called when the axis is under no acceleration
default is 2048
*/
void motion_set_offs_z();
/*! \fn void motion_set_offs_gyro()
\brief this should be called when the axis is under no rotation
default is 1680
*/
void motion_set_offs_gyro();
/*! \fn int motion_rotation()
\brief converts raw rotation value to degrees per second
*/
int motion_rotation();
/*! \fn MotionCalibration* motion_get_calibration()
\brief This returns the current calibration settings for saving
*/
MotionCalibration* motion_get_calibration();
/*! \fn void motion_set_calibration(MotionCalibration* cal)
\brief This sets the calibration settings. Intended
to restore saved calibration settings
*/
void motion_set_calibration(MotionCalibration* cal);
/*! \fn MotionCalibration* motion_enable_ain_1()
\brief This enables the analog input number 1.
Required before reading analog input number 1.
*/
void motion_enable_ain_1();
/*! \fn MotionCalibration* motion_enable_ain_2()
\brief This enables the analog input number 2.
Required before reading analog input number 2.
*/
void motion_enable_ain_2();
/*! \fn MotionCalibration* motion_read_ain_1()
\brief This reads the analog input number 1.
analog input number 1 needs to be enabled before reading.
*/
int motion_read_ain_1();
/*! \fn MotionCalibration* motion_read_ain_2()
\brief This reads the analog input number 2.
analog input number 2 needs to be enabled before reading.
*/
int motion_read_ain_2();
#ifdef __cplusplus
}
#endif
#endif
/*---------------------------------------------------------------------------------
$Id$
DS Motion Card/DS Motion Pak functionality
Copyright (C) 2007
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
Keith Epstein (KeithE)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file ndsmotion.h
\brief interface code for the ds motion card, ds motion pak, MK6
*/
#ifndef NDS_MOTION_INCLUDE
#define NDS_MOTION_INCLUDE
//---------------------------------------------------------------------------------
typedef struct
{
short xoff, yoff, zoff, goff;
short xsens, ysens, zsens, gsens;
}MotionCalibration;
#ifdef __cplusplus
extern "C" {
#endif
/*! \fn int motion_init()
\brief Initializes the DS Motion Sensor.
Run this before using any of the DS Motion Sensor functions
save the return value and pass it to the other motion_ functions
*/
int motion_init();
/*! \fn int motion_deinit()
\brief Deinitializes the DS Motion Sensor
*/
void motion_deinit();
/*! \fn signed int motion_read_x()
\brief read the X acceleration
*/
signed int motion_read_x();
/*! \fn signed int motion_read_y()
\brief read the Y acceleration
*/
signed int motion_read_y();
/*! \fn signed int motion_read_z()
\brief read the Z acceleration
*/
signed int motion_read_z();
/*! \fn signed int motion_read_gyro()
\brief read the Z rotational speed
*/
signed int motion_read_gyro();
/*! \fn int motion_acceleration_x()
\brief gets acceleration value to mili G (where g is 9.8 m/s*s)
*/
int motion_acceleration_x();
/*! \fn int motion_acceleration_y()
\brief gets acceleration value to mili G (where g is 9.8 m/s*s)
*/
int motion_acceleration_y();
/*! \fn int motion_acceleration_z()
\brief gets acceleration value to mili G (where g is 9.8 m/s*s)
*/
int motion_acceleration_z();
/*! \fn void motion_set_sens_x(int sens)
\brief this should be passed the raw reading at 1g for accurate
acceleration calculations. Default is 819
*/
void motion_set_sens_x(int sens);
/*! \fn void motion_set_sens_y(int sens)
\brief this should be passed the raw reading at 1g for accurate
acceleration calculations. Default is 819
*/
void motion_set_sens_y(int sens);
/*! \fn void motion_set_sens_z(int sens)
\brief this should be passed the raw reading at 1g for accurate
acceleration calculations. Default is 819
*/
void motion_set_sens_z(int sens);
/*! \fn void motion_set_sens_x(int sens)
\brief this should be passed the raw reading at 1g for accurate
acceleration calculations. Default is 825
*/
void motion_set_sens_gyro(int sens);
/*! \fn void motion_set_offs_x()
\brief this should be called when the axis is under no acceleration
default is 2048
*/
void motion_set_offs_x();
/*! \fn void motion_set_offs_y()
\brief this should be called when the axis is under no acceleration
default is 2048
*/
void motion_set_offs_y();
/*! \fn void motion_set_offs_z()
\brief this should be called when the axis is under no acceleration
default is 2048
*/
void motion_set_offs_z();
/*! \fn void motion_set_offs_gyro()
\brief this should be called when the axis is under no rotation
default is 1680
*/
void motion_set_offs_gyro();
/*! \fn int motion_rotation()
\brief converts raw rotation value to degrees per second
*/
int motion_rotation();
/*! \fn MotionCalibration* motion_get_calibration()
\brief This returns the current calibration settings for saving
*/
MotionCalibration* motion_get_calibration();
/*! \fn void motion_set_calibration(MotionCalibration* cal)
\brief This sets the calibration settings. Intended
to restore saved calibration settings
*/
void motion_set_calibration(MotionCalibration* cal);
/*! \fn MotionCalibration* motion_enable_ain_1()
\brief This enables the analog input number 1.
Required before reading analog input number 1.
*/
void motion_enable_ain_1();
/*! \fn MotionCalibration* motion_enable_ain_2()
\brief This enables the analog input number 2.
Required before reading analog input number 2.
*/
void motion_enable_ain_2();
/*! \fn MotionCalibration* motion_read_ain_1()
\brief This reads the analog input number 1.
analog input number 1 needs to be enabled before reading.
*/
int motion_read_ain_1();
/*! \fn MotionCalibration* motion_read_ain_2()
\brief This reads the analog input number 2.
analog input number 2 needs to be enabled before reading.
*/
int motion_read_ain_2();
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+127 -127
View File
@@ -1,127 +1,127 @@
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef NDS_CARD_INCLUDE
#define NDS_CARD_INCLUDE
#include "jtypes.h"
// Card bus
#define CARD_CR1 (*(vuint16*)0x040001A0)
#define CARD_CR1H (*(vuint8*)0x040001A1)
#define CARD_EEPDATA (*(vuint8*)0x040001A2)
#define CARD_CR2 (*(vuint32*)0x040001A4)
#define CARD_COMMAND ((vuint8*)0x040001A8)
#define CARD_DATA_RD (*(vuint32*)0x04100010)
#define CARD_1B0 (*(vuint32*)0x040001B0)
#define CARD_1B4 (*(vuint32*)0x040001B4)
#define CARD_1B8 (*(vuint16*)0x040001B8)
#define CARD_1BA (*(vuint16*)0x040001BA)
#define CARD_CR1_ENABLE 0x80 // in byte 1, i.e. 0x8000
#define CARD_CR1_IRQ 0x40 // in byte 1, i.e. 0x4000
// CARD_CR2 register:
#define CARD_ACTIVATE (1<<31) // when writing, get the ball rolling
// 1<<30
#define CARD_nRESET (1<<29) // value on the /reset pin (1 = high out, not a reset state, 0 = low out = in reset)
#define CARD_28 (1<<28) // when writing
#define CARD_27 (1<<27) // when writing
#define CARD_26 (1<<26)
#define CARD_22 (1<<22)
#define CARD_19 (1<<19)
#define CARD_ENCRYPTED (1<<14) // when writing, this command should be encrypted
#define CARD_13 (1<<13) // when writing
#define CARD_4 (1<<4) // when writing
// 3 bits in b10..b8 indicate something
// read bits
#define CARD_BUSY (1<<31) // when reading, still expecting incomming data?
#define CARD_DATA_READY (1<<23) // when reading, CARD_DATA_RD or CARD_DATA has another word of data and is good to go
#ifdef __cplusplus
extern "C" {
#endif
void cardWriteCommand(const uint8 * command);
void cardPolledTransfer(uint32 flags, uint32 * destination, uint32 length, const uint8 * command);
void cardStartTransfer(const uint8 * command, uint32 * destination, int channel, uint32 flags);
uint32 cardWriteAndRead(const uint8 * command, uint32 flags);
// These commands require the cart to not be initialized yet, which may mean the user
// needs to eject and reinsert the cart or they will return random data.
void cardRead00(uint32 address, uint32 * destination, uint32 length, uint32 flags);
void cardReadHeader(uint8 * header);
int cardReadID(uint32 flags);
// Reads from the EEPROM
void cardReadEeprom(uint32 address, uint8 *data, uint32 length, uint32 addrtype);
// Writes to the EEPROM. TYPE 3 EEPROM must be erased first (I think?)
void cardWriteEeprom(uint32 address, uint8 *data, uint32 length, uint32 addrtype);
// Returns the ID of the EEPROM chip? Doesn't work well, most chips give ff,ff
// i = 0 or 1
uint8 cardEepromReadID(uint8 i);
// Sends a command to the EEPROM
uint8 cardEepromCommand(uint8 command, uint32 address);
/*
* -1:no card or no EEPROM
* 0:unknown PassMe?
* 1:TYPE 1 4Kbit(512Byte) EEPROM
* 2:TYPE 2 64Kbit(8KByte)or 512kbit(64Kbyte) EEPROM
* 3:TYPE 3 2Mbit(256KByte) FLASH MEMORY (some rare 4Mbit and 8Mbit chips also)
*/
int cardEepromGetType(void);
// Returns the size in bytes of EEPROM
uint32 cardEepromGetSize();
// Erases the entire chip. TYPE 3 chips MUST be erased before writing to them. (I think?)
void cardEepromChipErase(void);
// Erases a single sector of the TYPE 3 chip
void cardEepromSectorErase(uint32 address);
#ifdef __cplusplus
}
#endif
#endif
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef NDS_CARD_INCLUDE
#define NDS_CARD_INCLUDE
#include "jtypes.h"
// Card bus
#define CARD_CR1 (*(vuint16*)0x040001A0)
#define CARD_CR1H (*(vuint8*)0x040001A1)
#define CARD_EEPDATA (*(vuint8*)0x040001A2)
#define CARD_CR2 (*(vuint32*)0x040001A4)
#define CARD_COMMAND ((vuint8*)0x040001A8)
#define CARD_DATA_RD (*(vuint32*)0x04100010)
#define CARD_1B0 (*(vuint32*)0x040001B0)
#define CARD_1B4 (*(vuint32*)0x040001B4)
#define CARD_1B8 (*(vuint16*)0x040001B8)
#define CARD_1BA (*(vuint16*)0x040001BA)
#define CARD_CR1_ENABLE 0x80 // in byte 1, i.e. 0x8000
#define CARD_CR1_IRQ 0x40 // in byte 1, i.e. 0x4000
// CARD_CR2 register:
#define CARD_ACTIVATE (1<<31) // when writing, get the ball rolling
// 1<<30
#define CARD_nRESET (1<<29) // value on the /reset pin (1 = high out, not a reset state, 0 = low out = in reset)
#define CARD_28 (1<<28) // when writing
#define CARD_27 (1<<27) // when writing
#define CARD_26 (1<<26)
#define CARD_22 (1<<22)
#define CARD_19 (1<<19)
#define CARD_ENCRYPTED (1<<14) // when writing, this command should be encrypted
#define CARD_13 (1<<13) // when writing
#define CARD_4 (1<<4) // when writing
// 3 bits in b10..b8 indicate something
// read bits
#define CARD_BUSY (1<<31) // when reading, still expecting incomming data?
#define CARD_DATA_READY (1<<23) // when reading, CARD_DATA_RD or CARD_DATA has another word of data and is good to go
#ifdef __cplusplus
extern "C" {
#endif
void cardWriteCommand(const uint8 * command);
void cardPolledTransfer(uint32 flags, uint32 * destination, uint32 length, const uint8 * command);
void cardStartTransfer(const uint8 * command, uint32 * destination, int channel, uint32 flags);
uint32 cardWriteAndRead(const uint8 * command, uint32 flags);
// These commands require the cart to not be initialized yet, which may mean the user
// needs to eject and reinsert the cart or they will return random data.
void cardRead00(uint32 address, uint32 * destination, uint32 length, uint32 flags);
void cardReadHeader(uint8 * header);
int cardReadID(uint32 flags);
// Reads from the EEPROM
void cardReadEeprom(uint32 address, uint8 *data, uint32 length, uint32 addrtype);
// Writes to the EEPROM. TYPE 3 EEPROM must be erased first (I think?)
void cardWriteEeprom(uint32 address, uint8 *data, uint32 length, uint32 addrtype);
// Returns the ID of the EEPROM chip? Doesn't work well, most chips give ff,ff
// i = 0 or 1
uint8 cardEepromReadID(uint8 i);
// Sends a command to the EEPROM
uint8 cardEepromCommand(uint8 command, uint32 address);
/*
* -1:no card or no EEPROM
* 0:unknown PassMe?
* 1:TYPE 1 4Kbit(512Byte) EEPROM
* 2:TYPE 2 64Kbit(8KByte)or 512kbit(64Kbyte) EEPROM
* 3:TYPE 3 2Mbit(256KByte) FLASH MEMORY (some rare 4Mbit and 8Mbit chips also)
*/
int cardEepromGetType(void);
// Returns the size in bytes of EEPROM
uint32 cardEepromGetSize(void);
// Erases the entire chip. TYPE 3 chips MUST be erased before writing to them. (I think?)
void cardEepromChipErase(void);
// Erases a single sector of the TYPE 3 chip
void cardEepromSectorErase(uint32 address);
#ifdef __cplusplus
}
#endif
#endif
+153 -153
View File
@@ -1,153 +1,153 @@
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef NDS_DMA_INCLUDE
#define NDS_DMA_INCLUDE
#define DMA0_SRC (*(vuint32*)0x040000B0)
#define DMA0_DEST (*(vuint32*)0x040000B4)
#define DMA0_CR (*(vuint32*)0x040000B8)
#define DMA1_SRC (*(vuint32*)0x040000BC)
#define DMA1_DEST (*(vuint32*)0x040000C0)
#define DMA1_CR (*(vuint32*)0x040000C4)
#define DMA2_SRC (*(vuint32*)0x040000C8)
#define DMA2_DEST (*(vuint32*)0x040000CC)
#define DMA2_CR (*(vuint32*)0x040000D0)
#define DMA3_SRC (*(vuint32*)0x040000D4)
#define DMA3_DEST (*(vuint32*)0x040000D8)
#define DMA3_CR (*(vuint32*)0x040000DC)
#define DMA_SRC(n) (*(vuint32*)(0x040000B0+(n*12)))
#define DMA_DEST(n) (*(vuint32*)(0x040000B4+(n*12)))
#define DMA_CR(n) (*(vuint32*)(0x040000B8+(n*12)))
// DMA control register contents
// The defaults are 16-bit, increment source/dest addresses, no irq
#define DMA_ENABLE BIT(31)
#define DMA_BUSY BIT(31)
#define DMA_IRQ_REQ BIT(30)
#define DMA_START_NOW 0
#define DMA_START_CARD (5<<27)
#ifdef ARM7
#define DMA_START_VBL BIT(27)
#endif
#ifdef ARM9
#define DMA_START_HBL BIT(28)
#define DMA_START_VBL BIT(27)
#define DMA_START_FIFO (7<<27)
#define DMA_DISP_FIFO (4<<27)
#endif
#define DMA_16_BIT 0
#define DMA_32_BIT BIT(26)
#define DMA_REPEAT BIT(25)
#define DMA_SRC_INC (0)
#define DMA_SRC_DEC BIT(23)
#define DMA_SRC_FIX BIT(24)
#define DMA_DST_INC (0)
#define DMA_DST_DEC BIT(21)
#define DMA_DST_FIX BIT(22)
#define DMA_DST_RESET (3<<21)
#define DMA_COPY_WORDS (DMA_ENABLE | DMA_32_BIT | DMA_START_NOW)
#define DMA_COPY_HALFWORDS (DMA_ENABLE | DMA_16_BIT | DMA_START_NOW)
#define DMA_FIFO (DMA_ENABLE | DMA_32_BIT | DMA_DST_FIX | DMA_START_FIFO)
static inline void dmaCopyWords(uint8 channel, const void* src, void* dest, uint32 size) {
DMA_SRC(channel) = (uint32)src;
DMA_DEST(channel) = (uint32)dest;
DMA_CR(channel) = DMA_COPY_WORDS | (size>>2);
while(DMA_CR(channel) & DMA_BUSY);
}
static inline void dmaCopyHalfWords(uint8 channel, const void* src, void* dest, uint32 size) {
DMA_SRC(channel) = (uint32)src;
DMA_DEST(channel) = (uint32)dest;
DMA_CR(channel) = DMA_COPY_HALFWORDS | (size>>1);
while(DMA_CR(channel) & DMA_BUSY);
}
static inline void dmaCopy(const void * source, void * dest, uint32 size) {
DMA_SRC(3) = (uint32)source;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_COPY_HALFWORDS | (size>>1);
while(DMA_CR(3) & DMA_BUSY);
}
static inline void dmaCopyWordsAsynch(uint8 channel, const void* src, void* dest, uint32 size) {
DMA_SRC(channel) = (uint32)src;
DMA_DEST(channel) = (uint32)dest;
DMA_CR(channel) = DMA_COPY_WORDS | (size>>2);
}
static inline void dmaCopyHalfWordsAsynch(uint8 channel, const void* src, void* dest, uint32 size) {
DMA_SRC(channel) = (uint32)src;
DMA_DEST(channel) = (uint32)dest;
DMA_CR(channel) = DMA_COPY_HALFWORDS | (size>>1);
}
static inline void dmaCopyAsynch(const void * source, void * dest, uint32 size) {
DMA_SRC(3) = (uint32)source;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_COPY_HALFWORDS | (size>>1);
}
static inline void dmaFillWords( const void* src, void* dest, uint32 size) {
DMA_SRC(3) = (uint32)src;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_SRC_FIX | DMA_COPY_WORDS | (size>>2);
while(DMA_CR(3) & DMA_BUSY);
}
static inline void dmaFillHalfWords( const void* src, void* dest, uint32 size) {
DMA_SRC(3) = (uint32)src;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_SRC_FIX | DMA_COPY_HALFWORDS | (size>>1);
while(DMA_CR(3) & DMA_BUSY);
}
static inline int dmaBusy(uint8 channel) {
return (DMA_CR(channel) & DMA_BUSY)>>31;
}
#endif
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef NDS_DMA_INCLUDE
#define NDS_DMA_INCLUDE
#define DMA0_SRC (*(vuint32*)0x040000B0)
#define DMA0_DEST (*(vuint32*)0x040000B4)
#define DMA0_CR (*(vuint32*)0x040000B8)
#define DMA1_SRC (*(vuint32*)0x040000BC)
#define DMA1_DEST (*(vuint32*)0x040000C0)
#define DMA1_CR (*(vuint32*)0x040000C4)
#define DMA2_SRC (*(vuint32*)0x040000C8)
#define DMA2_DEST (*(vuint32*)0x040000CC)
#define DMA2_CR (*(vuint32*)0x040000D0)
#define DMA3_SRC (*(vuint32*)0x040000D4)
#define DMA3_DEST (*(vuint32*)0x040000D8)
#define DMA3_CR (*(vuint32*)0x040000DC)
#define DMA_SRC(n) (*(vuint32*)(0x040000B0+(n*12)))
#define DMA_DEST(n) (*(vuint32*)(0x040000B4+(n*12)))
#define DMA_CR(n) (*(vuint32*)(0x040000B8+(n*12)))
// DMA control register contents
// The defaults are 16-bit, increment source/dest addresses, no irq
#define DMA_ENABLE BIT(31)
#define DMA_BUSY BIT(31)
#define DMA_IRQ_REQ BIT(30)
#define DMA_START_NOW 0
#define DMA_START_CARD (5<<27)
#ifdef ARM7
#define DMA_START_VBL BIT(27)
#endif
#ifdef ARM9
#define DMA_START_HBL BIT(28)
#define DMA_START_VBL BIT(27)
#define DMA_START_FIFO (7<<27)
#define DMA_DISP_FIFO (4<<27)
#endif
#define DMA_16_BIT 0
#define DMA_32_BIT BIT(26)
#define DMA_REPEAT BIT(25)
#define DMA_SRC_INC (0)
#define DMA_SRC_DEC BIT(23)
#define DMA_SRC_FIX BIT(24)
#define DMA_DST_INC (0)
#define DMA_DST_DEC BIT(21)
#define DMA_DST_FIX BIT(22)
#define DMA_DST_RESET (3<<21)
#define DMA_COPY_WORDS (DMA_ENABLE | DMA_32_BIT | DMA_START_NOW)
#define DMA_COPY_HALFWORDS (DMA_ENABLE | DMA_16_BIT | DMA_START_NOW)
#define DMA_FIFO (DMA_ENABLE | DMA_32_BIT | DMA_DST_FIX | DMA_START_FIFO)
static inline void dmaCopyWords(uint8 channel, const void* src, void* dest, uint32 size) {
DMA_SRC(channel) = (uint32)src;
DMA_DEST(channel) = (uint32)dest;
DMA_CR(channel) = DMA_COPY_WORDS | (size>>2);
while(DMA_CR(channel) & DMA_BUSY);
}
static inline void dmaCopyHalfWords(uint8 channel, const void* src, void* dest, uint32 size) {
DMA_SRC(channel) = (uint32)src;
DMA_DEST(channel) = (uint32)dest;
DMA_CR(channel) = DMA_COPY_HALFWORDS | (size>>1);
while(DMA_CR(channel) & DMA_BUSY);
}
static inline void dmaCopy(const void * source, void * dest, uint32 size) {
DMA_SRC(3) = (uint32)source;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_COPY_HALFWORDS | (size>>1);
while(DMA_CR(3) & DMA_BUSY);
}
static inline void dmaCopyWordsAsynch(uint8 channel, const void* src, void* dest, uint32 size) {
DMA_SRC(channel) = (uint32)src;
DMA_DEST(channel) = (uint32)dest;
DMA_CR(channel) = DMA_COPY_WORDS | (size>>2);
}
static inline void dmaCopyHalfWordsAsynch(uint8 channel, const void* src, void* dest, uint32 size) {
DMA_SRC(channel) = (uint32)src;
DMA_DEST(channel) = (uint32)dest;
DMA_CR(channel) = DMA_COPY_HALFWORDS | (size>>1);
}
static inline void dmaCopyAsynch(const void * source, void * dest, uint32 size) {
DMA_SRC(3) = (uint32)source;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_COPY_HALFWORDS | (size>>1);
}
static inline void dmaFillWords( const void* src, void* dest, uint32 size) {
DMA_SRC(3) = (uint32)src;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_SRC_FIX | DMA_COPY_WORDS | (size>>2);
while(DMA_CR(3) & DMA_BUSY);
}
static inline void dmaFillHalfWords( const void* src, void* dest, uint32 size) {
DMA_SRC(3) = (uint32)src;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_SRC_FIX | DMA_COPY_HALFWORDS | (size>>1);
while(DMA_CR(3) & DMA_BUSY);
}
static inline int dmaBusy(uint8 channel) {
return (DMA_CR(channel) & DMA_BUSY)>>31;
}
#endif
@@ -1,187 +1,187 @@
/*---------------------------------------------------------------------------------
$Id$
Interrupt registers and vector pointers
Copyright (C) 2005
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file interrupts.h
\brief nds interrupt support.
*/
#ifndef NDS_INTERRUPTS_INCLUDE
#define NDS_INTERRUPTS_INCLUDE
#include <nds/jtypes.h>
/*! \enum IRQ_MASKS
\brief values allowed for REG_IE and REG_IF
*/
enum IRQ_MASKS {
IRQ_VBLANK = BIT(0), /*!< vertical blank interrupt mask */
IRQ_HBLANK = BIT(1), /*!< horizontal blank interrupt mask */
IRQ_VCOUNT = BIT(2), /*!< vcount match interrupt mask */
IRQ_TIMER0 = BIT(3), /*!< timer 0 interrupt mask */
IRQ_TIMER1 = BIT(4), /*!< timer 1 interrupt mask */
IRQ_TIMER2 = BIT(5), /*!< timer 2 interrupt mask */
IRQ_TIMER3 = BIT(6), /*!< timer 3 interrupt mask */
IRQ_NETWORK = BIT(7), /*!< serial interrupt mask */
IRQ_DMA0 = BIT(8), /*!< DMA 0 interrupt mask */
IRQ_DMA1 = BIT(9), /*!< DMA 1 interrupt mask */
IRQ_DMA2 = BIT(10), /*!< DMA 2 interrupt mask */
IRQ_DMA3 = BIT(11), /*!< DMA 3 interrupt mask */
IRQ_KEYS = BIT(12), /*!< Keypad interrupt mask */
IRQ_CART = BIT(13), /*!< GBA cartridge interrupt mask */
IRQ_IPC_SYNC = BIT(16), /*!< IPC sync interrupt mask */
IRQ_FIFO_EMPTY = BIT(17), /*!< Send FIFO empty interrupt mask */
IRQ_FIFO_NOT_EMPTY = BIT(18), /*!< Receive FIFO empty interrupt mask */
IRQ_CARD = BIT(19), /*!< interrupt mask */
IRQ_CARD_LINE = BIT(20), /*!< interrupt mask */
IRQ_GEOMETRY_FIFO = BIT(21), /*!< geometry FIFO interrupt mask */
IRQ_LID = BIT(22), /*!< interrupt mask */
IRQ_SPI = BIT(23), /*!< SPI interrupt mask */
IRQ_WIFI = BIT(24), /*!< WIFI interrupt mask (ARM7)*/
IRQ_ALL = (~0)
};
#define MAX_INTERRUPTS 25
typedef enum IRQ_MASKS IRQ_MASK;
/*! \def REG_IE
\brief Interrupt Enable Register.
This is the activation mask for the internal interrupts. Unless
the corresponding bit is set, the IRQ will be masked out.
*/
#define REG_IE (*(vuint32*)0x04000210)
/*! \def REG_IF
\brief Interrupt Flag Register.
Since there is only one hardware interrupt vector, the IF register
contains flags to indicate when a particular of interrupt has occured.
To acknowledge processing interrupts, set IF to the value of the
interrupt handled.
*/
#define REG_IF (*(vuint32*)0x04000214)
/*! \def REG_IME
\brief Interrupt Master Enable Register.
When bit 0 is clear, all interrupts are masked. When it is 1,
interrupts will occur if not masked out in REG_IE.
*/
#define REG_IME (*(vuint16*)0x04000208)
/*! \enum IME_VALUE
\brief values allowed for REG_IME
*/
enum IME_VALUE {
IME_DISABLE = 0, /*!< Disable all interrupts. */
IME_ENABLE = 1, /*!< Enable all interrupts not masked out in REG_IE */
};
#ifdef __cplusplus
extern "C" {
#endif
extern VoidFunctionPointer __irq_vector[];
extern vuint32 __irq_flags[];
#define VBLANK_INTR_WAIT_FLAGS *(__irq_flags)
#define IRQ_HANDLER *(__irq_vector)
struct IntTable{IntFn handler; u32 mask;};
/*! \fn irqInit()
\brief Initialise the libnds interrupt system.
Call this function at the start of any application which requires interrupt support.
This function should be used in preference to irqInitHandler.
*/
void irqInit();
/*! \fn irqSet(IRQ_MASK irq, VoidFunctionPointer handler)
\brief Add a handler for the given interrupt mask.
Specify the handler to use for the given interrupt. This only works with
the default interrupt handler, do not mix the use of this routine with a
user-installed IRQ handler.
\param irq Mask associated with the interrupt.
\param handler Address of the function to use as an interrupt service routine
\note
When any handler specifies using IRQ_VBLANK or IRQ_HBLANK, DISP_SR
is automatically updated to include the corresponding DISP_VBLANK_IRQ or DISP_HBLANK_IRQ.
\warning Only one IRQ_MASK can be specified with this function.
*/
void irqSet(IRQ_MASK irq, VoidFunctionPointer handler);
/*! \fn irqClear(IRQ_MASK irq)
\brief remove the handler associated with the interrupt mask irq.
\param irq Mask associated with the interrupt.
*/
void irqClear(IRQ_MASK irq);
/*! \fn irqInitHandler(VoidFunctionPointer handler)
\brief Install a user interrupt dispatcher.
This function installs the main interrupt function, all interrupts are serviced through this routine. For most
purposes the libnds interrupt dispacther should be used in preference to user code unless you know *exactly* what you're doing.
\param handler Address of the function to use as an interrupt dispatcher
\note the function *must* be ARM code
*/
void irqInitHandler(VoidFunctionPointer handler);
/*! \fn irqEnable(uint32 irq)
\brief Allow the given interrupt to occur.
\param irq The set of interrupt masks to enable.
\note Specify multiple interrupts to enable by ORing several IRQ_MASKS.
*/
void irqEnable(uint32 irq);
/*! \fn irqDisable(uint32 irq)
\brief Prevent the given interrupt from occuring.
\param irq The set of interrupt masks to disable.
\note Specify multiple interrupts to disable by ORing several IRQ_MASKS.
*/
void irqDisable(uint32 irq);
#ifdef __cplusplus
}
#endif
#endif //NDS_INTERRUPTS_INCLUDE
/*---------------------------------------------------------------------------------
$Id$
Interrupt registers and vector pointers
Copyright (C) 2005
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file interrupts.h
\brief nds interrupt support.
*/
#ifndef NDS_INTERRUPTS_INCLUDE
#define NDS_INTERRUPTS_INCLUDE
#include <nds/jtypes.h>
/*! \enum IRQ_MASKS
\brief values allowed for REG_IE and REG_IF
*/
enum IRQ_MASKS {
IRQ_VBLANK = BIT(0), /*!< vertical blank interrupt mask */
IRQ_HBLANK = BIT(1), /*!< horizontal blank interrupt mask */
IRQ_VCOUNT = BIT(2), /*!< vcount match interrupt mask */
IRQ_TIMER0 = BIT(3), /*!< timer 0 interrupt mask */
IRQ_TIMER1 = BIT(4), /*!< timer 1 interrupt mask */
IRQ_TIMER2 = BIT(5), /*!< timer 2 interrupt mask */
IRQ_TIMER3 = BIT(6), /*!< timer 3 interrupt mask */
IRQ_NETWORK = BIT(7), /*!< serial interrupt mask */
IRQ_DMA0 = BIT(8), /*!< DMA 0 interrupt mask */
IRQ_DMA1 = BIT(9), /*!< DMA 1 interrupt mask */
IRQ_DMA2 = BIT(10), /*!< DMA 2 interrupt mask */
IRQ_DMA3 = BIT(11), /*!< DMA 3 interrupt mask */
IRQ_KEYS = BIT(12), /*!< Keypad interrupt mask */
IRQ_CART = BIT(13), /*!< GBA cartridge interrupt mask */
IRQ_IPC_SYNC = BIT(16), /*!< IPC sync interrupt mask */
IRQ_FIFO_EMPTY = BIT(17), /*!< Send FIFO empty interrupt mask */
IRQ_FIFO_NOT_EMPTY = BIT(18), /*!< Receive FIFO empty interrupt mask */
IRQ_CARD = BIT(19), /*!< interrupt mask */
IRQ_CARD_LINE = BIT(20), /*!< interrupt mask */
IRQ_GEOMETRY_FIFO = BIT(21), /*!< geometry FIFO interrupt mask */
IRQ_LID = BIT(22), /*!< interrupt mask */
IRQ_SPI = BIT(23), /*!< SPI interrupt mask */
IRQ_WIFI = BIT(24), /*!< WIFI interrupt mask (ARM7)*/
IRQ_ALL = (~0)
};
#define MAX_INTERRUPTS 25
typedef enum IRQ_MASKS IRQ_MASK;
/*! \def REG_IE
\brief Interrupt Enable Register.
This is the activation mask for the internal interrupts. Unless
the corresponding bit is set, the IRQ will be masked out.
*/
#define REG_IE (*(vuint32*)0x04000210)
/*! \def REG_IF
\brief Interrupt Flag Register.
Since there is only one hardware interrupt vector, the IF register
contains flags to indicate when a particular of interrupt has occured.
To acknowledge processing interrupts, set IF to the value of the
interrupt handled.
*/
#define REG_IF (*(vuint32*)0x04000214)
/*! \def REG_IME
\brief Interrupt Master Enable Register.
When bit 0 is clear, all interrupts are masked. When it is 1,
interrupts will occur if not masked out in REG_IE.
*/
#define REG_IME (*(vuint16*)0x04000208)
/*! \enum IME_VALUE
\brief values allowed for REG_IME
*/
enum IME_VALUE {
IME_DISABLE = 0, /*!< Disable all interrupts. */
IME_ENABLE = 1, /*!< Enable all interrupts not masked out in REG_IE */
};
#ifdef __cplusplus
extern "C" {
#endif
extern VoidFunctionPointer __irq_vector[];
extern vuint32 __irq_flags[];
#define VBLANK_INTR_WAIT_FLAGS *(__irq_flags)
#define IRQ_HANDLER *(__irq_vector)
struct IntTable{IntFn handler; u32 mask;};
/*! \fn irqInit(void)
\brief Initialise the libnds interrupt system.
Call this function at the start of any application which requires interrupt support.
This function should be used in preference to irqInitHandler.
*/
void irqInit(void);
/*! \fn irqSet(IRQ_MASK irq, VoidFunctionPointer handler)
\brief Add a handler for the given interrupt mask.
Specify the handler to use for the given interrupt. This only works with
the default interrupt handler, do not mix the use of this routine with a
user-installed IRQ handler.
\param irq Mask associated with the interrupt.
\param handler Address of the function to use as an interrupt service routine
\note
When any handler specifies using IRQ_VBLANK or IRQ_HBLANK, DISP_SR
is automatically updated to include the corresponding DISP_VBLANK_IRQ or DISP_HBLANK_IRQ.
\warning Only one IRQ_MASK can be specified with this function.
*/
void irqSet(IRQ_MASK irq, VoidFunctionPointer handler);
/*! \fn irqClear(IRQ_MASK irq)
\brief remove the handler associated with the interrupt mask irq.
\param irq Mask associated with the interrupt.
*/
void irqClear(IRQ_MASK irq);
/*! \fn irqInitHandler(VoidFunctionPointer handler)
\brief Install a user interrupt dispatcher.
This function installs the main interrupt function, all interrupts are serviced through this routine. For most
purposes the libnds interrupt dispacther should be used in preference to user code unless you know *exactly* what you're doing.
\param handler Address of the function to use as an interrupt dispatcher
\note the function *must* be ARM code
*/
void irqInitHandler(VoidFunctionPointer handler);
/*! \fn irqEnable(uint32 irq)
\brief Allow the given interrupt to occur.
\param irq The set of interrupt masks to enable.
\note Specify multiple interrupts to enable by ORing several IRQ_MASKS.
*/
void irqEnable(uint32 irq);
/*! \fn irqDisable(uint32 irq)
\brief Prevent the given interrupt from occuring.
\param irq The set of interrupt masks to disable.
\note Specify multiple interrupts to disable by ORing several IRQ_MASKS.
*/
void irqDisable(uint32 irq);
#ifdef __cplusplus
}
#endif
#endif //NDS_INTERRUPTS_INCLUDE
+157 -157
View File
@@ -1,157 +1,157 @@
/*---------------------------------------------------------------------------------
$Id$
Inter Processor Communication
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef NDS_IPC_INCLUDE
#define NDS_IPC_INCLUDE
#include <nds/jtypes.h>
//---------------------------------------------------------------------------------
typedef struct sTransferSoundData {
//---------------------------------------------------------------------------------
const void *data;
u32 len;
u32 rate;
u8 vol;
u8 pan;
u8 format;
u8 PADDING;
} TransferSoundData, * pTransferSoundData;
//---------------------------------------------------------------------------------
typedef struct sTransferSound {
//---------------------------------------------------------------------------------
TransferSoundData data[16];
u8 count;
u8 PADDING[3];
} TransferSound, * pTransferSound;
//---------------------------------------------------------------------------------
typedef struct sTransferRegion {
//---------------------------------------------------------------------------------
vint16 touchX, touchY; // TSC X, Y
vint16 touchXpx, touchYpx; // TSC X, Y pixel values
vint16 touchZ1, touchZ2; // TSC x-panel measurements
vuint16 tdiode1, tdiode2; // TSC temperature diodes
vuint32 temperature; // TSC computed temperature
uint16 buttons; // X, Y, /PENIRQ buttons
union {
vuint8 curtime[8]; // current time response from RTC
struct {
vu8 command;
vu8 year; //add 2000 to get 4 digit year
vu8 month; //1 to 12
vu8 day; //1 to (days in month)
vu8 weekday; // day of week
vu8 hours; //0 to 11 for AM, 52 to 63 for PM
vu8 minutes; //0 to 59
vu8 seconds; //0 to 59
} rtc;
} time;
vint32 unixTime;
uint16 battery; // battery life ?? hopefully. :)
uint16 aux; // i have no idea...
// Don't rely on these below, will change or be removed in the future
pTransferSound soundData;
vuint32 mailAddr;
vuint32 mailData;
vuint8 mailRead;
vuint8 mailBusy;
vuint32 mailSize;
} TransferRegion, * pTransferRegion;
static inline
TransferRegion volatile * getIPC(); // __attribute__ ((deprecated));
static inline
TransferRegion volatile * getIPC() {
return (TransferRegion volatile *)(0x027FF000);
}
#define IPC getIPC()
#define IPC_PEN_DOWN BIT(6)
#define IPC_X BIT(0)
#define IPC_Y BIT(1)
#define IPC_LID_CLOSED BIT(7)
//---------------------------------------------------------------------------------
// Synchronization register
//---------------------------------------------------------------------------------
#define REG_IPC_SYNC (*(vuint16*)0x04000180)
enum IPC_SYNC_BITS {
IPC_SYNC_IRQ_ENABLE = BIT(14),
IPC_SYNC_IRQ_REQUEST = BIT(13)
};
//---------------------------------------------------------------------------------
static inline void IPC_SendSync(unsigned int sync) {
//---------------------------------------------------------------------------------
REG_IPC_SYNC = (REG_IPC_SYNC & 0xf0ff) | (((sync) & 0x0f) << 8) | IPC_SYNC_IRQ_REQUEST;
}
//---------------------------------------------------------------------------------
static inline int IPC_GetSync() {
//---------------------------------------------------------------------------------
return REG_IPC_SYNC & 0x0f;
}
//---------------------------------------------------------------------------------
// fifo
//---------------------------------------------------------------------------------
#define REG_IPC_FIFO_TX (*(vu32*)0x4000188)
#define REG_IPC_FIFO_RX (*(vu32*)0x4100000)
#define REG_IPC_FIFO_CR (*(vu16*)0x4000184)
enum IPC_CONTROL_BITS {
IPC_FIFO_SEND_EMPTY = (1<<0),
IPC_FIFO_SEND_FULL = (1<<1),
IPC_FIFO_SEND_IRQ = (1<<2),
IPC_FIFO_SEND_CLEAR = (1<<3),
IPC_FIFO_RECV_EMPTY = (1<<8),
IPC_FIFO_RECV_FULL = (1<<9),
IPC_FIFO_RECV_IRQ = (1<<10),
IPC_FIFO_ERROR = (1<<14),
IPC_FIFO_ENABLE = (1<<15)
};
#endif // NDS_IPC_INCLUDE
/*---------------------------------------------------------------------------------
$Id$
Inter Processor Communication
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef NDS_IPC_INCLUDE
#define NDS_IPC_INCLUDE
#include <nds/jtypes.h>
//---------------------------------------------------------------------------------
typedef struct sTransferSoundData {
//---------------------------------------------------------------------------------
const void *data;
u32 len;
u32 rate;
u8 vol;
u8 pan;
u8 format;
u8 PADDING;
} TransferSoundData, * pTransferSoundData;
//---------------------------------------------------------------------------------
typedef struct sTransferSound {
//---------------------------------------------------------------------------------
TransferSoundData data[16];
u8 count;
u8 PADDING[3];
} TransferSound, * pTransferSound;
//---------------------------------------------------------------------------------
typedef struct sTransferRegion {
//---------------------------------------------------------------------------------
vint16 touchX, touchY; // TSC X, Y
vint16 touchXpx, touchYpx; // TSC X, Y pixel values
vint16 touchZ1, touchZ2; // TSC x-panel measurements
vuint16 tdiode1, tdiode2; // TSC temperature diodes
vuint32 temperature; // TSC computed temperature
uint16 buttons; // X, Y, /PENIRQ buttons
union {
vuint8 curtime[8]; // current time response from RTC
struct {
vu8 command;
vu8 year; //add 2000 to get 4 digit year
vu8 month; //1 to 12
vu8 day; //1 to (days in month)
vu8 weekday; // day of week
vu8 hours; //0 to 11 for AM, 52 to 63 for PM
vu8 minutes; //0 to 59
vu8 seconds; //0 to 59
} rtc;
} time;
vint32 unixTime;
uint16 battery; // battery life ?? hopefully. :)
uint16 aux; // i have no idea...
// Don't rely on these below, will change or be removed in the future
pTransferSound soundData;
vuint32 mailAddr;
vuint32 mailData;
vuint8 mailRead;
vuint8 mailBusy;
vuint32 mailSize;
} TransferRegion, * pTransferRegion;
static inline
TransferRegion volatile * getIPC(void); // __attribute__ ((deprecated));
static inline
TransferRegion volatile * getIPC(void) {
return (TransferRegion volatile *)(0x027FF000);
}
#define IPC getIPC()
#define IPC_PEN_DOWN BIT(6)
#define IPC_X BIT(0)
#define IPC_Y BIT(1)
#define IPC_LID_CLOSED BIT(7)
//---------------------------------------------------------------------------------
// Synchronization register
//---------------------------------------------------------------------------------
#define REG_IPC_SYNC (*(vuint16*)0x04000180)
enum IPC_SYNC_BITS {
IPC_SYNC_IRQ_ENABLE = BIT(14),
IPC_SYNC_IRQ_REQUEST = BIT(13)
};
//---------------------------------------------------------------------------------
static inline void IPC_SendSync(unsigned int sync) {
//---------------------------------------------------------------------------------
REG_IPC_SYNC = (REG_IPC_SYNC & 0xf0ff) | (((sync) & 0x0f) << 8) | IPC_SYNC_IRQ_REQUEST;
}
//---------------------------------------------------------------------------------
static inline int IPC_GetSync(void) {
//---------------------------------------------------------------------------------
return REG_IPC_SYNC & 0x0f;
}
//---------------------------------------------------------------------------------
// fifo
//---------------------------------------------------------------------------------
#define REG_IPC_FIFO_TX (*(vu32*)0x4000188)
#define REG_IPC_FIFO_RX (*(vu32*)0x4100000)
#define REG_IPC_FIFO_CR (*(vu16*)0x4000184)
enum IPC_CONTROL_BITS {
IPC_FIFO_SEND_EMPTY = (1<<0),
IPC_FIFO_SEND_FULL = (1<<1),
IPC_FIFO_SEND_IRQ = (1<<2),
IPC_FIFO_SEND_CLEAR = (1<<3),
IPC_FIFO_RECV_EMPTY = (1<<8),
IPC_FIFO_RECV_FULL = (1<<9),
IPC_FIFO_RECV_IRQ = (1<<10),
IPC_FIFO_ERROR = (1<<14),
IPC_FIFO_ENABLE = (1<<15)
};
#endif // NDS_IPC_INCLUDE
@@ -1,140 +1,140 @@
/*---------------------------------------------------------------------------------
$Id$
jtypes.h -- Common types (and a few useful macros)
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
Chris Double (doublec)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef NDS_JTYPES_INCLUDE
#define NDS_JTYPES_INCLUDE
//---------------------------------------------------------------------------------
#define PACKED __attribute__ ((packed))
#define packed_struct struct PACKED
//---------------------------------------------------------------------------------
// libgba compatible section macros
//---------------------------------------------------------------------------------
#define ITCM_CODE __attribute__((section(".itcm"), long_call))
#define DTCM_DATA __attribute__((section(".dtcm")))
#define DTCM_BSS __attribute__((section(".sbss")))
#define ALIGN(m) __attribute__((aligned (m)))
#define PACKED __attribute__ ((packed))
#define packed_struct struct PACKED
//---------------------------------------------------------------------------------
// These are linked to the bin2o macro in the Makefile
//---------------------------------------------------------------------------------
#define GETRAW(name) (name)
#define GETRAWSIZE(name) ((int)name##_size)
#define GETRAWEND(name) ((int)name##_end)
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define BIT(n) (1 << (n))
// define libnds types in terms of stdint
#include <stdint.h>
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
typedef float float32;
typedef double float64;
typedef volatile uint8_t vuint8;
typedef volatile uint16_t vuint16;
typedef volatile uint32_t vuint32;
typedef volatile uint64_t vuint64;
typedef volatile int8_t vint8;
typedef volatile int16_t vint16;
typedef volatile int32_t vint32;
typedef volatile int64_t vint64;
typedef volatile float32 vfloat32;
typedef volatile float64 vfloat64;
typedef uint8_t byte;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
typedef volatile s8 vs8;
typedef volatile s16 vs16;
typedef volatile s32 vs32;
typedef volatile s64 vs64;
typedef struct touchPosition {
int16 x;
int16 y;
int16 px;
int16 py;
int16 z1;
int16 z2;
} touchPosition;
#ifndef __cplusplus
/** C++ compatible bool for C
*/
typedef enum { false, true } bool;
#endif
// Handy function pointer typedefs
typedef void ( * IntFn)(void);
typedef void (* VoidFunctionPointer)(void);
typedef void (* fp)(void);
//---------------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------
$Id$
jtypes.h -- Common types (and a few useful macros)
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
Chris Double (doublec)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#ifndef NDS_JTYPES_INCLUDE
#define NDS_JTYPES_INCLUDE
//---------------------------------------------------------------------------------
#define PACKED __attribute__ ((packed))
#define packed_struct struct PACKED
//---------------------------------------------------------------------------------
// libgba compatible section macros
//---------------------------------------------------------------------------------
#define ITCM_CODE __attribute__((section(".itcm"), long_call))
#define DTCM_DATA __attribute__((section(".dtcm")))
#define DTCM_BSS __attribute__((section(".sbss")))
#define ALIGN(m) __attribute__((aligned (m)))
#define PACKED __attribute__ ((packed))
#define packed_struct struct PACKED
//---------------------------------------------------------------------------------
// These are linked to the bin2o macro in the Makefile
//---------------------------------------------------------------------------------
#define GETRAW(name) (name)
#define GETRAWSIZE(name) ((int)name##_size)
#define GETRAWEND(name) ((int)name##_end)
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define BIT(n) (1 << (n))
// define libnds types in terms of stdint
#include <stdint.h>
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
typedef float float32;
typedef double float64;
typedef volatile uint8_t vuint8;
typedef volatile uint16_t vuint16;
typedef volatile uint32_t vuint32;
typedef volatile uint64_t vuint64;
typedef volatile int8_t vint8;
typedef volatile int16_t vint16;
typedef volatile int32_t vint32;
typedef volatile int64_t vint64;
typedef volatile float32 vfloat32;
typedef volatile float64 vfloat64;
typedef uint8_t byte;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
typedef volatile s8 vs8;
typedef volatile s16 vs16;
typedef volatile s32 vs32;
typedef volatile s64 vs64;
typedef struct touchPosition {
int16 x;
int16 y;
int16 px;
int16 py;
int16 z1;
int16 z2;
} touchPosition;
#ifndef __cplusplus
/** C++ compatible bool for C
*/
typedef enum { false, true } bool;
#endif
// Handy function pointer typedefs
typedef void ( * IntFn)(void);
typedef void (* VoidFunctionPointer)(void);
typedef void (* fp)(void);
//---------------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------------
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,206 +1,206 @@
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file timers.h
\brief Contains defines and macros for ARM7 and ARM9 timer operation.
The timers are fed with a 33.4 MHz source on the ARM9. The ARM7
timing hasn't been tested yet, but is likely to be the same.
*/
//---------------------------------------------------------------------------------
#ifndef NDS_TIMERS_INCLUDE
#define NDS_TIMERS_INCLUDE
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
//---------------------------------------------------------------------------------
#include <nds/jtypes.h>
// Timers
//! A macro that calculates %TIMER_DATA(n) settings for a given frequency of n.
/*! Use the appropriate macro depending on clock divider: \n
<ul>
<li> %TIMER_FREQ(f) </li>
<li> %TIMER_FREQ_64(f) </li>
<li> %TIMER_FREQ_256(f) </li>
<li> %TIMER_FREQ_1024(f) </li>
</ul>
Clock divider is controlled by %TIMER_CR(n) \n
\n
<b>Example Usage:</b>
%TIMER_DATA(0) = %TIMER_FREQ(freq_in_hz); \n
%TIMER_CR(0) = %TIMER_DIV1 | %TIMER_ENABLE; \n
\n
Max frequency is: 33554432Hz\n
Min frequency is: 512Hz\n
*/
#define TIMER_FREQ(n) (-0x2000000/(n))
//! A macro that calculates %TIMER_DATA(n) settings for a given frequency of n.
/*! Use the appropriate macro depending on clock divider: \n
<ul>
<li> %TIMER_FREQ(f) </li>
<li> %TIMER_FREQ_64(f) </li>
<li> %TIMER_FREQ_256(f) </li>
<li> %TIMER_FREQ_1024(f) </li>
</ul>
Clock divider is controlled by %TIMER_CR(n) \n
\n
<b>Example Usage:</b>
%TIMER_DATA(x) = %TIMER_FREQ_64(freq_in_hz)\n
\n
Max frequency is: 524288Hz\n
Min frequency is: 8Hz\n
*/
#define TIMER_FREQ_64(n) (-(0x2000000>>6)/(n))
//! A macro that calculates %TIMER_DATA(n) settings for a given frequency of n.
/*! Use the appropriate macro depending on clock divider: \n
<ul>
<li> %TIMER_FREQ(f) </li>
<li> %TIMER_FREQ_64(f) </li>
<li> %TIMER_FREQ_256(f) </li>
<li> %TIMER_FREQ_1024(f) </li>
</ul> <p>
Clock divider is controlled by %TIMER_CR(n) \n
\n
<b>Example Usage:</b>
%TIMER_DATA(x) = %TIMER_FREQ_256(freq_in_hz)\n
\n
Max frequency is: 131072Hz\n
Min frequency is: 2Hz\n
*/
#define TIMER_FREQ_256(n) (-(0x2000000>>8)/(n))
//! A macro that calculates %TIMER_DATA(n) settings for a given frequency of n.
/*! Use the appropriate macro depending on clock divider: \n
<ul>
<li> %TIMER_FREQ(f) </li>
<li> %TIMER_FREQ_64(f) </li>
<li> %TIMER_FREQ_256(f) </li>
<li> TIMER_FREQ_1024(f) </li>
</ul>
Clock divider is controlled by %TIMER_CR(n) \n
\n
<b>Example Usage:</b>
%TIMER_DATA(x) = %TIMER_FREQ_1024(freq_in_hz)\n
\n
Max frequency is: 32768Hz\n
Min frequency is: 0.5Hz\n
*/
#define TIMER_FREQ_1024(n) (-(0x2000000>>10)/(n))
//! Same as %TIMER_DATA(0).
#define TIMER0_DATA (*(vuint16*)0x04000100)
//! Same as %TIMER_DATA(1).
#define TIMER1_DATA (*(vuint16*)0x04000104)
//! Same as %TIMER_DATA(2).
#define TIMER2_DATA (*(vuint16*)0x04000108)
//! Same as %TIMER_DATA(3).
#define TIMER3_DATA (*(vuint16*)0x0400010C)
//! Returns a dereferenced pointer to the data register for timer number "n".
/*! \see TIMER_CR(n)
\see TIMER_FREQ(n)
%TIMER_DATA(n) when set will latch that value into the counter. Everytime the
counter rolls over %TIMER_DATA(0) will return to the latched value. This allows
you to control the frequency of the timer using the following formula:\n
%TIMER_DATA(x) = -(0x2000000/(freq * divider)); \n
\n
<b>Example Usage:</b>
%TIMER_DATA(0) = value; were 0 can be 0 through 3 and value is 16 bits.
*/
#define TIMER_DATA(n) (*(vuint16*)(0x04000100+((n)<<2)))
// Timer control registers
//! Same as %TIMER_CR(0).
#define TIMER0_CR (*(vuint16*)0x04000102)
//! Same as %TIMER_CR(1).
#define TIMER1_CR (*(vuint16*)0x04000106)
//! Same as %TIMER_CR(2).
#define TIMER2_CR (*(vuint16*)0x0400010A)
//! Same as %TIMER_CR(3).
#define TIMER3_CR (*(vuint16*)0x0400010E)
//! Returns a dereferenced pointer to the data register for timer control Register.
/*! <b>Example Usage:</b> %TIMER_CR(x) = %TIMER_ENABLE | %TIMER_DIV_64; \n
\n
Possible bit defines: \n
\see TIMER_ENABLE
\see TIMER_IRQ_REQ
\see TIMER_DIV_1
\see TIMER_DIV_64
\see TIMER_DIV_256
\see TIMER_DIV_1024
*/
#define TIMER_CR(n) (*(vuint16*)(0x04000102+((n)<<2)))
//! Enables the timer.
#define TIMER_ENABLE (1<<7)
//! Causes the timer to request an Interupt on overflow.
#define TIMER_IRQ_REQ (1<<6)
//! When set will cause the timer to count when the timer below overflows (unavailable for timer 0).
#define TIMER_CASCADE (1<<2)
//! Causes the timer to count at 33.514Mhz.
#define TIMER_DIV_1 (0)
//! Causes the timer to count at (33.514 / 64) Mhz.
#define TIMER_DIV_64 (1)
//! Causes the timer to count at (33.514 / 256) Mhz.
#define TIMER_DIV_256 (2)
//! Causes the timer to count at (33.514 / 1024)Mhz.
#define TIMER_DIV_1024 (3)
//---------------------------------------------------------------------------------
#ifdef __cplusplus
}
#endif
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
/*! \file timers.h
\brief Contains defines and macros for ARM7 and ARM9 timer operation.
The timers are fed with a 33.4 MHz source on the ARM9. The ARM7
timing hasn't been tested yet, but is likely to be the same.
*/
//---------------------------------------------------------------------------------
#ifndef NDS_TIMERS_INCLUDE
#define NDS_TIMERS_INCLUDE
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
//---------------------------------------------------------------------------------
#include <nds/jtypes.h>
// Timers
//! A macro that calculates %TIMER_DATA(n) settings for a given frequency of n.
/*! Use the appropriate macro depending on clock divider: \n
<ul>
<li> %TIMER_FREQ(f) </li>
<li> %TIMER_FREQ_64(f) </li>
<li> %TIMER_FREQ_256(f) </li>
<li> %TIMER_FREQ_1024(f) </li>
</ul>
Clock divider is controlled by %TIMER_CR(n) \n
\n
<b>Example Usage:</b>
%TIMER_DATA(0) = %TIMER_FREQ(freq_in_hz); \n
%TIMER_CR(0) = %TIMER_DIV1 | %TIMER_ENABLE; \n
\n
Max frequency is: 33554432Hz\n
Min frequency is: 512Hz\n
*/
#define TIMER_FREQ(n) (-0x2000000/(n))
//! A macro that calculates %TIMER_DATA(n) settings for a given frequency of n.
/*! Use the appropriate macro depending on clock divider: \n
<ul>
<li> %TIMER_FREQ(f) </li>
<li> %TIMER_FREQ_64(f) </li>
<li> %TIMER_FREQ_256(f) </li>
<li> %TIMER_FREQ_1024(f) </li>
</ul>
Clock divider is controlled by %TIMER_CR(n) \n
\n
<b>Example Usage:</b>
%TIMER_DATA(x) = %TIMER_FREQ_64(freq_in_hz)\n
\n
Max frequency is: 524288Hz\n
Min frequency is: 8Hz\n
*/
#define TIMER_FREQ_64(n) (-(0x2000000>>6)/(n))
//! A macro that calculates %TIMER_DATA(n) settings for a given frequency of n.
/*! Use the appropriate macro depending on clock divider: \n
<ul>
<li> %TIMER_FREQ(f) </li>
<li> %TIMER_FREQ_64(f) </li>
<li> %TIMER_FREQ_256(f) </li>
<li> %TIMER_FREQ_1024(f) </li>
</ul> <p>
Clock divider is controlled by %TIMER_CR(n) \n
\n
<b>Example Usage:</b>
%TIMER_DATA(x) = %TIMER_FREQ_256(freq_in_hz)\n
\n
Max frequency is: 131072Hz\n
Min frequency is: 2Hz\n
*/
#define TIMER_FREQ_256(n) (-(0x2000000>>8)/(n))
//! A macro that calculates %TIMER_DATA(n) settings for a given frequency of n.
/*! Use the appropriate macro depending on clock divider: \n
<ul>
<li> %TIMER_FREQ(f) </li>
<li> %TIMER_FREQ_64(f) </li>
<li> %TIMER_FREQ_256(f) </li>
<li> TIMER_FREQ_1024(f) </li>
</ul>
Clock divider is controlled by %TIMER_CR(n) \n
\n
<b>Example Usage:</b>
%TIMER_DATA(x) = %TIMER_FREQ_1024(freq_in_hz)\n
\n
Max frequency is: 32768Hz\n
Min frequency is: 0.5Hz\n
*/
#define TIMER_FREQ_1024(n) (-(0x2000000>>10)/(n))
//! Same as %TIMER_DATA(0).
#define TIMER0_DATA (*(vuint16*)0x04000100)
//! Same as %TIMER_DATA(1).
#define TIMER1_DATA (*(vuint16*)0x04000104)
//! Same as %TIMER_DATA(2).
#define TIMER2_DATA (*(vuint16*)0x04000108)
//! Same as %TIMER_DATA(3).
#define TIMER3_DATA (*(vuint16*)0x0400010C)
//! Returns a dereferenced pointer to the data register for timer number "n".
/*! \see TIMER_CR(n)
\see TIMER_FREQ(n)
%TIMER_DATA(n) when set will latch that value into the counter. Everytime the
counter rolls over %TIMER_DATA(0) will return to the latched value. This allows
you to control the frequency of the timer using the following formula:\n
%TIMER_DATA(x) = -(0x2000000/(freq * divider)); \n
\n
<b>Example Usage:</b>
%TIMER_DATA(0) = value; were 0 can be 0 through 3 and value is 16 bits.
*/
#define TIMER_DATA(n) (*(vuint16*)(0x04000100+((n)<<2)))
// Timer control registers
//! Same as %TIMER_CR(0).
#define TIMER0_CR (*(vuint16*)0x04000102)
//! Same as %TIMER_CR(1).
#define TIMER1_CR (*(vuint16*)0x04000106)
//! Same as %TIMER_CR(2).
#define TIMER2_CR (*(vuint16*)0x0400010A)
//! Same as %TIMER_CR(3).
#define TIMER3_CR (*(vuint16*)0x0400010E)
//! Returns a dereferenced pointer to the data register for timer control Register.
/*! <b>Example Usage:</b> %TIMER_CR(x) = %TIMER_ENABLE | %TIMER_DIV_64; \n
\n
Possible bit defines: \n
\see TIMER_ENABLE
\see TIMER_IRQ_REQ
\see TIMER_DIV_1
\see TIMER_DIV_64
\see TIMER_DIV_256
\see TIMER_DIV_1024
*/
#define TIMER_CR(n) (*(vuint16*)(0x04000102+((n)<<2)))
//! Enables the timer.
#define TIMER_ENABLE (1<<7)
//! Causes the timer to request an Interupt on overflow.
#define TIMER_IRQ_REQ (1<<6)
//! When set will cause the timer to count when the timer below overflows (unavailable for timer 0).
#define TIMER_CASCADE (1<<2)
//! Causes the timer to count at 33.514Mhz.
#define TIMER_DIV_1 (0)
//! Causes the timer to count at (33.514 / 64) Mhz.
#define TIMER_DIV_64 (1)
//! Causes the timer to count at (33.514 / 256) Mhz.
#define TIMER_DIV_256 (2)
//! Causes the timer to count at (33.514 / 1024)Mhz.
#define TIMER_DIV_1024 (3)
//---------------------------------------------------------------------------------
#ifdef __cplusplus
}
#endif
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------------
@@ -1,27 +1,27 @@
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include "nds/arm7/audio.h"
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include "nds/arm7/audio.h"
File diff suppressed because it is too large Load Diff
@@ -1,115 +1,115 @@
/*---------------------------------------------------------------------------------
$Id$
Microphone control for the ARM7
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
Chris Double (doublec)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include <nds/arm7/audio.h>
#include <nds/timers.h>
//---------------------------------------------------------------------------------
// Turn on the Microphone Amp. Code based on neimod's example.
//---------------------------------------------------------------------------------
void PM_SetAmp(u8 control) {
//---------------------------------------------------------------------------------
SerialWaitBusy();
REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz | SPI_CONTINUOUS;
REG_SPIDATA = PM_AMP_OFFSET;
SerialWaitBusy();
REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz;
REG_SPIDATA = control;
}
//---------------------------------------------------------------------------------
// Read a byte from the microphone. Code based on neimod's example.
//---------------------------------------------------------------------------------
u8 MIC_ReadData() {
//---------------------------------------------------------------------------------
u16 result, result2;
SerialWaitBusy();
REG_SPICNT = SPI_ENABLE | SPI_DEVICE_MICROPHONE | SPI_BAUD_2MHz | SPI_CONTINUOUS;
REG_SPIDATA = 0xEC; // Touchscreen command format for AUX
SerialWaitBusy();
REG_SPIDATA = 0x00;
SerialWaitBusy();
result = REG_SPIDATA;
REG_SPICNT = SPI_ENABLE | SPI_DEVICE_TOUCH | SPI_BAUD_2MHz;
REG_SPIDATA = 0x00;
SerialWaitBusy();
result2 = REG_SPIDATA;
return (((result & 0x7F) << 1) | ((result2>>7)&1));
}
static u8* microphone_buffer = 0;
static int microphone_buffer_length = 0;
static int current_length = 0;
//---------------------------------------------------------------------------------
void StartRecording(u8* buffer, int length) {
//---------------------------------------------------------------------------------
microphone_buffer = buffer;
microphone_buffer_length = length;
current_length = 0;
MIC_On();
// Setup a 16kHz timer
TIMER0_DATA = 0xF7CF;
TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1 | TIMER_IRQ_REQ;
}
//---------------------------------------------------------------------------------
int StopRecording() {
//---------------------------------------------------------------------------------
TIMER0_CR &= ~TIMER_ENABLE;
MIC_Off();
microphone_buffer = 0;
return current_length;
}
//---------------------------------------------------------------------------------
void ProcessMicrophoneTimerIRQ() {
//---------------------------------------------------------------------------------
if(microphone_buffer && microphone_buffer_length > 0) {
// Read data from the microphone. Data from the Mic is unsigned, flipping
// the highest bit makes it signed.
*microphone_buffer++ = MIC_ReadData() ^ 0x80;
--microphone_buffer_length;
current_length++;
}
}
/*---------------------------------------------------------------------------------
$Id$
Microphone control for the ARM7
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
Chris Double (doublec)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include <nds/arm7/audio.h>
#include <nds/timers.h>
//---------------------------------------------------------------------------------
// Turn on the Microphone Amp. Code based on neimod's example.
//---------------------------------------------------------------------------------
void PM_SetAmp(u8 control) {
//---------------------------------------------------------------------------------
SerialWaitBusy();
REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz | SPI_CONTINUOUS;
REG_SPIDATA = PM_AMP_OFFSET;
SerialWaitBusy();
REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz;
REG_SPIDATA = control;
}
//---------------------------------------------------------------------------------
// Read a byte from the microphone. Code based on neimod's example.
//---------------------------------------------------------------------------------
u8 MIC_ReadData() {
//---------------------------------------------------------------------------------
u16 result, result2;
SerialWaitBusy();
REG_SPICNT = SPI_ENABLE | SPI_DEVICE_MICROPHONE | SPI_BAUD_2MHz | SPI_CONTINUOUS;
REG_SPIDATA = 0xEC; // Touchscreen command format for AUX
SerialWaitBusy();
REG_SPIDATA = 0x00;
SerialWaitBusy();
result = REG_SPIDATA;
REG_SPICNT = SPI_ENABLE | SPI_DEVICE_TOUCH | SPI_BAUD_2MHz;
REG_SPIDATA = 0x00;
SerialWaitBusy();
result2 = REG_SPIDATA;
return (((result & 0x7F) << 1) | ((result2>>7)&1));
}
static u8* microphone_buffer = 0;
static int microphone_buffer_length = 0;
static int current_length = 0;
//---------------------------------------------------------------------------------
void StartRecording(u8* buffer, int length) {
//---------------------------------------------------------------------------------
microphone_buffer = buffer;
microphone_buffer_length = length;
current_length = 0;
MIC_On();
// Setup a 16kHz timer
TIMER0_DATA = 0xF7CF;
TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1 | TIMER_IRQ_REQ;
}
//---------------------------------------------------------------------------------
int StopRecording() {
//---------------------------------------------------------------------------------
TIMER0_CR &= ~TIMER_ENABLE;
MIC_Off();
microphone_buffer = 0;
return current_length;
}
//---------------------------------------------------------------------------------
void ProcessMicrophoneTimerIRQ() {
//---------------------------------------------------------------------------------
if(microphone_buffer && microphone_buffer_length > 0) {
// Read data from the microphone. Data from the Mic is unsigned, flipping
// the highest bit makes it signed.
*microphone_buffer++ = MIC_ReadData() ^ 0x80;
--microphone_buffer_length;
current_length++;
}
}
File diff suppressed because it is too large Load Diff
@@ -1,71 +1,71 @@
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include <nds/arm7/serial.h>
#include <nds/system.h>
#include <string.h>
//---------------------------------------------------------------------------------
void readUserSettings() {
//---------------------------------------------------------------------------------
PERSONAL_DATA slot1;
PERSONAL_DATA slot2;
short slot1count, slot2count;
short slot1CRC, slot2CRC;
uint32 userSettingsBase;
readFirmware( 0x20, &userSettingsBase,2);
uint32 slot1Address = userSettingsBase * 8;
uint32 slot2Address = userSettingsBase * 8 + 0x100;
readFirmware( slot1Address , &slot1, sizeof(PERSONAL_DATA));
readFirmware( slot2Address , &slot2, sizeof(PERSONAL_DATA));
readFirmware( slot1Address + 0x70, &slot1count, 2);
readFirmware( slot2Address + 0x70, &slot2count, 2);
readFirmware( slot1Address + 0x72, &slot1CRC, 2);
readFirmware( slot2Address + 0x72, &slot2CRC, 2);
// default to slot 1 user Settings
void *currentSettings = &slot1;
short calc1CRC = swiCRC16( 0xffff, &slot1, sizeof(PERSONAL_DATA));
short calc2CRC = swiCRC16( 0xffff, &slot2, sizeof(PERSONAL_DATA));
// bail out if neither slot is valid
if ( calc1CRC != slot1CRC && calc2CRC != slot2CRC) return;
// if both slots are valid pick the most recent
if ( calc1CRC == slot1CRC && calc2CRC == slot2CRC ) {
currentSettings = (slot2count == (( slot2count + 1 ) & 0x7f) ? &slot2 : &slot1);
} else {
if ( calc2CRC == slot2CRC )
currentSettings = &slot2;
}
memcpy ( PersonalData, currentSettings, sizeof(PERSONAL_DATA));
}
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include <nds/arm7/serial.h>
#include <nds/system.h>
#include <string.h>
//---------------------------------------------------------------------------------
void readUserSettings() {
//---------------------------------------------------------------------------------
PERSONAL_DATA slot1;
PERSONAL_DATA slot2;
short slot1count, slot2count;
short slot1CRC, slot2CRC;
uint32 userSettingsBase;
readFirmware( 0x20, &userSettingsBase,2);
uint32 slot1Address = userSettingsBase * 8;
uint32 slot2Address = userSettingsBase * 8 + 0x100;
readFirmware( slot1Address , &slot1, sizeof(PERSONAL_DATA));
readFirmware( slot2Address , &slot2, sizeof(PERSONAL_DATA));
readFirmware( slot1Address + 0x70, &slot1count, 2);
readFirmware( slot2Address + 0x70, &slot2count, 2);
readFirmware( slot1Address + 0x72, &slot1CRC, 2);
readFirmware( slot2Address + 0x72, &slot2CRC, 2);
// default to slot 1 user Settings
void *currentSettings = &slot1;
short calc1CRC = swiCRC16( 0xffff, &slot1, sizeof(PERSONAL_DATA));
short calc2CRC = swiCRC16( 0xffff, &slot2, sizeof(PERSONAL_DATA));
// bail out if neither slot is valid
if ( calc1CRC != slot1CRC && calc2CRC != slot2CRC) return;
// if both slots are valid pick the most recent
if ( calc1CRC == slot1CRC && calc2CRC == slot2CRC ) {
currentSettings = (slot2count == (( slot2count + 1 ) & 0x7f) ? &slot2 : &slot1);
} else {
if ( calc2CRC == slot2CRC )
currentSettings = &slot2;
}
memcpy ( PersonalData, currentSettings, sizeof(PERSONAL_DATA));
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,88 +1,88 @@
/*---------------------------------------------------------------------------------
$Id$
BoxTest.c -- Code for performing hardware box test against viewing frustrum
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include <nds/arm9/video.h>
#include <nds/arm9/videoGL.h>
//---------------------------------------------------------------------------------
void BoxTest_Asynch(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth)
//---------------------------------------------------------------------------------
{
glPolyFmt(BIT(12) | BIT(13));
glBegin(GL_TRIANGLES);
glEnd();
GFX_BOX_TEST = VERTEX_PACK(x, y);
GFX_BOX_TEST = VERTEX_PACK(z, width);
GFX_BOX_TEST = VERTEX_PACK(height, depth);
}
//---------------------------------------------------------------------------------
void BoxTestf_Asynch(float x, float y, float z, float width, float height, float depth)
//---------------------------------------------------------------------------------
{
BoxTest_Asynch(floattov16(x), floattov16(y), floattov16(z),
floattov16(width), floattov16(height), floattov16(depth));
}
//---------------------------------------------------------------------------------
int BoxTestResult(void)
//---------------------------------------------------------------------------------
{
while(GFX_STATUS & BIT(0));
return (GFX_STATUS & BIT(1));
}
//---------------------------------------------------------------------------------
int BoxTest(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth)
//---------------------------------------------------------------------------------
{
glPolyFmt(BIT(12) | BIT(13));
glBegin(GL_TRIANGLES);
glEnd();
GFX_BOX_TEST = VERTEX_PACK(x, y);
GFX_BOX_TEST = VERTEX_PACK(z, width);
GFX_BOX_TEST = VERTEX_PACK(height, depth);
while(GFX_STATUS & BIT(0));
return (GFX_STATUS & BIT(1));
}
//---------------------------------------------------------------------------------
int BoxTestf(float x, float y, float z, float width, float height, float depth)
//---------------------------------------------------------------------------------
{
return BoxTest(floattov16(x), floattov16(y), floattov16(z),
floattov16(width), floattov16(height), floattov16(depth));
}
/*---------------------------------------------------------------------------------
$Id$
BoxTest.c -- Code for performing hardware box test against viewing frustrum
Copyright (C) 2005
Michael Noland (joat)
Jason Rogers (dovoto)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
---------------------------------------------------------------------------------*/
#include <nds/arm9/video.h>
#include <nds/arm9/videoGL.h>
//---------------------------------------------------------------------------------
void BoxTest_Asynch(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth)
//---------------------------------------------------------------------------------
{
glPolyFmt(BIT(12) | BIT(13));
glBegin(GL_TRIANGLES);
glEnd();
GFX_BOX_TEST = VERTEX_PACK(x, y);
GFX_BOX_TEST = VERTEX_PACK(z, width);
GFX_BOX_TEST = VERTEX_PACK(height, depth);
}
//---------------------------------------------------------------------------------
void BoxTestf_Asynch(float x, float y, float z, float width, float height, float depth)
//---------------------------------------------------------------------------------
{
BoxTest_Asynch(floattov16(x), floattov16(y), floattov16(z),
floattov16(width), floattov16(height), floattov16(depth));
}
//---------------------------------------------------------------------------------
int BoxTestResult(void)
//---------------------------------------------------------------------------------
{
while(GFX_STATUS & BIT(0));
return (GFX_STATUS & BIT(1));
}
//---------------------------------------------------------------------------------
int BoxTest(v16 x, v16 y, v16 z, v16 width, v16 height, v16 depth)
//---------------------------------------------------------------------------------
{
glPolyFmt(BIT(12) | BIT(13));
glBegin(GL_TRIANGLES);
glEnd();
GFX_BOX_TEST = VERTEX_PACK(x, y);
GFX_BOX_TEST = VERTEX_PACK(z, width);
GFX_BOX_TEST = VERTEX_PACK(height, depth);
while(GFX_STATUS & BIT(0));
return (GFX_STATUS & BIT(1));
}
//---------------------------------------------------------------------------------
int BoxTestf(float x, float y, float z, float width, float height, float depth)
//---------------------------------------------------------------------------------
{
return BoxTest(floattov16(x), floattov16(y), floattov16(z),
floattov16(width), floattov16(height), floattov16(depth));
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,27 +1,45 @@
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
/*---------------------------------------------------------------------------------
$Id$
Copyright (C) 2005
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
$Log$
Revision 1.1 2008/04/17 23:09:41 joel
2008-04-17 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am: Move .s files to .S
* dswifi/common/source/spinlock.S, libfat/source/disc_io/io_dldi.S,
libfat/source/disc_io/io_scsd_s.S, libnds/source/arm9/COS.S,
libnds/source/arm9/SIN.S, libnds/source/arm9/TAN.S,
libnds/source/arm9/dcache.S, libnds/source/arm9/default_font.S,
libnds/source/arm9/icache.S, libnds/source/common/biosCalls.S,
libnds/source/common/interruptDispatcher.S: New files.
* dswifi/common/source/spinlock.s, libfat/source/disc_io/io_dldi.s,
libfat/source/disc_io/io_scsd_s.s, libnds/source/arm9/COS.s,
libnds/source/arm9/SIN.s, libnds/source/arm9/TAN.s,
libnds/source/arm9/dcache.s, libnds/source/arm9/default_font.s,
libnds/source/arm9/exceptionHandler.s, libnds/source/arm9/icache.s,
libnds/source/common/biosCalls.s,
libnds/source/common/interruptDispatcher.s: Removed.
Revision 1.1 2008/04/16 18:37:33 joel
2008-04-16 Matthieu Bucchianeri <mbucchia@gmail.com>
@@ -159,132 +177,132 @@
touchscreen/reco.h, touchscreen/touchscreen.c,
touchscreen/touchscreen.h, wifi/compat.c, wifi/compat.h, wifi/wifi.c:
New files.
Revision 1.10 2007/08/11 06:00:23 wntrmute
make nesting really work
Revision 1.9 2007/01/10 15:48:27 wntrmute
remove unused code
Revision 1.8 2006/12/16 09:10:02 wntrmute
acknowledge interrupt before calling handler
Revision 1.7 2006/04/26 05:11:31 wntrmute
rebase dtcm, take __irq_flags and __irq_vector from linker script
move arm7 irq vector & irq flags to actual locations
Revision 1.6 2006/04/23 18:19:15 wntrmute
reworked interrupt code to allow dtcm moving
Revision 1.5 2005/12/12 13:01:55 wntrmute
disable interrupts on return from user handler
Revision 1.4 2005/10/21 22:43:42 wntrmute
restore REG_IME on exit from null handler
Revision 1.3 2005/09/27 18:21:53 wntrmute
safer nested interrupt support
Revision 1.2 2005/09/04 16:37:01 wntrmute
check for NULL handler
Revision 1.1 2005/09/03 17:09:35 wntrmute
added interworking aware interrupt dispatcher
---------------------------------------------------------------------------------*/
#ifdef ARM7
.text
#endif
#ifdef ARM9
.section .itcm,"ax",%progbits
#endif
.extern irqTable
.code 32
.global IntrMain
@---------------------------------------------------------------------------------
IntrMain:
@---------------------------------------------------------------------------------
mov r3, #0x4000000 @ REG_BASE
ldr r1, [r3, #0x208] @ r1 = IME
str r3, [r3, #0x208] @ disable IME
mrs r0, spsr
stmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
ldr r1, [r3,#0x210] @ REG_IE
ldr r2, [r3,#0x214] @ REG_IF
and r1,r1,r2
ldr r0,=__irq_flags @ defined by linker script
ldr r2,[r0]
orr r2,r2,r1
str r2,[r0]
ldr r2,=irqTable
@---------------------------------------------------------------------------------
findIRQ:
@---------------------------------------------------------------------------------
ldr r0, [r2, #4]
cmp r0,#0
beq no_handler
ands r0, r0, r1
bne jump_intr
add r2, r2, #8
b findIRQ
@---------------------------------------------------------------------------------
no_handler:
@---------------------------------------------------------------------------------
str r1, [r3, #0x0214] @ IF Clear
ldmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
str r1, [r3, #0x208] @ restore REG_IME
mov pc,lr
@---------------------------------------------------------------------------------
jump_intr:
@---------------------------------------------------------------------------------
ldr r1, [r2] @ user IRQ handler address
cmp r1, #0
bne got_handler
mov r1, r0
b no_handler
@---------------------------------------------------------------------------------
got_handler:
@---------------------------------------------------------------------------------
mrs r2, cpsr
bic r2, r2, #0xdf @ \__
orr r2, r2, #0x1f @ / --> Enable IRQ & FIQ. Set CPU mode to System.
msr cpsr,r2
str r0, [r3, #0x0214] @ IF Clear
push {lr}
adr lr, IntrRet
bx r1
@---------------------------------------------------------------------------------
IntrRet:
@---------------------------------------------------------------------------------
mov r3, #0x4000000 @ REG_BASE
str r3, [r3, #0x208] @ disable IME
pop {lr}
mrs r3, cpsr
bic r3, r3, #0xdf @ \__
orr r3, r3, #0x92 @ / --> Disable IRQ. Enable FIQ. Set CPU mode to IRQ.
msr cpsr, r3
ldmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
msr spsr, r0 @ restore spsr
str r1, [r3, #0x208] @ restore REG_IME
mov pc,lr
.pool
.end
Revision 1.10 2007/08/11 06:00:23 wntrmute
make nesting really work
Revision 1.9 2007/01/10 15:48:27 wntrmute
remove unused code
Revision 1.8 2006/12/16 09:10:02 wntrmute
acknowledge interrupt before calling handler
Revision 1.7 2006/04/26 05:11:31 wntrmute
rebase dtcm, take __irq_flags and __irq_vector from linker script
move arm7 irq vector & irq flags to actual locations
Revision 1.6 2006/04/23 18:19:15 wntrmute
reworked interrupt code to allow dtcm moving
Revision 1.5 2005/12/12 13:01:55 wntrmute
disable interrupts on return from user handler
Revision 1.4 2005/10/21 22:43:42 wntrmute
restore REG_IME on exit from null handler
Revision 1.3 2005/09/27 18:21:53 wntrmute
safer nested interrupt support
Revision 1.2 2005/09/04 16:37:01 wntrmute
check for NULL handler
Revision 1.1 2005/09/03 17:09:35 wntrmute
added interworking aware interrupt dispatcher
---------------------------------------------------------------------------------*/
#ifdef ARM7
.text
#endif
#ifdef ARM9
.section .itcm,"ax",%progbits
#endif
.extern irqTable
.code 32
.global IntrMain
@---------------------------------------------------------------------------------
IntrMain:
@---------------------------------------------------------------------------------
mov r3, #0x4000000 @ REG_BASE
ldr r1, [r3, #0x208] @ r1 = IME
str r3, [r3, #0x208] @ disable IME
mrs r0, spsr
stmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
ldr r1, [r3,#0x210] @ REG_IE
ldr r2, [r3,#0x214] @ REG_IF
and r1,r1,r2
ldr r0,=__irq_flags @ defined by linker script
ldr r2,[r0]
orr r2,r2,r1
str r2,[r0]
ldr r2,=irqTable
@---------------------------------------------------------------------------------
findIRQ:
@---------------------------------------------------------------------------------
ldr r0, [r2, #4]
cmp r0,#0
beq no_handler
ands r0, r0, r1
bne jump_intr
add r2, r2, #8
b findIRQ
@---------------------------------------------------------------------------------
no_handler:
@---------------------------------------------------------------------------------
str r1, [r3, #0x0214] @ IF Clear
ldmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
str r1, [r3, #0x208] @ restore REG_IME
mov pc,lr
@---------------------------------------------------------------------------------
jump_intr:
@---------------------------------------------------------------------------------
ldr r1, [r2] @ user IRQ handler address
cmp r1, #0
bne got_handler
mov r1, r0
b no_handler
@---------------------------------------------------------------------------------
got_handler:
@---------------------------------------------------------------------------------
mrs r2, cpsr
bic r2, r2, #0xdf @ \__
orr r2, r2, #0x1f @ / --> Enable IRQ & FIQ. Set CPU mode to System.
msr cpsr,r2
str r0, [r3, #0x0214] @ IF Clear
push {lr}
adr lr, IntrRet
bx r1
@---------------------------------------------------------------------------------
IntrRet:
@---------------------------------------------------------------------------------
mov r3, #0x4000000 @ REG_BASE
str r3, [r3, #0x208] @ disable IME
pop {lr}
mrs r3, cpsr
bic r3, r3, #0xdf @ \__
orr r3, r3, #0x92 @ / --> Disable IRQ. Enable FIQ. Set CPU mode to IRQ.
msr cpsr, r3
ldmfd sp!, {r0-r1,r3,lr} @ {spsr, IME, REG_BASE, lr_irq}
msr spsr, r0 @ restore spsr
str r1, [r3, #0x208] @ restore REG_IME
mov pc,lr
.pool
.end
+239 -239
View File
@@ -1,239 +1,239 @@
#include <nds.h>
#include "reco.h"
PA_StylusPosition PA_StylusPos[20000];
PA_RecoValues PA_Reco;
char PA_RecoShape[16];
u8 PA_UseGraffiti = true;
u8 PA_CustomReco = 0; // number of custom shapes
PA_FormType PA_CustomShape[200];
PA_RecoInfos PA_RecoInfo;
PA_FormType PA_Graffiti[PA_RECOTESTS] = {
{' ', "AAAAAAAAAAAAAAA"},
{'a', "FGGGGGFB;:;;;;;"},
{'b', "JJJJJIGC>:8=<62"},
{'c', "01234689;<>?@BC"},
{'d', "=995KJIFB?=;853"},
{'e', "1236;>@136;=?@A"},
{'f', "121111399998779"},
{'g', "235689;=@CFIJEA"},
{'h', "8999999;HFEA><:"},
{'i', "999999999999999"},
{'j', "999999998653100"},
{'k', "654320NIDCA?==="},
{'l', "999999988<AA@@@"},
{'m', "HGGEA<;EFDA=;99"},
{'n', "HHHIE<;;;<GIHHH"},
{'o', "4689;<?BDFHKMO0"},
{'p', "<KJIIIHGEB>;853"},
{'q', "4679<?CDFHKMJBA"},
{'r', "999IIIIGC?:53<="},
{'s', "0235:>?>>;73100"},
{'t', "AAAA@@@;8999999"},
{'u', "899:;<>ACEGHHIH"},
{'v', ";;:::::?FGGHHGF"},
{'w', "::;=BA<<@CDEFGH"},
{'x', ";;;;;;;;;;;;;;;"},
{'y', ">;=AFF899974OIF"},
{'z', ">A@@>843348?@AA"},
{'0', "35789;=AEGHIJKM"},
{'1', "CDEFFE988889999"},
{'2', "GDB@>:6546>AAAA"},
{'3', "CA>833A@=953210"},
{'4', "55558>@A@>97778"},
{'5', "00037:@@=;7310O"},
{'6', "346779;>@CFKN02"},
{'7', "AAAAAA@>9655556"},
{'8', "37;=;71MIECCGM1"},
{'9', "8<@CGL28<<;6311"},
{PA_BACKSPACE, "000000000000000"},
{PA_ENTER, "555555555555555"},
// {'?', "FCA@><8655799::"},
{'.', "LLLLLLLLLLLLLLL"}
};
void PA_AddStylusPos(u8 x, u8 y){
if (!((x == PA_StylusPos[PA_Reco.nvalues-1].x) && (y == PA_StylusPos[PA_Reco.nvalues-1].y))){
PA_StylusPos[PA_Reco.nvalues].x = x;
PA_StylusPos[PA_Reco.nvalues].y = y;
PA_Reco.nvalues++;
}
}
void PA_StylusLine(u8 x1, u8 y1, u8 x2, u8 y2){
int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py;
dx=x2-x1; /* the horizontal distance of the line */
dy=y2-y1; /* the vertical distance of the line */
dxabs = dx;
sdx = 1;
if (dx < 0) {
dxabs = -dx;
sdx = -1;
}
dyabs = dy;
sdy = 1;
if (dy < 0) {
dyabs = -dy;
sdy = -1;
}
x=dyabs>>1;
y=dxabs>>1;
px=x1;
py=y1;
PA_AddStylusPos(px, py);
if (dxabs>=dyabs) {
for(i=0;i<dxabs;i++) {
y+=dyabs;
if (y>=dxabs) {
y-=dxabs;
py+=sdy;
}
px+=sdx;
PA_AddStylusPos(px, py);
}
}
else {
for(i=0;i<dyabs;i++) {
x+=dxabs;
if (x>=dyabs) {
x-=dyabs;
px+=sdx;
}
py+=sdy;
PA_AddStylusPos(px, py);
}
}
}
#define PA_ShapeAddPoint(i, value){ \
points[i] = PA_StylusPos[value]; \
if (points[i].x < PA_RecoInfo.minX) PA_RecoInfo.minX = points[i].x; \
else if (points[i].x > PA_RecoInfo.maxX) PA_RecoInfo.maxX = points[i].x; \
if (points[i].y < PA_RecoInfo.minY) PA_RecoInfo.minY = points[i].y; \
else if (points[i].y > PA_RecoInfo.maxY) PA_RecoInfo.maxY = points[i].y; }
char PA_AnalyzeShape(void){
s32 i;
// for (i = 0; i < 32; i++) PA_OutputSimpleText(1, 0, i, " ");
PA_StylusPosition points[17];
for (i = 0; i < 16; i++){
PA_ShapeAddPoint(i, (PA_Reco.nvalues*i)>>4)
}
PA_ShapeAddPoint(16, PA_Reco.nvalues-1)
//points[16] = PA_StylusPos[PA_Reco.nvalues-1];
PA_RecoInfo.endX = PA_StylusPos[PA_Reco.nvalues-1].x; // last values
PA_RecoInfo.endY = PA_StylusPos[PA_Reco.nvalues-1].y; // last values
PA_RecoInfo.Length = PA_Reco.nvalues; // Total length
PA_RecoInfo.Angle = PA_GetAngle(points[0].x, points[0].y, points[16].x, points[16].y);
//Better values
if (PA_RecoInfo.minX > 1) PA_RecoInfo.minX-=2;
if (PA_RecoInfo.maxX <254) PA_RecoInfo.maxX+=2;
if (PA_RecoInfo.minY > 1) PA_RecoInfo.minY-=2;
if (PA_RecoInfo.maxY <190) PA_RecoInfo.maxY+=2;
u16 angles[15];
for (i = 0; i < 15; i++) angles[i] = PA_GetAngle(points[i+2].x, points[i+2].y, points[i].x, points[i].y);
for (i = 0; i < 15; i++) PA_RecoShape[i] = '0' + (((angles[i]+16)&511)>>4);
PA_RecoShape[15] = 0;
// printk("%s\n", PA_RecoShape);
u8 letter = 0; // 0 par défaut
s32 diff = 65000; // Diff max par défaut
u8 j;
if(PA_UseGraffiti){
for (j = 0; j < PA_RECOTESTS; j++){
s32 tempvalue = 0;
s32 tempdiff = 0;
for (i = 0; i < 15; i++) {
tempvalue = (PA_RecoShape[i]-PA_Graffiti[j].code[i])&31;
tempvalue -= (tempvalue >> 4)<<5; // normalise
if (tempvalue < 0) tempvalue = -tempvalue;
tempdiff += tempvalue; // value
}
if (tempdiff < diff){ // Nouvelle lettre !
diff = tempdiff;
letter = PA_Graffiti[j].letter;
}
}
}
if (PA_CustomReco > 0){
for (j = 0; j < PA_CustomReco; j++){
s32 tempvalue = 0;
s32 tempdiff = 0;
for (i = 0; i < 15; i++) {
tempvalue = (PA_RecoShape[i]-PA_CustomShape[j].code[i])&31;
tempvalue -= (tempvalue >> 4)<<5; // normalise
if (tempvalue < 0) tempvalue = -tempvalue;
tempdiff += tempvalue; // value
}
if (tempdiff < diff){ // Nouvelle lettre !
diff = tempdiff;
letter = PA_CustomShape[j].letter;
}
}
}
PA_RecoInfo.Difference = diff; // Difference to perfect shape
PA_RecoInfo.Shape = letter;
return letter;
}
int old_down = 0;
char PA_CheckLetter(int down, int x, int y){
if(!old_down && down){
PA_Reco.nvalues = 0; // Start over again
PA_Reco.oldn = 0;
PA_Reco.veryold = 0;
PA_RecoInfo.startX = PA_StylusPos[PA_Reco.nvalues].x = x; // start values
PA_RecoInfo.startY = PA_StylusPos[PA_Reco.nvalues].y = y;
PA_RecoInfo.minX = PA_RecoInfo.maxX = PA_RecoInfo.startX;
PA_RecoInfo.minY = PA_RecoInfo.maxY = PA_RecoInfo.startY;
PA_Reco.nvalues++;
}
else if(old_down && down) {
PA_StylusLine(PA_StylusPos[PA_Reco.nvalues-1].x, PA_StylusPos[PA_Reco.nvalues-1].y, x, y);
}
if(old_down && !down){ // Start analyzing...
PA_Reco.nvalues = PA_Reco.veryold;
old_down = down;
return PA_AnalyzeShape();
}
PA_Reco.veryold = PA_Reco.oldn;
PA_Reco.oldn = PA_Reco.nvalues;
old_down = down;
return 0;
}
#include <nds.h>
#include "reco.h"
PA_StylusPosition PA_StylusPos[20000];
PA_RecoValues PA_Reco;
char PA_RecoShape[16];
u8 PA_UseGraffiti = true;
u8 PA_CustomReco = 0; // number of custom shapes
PA_FormType PA_CustomShape[200];
PA_RecoInfos PA_RecoInfo;
PA_FormType PA_Graffiti[PA_RECOTESTS] = {
{' ', "AAAAAAAAAAAAAAA"},
{'a', "FGGGGGFB;:;;;;;"},
{'b', "JJJJJIGC>:8=<62"},
{'c', "01234689;<>?@BC"},
{'d', "=995KJIFB?=;853"},
{'e', "1236;>@136;=?@A"},
{'f', "121111399998779"},
{'g', "235689;=@CFIJEA"},
{'h', "8999999;HFEA><:"},
{'i', "999999999999999"},
{'j', "999999998653100"},
{'k', "654320NIDCA?==="},
{'l', "999999988<AA@@@"},
{'m', "HGGEA<;EFDA=;99"},
{'n', "HHHIE<;;;<GIHHH"},
{'o', "4689;<?BDFHKMO0"},
{'p', "<KJIIIHGEB>;853"},
{'q', "4679<?CDFHKMJBA"},
{'r', "999IIIIGC?:53<="},
{'s', "0235:>?>>;73100"},
{'t', "AAAA@@@;8999999"},
{'u', "899:;<>ACEGHHIH"},
{'v', ";;:::::?FGGHHGF"},
{'w', "::;=BA<<@CDEFGH"},
{'x', ";;;;;;;;;;;;;;;"},
{'y', ">;=AFF899974OIF"},
{'z', ">A@@>843348?@AA"},
{'0', "35789;=AEGHIJKM"},
{'1', "CDEFFE988889999"},
{'2', "GDB@>:6546>AAAA"},
{'3', "CA>833A@=953210"},
{'4', "55558>@A@>97778"},
{'5', "00037:@@=;7310O"},
{'6', "346779;>@CFKN02"},
{'7', "AAAAAA@>9655556"},
{'8', "37;=;71MIECCGM1"},
{'9', "8<@CGL28<<;6311"},
{PA_BACKSPACE, "000000000000000"},
{PA_ENTER, "555555555555555"},
// {'?', "FCA@><8655799::"},
{'.', "LLLLLLLLLLLLLLL"}
};
void PA_AddStylusPos(u8 x, u8 y){
if (!((x == PA_StylusPos[PA_Reco.nvalues-1].x) && (y == PA_StylusPos[PA_Reco.nvalues-1].y))){
PA_StylusPos[PA_Reco.nvalues].x = x;
PA_StylusPos[PA_Reco.nvalues].y = y;
PA_Reco.nvalues++;
}
}
void PA_StylusLine(u8 x1, u8 y1, u8 x2, u8 y2){
int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py;
dx=x2-x1; /* the horizontal distance of the line */
dy=y2-y1; /* the vertical distance of the line */
dxabs = dx;
sdx = 1;
if (dx < 0) {
dxabs = -dx;
sdx = -1;
}
dyabs = dy;
sdy = 1;
if (dy < 0) {
dyabs = -dy;
sdy = -1;
}
x=dyabs>>1;
y=dxabs>>1;
px=x1;
py=y1;
PA_AddStylusPos(px, py);
if (dxabs>=dyabs) {
for(i=0;i<dxabs;i++) {
y+=dyabs;
if (y>=dxabs) {
y-=dxabs;
py+=sdy;
}
px+=sdx;
PA_AddStylusPos(px, py);
}
}
else {
for(i=0;i<dyabs;i++) {
x+=dxabs;
if (x>=dyabs) {
x-=dyabs;
px+=sdx;
}
py+=sdy;
PA_AddStylusPos(px, py);
}
}
}
#define PA_ShapeAddPoint(i, value){ \
points[i] = PA_StylusPos[value]; \
if (points[i].x < PA_RecoInfo.minX) PA_RecoInfo.minX = points[i].x; \
else if (points[i].x > PA_RecoInfo.maxX) PA_RecoInfo.maxX = points[i].x; \
if (points[i].y < PA_RecoInfo.minY) PA_RecoInfo.minY = points[i].y; \
else if (points[i].y > PA_RecoInfo.maxY) PA_RecoInfo.maxY = points[i].y; }
char PA_AnalyzeShape(void){
s32 i;
// for (i = 0; i < 32; i++) PA_OutputSimpleText(1, 0, i, " ");
PA_StylusPosition points[17];
for (i = 0; i < 16; i++){
PA_ShapeAddPoint(i, (PA_Reco.nvalues*i)>>4)
}
PA_ShapeAddPoint(16, PA_Reco.nvalues-1)
//points[16] = PA_StylusPos[PA_Reco.nvalues-1];
PA_RecoInfo.endX = PA_StylusPos[PA_Reco.nvalues-1].x; // last values
PA_RecoInfo.endY = PA_StylusPos[PA_Reco.nvalues-1].y; // last values
PA_RecoInfo.Length = PA_Reco.nvalues; // Total length
PA_RecoInfo.Angle = PA_GetAngle(points[0].x, points[0].y, points[16].x, points[16].y);
//Better values
if (PA_RecoInfo.minX > 1) PA_RecoInfo.minX-=2;
if (PA_RecoInfo.maxX <254) PA_RecoInfo.maxX+=2;
if (PA_RecoInfo.minY > 1) PA_RecoInfo.minY-=2;
if (PA_RecoInfo.maxY <190) PA_RecoInfo.maxY+=2;
u16 angles[15];
for (i = 0; i < 15; i++) angles[i] = PA_GetAngle(points[i+2].x, points[i+2].y, points[i].x, points[i].y);
for (i = 0; i < 15; i++) PA_RecoShape[i] = '0' + (((angles[i]+16)&511)>>4);
PA_RecoShape[15] = 0;
// printk("%s\n", PA_RecoShape);
u8 letter = 0; // 0 par défaut
s32 diff = 65000; // Diff max par défaut
u8 j;
if(PA_UseGraffiti){
for (j = 0; j < PA_RECOTESTS; j++){
s32 tempvalue = 0;
s32 tempdiff = 0;
for (i = 0; i < 15; i++) {
tempvalue = (PA_RecoShape[i]-PA_Graffiti[j].code[i])&31;
tempvalue -= (tempvalue >> 4)<<5; // normalise
if (tempvalue < 0) tempvalue = -tempvalue;
tempdiff += tempvalue; // value
}
if (tempdiff < diff){ // Nouvelle lettre !
diff = tempdiff;
letter = PA_Graffiti[j].letter;
}
}
}
if (PA_CustomReco > 0){
for (j = 0; j < PA_CustomReco; j++){
s32 tempvalue = 0;
s32 tempdiff = 0;
for (i = 0; i < 15; i++) {
tempvalue = (PA_RecoShape[i]-PA_CustomShape[j].code[i])&31;
tempvalue -= (tempvalue >> 4)<<5; // normalise
if (tempvalue < 0) tempvalue = -tempvalue;
tempdiff += tempvalue; // value
}
if (tempdiff < diff){ // Nouvelle lettre !
diff = tempdiff;
letter = PA_CustomShape[j].letter;
}
}
}
PA_RecoInfo.Difference = diff; // Difference to perfect shape
PA_RecoInfo.Shape = letter;
return letter;
}
int old_down = 0;
char PA_CheckLetter(int down, int x, int y){
if(!old_down && down){
PA_Reco.nvalues = 0; // Start over again
PA_Reco.oldn = 0;
PA_Reco.veryold = 0;
PA_RecoInfo.startX = PA_StylusPos[PA_Reco.nvalues].x = x; // start values
PA_RecoInfo.startY = PA_StylusPos[PA_Reco.nvalues].y = y;
PA_RecoInfo.minX = PA_RecoInfo.maxX = PA_RecoInfo.startX;
PA_RecoInfo.minY = PA_RecoInfo.maxY = PA_RecoInfo.startY;
PA_Reco.nvalues++;
}
else if(old_down && down) {
PA_StylusLine(PA_StylusPos[PA_Reco.nvalues-1].x, PA_StylusPos[PA_Reco.nvalues-1].y, x, y);
}
if(old_down && !down){ // Start analyzing...
PA_Reco.nvalues = PA_Reco.veryold;
old_down = down;
return PA_AnalyzeShape();
}
PA_Reco.veryold = PA_Reco.oldn;
PA_Reco.oldn = PA_Reco.nvalues;
old_down = down;
return 0;
}